From: Neil Smith Date: Fri, 3 Jan 2014 20:37:14 +0000 (+0000) Subject: Started again with Rails 4 X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=36d9f3351a3b4e8159279445190e2287ffdea86c;p=feedcatcher.git Started again with Rails 4 --- diff --git a/.gitignore b/.gitignore index cc19b66..1506817 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,43 @@ -*~ -*log -database.yml -deploy.rb -*doc -tmp/* +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/*.log +/tmp + +*.rbc +*.sassc +.sass-cache +capybara-*.html +.rspec +/log +/tmp +/db/*.sqlite3 +/public/system +/coverage/ +/spec/tmp +**.orig +rerun.txt +pickle-email-*.html +config/initializers/secret_token.rb +config/secrets.yml + +## Environment normalisation: +/.bundle +/vendor/bundle + +# these should all be checked in to normalise the environment: +# Gemfile.lock, .ruby-version, .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc \ No newline at end of file diff --git a/Capfile b/Capfile deleted file mode 100644 index c36d48d..0000000 --- a/Capfile +++ /dev/null @@ -1,3 +0,0 @@ -load 'deploy' if respond_to?(:namespace) # cap2 differentiator -Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } -load 'config/deploy' \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..b2b01de --- /dev/null +++ b/Gemfile @@ -0,0 +1,45 @@ +source 'https://rubygems.org' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '4.0.2' + +# Use postgresql as the database for Active Record +gem 'pg' + +# Use SCSS for stylesheets +gem 'sass-rails', '~> 4.0.0' + +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' + +# Use CoffeeScript for .js.coffee assets and views +gem 'coffee-rails', '~> 4.0.0' + +# See https://github.com/sstephenson/execjs#readme for more supported runtimes +# gem 'therubyracer', platforms: :ruby + +# Use jquery as the JavaScript library +gem 'jquery-rails' + +# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks +gem 'turbolinks' + +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 1.2' + +group :doc do + # bundle exec rake doc:rails generates the API under doc/api. + gem 'sdoc', require: false +end + +# Use ActiveModel has_secure_password +# gem 'bcrypt-ruby', '~> 3.1.2' + +# Use unicorn as the app server +# gem 'unicorn' + +# Use Capistrano for deployment +# gem 'capistrano', group: :development + +# Use debugger +# gem 'debugger', group: [:development, :test] diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..27136cc --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,119 @@ +GEM + remote: https://rubygems.org/ + specs: + actionmailer (4.0.2) + actionpack (= 4.0.2) + mail (~> 2.5.4) + actionpack (4.0.2) + activesupport (= 4.0.2) + builder (~> 3.1.0) + erubis (~> 2.7.0) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + activemodel (4.0.2) + activesupport (= 4.0.2) + builder (~> 3.1.0) + activerecord (4.0.2) + activemodel (= 4.0.2) + activerecord-deprecated_finders (~> 1.0.2) + activesupport (= 4.0.2) + arel (~> 4.0.0) + activerecord-deprecated_finders (1.0.3) + activesupport (4.0.2) + i18n (~> 0.6, >= 0.6.4) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.37) + arel (4.0.1) + atomic (1.1.14) + builder (3.1.4) + coffee-rails (4.0.1) + coffee-script (>= 2.2.0) + railties (>= 4.0.0, < 5.0) + coffee-script (2.2.0) + coffee-script-source + execjs + coffee-script-source (1.6.3) + erubis (2.7.0) + execjs (2.0.2) + hike (1.2.3) + i18n (0.6.9) + jbuilder (1.5.3) + activesupport (>= 3.0.0) + multi_json (>= 1.2.0) + jquery-rails (3.0.4) + railties (>= 3.0, < 5.0) + thor (>= 0.14, < 2.0) + json (1.8.1) + mail (2.5.4) + mime-types (~> 1.16) + treetop (~> 1.4.8) + mime-types (1.25.1) + minitest (4.7.5) + multi_json (1.8.2) + pg (0.17.1) + polyglot (0.3.3) + rack (1.5.2) + rack-test (0.6.2) + rack (>= 1.0) + rails (4.0.2) + actionmailer (= 4.0.2) + actionpack (= 4.0.2) + activerecord (= 4.0.2) + activesupport (= 4.0.2) + bundler (>= 1.3.0, < 2.0) + railties (= 4.0.2) + sprockets-rails (~> 2.0.0) + railties (4.0.2) + actionpack (= 4.0.2) + activesupport (= 4.0.2) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (10.1.1) + rdoc (3.12.2) + json (~> 1.4) + sass (3.2.13) + sass-rails (4.0.1) + railties (>= 4.0.0, < 5.0) + sass (>= 3.1.10) + sprockets-rails (~> 2.0.0) + sdoc (0.3.20) + json (>= 1.1.3) + rdoc (~> 3.10) + sprockets (2.10.1) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.0.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (~> 2.8) + thor (0.18.1) + thread_safe (0.1.3) + atomic + tilt (1.4.1) + treetop (1.4.15) + polyglot + polyglot (>= 0.3.1) + turbolinks (2.1.0) + coffee-rails + tzinfo (0.3.38) + uglifier (2.4.0) + execjs (>= 0.3.0) + json (>= 1.8.0) + +PLATFORMS + ruby + +DEPENDENCIES + coffee-rails (~> 4.0.0) + jbuilder (~> 1.2) + jquery-rails + pg + rails (= 4.0.2) + sass-rails (~> 4.0.0) + sdoc + turbolinks + uglifier (>= 1.3.0) diff --git a/README.rdoc b/README.rdoc index e07ab78..dd4e97e 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,67 +1,28 @@ -== Welcome to Feedcatcher +== README -Feedcatcher is a lightweight RSS server that accepts write requests from anonymous clients. It was developed for the {Sense programming environment}[http://sense.open.ac.uk]. +This README would normally document whatever steps are necessary to get the +application up and running. -Feedcatcher was the first version of the RSS server. It has since been reimplemented, more robustly, by the {Open University}[http://www.open.ac.uk] for use in the {My Digital Life module}[http://www3.open.ac.uk/study/undergraduate/course/tu100.htm]. However, this version should still work with Sense. It's not been tested with the very latest versions, but nothing in that part of Sense has changed since it used this implementation of Feedcatcher. +Things you may want to cover: -Feel free to clone and modify this application. Let me know what you do with it! +* Ruby version -== Installation +* System dependencies -Feedcatcher is written in Rails 2.3.2 (vendored in) and runs on Ruby 1.8.7. I've not tried it with later versions of Ruby or Rails. Updating Ruby should be OK, but changing to Rails 3.x will probably break things. +* Configuration -You'll need to update the create the +database.yml+ and +deploy.rb+ files for your installation. You can use the +database.sample.yml+ and +deploy.sample.rb+ files as templates. In particular, +deploy.sample.rb+ still refers to when feedcatcher was stored in a Subversion repository. +* Database creation -== Instructions +* Database initialization -Visiting http://feedcatcher.example.com in a browser will give you an HTML view of the feeds available. +* How to run the test suite -Visiting http://feedcatcher.example.com/feed-a or http://feedcatcher.example.com/feed-a.html will show you the contents of that feed. The HTML pages also have a little form to allow you to update the contents of feeds. +* Services (job queues, cache servers, search engines, etc.) -Asking the server for RSS content will give you RSS content. That's most easily done with cURL. +* Deployment instructions -These give you HTML: - curl http://feedcatcher.example.com/ - curl http://feedcatcher.example.com/index - curl http://feedcatcher.example.com/index.html +* ... -These all give you RSS: - curl -H "Accept: application/rss+xml" http://feedcatcher.example.com/ - curl -H "Accept: application/rss+xml" http://feedcatcher.example.com/index - curl -H "Accept: application/rss+xml" http://feedcatcher.example.com/index.rss - curl http://feedcatcher.example.com/index.rss -These give you a feed: - curl -H "Accept: application/rss+xml" http://feedcatcher.example.com/test1 - curl -H "Accept: application/rss+xml" http://feedcatcher.example.com/test1.rss - curl http://feedcatcher.example.com/test1.rss - -These give you the same feed but as HTML: - curl http://feedcatcher.example.com/test1 - curl http://feedcatcher.example.com/test1.html - -This generates a 404 error: - curl -H "Accept: application/rss+xml" -D headers.txt \ http://feedcatcher.example.com/test%2099 -('test 99' is not a valid feed name) -(the -D saves the HTTP response header into the given file, so you can see it) - -This creates (or updates) a feed item: - curl -D headers.txt -H "Accept: application/rss+xml" \ - --data-urlencode "feed_name=test5" \ - --data-urlencode "title=test 5 item 2" \ - --data-urlencode "description=updated content"' \ - -d "commit=Update" \ - http://feedcatcher.example.com - -This deletes an item: - curl -D headers.txt -H "Accept: application/rss+xml" \ - --data-urlencode "feed_name=test5" \ - --data-urlencode "title=test 5 item 2" \ - --data-urlencode 'description=' \ - -d "commit=Update" \ - http://feedcatcher.example.com - -===Notes - -When you ask for HTML pages, the responses are likely to be redirects to the next page. You shouldn't get HTTP error codes. -Responses to POSTs made with "Accept: application/rss+xml" headers will often be empty, with the success or failure of the action indicated in the HTTP response code. +Please feel free to use a different markup language if you do not plan to run +rake doc:app. diff --git a/Rakefile b/Rakefile index 3bb0e85..fa0fdca 100644 --- a/Rakefile +++ b/Rakefile @@ -1,10 +1,6 @@ # 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 File.expand_path('../config/application', __FILE__) -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -require 'tasks/rails' +Feedcatcher::Application.load_tasks diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 0000000..d6925fa --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require turbolinks +//= require_tree . diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 0000000..3192ec8 --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,13 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the top of the + * compiled file, but it's generally better to create a new file per style scope. + * + *= require_self + *= require_tree . + */ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6635a3f..d83690e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,10 +1,5 @@ -# 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 + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/feed_controller.rb b/app/controllers/feed_controller.rb deleted file mode 100644 index 819dab1..0000000 --- a/app/controllers/feed_controller.rb +++ /dev/null @@ -1,115 +0,0 @@ -class FeedController < ApplicationController - - skip_before_filter :verify_authenticity_token - - def index - @feeds = FeedItem.find(:all, :select => 'DISTINCT feed_name') - respond_to do |format| - format.html - format.rss { render :layout => false } - end - end - - - def show - if FeedItem::valid_feed_name?(params[:feed_name]) - @feed_items = FeedItem.find_all_by_feed_name(params[:feed_name]) - @feed_name = params[:feed_name] - respond_to do |format| - if @feed_items == [] - flash[:notice] = "No items in feed #{params[:feed_name]}" - format.html { redirect_to index_url } - format.rss { render :layout => false } - else - format.html - format.rss { render :layout => false } - end - end - else - respond_to do |format| - flash[:notice] = "Invalid feed name" - format.html { redirect_to index_url } - format.rss { head :not_found} - end - end - end - - - def update - if FeedItem::valid_feed_name?(params[:feed_name]) - item = FeedItem.find_by_feed_name_and_title(params[:feed_name], params[:title]) - if item - if params[:description] == '' - destroy_item(item) - else - update_item(item) - end - else - create_item - end - else - respond_to do |format| - flash[:notice] = "Invalid feed name" - format.html { redirect_to index_url } - format.rss { head :not_found } - end - end - end - - - private - - - def create_item - item = FeedItem.new(:feed_name => params[:feed_name], - :title => params[:title], - :description => params[:description]) - item.save! - flash[:notice] = "Element #{params[:title]} created" - respond_to do |format| - format.html { redirect_to feed_url(params[:feed_name]) } - format.rss { head :ok } - end - rescue ActiveRecord::RecordInvalid => error - flash[:notice] = "Element #{params[:title]} could not be created" - respond_to do |format| - format.html { redirect_to feed_url(params[:feed_name]) } - format.rss { head :unprocessable_entity } - end - end - - - def update_item(item) - if item.update_attribute(:description, params[:description]) - flash[:notice] = "Element #{params[:title]} updated" - respond_to do |format| - format.html { redirect_to feed_url(params[:feed_name]) } - format.rss { head :ok } - end - else - flash[:notice] = "Element #{params[:title]} could not be updated" - respond_to do |format| - format.html { redirect_to feed_url(params[:feed_name]) } - format.rss { head :unprocessable_entity } - end - end - end - - - def destroy_item(item) - if item.destroy - flash[:notice] = "Element #{params[:title]} deleted" - respond_to do |format| - format.html { redirect_to feed_url(params[:feed_name]) } - format.rss { head :ok } - end - else - flash[:notice] = "Element #{params[:title]} could not be deleted" - respond_to do |format| - format.html { redirect_to feed_url(params[:feed_name]) } - format.rss { head :unprocessable_entity } - end - end - end - -end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 22a7940..de6be79 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,3 +1,2 @@ -# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end diff --git a/app/helpers/feed_helper.rb b/app/helpers/feed_helper.rb deleted file mode 100644 index 6709856..0000000 --- a/app/helpers/feed_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module FeedHelper -end diff --git a/app/mailers/.keep b/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/.keep b/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/feed_item.rb b/app/models/feed_item.rb deleted file mode 100644 index f18374f..0000000 --- a/app/models/feed_item.rb +++ /dev/null @@ -1,26 +0,0 @@ -class FeedItem < ActiveRecord::Base - - # require 'cgi' # needed for url decoding - - validates_presence_of :feed_name, :title, :description - validates_uniqueness_of :title, :scope => :feed_name - validate :feed_name_must_be_legal - - def FeedItem.valid_feed_name?(feed_name) - Rack::Utils::escape(feed_name) == feed_name and - Rack::Utils::unescape(feed_name) == feed_name and - feed_name != 'index' and - feed_name != 'show' and - feed_name != 'update' and - feed_name != 'action' - end - - private - - def feed_name_must_be_legal - unless FeedItem.valid_feed_name?(feed_name) - errors.add(:feed_name, 'is an invalid feed name') - end - end - -end diff --git a/app/views/feed/index.html.erb b/app/views/feed/index.html.erb deleted file mode 100644 index 8b2e8c1..0000000 --- a/app/views/feed/index.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -

Feeds available

- -<% form_tag :action => 'update' do %> -

Set feed <%= text_field_tag :feed_name, '', :size => 20 %> - to include <%= text_field_tag :title, '', :size => 30 %> - containing <%= text_field_tag :description, '', :size => 50 %> - <%= submit_tag 'Update' %>

-<% end %> - - \ No newline at end of file diff --git a/app/views/feed/index.rss.builder b/app/views/feed/index.rss.builder deleted file mode 100644 index a122ec0..0000000 --- a/app/views/feed/index.rss.builder +++ /dev/null @@ -1,17 +0,0 @@ -# index.rss.builder -xml.instruct! :xml, :version => "1.0" -xml.rss :version => "2.0" do - xml.channel do - xml.title "Feedcatcher" - xml.link index_url(:rss) - xml.description "Feeds available" - - for feed in @feeds - xml.item do - xml.title feed.feed_name - xml.link feed_url(feed.feed_name, :rss) - xml.guid feed_url(feed.feed_name, :rss) - end - end - end -end diff --git a/app/views/feed/show.html.erb b/app/views/feed/show.html.erb deleted file mode 100644 index 2a2b9b1..0000000 --- a/app/views/feed/show.html.erb +++ /dev/null @@ -1,17 +0,0 @@ -

Contents of feed <%= h params[:feed_name] %>

-

<%= link_to("List of all feeds", index_url) %>

- -<% form_tag :action => 'update' do %> -

Set feed <%= text_field_tag :feed_name, h(params[:feed_name]), :size => 20 %> - to include <%= text_field_tag :title, '', :size => 30 %> - containing <%= text_field_tag :description, '', :size => 50 %> - <%= submit_tag 'Update' %>

-<% end %> - - -
- <% for item in @feed_items %> -
<%= h item.title %>
-
<%= h item.description %>
- <% end %> -
diff --git a/app/views/feed/show.rss.builder b/app/views/feed/show.rss.builder deleted file mode 100644 index 88c0dd8..0000000 --- a/app/views/feed/show.rss.builder +++ /dev/null @@ -1,18 +0,0 @@ -# show.rss.builder -xml.instruct! :xml, :version => "1.0" -xml.rss :version => "2.0" do - xml.channel do - xml.title @feed_name - xml.link feed_url(@feed_name, :rss) - xml.description "The #{h @feed_name} feed" - - for item in @feed_items - xml.item do - xml.title item.title - xml.description item.description - xml.guid item.id, :isPermaLink => 'false' - xml.pubDate(item.updated_at.to_s(:rfc822)) - end - end - end -end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1f8b1b4..f11c29d 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,12 +1,14 @@ + - - Feedcatcher - <%= stylesheet_link_tag "feedcatcher", :media => :all %> - - - <% if flash[:notice] -%> -
<%= h flash[:notice] %>
- <% end -%> - <%= yield :layout %> - + + Feedcatcher + <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> + <%= javascript_include_tag "application", "data-turbolinks-track" => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + diff --git a/config.ru b/config.ru new file mode 100644 index 0000000..5bc2a61 --- /dev/null +++ b/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Rails.application diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 0000000..71c84ef --- /dev/null +++ b/config/application.rb @@ -0,0 +1,23 @@ +require File.expand_path('../boot', __FILE__) + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(:default, Rails.env) + +module Feedcatcher + class Application < Rails::Application + # 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. + + # 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. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # 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}').to_s] + # config.i18n.default_locale = :de + end +end diff --git a/config/boot.rb b/config/boot.rb index 0ad0f78..3596736 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,110 +1,4 @@ -# Don't change this file! -# Configure your app in config/environment.rb and config/environments/*.rb +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -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 - $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 - 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 - require 'rubygems' - min_version = '1.3.1' - 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 - -# All that for this: -Rails.boot! +require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) diff --git a/config/database.sample.yml b/config/database.sample.yml deleted file mode 100644 index db7f8b9..0000000 --- a/config/database.sample.yml +++ /dev/null @@ -1,49 +0,0 @@ -# MySQL. Versions 4.1 and 5.0 are recommended. -# -# Install the MySQL driver: -# gem install mysql -# On Mac OS X: -# sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql -# On Mac OS X Leopard: -# sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config -# This sets the ARCHFLAGS environment variable to your native architecture -# On Windows: -# gem install mysql -# Choose the win32 build. -# Install MySQL and put its /bin directory on your path. -# -# And be sure to use new-style password hashing: -# http://dev.mysql.com/doc/refman/5.0/en/old-client.html -development: - adapter: mysql - encoding: utf8 - reconnect: false - database: feedcatcher_development - pool: 5 - username: feedcatcher - password: - socket: /var/run/mysqld/mysqld.sock - -# 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: mysql - encoding: utf8 - reconnect: false - database: feedcatcher_test - pool: 5 - username: feedcatcher - password: - socket: /var/run/mysqld/mysqld.sock - -production: - adapter: mysql - encoding: utf8 - reconnect: false - database: feedcatcher_production - pool: 5 - username: feedcatcher - password: - socket: /var/run/mysqld/mysqld.sock - diff --git a/config/deploy.sample.rb b/config/deploy.sample.rb deleted file mode 100644 index e3ad447..0000000 --- a/config/deploy.sample.rb +++ /dev/null @@ -1,42 +0,0 @@ -set :application, "feedcatcher" -set :repository, "http://server.example.com/svn/#{application}/branches/stable" - -# If you aren't deploying to /u/apps/#{application} on the target -# servers (which is the default), you can specify the actual location -# via the :deploy_to variable: -set :deploy_to, "/var/www/feedcatcher/" - -# If you aren't using Subversion to manage your source code, specify -# your SCM below: -set :scm, :subversion -set :scm_username, 'user' - -role :app, "feedcatcher.example.com" -role :web, "feedcatcher.example.com" -role :db, "feedcatcher.example.com", :primary => true - -# Have the spinner/spawner/reaper processes run as the default user -set :runner, nil - -# Copy the database.yml file across, as it's not kept in the SVN repository -after "deploy:update_code" , :configure_database -desc "copy database.yml into the current release path" -task :configure_database, :roles => :app do - db_config = "#{deploy_to}/config/database.yml" - run "cp #{db_config} #{release_path}/config/database.yml" -end - - -namespace :deploy do - task :start, :roles => :app do - end - - task :stop, :roles => :app do - end - - desc "Restart Application" - task :restart, :roles => :app do - run "touch #{release_path}/tmp/restart.txt" - end - -end diff --git a/config/environment.rb b/config/environment.rb index 631a3a3..f0977cf 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,41 +1,5 @@ -# Be sure to restart your server when you modify this file +# Load the Rails application. +require File.expand_path('../application', __FILE__) -# Specifies gem version of Rails to use when vendor/rails is not present -RAILS_GEM_VERSION = '2.3.2' 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.load_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" - - # 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 +# Initialize the Rails application. +Feedcatcher::Application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 85c9a60..aa594d8 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,17 +1,29 @@ -# Settings specified here will take precedence over those in config/environment.rb +Feedcatcher::Application.configure do + # Settings specified here will take precedence over those in config/application.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 + # 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 web server when you make code changes. + config.cache_classes = false -# Log error messages when you accidentally call methods on nil. -config.whiny_nils = true + # Do not eager load code on boot. + config.eager_load = false -# 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 + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false -# Don't care if the mailer can't send -config.action_mailer.raise_delivery_errors = false \ No newline at end of file + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true +end diff --git a/config/environments/production.rb b/config/environments/production.rb index a3f3c4a..a394308 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,31 +1,80 @@ -# Settings specified here will take precedence over those in config/environment.rb +Feedcatcher::Application.configure do + # Settings specified here will take precedence over those in config/application.rb. -# The production environment is meant for finished, "live" apps. -# Code is not reloaded between requests -config.cache_classes = true + # 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 + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both thread web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true -# See everything in the log (default is :info) -# config.log_level = :debug + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true -# Use a different logger for distributed setups -# config.logger = SyslogLogger.new + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true -# Rotate logs when the file grows to 10Mb, keep 10 old log files -config.logger = Logger.new(config.log_path, 10, 10.megabytes) + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false -# Use a different cache store in production -# config.cache_store = :mem_cache_store + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass -# Enable serving of images, stylesheets, and javascripts from an asset server -# config.action_controller.asset_host = "http://assets.example.com" + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false -# Disable delivery errors, bad email addresses will be ignored -# config.action_mailer.raise_delivery_errors = false + # Generate digests for assets URLs. + config.assets.digest = true -# Enable threaded mode -# config.threadsafe! \ No newline at end of file + # Version of your assets, change this if you want to expire all your assets. + config.assets.version = '1.0' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(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" + + # Precompile additional assets. + # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. + # config.assets.precompile += %w( search.js ) + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new +end diff --git a/config/environments/test.rb b/config/environments/test.rb index d6f80a4..ac0df64 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,28 +1,36 @@ -# 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 \ No newline at end of file +Feedcatcher::Application.configure do + # Settings specified here will take precedence over those in config/application.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 + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = "public, max-age=3600" + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # 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 + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr +end diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index c2169ed..59385cd 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -3,5 +3,5 @@ # 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! \ No newline at end of file +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index d531b8b..ac033bf 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,10 +1,16 @@ # 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| +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/config/initializers/new_rails_defaults.rb b/config/initializers/new_rails_defaults.rb deleted file mode 100644 index 8ec3186..0000000 --- a/config/initializers/new_rails_defaults.rb +++ /dev/null @@ -1,19 +0,0 @@ -# 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 - -# 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 \ No newline at end of file diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 5078d7a..ce7cf52 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,15 +1,3 @@ # 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 => '_feedcatcher_session', - :secret => 'e2dacfa1d2730be2dcd393fa4f91418f345cfe7285aeff9c447e6f263373474885ad6d5248d2dfbea6d141cddda30c9350d01058a89e135610e8f8481bb2097c' -} - -# 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 +Feedcatcher::Application.config.session_store :cookie_store, key: '_feedcatcher_session' diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..33725e9 --- /dev/null +++ b/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/config/locales/en.yml b/config/locales/en.yml index f265c06..0653957 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,5 +1,23 @@ -# 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. +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. en: - hello: "Hello world" \ No newline at end of file + hello: "Hello world" diff --git a/config/routes.rb b/config/routes.rb index 75eb181..4a837c0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,61 +1,56 @@ -ActionController::Routing::Routes.draw do |map| +Feedcatcher::Application.routes.draw do # The priority is based upon order of creation: first created -> highest priority. + # See how all your routes lay out with "rake routes". + + # You can have the root of your site routed with "root" + # root 'welcome#index' + + # Example of regular route: + # get 'products/:id' => 'catalog#view' + + # Example of named route that can be invoked with purchase_url(id: product.id) + # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase + + # Example resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Example resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end - # 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 } + # Example resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller # 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 + # Example resource route with more complex sub-resources: + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', on: :collection + # end # end - map.index 'index.:format', - :conditions => { :method => :get }, - :controller => 'feed', - :action => 'index' - map.feed ':feed_name.:format', - :conditions => { :method => :get }, - :controller => 'feed', - :action => 'show' - map.update '*ignored', - :conditions => { :method => :post }, - #:defaults => { :ignored => nil }, - :controller => 'feed', - :action => 'update' - - map.connect '*ignored', - :controller => 'feed', - :action => 'index' - - # You can have the root of your site routed with map.root -- just remember to delete public/index.html. - map.root :controller => "feed" - - # 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 the them or commenting them out if you're using named routes and resources. -# map.connect ':controller/:action/:id' -# map.connect ':controller/:action/:id.:format' + # Example resource route with concerns: + # concern :toggleable do + # post 'toggle' + # end + # resources :posts, concerns: :toggleable + # resources :photos, concerns: :toggleable + + # Example resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end end diff --git a/db/migrate/20090717095501_create_feed_items.rb b/db/migrate/20090717095501_create_feed_items.rb deleted file mode 100644 index f34966b..0000000 --- a/db/migrate/20090717095501_create_feed_items.rb +++ /dev/null @@ -1,19 +0,0 @@ -class CreateFeedItems < ActiveRecord::Migration - def self.up - create_table :feed_items do |t| - t.string :feed_name - t.string :title - t.text :description - - t.timestamps - end - - add_index :feed_items, :feed_name - end - - def self.down - remove_index :feed_items, :feed_name - - drop_table :feed_items - end -end diff --git a/db/migrate/20090717095948_add_test_data.rb b/db/migrate/20090717095948_add_test_data.rb deleted file mode 100644 index ccd7cdd..0000000 --- a/db/migrate/20090717095948_add_test_data.rb +++ /dev/null @@ -1,16 +0,0 @@ -class AddTestData < ActiveRecord::Migration - def self.up - FeedItem.delete_all - (1..20).each do |item_number| - ('a'..'j').each do |feed_name| - FeedItem.create(:feed_name => "feed-#{feed_name}", - :title => "feed-#{feed_name}-item-" + sprintf("%02d", item_number), - :description => "Feed #{feed_name}, Item #{item_number} has a description") - end - end - end - - def self.down - FeedItem.delete_all - end -end diff --git a/db/schema.rb b/db/schema.rb deleted file mode 100644 index 677f113..0000000 --- a/db/schema.rb +++ /dev/null @@ -1,24 +0,0 @@ -# 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 => 20090717095948) do - - create_table "feed_items", :force => true do |t| - t.string "feed_name" - t.string "title" - t.text "description" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "feed_items", ["feed_name"], :name => "index_feed_items_on_feed_name" - -end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 0000000..4edb1e8 --- /dev/null +++ b/db/seeds.rb @@ -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' }]) +# Mayor.create(name: 'Emanuel', city: cities.first) diff --git a/doc/README_FOR_APP b/doc/README_FOR_APP deleted file mode 100644 index fe41f5c..0000000 --- a/doc/README_FOR_APP +++ /dev/null @@ -1,2 +0,0 @@ -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. diff --git a/nbproject/project.properties b/nbproject/project.properties deleted file mode 100644 index 8a59f1a..0000000 --- a/nbproject/project.properties +++ /dev/null @@ -1,3 +0,0 @@ -platform.active=Ruby -rails.port=3000 -source.encoding=UTF-8 diff --git a/nbproject/project.xml b/nbproject/project.xml deleted file mode 100644 index bdb9a40..0000000 --- a/nbproject/project.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - org.netbeans.modules.ruby.railsprojects - - - feedcatcher - - - diff --git a/public/404.html b/public/404.html index eff660b..a0daa0c 100644 --- a/public/404.html +++ b/public/404.html @@ -1,23 +1,50 @@ - - - - + + - The page you were looking for doesn't exist (404) - + @@ -26,5 +53,6 @@

The page you were looking for doesn't exist.

You may have mistyped the address or the page may have moved.

+

If you are the application owner check the logs for more information.

- \ No newline at end of file + diff --git a/public/422.html b/public/422.html index b54e4a3..fbb4b84 100644 --- a/public/422.html +++ b/public/422.html @@ -1,23 +1,50 @@ - - - - + + - The change you wanted was rejected (422) - + @@ -26,5 +53,6 @@

The change you wanted was rejected.

Maybe you tried to change something you didn't have access to.

+

If you are the application owner check the logs for more information.

- \ No newline at end of file + diff --git a/public/500.html b/public/500.html index ec3bbf0..e9052d3 100644 --- a/public/500.html +++ b/public/500.html @@ -1,30 +1,57 @@ - - - - + + - We're sorry, but something went wrong (500) - +

We're sorry, but something went wrong.

-

We've been notified about this issue and we'll take a look at it shortly.

+

If you are the application owner check the logs for more information.

diff --git a/public/favicon.ico b/public/favicon.ico index ced5ec1..e69de29 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/public/images/rails.png b/public/images/rails.png deleted file mode 100644 index d5edc04..0000000 Binary files a/public/images/rails.png and /dev/null differ diff --git a/public/javascripts/application.js b/public/javascripts/application.js deleted file mode 100644 index fe45776..0000000 --- a/public/javascripts/application.js +++ /dev/null @@ -1,2 +0,0 @@ -// Place your application-specific JavaScript functions and classes here -// This file is automatically included by javascript_include_tag :defaults diff --git a/public/javascripts/controls.js b/public/javascripts/controls.js deleted file mode 100644 index ca29aef..0000000 --- a/public/javascripts/controls.js +++ /dev/null @@ -1,963 +0,0 @@ -// 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, - ''); - 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("
  • " + elem.substr(0, entry.length) + "" + - elem.substr(entry.length) + "
  • "); - 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("
  • " + elem.substr(0, foundPos) + "" + - elem.substr(foundPos, entry.length) + "" + elem.substr( - foundPos + entry.length) + "
  • "); - 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 ""; - } - }, options || { }); - } -}); - -// AJAX in-place editor and collection editor -// Full rewrite by Christophe Porteneuve (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(); - else - this.buildOptionList(); - }, - - loadExternalText: function() { - this.showLoadingText(this.options.loadingText); - 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._text = transport.responseText.strip(); - this.buildOptionList(); - }.bind(this), - onFailure: this.onFailure - }); - new Ajax.Request(this.options.loadTextURL, options); - }, - - buildOptionList: function() { - this._form.removeClassName(this.options.loadingClassName); - this._collection = this._collection.map(function(entry) { - return 2 === entry.length ? entry : [entry, entry].flatten(); - }); - var marker = ('value' in this.options) ? this.options.value : this._text; - var textFound = this._collection.any(function(entry) { - return entry[0] == marker; - }.bind(this)); - this._controls.editor.update(''); - var option; - this._collection.each(function(entry, index) { - option = document.createElement('option'); - option.value = entry[0]; - option.selected = textFound ? entry[0] == marker : 0 == index; - option.appendChild(document.createTextNode(entry[1])); - this._controls.editor.appendChild(option); - }.bind(this)); - this._controls.editor.disabled = false; - Field.scrollFreeActivate(this._controls.editor); - } -}); - -//**** DEPRECATION LAYER FOR InPlace[Collection]Editor! **** -//**** This only exists for a while, in order to let **** -//**** users adapt to the new API. Read up on the new **** -//**** API and convert your code to it ASAP! **** - -Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) { - if (!options) return; - function fallback(name, expr) { - if (name in options || expr === undefined) return; - options[name] = expr; - }; - fallback('cancelControl', (options.cancelLink ? 'link' : (options.cancelButton ? 'button' : - options.cancelLink == options.cancelButton == false ? false : undefined))); - fallback('okControl', (options.okLink ? 'link' : (options.okButton ? 'button' : - options.okLink == options.okButton == false ? false : undefined))); - fallback('highlightColor', options.highlightcolor); - fallback('highlightEndColor', options.highlightendcolor); -}; - -Object.extend(Ajax.InPlaceEditor, { - DefaultOptions: { - ajaxOptions: { }, - autoRows: 3, // Use when multi-line w/ rows == 1 - cancelControl: 'link', // 'link'|'button'|false - cancelText: 'cancel', - clickToEditText: 'Click to edit', - externalControl: null, // id|elt - externalControlOnly: false, - fieldPostCreation: 'activate', // 'activate'|'focus'|false - formClassName: 'inplaceeditor-form', - formId: null, // id|elt - highlightColor: '#ffff99', - highlightEndColor: '#ffffff', - hoverClassName: '', - htmlResponse: true, - loadingClassName: 'inplaceeditor-loading', - loadingText: 'Loading...', - okControl: 'button', // 'link'|'button'|false - okText: 'ok', - paramName: 'value', - rows: 1, // If 1 and multi-line, uses autoRows - savingClassName: 'inplaceeditor-saving', - savingText: 'Saving...', - size: 0, - stripLoadedTextTags: false, - submitOnBlur: false, - textAfterControls: '', - textBeforeControls: '', - textBetweenControls: '' - }, - DefaultCallbacks: { - callback: function(form) { - return Form.serialize(form); - }, - onComplete: function(transport, element) { - // For backward compatibility, this one is bound to the IPE, and passes - // the element directly. It was too often customized, so we don't break it. - new Effect.Highlight(element, { - startcolor: this.options.highlightColor, keepBackgroundImage: true }); - }, - onEnterEditMode: null, - onEnterHover: function(ipe) { - ipe.element.style.backgroundColor = ipe.options.highlightColor; - if (ipe._effect) - ipe._effect.cancel(); - }, - onFailure: function(transport, ipe) { - alert('Error communication with the server: ' + transport.responseText.stripTags()); - }, - onFormCustomization: null, // Takes the IPE and its generated form, after editor, before controls. - onLeaveEditMode: null, - onLeaveHover: function(ipe) { - ipe._effect = new Effect.Highlight(ipe.element, { - startcolor: ipe.options.highlightColor, endcolor: ipe.options.highlightEndColor, - restorecolor: ipe._originalBackground, keepBackgroundImage: true - }); - } - }, - Listeners: { - click: 'enterEditMode', - keydown: 'checkForEscapeOrReturn', - mouseover: 'enterHover', - mouseout: 'leaveHover' - } -}); - -Ajax.InPlaceCollectionEditor.DefaultOptions = { - loadingCollectionText: 'Loading options...' -}; - -// Delayed observer, like Form.Element.Observer, -// but waits for delay after last key input -// Ideal for live-search fields - -Form.Element.DelayedObserver = Class.create({ - initialize: function(element, delay, callback) { - this.delay = delay || 0.5; - this.element = $(element); - this.callback = callback; - this.timer = null; - this.lastValue = $F(this.element); - Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this)); - }, - delayedListener: function(event) { - if(this.lastValue == $F(this.element)) return; - if(this.timer) clearTimeout(this.timer); - this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000); - this.lastValue = $F(this.element); - }, - onTimerEvent: function() { - this.timer = null; - this.callback(this.element, $F(this.element)); - } -}); \ No newline at end of file diff --git a/public/javascripts/dragdrop.js b/public/javascripts/dragdrop.js deleted file mode 100644 index 07229f9..0000000 --- a/public/javascripts/dragdrop.js +++ /dev/null @@ -1,973 +0,0 @@ -// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// (c) 2005-2008 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) -// -// 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/ - -if(Object.isUndefined(Effect)) - throw("dragdrop.js requires including script.aculo.us' effects.js library"); - -var Droppables = { - drops: [], - - remove: function(element) { - this.drops = this.drops.reject(function(d) { return d.element==$(element) }); - }, - - add: function(element) { - element = $(element); - var options = Object.extend({ - greedy: true, - hoverclass: null, - tree: false - }, arguments[1] || { }); - - // cache containers - if(options.containment) { - options._containers = []; - var containment = options.containment; - if(Object.isArray(containment)) { - containment.each( function(c) { options._containers.push($(c)) }); - } else { - options._containers.push($(containment)); - } - } - - if(options.accept) options.accept = [options.accept].flatten(); - - Element.makePositioned(element); // fix IE - options.element = element; - - this.drops.push(options); - }, - - findDeepestChild: function(drops) { - deepest = drops[0]; - - for (i = 1; i < drops.length; ++i) - if (Element.isParent(drops[i].element, deepest.element)) - deepest = drops[i]; - - return deepest; - }, - - isContained: function(element, drop) { - var containmentNode; - if(drop.tree) { - containmentNode = element.treeNode; - } else { - containmentNode = element.parentNode; - } - return drop._containers.detect(function(c) { return containmentNode == c }); - }, - - isAffected: function(point, element, drop) { - return ( - (drop.element!=element) && - ((!drop._containers) || - this.isContained(element, drop)) && - ((!drop.accept) || - (Element.classNames(element).detect( - function(v) { return drop.accept.include(v) } ) )) && - Position.within(drop.element, point[0], point[1]) ); - }, - - deactivate: function(drop) { - if(drop.hoverclass) - Element.removeClassName(drop.element, drop.hoverclass); - this.last_active = null; - }, - - activate: function(drop) { - if(drop.hoverclass) - Element.addClassName(drop.element, drop.hoverclass); - this.last_active = drop; - }, - - show: function(point, element) { - if(!this.drops.length) return; - var drop, affected = []; - - this.drops.each( function(drop) { - if(Droppables.isAffected(point, element, drop)) - affected.push(drop); - }); - - if(affected.length>0) - drop = Droppables.findDeepestChild(affected); - - if(this.last_active && this.last_active != drop) this.deactivate(this.last_active); - if (drop) { - Position.within(drop.element, point[0], point[1]); - if(drop.onHover) - drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element)); - - if (drop != this.last_active) Droppables.activate(drop); - } - }, - - fire: function(event, element) { - if(!this.last_active) return; - Position.prepare(); - - if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active)) - if (this.last_active.onDrop) { - this.last_active.onDrop(element, this.last_active.element, event); - return true; - } - }, - - reset: function() { - if(this.last_active) - this.deactivate(this.last_active); - } -}; - -var Draggables = { - drags: [], - observers: [], - - register: function(draggable) { - if(this.drags.length == 0) { - this.eventMouseUp = this.endDrag.bindAsEventListener(this); - this.eventMouseMove = this.updateDrag.bindAsEventListener(this); - this.eventKeypress = this.keyPress.bindAsEventListener(this); - - Event.observe(document, "mouseup", this.eventMouseUp); - Event.observe(document, "mousemove", this.eventMouseMove); - Event.observe(document, "keypress", this.eventKeypress); - } - this.drags.push(draggable); - }, - - unregister: function(draggable) { - this.drags = this.drags.reject(function(d) { return d==draggable }); - if(this.drags.length == 0) { - Event.stopObserving(document, "mouseup", this.eventMouseUp); - Event.stopObserving(document, "mousemove", this.eventMouseMove); - Event.stopObserving(document, "keypress", this.eventKeypress); - } - }, - - activate: function(draggable) { - if(draggable.options.delay) { - this._timeout = setTimeout(function() { - Draggables._timeout = null; - window.focus(); - Draggables.activeDraggable = draggable; - }.bind(this), draggable.options.delay); - } else { - window.focus(); // allows keypress events if window isn't currently focused, fails for Safari - this.activeDraggable = draggable; - } - }, - - deactivate: function() { - this.activeDraggable = null; - }, - - updateDrag: function(event) { - if(!this.activeDraggable) return; - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - // Mozilla-based browsers fire successive mousemove events with - // the same coordinates, prevent needless redrawing (moz bug?) - if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return; - this._lastPointer = pointer; - - this.activeDraggable.updateDrag(event, pointer); - }, - - endDrag: function(event) { - if(this._timeout) { - clearTimeout(this._timeout); - this._timeout = null; - } - if(!this.activeDraggable) return; - this._lastPointer = null; - this.activeDraggable.endDrag(event); - this.activeDraggable = null; - }, - - keyPress: function(event) { - if(this.activeDraggable) - this.activeDraggable.keyPress(event); - }, - - addObserver: function(observer) { - this.observers.push(observer); - this._cacheObserverCallbacks(); - }, - - removeObserver: function(element) { // element instead of observer fixes mem leaks - this.observers = this.observers.reject( function(o) { return o.element==element }); - this._cacheObserverCallbacks(); - }, - - notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag' - if(this[eventName+'Count'] > 0) - this.observers.each( function(o) { - if(o[eventName]) o[eventName](eventName, draggable, event); - }); - if(draggable.options[eventName]) draggable.options[eventName](draggable, event); - }, - - _cacheObserverCallbacks: function() { - ['onStart','onEnd','onDrag'].each( function(eventName) { - Draggables[eventName+'Count'] = Draggables.observers.select( - function(o) { return o[eventName]; } - ).length; - }); - } -}; - -/*--------------------------------------------------------------------------*/ - -var Draggable = Class.create({ - initialize: function(element) { - var defaults = { - handle: false, - reverteffect: function(element, top_offset, left_offset) { - var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; - new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur, - queue: {scope:'_draggable', position:'end'} - }); - }, - endeffect: function(element) { - var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0; - new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity, - queue: {scope:'_draggable', position:'end'}, - afterFinish: function(){ - Draggable._dragging[element] = false - } - }); - }, - zindex: 1000, - revert: false, - quiet: false, - scroll: false, - scrollSensitivity: 20, - scrollSpeed: 15, - snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] } - delay: 0 - }; - - if(!arguments[1] || Object.isUndefined(arguments[1].endeffect)) - Object.extend(defaults, { - starteffect: function(element) { - element._opacity = Element.getOpacity(element); - Draggable._dragging[element] = true; - new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7}); - } - }); - - var options = Object.extend(defaults, arguments[1] || { }); - - this.element = $(element); - - if(options.handle && Object.isString(options.handle)) - this.handle = this.element.down('.'+options.handle, 0); - - if(!this.handle) this.handle = $(options.handle); - if(!this.handle) this.handle = this.element; - - if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) { - options.scroll = $(options.scroll); - this._isScrollChild = Element.childOf(this.element, options.scroll); - } - - Element.makePositioned(this.element); // fix IE - - this.options = options; - this.dragging = false; - - this.eventMouseDown = this.initDrag.bindAsEventListener(this); - Event.observe(this.handle, "mousedown", this.eventMouseDown); - - Draggables.register(this); - }, - - destroy: function() { - Event.stopObserving(this.handle, "mousedown", this.eventMouseDown); - Draggables.unregister(this); - }, - - currentDelta: function() { - return([ - parseInt(Element.getStyle(this.element,'left') || '0'), - parseInt(Element.getStyle(this.element,'top') || '0')]); - }, - - initDrag: function(event) { - if(!Object.isUndefined(Draggable._dragging[this.element]) && - Draggable._dragging[this.element]) return; - if(Event.isLeftClick(event)) { - // abort on form elements, fixes a Firefox issue - var src = Event.element(event); - if((tag_name = src.tagName.toUpperCase()) && ( - tag_name=='INPUT' || - tag_name=='SELECT' || - tag_name=='OPTION' || - tag_name=='BUTTON' || - tag_name=='TEXTAREA')) return; - - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - var pos = Position.cumulativeOffset(this.element); - this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) }); - - Draggables.activate(this); - Event.stop(event); - } - }, - - startDrag: function(event) { - this.dragging = true; - if(!this.delta) - this.delta = this.currentDelta(); - - if(this.options.zindex) { - this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0); - this.element.style.zIndex = this.options.zindex; - } - - if(this.options.ghosting) { - this._clone = this.element.cloneNode(true); - this._originallyAbsolute = (this.element.getStyle('position') == 'absolute'); - if (!this._originallyAbsolute) - Position.absolutize(this.element); - this.element.parentNode.insertBefore(this._clone, this.element); - } - - if(this.options.scroll) { - if (this.options.scroll == window) { - var where = this._getWindowScroll(this.options.scroll); - this.originalScrollLeft = where.left; - this.originalScrollTop = where.top; - } else { - this.originalScrollLeft = this.options.scroll.scrollLeft; - this.originalScrollTop = this.options.scroll.scrollTop; - } - } - - Draggables.notify('onStart', this, event); - - if(this.options.starteffect) this.options.starteffect(this.element); - }, - - updateDrag: function(event, pointer) { - if(!this.dragging) this.startDrag(event); - - if(!this.options.quiet){ - Position.prepare(); - Droppables.show(pointer, this.element); - } - - Draggables.notify('onDrag', this, event); - - this.draw(pointer); - if(this.options.change) this.options.change(this); - - if(this.options.scroll) { - this.stopScrolling(); - - var p; - if (this.options.scroll == window) { - with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; } - } else { - p = Position.page(this.options.scroll); - p[0] += this.options.scroll.scrollLeft + Position.deltaX; - p[1] += this.options.scroll.scrollTop + Position.deltaY; - p.push(p[0]+this.options.scroll.offsetWidth); - p.push(p[1]+this.options.scroll.offsetHeight); - } - var speed = [0,0]; - if(pointer[0] < (p[0]+this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[0]+this.options.scrollSensitivity); - if(pointer[1] < (p[1]+this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[1]+this.options.scrollSensitivity); - if(pointer[0] > (p[2]-this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[2]-this.options.scrollSensitivity); - if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity); - this.startScrolling(speed); - } - - // fix AppleWebKit rendering - if(Prototype.Browser.WebKit) window.scrollBy(0,0); - - Event.stop(event); - }, - - finishDrag: function(event, success) { - this.dragging = false; - - if(this.options.quiet){ - Position.prepare(); - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - Droppables.show(pointer, this.element); - } - - if(this.options.ghosting) { - if (!this._originallyAbsolute) - Position.relativize(this.element); - delete this._originallyAbsolute; - Element.remove(this._clone); - this._clone = null; - } - - var dropped = false; - if(success) { - dropped = Droppables.fire(event, this.element); - if (!dropped) dropped = false; - } - if(dropped && this.options.onDropped) this.options.onDropped(this.element); - Draggables.notify('onEnd', this, event); - - var revert = this.options.revert; - if(revert && Object.isFunction(revert)) revert = revert(this.element); - - var d = this.currentDelta(); - if(revert && this.options.reverteffect) { - if (dropped == 0 || revert != 'failure') - this.options.reverteffect(this.element, - d[1]-this.delta[1], d[0]-this.delta[0]); - } else { - this.delta = d; - } - - if(this.options.zindex) - this.element.style.zIndex = this.originalZ; - - if(this.options.endeffect) - this.options.endeffect(this.element); - - Draggables.deactivate(this); - Droppables.reset(); - }, - - keyPress: function(event) { - if(event.keyCode!=Event.KEY_ESC) return; - this.finishDrag(event, false); - Event.stop(event); - }, - - endDrag: function(event) { - if(!this.dragging) return; - this.stopScrolling(); - this.finishDrag(event, true); - Event.stop(event); - }, - - draw: function(point) { - var pos = Position.cumulativeOffset(this.element); - if(this.options.ghosting) { - var r = Position.realOffset(this.element); - pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY; - } - - var d = this.currentDelta(); - pos[0] -= d[0]; pos[1] -= d[1]; - - if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) { - pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft; - pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop; - } - - var p = [0,1].map(function(i){ - return (point[i]-pos[i]-this.offset[i]) - }.bind(this)); - - if(this.options.snap) { - if(Object.isFunction(this.options.snap)) { - p = this.options.snap(p[0],p[1],this); - } else { - if(Object.isArray(this.options.snap)) { - p = p.map( function(v, i) { - return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this)); - } else { - p = p.map( function(v) { - return (v/this.options.snap).round()*this.options.snap }.bind(this)); - } - }} - - var style = this.element.style; - if((!this.options.constraint) || (this.options.constraint=='horizontal')) - style.left = p[0] + "px"; - if((!this.options.constraint) || (this.options.constraint=='vertical')) - style.top = p[1] + "px"; - - if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering - }, - - stopScrolling: function() { - if(this.scrollInterval) { - clearInterval(this.scrollInterval); - this.scrollInterval = null; - Draggables._lastScrollPointer = null; - } - }, - - startScrolling: function(speed) { - if(!(speed[0] || speed[1])) return; - this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed]; - this.lastScrolled = new Date(); - this.scrollInterval = setInterval(this.scroll.bind(this), 10); - }, - - scroll: function() { - var current = new Date(); - var delta = current - this.lastScrolled; - this.lastScrolled = current; - if(this.options.scroll == window) { - with (this._getWindowScroll(this.options.scroll)) { - if (this.scrollSpeed[0] || this.scrollSpeed[1]) { - var d = delta / 1000; - this.options.scroll.scrollTo( left + d*this.scrollSpeed[0], top + d*this.scrollSpeed[1] ); - } - } - } else { - this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000; - this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000; - } - - Position.prepare(); - Droppables.show(Draggables._lastPointer, this.element); - Draggables.notify('onDrag', this); - if (this._isScrollChild) { - Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer); - Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000; - Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000; - if (Draggables._lastScrollPointer[0] < 0) - Draggables._lastScrollPointer[0] = 0; - if (Draggables._lastScrollPointer[1] < 0) - Draggables._lastScrollPointer[1] = 0; - this.draw(Draggables._lastScrollPointer); - } - - if(this.options.change) this.options.change(this); - }, - - _getWindowScroll: function(w) { - var T, L, W, H; - with (w.document) { - if (w.document.documentElement && documentElement.scrollTop) { - T = documentElement.scrollTop; - L = documentElement.scrollLeft; - } else if (w.document.body) { - T = body.scrollTop; - L = body.scrollLeft; - } - if (w.innerWidth) { - W = w.innerWidth; - H = w.innerHeight; - } else if (w.document.documentElement && documentElement.clientWidth) { - W = documentElement.clientWidth; - H = documentElement.clientHeight; - } else { - W = body.offsetWidth; - H = body.offsetHeight; - } - } - return { top: T, left: L, width: W, height: H }; - } -}); - -Draggable._dragging = { }; - -/*--------------------------------------------------------------------------*/ - -var SortableObserver = Class.create({ - initialize: function(element, observer) { - this.element = $(element); - this.observer = observer; - this.lastValue = Sortable.serialize(this.element); - }, - - onStart: function() { - this.lastValue = Sortable.serialize(this.element); - }, - - onEnd: function() { - Sortable.unmark(); - if(this.lastValue != Sortable.serialize(this.element)) - this.observer(this.element) - } -}); - -var Sortable = { - SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/, - - sortables: { }, - - _findRootElement: function(element) { - while (element.tagName.toUpperCase() != "BODY") { - if(element.id && Sortable.sortables[element.id]) return element; - element = element.parentNode; - } - }, - - options: function(element) { - element = Sortable._findRootElement($(element)); - if(!element) return; - return Sortable.sortables[element.id]; - }, - - destroy: function(element){ - element = $(element); - var s = Sortable.sortables[element.id]; - - if(s) { - Draggables.removeObserver(s.element); - s.droppables.each(function(d){ Droppables.remove(d) }); - s.draggables.invoke('destroy'); - - delete Sortable.sortables[s.element.id]; - } - }, - - create: function(element) { - element = $(element); - var options = Object.extend({ - element: element, - tag: 'li', // assumes li children, override with tag: 'tagname' - dropOnEmpty: false, - tree: false, - treeTag: 'ul', - overlap: 'vertical', // one of 'vertical', 'horizontal' - constraint: 'vertical', // one of 'vertical', 'horizontal', false - containment: element, // also takes array of elements (or id's); or false - handle: false, // or a CSS class - only: false, - delay: 0, - hoverclass: null, - ghosting: false, - quiet: false, - scroll: false, - scrollSensitivity: 20, - scrollSpeed: 15, - format: this.SERIALIZE_RULE, - - // these take arrays of elements or ids and can be - // used for better initialization performance - elements: false, - handles: false, - - onChange: Prototype.emptyFunction, - onUpdate: Prototype.emptyFunction - }, arguments[1] || { }); - - // clear any old sortable with same element - this.destroy(element); - - // build options for the draggables - var options_for_draggable = { - revert: true, - quiet: options.quiet, - scroll: options.scroll, - scrollSpeed: options.scrollSpeed, - scrollSensitivity: options.scrollSensitivity, - delay: options.delay, - ghosting: options.ghosting, - constraint: options.constraint, - handle: options.handle }; - - if(options.starteffect) - options_for_draggable.starteffect = options.starteffect; - - if(options.reverteffect) - options_for_draggable.reverteffect = options.reverteffect; - else - if(options.ghosting) options_for_draggable.reverteffect = function(element) { - element.style.top = 0; - element.style.left = 0; - }; - - if(options.endeffect) - options_for_draggable.endeffect = options.endeffect; - - if(options.zindex) - options_for_draggable.zindex = options.zindex; - - // build options for the droppables - var options_for_droppable = { - overlap: options.overlap, - containment: options.containment, - tree: options.tree, - hoverclass: options.hoverclass, - onHover: Sortable.onHover - }; - - var options_for_tree = { - onHover: Sortable.onEmptyHover, - overlap: options.overlap, - containment: options.containment, - hoverclass: options.hoverclass - }; - - // fix for gecko engine - Element.cleanWhitespace(element); - - options.draggables = []; - options.droppables = []; - - // drop on empty handling - if(options.dropOnEmpty || options.tree) { - Droppables.add(element, options_for_tree); - options.droppables.push(element); - } - - (options.elements || this.findElements(element, options) || []).each( function(e,i) { - var handle = options.handles ? $(options.handles[i]) : - (options.handle ? $(e).select('.' + options.handle)[0] : e); - options.draggables.push( - new Draggable(e, Object.extend(options_for_draggable, { handle: handle }))); - Droppables.add(e, options_for_droppable); - if(options.tree) e.treeNode = element; - options.droppables.push(e); - }); - - if(options.tree) { - (Sortable.findTreeElements(element, options) || []).each( function(e) { - Droppables.add(e, options_for_tree); - e.treeNode = element; - options.droppables.push(e); - }); - } - - // keep reference - this.sortables[element.id] = options; - - // for onupdate - Draggables.addObserver(new SortableObserver(element, options.onUpdate)); - - }, - - // return all suitable-for-sortable elements in a guaranteed order - findElements: function(element, options) { - return Element.findChildren( - element, options.only, options.tree ? true : false, options.tag); - }, - - findTreeElements: function(element, options) { - return Element.findChildren( - element, options.only, options.tree ? true : false, options.treeTag); - }, - - onHover: function(element, dropon, overlap) { - if(Element.isParent(dropon, element)) return; - - if(overlap > .33 && overlap < .66 && Sortable.options(dropon).tree) { - return; - } else if(overlap>0.5) { - Sortable.mark(dropon, 'before'); - if(dropon.previousSibling != element) { - var oldParentNode = element.parentNode; - element.style.visibility = "hidden"; // fix gecko rendering - dropon.parentNode.insertBefore(element, dropon); - if(dropon.parentNode!=oldParentNode) - Sortable.options(oldParentNode).onChange(element); - Sortable.options(dropon.parentNode).onChange(element); - } - } else { - Sortable.mark(dropon, 'after'); - var nextElement = dropon.nextSibling || null; - if(nextElement != element) { - var oldParentNode = element.parentNode; - element.style.visibility = "hidden"; // fix gecko rendering - dropon.parentNode.insertBefore(element, nextElement); - if(dropon.parentNode!=oldParentNode) - Sortable.options(oldParentNode).onChange(element); - Sortable.options(dropon.parentNode).onChange(element); - } - } - }, - - onEmptyHover: function(element, dropon, overlap) { - var oldParentNode = element.parentNode; - var droponOptions = Sortable.options(dropon); - - if(!Element.isParent(dropon, element)) { - var index; - - var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only}); - var child = null; - - if(children) { - var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap); - - for (index = 0; index < children.length; index += 1) { - if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) { - offset -= Element.offsetSize (children[index], droponOptions.overlap); - } else if (offset - (Element.offsetSize (children[index], droponOptions.overlap) / 2) >= 0) { - child = index + 1 < children.length ? children[index + 1] : null; - break; - } else { - child = children[index]; - break; - } - } - } - - dropon.insertBefore(element, child); - - Sortable.options(oldParentNode).onChange(element); - droponOptions.onChange(element); - } - }, - - unmark: function() { - if(Sortable._marker) Sortable._marker.hide(); - }, - - mark: function(dropon, position) { - // mark on ghosting only - var sortable = Sortable.options(dropon.parentNode); - if(sortable && !sortable.ghosting) return; - - if(!Sortable._marker) { - Sortable._marker = - ($('dropmarker') || Element.extend(document.createElement('DIV'))). - hide().addClassName('dropmarker').setStyle({position:'absolute'}); - document.getElementsByTagName("body").item(0).appendChild(Sortable._marker); - } - var offsets = Position.cumulativeOffset(dropon); - Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'}); - - if(position=='after') - if(sortable.overlap == 'horizontal') - Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'}); - else - Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'}); - - Sortable._marker.show(); - }, - - _tree: function(element, options, parent) { - var children = Sortable.findElements(element, options) || []; - - for (var i = 0; i < children.length; ++i) { - var match = children[i].id.match(options.format); - - if (!match) continue; - - var child = { - id: encodeURIComponent(match ? match[1] : null), - element: element, - parent: parent, - children: [], - position: parent.children.length, - container: $(children[i]).down(options.treeTag) - }; - - /* Get the element containing the children and recurse over it */ - if (child.container) - this._tree(child.container, options, child); - - parent.children.push (child); - } - - return parent; - }, - - tree: function(element) { - element = $(element); - var sortableOptions = this.options(element); - var options = Object.extend({ - tag: sortableOptions.tag, - treeTag: sortableOptions.treeTag, - only: sortableOptions.only, - name: element.id, - format: sortableOptions.format - }, arguments[1] || { }); - - var root = { - id: null, - parent: null, - children: [], - container: element, - position: 0 - }; - - return Sortable._tree(element, options, root); - }, - - /* Construct a [i] index for a particular node */ - _constructIndex: function(node) { - var index = ''; - do { - if (node.id) index = '[' + node.position + ']' + index; - } while ((node = node.parent) != null); - return index; - }, - - sequence: function(element) { - element = $(element); - var options = Object.extend(this.options(element), arguments[1] || { }); - - return $(this.findElements(element, options) || []).map( function(item) { - return item.id.match(options.format) ? item.id.match(options.format)[1] : ''; - }); - }, - - setSequence: function(element, new_sequence) { - element = $(element); - var options = Object.extend(this.options(element), arguments[2] || { }); - - var nodeMap = { }; - this.findElements(element, options).each( function(n) { - if (n.id.match(options.format)) - nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode]; - n.parentNode.removeChild(n); - }); - - new_sequence.each(function(ident) { - var n = nodeMap[ident]; - if (n) { - n[1].appendChild(n[0]); - delete nodeMap[ident]; - } - }); - }, - - serialize: function(element) { - element = $(element); - var options = Object.extend(Sortable.options(element), arguments[1] || { }); - var name = encodeURIComponent( - (arguments[1] && arguments[1].name) ? arguments[1].name : element.id); - - if (options.tree) { - return Sortable.tree(element, arguments[1]).children.map( function (item) { - return [name + Sortable._constructIndex(item) + "[id]=" + - encodeURIComponent(item.id)].concat(item.children.map(arguments.callee)); - }).flatten().join('&'); - } else { - return Sortable.sequence(element, arguments[1]).map( function(item) { - return name + "[]=" + encodeURIComponent(item); - }).join('&'); - } - } -}; - -// Returns true if child is contained within element -Element.isParent = function(child, element) { - if (!child.parentNode || child == element) return false; - if (child.parentNode == element) return true; - return Element.isParent(child.parentNode, element); -}; - -Element.findChildren = function(element, only, recursive, tagName) { - if(!element.hasChildNodes()) return null; - tagName = tagName.toUpperCase(); - if(only) only = [only].flatten(); - var elements = []; - $A(element.childNodes).each( function(e) { - if(e.tagName && e.tagName.toUpperCase()==tagName && - (!only || (Element.classNames(e).detect(function(v) { return only.include(v) })))) - elements.push(e); - if(recursive) { - var grandchildren = Element.findChildren(e, only, recursive, tagName); - if(grandchildren) elements.push(grandchildren); - } - }); - - return (elements.length>0 ? elements.flatten() : []); -}; - -Element.offsetSize = function (element, type) { - return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')]; -}; \ No newline at end of file diff --git a/public/javascripts/effects.js b/public/javascripts/effects.js deleted file mode 100644 index 5a639d2..0000000 --- a/public/javascripts/effects.js +++ /dev/null @@ -1,1128 +0,0 @@ -// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// Contributors: -// Justin Palmer (http://encytemedia.com/) -// Mark Pilgrim (http://diveintomark.org/) -// Martin Bialasinki -// -// 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/ - -// converts rgb() and #xxx to #xxxxxx format, -// returns self (or first argument) if not convertable -String.prototype.parseColor = function() { - var color = '#'; - if (this.slice(0,4) == 'rgb(') { - var cols = this.slice(4,this.length-1).split(','); - var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3); - } else { - if (this.slice(0,1) == '#') { - if (this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase(); - if (this.length==7) color = this.toLowerCase(); - } - } - return (color.length==7 ? color : (arguments[0] || this)); -}; - -/*--------------------------------------------------------------------------*/ - -Element.collectTextNodes = function(element) { - return $A($(element).childNodes).collect( function(node) { - return (node.nodeType==3 ? node.nodeValue : - (node.hasChildNodes() ? Element.collectTextNodes(node) : '')); - }).flatten().join(''); -}; - -Element.collectTextNodesIgnoreClass = function(element, className) { - return $A($(element).childNodes).collect( function(node) { - return (node.nodeType==3 ? node.nodeValue : - ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? - Element.collectTextNodesIgnoreClass(node, className) : '')); - }).flatten().join(''); -}; - -Element.setContentZoom = function(element, percent) { - element = $(element); - element.setStyle({fontSize: (percent/100) + 'em'}); - if (Prototype.Browser.WebKit) window.scrollBy(0,0); - return element; -}; - -Element.getInlineOpacity = function(element){ - return $(element).style.opacity || ''; -}; - -Element.forceRerendering = function(element) { - try { - element = $(element); - var n = document.createTextNode(' '); - element.appendChild(n); - element.removeChild(n); - } catch(e) { } -}; - -/*--------------------------------------------------------------------------*/ - -var Effect = { - _elementDoesNotExistError: { - name: 'ElementDoesNotExistError', - message: 'The specified DOM element does not exist, but is required for this effect to operate' - }, - Transitions: { - linear: Prototype.K, - sinoidal: function(pos) { - return (-Math.cos(pos*Math.PI)/2) + .5; - }, - reverse: function(pos) { - return 1-pos; - }, - flicker: function(pos) { - var pos = ((-Math.cos(pos*Math.PI)/4) + .75) + Math.random()/4; - return pos > 1 ? 1 : pos; - }, - wobble: function(pos) { - return (-Math.cos(pos*Math.PI*(9*pos))/2) + .5; - }, - pulse: function(pos, pulses) { - return (-Math.cos((pos*((pulses||5)-.5)*2)*Math.PI)/2) + .5; - }, - spring: function(pos) { - return 1 - (Math.cos(pos * 4.5 * Math.PI) * Math.exp(-pos * 6)); - }, - none: function(pos) { - return 0; - }, - full: function(pos) { - return 1; - } - }, - DefaultOptions: { - duration: 1.0, // seconds - fps: 100, // 100= assume 66fps max. - sync: false, // true for combining - from: 0.0, - to: 1.0, - delay: 0.0, - queue: 'parallel' - }, - tagifyText: function(element) { - var tagifyStyle = 'position:relative'; - if (Prototype.Browser.IE) tagifyStyle += ';zoom:1'; - - element = $(element); - $A(element.childNodes).each( function(child) { - if (child.nodeType==3) { - child.nodeValue.toArray().each( function(character) { - element.insertBefore( - new Element('span', {style: tagifyStyle}).update( - character == ' ' ? String.fromCharCode(160) : character), - child); - }); - Element.remove(child); - } - }); - }, - multiple: function(element, effect) { - var elements; - if (((typeof element == 'object') || - Object.isFunction(element)) && - (element.length)) - elements = element; - else - elements = $(element).childNodes; - - var options = Object.extend({ - speed: 0.1, - delay: 0.0 - }, arguments[2] || { }); - var masterDelay = options.delay; - - $A(elements).each( function(element, index) { - new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay })); - }); - }, - PAIRS: { - 'slide': ['SlideDown','SlideUp'], - 'blind': ['BlindDown','BlindUp'], - 'appear': ['Appear','Fade'] - }, - toggle: function(element, effect) { - element = $(element); - effect = (effect || 'appear').toLowerCase(); - var options = Object.extend({ - queue: { position:'end', scope:(element.id || 'global'), limit: 1 } - }, arguments[2] || { }); - Effect[element.visible() ? - Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options); - } -}; - -Effect.DefaultOptions.transition = Effect.Transitions.sinoidal; - -/* ------------- core effects ------------- */ - -Effect.ScopedQueue = Class.create(Enumerable, { - initialize: function() { - this.effects = []; - this.interval = null; - }, - _each: function(iterator) { - this.effects._each(iterator); - }, - add: function(effect) { - var timestamp = new Date().getTime(); - - var position = Object.isString(effect.options.queue) ? - effect.options.queue : effect.options.queue.position; - - switch(position) { - case 'front': - // move unstarted effects after this effect - this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) { - e.startOn += effect.finishOn; - e.finishOn += effect.finishOn; - }); - break; - case 'with-last': - timestamp = this.effects.pluck('startOn').max() || timestamp; - break; - case 'end': - // start effect after last queued effect has finished - timestamp = this.effects.pluck('finishOn').max() || timestamp; - break; - } - - effect.startOn += timestamp; - effect.finishOn += timestamp; - - if (!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit)) - this.effects.push(effect); - - if (!this.interval) - this.interval = setInterval(this.loop.bind(this), 15); - }, - remove: function(effect) { - this.effects = this.effects.reject(function(e) { return e==effect }); - if (this.effects.length == 0) { - clearInterval(this.interval); - this.interval = null; - } - }, - loop: function() { - var timePos = new Date().getTime(); - for(var i=0, len=this.effects.length;i= this.startOn) { - if (timePos >= this.finishOn) { - this.render(1.0); - this.cancel(); - this.event('beforeFinish'); - if (this.finish) this.finish(); - this.event('afterFinish'); - return; - } - var pos = (timePos - this.startOn) / this.totalTime, - frame = (pos * this.totalFrames).round(); - if (frame > this.currentFrame) { - this.render(pos); - this.currentFrame = frame; - } - } - }, - cancel: function() { - if (!this.options.sync) - Effect.Queues.get(Object.isString(this.options.queue) ? - 'global' : this.options.queue.scope).remove(this); - this.state = 'finished'; - }, - event: function(eventName) { - if (this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this); - if (this.options[eventName]) this.options[eventName](this); - }, - inspect: function() { - var data = $H(); - for(property in this) - if (!Object.isFunction(this[property])) data.set(property, this[property]); - return '#'; - } -}); - -Effect.Parallel = Class.create(Effect.Base, { - initialize: function(effects) { - this.effects = effects || []; - this.start(arguments[1]); - }, - update: function(position) { - this.effects.invoke('render', position); - }, - finish: function(position) { - this.effects.each( function(effect) { - effect.render(1.0); - effect.cancel(); - effect.event('beforeFinish'); - if (effect.finish) effect.finish(position); - effect.event('afterFinish'); - }); - } -}); - -Effect.Tween = Class.create(Effect.Base, { - initialize: function(object, from, to) { - object = Object.isString(object) ? $(object) : object; - var args = $A(arguments), method = args.last(), - options = args.length == 5 ? args[3] : null; - this.method = Object.isFunction(method) ? method.bind(object) : - Object.isFunction(object[method]) ? object[method].bind(object) : - function(value) { object[method] = value }; - this.start(Object.extend({ from: from, to: to }, options || { })); - }, - update: function(position) { - this.method(position); - } -}); - -Effect.Event = Class.create(Effect.Base, { - initialize: function() { - this.start(Object.extend({ duration: 0 }, arguments[0] || { })); - }, - update: Prototype.emptyFunction -}); - -Effect.Opacity = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - // make this work on IE on elements without 'layout' - if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout)) - this.element.setStyle({zoom: 1}); - var options = Object.extend({ - from: this.element.getOpacity() || 0.0, - to: 1.0 - }, arguments[1] || { }); - this.start(options); - }, - update: function(position) { - this.element.setOpacity(position); - } -}); - -Effect.Move = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - x: 0, - y: 0, - mode: 'relative' - }, arguments[1] || { }); - this.start(options); - }, - setup: function() { - this.element.makePositioned(); - this.originalLeft = parseFloat(this.element.getStyle('left') || '0'); - this.originalTop = parseFloat(this.element.getStyle('top') || '0'); - if (this.options.mode == 'absolute') { - this.options.x = this.options.x - this.originalLeft; - this.options.y = this.options.y - this.originalTop; - } - }, - update: function(position) { - this.element.setStyle({ - left: (this.options.x * position + this.originalLeft).round() + 'px', - top: (this.options.y * position + this.originalTop).round() + 'px' - }); - } -}); - -// for backwards compatibility -Effect.MoveBy = function(element, toTop, toLeft) { - return new Effect.Move(element, - Object.extend({ x: toLeft, y: toTop }, arguments[3] || { })); -}; - -Effect.Scale = Class.create(Effect.Base, { - initialize: function(element, percent) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - scaleX: true, - scaleY: true, - scaleContent: true, - scaleFromCenter: false, - scaleMode: 'box', // 'box' or 'contents' or { } with provided values - scaleFrom: 100.0, - scaleTo: percent - }, arguments[2] || { }); - this.start(options); - }, - setup: function() { - this.restoreAfterFinish = this.options.restoreAfterFinish || false; - this.elementPositioning = this.element.getStyle('position'); - - this.originalStyle = { }; - ['top','left','width','height','fontSize'].each( function(k) { - this.originalStyle[k] = this.element.style[k]; - }.bind(this)); - - this.originalTop = this.element.offsetTop; - this.originalLeft = this.element.offsetLeft; - - var fontSize = this.element.getStyle('font-size') || '100%'; - ['em','px','%','pt'].each( function(fontSizeType) { - if (fontSize.indexOf(fontSizeType)>0) { - this.fontSize = parseFloat(fontSize); - this.fontSizeType = fontSizeType; - } - }.bind(this)); - - this.factor = (this.options.scaleTo - this.options.scaleFrom)/100; - - this.dims = null; - if (this.options.scaleMode=='box') - this.dims = [this.element.offsetHeight, this.element.offsetWidth]; - if (/^content/.test(this.options.scaleMode)) - this.dims = [this.element.scrollHeight, this.element.scrollWidth]; - if (!this.dims) - this.dims = [this.options.scaleMode.originalHeight, - this.options.scaleMode.originalWidth]; - }, - update: function(position) { - var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position); - if (this.options.scaleContent && this.fontSize) - this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType }); - this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale); - }, - finish: function(position) { - if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle); - }, - setDimensions: function(height, width) { - var d = { }; - if (this.options.scaleX) d.width = width.round() + 'px'; - if (this.options.scaleY) d.height = height.round() + 'px'; - if (this.options.scaleFromCenter) { - var topd = (height - this.dims[0])/2; - var leftd = (width - this.dims[1])/2; - if (this.elementPositioning == 'absolute') { - if (this.options.scaleY) d.top = this.originalTop-topd + 'px'; - if (this.options.scaleX) d.left = this.originalLeft-leftd + 'px'; - } else { - if (this.options.scaleY) d.top = -topd + 'px'; - if (this.options.scaleX) d.left = -leftd + 'px'; - } - } - this.element.setStyle(d); - } -}); - -Effect.Highlight = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || { }); - this.start(options); - }, - setup: function() { - // Prevent executing on elements not in the layout flow - if (this.element.getStyle('display')=='none') { this.cancel(); return; } - // Disable background image during the effect - this.oldStyle = { }; - if (!this.options.keepBackgroundImage) { - this.oldStyle.backgroundImage = this.element.getStyle('background-image'); - this.element.setStyle({backgroundImage: 'none'}); - } - if (!this.options.endcolor) - this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff'); - if (!this.options.restorecolor) - this.options.restorecolor = this.element.getStyle('background-color'); - // init color calculations - this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this)); - this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this)); - }, - update: function(position) { - this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){ - return m+((this._base[i]+(this._delta[i]*position)).round().toColorPart()); }.bind(this)) }); - }, - finish: function() { - this.element.setStyle(Object.extend(this.oldStyle, { - backgroundColor: this.options.restorecolor - })); - } -}); - -Effect.ScrollTo = function(element) { - var options = arguments[1] || { }, - scrollOffsets = document.viewport.getScrollOffsets(), - elementOffsets = $(element).cumulativeOffset(); - - if (options.offset) elementOffsets[1] += options.offset; - - return new Effect.Tween(null, - scrollOffsets.top, - elementOffsets[1], - options, - function(p){ scrollTo(scrollOffsets.left, p.round()); } - ); -}; - -/* ------------- combination effects ------------- */ - -Effect.Fade = function(element) { - element = $(element); - var oldOpacity = element.getInlineOpacity(); - var options = Object.extend({ - from: element.getOpacity() || 1.0, - to: 0.0, - afterFinishInternal: function(effect) { - if (effect.options.to!=0) return; - effect.element.hide().setStyle({opacity: oldOpacity}); - } - }, arguments[1] || { }); - return new Effect.Opacity(element,options); -}; - -Effect.Appear = function(element) { - element = $(element); - var options = Object.extend({ - from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0), - to: 1.0, - // force Safari to render floated elements properly - afterFinishInternal: function(effect) { - effect.element.forceRerendering(); - }, - beforeSetup: function(effect) { - effect.element.setOpacity(effect.options.from).show(); - }}, arguments[1] || { }); - return new Effect.Opacity(element,options); -}; - -Effect.Puff = function(element) { - element = $(element); - var oldStyle = { - opacity: element.getInlineOpacity(), - position: element.getStyle('position'), - top: element.style.top, - left: element.style.left, - width: element.style.width, - height: element.style.height - }; - return new Effect.Parallel( - [ new Effect.Scale(element, 200, - { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), - new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], - Object.extend({ duration: 1.0, - beforeSetupInternal: function(effect) { - Position.absolutize(effect.effects[0].element); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.hide().setStyle(oldStyle); } - }, arguments[1] || { }) - ); -}; - -Effect.BlindUp = function(element) { - element = $(element); - element.makeClipping(); - return new Effect.Scale(element, 0, - Object.extend({ scaleContent: false, - scaleX: false, - restoreAfterFinish: true, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping(); - } - }, arguments[1] || { }) - ); -}; - -Effect.BlindDown = function(element) { - element = $(element); - var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, 100, Object.extend({ - scaleContent: false, - scaleX: false, - scaleFrom: 0, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { - effect.element.makeClipping().setStyle({height: '0px'}).show(); - }, - afterFinishInternal: function(effect) { - effect.element.undoClipping(); - } - }, arguments[1] || { })); -}; - -Effect.SwitchOff = function(element) { - element = $(element); - var oldOpacity = element.getInlineOpacity(); - return new Effect.Appear(element, Object.extend({ - duration: 0.4, - from: 0, - transition: Effect.Transitions.flicker, - afterFinishInternal: function(effect) { - new Effect.Scale(effect.element, 1, { - duration: 0.3, scaleFromCenter: true, - scaleX: false, scaleContent: false, restoreAfterFinish: true, - beforeSetup: function(effect) { - effect.element.makePositioned().makeClipping(); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity}); - } - }); - } - }, arguments[1] || { })); -}; - -Effect.DropOut = function(element) { - element = $(element); - var oldStyle = { - top: element.getStyle('top'), - left: element.getStyle('left'), - opacity: element.getInlineOpacity() }; - return new Effect.Parallel( - [ new Effect.Move(element, {x: 0, y: 100, sync: true }), - new Effect.Opacity(element, { sync: true, to: 0.0 }) ], - Object.extend( - { duration: 0.5, - beforeSetup: function(effect) { - effect.effects[0].element.makePositioned(); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle); - } - }, arguments[1] || { })); -}; - -Effect.Shake = function(element) { - element = $(element); - var options = Object.extend({ - distance: 20, - duration: 0.5 - }, arguments[1] || {}); - var distance = parseFloat(options.distance); - var split = parseFloat(options.duration) / 10.0; - var oldStyle = { - top: element.getStyle('top'), - left: element.getStyle('left') }; - return new Effect.Move(element, - { x: distance, y: 0, duration: split, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -distance, y: 0, duration: split, afterFinishInternal: function(effect) { - effect.element.undoPositioned().setStyle(oldStyle); - }}); }}); }}); }}); }}); }}); -}; - -Effect.SlideDown = function(element) { - element = $(element).cleanWhitespace(); - // SlideDown need to have the content of the element wrapped in a container element with fixed height! - var oldInnerBottom = element.down().getStyle('bottom'); - var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, 100, Object.extend({ - scaleContent: false, - scaleX: false, - scaleFrom: window.opera ? 0 : 1, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { - effect.element.makePositioned(); - effect.element.down().makePositioned(); - if (window.opera) effect.element.setStyle({top: ''}); - effect.element.makeClipping().setStyle({height: '0px'}).show(); - }, - afterUpdateInternal: function(effect) { - effect.element.down().setStyle({bottom: - (effect.dims[0] - effect.element.clientHeight) + 'px' }); - }, - afterFinishInternal: function(effect) { - effect.element.undoClipping().undoPositioned(); - effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); } - }, arguments[1] || { }) - ); -}; - -Effect.SlideUp = function(element) { - element = $(element).cleanWhitespace(); - var oldInnerBottom = element.down().getStyle('bottom'); - var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, window.opera ? 0 : 1, - Object.extend({ scaleContent: false, - scaleX: false, - scaleMode: 'box', - scaleFrom: 100, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { - effect.element.makePositioned(); - effect.element.down().makePositioned(); - if (window.opera) effect.element.setStyle({top: ''}); - effect.element.makeClipping().show(); - }, - afterUpdateInternal: function(effect) { - effect.element.down().setStyle({bottom: - (effect.dims[0] - effect.element.clientHeight) + 'px' }); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().undoPositioned(); - effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); - } - }, arguments[1] || { }) - ); -}; - -// Bug in opera makes the TD containing this element expand for a instance after finish -Effect.Squish = function(element) { - return new Effect.Scale(element, window.opera ? 1 : 0, { - restoreAfterFinish: true, - beforeSetup: function(effect) { - effect.element.makeClipping(); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping(); - } - }); -}; - -Effect.Grow = function(element) { - element = $(element); - var options = Object.extend({ - direction: 'center', - moveTransition: Effect.Transitions.sinoidal, - scaleTransition: Effect.Transitions.sinoidal, - opacityTransition: Effect.Transitions.full - }, arguments[1] || { }); - var oldStyle = { - top: element.style.top, - left: element.style.left, - height: element.style.height, - width: element.style.width, - opacity: element.getInlineOpacity() }; - - var dims = element.getDimensions(); - var initialMoveX, initialMoveY; - var moveX, moveY; - - switch (options.direction) { - case 'top-left': - initialMoveX = initialMoveY = moveX = moveY = 0; - break; - case 'top-right': - initialMoveX = dims.width; - initialMoveY = moveY = 0; - moveX = -dims.width; - break; - case 'bottom-left': - initialMoveX = moveX = 0; - initialMoveY = dims.height; - moveY = -dims.height; - break; - case 'bottom-right': - initialMoveX = dims.width; - initialMoveY = dims.height; - moveX = -dims.width; - moveY = -dims.height; - break; - case 'center': - initialMoveX = dims.width / 2; - initialMoveY = dims.height / 2; - moveX = -dims.width / 2; - moveY = -dims.height / 2; - break; - } - - return new Effect.Move(element, { - x: initialMoveX, - y: initialMoveY, - duration: 0.01, - beforeSetup: function(effect) { - effect.element.hide().makeClipping().makePositioned(); - }, - afterFinishInternal: function(effect) { - new Effect.Parallel( - [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }), - new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }), - new Effect.Scale(effect.element, 100, { - scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, - sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true}) - ], Object.extend({ - beforeSetup: function(effect) { - effect.effects[0].element.setStyle({height: '0px'}).show(); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle); - } - }, options) - ); - } - }); -}; - -Effect.Shrink = function(element) { - element = $(element); - var options = Object.extend({ - direction: 'center', - moveTransition: Effect.Transitions.sinoidal, - scaleTransition: Effect.Transitions.sinoidal, - opacityTransition: Effect.Transitions.none - }, arguments[1] || { }); - var oldStyle = { - top: element.style.top, - left: element.style.left, - height: element.style.height, - width: element.style.width, - opacity: element.getInlineOpacity() }; - - var dims = element.getDimensions(); - var moveX, moveY; - - switch (options.direction) { - case 'top-left': - moveX = moveY = 0; - break; - case 'top-right': - moveX = dims.width; - moveY = 0; - break; - case 'bottom-left': - moveX = 0; - moveY = dims.height; - break; - case 'bottom-right': - moveX = dims.width; - moveY = dims.height; - break; - case 'center': - moveX = dims.width / 2; - moveY = dims.height / 2; - break; - } - - return new Effect.Parallel( - [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }), - new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}), - new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }) - ], Object.extend({ - beforeStartInternal: function(effect) { - effect.effects[0].element.makePositioned().makeClipping(); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); } - }, options) - ); -}; - -Effect.Pulsate = function(element) { - element = $(element); - var options = arguments[1] || { }, - oldOpacity = element.getInlineOpacity(), - transition = options.transition || Effect.Transitions.linear, - reverser = function(pos){ - return 1 - transition((-Math.cos((pos*(options.pulses||5)*2)*Math.PI)/2) + .5); - }; - - return new Effect.Opacity(element, - Object.extend(Object.extend({ duration: 2.0, from: 0, - afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); } - }, options), {transition: reverser})); -}; - -Effect.Fold = function(element) { - element = $(element); - var oldStyle = { - top: element.style.top, - left: element.style.left, - width: element.style.width, - height: element.style.height }; - element.makeClipping(); - return new Effect.Scale(element, 5, Object.extend({ - scaleContent: false, - scaleX: false, - afterFinishInternal: function(effect) { - new Effect.Scale(element, 1, { - scaleContent: false, - scaleY: false, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().setStyle(oldStyle); - } }); - }}, arguments[1] || { })); -}; - -Effect.Morph = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - style: { } - }, arguments[1] || { }); - - if (!Object.isString(options.style)) this.style = $H(options.style); - else { - if (options.style.include(':')) - this.style = options.style.parseStyle(); - else { - this.element.addClassName(options.style); - this.style = $H(this.element.getStyles()); - this.element.removeClassName(options.style); - var css = this.element.getStyles(); - this.style = this.style.reject(function(style) { - return style.value == css[style.key]; - }); - options.afterFinishInternal = function(effect) { - effect.element.addClassName(effect.options.style); - effect.transforms.each(function(transform) { - effect.element.style[transform.style] = ''; - }); - }; - } - } - this.start(options); - }, - - setup: function(){ - function parseColor(color){ - if (!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff'; - color = color.parseColor(); - return $R(0,2).map(function(i){ - return parseInt( color.slice(i*2+1,i*2+3), 16 ); - }); - } - this.transforms = this.style.map(function(pair){ - var property = pair[0], value = pair[1], unit = null; - - if (value.parseColor('#zzzzzz') != '#zzzzzz') { - value = value.parseColor(); - unit = 'color'; - } else if (property == 'opacity') { - value = parseFloat(value); - if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout)) - this.element.setStyle({zoom: 1}); - } else if (Element.CSS_LENGTH.test(value)) { - var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/); - value = parseFloat(components[1]); - unit = (components.length == 3) ? components[2] : null; - } - - var originalValue = this.element.getStyle(property); - return { - style: property.camelize(), - originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0), - targetValue: unit=='color' ? parseColor(value) : value, - unit: unit - }; - }.bind(this)).reject(function(transform){ - return ( - (transform.originalValue == transform.targetValue) || - ( - transform.unit != 'color' && - (isNaN(transform.originalValue) || isNaN(transform.targetValue)) - ) - ); - }); - }, - update: function(position) { - var style = { }, transform, i = this.transforms.length; - while(i--) - style[(transform = this.transforms[i]).style] = - transform.unit=='color' ? '#'+ - (Math.round(transform.originalValue[0]+ - (transform.targetValue[0]-transform.originalValue[0])*position)).toColorPart() + - (Math.round(transform.originalValue[1]+ - (transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart() + - (Math.round(transform.originalValue[2]+ - (transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() : - (transform.originalValue + - (transform.targetValue - transform.originalValue) * position).toFixed(3) + - (transform.unit === null ? '' : transform.unit); - this.element.setStyle(style, true); - } -}); - -Effect.Transform = Class.create({ - initialize: function(tracks){ - this.tracks = []; - this.options = arguments[1] || { }; - this.addTracks(tracks); - }, - addTracks: function(tracks){ - tracks.each(function(track){ - track = $H(track); - var data = track.values().first(); - this.tracks.push($H({ - ids: track.keys().first(), - effect: Effect.Morph, - options: { style: data } - })); - }.bind(this)); - return this; - }, - play: function(){ - return new Effect.Parallel( - this.tracks.map(function(track){ - var ids = track.get('ids'), effect = track.get('effect'), options = track.get('options'); - var elements = [$(ids) || $$(ids)].flatten(); - return elements.map(function(e){ return new effect(e, Object.extend({ sync:true }, options)) }); - }).flatten(), - this.options - ); - } -}); - -Element.CSS_PROPERTIES = $w( - 'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' + - 'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' + - 'borderRightColor borderRightStyle borderRightWidth borderSpacing ' + - 'borderTopColor borderTopStyle borderTopWidth bottom clip color ' + - 'fontSize fontWeight height left letterSpacing lineHeight ' + - 'marginBottom marginLeft marginRight marginTop markerOffset maxHeight '+ - 'maxWidth minHeight minWidth opacity outlineColor outlineOffset ' + - 'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' + - 'right textIndent top width wordSpacing zIndex'); - -Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/; - -String.__parseStyleElement = document.createElement('div'); -String.prototype.parseStyle = function(){ - var style, styleRules = $H(); - if (Prototype.Browser.WebKit) - style = new Element('div',{style:this}).style; - else { - String.__parseStyleElement.innerHTML = '
    '; - style = String.__parseStyleElement.childNodes[0].style; - } - - Element.CSS_PROPERTIES.each(function(property){ - if (style[property]) styleRules.set(property, style[property]); - }); - - if (Prototype.Browser.IE && this.include('opacity')) - styleRules.set('opacity', this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]); - - return styleRules; -}; - -if (document.defaultView && document.defaultView.getComputedStyle) { - Element.getStyles = function(element) { - var css = document.defaultView.getComputedStyle($(element), null); - return Element.CSS_PROPERTIES.inject({ }, function(styles, property) { - styles[property] = css[property]; - return styles; - }); - }; -} else { - Element.getStyles = function(element) { - element = $(element); - var css = element.currentStyle, styles; - styles = Element.CSS_PROPERTIES.inject({ }, function(results, property) { - results[property] = css[property]; - return results; - }); - if (!styles.opacity) styles.opacity = element.getOpacity(); - return styles; - }; -} - -Effect.Methods = { - morph: function(element, style) { - element = $(element); - new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || { })); - return element; - }, - visualEffect: function(element, effect, options) { - element = $(element); - var s = effect.dasherize().camelize(), klass = s.charAt(0).toUpperCase() + s.substring(1); - new Effect[klass](element, options); - return element; - }, - highlight: function(element, options) { - element = $(element); - new Effect.Highlight(element, options); - return element; - } -}; - -$w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+ - 'pulsate shake puff squish switchOff dropOut').each( - function(effect) { - Effect.Methods[effect] = function(element, options){ - element = $(element); - Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options); - return element; - }; - } -); - -$w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each( - function(f) { Effect.Methods[f] = Element[f]; } -); - -Element.addMethods(Effect.Methods); \ No newline at end of file diff --git a/public/javascripts/prototype.js b/public/javascripts/prototype.js deleted file mode 100644 index dfe8ab4..0000000 --- a/public/javascripts/prototype.js +++ /dev/null @@ -1,4320 +0,0 @@ -/* Prototype JavaScript framework, version 1.6.0.3 - * (c) 2005-2008 Sam Stephenson - * - * Prototype is freely distributable under the terms of an MIT-style license. - * For details, see the Prototype web site: http://www.prototypejs.org/ - * - *--------------------------------------------------------------------------*/ - -var Prototype = { - Version: '1.6.0.3', - - Browser: { - IE: !!(window.attachEvent && - navigator.userAgent.indexOf('Opera') === -1), - Opera: navigator.userAgent.indexOf('Opera') > -1, - WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, - Gecko: navigator.userAgent.indexOf('Gecko') > -1 && - navigator.userAgent.indexOf('KHTML') === -1, - MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/) - }, - - BrowserFeatures: { - XPath: !!document.evaluate, - SelectorsAPI: !!document.querySelector, - ElementExtensions: !!window.HTMLElement, - SpecificElementExtensions: - document.createElement('div')['__proto__'] && - document.createElement('div')['__proto__'] !== - document.createElement('form')['__proto__'] - }, - - ScriptFragment: ']*>([\\S\\s]*?)<\/script>', - JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, - - emptyFunction: function() { }, - K: function(x) { return x } -}; - -if (Prototype.Browser.MobileSafari) - Prototype.BrowserFeatures.SpecificElementExtensions = false; - - -/* Based on Alex Arnell's inheritance implementation. */ -var Class = { - create: function() { - var parent = null, properties = $A(arguments); - if (Object.isFunction(properties[0])) - parent = properties.shift(); - - function klass() { - this.initialize.apply(this, arguments); - } - - Object.extend(klass, Class.Methods); - klass.superclass = parent; - klass.subclasses = []; - - if (parent) { - var subclass = function() { }; - subclass.prototype = parent.prototype; - klass.prototype = new subclass; - parent.subclasses.push(klass); - } - - for (var i = 0; i < properties.length; i++) - klass.addMethods(properties[i]); - - if (!klass.prototype.initialize) - klass.prototype.initialize = Prototype.emptyFunction; - - klass.prototype.constructor = klass; - - return klass; - } -}; - -Class.Methods = { - addMethods: function(source) { - var ancestor = this.superclass && this.superclass.prototype; - var properties = Object.keys(source); - - if (!Object.keys({ toString: true }).length) - properties.push("toString", "valueOf"); - - for (var i = 0, length = properties.length; i < length; i++) { - var property = properties[i], value = source[property]; - if (ancestor && Object.isFunction(value) && - value.argumentNames().first() == "$super") { - var method = value; - value = (function(m) { - return function() { return ancestor[m].apply(this, arguments) }; - })(property).wrap(method); - - value.valueOf = method.valueOf.bind(method); - value.toString = method.toString.bind(method); - } - this.prototype[property] = value; - } - - return this; - } -}; - -var Abstract = { }; - -Object.extend = function(destination, source) { - for (var property in source) - destination[property] = source[property]; - return destination; -}; - -Object.extend(Object, { - inspect: function(object) { - try { - if (Object.isUndefined(object)) return 'undefined'; - if (object === null) return 'null'; - return object.inspect ? object.inspect() : String(object); - } catch (e) { - if (e instanceof RangeError) return '...'; - throw e; - } - }, - - toJSON: function(object) { - var type = typeof object; - switch (type) { - case 'undefined': - case 'function': - case 'unknown': return; - case 'boolean': return object.toString(); - } - - if (object === null) return 'null'; - if (object.toJSON) return object.toJSON(); - if (Object.isElement(object)) return; - - var results = []; - for (var property in object) { - var value = Object.toJSON(object[property]); - if (!Object.isUndefined(value)) - results.push(property.toJSON() + ': ' + value); - } - - return '{' + results.join(', ') + '}'; - }, - - toQueryString: function(object) { - return $H(object).toQueryString(); - }, - - toHTML: function(object) { - return object && object.toHTML ? object.toHTML() : String.interpret(object); - }, - - keys: function(object) { - var keys = []; - for (var property in object) - keys.push(property); - return keys; - }, - - values: function(object) { - var values = []; - for (var property in object) - values.push(object[property]); - return values; - }, - - clone: function(object) { - return Object.extend({ }, object); - }, - - isElement: function(object) { - return !!(object && object.nodeType == 1); - }, - - isArray: function(object) { - return object != null && typeof object == "object" && - 'splice' in object && 'join' in object; - }, - - isHash: function(object) { - return object instanceof Hash; - }, - - isFunction: function(object) { - return typeof object == "function"; - }, - - isString: function(object) { - return typeof object == "string"; - }, - - isNumber: function(object) { - return typeof object == "number"; - }, - - isUndefined: function(object) { - return typeof object == "undefined"; - } -}); - -Object.extend(Function.prototype, { - argumentNames: function() { - var names = this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1] - .replace(/\s+/g, '').split(','); - return names.length == 1 && !names[0] ? [] : names; - }, - - bind: function() { - if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this; - var __method = this, args = $A(arguments), object = args.shift(); - return function() { - return __method.apply(object, args.concat($A(arguments))); - } - }, - - bindAsEventListener: function() { - var __method = this, args = $A(arguments), object = args.shift(); - return function(event) { - return __method.apply(object, [event || window.event].concat(args)); - } - }, - - curry: function() { - if (!arguments.length) return this; - var __method = this, args = $A(arguments); - return function() { - return __method.apply(this, args.concat($A(arguments))); - } - }, - - delay: function() { - var __method = this, args = $A(arguments), timeout = args.shift() * 1000; - return window.setTimeout(function() { - return __method.apply(__method, args); - }, timeout); - }, - - defer: function() { - var args = [0.01].concat($A(arguments)); - return this.delay.apply(this, args); - }, - - wrap: function(wrapper) { - var __method = this; - return function() { - return wrapper.apply(this, [__method.bind(this)].concat($A(arguments))); - } - }, - - methodize: function() { - if (this._methodized) return this._methodized; - var __method = this; - return this._methodized = function() { - return __method.apply(null, [this].concat($A(arguments))); - }; - } -}); - -Date.prototype.toJSON = function() { - return '"' + this.getUTCFullYear() + '-' + - (this.getUTCMonth() + 1).toPaddedString(2) + '-' + - this.getUTCDate().toPaddedString(2) + 'T' + - this.getUTCHours().toPaddedString(2) + ':' + - this.getUTCMinutes().toPaddedString(2) + ':' + - this.getUTCSeconds().toPaddedString(2) + 'Z"'; -}; - -var Try = { - these: function() { - var returnValue; - - for (var i = 0, length = arguments.length; i < length; i++) { - var lambda = arguments[i]; - try { - returnValue = lambda(); - break; - } catch (e) { } - } - - return returnValue; - } -}; - -RegExp.prototype.match = RegExp.prototype.test; - -RegExp.escape = function(str) { - return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); -}; - -/*--------------------------------------------------------------------------*/ - -var PeriodicalExecuter = Class.create({ - initialize: function(callback, frequency) { - this.callback = callback; - this.frequency = frequency; - this.currentlyExecuting = false; - - this.registerCallback(); - }, - - registerCallback: function() { - this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); - }, - - execute: function() { - this.callback(this); - }, - - stop: function() { - if (!this.timer) return; - clearInterval(this.timer); - this.timer = null; - }, - - onTimerEvent: function() { - if (!this.currentlyExecuting) { - try { - this.currentlyExecuting = true; - this.execute(); - } finally { - this.currentlyExecuting = false; - } - } - } -}); -Object.extend(String, { - interpret: function(value) { - return value == null ? '' : String(value); - }, - specialChar: { - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '\\': '\\\\' - } -}); - -Object.extend(String.prototype, { - gsub: function(pattern, replacement) { - var result = '', source = this, match; - replacement = arguments.callee.prepareReplacement(replacement); - - while (source.length > 0) { - if (match = source.match(pattern)) { - result += source.slice(0, match.index); - result += String.interpret(replacement(match)); - source = source.slice(match.index + match[0].length); - } else { - result += source, source = ''; - } - } - return result; - }, - - sub: function(pattern, replacement, count) { - replacement = this.gsub.prepareReplacement(replacement); - count = Object.isUndefined(count) ? 1 : count; - - return this.gsub(pattern, function(match) { - if (--count < 0) return match[0]; - return replacement(match); - }); - }, - - scan: function(pattern, iterator) { - this.gsub(pattern, iterator); - return String(this); - }, - - truncate: function(length, truncation) { - length = length || 30; - truncation = Object.isUndefined(truncation) ? '...' : truncation; - return this.length > length ? - this.slice(0, length - truncation.length) + truncation : String(this); - }, - - strip: function() { - return this.replace(/^\s+/, '').replace(/\s+$/, ''); - }, - - stripTags: function() { - return this.replace(/<\/?[^>]+>/gi, ''); - }, - - stripScripts: function() { - return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); - }, - - extractScripts: function() { - var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); - var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); - return (this.match(matchAll) || []).map(function(scriptTag) { - return (scriptTag.match(matchOne) || ['', ''])[1]; - }); - }, - - evalScripts: function() { - return this.extractScripts().map(function(script) { return eval(script) }); - }, - - escapeHTML: function() { - var self = arguments.callee; - self.text.data = this; - return self.div.innerHTML; - }, - - unescapeHTML: function() { - var div = new Element('div'); - div.innerHTML = this.stripTags(); - return div.childNodes[0] ? (div.childNodes.length > 1 ? - $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) : - div.childNodes[0].nodeValue) : ''; - }, - - toQueryParams: function(separator) { - var match = this.strip().match(/([^?#]*)(#.*)?$/); - if (!match) return { }; - - return match[1].split(separator || '&').inject({ }, function(hash, pair) { - if ((pair = pair.split('='))[0]) { - var key = decodeURIComponent(pair.shift()); - var value = pair.length > 1 ? pair.join('=') : pair[0]; - if (value != undefined) value = decodeURIComponent(value); - - if (key in hash) { - if (!Object.isArray(hash[key])) hash[key] = [hash[key]]; - hash[key].push(value); - } - else hash[key] = value; - } - return hash; - }); - }, - - toArray: function() { - return this.split(''); - }, - - succ: function() { - return this.slice(0, this.length - 1) + - String.fromCharCode(this.charCodeAt(this.length - 1) + 1); - }, - - times: function(count) { - return count < 1 ? '' : new Array(count + 1).join(this); - }, - - camelize: function() { - var parts = this.split('-'), len = parts.length; - if (len == 1) return parts[0]; - - var camelized = this.charAt(0) == '-' - ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) - : parts[0]; - - for (var i = 1; i < len; i++) - camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); - - return camelized; - }, - - capitalize: function() { - return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); - }, - - underscore: function() { - return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase(); - }, - - dasherize: function() { - return this.gsub(/_/,'-'); - }, - - inspect: function(useDoubleQuotes) { - var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) { - var character = String.specialChar[match[0]]; - return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16); - }); - if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"'; - return "'" + escapedString.replace(/'/g, '\\\'') + "'"; - }, - - toJSON: function() { - return this.inspect(true); - }, - - unfilterJSON: function(filter) { - return this.sub(filter || Prototype.JSONFilter, '#{1}'); - }, - - isJSON: function() { - var str = this; - if (str.blank()) return false; - str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); - return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str); - }, - - evalJSON: function(sanitize) { - var json = this.unfilterJSON(); - try { - if (!sanitize || json.isJSON()) return eval('(' + json + ')'); - } catch (e) { } - throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); - }, - - include: function(pattern) { - return this.indexOf(pattern) > -1; - }, - - startsWith: function(pattern) { - return this.indexOf(pattern) === 0; - }, - - endsWith: function(pattern) { - var d = this.length - pattern.length; - return d >= 0 && this.lastIndexOf(pattern) === d; - }, - - empty: function() { - return this == ''; - }, - - blank: function() { - return /^\s*$/.test(this); - }, - - interpolate: function(object, pattern) { - return new Template(this, pattern).evaluate(object); - } -}); - -if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, { - escapeHTML: function() { - return this.replace(/&/g,'&').replace(//g,'>'); - }, - unescapeHTML: function() { - return this.stripTags().replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); - } -}); - -String.prototype.gsub.prepareReplacement = function(replacement) { - if (Object.isFunction(replacement)) return replacement; - var template = new Template(replacement); - return function(match) { return template.evaluate(match) }; -}; - -String.prototype.parseQuery = String.prototype.toQueryParams; - -Object.extend(String.prototype.escapeHTML, { - div: document.createElement('div'), - text: document.createTextNode('') -}); - -String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text); - -var Template = Class.create({ - initialize: function(template, pattern) { - this.template = template.toString(); - this.pattern = pattern || Template.Pattern; - }, - - evaluate: function(object) { - if (Object.isFunction(object.toTemplateReplacements)) - object = object.toTemplateReplacements(); - - return this.template.gsub(this.pattern, function(match) { - if (object == null) return ''; - - var before = match[1] || ''; - if (before == '\\') return match[2]; - - var ctx = object, expr = match[3]; - var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/; - match = pattern.exec(expr); - if (match == null) return before; - - while (match != null) { - var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1]; - ctx = ctx[comp]; - if (null == ctx || '' == match[3]) break; - expr = expr.substring('[' == match[3] ? match[1].length : match[0].length); - match = pattern.exec(expr); - } - - return before + String.interpret(ctx); - }); - } -}); -Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; - -var $break = { }; - -var Enumerable = { - each: function(iterator, context) { - var index = 0; - try { - this._each(function(value) { - iterator.call(context, value, index++); - }); - } catch (e) { - if (e != $break) throw e; - } - return this; - }, - - eachSlice: function(number, iterator, context) { - var index = -number, slices = [], array = this.toArray(); - if (number < 1) return array; - while ((index += number) < array.length) - slices.push(array.slice(index, index+number)); - return slices.collect(iterator, context); - }, - - all: function(iterator, context) { - iterator = iterator || Prototype.K; - var result = true; - this.each(function(value, index) { - result = result && !!iterator.call(context, value, index); - if (!result) throw $break; - }); - return result; - }, - - any: function(iterator, context) { - iterator = iterator || Prototype.K; - var result = false; - this.each(function(value, index) { - if (result = !!iterator.call(context, value, index)) - throw $break; - }); - return result; - }, - - collect: function(iterator, context) { - iterator = iterator || Prototype.K; - var results = []; - this.each(function(value, index) { - results.push(iterator.call(context, value, index)); - }); - return results; - }, - - detect: function(iterator, context) { - var result; - this.each(function(value, index) { - if (iterator.call(context, value, index)) { - result = value; - throw $break; - } - }); - return result; - }, - - findAll: function(iterator, context) { - var results = []; - this.each(function(value, index) { - if (iterator.call(context, value, index)) - results.push(value); - }); - return results; - }, - - grep: function(filter, iterator, context) { - iterator = iterator || Prototype.K; - var results = []; - - if (Object.isString(filter)) - filter = new RegExp(filter); - - this.each(function(value, index) { - if (filter.match(value)) - results.push(iterator.call(context, value, index)); - }); - return results; - }, - - include: function(object) { - if (Object.isFunction(this.indexOf)) - if (this.indexOf(object) != -1) return true; - - var found = false; - this.each(function(value) { - if (value == object) { - found = true; - throw $break; - } - }); - return found; - }, - - inGroupsOf: function(number, fillWith) { - fillWith = Object.isUndefined(fillWith) ? null : fillWith; - return this.eachSlice(number, function(slice) { - while(slice.length < number) slice.push(fillWith); - return slice; - }); - }, - - inject: function(memo, iterator, context) { - this.each(function(value, index) { - memo = iterator.call(context, memo, value, index); - }); - return memo; - }, - - invoke: function(method) { - var args = $A(arguments).slice(1); - return this.map(function(value) { - return value[method].apply(value, args); - }); - }, - - max: function(iterator, context) { - iterator = iterator || Prototype.K; - var result; - this.each(function(value, index) { - value = iterator.call(context, value, index); - if (result == null || value >= result) - result = value; - }); - return result; - }, - - min: function(iterator, context) { - iterator = iterator || Prototype.K; - var result; - this.each(function(value, index) { - value = iterator.call(context, value, index); - if (result == null || value < result) - result = value; - }); - return result; - }, - - partition: function(iterator, context) { - iterator = iterator || Prototype.K; - var trues = [], falses = []; - this.each(function(value, index) { - (iterator.call(context, value, index) ? - trues : falses).push(value); - }); - return [trues, falses]; - }, - - pluck: function(property) { - var results = []; - this.each(function(value) { - results.push(value[property]); - }); - return results; - }, - - reject: function(iterator, context) { - var results = []; - this.each(function(value, index) { - if (!iterator.call(context, value, index)) - results.push(value); - }); - return results; - }, - - sortBy: function(iterator, context) { - return this.map(function(value, index) { - return { - value: value, - criteria: iterator.call(context, value, index) - }; - }).sort(function(left, right) { - var a = left.criteria, b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - }).pluck('value'); - }, - - toArray: function() { - return this.map(); - }, - - zip: function() { - var iterator = Prototype.K, args = $A(arguments); - if (Object.isFunction(args.last())) - iterator = args.pop(); - - var collections = [this].concat(args).map($A); - return this.map(function(value, index) { - return iterator(collections.pluck(index)); - }); - }, - - size: function() { - return this.toArray().length; - }, - - inspect: function() { - return '#'; - } -}; - -Object.extend(Enumerable, { - map: Enumerable.collect, - find: Enumerable.detect, - select: Enumerable.findAll, - filter: Enumerable.findAll, - member: Enumerable.include, - entries: Enumerable.toArray, - every: Enumerable.all, - some: Enumerable.any -}); -function $A(iterable) { - if (!iterable) return []; - if (iterable.toArray) return iterable.toArray(); - var length = iterable.length || 0, results = new Array(length); - while (length--) results[length] = iterable[length]; - return results; -} - -if (Prototype.Browser.WebKit) { - $A = function(iterable) { - if (!iterable) return []; - // In Safari, only use the `toArray` method if it's not a NodeList. - // A NodeList is a function, has an function `item` property, and a numeric - // `length` property. Adapted from Google Doctype. - if (!(typeof iterable === 'function' && typeof iterable.length === - 'number' && typeof iterable.item === 'function') && iterable.toArray) - return iterable.toArray(); - var length = iterable.length || 0, results = new Array(length); - while (length--) results[length] = iterable[length]; - return results; - }; -} - -Array.from = $A; - -Object.extend(Array.prototype, Enumerable); - -if (!Array.prototype._reverse) Array.prototype._reverse = Array.prototype.reverse; - -Object.extend(Array.prototype, { - _each: function(iterator) { - for (var i = 0, length = this.length; i < length; i++) - iterator(this[i]); - }, - - clear: function() { - this.length = 0; - return this; - }, - - first: function() { - return this[0]; - }, - - last: function() { - return this[this.length - 1]; - }, - - compact: function() { - return this.select(function(value) { - return value != null; - }); - }, - - flatten: function() { - return this.inject([], function(array, value) { - return array.concat(Object.isArray(value) ? - value.flatten() : [value]); - }); - }, - - without: function() { - var values = $A(arguments); - return this.select(function(value) { - return !values.include(value); - }); - }, - - reverse: function(inline) { - return (inline !== false ? this : this.toArray())._reverse(); - }, - - reduce: function() { - return this.length > 1 ? this : this[0]; - }, - - uniq: function(sorted) { - return this.inject([], function(array, value, index) { - if (0 == index || (sorted ? array.last() != value : !array.include(value))) - array.push(value); - return array; - }); - }, - - intersect: function(array) { - return this.uniq().findAll(function(item) { - return array.detect(function(value) { return item === value }); - }); - }, - - clone: function() { - return [].concat(this); - }, - - size: function() { - return this.length; - }, - - inspect: function() { - return '[' + this.map(Object.inspect).join(', ') + ']'; - }, - - toJSON: function() { - var results = []; - this.each(function(object) { - var value = Object.toJSON(object); - if (!Object.isUndefined(value)) results.push(value); - }); - return '[' + results.join(', ') + ']'; - } -}); - -// use native browser JS 1.6 implementation if available -if (Object.isFunction(Array.prototype.forEach)) - Array.prototype._each = Array.prototype.forEach; - -if (!Array.prototype.indexOf) Array.prototype.indexOf = function(item, i) { - i || (i = 0); - var length = this.length; - if (i < 0) i = length + i; - for (; i < length; i++) - if (this[i] === item) return i; - return -1; -}; - -if (!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(item, i) { - i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1; - var n = this.slice(0, i).reverse().indexOf(item); - return (n < 0) ? n : i - n - 1; -}; - -Array.prototype.toArray = Array.prototype.clone; - -function $w(string) { - if (!Object.isString(string)) return []; - string = string.strip(); - return string ? string.split(/\s+/) : []; -} - -if (Prototype.Browser.Opera){ - Array.prototype.concat = function() { - var array = []; - for (var i = 0, length = this.length; i < length; i++) array.push(this[i]); - for (var i = 0, length = arguments.length; i < length; i++) { - if (Object.isArray(arguments[i])) { - for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) - array.push(arguments[i][j]); - } else { - array.push(arguments[i]); - } - } - return array; - }; -} -Object.extend(Number.prototype, { - toColorPart: function() { - return this.toPaddedString(2, 16); - }, - - succ: function() { - return this + 1; - }, - - times: function(iterator, context) { - $R(0, this, true).each(iterator, context); - return this; - }, - - toPaddedString: function(length, radix) { - var string = this.toString(radix || 10); - return '0'.times(length - string.length) + string; - }, - - toJSON: function() { - return isFinite(this) ? this.toString() : 'null'; - } -}); - -$w('abs round ceil floor').each(function(method){ - Number.prototype[method] = Math[method].methodize(); -}); -function $H(object) { - return new Hash(object); -}; - -var Hash = Class.create(Enumerable, (function() { - - function toQueryPair(key, value) { - if (Object.isUndefined(value)) return key; - return key + '=' + encodeURIComponent(String.interpret(value)); - } - - return { - initialize: function(object) { - this._object = Object.isHash(object) ? object.toObject() : Object.clone(object); - }, - - _each: function(iterator) { - for (var key in this._object) { - var value = this._object[key], pair = [key, value]; - pair.key = key; - pair.value = value; - iterator(pair); - } - }, - - set: function(key, value) { - return this._object[key] = value; - }, - - get: function(key) { - // simulating poorly supported hasOwnProperty - if (this._object[key] !== Object.prototype[key]) - return this._object[key]; - }, - - unset: function(key) { - var value = this._object[key]; - delete this._object[key]; - return value; - }, - - toObject: function() { - return Object.clone(this._object); - }, - - keys: function() { - return this.pluck('key'); - }, - - values: function() { - return this.pluck('value'); - }, - - index: function(value) { - var match = this.detect(function(pair) { - return pair.value === value; - }); - return match && match.key; - }, - - merge: function(object) { - return this.clone().update(object); - }, - - update: function(object) { - return new Hash(object).inject(this, function(result, pair) { - result.set(pair.key, pair.value); - return result; - }); - }, - - toQueryString: function() { - return this.inject([], function(results, pair) { - var key = encodeURIComponent(pair.key), values = pair.value; - - if (values && typeof values == 'object') { - if (Object.isArray(values)) - return results.concat(values.map(toQueryPair.curry(key))); - } else results.push(toQueryPair(key, values)); - return results; - }).join('&'); - }, - - inspect: function() { - return '#'; - }, - - toJSON: function() { - return Object.toJSON(this.toObject()); - }, - - clone: function() { - return new Hash(this); - } - } -})()); - -Hash.prototype.toTemplateReplacements = Hash.prototype.toObject; -Hash.from = $H; -var ObjectRange = Class.create(Enumerable, { - initialize: function(start, end, exclusive) { - this.start = start; - this.end = end; - this.exclusive = exclusive; - }, - - _each: function(iterator) { - var value = this.start; - while (this.include(value)) { - iterator(value); - value = value.succ(); - } - }, - - include: function(value) { - if (value < this.start) - return false; - if (this.exclusive) - return value < this.end; - return value <= this.end; - } -}); - -var $R = function(start, end, exclusive) { - return new ObjectRange(start, end, exclusive); -}; - -var Ajax = { - getTransport: function() { - return Try.these( - function() {return new XMLHttpRequest()}, - function() {return new ActiveXObject('Msxml2.XMLHTTP')}, - function() {return new ActiveXObject('Microsoft.XMLHTTP')} - ) || false; - }, - - activeRequestCount: 0 -}; - -Ajax.Responders = { - responders: [], - - _each: function(iterator) { - this.responders._each(iterator); - }, - - register: function(responder) { - if (!this.include(responder)) - this.responders.push(responder); - }, - - unregister: function(responder) { - this.responders = this.responders.without(responder); - }, - - dispatch: function(callback, request, transport, json) { - this.each(function(responder) { - if (Object.isFunction(responder[callback])) { - try { - responder[callback].apply(responder, [request, transport, json]); - } catch (e) { } - } - }); - } -}; - -Object.extend(Ajax.Responders, Enumerable); - -Ajax.Responders.register({ - onCreate: function() { Ajax.activeRequestCount++ }, - onComplete: function() { Ajax.activeRequestCount-- } -}); - -Ajax.Base = Class.create({ - initialize: function(options) { - this.options = { - method: 'post', - asynchronous: true, - contentType: 'application/x-www-form-urlencoded', - encoding: 'UTF-8', - parameters: '', - evalJSON: true, - evalJS: true - }; - Object.extend(this.options, options || { }); - - this.options.method = this.options.method.toLowerCase(); - - if (Object.isString(this.options.parameters)) - this.options.parameters = this.options.parameters.toQueryParams(); - else if (Object.isHash(this.options.parameters)) - this.options.parameters = this.options.parameters.toObject(); - } -}); - -Ajax.Request = Class.create(Ajax.Base, { - _complete: false, - - initialize: function($super, url, options) { - $super(options); - this.transport = Ajax.getTransport(); - this.request(url); - }, - - request: function(url) { - this.url = url; - this.method = this.options.method; - var params = Object.clone(this.options.parameters); - - if (!['get', 'post'].include(this.method)) { - // simulate other verbs over post - params['_method'] = this.method; - this.method = 'post'; - } - - this.parameters = params; - - if (params = Object.toQueryString(params)) { - // when GET, append parameters to URL - if (this.method == 'get') - this.url += (this.url.include('?') ? '&' : '?') + params; - else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) - params += '&_='; - } - - try { - var response = new Ajax.Response(this); - if (this.options.onCreate) this.options.onCreate(response); - Ajax.Responders.dispatch('onCreate', this, response); - - this.transport.open(this.method.toUpperCase(), this.url, - this.options.asynchronous); - - if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1); - - this.transport.onreadystatechange = this.onStateChange.bind(this); - this.setRequestHeaders(); - - this.body = this.method == 'post' ? (this.options.postBody || params) : null; - this.transport.send(this.body); - - /* Force Firefox to handle ready state 4 for synchronous requests */ - if (!this.options.asynchronous && this.transport.overrideMimeType) - this.onStateChange(); - - } - catch (e) { - this.dispatchException(e); - } - }, - - onStateChange: function() { - var readyState = this.transport.readyState; - if (readyState > 1 && !((readyState == 4) && this._complete)) - this.respondToReadyState(this.transport.readyState); - }, - - setRequestHeaders: function() { - var headers = { - 'X-Requested-With': 'XMLHttpRequest', - 'X-Prototype-Version': Prototype.Version, - 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' - }; - - if (this.method == 'post') { - headers['Content-type'] = this.options.contentType + - (this.options.encoding ? '; charset=' + this.options.encoding : ''); - - /* Force "Connection: close" for older Mozilla browsers to work - * around a bug where XMLHttpRequest sends an incorrect - * Content-length header. See Mozilla Bugzilla #246651. - */ - if (this.transport.overrideMimeType && - (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) - headers['Connection'] = 'close'; - } - - // user-defined headers - if (typeof this.options.requestHeaders == 'object') { - var extras = this.options.requestHeaders; - - if (Object.isFunction(extras.push)) - for (var i = 0, length = extras.length; i < length; i += 2) - headers[extras[i]] = extras[i+1]; - else - $H(extras).each(function(pair) { headers[pair.key] = pair.value }); - } - - for (var name in headers) - this.transport.setRequestHeader(name, headers[name]); - }, - - success: function() { - var status = this.getStatus(); - return !status || (status >= 200 && status < 300); - }, - - getStatus: function() { - try { - return this.transport.status || 0; - } catch (e) { return 0 } - }, - - respondToReadyState: function(readyState) { - var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this); - - if (state == 'Complete') { - try { - this._complete = true; - (this.options['on' + response.status] - || this.options['on' + (this.success() ? 'Success' : 'Failure')] - || Prototype.emptyFunction)(response, response.headerJSON); - } catch (e) { - this.dispatchException(e); - } - - var contentType = response.getHeader('Content-type'); - if (this.options.evalJS == 'force' - || (this.options.evalJS && this.isSameOrigin() && contentType - && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))) - this.evalResponse(); - } - - try { - (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON); - Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON); - } catch (e) { - this.dispatchException(e); - } - - if (state == 'Complete') { - // avoid memory leak in MSIE: clean up - this.transport.onreadystatechange = Prototype.emptyFunction; - } - }, - - isSameOrigin: function() { - var m = this.url.match(/^\s*https?:\/\/[^\/]*/); - return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({ - protocol: location.protocol, - domain: document.domain, - port: location.port ? ':' + location.port : '' - })); - }, - - getHeader: function(name) { - try { - return this.transport.getResponseHeader(name) || null; - } catch (e) { return null } - }, - - evalResponse: function() { - try { - return eval((this.transport.responseText || '').unfilterJSON()); - } catch (e) { - this.dispatchException(e); - } - }, - - dispatchException: function(exception) { - (this.options.onException || Prototype.emptyFunction)(this, exception); - Ajax.Responders.dispatch('onException', this, exception); - } -}); - -Ajax.Request.Events = - ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; - -Ajax.Response = Class.create({ - initialize: function(request){ - this.request = request; - var transport = this.transport = request.transport, - readyState = this.readyState = transport.readyState; - - if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) { - this.status = this.getStatus(); - this.statusText = this.getStatusText(); - this.responseText = String.interpret(transport.responseText); - this.headerJSON = this._getHeaderJSON(); - } - - if(readyState == 4) { - var xml = transport.responseXML; - this.responseXML = Object.isUndefined(xml) ? null : xml; - this.responseJSON = this._getResponseJSON(); - } - }, - - status: 0, - statusText: '', - - getStatus: Ajax.Request.prototype.getStatus, - - getStatusText: function() { - try { - return this.transport.statusText || ''; - } catch (e) { return '' } - }, - - getHeader: Ajax.Request.prototype.getHeader, - - getAllHeaders: function() { - try { - return this.getAllResponseHeaders(); - } catch (e) { return null } - }, - - getResponseHeader: function(name) { - return this.transport.getResponseHeader(name); - }, - - getAllResponseHeaders: function() { - return this.transport.getAllResponseHeaders(); - }, - - _getHeaderJSON: function() { - var json = this.getHeader('X-JSON'); - if (!json) return null; - json = decodeURIComponent(escape(json)); - try { - return json.evalJSON(this.request.options.sanitizeJSON || - !this.request.isSameOrigin()); - } catch (e) { - this.request.dispatchException(e); - } - }, - - _getResponseJSON: function() { - var options = this.request.options; - if (!options.evalJSON || (options.evalJSON != 'force' && - !(this.getHeader('Content-type') || '').include('application/json')) || - this.responseText.blank()) - return null; - try { - return this.responseText.evalJSON(options.sanitizeJSON || - !this.request.isSameOrigin()); - } catch (e) { - this.request.dispatchException(e); - } - } -}); - -Ajax.Updater = Class.create(Ajax.Request, { - initialize: function($super, container, url, options) { - this.container = { - success: (container.success || container), - failure: (container.failure || (container.success ? null : container)) - }; - - options = Object.clone(options); - var onComplete = options.onComplete; - options.onComplete = (function(response, json) { - this.updateContent(response.responseText); - if (Object.isFunction(onComplete)) onComplete(response, json); - }).bind(this); - - $super(url, options); - }, - - updateContent: function(responseText) { - var receiver = this.container[this.success() ? 'success' : 'failure'], - options = this.options; - - if (!options.evalScripts) responseText = responseText.stripScripts(); - - if (receiver = $(receiver)) { - if (options.insertion) { - if (Object.isString(options.insertion)) { - var insertion = { }; insertion[options.insertion] = responseText; - receiver.insert(insertion); - } - else options.insertion(receiver, responseText); - } - else receiver.update(responseText); - } - } -}); - -Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { - initialize: function($super, container, url, options) { - $super(options); - this.onComplete = this.options.onComplete; - - this.frequency = (this.options.frequency || 2); - this.decay = (this.options.decay || 1); - - this.updater = { }; - this.container = container; - this.url = url; - - this.start(); - }, - - start: function() { - this.options.onComplete = this.updateComplete.bind(this); - this.onTimerEvent(); - }, - - stop: function() { - this.updater.options.onComplete = undefined; - clearTimeout(this.timer); - (this.onComplete || Prototype.emptyFunction).apply(this, arguments); - }, - - updateComplete: function(response) { - if (this.options.decay) { - this.decay = (response.responseText == this.lastText ? - this.decay * this.options.decay : 1); - - this.lastText = response.responseText; - } - this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency); - }, - - onTimerEvent: function() { - this.updater = new Ajax.Updater(this.container, this.url, this.options); - } -}); -function $(element) { - if (arguments.length > 1) { - for (var i = 0, elements = [], length = arguments.length; i < length; i++) - elements.push($(arguments[i])); - return elements; - } - if (Object.isString(element)) - element = document.getElementById(element); - return Element.extend(element); -} - -if (Prototype.BrowserFeatures.XPath) { - document._getElementsByXPath = function(expression, parentElement) { - var results = []; - var query = document.evaluate(expression, $(parentElement) || document, - null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - for (var i = 0, length = query.snapshotLength; i < length; i++) - results.push(Element.extend(query.snapshotItem(i))); - return results; - }; -} - -/*--------------------------------------------------------------------------*/ - -if (!window.Node) var Node = { }; - -if (!Node.ELEMENT_NODE) { - // DOM level 2 ECMAScript Language Binding - Object.extend(Node, { - ELEMENT_NODE: 1, - ATTRIBUTE_NODE: 2, - TEXT_NODE: 3, - CDATA_SECTION_NODE: 4, - ENTITY_REFERENCE_NODE: 5, - ENTITY_NODE: 6, - PROCESSING_INSTRUCTION_NODE: 7, - COMMENT_NODE: 8, - DOCUMENT_NODE: 9, - DOCUMENT_TYPE_NODE: 10, - DOCUMENT_FRAGMENT_NODE: 11, - NOTATION_NODE: 12 - }); -} - -(function() { - var element = this.Element; - this.Element = function(tagName, attributes) { - attributes = attributes || { }; - tagName = tagName.toLowerCase(); - var cache = Element.cache; - if (Prototype.Browser.IE && attributes.name) { - tagName = '<' + tagName + ' name="' + attributes.name + '">'; - delete attributes.name; - return Element.writeAttribute(document.createElement(tagName), attributes); - } - if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName)); - return Element.writeAttribute(cache[tagName].cloneNode(false), attributes); - }; - Object.extend(this.Element, element || { }); - if (element) this.Element.prototype = element.prototype; -}).call(window); - -Element.cache = { }; - -Element.Methods = { - visible: function(element) { - return $(element).style.display != 'none'; - }, - - toggle: function(element) { - element = $(element); - Element[Element.visible(element) ? 'hide' : 'show'](element); - return element; - }, - - hide: function(element) { - element = $(element); - element.style.display = 'none'; - return element; - }, - - show: function(element) { - element = $(element); - element.style.display = ''; - return element; - }, - - remove: function(element) { - element = $(element); - element.parentNode.removeChild(element); - return element; - }, - - update: function(element, content) { - element = $(element); - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) return element.update().insert(content); - content = Object.toHTML(content); - element.innerHTML = content.stripScripts(); - content.evalScripts.bind(content).defer(); - return element; - }, - - replace: function(element, content) { - element = $(element); - if (content && content.toElement) content = content.toElement(); - else if (!Object.isElement(content)) { - content = Object.toHTML(content); - var range = element.ownerDocument.createRange(); - range.selectNode(element); - content.evalScripts.bind(content).defer(); - content = range.createContextualFragment(content.stripScripts()); - } - element.parentNode.replaceChild(content, element); - return element; - }, - - insert: function(element, insertions) { - element = $(element); - - if (Object.isString(insertions) || Object.isNumber(insertions) || - Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML))) - insertions = {bottom:insertions}; - - var content, insert, tagName, childNodes; - - for (var position in insertions) { - content = insertions[position]; - position = position.toLowerCase(); - insert = Element._insertionTranslations[position]; - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) { - insert(element, content); - continue; - } - - content = Object.toHTML(content); - - tagName = ((position == 'before' || position == 'after') - ? element.parentNode : element).tagName.toUpperCase(); - - childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); - - if (position == 'top' || position == 'after') childNodes.reverse(); - childNodes.each(insert.curry(element)); - - content.evalScripts.bind(content).defer(); - } - - return element; - }, - - wrap: function(element, wrapper, attributes) { - element = $(element); - if (Object.isElement(wrapper)) - $(wrapper).writeAttribute(attributes || { }); - else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes); - else wrapper = new Element('div', wrapper); - if (element.parentNode) - element.parentNode.replaceChild(wrapper, element); - wrapper.appendChild(element); - return wrapper; - }, - - inspect: function(element) { - element = $(element); - var result = '<' + element.tagName.toLowerCase(); - $H({'id': 'id', 'className': 'class'}).each(function(pair) { - var property = pair.first(), attribute = pair.last(); - var value = (element[property] || '').toString(); - if (value) result += ' ' + attribute + '=' + value.inspect(true); - }); - return result + '>'; - }, - - recursivelyCollect: function(element, property) { - element = $(element); - var elements = []; - while (element = element[property]) - if (element.nodeType == 1) - elements.push(Element.extend(element)); - return elements; - }, - - ancestors: function(element) { - return $(element).recursivelyCollect('parentNode'); - }, - - descendants: function(element) { - return $(element).select("*"); - }, - - firstDescendant: function(element) { - element = $(element).firstChild; - while (element && element.nodeType != 1) element = element.nextSibling; - return $(element); - }, - - immediateDescendants: function(element) { - if (!(element = $(element).firstChild)) return []; - while (element && element.nodeType != 1) element = element.nextSibling; - if (element) return [element].concat($(element).nextSiblings()); - return []; - }, - - previousSiblings: function(element) { - return $(element).recursivelyCollect('previousSibling'); - }, - - nextSiblings: function(element) { - return $(element).recursivelyCollect('nextSibling'); - }, - - siblings: function(element) { - element = $(element); - return element.previousSiblings().reverse().concat(element.nextSiblings()); - }, - - match: function(element, selector) { - if (Object.isString(selector)) - selector = new Selector(selector); - return selector.match($(element)); - }, - - up: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(element.parentNode); - var ancestors = element.ancestors(); - return Object.isNumber(expression) ? ancestors[expression] : - Selector.findElement(ancestors, expression, index); - }, - - down: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return element.firstDescendant(); - return Object.isNumber(expression) ? element.descendants()[expression] : - Element.select(element, expression)[index || 0]; - }, - - previous: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element)); - var previousSiblings = element.previousSiblings(); - return Object.isNumber(expression) ? previousSiblings[expression] : - Selector.findElement(previousSiblings, expression, index); - }, - - next: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element)); - var nextSiblings = element.nextSiblings(); - return Object.isNumber(expression) ? nextSiblings[expression] : - Selector.findElement(nextSiblings, expression, index); - }, - - select: function() { - var args = $A(arguments), element = $(args.shift()); - return Selector.findChildElements(element, args); - }, - - adjacent: function() { - var args = $A(arguments), element = $(args.shift()); - return Selector.findChildElements(element.parentNode, args).without(element); - }, - - identify: function(element) { - element = $(element); - var id = element.readAttribute('id'), self = arguments.callee; - if (id) return id; - do { id = 'anonymous_element_' + self.counter++ } while ($(id)); - element.writeAttribute('id', id); - return id; - }, - - readAttribute: function(element, name) { - element = $(element); - if (Prototype.Browser.IE) { - var t = Element._attributeTranslations.read; - if (t.values[name]) return t.values[name](element, name); - if (t.names[name]) name = t.names[name]; - if (name.include(':')) { - return (!element.attributes || !element.attributes[name]) ? null : - element.attributes[name].value; - } - } - return element.getAttribute(name); - }, - - writeAttribute: function(element, name, value) { - element = $(element); - var attributes = { }, t = Element._attributeTranslations.write; - - if (typeof name == 'object') attributes = name; - else attributes[name] = Object.isUndefined(value) ? true : value; - - for (var attr in attributes) { - name = t.names[attr] || attr; - value = attributes[attr]; - if (t.values[attr]) name = t.values[attr](element, value); - if (value === false || value === null) - element.removeAttribute(name); - else if (value === true) - element.setAttribute(name, name); - else element.setAttribute(name, value); - } - return element; - }, - - getHeight: function(element) { - return $(element).getDimensions().height; - }, - - getWidth: function(element) { - return $(element).getDimensions().width; - }, - - classNames: function(element) { - return new Element.ClassNames(element); - }, - - hasClassName: function(element, className) { - if (!(element = $(element))) return; - var elementClassName = element.className; - return (elementClassName.length > 0 && (elementClassName == className || - new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName))); - }, - - addClassName: function(element, className) { - if (!(element = $(element))) return; - if (!element.hasClassName(className)) - element.className += (element.className ? ' ' : '') + className; - return element; - }, - - removeClassName: function(element, className) { - if (!(element = $(element))) return; - element.className = element.className.replace( - new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip(); - return element; - }, - - toggleClassName: function(element, className) { - if (!(element = $(element))) return; - return element[element.hasClassName(className) ? - 'removeClassName' : 'addClassName'](className); - }, - - // removes whitespace-only text node children - cleanWhitespace: function(element) { - element = $(element); - var node = element.firstChild; - while (node) { - var nextNode = node.nextSibling; - if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) - element.removeChild(node); - node = nextNode; - } - return element; - }, - - empty: function(element) { - return $(element).innerHTML.blank(); - }, - - descendantOf: function(element, ancestor) { - element = $(element), ancestor = $(ancestor); - - if (element.compareDocumentPosition) - return (element.compareDocumentPosition(ancestor) & 8) === 8; - - if (ancestor.contains) - return ancestor.contains(element) && ancestor !== element; - - while (element = element.parentNode) - if (element == ancestor) return true; - - return false; - }, - - scrollTo: function(element) { - element = $(element); - var pos = element.cumulativeOffset(); - window.scrollTo(pos[0], pos[1]); - return element; - }, - - getStyle: function(element, style) { - element = $(element); - style = style == 'float' ? 'cssFloat' : style.camelize(); - var value = element.style[style]; - if (!value || value == 'auto') { - var css = document.defaultView.getComputedStyle(element, null); - value = css ? css[style] : null; - } - if (style == 'opacity') return value ? parseFloat(value) : 1.0; - return value == 'auto' ? null : value; - }, - - getOpacity: function(element) { - return $(element).getStyle('opacity'); - }, - - setStyle: function(element, styles) { - element = $(element); - var elementStyle = element.style, match; - if (Object.isString(styles)) { - element.style.cssText += ';' + styles; - return styles.include('opacity') ? - element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element; - } - for (var property in styles) - if (property == 'opacity') element.setOpacity(styles[property]); - else - elementStyle[(property == 'float' || property == 'cssFloat') ? - (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') : - property] = styles[property]; - - return element; - }, - - setOpacity: function(element, value) { - element = $(element); - element.style.opacity = (value == 1 || value === '') ? '' : - (value < 0.00001) ? 0 : value; - return element; - }, - - getDimensions: function(element) { - element = $(element); - var display = element.getStyle('display'); - if (display != 'none' && display != null) // Safari bug - return {width: element.offsetWidth, height: element.offsetHeight}; - - // All *Width and *Height properties give 0 on elements with display none, - // so enable the element temporarily - var els = element.style; - var originalVisibility = els.visibility; - var originalPosition = els.position; - var originalDisplay = els.display; - els.visibility = 'hidden'; - els.position = 'absolute'; - els.display = 'block'; - var originalWidth = element.clientWidth; - var originalHeight = element.clientHeight; - els.display = originalDisplay; - els.position = originalPosition; - els.visibility = originalVisibility; - return {width: originalWidth, height: originalHeight}; - }, - - makePositioned: function(element) { - element = $(element); - var pos = Element.getStyle(element, 'position'); - if (pos == 'static' || !pos) { - element._madePositioned = true; - element.style.position = 'relative'; - // Opera returns the offset relative to the positioning context, when an - // element is position relative but top and left have not been defined - if (Prototype.Browser.Opera) { - element.style.top = 0; - element.style.left = 0; - } - } - return element; - }, - - undoPositioned: function(element) { - element = $(element); - if (element._madePositioned) { - element._madePositioned = undefined; - element.style.position = - element.style.top = - element.style.left = - element.style.bottom = - element.style.right = ''; - } - return element; - }, - - makeClipping: function(element) { - element = $(element); - if (element._overflow) return element; - element._overflow = Element.getStyle(element, 'overflow') || 'auto'; - if (element._overflow !== 'hidden') - element.style.overflow = 'hidden'; - return element; - }, - - undoClipping: function(element) { - element = $(element); - if (!element._overflow) return element; - element.style.overflow = element._overflow == 'auto' ? '' : element._overflow; - element._overflow = null; - return element; - }, - - cumulativeOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - positionedOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - if (element) { - if (element.tagName.toUpperCase() == 'BODY') break; - var p = Element.getStyle(element, 'position'); - if (p !== 'static') break; - } - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - absolutize: function(element) { - element = $(element); - if (element.getStyle('position') == 'absolute') return element; - // Position.prepare(); // To be done manually by Scripty when it needs it. - - var offsets = element.positionedOffset(); - var top = offsets[1]; - var left = offsets[0]; - var width = element.clientWidth; - var height = element.clientHeight; - - element._originalLeft = left - parseFloat(element.style.left || 0); - element._originalTop = top - parseFloat(element.style.top || 0); - element._originalWidth = element.style.width; - element._originalHeight = element.style.height; - - element.style.position = 'absolute'; - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.width = width + 'px'; - element.style.height = height + 'px'; - return element; - }, - - relativize: function(element) { - element = $(element); - if (element.getStyle('position') == 'relative') return element; - // Position.prepare(); // To be done manually by Scripty when it needs it. - - element.style.position = 'relative'; - var top = parseFloat(element.style.top || 0) - (element._originalTop || 0); - var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0); - - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.height = element._originalHeight; - element.style.width = element._originalWidth; - return element; - }, - - cumulativeScrollOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.scrollTop || 0; - valueL += element.scrollLeft || 0; - element = element.parentNode; - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - getOffsetParent: function(element) { - if (element.offsetParent) return $(element.offsetParent); - if (element == document.body) return $(element); - - while ((element = element.parentNode) && element != document.body) - if (Element.getStyle(element, 'position') != 'static') - return $(element); - - return $(document.body); - }, - - viewportOffset: function(forElement) { - var valueT = 0, valueL = 0; - - var element = forElement; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - - // Safari fix - if (element.offsetParent == document.body && - Element.getStyle(element, 'position') == 'absolute') break; - - } while (element = element.offsetParent); - - element = forElement; - do { - if (!Prototype.Browser.Opera || (element.tagName && (element.tagName.toUpperCase() == 'BODY'))) { - valueT -= element.scrollTop || 0; - valueL -= element.scrollLeft || 0; - } - } while (element = element.parentNode); - - return Element._returnOffset(valueL, valueT); - }, - - clonePosition: function(element, source) { - var options = Object.extend({ - setLeft: true, - setTop: true, - setWidth: true, - setHeight: true, - offsetTop: 0, - offsetLeft: 0 - }, arguments[2] || { }); - - // find page position of source - source = $(source); - var p = source.viewportOffset(); - - // find coordinate system to use - element = $(element); - var delta = [0, 0]; - var parent = null; - // delta [0,0] will do fine with position: fixed elements, - // position:absolute needs offsetParent deltas - if (Element.getStyle(element, 'position') == 'absolute') { - parent = element.getOffsetParent(); - delta = parent.viewportOffset(); - } - - // correct by body offsets (fixes Safari) - if (parent == document.body) { - delta[0] -= document.body.offsetLeft; - delta[1] -= document.body.offsetTop; - } - - // set position - if (options.setLeft) element.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px'; - if (options.setTop) element.style.top = (p[1] - delta[1] + options.offsetTop) + 'px'; - if (options.setWidth) element.style.width = source.offsetWidth + 'px'; - if (options.setHeight) element.style.height = source.offsetHeight + 'px'; - return element; - } -}; - -Element.Methods.identify.counter = 1; - -Object.extend(Element.Methods, { - getElementsBySelector: Element.Methods.select, - childElements: Element.Methods.immediateDescendants -}); - -Element._attributeTranslations = { - write: { - names: { - className: 'class', - htmlFor: 'for' - }, - values: { } - } -}; - -if (Prototype.Browser.Opera) { - Element.Methods.getStyle = Element.Methods.getStyle.wrap( - function(proceed, element, style) { - switch (style) { - case 'left': case 'top': case 'right': case 'bottom': - if (proceed(element, 'position') === 'static') return null; - case 'height': case 'width': - // returns '0px' for hidden elements; we want it to return null - if (!Element.visible(element)) return null; - - // returns the border-box dimensions rather than the content-box - // dimensions, so we subtract padding and borders from the value - var dim = parseInt(proceed(element, style), 10); - - if (dim !== element['offset' + style.capitalize()]) - return dim + 'px'; - - var properties; - if (style === 'height') { - properties = ['border-top-width', 'padding-top', - 'padding-bottom', 'border-bottom-width']; - } - else { - properties = ['border-left-width', 'padding-left', - 'padding-right', 'border-right-width']; - } - return properties.inject(dim, function(memo, property) { - var val = proceed(element, property); - return val === null ? memo : memo - parseInt(val, 10); - }) + 'px'; - default: return proceed(element, style); - } - } - ); - - Element.Methods.readAttribute = Element.Methods.readAttribute.wrap( - function(proceed, element, attribute) { - if (attribute === 'title') return element.title; - return proceed(element, attribute); - } - ); -} - -else if (Prototype.Browser.IE) { - // IE doesn't report offsets correctly for static elements, so we change them - // to "relative" to get the values, then change them back. - Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap( - function(proceed, element) { - element = $(element); - // IE throws an error if element is not in document - try { element.offsetParent } - catch(e) { return $(document.body) } - var position = element.getStyle('position'); - if (position !== 'static') return proceed(element); - element.setStyle({ position: 'relative' }); - var value = proceed(element); - element.setStyle({ position: position }); - return value; - } - ); - - $w('positionedOffset viewportOffset').each(function(method) { - Element.Methods[method] = Element.Methods[method].wrap( - function(proceed, element) { - element = $(element); - try { element.offsetParent } - catch(e) { return Element._returnOffset(0,0) } - var position = element.getStyle('position'); - if (position !== 'static') return proceed(element); - // Trigger hasLayout on the offset parent so that IE6 reports - // accurate offsetTop and offsetLeft values for position: fixed. - var offsetParent = element.getOffsetParent(); - if (offsetParent && offsetParent.getStyle('position') === 'fixed') - offsetParent.setStyle({ zoom: 1 }); - element.setStyle({ position: 'relative' }); - var value = proceed(element); - element.setStyle({ position: position }); - return value; - } - ); - }); - - Element.Methods.cumulativeOffset = Element.Methods.cumulativeOffset.wrap( - function(proceed, element) { - try { element.offsetParent } - catch(e) { return Element._returnOffset(0,0) } - return proceed(element); - } - ); - - Element.Methods.getStyle = function(element, style) { - element = $(element); - style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize(); - var value = element.style[style]; - if (!value && element.currentStyle) value = element.currentStyle[style]; - - if (style == 'opacity') { - if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) - if (value[1]) return parseFloat(value[1]) / 100; - return 1.0; - } - - if (value == 'auto') { - if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none')) - return element['offset' + style.capitalize()] + 'px'; - return null; - } - return value; - }; - - Element.Methods.setOpacity = function(element, value) { - function stripAlpha(filter){ - return filter.replace(/alpha\([^\)]*\)/gi,''); - } - element = $(element); - var currentStyle = element.currentStyle; - if ((currentStyle && !currentStyle.hasLayout) || - (!currentStyle && element.style.zoom == 'normal')) - element.style.zoom = 1; - - var filter = element.getStyle('filter'), style = element.style; - if (value == 1 || value === '') { - (filter = stripAlpha(filter)) ? - style.filter = filter : style.removeAttribute('filter'); - return element; - } else if (value < 0.00001) value = 0; - style.filter = stripAlpha(filter) + - 'alpha(opacity=' + (value * 100) + ')'; - return element; - }; - - Element._attributeTranslations = { - read: { - names: { - 'class': 'className', - 'for': 'htmlFor' - }, - values: { - _getAttr: function(element, attribute) { - return element.getAttribute(attribute, 2); - }, - _getAttrNode: function(element, attribute) { - var node = element.getAttributeNode(attribute); - return node ? node.value : ""; - }, - _getEv: function(element, attribute) { - attribute = element.getAttribute(attribute); - return attribute ? attribute.toString().slice(23, -2) : null; - }, - _flag: function(element, attribute) { - return $(element).hasAttribute(attribute) ? attribute : null; - }, - style: function(element) { - return element.style.cssText.toLowerCase(); - }, - title: function(element) { - return element.title; - } - } - } - }; - - Element._attributeTranslations.write = { - names: Object.extend({ - cellpadding: 'cellPadding', - cellspacing: 'cellSpacing' - }, Element._attributeTranslations.read.names), - values: { - checked: function(element, value) { - element.checked = !!value; - }, - - style: function(element, value) { - element.style.cssText = value ? value : ''; - } - } - }; - - Element._attributeTranslations.has = {}; - - $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' + - 'encType maxLength readOnly longDesc frameBorder').each(function(attr) { - Element._attributeTranslations.write.names[attr.toLowerCase()] = attr; - Element._attributeTranslations.has[attr.toLowerCase()] = attr; - }); - - (function(v) { - Object.extend(v, { - href: v._getAttr, - src: v._getAttr, - type: v._getAttr, - action: v._getAttrNode, - disabled: v._flag, - checked: v._flag, - readonly: v._flag, - multiple: v._flag, - onload: v._getEv, - onunload: v._getEv, - onclick: v._getEv, - ondblclick: v._getEv, - onmousedown: v._getEv, - onmouseup: v._getEv, - onmouseover: v._getEv, - onmousemove: v._getEv, - onmouseout: v._getEv, - onfocus: v._getEv, - onblur: v._getEv, - onkeypress: v._getEv, - onkeydown: v._getEv, - onkeyup: v._getEv, - onsubmit: v._getEv, - onreset: v._getEv, - onselect: v._getEv, - onchange: v._getEv - }); - })(Element._attributeTranslations.read.values); -} - -else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) { - Element.Methods.setOpacity = function(element, value) { - element = $(element); - element.style.opacity = (value == 1) ? 0.999999 : - (value === '') ? '' : (value < 0.00001) ? 0 : value; - return element; - }; -} - -else if (Prototype.Browser.WebKit) { - Element.Methods.setOpacity = function(element, value) { - element = $(element); - element.style.opacity = (value == 1 || value === '') ? '' : - (value < 0.00001) ? 0 : value; - - if (value == 1) - if(element.tagName.toUpperCase() == 'IMG' && element.width) { - element.width++; element.width--; - } else try { - var n = document.createTextNode(' '); - element.appendChild(n); - element.removeChild(n); - } catch (e) { } - - return element; - }; - - // Safari returns margins on body which is incorrect if the child is absolutely - // positioned. For performance reasons, redefine Element#cumulativeOffset for - // KHTML/WebKit only. - Element.Methods.cumulativeOffset = function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - if (element.offsetParent == document.body) - if (Element.getStyle(element, 'position') == 'absolute') break; - - element = element.offsetParent; - } while (element); - - return Element._returnOffset(valueL, valueT); - }; -} - -if (Prototype.Browser.IE || Prototype.Browser.Opera) { - // IE and Opera are missing .innerHTML support for TABLE-related and SELECT elements - Element.Methods.update = function(element, content) { - element = $(element); - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) return element.update().insert(content); - - content = Object.toHTML(content); - var tagName = element.tagName.toUpperCase(); - - if (tagName in Element._insertionTranslations.tags) { - $A(element.childNodes).each(function(node) { element.removeChild(node) }); - Element._getContentFromAnonymousElement(tagName, content.stripScripts()) - .each(function(node) { element.appendChild(node) }); - } - else element.innerHTML = content.stripScripts(); - - content.evalScripts.bind(content).defer(); - return element; - }; -} - -if ('outerHTML' in document.createElement('div')) { - Element.Methods.replace = function(element, content) { - element = $(element); - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) { - element.parentNode.replaceChild(content, element); - return element; - } - - content = Object.toHTML(content); - var parent = element.parentNode, tagName = parent.tagName.toUpperCase(); - - if (Element._insertionTranslations.tags[tagName]) { - var nextSibling = element.next(); - var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); - parent.removeChild(element); - if (nextSibling) - fragments.each(function(node) { parent.insertBefore(node, nextSibling) }); - else - fragments.each(function(node) { parent.appendChild(node) }); - } - else element.outerHTML = content.stripScripts(); - - content.evalScripts.bind(content).defer(); - return element; - }; -} - -Element._returnOffset = function(l, t) { - var result = [l, t]; - result.left = l; - result.top = t; - return result; -}; - -Element._getContentFromAnonymousElement = function(tagName, html) { - var div = new Element('div'), t = Element._insertionTranslations.tags[tagName]; - if (t) { - div.innerHTML = t[0] + html + t[1]; - t[2].times(function() { div = div.firstChild }); - } else div.innerHTML = html; - return $A(div.childNodes); -}; - -Element._insertionTranslations = { - before: function(element, node) { - element.parentNode.insertBefore(node, element); - }, - top: function(element, node) { - element.insertBefore(node, element.firstChild); - }, - bottom: function(element, node) { - element.appendChild(node); - }, - after: function(element, node) { - element.parentNode.insertBefore(node, element.nextSibling); - }, - tags: { - TABLE: ['', '
    ', 1], - TBODY: ['', '
    ', 2], - TR: ['', '
    ', 3], - TD: ['
    ', '
    ', 4], - SELECT: ['', 1] - } -}; - -(function() { - Object.extend(this.tags, { - THEAD: this.tags.TBODY, - TFOOT: this.tags.TBODY, - TH: this.tags.TD - }); -}).call(Element._insertionTranslations); - -Element.Methods.Simulated = { - hasAttribute: function(element, attribute) { - attribute = Element._attributeTranslations.has[attribute] || attribute; - var node = $(element).getAttributeNode(attribute); - return !!(node && node.specified); - } -}; - -Element.Methods.ByTag = { }; - -Object.extend(Element, Element.Methods); - -if (!Prototype.BrowserFeatures.ElementExtensions && - document.createElement('div')['__proto__']) { - window.HTMLElement = { }; - window.HTMLElement.prototype = document.createElement('div')['__proto__']; - Prototype.BrowserFeatures.ElementExtensions = true; -} - -Element.extend = (function() { - if (Prototype.BrowserFeatures.SpecificElementExtensions) - return Prototype.K; - - var Methods = { }, ByTag = Element.Methods.ByTag; - - var extend = Object.extend(function(element) { - if (!element || element._extendedByPrototype || - element.nodeType != 1 || element == window) return element; - - var methods = Object.clone(Methods), - tagName = element.tagName.toUpperCase(), property, value; - - // extend methods for specific tags - if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]); - - for (property in methods) { - value = methods[property]; - if (Object.isFunction(value) && !(property in element)) - element[property] = value.methodize(); - } - - element._extendedByPrototype = Prototype.emptyFunction; - return element; - - }, { - refresh: function() { - // extend methods for all tags (Safari doesn't need this) - if (!Prototype.BrowserFeatures.ElementExtensions) { - Object.extend(Methods, Element.Methods); - Object.extend(Methods, Element.Methods.Simulated); - } - } - }); - - extend.refresh(); - return extend; -})(); - -Element.hasAttribute = function(element, attribute) { - if (element.hasAttribute) return element.hasAttribute(attribute); - return Element.Methods.Simulated.hasAttribute(element, attribute); -}; - -Element.addMethods = function(methods) { - var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag; - - if (!methods) { - Object.extend(Form, Form.Methods); - Object.extend(Form.Element, Form.Element.Methods); - Object.extend(Element.Methods.ByTag, { - "FORM": Object.clone(Form.Methods), - "INPUT": Object.clone(Form.Element.Methods), - "SELECT": Object.clone(Form.Element.Methods), - "TEXTAREA": Object.clone(Form.Element.Methods) - }); - } - - if (arguments.length == 2) { - var tagName = methods; - methods = arguments[1]; - } - - if (!tagName) Object.extend(Element.Methods, methods || { }); - else { - if (Object.isArray(tagName)) tagName.each(extend); - else extend(tagName); - } - - function extend(tagName) { - tagName = tagName.toUpperCase(); - if (!Element.Methods.ByTag[tagName]) - Element.Methods.ByTag[tagName] = { }; - Object.extend(Element.Methods.ByTag[tagName], methods); - } - - function copy(methods, destination, onlyIfAbsent) { - onlyIfAbsent = onlyIfAbsent || false; - for (var property in methods) { - var value = methods[property]; - if (!Object.isFunction(value)) continue; - if (!onlyIfAbsent || !(property in destination)) - destination[property] = value.methodize(); - } - } - - function findDOMClass(tagName) { - var klass; - var trans = { - "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph", - "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList", - "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading", - "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote", - "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION": - "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD": - "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR": - "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET": - "FrameSet", "IFRAME": "IFrame" - }; - if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element'; - if (window[klass]) return window[klass]; - klass = 'HTML' + tagName + 'Element'; - if (window[klass]) return window[klass]; - klass = 'HTML' + tagName.capitalize() + 'Element'; - if (window[klass]) return window[klass]; - - window[klass] = { }; - window[klass].prototype = document.createElement(tagName)['__proto__']; - return window[klass]; - } - - if (F.ElementExtensions) { - copy(Element.Methods, HTMLElement.prototype); - copy(Element.Methods.Simulated, HTMLElement.prototype, true); - } - - if (F.SpecificElementExtensions) { - for (var tag in Element.Methods.ByTag) { - var klass = findDOMClass(tag); - if (Object.isUndefined(klass)) continue; - copy(T[tag], klass.prototype); - } - } - - Object.extend(Element, Element.Methods); - delete Element.ByTag; - - if (Element.extend.refresh) Element.extend.refresh(); - Element.cache = { }; -}; - -document.viewport = { - getDimensions: function() { - var dimensions = { }, B = Prototype.Browser; - $w('width height').each(function(d) { - var D = d.capitalize(); - if (B.WebKit && !document.evaluate) { - // Safari <3.0 needs self.innerWidth/Height - dimensions[d] = self['inner' + D]; - } else if (B.Opera && parseFloat(window.opera.version()) < 9.5) { - // Opera <9.5 needs document.body.clientWidth/Height - dimensions[d] = document.body['client' + D] - } else { - dimensions[d] = document.documentElement['client' + D]; - } - }); - return dimensions; - }, - - getWidth: function() { - return this.getDimensions().width; - }, - - getHeight: function() { - return this.getDimensions().height; - }, - - getScrollOffsets: function() { - return Element._returnOffset( - window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft, - window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop); - } -}; -/* Portions of the Selector class are derived from Jack Slocum's DomQuery, - * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style - * license. Please see http://www.yui-ext.com/ for more information. */ - -var Selector = Class.create({ - initialize: function(expression) { - this.expression = expression.strip(); - - if (this.shouldUseSelectorsAPI()) { - this.mode = 'selectorsAPI'; - } else if (this.shouldUseXPath()) { - this.mode = 'xpath'; - this.compileXPathMatcher(); - } else { - this.mode = "normal"; - this.compileMatcher(); - } - - }, - - shouldUseXPath: function() { - if (!Prototype.BrowserFeatures.XPath) return false; - - var e = this.expression; - - // Safari 3 chokes on :*-of-type and :empty - if (Prototype.Browser.WebKit && - (e.include("-of-type") || e.include(":empty"))) - return false; - - // XPath can't do namespaced attributes, nor can it read - // the "checked" property from DOM nodes - if ((/(\[[\w-]*?:|:checked)/).test(e)) - return false; - - return true; - }, - - shouldUseSelectorsAPI: function() { - if (!Prototype.BrowserFeatures.SelectorsAPI) return false; - - if (!Selector._div) Selector._div = new Element('div'); - - // Make sure the browser treats the selector as valid. Test on an - // isolated element to minimize cost of this check. - try { - Selector._div.querySelector(this.expression); - } catch(e) { - return false; - } - - return true; - }, - - compileMatcher: function() { - var e = this.expression, ps = Selector.patterns, h = Selector.handlers, - c = Selector.criteria, le, p, m; - - if (Selector._cache[e]) { - this.matcher = Selector._cache[e]; - return; - } - - this.matcher = ["this.matcher = function(root) {", - "var r = root, h = Selector.handlers, c = false, n;"]; - - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - p = ps[i]; - if (m = e.match(p)) { - this.matcher.push(Object.isFunction(c[i]) ? c[i](m) : - new Template(c[i]).evaluate(m)); - e = e.replace(m[0], ''); - break; - } - } - } - - this.matcher.push("return h.unique(n);\n}"); - eval(this.matcher.join('\n')); - Selector._cache[this.expression] = this.matcher; - }, - - compileXPathMatcher: function() { - var e = this.expression, ps = Selector.patterns, - x = Selector.xpath, le, m; - - if (Selector._cache[e]) { - this.xpath = Selector._cache[e]; return; - } - - this.matcher = ['.//*']; - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - if (m = e.match(ps[i])) { - this.matcher.push(Object.isFunction(x[i]) ? x[i](m) : - new Template(x[i]).evaluate(m)); - e = e.replace(m[0], ''); - break; - } - } - } - - this.xpath = this.matcher.join(''); - Selector._cache[this.expression] = this.xpath; - }, - - findElements: function(root) { - root = root || document; - var e = this.expression, results; - - switch (this.mode) { - case 'selectorsAPI': - // querySelectorAll queries document-wide, then filters to descendants - // of the context element. That's not what we want. - // Add an explicit context to the selector if necessary. - if (root !== document) { - var oldId = root.id, id = $(root).identify(); - e = "#" + id + " " + e; - } - - results = $A(root.querySelectorAll(e)).map(Element.extend); - root.id = oldId; - - return results; - case 'xpath': - return document._getElementsByXPath(this.xpath, root); - default: - return this.matcher(root); - } - }, - - match: function(element) { - this.tokens = []; - - var e = this.expression, ps = Selector.patterns, as = Selector.assertions; - var le, p, m; - - while (e && le !== e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - p = ps[i]; - if (m = e.match(p)) { - // use the Selector.assertions methods unless the selector - // is too complex. - if (as[i]) { - this.tokens.push([i, Object.clone(m)]); - e = e.replace(m[0], ''); - } else { - // reluctantly do a document-wide search - // and look for a match in the array - return this.findElements(document).include(element); - } - } - } - } - - var match = true, name, matches; - for (var i = 0, token; token = this.tokens[i]; i++) { - name = token[0], matches = token[1]; - if (!Selector.assertions[name](element, matches)) { - match = false; break; - } - } - - return match; - }, - - toString: function() { - return this.expression; - }, - - inspect: function() { - return "#"; - } -}); - -Object.extend(Selector, { - _cache: { }, - - xpath: { - descendant: "//*", - child: "/*", - adjacent: "/following-sibling::*[1]", - laterSibling: '/following-sibling::*', - tagName: function(m) { - if (m[1] == '*') return ''; - return "[local-name()='" + m[1].toLowerCase() + - "' or local-name()='" + m[1].toUpperCase() + "']"; - }, - className: "[contains(concat(' ', @class, ' '), ' #{1} ')]", - id: "[@id='#{1}']", - attrPresence: function(m) { - m[1] = m[1].toLowerCase(); - return new Template("[@#{1}]").evaluate(m); - }, - attr: function(m) { - m[1] = m[1].toLowerCase(); - m[3] = m[5] || m[6]; - return new Template(Selector.xpath.operators[m[2]]).evaluate(m); - }, - pseudo: function(m) { - var h = Selector.xpath.pseudos[m[1]]; - if (!h) return ''; - if (Object.isFunction(h)) return h(m); - return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m); - }, - operators: { - '=': "[@#{1}='#{3}']", - '!=': "[@#{1}!='#{3}']", - '^=': "[starts-with(@#{1}, '#{3}')]", - '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']", - '*=': "[contains(@#{1}, '#{3}')]", - '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]", - '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]" - }, - pseudos: { - 'first-child': '[not(preceding-sibling::*)]', - 'last-child': '[not(following-sibling::*)]', - 'only-child': '[not(preceding-sibling::* or following-sibling::*)]', - 'empty': "[count(*) = 0 and (count(text()) = 0)]", - 'checked': "[@checked]", - 'disabled': "[(@disabled) and (@type!='hidden')]", - 'enabled': "[not(@disabled) and (@type!='hidden')]", - 'not': function(m) { - var e = m[6], p = Selector.patterns, - x = Selector.xpath, le, v; - - var exclusion = []; - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in p) { - if (m = e.match(p[i])) { - v = Object.isFunction(x[i]) ? x[i](m) : new Template(x[i]).evaluate(m); - exclusion.push("(" + v.substring(1, v.length - 1) + ")"); - e = e.replace(m[0], ''); - break; - } - } - } - return "[not(" + exclusion.join(" and ") + ")]"; - }, - 'nth-child': function(m) { - return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m); - }, - 'nth-last-child': function(m) { - return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m); - }, - 'nth-of-type': function(m) { - return Selector.xpath.pseudos.nth("position() ", m); - }, - 'nth-last-of-type': function(m) { - return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m); - }, - 'first-of-type': function(m) { - m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m); - }, - 'last-of-type': function(m) { - m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m); - }, - 'only-of-type': function(m) { - var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m); - }, - nth: function(fragment, m) { - var mm, formula = m[6], predicate; - if (formula == 'even') formula = '2n+0'; - if (formula == 'odd') formula = '2n+1'; - if (mm = formula.match(/^(\d+)$/)) // digit only - return '[' + fragment + "= " + mm[1] + ']'; - if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b - if (mm[1] == "-") mm[1] = -1; - var a = mm[1] ? Number(mm[1]) : 1; - var b = mm[2] ? Number(mm[2]) : 0; - predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " + - "((#{fragment} - #{b}) div #{a} >= 0)]"; - return new Template(predicate).evaluate({ - fragment: fragment, a: a, b: b }); - } - } - } - }, - - criteria: { - tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;', - className: 'n = h.className(n, r, "#{1}", c); c = false;', - id: 'n = h.id(n, r, "#{1}", c); c = false;', - attrPresence: 'n = h.attrPresence(n, r, "#{1}", c); c = false;', - attr: function(m) { - m[3] = (m[5] || m[6]); - return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(m); - }, - pseudo: function(m) { - if (m[6]) m[6] = m[6].replace(/"/g, '\\"'); - return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m); - }, - descendant: 'c = "descendant";', - child: 'c = "child";', - adjacent: 'c = "adjacent";', - laterSibling: 'c = "laterSibling";' - }, - - patterns: { - // combinators must be listed first - // (and descendant needs to be last combinator) - laterSibling: /^\s*~\s*/, - child: /^\s*>\s*/, - adjacent: /^\s*\+\s*/, - descendant: /^\s/, - - // selectors follow - tagName: /^\s*(\*|[\w\-]+)(\b|$)?/, - id: /^#([\w\-\*]+)(\b|$)/, - className: /^\.([\w\-\*]+)(\b|$)/, - pseudo: -/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/, - attrPresence: /^\[((?:[\w]+:)?[\w]+)\]/, - attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/ - }, - - // for Selector.match and Element#match - assertions: { - tagName: function(element, matches) { - return matches[1].toUpperCase() == element.tagName.toUpperCase(); - }, - - className: function(element, matches) { - return Element.hasClassName(element, matches[1]); - }, - - id: function(element, matches) { - return element.id === matches[1]; - }, - - attrPresence: function(element, matches) { - return Element.hasAttribute(element, matches[1]); - }, - - attr: function(element, matches) { - var nodeValue = Element.readAttribute(element, matches[1]); - return nodeValue && Selector.operators[matches[2]](nodeValue, matches[5] || matches[6]); - } - }, - - handlers: { - // UTILITY FUNCTIONS - // joins two collections - concat: function(a, b) { - for (var i = 0, node; node = b[i]; i++) - a.push(node); - return a; - }, - - // marks an array of nodes for counting - mark: function(nodes) { - var _true = Prototype.emptyFunction; - for (var i = 0, node; node = nodes[i]; i++) - node._countedByPrototype = _true; - return nodes; - }, - - unmark: function(nodes) { - for (var i = 0, node; node = nodes[i]; i++) - node._countedByPrototype = undefined; - return nodes; - }, - - // mark each child node with its position (for nth calls) - // "ofType" flag indicates whether we're indexing for nth-of-type - // rather than nth-child - index: function(parentNode, reverse, ofType) { - parentNode._countedByPrototype = Prototype.emptyFunction; - if (reverse) { - for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) { - var node = nodes[i]; - if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++; - } - } else { - for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++) - if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++; - } - }, - - // filters out duplicates and extends all nodes - unique: function(nodes) { - if (nodes.length == 0) return nodes; - var results = [], n; - for (var i = 0, l = nodes.length; i < l; i++) - if (!(n = nodes[i])._countedByPrototype) { - n._countedByPrototype = Prototype.emptyFunction; - results.push(Element.extend(n)); - } - return Selector.handlers.unmark(results); - }, - - // COMBINATOR FUNCTIONS - descendant: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - h.concat(results, node.getElementsByTagName('*')); - return results; - }, - - child: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) { - for (var j = 0, child; child = node.childNodes[j]; j++) - if (child.nodeType == 1 && child.tagName != '!') results.push(child); - } - return results; - }, - - adjacent: function(nodes) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - var next = this.nextElementSibling(node); - if (next) results.push(next); - } - return results; - }, - - laterSibling: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - h.concat(results, Element.nextSiblings(node)); - return results; - }, - - nextElementSibling: function(node) { - while (node = node.nextSibling) - if (node.nodeType == 1) return node; - return null; - }, - - previousElementSibling: function(node) { - while (node = node.previousSibling) - if (node.nodeType == 1) return node; - return null; - }, - - // TOKEN FUNCTIONS - tagName: function(nodes, root, tagName, combinator) { - var uTagName = tagName.toUpperCase(); - var results = [], h = Selector.handlers; - if (nodes) { - if (combinator) { - // fastlane for ordinary descendant combinators - if (combinator == "descendant") { - for (var i = 0, node; node = nodes[i]; i++) - h.concat(results, node.getElementsByTagName(tagName)); - return results; - } else nodes = this[combinator](nodes); - if (tagName == "*") return nodes; - } - for (var i = 0, node; node = nodes[i]; i++) - if (node.tagName.toUpperCase() === uTagName) results.push(node); - return results; - } else return root.getElementsByTagName(tagName); - }, - - id: function(nodes, root, id, combinator) { - var targetNode = $(id), h = Selector.handlers; - if (!targetNode) return []; - if (!nodes && root == document) return [targetNode]; - if (nodes) { - if (combinator) { - if (combinator == 'child') { - for (var i = 0, node; node = nodes[i]; i++) - if (targetNode.parentNode == node) return [targetNode]; - } else if (combinator == 'descendant') { - for (var i = 0, node; node = nodes[i]; i++) - if (Element.descendantOf(targetNode, node)) return [targetNode]; - } else if (combinator == 'adjacent') { - for (var i = 0, node; node = nodes[i]; i++) - if (Selector.handlers.previousElementSibling(targetNode) == node) - return [targetNode]; - } else nodes = h[combinator](nodes); - } - for (var i = 0, node; node = nodes[i]; i++) - if (node == targetNode) return [targetNode]; - return []; - } - return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : []; - }, - - className: function(nodes, root, className, combinator) { - if (nodes && combinator) nodes = this[combinator](nodes); - return Selector.handlers.byClassName(nodes, root, className); - }, - - byClassName: function(nodes, root, className) { - if (!nodes) nodes = Selector.handlers.descendant([root]); - var needle = ' ' + className + ' '; - for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) { - nodeClassName = node.className; - if (nodeClassName.length == 0) continue; - if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle)) - results.push(node); - } - return results; - }, - - attrPresence: function(nodes, root, attr, combinator) { - if (!nodes) nodes = root.getElementsByTagName("*"); - if (nodes && combinator) nodes = this[combinator](nodes); - var results = []; - for (var i = 0, node; node = nodes[i]; i++) - if (Element.hasAttribute(node, attr)) results.push(node); - return results; - }, - - attr: function(nodes, root, attr, value, operator, combinator) { - if (!nodes) nodes = root.getElementsByTagName("*"); - if (nodes && combinator) nodes = this[combinator](nodes); - var handler = Selector.operators[operator], results = []; - for (var i = 0, node; node = nodes[i]; i++) { - var nodeValue = Element.readAttribute(node, attr); - if (nodeValue === null) continue; - if (handler(nodeValue, value)) results.push(node); - } - return results; - }, - - pseudo: function(nodes, name, value, root, combinator) { - if (nodes && combinator) nodes = this[combinator](nodes); - if (!nodes) nodes = root.getElementsByTagName("*"); - return Selector.pseudos[name](nodes, value, root); - } - }, - - pseudos: { - 'first-child': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - if (Selector.handlers.previousElementSibling(node)) continue; - results.push(node); - } - return results; - }, - 'last-child': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - if (Selector.handlers.nextElementSibling(node)) continue; - results.push(node); - } - return results; - }, - 'only-child': function(nodes, value, root) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!h.previousElementSibling(node) && !h.nextElementSibling(node)) - results.push(node); - return results; - }, - 'nth-child': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root); - }, - 'nth-last-child': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, true); - }, - 'nth-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, false, true); - }, - 'nth-last-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, true, true); - }, - 'first-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, "1", root, false, true); - }, - 'last-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, "1", root, true, true); - }, - 'only-of-type': function(nodes, formula, root) { - var p = Selector.pseudos; - return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root); - }, - - // handles the an+b logic - getIndices: function(a, b, total) { - if (a == 0) return b > 0 ? [b] : []; - return $R(1, total).inject([], function(memo, i) { - if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i); - return memo; - }); - }, - - // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type - nth: function(nodes, formula, root, reverse, ofType) { - if (nodes.length == 0) return []; - if (formula == 'even') formula = '2n+0'; - if (formula == 'odd') formula = '2n+1'; - var h = Selector.handlers, results = [], indexed = [], m; - h.mark(nodes); - for (var i = 0, node; node = nodes[i]; i++) { - if (!node.parentNode._countedByPrototype) { - h.index(node.parentNode, reverse, ofType); - indexed.push(node.parentNode); - } - } - if (formula.match(/^\d+$/)) { // just a number - formula = Number(formula); - for (var i = 0, node; node = nodes[i]; i++) - if (node.nodeIndex == formula) results.push(node); - } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b - if (m[1] == "-") m[1] = -1; - var a = m[1] ? Number(m[1]) : 1; - var b = m[2] ? Number(m[2]) : 0; - var indices = Selector.pseudos.getIndices(a, b, nodes.length); - for (var i = 0, node, l = indices.length; node = nodes[i]; i++) { - for (var j = 0; j < l; j++) - if (node.nodeIndex == indices[j]) results.push(node); - } - } - h.unmark(nodes); - h.unmark(indexed); - return results; - }, - - 'empty': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - // IE treats comments as element nodes - if (node.tagName == '!' || node.firstChild) continue; - results.push(node); - } - return results; - }, - - 'not': function(nodes, selector, root) { - var h = Selector.handlers, selectorType, m; - var exclusions = new Selector(selector).findElements(root); - h.mark(exclusions); - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!node._countedByPrototype) results.push(node); - h.unmark(exclusions); - return results; - }, - - 'enabled': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!node.disabled && (!node.type || node.type !== 'hidden')) - results.push(node); - return results; - }, - - 'disabled': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (node.disabled) results.push(node); - return results; - }, - - 'checked': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (node.checked) results.push(node); - return results; - } - }, - - operators: { - '=': function(nv, v) { return nv == v; }, - '!=': function(nv, v) { return nv != v; }, - '^=': function(nv, v) { return nv == v || nv && nv.startsWith(v); }, - '$=': function(nv, v) { return nv == v || nv && nv.endsWith(v); }, - '*=': function(nv, v) { return nv == v || nv && nv.include(v); }, - '$=': function(nv, v) { return nv.endsWith(v); }, - '*=': function(nv, v) { return nv.include(v); }, - '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); }, - '|=': function(nv, v) { return ('-' + (nv || "").toUpperCase() + - '-').include('-' + (v || "").toUpperCase() + '-'); } - }, - - split: function(expression) { - var expressions = []; - expression.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) { - expressions.push(m[1].strip()); - }); - return expressions; - }, - - matchElements: function(elements, expression) { - var matches = $$(expression), h = Selector.handlers; - h.mark(matches); - for (var i = 0, results = [], element; element = elements[i]; i++) - if (element._countedByPrototype) results.push(element); - h.unmark(matches); - return results; - }, - - findElement: function(elements, expression, index) { - if (Object.isNumber(expression)) { - index = expression; expression = false; - } - return Selector.matchElements(elements, expression || '*')[index || 0]; - }, - - findChildElements: function(element, expressions) { - expressions = Selector.split(expressions.join(',')); - var results = [], h = Selector.handlers; - for (var i = 0, l = expressions.length, selector; i < l; i++) { - selector = new Selector(expressions[i].strip()); - h.concat(results, selector.findElements(element)); - } - return (l > 1) ? h.unique(results) : results; - } -}); - -if (Prototype.Browser.IE) { - Object.extend(Selector.handlers, { - // IE returns comment nodes on getElementsByTagName("*"). - // Filter them out. - concat: function(a, b) { - for (var i = 0, node; node = b[i]; i++) - if (node.tagName !== "!") a.push(node); - return a; - }, - - // IE improperly serializes _countedByPrototype in (inner|outer)HTML. - unmark: function(nodes) { - for (var i = 0, node; node = nodes[i]; i++) - node.removeAttribute('_countedByPrototype'); - return nodes; - } - }); -} - -function $$() { - return Selector.findChildElements(document, $A(arguments)); -} -var Form = { - reset: function(form) { - $(form).reset(); - return form; - }, - - serializeElements: function(elements, options) { - if (typeof options != 'object') options = { hash: !!options }; - else if (Object.isUndefined(options.hash)) options.hash = true; - var key, value, submitted = false, submit = options.submit; - - var data = elements.inject({ }, function(result, element) { - if (!element.disabled && element.name) { - key = element.name; value = $(element).getValue(); - if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted && - submit !== false && (!submit || key == submit) && (submitted = true)))) { - if (key in result) { - // a key is already present; construct an array of values - if (!Object.isArray(result[key])) result[key] = [result[key]]; - result[key].push(value); - } - else result[key] = value; - } - } - return result; - }); - - return options.hash ? data : Object.toQueryString(data); - } -}; - -Form.Methods = { - serialize: function(form, options) { - return Form.serializeElements(Form.getElements(form), options); - }, - - getElements: function(form) { - return $A($(form).getElementsByTagName('*')).inject([], - function(elements, child) { - if (Form.Element.Serializers[child.tagName.toLowerCase()]) - elements.push(Element.extend(child)); - return elements; - } - ); - }, - - getInputs: function(form, typeName, name) { - form = $(form); - var inputs = form.getElementsByTagName('input'); - - if (!typeName && !name) return $A(inputs).map(Element.extend); - - for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) { - var input = inputs[i]; - if ((typeName && input.type != typeName) || (name && input.name != name)) - continue; - matchingInputs.push(Element.extend(input)); - } - - return matchingInputs; - }, - - disable: function(form) { - form = $(form); - Form.getElements(form).invoke('disable'); - return form; - }, - - enable: function(form) { - form = $(form); - Form.getElements(form).invoke('enable'); - return form; - }, - - findFirstElement: function(form) { - var elements = $(form).getElements().findAll(function(element) { - return 'hidden' != element.type && !element.disabled; - }); - var firstByIndex = elements.findAll(function(element) { - return element.hasAttribute('tabIndex') && element.tabIndex >= 0; - }).sortBy(function(element) { return element.tabIndex }).first(); - - return firstByIndex ? firstByIndex : elements.find(function(element) { - return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); - }); - }, - - focusFirstElement: function(form) { - form = $(form); - form.findFirstElement().activate(); - return form; - }, - - request: function(form, options) { - form = $(form), options = Object.clone(options || { }); - - var params = options.parameters, action = form.readAttribute('action') || ''; - if (action.blank()) action = window.location.href; - options.parameters = form.serialize(true); - - if (params) { - if (Object.isString(params)) params = params.toQueryParams(); - Object.extend(options.parameters, params); - } - - if (form.hasAttribute('method') && !options.method) - options.method = form.method; - - return new Ajax.Request(action, options); - } -}; - -/*--------------------------------------------------------------------------*/ - -Form.Element = { - focus: function(element) { - $(element).focus(); - return element; - }, - - select: function(element) { - $(element).select(); - return element; - } -}; - -Form.Element.Methods = { - serialize: function(element) { - element = $(element); - if (!element.disabled && element.name) { - var value = element.getValue(); - if (value != undefined) { - var pair = { }; - pair[element.name] = value; - return Object.toQueryString(pair); - } - } - return ''; - }, - - getValue: function(element) { - element = $(element); - var method = element.tagName.toLowerCase(); - return Form.Element.Serializers[method](element); - }, - - setValue: function(element, value) { - element = $(element); - var method = element.tagName.toLowerCase(); - Form.Element.Serializers[method](element, value); - return element; - }, - - clear: function(element) { - $(element).value = ''; - return element; - }, - - present: function(element) { - return $(element).value != ''; - }, - - activate: function(element) { - element = $(element); - try { - element.focus(); - if (element.select && (element.tagName.toLowerCase() != 'input' || - !['button', 'reset', 'submit'].include(element.type))) - element.select(); - } catch (e) { } - return element; - }, - - disable: function(element) { - element = $(element); - element.disabled = true; - return element; - }, - - enable: function(element) { - element = $(element); - element.disabled = false; - return element; - } -}; - -/*--------------------------------------------------------------------------*/ - -var Field = Form.Element; -var $F = Form.Element.Methods.getValue; - -/*--------------------------------------------------------------------------*/ - -Form.Element.Serializers = { - input: function(element, value) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - return Form.Element.Serializers.inputSelector(element, value); - default: - return Form.Element.Serializers.textarea(element, value); - } - }, - - inputSelector: function(element, value) { - if (Object.isUndefined(value)) return element.checked ? element.value : null; - else element.checked = !!value; - }, - - textarea: function(element, value) { - if (Object.isUndefined(value)) return element.value; - else element.value = value; - }, - - select: function(element, value) { - if (Object.isUndefined(value)) - return this[element.type == 'select-one' ? - 'selectOne' : 'selectMany'](element); - else { - var opt, currentValue, single = !Object.isArray(value); - for (var i = 0, length = element.length; i < length; i++) { - opt = element.options[i]; - currentValue = this.optionValue(opt); - if (single) { - if (currentValue == value) { - opt.selected = true; - return; - } - } - else opt.selected = value.include(currentValue); - } - } - }, - - selectOne: function(element) { - var index = element.selectedIndex; - return index >= 0 ? this.optionValue(element.options[index]) : null; - }, - - selectMany: function(element) { - var values, length = element.length; - if (!length) return null; - - for (var i = 0, values = []; i < length; i++) { - var opt = element.options[i]; - if (opt.selected) values.push(this.optionValue(opt)); - } - return values; - }, - - optionValue: function(opt) { - // extend element because hasAttribute may not be native - return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text; - } -}; - -/*--------------------------------------------------------------------------*/ - -Abstract.TimedObserver = Class.create(PeriodicalExecuter, { - initialize: function($super, element, frequency, callback) { - $super(callback, frequency); - this.element = $(element); - this.lastValue = this.getValue(); - }, - - execute: function() { - var value = this.getValue(); - if (Object.isString(this.lastValue) && Object.isString(value) ? - this.lastValue != value : String(this.lastValue) != String(value)) { - this.callback(this.element, value); - this.lastValue = value; - } - } -}); - -Form.Element.Observer = Class.create(Abstract.TimedObserver, { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.Observer = Class.create(Abstract.TimedObserver, { - getValue: function() { - return Form.serialize(this.element); - } -}); - -/*--------------------------------------------------------------------------*/ - -Abstract.EventObserver = Class.create({ - initialize: function(element, callback) { - this.element = $(element); - this.callback = callback; - - this.lastValue = this.getValue(); - if (this.element.tagName.toLowerCase() == 'form') - this.registerFormCallbacks(); - else - this.registerCallback(this.element); - }, - - onElementEvent: function() { - var value = this.getValue(); - if (this.lastValue != value) { - this.callback(this.element, value); - this.lastValue = value; - } - }, - - registerFormCallbacks: function() { - Form.getElements(this.element).each(this.registerCallback, this); - }, - - registerCallback: function(element) { - if (element.type) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - Event.observe(element, 'click', this.onElementEvent.bind(this)); - break; - default: - Event.observe(element, 'change', this.onElementEvent.bind(this)); - break; - } - } - } -}); - -Form.Element.EventObserver = Class.create(Abstract.EventObserver, { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.EventObserver = Class.create(Abstract.EventObserver, { - getValue: function() { - return Form.serialize(this.element); - } -}); -if (!window.Event) var Event = { }; - -Object.extend(Event, { - KEY_BACKSPACE: 8, - KEY_TAB: 9, - KEY_RETURN: 13, - KEY_ESC: 27, - KEY_LEFT: 37, - KEY_UP: 38, - KEY_RIGHT: 39, - KEY_DOWN: 40, - KEY_DELETE: 46, - KEY_HOME: 36, - KEY_END: 35, - KEY_PAGEUP: 33, - KEY_PAGEDOWN: 34, - KEY_INSERT: 45, - - cache: { }, - - relatedTarget: function(event) { - var element; - switch(event.type) { - case 'mouseover': element = event.fromElement; break; - case 'mouseout': element = event.toElement; break; - default: return null; - } - return Element.extend(element); - } -}); - -Event.Methods = (function() { - var isButton; - - if (Prototype.Browser.IE) { - var buttonMap = { 0: 1, 1: 4, 2: 2 }; - isButton = function(event, code) { - return event.button == buttonMap[code]; - }; - - } else if (Prototype.Browser.WebKit) { - isButton = function(event, code) { - switch (code) { - case 0: return event.which == 1 && !event.metaKey; - case 1: return event.which == 1 && event.metaKey; - default: return false; - } - }; - - } else { - isButton = function(event, code) { - return event.which ? (event.which === code + 1) : (event.button === code); - }; - } - - return { - isLeftClick: function(event) { return isButton(event, 0) }, - isMiddleClick: function(event) { return isButton(event, 1) }, - isRightClick: function(event) { return isButton(event, 2) }, - - element: function(event) { - event = Event.extend(event); - - var node = event.target, - type = event.type, - currentTarget = event.currentTarget; - - if (currentTarget && currentTarget.tagName) { - // Firefox screws up the "click" event when moving between radio buttons - // via arrow keys. It also screws up the "load" and "error" events on images, - // reporting the document as the target instead of the original image. - if (type === 'load' || type === 'error' || - (type === 'click' && currentTarget.tagName.toLowerCase() === 'input' - && currentTarget.type === 'radio')) - node = currentTarget; - } - if (node.nodeType == Node.TEXT_NODE) node = node.parentNode; - return Element.extend(node); - }, - - findElement: function(event, expression) { - var element = Event.element(event); - if (!expression) return element; - var elements = [element].concat(element.ancestors()); - return Selector.findElement(elements, expression, 0); - }, - - pointer: function(event) { - var docElement = document.documentElement, - body = document.body || { scrollLeft: 0, scrollTop: 0 }; - return { - x: event.pageX || (event.clientX + - (docElement.scrollLeft || body.scrollLeft) - - (docElement.clientLeft || 0)), - y: event.pageY || (event.clientY + - (docElement.scrollTop || body.scrollTop) - - (docElement.clientTop || 0)) - }; - }, - - pointerX: function(event) { return Event.pointer(event).x }, - pointerY: function(event) { return Event.pointer(event).y }, - - stop: function(event) { - Event.extend(event); - event.preventDefault(); - event.stopPropagation(); - event.stopped = true; - } - }; -})(); - -Event.extend = (function() { - var methods = Object.keys(Event.Methods).inject({ }, function(m, name) { - m[name] = Event.Methods[name].methodize(); - return m; - }); - - if (Prototype.Browser.IE) { - Object.extend(methods, { - stopPropagation: function() { this.cancelBubble = true }, - preventDefault: function() { this.returnValue = false }, - inspect: function() { return "[object Event]" } - }); - - return function(event) { - if (!event) return false; - if (event._extendedByPrototype) return event; - - event._extendedByPrototype = Prototype.emptyFunction; - var pointer = Event.pointer(event); - Object.extend(event, { - target: event.srcElement, - relatedTarget: Event.relatedTarget(event), - pageX: pointer.x, - pageY: pointer.y - }); - return Object.extend(event, methods); - }; - - } else { - Event.prototype = Event.prototype || document.createEvent("HTMLEvents")['__proto__']; - Object.extend(Event.prototype, methods); - return Prototype.K; - } -})(); - -Object.extend(Event, (function() { - var cache = Event.cache; - - function getEventID(element) { - if (element._prototypeEventID) return element._prototypeEventID[0]; - arguments.callee.id = arguments.callee.id || 1; - return element._prototypeEventID = [++arguments.callee.id]; - } - - function getDOMEventName(eventName) { - if (eventName && eventName.include(':')) return "dataavailable"; - return eventName; - } - - function getCacheForID(id) { - return cache[id] = cache[id] || { }; - } - - function getWrappersForEventName(id, eventName) { - var c = getCacheForID(id); - return c[eventName] = c[eventName] || []; - } - - function createWrapper(element, eventName, handler) { - var id = getEventID(element); - var c = getWrappersForEventName(id, eventName); - if (c.pluck("handler").include(handler)) return false; - - var wrapper = function(event) { - if (!Event || !Event.extend || - (event.eventName && event.eventName != eventName)) - return false; - - Event.extend(event); - handler.call(element, event); - }; - - wrapper.handler = handler; - c.push(wrapper); - return wrapper; - } - - function findWrapper(id, eventName, handler) { - var c = getWrappersForEventName(id, eventName); - return c.find(function(wrapper) { return wrapper.handler == handler }); - } - - function destroyWrapper(id, eventName, handler) { - var c = getCacheForID(id); - if (!c[eventName]) return false; - c[eventName] = c[eventName].without(findWrapper(id, eventName, handler)); - } - - function destroyCache() { - for (var id in cache) - for (var eventName in cache[id]) - cache[id][eventName] = null; - } - - - // Internet Explorer needs to remove event handlers on page unload - // in order to avoid memory leaks. - if (window.attachEvent) { - window.attachEvent("onunload", destroyCache); - } - - // Safari has a dummy event handler on page unload so that it won't - // use its bfcache. Safari <= 3.1 has an issue with restoring the "document" - // object when page is returned to via the back button using its bfcache. - if (Prototype.Browser.WebKit) { - window.addEventListener('unload', Prototype.emptyFunction, false); - } - - return { - observe: function(element, eventName, handler) { - element = $(element); - var name = getDOMEventName(eventName); - - var wrapper = createWrapper(element, eventName, handler); - if (!wrapper) return element; - - if (element.addEventListener) { - element.addEventListener(name, wrapper, false); - } else { - element.attachEvent("on" + name, wrapper); - } - - return element; - }, - - stopObserving: function(element, eventName, handler) { - element = $(element); - var id = getEventID(element), name = getDOMEventName(eventName); - - if (!handler && eventName) { - getWrappersForEventName(id, eventName).each(function(wrapper) { - element.stopObserving(eventName, wrapper.handler); - }); - return element; - - } else if (!eventName) { - Object.keys(getCacheForID(id)).each(function(eventName) { - element.stopObserving(eventName); - }); - return element; - } - - var wrapper = findWrapper(id, eventName, handler); - if (!wrapper) return element; - - if (element.removeEventListener) { - element.removeEventListener(name, wrapper, false); - } else { - element.detachEvent("on" + name, wrapper); - } - - destroyWrapper(id, eventName, handler); - - return element; - }, - - fire: function(element, eventName, memo) { - element = $(element); - if (element == document && document.createEvent && !element.dispatchEvent) - element = document.documentElement; - - var event; - if (document.createEvent) { - event = document.createEvent("HTMLEvents"); - event.initEvent("dataavailable", true, true); - } else { - event = document.createEventObject(); - event.eventType = "ondataavailable"; - } - - event.eventName = eventName; - event.memo = memo || { }; - - if (document.createEvent) { - element.dispatchEvent(event); - } else { - element.fireEvent(event.eventType, event); - } - - return Event.extend(event); - } - }; -})()); - -Object.extend(Event, Event.Methods); - -Element.addMethods({ - fire: Event.fire, - observe: Event.observe, - stopObserving: Event.stopObserving -}); - -Object.extend(document, { - fire: Element.Methods.fire.methodize(), - observe: Element.Methods.observe.methodize(), - stopObserving: Element.Methods.stopObserving.methodize(), - loaded: false -}); - -(function() { - /* Support for the DOMContentLoaded event is based on work by Dan Webb, - Matthias Miller, Dean Edwards and John Resig. */ - - var timer; - - function fireContentLoadedEvent() { - if (document.loaded) return; - if (timer) window.clearInterval(timer); - document.fire("dom:loaded"); - document.loaded = true; - } - - if (document.addEventListener) { - if (Prototype.Browser.WebKit) { - timer = window.setInterval(function() { - if (/loaded|complete/.test(document.readyState)) - fireContentLoadedEvent(); - }, 0); - - Event.observe(window, "load", fireContentLoadedEvent); - - } else { - document.addEventListener("DOMContentLoaded", - fireContentLoadedEvent, false); - } - - } else { - document.write(" - - Which is needed for dealing with the IE6 DOM when it's not yet fully loaded. - -* Fixed that rescue template path shouldn't be hardcoded, then it's easier to hook in your own #6295 [Mike Naberezny] - -* Fixed escaping of backslashes in JavaScriptHelper#escape_javascript #6302 [sven@c3d2.de] - -* Fixed that some 500 rescues would cause 500's themselves because the response had not yet been generated #6329 [cmselmer] - -* respond_to :html doesn't assume .rhtml. #6281 [Hampton Catlin] - -* Fixed some deprecation warnings in ActionPack [Rick Olson] - -* assert_select_rjs decodes escaped unicode chars since the Javascript generators encode them. #6240 [japgolly] - -* Deprecation: @cookies, @headers, @request, @response will be removed after 1.2. Use the corresponding method instead. [Jeremy Kemper] - -* Make the :status parameter expand to the default message for that status code if it is an integer. Also support symbol statuses. [Jamis Buck]. Examples: - - head :status => 404 # expands to "404 Not Found" - head :status => :not_found # expands to "404 Not Found" - head :status => :created # expands to "201 Created" - -* Add head(options = {}) for responses that have no body. [Jamis Buck]. Examples: - - head :status => 404 # return an empty response with a 404 status - head :location => person_path(@person), :status => 201 - -* Fix bug that kept any before_filter except the first one from being able to halt the before_filter chain. [Rick Olson] - -* strip_links is case-insensitive. #6285 [tagoh, Bob Silva] - -* Clear the cache of possible controllers whenever Routes are reloaded. [Nicholas Seckar] - -* Filters overhaul including meantime filter support using around filters + blocks. #5949 [Martin Emde, Roman Le Negrate, Stefan Kaes, Jeremy Kemper] - -* Update RJS render tests. [sam] - -* Update CGI process to allow sessions to contain namespaced models. Closes #4638. [dfelstead@site5.com] - -* Fix routing to respect user provided requirements and defaults when assigning default routing options (such as :action => 'index'). Closes #5950. [Nicholas Seckar] - -* Rescue Errno::ECONNRESET to handle an unexpectedly closed socket connection. Improves SCGI reliability. #3368, #6226 [sdsykes, fhanshaw@vesaria.com] - -* Added that respond_to blocks will automatically set the content type to be the same as is requested [David Heinemeier Hansson]. Examples: - - respond_to do |format| - format.html { render :text => "I'm being sent as text/html" } - format.rss { render :text => "I'm being sent as application/rss+xml" } - format.atom { render :text => "I'm being sent as application/xml", :content_type => Mime::XML } - end - -* Added utf-8 as the default charset for all renders. You can change this default using ActionController::Base.default_charset=(encoding) [David Heinemeier Hansson] - -* Added proper getters and setters for content type and charset [David Heinemeier Hansson]. Example of what we used to do: - - response.headers["Content-Type"] = "application/atom+xml; charset=utf-8" - - ...now: - - response.content_type = Mime::ATOM - response.charset = "utf-8" - -* Updated prototype.js to 1.5.0_rc1 with latest fixes. [Rick Olson] - - - XPATH support - - Make Form.getElements() return elements in the correct order - - fix broken Form.serialize return - -* Declare file extensions exempt from layouts. #6219 [brandon] - Example: ActionController::Base.exempt_from_layout 'rpdf' - -* Add chained replace/update support for assert_select_rjs [Rick Olson] - - Given RJS like... - - page['test1'].replace "
    foo
    " - page['test2'].replace_html "
    foo
    " - - Test it with... - - assert_select_rjs :chained_replace - assert_select_rjs :chained_replace, "test1" - - assert_select_rjs :chained_replace_html - assert_select_rjs :chained_replace_html, "test2" - -* Load helpers in alphabetical order for consistency. Resolve cyclic javascript_helper dependency. #6132, #6178 [choonkeat@gmail.com] - -* Skip params with empty names, such as the &=Save query string from . #2569 [Manfred Stienstra, raphinou@yahoo.com] - -* Fix assert_tag so that :content => "foo" does not match substrings, but only exact strings. Use :content => /foo/ to match substrings. #2799 [Eric Hodel] - -* Add descriptive messages to the exceptions thrown by cgi_methods. #6091, #6103 [Nicholas Seckar, Bob Silva] - -* Update JavaScriptGenerator#show/hide/toggle/remove to new Prototype syntax for multiple ids, #6068 [petermichaux@gmail.com] - -* Update UrlWriter to support :only_path. [Nicholas Seckar, Dave Thomas] - -* Fixed JavaScriptHelper#link_to_function and JavaScriptHelper#button_to_function to have the script argument be optional [David Heinemeier Hansson]. So what used to require a nil, like this: - - link_to("Hider", nil, :class => "hider_link") { |p| p[:something].hide } - - ...can be written like this: - - link_to("Hider", :class => "hider_link") { |p| p[:something].hide } - -* Update to script.aculo.us 1.6.3 [Thomas Fuchs] - -* Update to Prototype 1.5.0_rc1 [sam] - -* Added access to nested attributes in RJS #4548 [richcollins@gmail.com]. Examples: - - page['foo']['style'] # => $('foo').style; - page['foo']['style']['color'] # => $('blank_slate').style.color; - page['foo']['style']['color'] = 'red' # => $('blank_slate').style.color = 'red'; - page['foo']['style'].color = 'red' # => $('blank_slate').style.color = 'red'; - -* Fixed that AssetTagHelper#image_tag and others using compute_public_path should not modify the incoming source argument (closes #5102) [eule@space.ch] - -* Deprecated the auto-appending of .png to AssetTagHelper#image_tag calls that doesn't have an extension [David Heinemeier Hansson] - -* Fixed FormOptionsHelper#select to respect :selected value #5813 - -* Fixed TextHelper#simple_format to deal with multiple single returns within a single paragraph #5835 [moriq@moriq.com] - -* Fixed TextHelper#pluralize to handle 1 as a string #5909 [rails@bencurtis.com] - -* Improved resolution of DateHelper#distance_of_time_in_words for better precision #5994 [Bob Silva] - -* Changed that uncaught exceptions raised any where in the application will cause RAILS_ROOT/public/500.html to be read and shown instead of just the static "Application error (Rails)" [David Heinemeier Hansson] - -* Integration tests: thoroughly test ActionController::Integration::Session. #6022 [Kevin Clark] - (tests skipped unless you `gem install mocha`) - -* Added deprecation language for pagination which will become a plugin by Rails 2.0 [David Heinemeier Hansson] - -* Added deprecation language for in_place_editor and auto_complete_field that both pieces will become plugins by Rails 2.0 [David Heinemeier Hansson] - -* Deprecated all of ActionController::Dependencies. All dependency loading is now handled from Active Support [David Heinemeier Hansson] - -* Added assert_select* for CSS selector-based testing (deprecates assert_tag) #5936 [assaf.arkin@gmail.com] - -* radio_button_tag generates unique id attributes. #3353 [Bob Silva, somekool@gmail.com] - -* strip_tags passes through blank args such as nil or "". #2229, #6702 [duncan@whomwah.com, dharana] - -* Cleanup assert_tag :children counting. #2181 [jamie@bravenet.com] - -* button_to accepts :method so you can PUT and DELETE with it. #6005 [Dan Webb] - -* Update sanitize text helper to strip plaintext tags, and . [Rick Olson] - -* Update routing documentation. Closes #6017 [Nathan Witmer] - -* Add routing tests to assert that RoutingError is raised when conditions aren't met. Closes #6016 [Nathan Witmer] - -* Deprecation: update docs. #5998 [Jakob Skjerning, Kevin Clark] - -* Make auto_link parse a greater subset of valid url formats. [Jamis Buck] - -* Integration tests: headers beginning with X aren't excluded from the HTTP_ prefix, so X-Requested-With becomes HTTP_X_REQUESTED_WITH as expected. [Mike Clark] - -* Tighten rescue clauses. #5985 [james@grayproductions.net] - -* Fix send_data documentation typo. #5982 [brad@madriska.com] - -* Switch to using FormEncodedPairParser for parsing request parameters. [Nicholas Seckar, David Heinemeier Hansson] - -* respond_to .html now always renders #{action_name}.rhtml so that registered custom template handlers do not override it in priority. Custom mime types require a block and throw proper error now. [Tobias Lütke] - -* Deprecation: test deprecated instance vars in partials. [Jeremy Kemper] - -* Add UrlWriter to allow writing urls from Mailers and scripts. [Nicholas Seckar] - -* Clean up and run the Active Record integration tests by default. #5854 [Kevin Clark, Jeremy Kemper] - -* Correct example in cookies docs. #5832 [jessemerriman@warpmail.net] - -* Updated to script.aculo.us 1.6.2 [Thomas Fuchs] - -* Relax Routing's anchor pattern warning; it was preventing use of [^/] inside restrictions. [Nicholas Seckar] - -* Add controller_paths variable to Routing. [Nicholas Seckar] - -* Fix assert_redirected_to issue with named routes for module controllers. [Rick Olson] - -* Tweak RoutingError message to show option diffs, not just missing named route significant keys. [Rick Olson] - -* Invoke method_missing directly on hidden actions. Closes #3030. [Nicholas Seckar] - -* Require Tempfile explicitly for TestUploadedFile due to changes in class auto loading. [Rick Olson] - -* Add RoutingError exception when RouteSet fails to generate a path from a Named Route. [Rick Olson] - -* Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar] - -* Deprecation: check whether instance variables have been monkeyed with before assigning them to deprecation proxies. Raises a RuntimeError if so. [Jeremy Kemper] - -* Add support for the param_name parameter to the auto_complete_field helper. #5026 [david.a.williams@gmail.com] - -* Deprecation! @params, @session, @flash will be removed after 1.2. Use the corresponding instance methods instead. You'll get printed warnings during tests and logged warnings in dev mode when you access either instance variable directly. [Jeremy Kemper] - -* Make Routing noisy when an anchor regexp is assigned to a segment. #5674 [François Beausoleil] - -* Added months and years to the resolution of DateHelper#distance_of_time_in_words, such that "60 days ago" becomes "2 months ago" #5611 [pjhyett@gmail.com] - -* Short documentation to mention use of Mime::Type.register. #5710 [choonkeat@gmail.com] - -* Make controller_path available as an instance method. #5724 [jmckible@gmail.com] - -* Update query parser to support adjacent hashes. [Nicholas Seckar] - -* Make action caching aware of different formats for the same action so that, e.g. foo.xml is cached separately from foo.html. Implicitly set content type when reading in cached content with mime revealing extensions so the entire onous isn't on the webserver. [Marcel Molina Jr.] - -* Restrict Request Method hacking with ?_method to POST requests. [Rick Olson] - -* Fix bug when passing multiple options to SimplyRestful, like :new => { :preview => :get, :draft => :get }. [Rick Olson, Josh Susser, Lars Pind] - -* Dup the options passed to map.resources so that multiple resources get the same options. [Rick Olson] - -* Fixed the new_#{resource}_url route and added named route tests for Simply Restful. [Rick Olson] - -* Added map.resources from the Simply Restful plugin [David Heinemeier Hansson]. Examples (the API has changed to use plurals!): - - map.resources :messages - map.resources :messages, :comments - map.resources :messages, :new => { :preview => :post } - -* Fixed that integration simulation of XHRs should set Accept header as well [Edward Frederick] - -* TestRequest#reset_session should restore a TestSession, not a hash [Michael Koziarski] - -* Don't search a load-path of '.' for controller files [Jamis Buck] - -* Update integration.rb to require test_process explicitly instead of via Dependencies. [Nicholas Seckar] - -* Fixed that you can still access the flash after the flash has been reset in reset_session. Closes #5584 [lmarlow] - -* Allow form_for and fields_for to work with indexed form inputs. [Jeremy Kemper, Matt Lyon] - - <% form_for 'post[]', @post do |f| -%> - <% end -%> - -* Remove leak in development mode by replacing define_method with module_eval. [Nicholas Seckar] - -* Provide support for decimal columns to form helpers. Closes #5672. [Dave Thomas] - -* Update documentation for erb trim syntax. #5651 [matt@mattmargolis.net] - -* Pass :id => nil or :class => nil to error_messages_for to supress that html attribute. #3586 [olivier_ansaldi@yahoo.com, sebastien@goetzilla.info] - -* Reset @html_document between requests so assert_tag works. #4810 [Jarkko Laine, easleydp@gmail.com] - -* Update render :partial documentation. #5646 [matt@mattmargolis.net] - -* Integration tests behave well with render_component. #4632 [edward.frederick@revolution.com, dev.rubyonrails@maxdunn.com] - -* Added exception handling of missing layouts #5373 [chris@ozmm.org] - -* Fixed that real files and symlinks should be treated the same when compiling templates #5438 [zachary@panandscan.com] - -* Fixed that the flash should be reset when reset_session is called #5584 [Shugo Maeda] - -* Added special case for "1 Byte" in NumberHelper#number_to_human_size #5593 [murpyh@rubychan.de] - -* Fixed proper form-encoded parameter parsing for requests with "Content-Type: application/x-www-form-urlencoded; charset=utf-8" (note the presence of a charset directive) [David Heinemeier Hansson] - -* Add route_name_path method to generate only the path for a named routes. For example, map.person will add person_path. [Nicholas Seckar] - -* Avoid naming collision among compiled view methods. [Jeremy Kemper] - -* Fix CGI extensions when they expect string but get nil in Windows. Closes #5276 [Mislav Marohnić] - -* Determine the correct template_root for deeply nested components. #2841 [s.brink@web.de] - -* Fix that routes with *path segments in the recall can generate URLs. [Rick Olson] - -* Fix strip_links so that it doesn't hang on multiline tags [Jamis Buck] - -* Remove problematic control chars in rescue template. #5316 [Stefan Kaes] - -* Make sure passed routing options are not mutated by routing code. #5314 [Blair Zajac] - -* Make sure changing the controller from foo/bar to bing/bang does not change relative to foo. [Jamis Buck] - -* Escape the path before routing recognition. #3671 - -* Make sure :id and friends are unescaped properly. #5275 [me@julik.nl] - -* Fix documentation for with_routing to reflect new reality. #5281 [rramdas@gmail.com] - -* Rewind readable CGI params so others may reread them (such as CGI::Session when passing the session id in a multipart form). #210 [mklame@atxeu.com, matthew@walker.wattle.id.au] - -* Added Mime::TEXT (text/plain) and Mime::ICS (text/calendar) as new default types [David Heinemeier Hansson] - -* Added Mime::Type.register(string, symbol, synonyms = []) for adding new custom mime types [David Heinemeier Hansson]. Example: Mime::Type.register("image/gif", :gif) - -* Added support for Mime objects in render :content_type option [David Heinemeier Hansson]. Example: render :text => some_atom, :content_type => Mime::ATOM - -* Add :status option to send_data and send_file. Defaults to '200 OK'. #5243 [Manfred Stienstra ] - -* Routing rewrite. Simpler, faster, easier to understand. The published API for config/routes.rb is unchanged, but nearly everything else is different, so expect breakage in plugins and libs that try to fiddle with routes. [Nicholas Seckar, Jamis Buck] - - map.connect '/foo/:id', :controller => '...', :action => '...' - map.connect '/foo/:id.:format', :controller => '...', :action => '...' - map.connect '/foo/:id', ..., :conditions => { :method => :get } - -* Cope with missing content type and length headers. Parse parameters from multipart and urlencoded request bodies only. [Jeremy Kemper] - -* Accept multipart PUT parameters. #5235 [guy.naor@famundo.com] - -* Added interrogation of params[:format] to determine Accept type. If :format is specified and matches a declared extension, like "rss" or "xml", that mime type will be put in front of the accept handler. This means you can link to the same action from different extensions and use that fact to determine output [David Heinemeier Hansson]. Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find :all - - respond_to do |format| - format.html - format.xml { render :xml => @posts.to_xml } - format.rss { render :action => "feed.rxml" } - end - end - end - - # returns HTML when requested by a browser, since the browser - # has the HTML mimetype at the top of its priority list - Accept: text/html - GET /weblog - - # returns the XML - Accept: application/xml - GET /weblog - - # returns the HTML - Accept: application/xml - GET /weblog.html - - # returns the XML - Accept: text/html - GET /weblog.xml - - All this relies on the fact that you have a route that includes .:format. - -* Expanded :method option in FormTagHelper#form_tag, FormHelper#form_for, PrototypeHelper#remote_form_for, PrototypeHelper#remote_form_tag, and PrototypeHelper#link_to_remote to allow for verbs other than GET and POST by automatically creating a hidden form field named _method, which will simulate the other verbs over post [David Heinemeier Hansson] - -* Added :method option to UrlHelper#link_to, which allows for using other verbs than GET for the link. This replaces the :post option, which is now deprecated. Example: link_to "Destroy", person_url(:id => person), :method => :delete [David Heinemeier Hansson] - -* follow_redirect doesn't complain about being redirected to the same controller. #5153 [dymo@mk.ukrtelecom.ua] - -* Add layout attribute to response object with the name of the layout that was rendered, or nil if none rendered. [Kevin Clark] - -* Fix NoMethodError when parsing params like &&. [Adam Greenfield] - -* Fix flip flopped logic in docs for url_for's :only_path option. Closes #4998. [esad@esse.at] - -* form.text_area handles the :size option just like the original text_area (:size => '60x10' becomes cols="60" rows="10"). [Jeremy Kemper] - -* Excise ingrown code from FormOptionsHelper#options_for_select. #5008 [anonymous] - -* Small fix in routing to allow dynamic routes (broken after [4242]) [Rick Olson] - - map.connect '*path', :controller => 'files', :action => 'show' - -* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.] - -* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.] - -* Use #flush between switching from #write to #syswrite. Closes #4907. [Blair Zajac ] - -* Documentation fix: integration test scripts don't require integration_test. Closes #4914. [Frederick Ros ] - -* ActionController::Base Summary documentation rewrite. Closes #4900. [Kevin Clark] - -* Fix text_helper.rb documentation rendering. Closes #4725. [Frederick Ros] - -* Fixes bad rendering of JavaScriptMacrosHelper rdoc (closes #4910) [Frederick Ros] - -* Allow error_messages_for to report errors for multiple objects, as well as support for customizing the name of the object in the error summary header. Closes #4186. [andrew@redlinesoftware.com, Marcel Molina Jr.] - - error_messages_for :account, :user, :subscription, :object_name => :account - -* Enhance documentation for setting headers in integration tests. Skip auto HTTP prepending when its already there. Closes #4079. [Rick Olson] - -* Documentation for AbstractRequest. Closes #4895. [Kevin Clark] - -* Refactor various InstanceTag instance method to class methods. Closes #4800. [Stefan Kaes] - -* Remove all remaining references to @params in the documentation. [Marcel Molina Jr.] - -* Add documentation for redirect_to :back's RedirectBackError exception. [Marcel Molina Jr.] - -* Update layout and content_for documentation to use yield rather than magic @content_for instance variables. [Marcel Molina Jr.] - -* Fix assert_redirected_to tests according to real-world usage. Also, don't fail if you add an extra :controller option: [Rick Olson] - - redirect_to :action => 'new' - assert_redirected_to :controller => 'monkeys', :action => 'new' - -* Cache CgiRequest#request_parameters so that multiple calls don't re-parse multipart data. [Rick Olson] - -* Diff compared routing options. Allow #assert_recognizes to take a second arg as a hash to specify optional request method [Rick Olson] - - assert_recognizes({:controller => 'users', :action => 'index'}, 'users') - assert_recognizes({:controller => 'users', :action => 'create'}, {:path => 'users', :method => :post}) - -* Diff compared options with #assert_redirected_to [Rick Olson] - -* Add support in routes for semicolon delimited "subpaths", like /books/:id;:action [Jamis Buck] - -* Change link_to_function and button_to_function to (optionally) take an update_page block instead of a JavaScript string. Closes #4804. [zraii@comcast.net, Sam Stephenson] - -* Fixed that remote_form_for can leave out the object parameter and default to the instance variable of the object_name, just like form_for [David Heinemeier Hansson] - -* Modify routing so that you can say :require => { :method => :post } for a route, and the route will never be selected unless the request method is POST. Only works for route recognition, not for route generation. [Jamis Buck] - -* Added :add_headers option to verify which merges a hash of name/value pairs into the response's headers hash if the prerequisites cannot be satisfied. [Sam Stephenson] - ex. verify :only => :speak, :method => :post, - :render => { :status => 405, :text => "Must be post" }, - :add_headers => { "Allow" => "POST" } - -* Added ActionController.filter_parameter_logging that makes it easy to remove passwords, credit card numbers, and other sensitive information from being logged when a request is handled #1897 [jeremye@bsa.ca.gov] - - -*1.13.3* (March 12th, 2007) - -* Apply [5709] to stable. - -* session_enabled? works with session :off. #6680 [Jonathan del Strother] - -* Performance: patch cgi/session to require digest/md5 once rather than per #create_new_id. [Stefan Kaes] - - -*1.13.2* (February 5th, 2007) - -* Add much-needed html-scanner tests. Fixed CDATA parsing bug. [Rick Olson] - -* improve error message for Routing for named routes. [Rob Sanheim] - -* Added enhanced docs to routing assertions. [Rob Sanheim] - -* fix form_for example in ActionController::Resources documentation. [gnarg] - -* Add singleton resources from trunk [Rick Olson] - -* select :multiple => true suffixes the attribute name with [] unless already suffixed. #6977 [nik.kakelin, ben, julik] - -* Improve routes documentation. #7095 [zackchandler] - -* Resource member routes require :id, eliminating the ambiguous overlap with collection routes. #7229 [dkubb] - -* Fixed NumberHelper#number_with_delimiter to use "." always for splitting the original number, not the delimiter parameter #7389 [ceefour] - -* Autolinking recognizes trailing and embedded . , : ; #7354 [Jarkko Laine] - -* Make TextHelper::auto_link recognize URLs with colons in path correctly, fixes #7268. [imajes] - -* Improved auto_link to match more valid urls correctly [Tobias Lütke] - - -*1.13.1* (January 18th, 2007) - -* Fixed content-type bug in Prototype [sam] - - -*1.13.0* (January 16th, 2007) - -* Modernize cookie testing code, and increase coverage (Heckle++) #7101 [Kevin Clark] - -* Heckling ActionController::Resources::Resource revealed that set_prefixes didn't break when :name_prefix was munged. #7081 [Kevin Clark] - -* Update to Prototype 1.5.0. [Sam Stephenson] - -* Allow exempt_from_layout :rhtml. #6742, #7026 [Dan Manges, Squeegy] - -* Fix parsing of array[] CGI parameters so extra empty values aren't included. #6252 [Nicholas Seckar, aiwilliams, brentrowland] - -* link_to_unless_current works with full URLs as well as paths. #6891 [Jarkko Laine, Manfred Stienstra, idrifter] - -* Fix HTML::Node to output double quotes instead of single quotes. Closes #6845 [mitreandy] - -* Fix no method error with error_messages_on. Closes #6935 [nik.wakelin Koz] - -* Slight doc tweak to the ActionView::Helpers::PrototypeHelper#replace docs. Closes #6922 [Steven Bristol] - -* Slight doc tweak to #prepend_filter. Closes #6493 [Jeremy Voorhis] - -* Add more extensive documentation to the AssetTagHelper. Closes #6452 [Bob Silva] - -* Clean up multiple calls to #stringify_keys in TagHelper, add better documentation and testing for TagHelper. Closes #6394 [Bob Silva] - -* [DOCS] fix reference to ActionController::Macros::AutoComplete for #text_field_with_auto_complete. Closes #2578 [Jan Prill] - -* Make sure html_document is reset between integration test requests. [ctm] - -* Set session to an empty hash if :new_session => false and no session cookie or param is present. CGI::Session was raising an unrescued ArgumentError. [Josh Susser] - -* Fix assert_redirected_to bug where redirecting from a nested to to a top-level controller incorrectly added the current controller's nesting. Closes #6128. [Rick Olson] - -* Ensure render :json => ... skips the layout. #6808 [Josh Peek] - -* Silence log_error deprecation warnings from inspecting deprecated instance variables. [Nate Wiger] - -* Only cache GET requests with a 200 OK response. #6514, #6743 [RSL, anamba] - -* Correctly report which filter halted the chain. #6699 [Martin Emde] - -* respond_to recognizes JSON. render :json => @person.to_json automatically sets the content type and takes a :callback option to specify a client-side function to call using the rendered JSON as an argument. #4185 [Scott Raymond, eventualbuddha] - # application/json response with body 'Element.show({:name: "David"})' - respond_to do |format| - format.json { render :json => { :name => "David" }.to_json, :callback => 'Element.show' } - end - -* Makes :discard_year work without breaking multi-attribute parsing in AR. #1260, #3800 [sean@ardismg.com, jmartin@desertflood.com, stephen@touset.org, Bob Silva] - -* Adds html id attribute to date helper elements. #1050, #1382 [mortonda@dgrmm.net, David North, Bob Silva] - -* Add :index and @auto_index capability to model driven date/time selects. #847, #2655 [moriq, Doug Fales, Bob Silva] - -* Add :order to datetime_select, select_datetime, and select_date. #1427 [Timothee Peignier, Patrick Lenz, Bob Silva] - -* Added time_select to work with time values in models. Update scaffolding. #2489, #2833 [Justin Palmer, Andre Caum, Bob Silva] - -* Added :include_seconds to select_datetime, datetime_select and time_select. #2998 [csn, Bob Silva] - -* All date/datetime selects can now accept an array of month names with :use_month_names. Allows for localization. #363 [tomasj, Bob Silva] - -* Adds :time_separator to select_time and :date_separator to select_datetime. Preserves BC. #3811 [Bob Silva] - -* @response.redirect_url works with 201 Created responses: just return headers['Location'] rather than checking the response status. [Jeremy Kemper] - -* Fixed that HEAD should return the proper Content-Length header (that is, actually use @body.size, not just 0) [David Heinemeier Hansson] - -* Added GET-masquarading for HEAD, so request.method will return :get even for HEADs. This will help anyone relying on case request.method to automatically work with HEAD and map.resources will also allow HEADs to all GET actions. Rails automatically throws away the response content in a reply to HEAD, so you don't even need to worry about that. If you, for whatever reason, still need to distinguish between GET and HEAD in some edge case, you can use Request#head? and even Request.headers["REQUEST_METHOD"] for get the "real" answer. Closes #6694 [David Heinemeier Hansson] - - -*1.13.0 RC1* (r5619, November 22nd, 2006) - -* Update Routing to complain when :controller is not specified by a route. Closes #6669. [Nicholas Seckar] - -* Ensure render_to_string cleans up after itself when an exception is raised. #6658 [rsanheim] - -* Update to Prototype and script.aculo.us [5579]. [Sam Stephenson, Thomas Fuchs] - -* simple_format helper doesn't choke on nil. #6644 [jerry426] - -* Reuse named route helper module between Routing reloads. Use remove_method to delete named route methods after each load. Since the module is never collected, this fixes a significant memory leak. [Nicholas Seckar] - -* Deprecate standalone components. [Jeremy Kemper] - -* Always clear model associations from session. #4795 [sd@notso.net, andylien@gmail.com] - -* Remove JavaScriptLiteral in favor of ActiveSupport::JSON::Variable. [Sam Stephenson] - -* Sync ActionController::StatusCodes::STATUS_CODES with http://www.iana.org/assignments/http-status-codes. #6586 [dkubb] - -* Multipart form values may have a content type without being treated as uploaded files if they do not provide a filename. #6401 [Andreas Schwarz, Jeremy Kemper] - -* assert_response supports symbolic status codes. #6569 [Kevin Clark] - assert_response :ok - assert_response :not_found - assert_response :forbidden - -* Cache parsed query parameters. #6559 [Stefan Kaes] - -* Deprecate JavaScriptHelper#update_element_function, which is superseeded by RJS [Thomas Fuchs] - -* Fix invalid test fixture exposed by stricter Ruby 1.8.5 multipart parsing. #6524 [Bob Silva] - -* Set ActionView::Base.default_form_builder once rather than passing the :builder option to every form or overriding the form helper methods. [Jeremy Kemper] - -* Deprecate expire_matched_fragments. Use expire_fragment instead. #6535 [Bob Silva] - -* Deprecate start_form_tag and end_form_tag. Use form_tag / '' from now on. [Rick Olson] - -* Added block-usage to PrototypeHelper#form_remote_tag, document block-usage of FormTagHelper#form_tag [Rick Olson] - -* Add a 0 margin/padding div around the hidden _method input tag that form_tag outputs. [Rick Olson] - -* Added block-usage to TagHelper#content_tag [David Heinemeier Hansson]. Example: - - <% content_tag :div, :class => "strong" %> - Hello world! - <% end %> - - Will output: -
    Hello world!
    - -* Deprecated UrlHelper#link_to_image and UrlHelper#link_to :post => true #6409 [Bob Silva] - -* Upgraded NumberHelper with number_to_phone support international formats to comply with ITU E.123 by supporting area codes with less than 3 digits, added precision argument to number_to_human_size (defaults to 1) #6421 [Bob Silva] - -* Fixed that setting RAILS_ASSET_ID to "" should not add a trailing slash after assets #6454 [Bob Silva/chrismear] - -* Force *_url named routes to show the host in ActionView [Rick Olson] - - <%= url_for ... %> # no host - <%= foo_path %> # no host - <%= foo_url %> # host! - -* Add support for converting blocks into function arguments to JavaScriptGenerator#call and JavaScriptProxy#call. [Sam Stephenson] - -* Add JavaScriptGenerator#literal for wrapping a string in an object whose #to_json is the string itself. [Sam Stephenson] - -* Add <%= escape_once html %> to escape html while leaving any currently escaped entities alone. Fix button_to double-escaping issue. [Rick Olson] - -* Fix double-escaped entities, such as &amp;, &#123;, etc. [Rick Olson] - -* Fix routing to correctly determine when generation fails. Closes #6300. [psross]. - -* Fix broken assert_generates when extra keys are being checked. [Jamis Buck] - -* Replace KCODE checks with String#chars for truncate. Closes #6385 [Manfred Stienstra] - -* Make page caching respect the format of the resource that is being requested even if the current route is the default route so that, e.g. posts.rss is not transformed by url_for to '/' and subsequently cached as '/index.html' when it should be cached as '/posts.rss'. [Marcel Molina Jr.] - -* Use String#chars in TextHelper::excerpt. Closes #6386 [Manfred Stienstra] - -* Fix relative URL root matching problems. [Mark Imbriaco] - -* Fix filter skipping in controller subclasses. #5949, #6297, #6299 [Martin Emde] - -* render_text may optionally append to the response body. render_javascript appends by default. This allows you to chain multiple render :update calls by setting @performed_render = false between them (awaiting a better public API). [Jeremy Kemper] - -* Rename test assertion to prevent shadowing. Closes #6306. [psross] - -* Fixed that NumberHelper#number_to_delimiter should respect precision of higher than two digits #6231 [Philip Hallstrom] - -* Fixed that FormHelper#radio_button didn't respect an :id being passed in #6266 [evansj] - -* Added an html_options hash parameter to javascript_tag() and update_page_tag() helpers #6311 [tzaharia]. Example: - - update_page_tag :defer => 'true' { |page| ... } - - Gives: - - - - Which is needed for dealing with the IE6 DOM when it's not yet fully loaded. - -* Fixed that rescue template path shouldn't be hardcoded, then it's easier to hook in your own #6295 [Mike Naberezny] - -* Fixed escaping of backslashes in JavaScriptHelper#escape_javascript #6302 [sven@c3d2.de] - -* Fixed that some 500 rescues would cause 500's themselves because the response had not yet been generated #6329 [cmselmer] - -* respond_to :html doesn't assume .rhtml. #6281 [Hampton Catlin] - -* Fixed some deprecation warnings in ActionPack [Rick Olson] - -* assert_select_rjs decodes escaped unicode chars since the Javascript generators encode them. #6240 [japgolly] - -* Deprecation: @cookies, @headers, @request, @response will be removed after 1.2. Use the corresponding method instead. [Jeremy Kemper] - -* Make the :status parameter expand to the default message for that status code if it is an integer. Also support symbol statuses. [Jamis Buck]. Examples: - - head :status => 404 # expands to "404 Not Found" - head :status => :not_found # expands to "404 Not Found" - head :status => :created # expands to "201 Created" - -* Add head(options = {}) for responses that have no body. [Jamis Buck]. Examples: - - head :status => 404 # return an empty response with a 404 status - head :location => person_path(@person), :status => 201 - -* Fix bug that kept any before_filter except the first one from being able to halt the before_filter chain. [Rick Olson] - -* strip_links is case-insensitive. #6285 [tagoh, Bob Silva] - -* Clear the cache of possible controllers whenever Routes are reloaded. [Nicholas Seckar] - -* Filters overhaul including meantime filter support using around filters + blocks. #5949 [Martin Emde, Roman Le Negrate, Stefan Kaes, Jeremy Kemper] - -* Update CGI process to allow sessions to contain namespaced models. Closes #4638. [dfelstead@site5.com] - -* Fix routing to respect user provided requirements and defaults when assigning default routing options (such as :action => 'index'). Closes #5950. [Nicholas Seckar] - -* Rescue Errno::ECONNRESET to handle an unexpectedly closed socket connection. Improves SCGI reliability. #3368, #6226 [sdsykes, fhanshaw@vesaria.com] - -* Added that respond_to blocks will automatically set the content type to be the same as is requested [David Heinemeier Hansson]. Examples: - - respond_to do |format| - format.html { render :text => "I'm being sent as text/html" } - format.rss { render :text => "I'm being sent as application/rss+xml" } - format.atom { render :text => "I'm being sent as application/xml", :content_type => Mime::XML } - end - -* Added utf-8 as the default charset for all renders. You can change this default using ActionController::Base.default_charset=(encoding) [David Heinemeier Hansson] - -* Added proper getters and setters for content type and charset [David Heinemeier Hansson]. Example of what we used to do: - - response.headers["Content-Type"] = "application/atom+xml; charset=utf-8" - - ...now: - - response.content_type = Mime::ATOM - response.charset = "utf-8" - -* Declare file extensions exempt from layouts. #6219 [brandon] - Example: ActionController::Base.exempt_from_layout 'rpdf' - -* Add chained replace/update support for assert_select_rjs [Rick Olson] - - Given RJS like... - - page['test1'].replace "
    foo
    " - page['test2'].replace_html "
    foo
    " - - Test it with... - - assert_select_rjs :chained_replace - assert_select_rjs :chained_replace, "test1" - - assert_select_rjs :chained_replace_html - assert_select_rjs :chained_replace_html, "test2" - -* Load helpers in alphabetical order for consistency. Resolve cyclic javascript_helper dependency. #6132, #6178 [choonkeat@gmail.com] - -* Skip params with empty names, such as the &=Save query string from . #2569 [Manfred Stienstra, raphinou@yahoo.com] - -* Fix assert_tag so that :content => "foo" does not match substrings, but only exact strings. Use :content => /foo/ to match substrings. #2799 [Eric Hodel] - -* Update JavaScriptGenerator#show/hide/toggle/remove to new Prototype syntax for multiple ids, #6068 [petermichaux@gmail.com] - -* Update UrlWriter to support :only_path. [Nicholas Seckar, Dave Thomas] - -* Fixed JavaScriptHelper#link_to_function and JavaScriptHelper#button_to_function to have the script argument be optional [David Heinemeier Hansson]. So what used to require a nil, like this: - - link_to("Hider", nil, :class => "hider_link") { |p| p[:something].hide } - - ...can be written like this: - - link_to("Hider", :class => "hider_link") { |p| p[:something].hide } - -* Added access to nested attributes in RJS #4548 [richcollins@gmail.com]. Examples: - - page['foo']['style'] # => $('foo').style; - page['foo']['style']['color'] # => $('blank_slate').style.color; - page['foo']['style']['color'] = 'red' # => $('blank_slate').style.color = 'red'; - page['foo']['style'].color = 'red' # => $('blank_slate').style.color = 'red'; - -* Fixed that AssetTagHelper#image_tag and others using compute_public_path should not modify the incoming source argument (closes #5102) [eule@space.ch] - -* Deprecated the auto-appending of .png to AssetTagHelper#image_tag calls that doesn't have an extension [David Heinemeier Hansson] - -* Fixed FormOptionsHelper#select to respect :selected value #5813 - -* Fixed TextHelper#simple_format to deal with multiple single returns within a single paragraph #5835 [moriq@moriq.com] - -* Fixed TextHelper#pluralize to handle 1 as a string #5909 [rails@bencurtis.com] - -* Improved resolution of DateHelper#distance_of_time_in_words for better precision #5994 [Bob Silva] - -* Changed that uncaught exceptions raised any where in the application will cause RAILS_ROOT/public/500.html to be read and shown instead of just the static "Application error (Rails)" [David Heinemeier Hansson] - -* Added deprecation language for pagination which will become a plugin by Rails 2.0 [David Heinemeier Hansson] - -* Added deprecation language for in_place_editor and auto_complete_field that both pieces will become plugins by Rails 2.0 [David Heinemeier Hansson] - -* Deprecated all of ActionController::Dependencies. All dependency loading is now handled from Active Support [David Heinemeier Hansson] - -* Added assert_select* for CSS selector-based testing (deprecates assert_tag) #5936 [assaf.arkin@gmail.com] - -* radio_button_tag generates unique id attributes. #3353 [Bob Silva, somekool@gmail.com] - -* strip_tags passes through blank args such as nil or "". #2229, #6702 [duncan@whomwah.com, dharana] - -* Cleanup assert_tag :children counting. #2181 [jamie@bravenet.com] - -* button_to accepts :method so you can PUT and DELETE with it. #6005 [Dan Webb] - -* Update sanitize text helper to strip plaintext tags, and . [Rick Olson] - -* Add routing tests to assert that RoutingError is raised when conditions aren't met. Closes #6016 [Nathan Witmer] - -* Make auto_link parse a greater subset of valid url formats. [Jamis Buck] - -* Integration tests: headers beginning with X aren't excluded from the HTTP_ prefix, so X-Requested-With becomes HTTP_X_REQUESTED_WITH as expected. [Mike Clark] - -* Switch to using FormEncodedPairParser for parsing request parameters. [Nicholas Seckar, David Heinemeier Hansson] - -* respond_to .html now always renders #{action_name}.rhtml so that registered custom template handlers do not override it in priority. Custom mime types require a block and throw proper error now. [Tobias Lütke] - -* Deprecation: test deprecated instance vars in partials. [Jeremy Kemper] - -* Add UrlWriter to allow writing urls from Mailers and scripts. [Nicholas Seckar] - -* Relax Routing's anchor pattern warning; it was preventing use of [^/] inside restrictions. [Nicholas Seckar] - -* Add controller_paths variable to Routing. [Nicholas Seckar] - -* Fix assert_redirected_to issue with named routes for module controllers. [Rick Olson] - -* Tweak RoutingError message to show option diffs, not just missing named route significant keys. [Rick Olson] - -* Invoke method_missing directly on hidden actions. Closes #3030. [Nicholas Seckar] - -* Add RoutingError exception when RouteSet fails to generate a path from a Named Route. [Rick Olson] - -* Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar] - -* Deprecation: check whether instance variables have been monkeyed with before assigning them to deprecation proxies. Raises a RuntimeError if so. [Jeremy Kemper] - -* Add support for the param_name parameter to the auto_complete_field helper. #5026 [david.a.williams@gmail.com] - -* Deprecation! @params, @session, @flash will be removed after 1.2. Use the corresponding instance methods instead. You'll get printed warnings during tests and logged warnings in dev mode when you access either instance variable directly. [Jeremy Kemper] - -* Make Routing noisy when an anchor regexp is assigned to a segment. #5674 [François Beausoleil] - -* Added months and years to the resolution of DateHelper#distance_of_time_in_words, such that "60 days ago" becomes "2 months ago" #5611 [pjhyett@gmail.com] - -* Make controller_path available as an instance method. #5724 [jmckible@gmail.com] - -* Update query parser to support adjacent hashes. [Nicholas Seckar] - -* Make action caching aware of different formats for the same action so that, e.g. foo.xml is cached separately from foo.html. Implicitly set content type when reading in cached content with mime revealing extensions so the entire onous isn't on the webserver. [Marcel Molina Jr.] - -* Restrict Request Method hacking with ?_method to POST requests. [Rick Olson] - -* Fixed the new_#{resource}_url route and added named route tests for Simply Restful. [Rick Olson] - -* Added map.resources from the Simply Restful plugin [David Heinemeier Hansson]. Examples (the API has changed to use plurals!): - - map.resources :messages - map.resources :messages, :comments - map.resources :messages, :new => { :preview => :post } - -* Fixed that integration simulation of XHRs should set Accept header as well [Edward Frederick] - -* TestRequest#reset_session should restore a TestSession, not a hash [Michael Koziarski] - -* Don't search a load-path of '.' for controller files [Jamis Buck] - -* Update integration.rb to require test_process explicitly instead of via Dependencies. [Nicholas Seckar] - -* Fixed that you can still access the flash after the flash has been reset in reset_session. Closes #5584 [lmarlow] - -* Allow form_for and fields_for to work with indexed form inputs. [Jeremy Kemper, Matt Lyon] - - <% form_for 'post[]', @post do |f| -%> - <% end -%> - -* Remove leak in development mode by replacing define_method with module_eval. [Nicholas Seckar] - -* Provide support for decimal columns to form helpers. Closes #5672. [Dave Thomas] - -* Pass :id => nil or :class => nil to error_messages_for to supress that html attribute. #3586 [olivier_ansaldi@yahoo.com, sebastien@goetzilla.info] - -* Reset @html_document between requests so assert_tag works. #4810 [Jarkko Laine, easleydp@gmail.com] - -* Integration tests behave well with render_component. #4632 [edward.frederick@revolution.com, dev.rubyonrails@maxdunn.com] - -* Added exception handling of missing layouts #5373 [chris@ozmm.org] - -* Fixed that real files and symlinks should be treated the same when compiling templates #5438 [zachary@panandscan.com] - -* Fixed that the flash should be reset when reset_session is called #5584 [Shugo Maeda] - -* Added special case for "1 Byte" in NumberHelper#number_to_human_size #5593 [murpyh@rubychan.de] - -* Fixed proper form-encoded parameter parsing for requests with "Content-Type: application/x-www-form-urlencoded; charset=utf-8" (note the presence of a charset directive) [David Heinemeier Hansson] - -* Add route_name_path method to generate only the path for a named routes. For example, map.person will add person_path. [Nicholas Seckar] - -* Avoid naming collision among compiled view methods. [Jeremy Kemper] - -* Fix CGI extensions when they expect string but get nil in Windows. Closes #5276 [Mislav Marohnić] - -* Determine the correct template_root for deeply nested components. #2841 [s.brink@web.de] - -* Fix that routes with *path segments in the recall can generate URLs. [Rick Olson] - -* Fix strip_links so that it doesn't hang on multiline tags [Jamis Buck] - -* Remove problematic control chars in rescue template. #5316 [Stefan Kaes] - -* Make sure passed routing options are not mutated by routing code. #5314 [Blair Zajac] - -* Make sure changing the controller from foo/bar to bing/bang does not change relative to foo. [Jamis Buck] - -* Escape the path before routing recognition. #3671 - -* Make sure :id and friends are unescaped properly. #5275 [me@julik.nl] - -* Rewind readable CGI params so others may reread them (such as CGI::Session when passing the session id in a multipart form). #210 [mklame@atxeu.com, matthew@walker.wattle.id.au] - -* Added Mime::TEXT (text/plain) and Mime::ICS (text/calendar) as new default types [David Heinemeier Hansson] - -* Added Mime::Type.register(string, symbol, synonyms = []) for adding new custom mime types [David Heinemeier Hansson]. Example: Mime::Type.register("image/gif", :gif) - -* Added support for Mime objects in render :content_type option [David Heinemeier Hansson]. Example: render :text => some_atom, :content_type => Mime::ATOM - -* Add :status option to send_data and send_file. Defaults to '200 OK'. #5243 [Manfred Stienstra ] - -* Routing rewrite. Simpler, faster, easier to understand. The published API for config/routes.rb is unchanged, but nearly everything else is different, so expect breakage in plugins and libs that try to fiddle with routes. [Nicholas Seckar, Jamis Buck] - - map.connect '/foo/:id', :controller => '...', :action => '...' - map.connect '/foo/:id.:format', :controller => '...', :action => '...' - map.connect '/foo/:id', ..., :conditions => { :method => :get } - -* Cope with missing content type and length headers. Parse parameters from multipart and urlencoded request bodies only. [Jeremy Kemper] - -* Accept multipart PUT parameters. #5235 [guy.naor@famundo.com] - -* Added interrogation of params[:format] to determine Accept type. If :format is specified and matches a declared extension, like "rss" or "xml", that mime type will be put in front of the accept handler. This means you can link to the same action from different extensions and use that fact to determine output [David Heinemeier Hansson]. Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find :all - - respond_to do |format| - format.html - format.xml { render :xml => @posts.to_xml } - format.rss { render :action => "feed.rxml" } - end - end - end - - # returns HTML when requested by a browser, since the browser - # has the HTML mimetype at the top of its priority list - Accept: text/html - GET /weblog - - # returns the XML - Accept: application/xml - GET /weblog - - # returns the HTML - Accept: application/xml - GET /weblog.html - - # returns the XML - Accept: text/html - GET /weblog.xml - - All this relies on the fact that you have a route that includes .:format. - -* Expanded :method option in FormTagHelper#form_tag, FormHelper#form_for, PrototypeHelper#remote_form_for, PrototypeHelper#remote_form_tag, and PrototypeHelper#link_to_remote to allow for verbs other than GET and POST by automatically creating a hidden form field named _method, which will simulate the other verbs over post [David Heinemeier Hansson] - -* Added :method option to UrlHelper#link_to, which allows for using other verbs than GET for the link. This replaces the :post option, which is now deprecated. Example: link_to "Destroy", person_url(:id => person), :method => :delete [David Heinemeier Hansson] - -* follow_redirect doesn't complain about being redirected to the same controller. #5153 [dymo@mk.ukrtelecom.ua] - -* Add layout attribute to response object with the name of the layout that was rendered, or nil if none rendered. [Kevin Clark] - -* Fix NoMethodError when parsing params like &&. [Adam Greenfield] - -* form.text_area handles the :size option just like the original text_area (:size => '60x10' becomes cols="60" rows="10"). [Jeremy Kemper] - -* Excise ingrown code from FormOptionsHelper#options_for_select. #5008 [anonymous] - -* Small fix in routing to allow dynamic routes (broken after [4242]) [Rick Olson] - - map.connect '*path', :controller => 'files', :action => 'show' - -* Use #flush between switching from #write to #syswrite. Closes #4907. [Blair Zajac ] - -* Allow error_messages_for to report errors for multiple objects, as well as support for customizing the name of the object in the error summary header. Closes #4186. [andrew@redlinesoftware.com, Marcel Molina Jr.] - - error_messages_for :account, :user, :subscription, :object_name => :account - -* Fix assert_redirected_to tests according to real-world usage. Also, don't fail if you add an extra :controller option: [Rick Olson] - - redirect_to :action => 'new' - assert_redirected_to :controller => 'monkeys', :action => 'new' - -* Diff compared routing options. Allow #assert_recognizes to take a second arg as a hash to specify optional request method [Rick Olson] - - assert_recognizes({:controller => 'users', :action => 'index'}, 'users') - assert_recognizes({:controller => 'users', :action => 'create'}, {:path => 'users', :method => :post}) - -* Diff compared options with #assert_redirected_to [Rick Olson] - -* Add support in routes for semicolon delimited "subpaths", like /books/:id;:action [Jamis Buck] - -* Change link_to_function and button_to_function to (optionally) take an update_page block instead of a JavaScript string. Closes #4804. [zraii@comcast.net, Sam Stephenson] - -* Modify routing so that you can say :require => { :method => :post } for a route, and the route will never be selected unless the request method is POST. Only works for route recognition, not for route generation. [Jamis Buck] - -* Added :add_headers option to verify which merges a hash of name/value pairs into the response's headers hash if the prerequisites cannot be satisfied. [Sam Stephenson] - ex. verify :only => :speak, :method => :post, - :render => { :status => 405, :text => "Must be post" }, - :add_headers => { "Allow" => "POST" } - - -*1.12.5* (August 10th, 2006) - -* Updated security fix - - -*1.12.4* (August 8th, 2006) - -* Cache CgiRequest#request_parameters so that multiple calls don't re-parse multipart data. [Rick Olson] - -* Fixed that remote_form_for can leave out the object parameter and default to the instance variable of the object_name, just like form_for [David Heinemeier Hansson] - -* Added ActionController.filter_parameter_logging that makes it easy to remove passwords, credit card numbers, and other sensitive information from being logged when a request is handled. #1897 [jeremye@bsa.ca.gov] - -* Fixed that real files and symlinks should be treated the same when compiling templates. #5438 [zachary@panandscan.com] - -* Add :status option to send_data and send_file. Defaults to '200 OK'. #5243 [Manfred Stienstra ] - -* Update documentation for erb trim syntax. #5651 [matt@mattmargolis.net] - -* Short documentation to mention use of Mime::Type.register. #5710 [choonkeat@gmail.com] - - -*1.12.3* (June 28th, 2006) - -* Fix broken traverse_to_controller. We now: - Look for a _controller.rb file under RAILS_ROOT to load. - If we find it, we require_dependency it and return the controller it defined. (If none was defined we stop looking.) - If we don't find it, we look for a .rb file under RAILS_ROOT to load. If we find it, and it loads a constant we keep looking. - Otherwise we check to see if a directory of the same name exists, and if it does we create a module for it. - - -*1.12.2* (June 27th, 2006) - -* Refinement to avoid exceptions in traverse_to_controller. - -* (Hackish) Fix loading of arbitrary files in Ruby's load path by traverse_to_controller. [Nicholas Seckar] - - -*1.12.1* (April 6th, 2006) - -* Fixed that template extensions would be cached development mode #4624 [Stefan Kaes] - -* Update to Prototype 1.5.0_rc0 [Sam Stephenson] - -* Honor skipping filters conditionally for only certain actions even when the parent class sets that filter to conditionally be executed only for the same actions. #4522 [Marcel Molina Jr.] - -* Delegate xml_http_request in integration tests to the session instance. [Jamis Buck] - -* Update the diagnostics template skip the useless '' text. [Nicholas Seckar] - -* CHANGED DEFAULT: Don't parse YAML input by default, but keep it available as an easy option [David Heinemeier Hansson] - -* Add additional autocompleter options [aballai, Thomas Fuchs] - -* Fixed fragment caching of binary data on Windows #4493 [bellis@deepthought.org] - -* Applied Prototype $() performance patches (#4465, #4477) and updated script.aculo.us [Sam Stephenson, Thomas Fuchs] - -* Added automated timestamping to AssetTagHelper methods for stylesheets, javascripts, and images when Action Controller is run under Rails [David Heinemeier Hansson]. Example: - - image_tag("rails.png") # => 'Rails' - - ...to avoid frequent stats (not a problem for most people), you can set RAILS_ASSET_ID in the ENV to avoid stats: - - ENV["RAILS_ASSET_ID"] = "2345" - image_tag("rails.png") # => 'Rails' - - This can be used by deployment managers to set the asset id by application revision - - -*1.12.0* (March 27th, 2006) - -* Add documentation for respond_to. [Jamis Buck] - -* Fixed require of bluecloth and redcloth when gems haven't been loaded #4446 [murphy@cYcnus.de] - -* Update to Prototype 1.5.0_pre1 [Sam Stephenson] - -* Change #form_for and #fields_for so that the second argument is not required [Dave Thomas] - - <% form_for :post, @post, :url => { :action => 'create' } do |f| -%> - - becomes... - - <% form_for :post, :url => { :action => 'create' } do |f| -%> - -* Update to script.aculo.us 1.6 [Thomas Fuchs] - -* Enable application/x-yaml processing by default [Jamis Buck] - -* Fix double url escaping of remote_function. Add :escape => false option to ActionView's url_for. [Nicholas Seckar] - -* Add :script option to in_place_editor to support evalScripts (closes #4194) [Cody Fauser] - -* Fix mixed case enumerable methods in the JavaScript Collection Proxy (closes #4314) [Cody Fauser] - -* Undo accidental escaping for mail_to; add regression test. [Nicholas Seckar] - -* Added nicer message for assert_redirected_to (closes #4294) [court3nay] - - assert_redirected_to :action => 'other_host', :only_path => false - - when it was expecting... - - redirected_to :action => 'other_host', :only_path => true, :host => 'other.test.host' - - gives the error message... - - response is not a redirection to all of the options supplied (redirection is <{:only_path=>false, :host=>"other.test.host", :action=>"other_host"}>), difference: <{:only_path=>"true", :host=>"other.test.host"}> - -* Change url_for to escape the resulting URLs when called from a view. [Nicholas Seckar, coffee2code] - -* Added easy support for testing file uploads with fixture_file_upload #4105 [turnip@turnipspatch.com]. Example: - - # Looks in Test::Unit::TestCase.fixture_path + '/files/spongebob.png' - post :change_avatar, :avatar => fixture_file_upload('/files/spongebob.png', 'image/png') - -* Fixed UrlHelper#current_page? to behave even when url-escaped entities are present #3929 [jeremy@planetargon.com] - -* Add ability for relative_url_root to be specified via an environment variable RAILS_RELATIVE_URL_ROOT. [isaac@reuben.com, Nicholas Seckar] - -* Fixed link_to "somewhere", :post => true to produce valid XHTML by using the parentnode instead of document.body for the instant form #3007 [Bob Silva] - -* Added :function option to PrototypeHelper#observe_field/observe_form that allows you to call a function instead of submitting an ajax call as the trigger #4268 [jonathan@daikini.com] - -* Make Mime::Type.parse consider q values (if any) [Jamis Buck] - -* XML-formatted requests are typecast according to "type" attributes for :xml_simple [Jamis Buck] - -* Added protection against proxy setups treating requests as local even when they're not #3898 [Steve Purcell] - -* Added TestRequest#raw_post that simulate raw_post from CgiRequest #3042 [François Beausoleil] - -* Underscore dasherized keys in formatted requests [Jamis Buck] - -* Add MimeResponds::Responder#any for managing multiple types with identical responses [Jamis Buck] - -* Make the xml_http_request testing method set the HTTP_ACCEPT header [Jamis Buck] - -* Add Verification to scaffolds. Prevent destructive actions using GET [Michael Koziarski] - -* Avoid hitting the filesystem when using layouts by using a File.directory? cache. [Stefan Kaes, Nicholas Seckar] - -* Simplify ActionController::Base#controller_path [Nicholas Seckar] - -* Added simple alert() notifications for RJS exceptions when config.action_view.debug_rjs = true. [Sam Stephenson] - -* Added :content_type option to render, so you can change the content type on the fly [David Heinemeier Hansson]. Example: render :action => "atom.rxml", :content_type => "application/atom+xml" - -* CHANGED DEFAULT: The default content type for .rxml is now application/xml instead of type/xml, see http://www.xml.com/pub/a/2004/07/21/dive.html for reason [David Heinemeier Hansson] - -* Added option to render action/template/file of a specific extension (and here by template type). This means you can have multiple templates with the same name but a different extension [David Heinemeier Hansson]. Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find :all - - respond_to do |type| - type.html # using defaults, which will render weblog/index.rhtml - type.xml { render :action => "index.rxml" } - type.js { render :action => "index.rjs" } - end - end - end - -* Added better support for using the same actions to output for different sources depending on the Accept header [David Heinemeier Hansson]. Example: - - class WeblogController < ActionController::Base - def create - @post = Post.create(params[:post]) - - respond_to do |type| - type.js { render } # renders create.rjs - type.html { redirect_to :action => "index" } - type.xml do - headers["Location"] = url_for(:action => "show", :id => @post) - render(:nothing, :status => "201 Created") - end - end - end - end - -* Added Base#render(:xml => xml) that works just like Base#render(:text => text), but sets the content-type to text/xml and the charset to UTF-8 [David Heinemeier Hansson] - -* Integration test's url_for now runs in the context of the last request (if any) so after post /products/show/1 url_for :action => 'new' will yield /product/new [Tobias Lütke] - -* Re-added mixed-in helper methods for the JavascriptGenerator. Moved JavascriptGenerators methods to a module that is mixed in after the helpers are added. Also fixed that variables set in the enumeration methods like #collect are set correctly. Documentation added for the enumeration methods [Rick Olson]. Examples: - - page.select('#items li').collect('items') do |element| - element.hide - end - # => var items = $$('#items li').collect(function(value, index) { return value.hide(); }); - -* Added plugin support for parameter parsers, which allows for better support for REST web services. By default, posts submitted with the application/xml content type is handled by creating a XmlSimple hash with the same name as the root element of the submitted xml. More handlers can easily be registered like this: - - # Assign a new param parser to a new content type - ActionController::Base.param_parsers['application/atom+xml'] = Proc.new do |data| - node = REXML::Document.new(post) - { node.root.name => node.root } - end - - # Assign the default XmlSimple to a new content type - ActionController::Base.param_parsers['application/backpack+xml'] = :xml_simple - -Default YAML web services were retired, ActionController::Base.param_parsers carries an example which shows how to get this functionality back. As part of this new plugin support, request.[formatted_post?, xml_post?, yaml_post? and post_format] were all deprecated in favor of request.content_type [Tobias Lütke] - -* Fixed Effect.Appear in effects.js to work with floats in Safari #3524, #3813, #3044 [Thomas Fuchs] - -* Fixed that default image extension was not appended when using a full URL with AssetTagHelper#image_tag #4032, #3728 [rubyonrails@beautifulpixel.com] - -* Added that page caching will only happen if the response code is less than 400 #4033 [g.bucher@teti.ch] - -* Add ActionController::IntegrationTest to allow high-level testing of the way the controllers and routes all work together [Jamis Buck] - -* Added support to AssetTagHelper#javascript_include_tag for having :defaults appear anywhere in the list, so you can now make one call ala javascript_include_tag(:defaults, "my_scripts") or javascript_include_tag("my_scripts", :defaults) depending on how you want the load order #3506 [Bob Silva] - -* Added support for visual effects scoped queues to the visual_effect helper #3530 [Abdur-Rahman Advany] - -* Added .rxml (and any non-rhtml template, really) supportfor CaptureHelper#content_for and CaptureHelper#capture #3287 [Brian Takita] - -* Added script.aculo.us drag and drop helpers to RJS [Thomas Fuchs]. Examples: - - page.draggable 'product-1' - page.drop_receiving 'wastebasket', :url => { :action => 'delete' } - page.sortable 'todolist', :url => { action => 'change_order' } - -* Fixed that form elements would strip the trailing [] from the first parameter #3545 [ruby@bobsilva.com] - -* During controller resolution, update the NameError suppression to check for the expected constant. [Nicholas Seckar] - -* Update script.aculo.us to V1.5.3 [Thomas Fuchs] - -* Added various InPlaceEditor options, #3746, #3891, #3896, #3906 [Bill Burcham, ruairi, sl33p3r] - -* Added :count option to pagination that'll make it possible for the ActiveRecord::Base.count call to using something else than * for the count. Especially important for count queries using DISTINCT #3839 [Stefan Kaes] - -* Update script.aculo.us to V1.5.2 [Thomas Fuchs] - -* Added element and collection proxies to RJS [David Heinemeier Hansson]. Examples: - - page['blank_slate'] # => $('blank_slate'); - page['blank_slate'].show # => $('blank_slate').show(); - page['blank_slate'].show('first').up # => $('blank_slate').show('first').up(); - - page.select('p') # => $$('p'); - page.select('p.welcome b').first # => $$('p.welcome b').first(); - page.select('p.welcome b').first.hide # => $$('p.welcome b').first().hide(); - -* Add JavaScriptGenerator#replace for replacing an element's "outer HTML". #3246 [tom@craz8.com, Sam Stephenson] - -* Remove over-engineered form_for code for a leaner implementation. [Nicholas Seckar] - -* Document form_for's :html option. [Nicholas Seckar] - -* Major components cleanup and speedup. #3527 [Stefan Kaes] - -* Fix problems with pagination and :include. [Kevin Clark] - -* Add ActiveRecordTestCase for testing AR integration. [Kevin Clark] - -* Add Unit Tests for pagination [Kevin Clark] - -* Add :html option for specifying form tag options in form_for. [Sam Stephenson] - -* Replace dubious controller parent class in filter docs. #3655, #3722 [info@rhalff.com, eigentone@gmail.com] - -* Don't interpret the :value option on text_area as an html attribute. Set the text_area's value. #3752 [gabriel@gironda.org] - -* Fix remote_form_for creates a non-ajax form. [Rick Olson] - -* Don't let arbitrary classes match as controllers -- a potentially dangerous bug. [Nicholas Seckar] - -* Fix Routing tests. Fix routing where failing to match a controller would prevent the rest of routes from being attempted. [Nicholas Seckar] - -* Add :builder => option to form_for and friends. [Nicholas Seckar, Rick Olson] - -* Fix controller resolution to avoid accidentally inheriting a controller from a parent module. [Nicholas Seckar] - -* Set sweeper's @controller to nil after a request so that the controller may be collected between requests. [Nicholas Seckar] - -* Subclasses of ActionController::Caching::Sweeper should be Reloadable. [Rick Olson] - -* Document the :xhr option for verifications. #3666 [leeo] - -* Added :only and :except controls to skip_before/after_filter just like for when you add filters [David Heinemeier Hansson] - -* Ensure that the instance variables are copied to the template when performing render :update. [Nicholas Seckar] - -* Add the ability to call JavaScriptGenerator methods from helpers called in update blocks. [Sam Stephenson] Example: - module ApplicationHelper - def update_time - page.replace_html 'time', Time.now.to_s(:db) - page.visual_effect :highlight, 'time' - end - end - - class UserController < ApplicationController - def poll - render :update { |page| page.update_time } - end - end - -* Add render(:update) to ActionView::Base. [Sam Stephenson] - -* Fix render(:update) to not render layouts. [Sam Stephenson] - -* Fixed that SSL would not correctly be detected when running lighttpd/fcgi behind lighttpd w/mod_proxy #3548 [Steve Purcell] - -* Added the possibility to specify atomatic expiration for the memcachd session container #3571 [Stefan Kaes] - -* Change layout discovery to take into account the change in semantics with File.join and nil arguments. [Marcel Molina Jr.] - -* Raise a RedirectBackError if redirect_to :back is called when there's no HTTP_REFERER defined #3049 [Kevin Clark] - -* Treat timestamps like datetimes for scaffolding purposes #3388 [Maik Schmidt] - -* Fix IE bug with link_to "something", :post => true #3443 [Justin Palmer] - -* Extract Test::Unit::TestCase test process behavior into an ActionController::TestProcess module. [Sam Stephenson] - -* Pass along blocks from render_to_string to render. [Sam Stephenson] - -* Add render :update for inline RJS. [Sam Stephenson] Example: - class UserController < ApplicationController - def refresh - render :update do |page| - page.replace_html 'user_list', :partial => 'user', :collection => @users - page.visual_effect :highlight, 'user_list' - end - end - end - -* allow nil objects for error_messages_for [Michael Koziarski] - -* Refactor human_size to exclude decimal place if it is zero. [Marcel Molina Jr.] - -* Update to Prototype 1.5.0_pre0 [Sam Stephenson] - -* Automatically discover layouts when a controller is namespaced. #2199, #3424 [me@jonnii.com rails@jeffcole.net Marcel Molina Jr.] - -* Add support for multiple proxy servers to CgiRequest#host [gaetanot@comcast.net] - -* Documentation typo fix. #2367 [Blair Zajac] - -* Remove Upload Progress. #2871 [Sean Treadway] - -* Fix typo in function name mapping in auto_complete_field. #2929 #3446 [doppler@gmail.com phil.ross@gmail.com] - -* Allow auto-discovery of third party template library layouts. [Marcel Molina Jr.] - -* Have the form builder output radio button, not check box, when calling the radio button helper. #3331 [LouisStAmour@gmail.com] - -* Added assignment of the Autocompleter object created by JavaScriptMacroHelper#auto_complete_field to a local javascript variables [David Heinemeier Hansson] - -* Added :on option for PrototypeHelper#observe_field that allows you to specify a different callback hook to have the observer trigger on [David Heinemeier Hansson] - -* Added JavaScriptHelper#button_to_function that works just like JavaScriptHelper#link_to_function but uses a button instead of a href [David Heinemeier Hansson] - -* Added that JavaScriptHelper#link_to_function will honor existing :onclick definitions when adding the function call [David Heinemeier Hansson] - -* Added :disable_with option to FormTagHelper#submit_tag to allow for easily disabled submit buttons with different text [David Heinemeier Hansson] - -* Make auto_link handle nil by returning quickly if blank? [Scott Barron] - -* Make auto_link match urls with a port number specified. [Marcel Molina Jr.] - -* Added support for toggling visual effects to ScriptaculousHelper::visual_effect, #3323. [Thomas Fuchs] - -* Update to script.aculo.us to 1.5.0 rev. 3343 [Thomas Fuchs] - -* Added :select option for JavaScriptMacroHelper#auto_complete_field that makes it easier to only use part of the auto-complete suggestion as the value for insertion [Thomas Fuchs] - -* Added delayed execution of Javascript from within RJS #3264 [devslashnull@gmail.com]. Example: - - page.delay(20) do - page.visual_effect :fade, 'notice' - end - -* Add session ID to default logging, but remove the verbose description of every step [David Heinemeier Hansson] - -* Add the following RJS methods: [Sam Stephenson] - - * alert - Displays an alert() dialog - * redirect_to - Changes window.location.href to simulate a browser redirect - * call - Calls a JavaScript function - * assign - Assigns to a JavaScript variable - * << - Inserts an arbitrary JavaScript string - -* Fix incorrect documentation for form_for [Nicholas Seckar] - -* Don't include a layout when rendering an rjs template using render's :template option. [Marcel Molina Jr.] - -*1.1.2* (December 13th, 2005) - -* Become part of Rails 1.0 - -* Update to script.aculo.us 1.5.0 final (equals 1.5.0_rc6) [Thomas Fuchs] - -* Update to Prototype 1.4.0 final [Sam Stephenson] - -* Added form_remote_for (form_for meets form_remote_tag) [David Heinemeier Hansson] - -* Update to script.aculo.us 1.5.0_rc6 - -* More robust relative url root discovery for SCGI compatibility. This solves the 'SCGI routes problem' -- you no longer need to prefix all your routes with the name of the SCGI mountpoint. #3070 [Dave Ringoen] - -* Fix docs for text_area_tag. #3083. [Christopher Cotton] - -* Change form_for and fields_for method signatures to take object name and object as separate arguments rather than as a Hash. [David Heinemeier Hansson] - -* Introduce :selected option to the select helper. Allows you to specify a selection other than the current value of object.method. Specify :selected => nil to leave all options unselected. #2991 [Jonathan Viney ] - -* Initialize @optional in routing code to avoid warnings about uninitialized access to an instance variable. [Nicholas Seckar] - -* Make ActionController's render honor the :locals option when rendering a :file. #1665. [Emanuel Borsboom, Marcel Molina Jr.] - -* Allow assert_tag(:conditions) to match the empty string when a tag has no children. Closes #2959. [Jamis Buck] - -* Update html-scanner to handle CDATA sections better. Closes #2970. [Jamis Buck] - -* Don't put flash in session if sessions are disabled. [Jeremy Kemper] - -* Strip out trailing &_= for raw post bodies. Closes #2868. [Sam Stephenson] - -* Pass multiple arguments to Element.show and Element.hide in JavaScriptGenerator instead of using iterators. [Sam Stephenson] - -* Improve expire_fragment documentation. #2966 [court3nay] - -* Correct docs for automatic layout assignment. #2610. [Charles M. Gerungan] - -* Always create new AR sessions rather than trying too hard to avoid database traffic. #2731 [Jeremy Kemper] - -* Update to Prototype 1.4.0_rc4. Closes #2943 (old Array.prototype.reverse behavior can be obtained by passing false as an argument). [Sam Stephenson] - -* Use Element.update('id', 'html') instead of $('id').innerHTML = 'html' in JavaScriptGenerator#replace_html so that script tags are evaluated. [Sam Stephenson] - -* Make rjs templates always implicitly skip out on layouts. [Marcel Molina Jr.] - -* Correct length for the truncate text helper. #2913 [Stefan Kaes] - -* Update to Prototype 1.4.0_rc3. Closes #1893, #2505, #2550, #2748, #2783. [Sam Stephenson] - -* Add support for new rjs templates which wrap an update_page block. [Marcel Molina Jr.] - -* Rename Version constant to VERSION. #2802 [Marcel Molina Jr.] - -* Correct time_zone_options_for_select docs. #2892 [pudeyo@rpi.com] - -* Remove the unused, slow response_dump and session_dump variables from error pages. #1222 [lmarlow] - -* Performance tweaks: use Set instead of Array to speed up prototype helper include? calls. Avoid logging code if logger is nil. Inline commonly-called template presence checks. #2880, #2881, #2882, #2883 [Stefan Kaes] - -* MemCache store may be given multiple addresses. #2869 [Ryan Carver ] - -* Handle cookie parsing irregularity for certain Nokia phones. #2530 [zaitzow@gmail.com] - -* Added PrototypeHelper::JavaScriptGenerator and PrototypeHelper#update_page for easily modifying multiple elements in an Ajax response. [Sam Stephenson] Example: - - update_page do |page| - page.insert_html :bottom, 'list', '
  • Last item
  • ' - page.visual_effect :highlight, 'list' - page.hide 'status-indicator', 'cancel-link' - end - - generates the following JavaScript: - - new Insertion.Bottom("list", "
  • Last item
  • "); - new Effect.Highlight("list"); - ["status-indicator", "cancel-link"].each(Element.hide); - -* Refactored JavaScriptHelper into PrototypeHelper and ScriptaculousHelper [Sam Stephenson] - -* Update to latest script.aculo.us version (as of [3031]) - -* Updated docs for in_place_editor, fixes a couple bugs and offers extended support for external controls [Justin Palmer] - -* Update documentation for render :file. #2858 [Tom Werner] - -* Only include builtin filters whose filenames match /^[a-z][a-z_]*_helper.rb$/ to avoid including operating system metadata such as ._foo_helper.rb. #2855 [court3nay] - -* Added FormHelper#form_for and FormHelper#fields_for that makes it easier to work with forms for single objects also if they don't reside in instance variables [David Heinemeier Hansson]. Examples: - - <% form_for :person, @person, :url => { :action => "update" } do |f| %> - First name: <%= f.text_field :first_name %> - Last name : <%= f.text_field :last_name %> - Biography : <%= f.text_area :biography %> - Admin? : <%= f.check_box :admin %> - <% end %> - - <% form_for :person, person, :url => { :action => "update" } do |person_form| %> - First name: <%= person_form.text_field :first_name %> - Last name : <%= person_form.text_field :last_name %> - - <% fields_for :permission => person.permission do |permission_fields| %> - Admin? : <%= permission_fields.check_box :admin %> - <% end %> - <% end %> - -* options_for_select allows any objects which respond_to? :first and :last rather than restricting to Array and Range. #2824 [Jacob Robbins , Jeremy Kemper] - -* The auto_link text helper accepts an optional block to format the link text for each url and email address. Example: auto_link(post.body) { |text| truncate(text, 10) } [Jeremy Kemper] - -* assert_tag uses exact matches for string conditions, instead of partial matches. Use regex to do partial matches. #2799 [Jamis Buck] - -* CGI::Session::ActiveRecordStore.data_column_name = 'foobar' to use a different session data column than the 'data' default. [nbpwie102@sneakemail.com] - -* Do not raise an exception when default helper is missing; log a debug message instead. It's nice to delete empty helpers. [Jeremy Kemper] - -* Controllers with acronyms in their names (e.g. PDFController) require the correct default helper (PDFHelper in file pdf_helper.rb). #2262 [jeff@opendbms.com] - - -*1.11.0* (November 7th, 2005) - -* Added request as instance method to views, so you can do <%= request.env["HTTP_REFERER"] %>, just like you can already access response, session, and the likes [David Heinemeier Hansson] - -* Fix conflict with assert_tag and Glue gem #2255 [david.felstead@gmail.com] - -* Add documentation to assert_tag indicating that it only works with well-formed XHTML #1937, #2570 [Jamis Buck] - -* Added action_pack.rb stub so that ActionPack::Version loads properly [Sam Stephenson] - -* Added short-hand to assert_tag so assert_tag :tag => "span" can be written as assert_tag "span" [David Heinemeier Hansson] - -* Added skip_before_filter/skip_after_filter for easier control of the filter chain in inheritance hierachies [David Heinemeier Hansson]. Example: - - class ApplicationController < ActionController::Base - before_filter :authenticate - end - - class WeblogController < ApplicationController - # will run the :authenticate filter - end - - class SignupController < ActionController::Base - # will not run the :authenticate filter - skip_before_filter :authenticate - end - -* Added redirect_to :back as a short-hand for redirect_to(request.env["HTTP_REFERER"]) [David Heinemeier Hansson] - -* Change javascript_include_tag :defaults to not use script.aculo.us loader, which facilitates the use of plugins for future script.aculo.us and third party javascript extensions, and provide register_javascript_include_default for plugins to specify additional JavaScript files to load. Removed slider.js and builder.js from actionpack. [Thomas Fuchs] - -* Fix problem where redirecting components can cause an infinite loop [Rick Olson] - -* Added support for the queue option on visual_effect [Thomas Fuchs] - -* Update script.aculo.us to V1.5_rc4 [Thomas Fuchs] - -* Fix that render :text didn't interpolate instance variables #2629, #2626 [Stefan Kaes] - -* Fix line number detection and escape RAILS_ROOT in backtrace Regexp [Nicholas Seckar] - -* Fixed document.getElementsByClassName from Prototype to be speedy again [Sam Stephenson] - -* Recognize ./#{RAILS_ROOT} as RAILS_ROOT in error traces [Nicholas Seckar] - -* Remove ARStore session fingerprinting [Nicholas Seckar] - -* Fix obscure bug in ARStore [Nicholas Seckar] - -* Added TextHelper#strip_tags for removing HTML tags from a string (using HTMLTokenizer) #2229 [marcin@junkheap.net] - -* Added a reader for flash.now, so it's possible to do stuff like flash.now[:alert] ||= 'New if not set' #2422 [Caio Chassot] - - -*1.10.2* (October 26th, 2005) - -* Reset template variables after using render_to_string [Stefan Kaes] - -* Expose the session model backing CGI::Session - -* Abbreviate RAILS_ROOT in traces - - -*1.10.1* (October 19th, 2005) - -* Update error trace templates [Nicholas Seckar] - -* Stop showing generated routing code in application traces [Nicholas Seckar] - - -*1.10.0* (October 16th, 2005) - -* Make string-keys locals assigns optional. Add documentation describing depreciated state [Stefan Kaes] - -* Improve line number detection for template errors [Nicholas Seckar] - -* Update/clean up documentation (rdoc) - -* Upgrade to Prototype 1.4.0_rc0 [Sam Stephenson] - -* Added assert_vaild. Reports the proper AR error messages as fail message when the passed record is invalid [Tobias Lütke] - -* Add temporary support for passing locals to render using string keys [Nicholas Seckar] - -* Clean up error pages by providing better backtraces [Nicholas Seckar] - -* Raise an exception if an attempt is made to insert more session data into the ActiveRecordStore data column than the column can hold. #2234. [justin@textdrive.com] - -* Removed references to assertions.rb from actionpack assert's backtraces. Makes error reports in functional unit tests much less noisy. [Tobias Lütke] - -* Updated and clarified documentation for JavaScriptHelper to be more concise about the various options for including the JavaScript libs. [Thomas Fuchs] - -* Hide "Retry with Breakpoint" button on error pages until feature is functional. [David Heinemeier Hansson] - -* Fix Request#host_with_port to use the standard port when Rails is behind a proxy. [Nicholas Seckar] - -* Escape query strings in the href attribute of URLs created by url_helper. #2333 [Michael Schuerig ] - -* Improved line number reporting for template errors [Nicholas Seckar] - -* Added :locals support for render :inline #2463 [mdabney@cavoksolutions.com] - -* Unset the X-Requested-With header when using the xhr wrapper in functional tests so that future requests aren't accidentally xhr'ed #2352 [me@julik.nl, Sam Stephenson] - -* Unescape paths before writing cache to file system. #1877. [Damien Pollet] - -* Wrap javascript_tag contents in a CDATA section and add a cdata_section method to TagHelper #1691 [Michael Schuerig, Sam Stephenson] - -* Misc doc fixes (typos/grammar/etc). #2445. [coffee2code] - -* Speed improvement for session_options. #2287. [Stefan Kaes] - -* Make cacheing binary files friendly with Windows. #1975. [Rich Olson] - -* Convert boolean form options form the tag_helper. #809. [Michael Schuerig ] - -* Fixed that an instance variable with the same name as a partial should be implicitly passed as the partial :object #2269 [court3nay] - -* Update Prototype to V1.4.0_pre11, script.aculo.us to [2502] [Thomas Fuchs] - -* Make assert_tag :children count appropriately. Closes #2181. [jamie@bravenet.com] - -* Forced newer versions of RedCloth to use hard breaks [David Heinemeier Hansson] - -* Added new scriptaculous options for auto_complete_field #2343 [Manfred Stienstra] - -* Don't prepend the asset host if the string is already a fully-qualified URL - -* Updated to script.aculo.us V1.5.0_rc2 and Prototype to V1.4.0_pre7 [Thomas Fuchs] - -* Undo condition change made in [2345] to prevent normal parameters arriving as StringIO. - -* Tolerate consecutive delimiters in query parameters. #2295 [darashi@gmail.com] - -* Streamline render process, code cleaning. Closes #2294. [skae] - -* Keep flash after components are rendered. #2291 [Rick Olson, Scott] - -* Shorten IE file upload path to filename only to match other browsers. #1507 [court3nay] - -* Fix open/save dialog in IE not opening files send with send_file/send_data, #2279 [Thomas Fuchs] - -* Fixed that auto_discovery_link_tag couldn't take a string as the URL [David Heinemeier Hansson] - -* Fixed problem with send_file and WEBrick using stdout #1812 [David Heinemeier Hansson] - -* Optimized tag_options to not sort keys, which is no longer necessary when assert_dom_equal and friend is available #1995 [skae] - -* Added assert_dom_equal and assert_dom_not_equal to compare tags generated by the helpers in an order-indifferent manner #1995 [skae] - -* Fixed that Request#domain caused an exception if the domain header wasn't set in the original http request #1795 [Michael Koziarski] - -* Make the truncate() helper multi-byte safe (assuming $KCODE has been set to something other than "NONE") #2103 - -* Add routing tests from #1945 [ben@groovie.org] - -* Add a routing test case covering #2101 [Nicholas Seckar] - -* Cache relative_url_root for all webservers, not just Apache #2193 [skae] - -* Speed up cookie use by decreasing string copying #2194 [skae] - -* Fixed access to "Host" header with requests made by crappy old HTTP/1.0 clients #2124 [Marcel Molina Jr.] - -* Added easy assignment of fragment cache store through use of symbols for included stores (old way still works too) - - Before: - ActionController::Base.fragment_cache_store = - ActionController::Base::Caching::Fragments::FileStore.new("/path/to/cache/directory") - - After: - ActionController::Base.fragment_cache_store = :file_store, "/path/to/cache/directory" - -* Added ActionController::Base.session_store=, session_store, and session_options to make it easier to tweak the session options (instead of going straight to ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS) - -* Added TextHelper#cycle to cycle over an array of values on each hit (useful for alternating row colors etc) #2154 [dave-ml@dribin.org] - -* Ensure that request.path never returns nil. Closes #1675 [Nicholas Seckar] - -* Add ability to specify Route Regexps for controllers. Closes #1917. [Sebastian Kanthak] - -* Provide Named Route's hash methods as helper methods. Closes #1744. [Nicholas Seckar, Steve Purcell] - -* Added :multipart option to ActiveRecordHelper#form to make it possible to add file input fields #2034 [jstirk@oobleyboo.com] - -* Moved auto-completion and in-place editing into the Macros module and their helper counterparts into JavaScriptMacrosHelper - -* Added in-place editing support in the spirit of auto complete with ActionController::Base.in_place_edit_for, JavascriptHelper#in_place_editor_field, and Javascript support from script.aculo.us #2038 [Jon Tirsen] - -* Added :disabled option to all data selects that'll make the elements inaccessible for change #2167, #253 [eigentone] - -* Fixed that TextHelper#auto_link_urls would include punctuation in the links #2166, #1671 [eigentone] - -* Fixed that number_to_currency(1000, {:precision => 0})) should return "$1,000", instead of "$1,000." #2122 [sd@notso.net] - -* Allow link_to_remote to use any DOM-element as the parent of the form elements to be submitted #2137 [erik@ruby-lang.nl]. Example: - - - - - <%= link_to_remote 'Save', :update => "row023", - :submit => "row023", :url => {:action => 'save_row'} %> - - -* Fixed that render :partial would fail when :object was a Hash (due to backwards compatibility issues) #2148 [Sam Stephenson] - -* Fixed JavascriptHelper#auto_complete_for to only include unique items #2153 [Thomas Fuchs] - -* Fixed all AssetHelper methods to work with relative paths, such that javascript_include_tag('stdlib/standard') will look in /javascripts/stdlib/standard instead of '/stdlib/standard/' #1963 - -* Avoid extending view instance with helper modules each request. Closes #1979 - -* Performance improvements to CGI methods. Closes #1980 [Stefan Kaes] - -* Added :post option to UrlHelper#link_to that makes it possible to do POST requests through normal ahref links using Javascript - -* Fixed overwrite_params - -* Added ActionController::Base.benchmark and ActionController::Base.silence to allow for easy benchmarking and turning off the log - -* Updated vendor copy of html-scanner to support better xml parsing - -* Added :popup option to UrlHelper#link_to #1996 [gabriel.gironda@gmail.com]. Examples: - - link_to "Help", { :action => "help" }, :popup => true - link_to "Busy loop", { :action => "busy" }, :popup => ['new_window', 'height=300,width=600'] - -* Drop trailing \000 if present on RAW_POST_DATA (works around bug in Safari Ajax implementation) #918 - -* Fix observe_field to fall back to event-based observation if frequency <= 0 #1916 [Michael Schubert] - -* Allow use of the :with option for submit_to_remote #1936 [jon@instance-design.co.uk] - -* AbstractRequest#domain returns nil when host is an ip address #2012 [Kevin Clark] - -* ActionController documentation update #2051 [François Beausoleil] - -* Yield @content_for_ variables to templates #2058 [Sam Stephenson] - -* Make rendering an empty partial collection behave like :nothing => true #2080 [Sam Stephenson] - -* Add option to specify the singular name used by pagination. - -* Use string key to obtain action value. Allows indifferent hashes to be disabled. - -* Added ActionView::Base.cache_template_loading back. - -* Rewrote compiled templates to decrease code complexity. Removed template load caching in favour of compiled caching. Fixed template error messages. [Nicholas Seckar] - -* Fix Routing to handle :some_param => nil better. [Nicholas Seckar, Luminas] - -* Add support for :include with pagination (subject to existing constraints for :include with :limit and :offset) #1478 [Michael Schubert] - -* Prevent the benchmark module from blowing up if a non-HTTP/1.1 request is processed - -* Added :use_short_month option to select_month helper to show month names as abbreviations - -* Make link_to escape the javascript in the confirm option #1964 [nicolas.pouillard@gmail.com] - -* Make assert_redirected_to properly check URL's passed as strings #1910 [Scott Barron] - -* Make sure :layout => false is always used when rendering inside a layout - -* Use raise instead of assert_not_nil in Test::Unit::TestCase#process to ensure that the test variables (controller, request, response) have been set - -* Make sure assigns are built for every request when testing #1866 - -* Allow remote_addr to be queried on TestRequest #1668 - -* Fixed bug when a partial render was passing a local with the same name as the partial - -* Improved performance of test app req/sec with ~10% refactoring the render method #1823 [Stefan Kaes] - -* Improved performance of test app req/sec with 5-30% through a series of Action Pack optimizations #1811 [Stefan Kaes] - -* Changed caching/expiration/hit to report using the DEBUG log level and errors to use the ERROR log level instead of both using INFO - -* Added support for per-action session management #1763 - -* Improved rendering speed on complicated templates by up to 100% (the more complex the templates, the higher the speedup) #1234 [Stefan Kaes]. This did necessasitate a change to the internals of ActionView#render_template that now has four parameters. Developers of custom view handlers (like Amrita) need to update for that. - -* Added options hash as third argument to FormHelper#input, so you can do input('person', 'zip', :size=>10) #1719 [jeremye@bsa.ca.gov] - -* Added Base#expires_in(seconds)/Base#expires_now to control HTTP content cache headers #1755 [Thomas Fuchs] - -* Fixed line number reporting for Builder template errors #1753 [piotr] - -* Fixed assert_routing so that testing controllers in modules works as expected [Nicholas Seckar, Rick Olson] - -* Fixed bug with :success/:failure callbacks for the JavaScriptHelper methods #1730 [court3nay/Thomas Fuchs] - -* Added named_route method to RouteSet instances so that RouteSet instance methods do not prevent certain names from being used. [Nicholas Seckar] - -* Fixed routes so that routes which do not specify :action in the path or in the requirements have a default of :action => 'index', In addition, fixed url generation so that :action => 'index' does not need to be provided for such urls. [Nicholas Seckar, Markjuh] - -* Worked around a Safari bug where it wouldn't pass headers through if the response was zero length by having render :nothing return ' ' instead of '' - -* Fixed Request#subdomains to handle "foo.foo.com" correctly - - -*1.9.1* (11 July, 2005) - -* Fixed that auto_complete_for didn't force the input string to lower case even as the db comparison was - -* Fixed that Action View should always use the included Builder, never attempt to require the gem, to ensure compatibility - -* Added that nil options are not included in tags, so tag("p", :ignore => nil) now returns

    not

    but that tag("p", :ignore => "") still includes it #1465 [Michael Schuerig] - -* Fixed that UrlHelper#link_to_unless/link_to_if used html_escape on the name if no link was to be applied. This is unnecessary and breaks its use with images #1649 [joergd@pobox.com] - -* Improved error message for DoubleRenderError - -* Fixed routing to allow for testing of *path components #1650 [Nicholas Seckar] - -* Added :handle as an option to sortable_element to restrict the drag handle to a given class #1642 [thejohnny] - -* Added a bunch of script.aculo.us features #1644, #1677, #1695 [Thomas Fuchs] - * Effect.ScrollTo, to smoothly scroll the page to an element - * Better Firefox flickering handling on SlideUp/SlideDown - * Removed a possible memory leak in IE with draggables - * Added support for cancelling dragging my hitting ESC - * Added capability to remove draggables/droppables and redeclare sortables in dragdrop.js (this makes it possible to call sortable_element on the same element more than once, e.g. in AJAX returns that modify the sortable element. all current sortable 'stuff' on the element will be discarded and the sortable will be rebuilt) - * Always reset background color on Effect.Highlight; this make change backwards-compatibility, to be sure include style="background-color:(target-color)" on your elements or else elements will fall back to their CSS rules (which is a good thing in most circumstances) - * Removed circular references from element to prevent memory leaks (still not completely gone in IE) - * Changes to class extension in effects.js - * Make Effect.Highlight restore any previously set background color when finishing (makes effect work with CSS classes that set a background color) - * Fixed myriads of memory leaks in IE and Gecko-based browsers [David Zülke] - * Added incremental and local autocompleting and loads of documentation to controls.js [Ivan Krstic] - * Extended the auto_complete_field helper to accept tokens option - * Changed object extension mechanism to favor Object.extend to make script.aculo.us easily adaptable to support 3rd party libs like IE7.js [David Zülke] - -* Fixed that named routes didn't use the default values for action and possible other parameters #1534 [Nicholas Seckar] - -* Fixed JavascriptHelper#visual_effect to use camelize such that :blind_up will work #1639 [pelletierm@eastmedia.net] - -* Fixed that a SessionRestoreError was thrown if a model object was placed in the session that wasn't available to all controllers. This means that it's no longer necessary to use the 'model :post' work-around in ApplicationController to have a Post model in your session. - - -*1.9.0* (6 July, 2005) - -* Added logging of the request URI in the benchmark statement (makes it easy to grep for slow actions) - -* Added javascript_include_tag :defaults shortcut that'll include all the default javascripts included with Action Pack (prototype, effects, controls, dragdrop) - -* Cache several controller variables that are expensive to calculate #1229 [Stefan Kaes] - -* The session class backing CGI::Session::ActiveRecordStore may be replaced with any class that duck-types with a subset of Active Record. See docs for details #1238 [Stefan Kaes] - -* Fixed that hashes was not working properly when passed by GET to lighttpd #849 [Nicholas Seckar] - -* Fixed assert_template nil will be true when no template was rendered #1565 [maceywj@telus.net] - -* Added :prompt option to FormOptions#select (and the users of it, like FormOptions#select_country etc) to create "Please select" style descriptors #1181 [Michael Schuerig] - -* Added JavascriptHelper#update_element_function, which returns a Javascript function (or expression) that'll update a DOM element according to the options passed #933 [mortonda@dgrmm.net]. Examples: - - <%= update_element_function("products", :action => :insert, :position => :bottom, :content => "

    New product!

    ") %> - - <% update_element_function("products", :action => :replace, :binding => binding) do %> -

    Product 1

    -

    Product 2

    - <% end %> - -* Added :field_name option to DateHelper#select_(year|month|day) to deviate from the year/month/day defaults #1266 [Marcel Molina Jr.] - -* Added JavascriptHelper#draggable_element and JavascriptHelper#drop_receiving_element to facilitate easy dragging and dropping through the script.aculo.us libraries #1578 [Thomas Fuchs] - -* Added that UrlHelper#mail_to will now also encode the default link title #749 [f.svehla@gmail.com] - -* Removed the default option of wrap=virtual on FormHelper#text_area to ensure XHTML compatibility #1300 [thomas@columbus.rr.com] - -* Adds the ability to include XML CDATA tags using Builder #1563 [Josh Knowles]. Example: - - xml.cdata! "some text" # => - -* Added evaluation of - - - -
    -

    <%=h exception.class %> at <%=h path %>

    -

    <%=h exception.message %>

    - - - - - - -
    Ruby<%=h frames.first.filename %>: in <%=h frames.first.function %>, line <%=h frames.first.lineno %>
    Web<%=h req.request_method %> <%=h(req.host + path)%>
    - -

    Jump to:

    - -
    - -
    -

    Traceback (innermost first)

    -
      -<% frames.each { |frame| %> -
    • - <%=h frame.filename %>: in <%=h frame.function %> - - <% if frame.context_line %> -
      - <% if frame.pre_context %> -
        - <% frame.pre_context.each { |line| %> -
      1. <%=h line %>
      2. - <% } %> -
      - <% end %> - -
        -
      1. <%=h frame.context_line %>...
      - - <% if frame.post_context %> -
        - <% frame.post_context.each { |line| %> -
      1. <%=h line %>
      2. - <% } %> -
      - <% end %> -
      - <% end %> -
    • -<% } %> -
    -
    - -
    -

    Request information

    - -

    GET

    - <% unless req.GET.empty? %> - - - - - - - - - <% req.GET.sort_by { |k, v| k.to_s }.each { |key, val| %> - - - - - <% } %> - -
    VariableValue
    <%=h key %>
    <%=h val.inspect %>
    - <% else %> -

    No GET data.

    - <% end %> - -

    POST

    - <% unless req.POST.empty? %> - - - - - - - - - <% req.POST.sort_by { |k, v| k.to_s }.each { |key, val| %> - - - - - <% } %> - -
    VariableValue
    <%=h key %>
    <%=h val.inspect %>
    - <% else %> -

    No POST data.

    - <% end %> - - - - <% unless req.cookies.empty? %> - - - - - - - - - <% req.cookies.each { |key, val| %> - - - - - <% } %> - -
    VariableValue
    <%=h key %>
    <%=h val.inspect %>
    - <% else %> -

    No cookie data.

    - <% end %> - -

    Rack ENV

    - - - - - - - - - <% env.sort_by { |k, v| k.to_s }.each { |key, val| %> - - - - - <% } %> - -
    VariableValue
    <%=h key %>
    <%=h val %>
    - -
    - -
    -

    - You're seeing this error because you use Rack::ShowExceptions. -

    -
    - - - -HTML - - # :startdoc: - end -end diff --git a/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/showstatus.rb b/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/showstatus.rb deleted file mode 100644 index 28258c7..0000000 --- a/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/showstatus.rb +++ /dev/null @@ -1,106 +0,0 @@ -require 'erb' -require 'rack/request' -require 'rack/utils' - -module Rack - # Rack::ShowStatus catches all empty responses the app it wraps and - # replaces them with a site explaining the error. - # - # Additional details can be put into rack.showstatus.detail - # and will be shown as HTML. If such details exist, the error page - # is always rendered, even if the reply was not empty. - - class ShowStatus - def initialize(app) - @app = app - @template = ERB.new(TEMPLATE) - end - - def call(env) - status, headers, body = @app.call(env) - headers = Utils::HeaderHash.new(headers) - empty = headers['Content-Length'].to_i <= 0 - - # client or server error, or explicit message - if (status.to_i >= 400 && empty) || env["rack.showstatus.detail"] - req = Rack::Request.new(env) - message = Rack::Utils::HTTP_STATUS_CODES[status.to_i] || status.to_s - detail = env["rack.showstatus.detail"] || message - body = @template.result(binding) - size = Rack::Utils.bytesize(body) - [status, headers.merge("Content-Type" => "text/html", "Content-Length" => size.to_s), [body]] - else - [status, headers, body] - end - end - - def h(obj) # :nodoc: - case obj - when String - Utils.escape_html(obj) - else - Utils.escape_html(obj.inspect) - end - end - - # :stopdoc: - -# adapted from Django -# Copyright (c) 2005, the Lawrence Journal-World -# Used under the modified BSD license: -# http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5 -TEMPLATE = <<'HTML' - - - - - <%=h message %> at <%=h req.script_name + req.path_info %> - - - - -
    -

    <%=h message %> (<%= status.to_i %>)

    - - - - - - - - - -
    Request Method:<%=h req.request_method %>
    Request URL:<%=h req.url %>
    -
    -
    -

    <%= detail %>

    -
    - -
    -

    - You're seeing this error because you use Rack::ShowStatus. -

    -
    - - -HTML - - # :startdoc: - end -end diff --git a/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/static.rb b/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/static.rb deleted file mode 100644 index 168e8f8..0000000 --- a/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/static.rb +++ /dev/null @@ -1,38 +0,0 @@ -module Rack - - # The Rack::Static middleware intercepts requests for static files - # (javascript files, images, stylesheets, etc) based on the url prefixes - # passed in the options, and serves them using a Rack::File object. This - # allows a Rack stack to serve both static and dynamic content. - # - # Examples: - # use Rack::Static, :urls => ["/media"] - # will serve all requests beginning with /media from the "media" folder - # located in the current directory (ie media/*). - # - # use Rack::Static, :urls => ["/css", "/images"], :root => "public" - # will serve all requests beginning with /css or /images from the folder - # "public" in the current directory (ie public/css/* and public/images/*) - - class Static - - def initialize(app, options={}) - @app = app - @urls = options[:urls] || ["/favicon.ico"] - root = options[:root] || Dir.pwd - @file_server = Rack::File.new(root) - end - - def call(env) - path = env["PATH_INFO"] - can_serve = @urls.any? { |url| path.index(url) == 0 } - - if can_serve - @file_server.call(env) - else - @app.call(env) - end - end - - end -end diff --git a/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb b/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb deleted file mode 100644 index 0ff32df..0000000 --- a/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb +++ /dev/null @@ -1,55 +0,0 @@ -module Rack - # Rack::URLMap takes a hash mapping urls or paths to apps, and - # dispatches accordingly. Support for HTTP/1.1 host names exists if - # the URLs start with http:// or https://. - # - # URLMap modifies the SCRIPT_NAME and PATH_INFO such that the part - # relevant for dispatch is in the SCRIPT_NAME, and the rest in the - # PATH_INFO. This should be taken care of when you need to - # reconstruct the URL in order to create links. - # - # URLMap dispatches in such a way that the longest paths are tried - # first, since they are most specific. - - class URLMap - def initialize(map = {}) - remap(map) - end - - def remap(map) - @mapping = map.map { |location, app| - if location =~ %r{\Ahttps?://(.*?)(/.*)} - host, location = $1, $2 - else - host = nil - end - - unless location[0] == ?/ - raise ArgumentError, "paths need to start with /" - end - location = location.chomp('/') - - [host, location, app] - }.sort_by { |(h, l, a)| [-l.size, h.to_s.size] } # Longest path first - end - - def call(env) - path = env["PATH_INFO"].to_s.squeeze("/") - script_name = env['SCRIPT_NAME'] - hHost, sName, sPort = env.values_at('HTTP_HOST','SERVER_NAME','SERVER_PORT') - @mapping.each { |host, location, app| - next unless (hHost == host || sName == host \ - || (host.nil? && (hHost == sName || hHost == sName+':'+sPort))) - next unless location == path[0, location.size] - next unless path[location.size] == nil || path[location.size] == ?/ - - return app.call( - env.merge( - 'SCRIPT_NAME' => (script_name + location), - 'PATH_INFO' => path[location.size..-1])) - } - [404, {"Content-Type" => "text/plain"}, ["Not Found: #{path}"]] - end - end -end - diff --git a/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb b/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb deleted file mode 100644 index 0a61bce..0000000 --- a/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb +++ /dev/null @@ -1,392 +0,0 @@ -require 'set' -require 'tempfile' - -module Rack - # Rack::Utils contains a grab-bag of useful methods for writing web - # applications adopted from all kinds of Ruby libraries. - - module Utils - # Performs URI escaping so that you can construct proper - # query strings faster. Use this rather than the cgi.rb - # version since it's faster. (Stolen from Camping). - def escape(s) - s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) { - '%'+$1.unpack('H2'*$1.size).join('%').upcase - }.tr(' ', '+') - end - module_function :escape - - # Unescapes a URI escaped string. (Stolen from Camping). - def unescape(s) - s.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n){ - [$1.delete('%')].pack('H*') - } - end - module_function :unescape - - # Stolen from Mongrel, with some small modifications: - # Parses a query string by breaking it up at the '&' - # and ';' characters. You can also use this to parse - # cookies by changing the characters used in the second - # parameter (which defaults to '&;'). - def parse_query(qs, d = '&;') - params = {} - - (qs || '').split(/[#{d}] */n).each do |p| - k, v = unescape(p).split('=', 2) - - if cur = params[k] - if cur.class == Array - params[k] << v - else - params[k] = [cur, v] - end - else - params[k] = v - end - end - - return params - end - module_function :parse_query - - def parse_nested_query(qs, d = '&;') - params = {} - - (qs || '').split(/[#{d}] */n).each do |p| - k, v = unescape(p).split('=', 2) - normalize_params(params, k, v) - end - - return params - end - module_function :parse_nested_query - - def normalize_params(params, name, v = nil) - name =~ %r([\[\]]*([^\[\]]+)\]*) - k = $1 || '' - after = $' || '' - - return if k.empty? - - if after == "" - params[k] = v - elsif after == "[]" - params[k] ||= [] - raise TypeError unless params[k].is_a?(Array) - params[k] << v - elsif after =~ %r(^\[\]\[([^\[\]]+)\]$) || after =~ %r(^\[\](.+)$) - child_key = $1 - params[k] ||= [] - raise TypeError unless params[k].is_a?(Array) - if params[k].last.is_a?(Hash) && !params[k].last.key?(child_key) - normalize_params(params[k].last, child_key, v) - else - params[k] << normalize_params({}, child_key, v) - end - else - params[k] ||= {} - params[k] = normalize_params(params[k], after, v) - end - - return params - end - module_function :normalize_params - - def build_query(params) - params.map { |k, v| - if v.class == Array - build_query(v.map { |x| [k, x] }) - else - escape(k) + "=" + escape(v) - end - }.join("&") - end - module_function :build_query - - # Escape ampersands, brackets and quotes to their HTML/XML entities. - def escape_html(string) - string.to_s.gsub("&", "&"). - gsub("<", "<"). - gsub(">", ">"). - gsub("'", "'"). - gsub('"', """) - end - module_function :escape_html - - def select_best_encoding(available_encodings, accept_encoding) - # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html - - expanded_accept_encoding = - accept_encoding.map { |m, q| - if m == "*" - (available_encodings - accept_encoding.map { |m2, _| m2 }).map { |m2| [m2, q] } - else - [[m, q]] - end - }.inject([]) { |mem, list| - mem + list - } - - encoding_candidates = expanded_accept_encoding.sort_by { |_, q| -q }.map { |m, _| m } - - unless encoding_candidates.include?("identity") - encoding_candidates.push("identity") - end - - expanded_accept_encoding.find_all { |m, q| - q == 0.0 - }.each { |m, _| - encoding_candidates.delete(m) - } - - return (encoding_candidates & available_encodings)[0] - end - module_function :select_best_encoding - - # Return the bytesize of String; uses String#length under Ruby 1.8 and - # String#bytesize under 1.9. - if ''.respond_to?(:bytesize) - def bytesize(string) - string.bytesize - end - else - def bytesize(string) - string.size - end - end - module_function :bytesize - - # Context allows the use of a compatible middleware at different points - # in a request handling stack. A compatible middleware must define - # #context which should take the arguments env and app. The first of which - # would be the request environment. The second of which would be the rack - # application that the request would be forwarded to. - class Context - attr_reader :for, :app - - def initialize(app_f, app_r) - raise 'running context does not respond to #context' unless app_f.respond_to? :context - @for, @app = app_f, app_r - end - - def call(env) - @for.context(env, @app) - end - - def recontext(app) - self.class.new(@for, app) - end - - def context(env, app=@app) - recontext(app).call(env) - end - end - - # A case-insensitive Hash that preserves the original case of a - # header when set. - class HeaderHash < Hash - def initialize(hash={}) - @names = {} - hash.each { |k, v| self[k] = v } - end - - def to_hash - inject({}) do |hash, (k,v)| - if v.respond_to? :to_ary - hash[k] = v.to_ary.join("\n") - else - hash[k] = v - end - hash - end - end - - def [](k) - super @names[k.downcase] - end - - def []=(k, v) - delete k - @names[k.downcase] = k - super k, v - end - - def delete(k) - super @names.delete(k.downcase) - end - - def include?(k) - @names.has_key? k.downcase - end - - alias_method :has_key?, :include? - alias_method :member?, :include? - alias_method :key?, :include? - - def merge!(other) - other.each { |k, v| self[k] = v } - self - end - - def merge(other) - hash = dup - hash.merge! other - end - end - - # Every standard HTTP code mapped to the appropriate message. - # Stolen from Mongrel. - HTTP_STATUS_CODES = { - 100 => 'Continue', - 101 => 'Switching Protocols', - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 307 => 'Temporary Redirect', - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Large', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported' - } - - # Responses with HTTP status codes that should not have an entity body - STATUS_WITH_NO_ENTITY_BODY = Set.new((100..199).to_a << 204 << 304) - - # A multipart form data parser, adapted from IOWA. - # - # Usually, Rack::Request#POST takes care of calling this. - - module Multipart - EOL = "\r\n" - - def self.parse_multipart(env) - unless env['CONTENT_TYPE'] =~ - %r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?|n - nil - else - boundary = "--#{$1}" - - params = {} - buf = "" - content_length = env['CONTENT_LENGTH'].to_i - input = env['rack.input'] - - boundary_size = boundary.size + EOL.size - bufsize = 16384 - - content_length -= boundary_size - - status = input.read(boundary_size) - raise EOFError, "bad content body" unless status == boundary + EOL - - rx = /(?:#{EOL})?#{Regexp.quote boundary}(#{EOL}|--)/n - - loop { - head = nil - body = '' - filename = content_type = name = nil - - until head && buf =~ rx - if !head && i = buf.index("\r\n\r\n") - head = buf.slice!(0, i+2) # First \r\n - buf.slice!(0, 2) # Second \r\n - - filename = head[/Content-Disposition:.* filename="?([^\";]*)"?/ni, 1] - content_type = head[/Content-Type: (.*)\r\n/ni, 1] - name = head[/Content-Disposition:.* name="?([^\";]*)"?/ni, 1] - - if filename - body = Tempfile.new("RackMultipart") - body.binmode if body.respond_to?(:binmode) - end - - next - end - - # Save the read body part. - if head && (boundary_size+4 < buf.size) - body << buf.slice!(0, buf.size - (boundary_size+4)) - end - - c = input.read(bufsize < content_length ? bufsize : content_length) - raise EOFError, "bad content body" if c.nil? || c.empty? - buf << c - content_length -= c.size - end - - # Save the rest. - if i = buf.index(rx) - body << buf.slice!(0, i) - buf.slice!(0, boundary_size+2) - - content_length = -1 if $1 == "--" - end - - if filename == "" - # filename is blank which means no file has been selected - data = nil - elsif filename - body.rewind - - # Take the basename of the upload's original filename. - # This handles the full Windows paths given by Internet Explorer - # (and perhaps other broken user agents) without affecting - # those which give the lone filename. - filename =~ /^(?:.*[:\\\/])?(.*)/m - filename = $1 - - data = {:filename => filename, :type => content_type, - :name => name, :tempfile => body, :head => head} - else - data = body - end - - Utils.normalize_params(params, name, data) unless data.nil? - - break if buf.empty? || content_length == -1 - } - - begin - input.rewind if input.respond_to?(:rewind) - rescue Errno::ESPIPE - # Handles exceptions raised by input streams that cannot be rewound - # such as when using plain CGI under Apache - end - - params - end - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_controller/verification.rb b/vendor/rails/actionpack/lib/action_controller/verification.rb deleted file mode 100644 index c62b81b..0000000 --- a/vendor/rails/actionpack/lib/action_controller/verification.rb +++ /dev/null @@ -1,130 +0,0 @@ -module ActionController #:nodoc: - module Verification #:nodoc: - def self.included(base) #:nodoc: - base.extend(ClassMethods) - end - - # This module provides a class-level method for specifying that certain - # actions are guarded against being called without certain prerequisites - # being met. This is essentially a special kind of before_filter. - # - # An action may be guarded against being invoked without certain request - # parameters being set, or without certain session values existing. - # - # When a verification is violated, values may be inserted into the flash, and - # a specified redirection is triggered. If no specific action is configured, - # verification failures will by default result in a 400 Bad Request response. - # - # Usage: - # - # class GlobalController < ActionController::Base - # # Prevent the #update_settings action from being invoked unless - # # the 'admin_privileges' request parameter exists. The - # # settings action will be redirected to in current controller - # # if verification fails. - # verify :params => "admin_privileges", :only => :update_post, - # :redirect_to => { :action => "settings" } - # - # # Disallow a post from being updated if there was no information - # # submitted with the post, and if there is no active post in the - # # session, and if there is no "note" key in the flash. The route - # # named category_url will be redirected to if verification fails. - # - # verify :params => "post", :session => "post", "flash" => "note", - # :only => :update_post, - # :add_flash => { "alert" => "Failed to create your message" }, - # :redirect_to => :category_url - # - # Note that these prerequisites are not business rules. They do not examine - # the content of the session or the parameters. That level of validation should - # be encapsulated by your domain model or helper methods in the controller. - module ClassMethods - # Verify the given actions so that if certain prerequisites are not met, - # the user is redirected to a different action. The +options+ parameter - # is a hash consisting of the following key/value pairs: - # - # :params:: - # a single key or an array of keys that must be in the params - # hash in order for the action(s) to be safely called. - # :session:: - # a single key or an array of keys that must be in the session - # in order for the action(s) to be safely called. - # :flash:: - # a single key or an array of keys that must be in the flash in order - # for the action(s) to be safely called. - # :method:: - # a single key or an array of keys--any one of which must match the - # current request method in order for the action(s) to be safely called. - # (The key should be a symbol: :get or :post, for - # example.) - # :xhr:: - # true/false option to ensure that the request is coming from an Ajax - # call or not. - # :add_flash:: - # a hash of name/value pairs that should be merged into the session's - # flash if the prerequisites cannot be satisfied. - # :add_headers:: - # a hash of name/value pairs that should be merged into the response's - # headers hash if the prerequisites cannot be satisfied. - # :redirect_to:: - # the redirection parameters to be used when redirecting if the - # prerequisites cannot be satisfied. You can redirect either to named - # route or to the action in some controller. - # :render:: - # the render parameters to be used when the prerequisites cannot be satisfied. - # :only:: - # only apply this verification to the actions specified in the associated - # array (may also be a single value). - # :except:: - # do not apply this verification to the actions specified in the associated - # array (may also be a single value). - def verify(options={}) - before_filter :only => options[:only], :except => options[:except] do |c| - c.__send__ :verify_action, options - end - end - end - - private - - def verify_action(options) #:nodoc: - if prereqs_invalid?(options) - flash.update(options[:add_flash]) if options[:add_flash] - response.headers.merge!(options[:add_headers]) if options[:add_headers] - apply_remaining_actions(options) unless performed? - end - end - - def prereqs_invalid?(options) # :nodoc: - verify_presence_of_keys_in_hash_flash_or_params(options) || - verify_method(options) || - verify_request_xhr_status(options) - end - - def verify_presence_of_keys_in_hash_flash_or_params(options) # :nodoc: - [*options[:params] ].find { |v| params[v].nil? } || - [*options[:session]].find { |v| session[v].nil? } || - [*options[:flash] ].find { |v| flash[v].nil? } - end - - def verify_method(options) # :nodoc: - [*options[:method]].all? { |v| request.method != v.to_sym } if options[:method] - end - - def verify_request_xhr_status(options) # :nodoc: - request.xhr? != options[:xhr] unless options[:xhr].nil? - end - - def apply_redirect_to(redirect_to_option) # :nodoc: - (redirect_to_option.is_a?(Symbol) && redirect_to_option != :back) ? self.__send__(redirect_to_option) : redirect_to_option - end - - def apply_remaining_actions(options) # :nodoc: - case - when options[:render] ; render(options[:render]) - when options[:redirect_to] ; redirect_to(apply_redirect_to(options[:redirect_to])) - else head(:bad_request) - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/lib/action_pack.rb b/vendor/rails/actionpack/lib/action_pack.rb deleted file mode 100644 index b90f89b..0000000 --- a/vendor/rails/actionpack/lib/action_pack.rb +++ /dev/null @@ -1,24 +0,0 @@ -#-- -# Copyright (c) 2004-2009 David Heinemeier Hansson -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ - -require 'action_pack/version' diff --git a/vendor/rails/actionpack/lib/action_pack/version.rb b/vendor/rails/actionpack/lib/action_pack/version.rb deleted file mode 100644 index e0aa2a5..0000000 --- a/vendor/rails/actionpack/lib/action_pack/version.rb +++ /dev/null @@ -1,9 +0,0 @@ -module ActionPack #:nodoc: - module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 2 - - STRING = [MAJOR, MINOR, TINY].join('.') - end -end diff --git a/vendor/rails/actionpack/lib/action_view.rb b/vendor/rails/actionpack/lib/action_view.rb deleted file mode 100644 index 1f1ff9d..0000000 --- a/vendor/rails/actionpack/lib/action_view.rb +++ /dev/null @@ -1,58 +0,0 @@ -#-- -# Copyright (c) 2004-2009 David Heinemeier Hansson -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ - -begin - require 'active_support' -rescue LoadError - activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib" - if File.directory?(activesupport_path) - $:.unshift activesupport_path - require 'active_support' - end -end - -module ActionView - def self.load_all! - [Base, InlineTemplate, TemplateError] - end - - autoload :Base, 'action_view/base' - autoload :Helpers, 'action_view/helpers' - autoload :InlineTemplate, 'action_view/inline_template' - autoload :Partials, 'action_view/partials' - autoload :PathSet, 'action_view/paths' - autoload :Renderable, 'action_view/renderable' - autoload :RenderablePartial, 'action_view/renderable_partial' - autoload :Template, 'action_view/template' - autoload :ReloadableTemplate, 'action_view/reloadable_template' - autoload :TemplateError, 'action_view/template_error' - autoload :TemplateHandler, 'action_view/template_handler' - autoload :TemplateHandlers, 'action_view/template_handlers' - autoload :Helpers, 'action_view/helpers' -end - -class ERB - autoload :Util, 'action_view/erb/util' -end - -I18n.load_path << "#{File.dirname(__FILE__)}/action_view/locale/en.yml" diff --git a/vendor/rails/actionpack/lib/action_view/base.rb b/vendor/rails/actionpack/lib/action_view/base.rb deleted file mode 100644 index e19acc5..0000000 --- a/vendor/rails/actionpack/lib/action_view/base.rb +++ /dev/null @@ -1,357 +0,0 @@ -module ActionView #:nodoc: - class ActionViewError < StandardError #:nodoc: - end - - class MissingTemplate < ActionViewError #:nodoc: - attr_reader :path - - def initialize(paths, path, template_format = nil) - @path = path - full_template_path = path.include?('.') ? path : "#{path}.erb" - display_paths = paths.compact.join(":") - template_type = (path =~ /layouts/i) ? 'layout' : 'template' - super("Missing #{template_type} #{full_template_path} in view path #{display_paths}") - end - end - - # Action View templates can be written in three ways. If the template file has a .erb (or .rhtml) extension then it uses a mixture of ERb - # (included in Ruby) and HTML. If the template file has a .builder (or .rxml) extension then Jim Weirich's Builder::XmlMarkup library is used. - # If the template file has a .rjs extension then it will use ActionView::Helpers::PrototypeHelper::JavaScriptGenerator. - # - # = ERb - # - # You trigger ERb by using embeddings such as <% %>, <% -%>, and <%= %>. The <%= %> tag set is used when you want output. Consider the - # following loop for names: - # - # Names of all the people - # <% for person in @people %> - # Name: <%= person.name %>
    - # <% end %> - # - # The loop is setup in regular embedding tags <% %> and the name is written using the output embedding tag <%= %>. Note that this - # is not just a usage suggestion. Regular output functions like print or puts won't work with ERb templates. So this would be wrong: - # - # Hi, Mr. <% puts "Frodo" %> - # - # If you absolutely must write from within a function, you can use the TextHelper#concat. - # - # <%- and -%> suppress leading and trailing whitespace, including the trailing newline, and can be used interchangeably with <% and %>. - # - # == Using sub templates - # - # Using sub templates allows you to sidestep tedious replication and extract common display structures in shared templates. The - # classic example is the use of a header and footer (even though the Action Pack-way would be to use Layouts): - # - # <%= render "shared/header" %> - # Something really specific and terrific - # <%= render "shared/footer" %> - # - # As you see, we use the output embeddings for the render methods. The render call itself will just return a string holding the - # result of the rendering. The output embedding writes it to the current template. - # - # But you don't have to restrict yourself to static includes. Templates can share variables amongst themselves by using instance - # variables defined using the regular embedding tags. Like this: - # - # <% @page_title = "A Wonderful Hello" %> - # <%= render "shared/header" %> - # - # Now the header can pick up on the @page_title variable and use it for outputting a title tag: - # - # <%= @page_title %> - # - # == Passing local variables to sub templates - # - # You can pass local variables to sub templates by using a hash with the variable names as keys and the objects as values: - # - # <%= render "shared/header", { :headline => "Welcome", :person => person } %> - # - # These can now be accessed in shared/header with: - # - # Headline: <%= headline %> - # First name: <%= person.first_name %> - # - # If you need to find out whether a certain local variable has been assigned a value in a particular render call, - # you need to use the following pattern: - # - # <% if local_assigns.has_key? :headline %> - # Headline: <%= headline %> - # <% end %> - # - # Testing using defined? headline will not work. This is an implementation restriction. - # - # == Template caching - # - # By default, Rails will compile each template to a method in order to render it. When you alter a template, Rails will - # check the file's modification time and recompile it. - # - # == Builder - # - # Builder templates are a more programmatic alternative to ERb. They are especially useful for generating XML content. An XmlMarkup object - # named +xml+ is automatically made available to templates with a .builder extension. - # - # Here are some basic examples: - # - # xml.em("emphasized") # => emphasized - # xml.em { xml.b("emph & bold") } # => emph & bold - # xml.a("A Link", "href"=>"http://onestepback.org") # => A Link - # xml.target("name"=>"compile", "option"=>"fast") # => - # # NOTE: order of attributes is not specified. - # - # Any method with a block will be treated as an XML markup tag with nested markup in the block. For example, the following: - # - # xml.div { - # xml.h1(@person.name) - # xml.p(@person.bio) - # } - # - # would produce something like: - # - #
    - #

    David Heinemeier Hansson

    - #

    A product of Danish Design during the Winter of '79...

    - #
    - # - # A full-length RSS example actually used on Basecamp: - # - # xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do - # xml.channel do - # xml.title(@feed_title) - # xml.link(@url) - # xml.description "Basecamp: Recent items" - # xml.language "en-us" - # xml.ttl "40" - # - # for item in @recent_items - # xml.item do - # xml.title(item_title(item)) - # xml.description(item_description(item)) if item_description(item) - # xml.pubDate(item_pubDate(item)) - # xml.guid(@person.firm.account.url + @recent_items.url(item)) - # xml.link(@person.firm.account.url + @recent_items.url(item)) - # - # xml.tag!("dc:creator", item.author_name) if item_has_creator?(item) - # end - # end - # end - # end - # - # More builder documentation can be found at http://builder.rubyforge.org. - # - # == JavaScriptGenerator - # - # JavaScriptGenerator templates end in .rjs. Unlike conventional templates which are used to - # render the results of an action, these templates generate instructions on how to modify an already rendered page. This makes it easy to - # modify multiple elements on your page in one declarative Ajax response. Actions with these templates are called in the background with Ajax - # and make updates to the page where the request originated from. - # - # An instance of the JavaScriptGenerator object named +page+ is automatically made available to your template, which is implicitly wrapped in an ActionView::Helpers::PrototypeHelper#update_page block. - # - # When an .rjs action is called with +link_to_remote+, the generated JavaScript is automatically evaluated. Example: - # - # link_to_remote :url => {:action => 'delete'} - # - # The subsequently rendered delete.rjs might look like: - # - # page.replace_html 'sidebar', :partial => 'sidebar' - # page.remove "person-#{@person.id}" - # page.visual_effect :highlight, 'user-list' - # - # This refreshes the sidebar, removes a person element and highlights the user list. - # - # See the ActionView::Helpers::PrototypeHelper::GeneratorMethods documentation for more details. - class Base - include Helpers, Partials, ::ERB::Util - extend ActiveSupport::Memoizable - - attr_accessor :base_path, :assigns, :template_extension - attr_accessor :controller - - attr_writer :template_format - - attr_accessor :output_buffer - - class << self - delegate :erb_trim_mode=, :to => 'ActionView::TemplateHandlers::ERB' - delegate :logger, :to => 'ActionController::Base' - end - - @@debug_rjs = false - ## - # :singleton-method: - # Specify whether RJS responses should be wrapped in a try/catch block - # that alert()s the caught exception (and then re-raises it). - cattr_accessor :debug_rjs - - # Specify whether templates should be cached. Otherwise the file we be read everytime it is accessed. - # Automatically reloading templates are not thread safe and should only be used in development mode. - @@cache_template_loading = nil - cattr_accessor :cache_template_loading - - def self.cache_template_loading? - ActionController::Base.allow_concurrency || (cache_template_loading.nil? ? !ActiveSupport::Dependencies.load? : cache_template_loading) - end - - attr_internal :request - - delegate :request_forgery_protection_token, :template, :params, :session, :cookies, :response, :headers, - :flash, :logger, :action_name, :controller_name, :to => :controller - - module CompiledTemplates #:nodoc: - # holds compiled template code - end - include CompiledTemplates - - def self.process_view_paths(value) - ActionView::PathSet.new(Array(value)) - end - - attr_reader :helpers - - class ProxyModule < Module - def initialize(receiver) - @receiver = receiver - end - - def include(*args) - super(*args) - @receiver.extend(*args) - end - end - - def initialize(view_paths = [], assigns_for_first_render = {}, controller = nil)#:nodoc: - @assigns = assigns_for_first_render - @assigns_added = nil - @controller = controller - @helpers = ProxyModule.new(self) - self.view_paths = view_paths - - @_first_render = nil - @_current_render = nil - end - - attr_reader :view_paths - - def view_paths=(paths) - @view_paths = self.class.process_view_paths(paths) - # we might be using ReloadableTemplates, so we need to let them know this a new request - @view_paths.load! - end - - # Returns the result of a render that's dictated by the options hash. The primary options are: - # - # * :partial - See ActionView::Partials. - # * :update - Calls update_page with the block given. - # * :file - Renders an explicit template file (this used to be the old default), add :locals to pass in those. - # * :inline - Renders an inline template similar to how it's done in the controller. - # * :text - Renders the text passed in out. - # - # If no options hash is passed or :update specified, the default is to render a partial and use the second parameter - # as the locals hash. - def render(options = {}, local_assigns = {}, &block) #:nodoc: - local_assigns ||= {} - - case options - when Hash - options = options.reverse_merge(:locals => {}) - if options[:layout] - _render_with_layout(options, local_assigns, &block) - elsif options[:file] - template = self.view_paths.find_template(options[:file], template_format) - template.render_template(self, options[:locals]) - elsif options[:partial] - render_partial(options) - elsif options[:inline] - InlineTemplate.new(options[:inline], options[:type]).render(self, options[:locals]) - elsif options[:text] - options[:text] - end - when :update - update_page(&block) - else - render_partial(:partial => options, :locals => local_assigns) - end - end - - # The format to be used when choosing between multiple templates with - # the same name but differing formats. See +Request#template_format+ - # for more details. - def template_format - if defined? @template_format - @template_format - elsif controller && controller.respond_to?(:request) - @template_format = controller.request.template_format.to_sym - else - @template_format = :html - end - end - - # Access the current template being rendered. - # Returns a ActionView::Template object. - def template - @_current_render - end - - def template=(template) #:nodoc: - @_first_render ||= template - @_current_render = template - end - - def with_template(current_template) - last_template, self.template = template, current_template - yield - ensure - self.template = last_template - end - - private - # Evaluates the local assigns and controller ivars, pushes them to the view. - def _evaluate_assigns_and_ivars #:nodoc: - unless @assigns_added - @assigns.each { |key, value| instance_variable_set("@#{key}", value) } - _copy_ivars_from_controller - @assigns_added = true - end - end - - def _copy_ivars_from_controller #:nodoc: - if @controller - variables = @controller.instance_variable_names - variables -= @controller.protected_instance_variables if @controller.respond_to?(:protected_instance_variables) - variables.each { |name| instance_variable_set(name, @controller.instance_variable_get(name)) } - end - end - - def _set_controller_content_type(content_type) #:nodoc: - if controller.respond_to?(:response) - controller.response.content_type ||= content_type - end - end - - def _render_with_layout(options, local_assigns, &block) #:nodoc: - partial_layout = options.delete(:layout) - - if block_given? - begin - @_proc_for_layout = block - concat(render(options.merge(:partial => partial_layout))) - ensure - @_proc_for_layout = nil - end - else - begin - original_content_for_layout = @content_for_layout if defined?(@content_for_layout) - @content_for_layout = render(options) - - if (options[:inline] || options[:file] || options[:text]) - @cached_content_for_layout = @content_for_layout - render(:file => partial_layout, :locals => local_assigns) - else - render(options.merge(:partial => partial_layout)) - end - ensure - @content_for_layout = original_content_for_layout - end - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/erb/util.rb b/vendor/rails/actionpack/lib/action_view/erb/util.rb deleted file mode 100644 index 3c77c5c..0000000 --- a/vendor/rails/actionpack/lib/action_view/erb/util.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'erb' - -class ERB - module Util - HTML_ESCAPE = { '&' => '&', '>' => '>', '<' => '<', '"' => '"' } - JSON_ESCAPE = { '&' => '\u0026', '>' => '\u003E', '<' => '\u003C' } - - # A utility method for escaping HTML tag characters. - # This method is also aliased as h. - # - # In your ERb templates, use this method to escape any unsafe content. For example: - # <%=h @person.name %> - # - # ==== Example: - # puts html_escape("is a > 0 & a < 10?") - # # => is a > 0 & a < 10? - def html_escape(s) - s.to_s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] } - end - - # A utility method for escaping HTML entities in JSON strings. - # This method is also aliased as j. - # - # In your ERb templates, use this method to escape any HTML entities: - # <%=j @person.to_json %> - # - # ==== Example: - # puts json_escape("is a > 0 & a < 10?") - # # => is a \u003E 0 \u0026 a \u003C 10? - def json_escape(s) - s.to_s.gsub(/[&"><]/) { |special| JSON_ESCAPE[special] } - end - - alias j json_escape - module_function :j - module_function :json_escape - end -end diff --git a/vendor/rails/actionpack/lib/action_view/helpers.rb b/vendor/rails/actionpack/lib/action_view/helpers.rb deleted file mode 100644 index 693ab7c..0000000 --- a/vendor/rails/actionpack/lib/action_view/helpers.rb +++ /dev/null @@ -1,57 +0,0 @@ -module ActionView #:nodoc: - module Helpers #:nodoc: - autoload :ActiveRecordHelper, 'action_view/helpers/active_record_helper' - autoload :AssetTagHelper, 'action_view/helpers/asset_tag_helper' - autoload :AtomFeedHelper, 'action_view/helpers/atom_feed_helper' - autoload :BenchmarkHelper, 'action_view/helpers/benchmark_helper' - autoload :CacheHelper, 'action_view/helpers/cache_helper' - autoload :CaptureHelper, 'action_view/helpers/capture_helper' - autoload :DateHelper, 'action_view/helpers/date_helper' - autoload :DebugHelper, 'action_view/helpers/debug_helper' - autoload :FormHelper, 'action_view/helpers/form_helper' - autoload :FormOptionsHelper, 'action_view/helpers/form_options_helper' - autoload :FormTagHelper, 'action_view/helpers/form_tag_helper' - autoload :JavascriptHelper, 'action_view/helpers/javascript_helper' - autoload :NumberHelper, 'action_view/helpers/number_helper' - autoload :PrototypeHelper, 'action_view/helpers/prototype_helper' - autoload :RecordIdentificationHelper, 'action_view/helpers/record_identification_helper' - autoload :RecordTagHelper, 'action_view/helpers/record_tag_helper' - autoload :SanitizeHelper, 'action_view/helpers/sanitize_helper' - autoload :ScriptaculousHelper, 'action_view/helpers/scriptaculous_helper' - autoload :TagHelper, 'action_view/helpers/tag_helper' - autoload :TextHelper, 'action_view/helpers/text_helper' - autoload :TranslationHelper, 'action_view/helpers/translation_helper' - autoload :UrlHelper, 'action_view/helpers/url_helper' - - def self.included(base) - base.extend(ClassMethods) - end - - module ClassMethods - include SanitizeHelper::ClassMethods - end - - include ActiveRecordHelper - include AssetTagHelper - include AtomFeedHelper - include BenchmarkHelper - include CacheHelper - include CaptureHelper - include DateHelper - include DebugHelper - include FormHelper - include FormOptionsHelper - include FormTagHelper - include JavaScriptHelper - include NumberHelper - include PrototypeHelper - include RecordIdentificationHelper - include RecordTagHelper - include SanitizeHelper - include ScriptaculousHelper - include TagHelper - include TextHelper - include TranslationHelper - include UrlHelper - end -end diff --git a/vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb b/vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb deleted file mode 100644 index 541899e..0000000 --- a/vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb +++ /dev/null @@ -1,305 +0,0 @@ -require 'cgi' -require 'action_view/helpers/form_helper' - -module ActionView - class Base - @@field_error_proc = Proc.new{ |html_tag, instance| "
    #{html_tag}
    " } - cattr_accessor :field_error_proc - end - - module Helpers - # The Active Record Helper makes it easier to create forms for records kept in instance variables. The most far-reaching is the +form+ - # method that creates a complete form for all the basic content types of the record (not associations or aggregations, though). This - # is a great way of making the record quickly available for editing, but likely to prove lackluster for a complicated real-world form. - # In that case, it's better to use the +input+ method and the specialized +form+ methods in link:classes/ActionView/Helpers/FormHelper.html - module ActiveRecordHelper - # Returns a default input tag for the type of object returned by the method. For example, if @post - # has an attribute +title+ mapped to a +VARCHAR+ column that holds "Hello World": - # - # input("post", "title") - # # => - def input(record_name, method, options = {}) - InstanceTag.new(record_name, method, self).to_tag(options) - end - - # Returns an entire form with all needed input tags for a specified Active Record object. For example, if @post - # has attributes named +title+ of type +VARCHAR+ and +body+ of type +TEXT+ then - # - # form("post") - # - # would yield a form like the following (modulus formatting): - # - #
    - #

    - #
    - # - #

    - #

    - #
    - # - #

    - # - #
    - # - # It's possible to specialize the form builder by using a different action name and by supplying another - # block renderer. For example, if @entry has an attribute +message+ of type +VARCHAR+ then - # - # form("entry", - # :action => "sign", - # :input_block => Proc.new { |record, column| - # "#{column.human_name}: #{input(record, column.name)}
    " - # }) - # - # would yield a form like the following (modulus formatting): - # - #
    - # Message: - #
    - # - #
    - # - # It's also possible to add additional content to the form by giving it a block, such as: - # - # form("entry", :action => "sign") do |form| - # form << content_tag("b", "Department") - # form << collection_select("department", "id", @departments, "id", "name") - # end - # - # The following options are available: - # - # * :action - The action used when submitting the form (default: +create+ if a new record, otherwise +update+). - # * :input_block - Specialize the output using a different block, see above. - # * :method - The method used when submitting the form (default: +post+). - # * :multipart - Whether to change the enctype of the form to "multipart/form-data", used when uploading a file (default: +false+). - # * :submit_value - The text of the submit button (default: "Create" if a new record, otherwise "Update"). - def form(record_name, options = {}) - record = instance_variable_get("@#{record_name}") - - options = options.symbolize_keys - options[:action] ||= record.new_record? ? "create" : "update" - action = url_for(:action => options[:action], :id => record) - - submit_value = options[:submit_value] || options[:action].gsub(/[^\w]/, '').capitalize - - contents = form_tag({:action => action}, :method =>(options[:method] || 'post'), :enctype => options[:multipart] ? 'multipart/form-data': nil) - contents << hidden_field(record_name, :id) unless record.new_record? - contents << all_input_tags(record, record_name, options) - yield contents if block_given? - contents << submit_tag(submit_value) - contents << '' - end - - # Returns a string containing the error message attached to the +method+ on the +object+ if one exists. - # This error message is wrapped in a DIV tag, which can be extended to include a :prepend_text - # and/or :append_text (to properly explain the error), and a :css_class to style it - # accordingly. +object+ should either be the name of an instance variable or the actual object. The method can be - # passed in either as a string or a symbol. - # As an example, let's say you have a model @post that has an error message on the +title+ attribute: - # - # <%= error_message_on "post", "title" %> - # # =>
    can't be empty
    - # - # <%= error_message_on @post, :title %> - # # =>
    can't be empty
    - # - # <%= error_message_on "post", "title", - # :prepend_text => "Title simply ", - # :append_text => " (or it won't work).", - # :css_class => "inputError" %> - def error_message_on(object, method, *args) - options = args.extract_options! - unless args.empty? - ActiveSupport::Deprecation.warn('error_message_on takes an option hash instead of separate ' + - 'prepend_text, append_text, and css_class arguments', caller) - - options[:prepend_text] = args[0] || '' - options[:append_text] = args[1] || '' - options[:css_class] = args[2] || 'formError' - end - options.reverse_merge!(:prepend_text => '', :append_text => '', :css_class => 'formError') - - if (obj = (object.respond_to?(:errors) ? object : instance_variable_get("@#{object}"))) && - (errors = obj.errors.on(method)) - content_tag("div", - "#{options[:prepend_text]}#{ERB::Util.html_escape(errors.is_a?(Array) ? errors.first : errors)}#{options[:append_text]}", - :class => options[:css_class] - ) - else - '' - end - end - - # Returns a string with a DIV containing all of the error messages for the objects located as instance variables by the names - # given. If more than one object is specified, the errors for the objects are displayed in the order that the object names are - # provided. - # - # This DIV can be tailored by the following options: - # - # * :header_tag - Used for the header of the error div (default: "h2"). - # * :id - The id of the error div (default: "errorExplanation"). - # * :class - The class of the error div (default: "errorExplanation"). - # * :object - The object (or array of objects) for which to display errors, - # if you need to escape the instance variable convention. - # * :object_name - The object name to use in the header, or any text that you prefer. - # If :object_name is not set, the name of the first object will be used. - # * :header_message - The message in the header of the error div. Pass +nil+ - # or an empty string to avoid the header message altogether. (Default: "X errors - # prohibited this object from being saved"). - # * :message - The explanation message after the header message and before - # the error list. Pass +nil+ or an empty string to avoid the explanation message - # altogether. (Default: "There were problems with the following fields:"). - # - # To specify the display for one object, you simply provide its name as a parameter. - # For example, for the @user model: - # - # error_messages_for 'user' - # - # To specify more than one object, you simply list them; optionally, you can add an extra :object_name parameter, which - # will be the name used in the header message: - # - # error_messages_for 'user_common', 'user', :object_name => 'user' - # - # If the objects cannot be located as instance variables, you can add an extra :object parameter which gives the actual - # object (or array of objects to use): - # - # error_messages_for 'user', :object => @question.user - # - # NOTE: This is a pre-packaged presentation of the errors with embedded strings and a certain HTML structure. If what - # you need is significantly different from the default presentation, it makes plenty of sense to access the object.errors - # instance yourself and set it up. View the source of this method to see how easy it is. - def error_messages_for(*params) - options = params.extract_options!.symbolize_keys - - if object = options.delete(:object) - objects = [object].flatten - else - objects = params.collect {|object_name| instance_variable_get("@#{object_name}") }.compact - end - - count = objects.inject(0) {|sum, object| sum + object.errors.count } - unless count.zero? - html = {} - [:id, :class].each do |key| - if options.include?(key) - value = options[key] - html[key] = value unless value.blank? - else - html[key] = 'errorExplanation' - end - end - options[:object_name] ||= params.first - - I18n.with_options :locale => options[:locale], :scope => [:activerecord, :errors, :template] do |locale| - header_message = if options.include?(:header_message) - options[:header_message] - else - object_name = options[:object_name].to_s.gsub('_', ' ') - object_name = I18n.t(object_name, :default => object_name, :scope => [:activerecord, :models], :count => 1) - locale.t :header, :count => count, :model => object_name - end - message = options.include?(:message) ? options[:message] : locale.t(:body) - error_messages = objects.sum {|object| object.errors.full_messages.map {|msg| content_tag(:li, ERB::Util.html_escape(msg)) } }.join - - contents = '' - contents << content_tag(options[:header_tag] || :h2, header_message) unless header_message.blank? - contents << content_tag(:p, message) unless message.blank? - contents << content_tag(:ul, error_messages) - - content_tag(:div, contents, html) - end - else - '' - end - end - - private - def all_input_tags(record, record_name, options) - input_block = options[:input_block] || default_input_block - record.class.content_columns.collect{ |column| input_block.call(record_name, column) }.join("\n") - end - - def default_input_block - Proc.new { |record, column| %(


    #{input(record, column.name)}

    ) } - end - end - - class InstanceTag #:nodoc: - def to_tag(options = {}) - case column_type - when :string - field_type = @method_name.include?("password") ? "password" : "text" - to_input_field_tag(field_type, options) - when :text - to_text_area_tag(options) - when :integer, :float, :decimal - to_input_field_tag("text", options) - when :date - to_date_select_tag(options) - when :datetime, :timestamp - to_datetime_select_tag(options) - when :time - to_time_select_tag(options) - when :boolean - to_boolean_select_tag(options) - end - end - - alias_method :tag_without_error_wrapping, :tag - def tag(name, options) - if object.respond_to?(:errors) && object.errors.respond_to?(:on) - error_wrapping(tag_without_error_wrapping(name, options), object.errors.on(@method_name)) - else - tag_without_error_wrapping(name, options) - end - end - - alias_method :content_tag_without_error_wrapping, :content_tag - def content_tag(name, value, options) - if object.respond_to?(:errors) && object.errors.respond_to?(:on) - error_wrapping(content_tag_without_error_wrapping(name, value, options), object.errors.on(@method_name)) - else - content_tag_without_error_wrapping(name, value, options) - end - end - - alias_method :to_date_select_tag_without_error_wrapping, :to_date_select_tag - def to_date_select_tag(options = {}, html_options = {}) - if object.respond_to?(:errors) && object.errors.respond_to?(:on) - error_wrapping(to_date_select_tag_without_error_wrapping(options, html_options), object.errors.on(@method_name)) - else - to_date_select_tag_without_error_wrapping(options, html_options) - end - end - - alias_method :to_datetime_select_tag_without_error_wrapping, :to_datetime_select_tag - def to_datetime_select_tag(options = {}, html_options = {}) - if object.respond_to?(:errors) && object.errors.respond_to?(:on) - error_wrapping(to_datetime_select_tag_without_error_wrapping(options, html_options), object.errors.on(@method_name)) - else - to_datetime_select_tag_without_error_wrapping(options, html_options) - end - end - - alias_method :to_time_select_tag_without_error_wrapping, :to_time_select_tag - def to_time_select_tag(options = {}, html_options = {}) - if object.respond_to?(:errors) && object.errors.respond_to?(:on) - error_wrapping(to_time_select_tag_without_error_wrapping(options, html_options), object.errors.on(@method_name)) - else - to_time_select_tag_without_error_wrapping(options, html_options) - end - end - - def error_wrapping(html_tag, has_error) - has_error ? Base.field_error_proc.call(html_tag, self) : html_tag - end - - def error_message - object.errors.on(@method_name) - end - - def column_type - object.send(:column_for_attribute, @method_name).type - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb deleted file mode 100644 index a32beb6..0000000 --- a/vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ /dev/null @@ -1,682 +0,0 @@ -require 'cgi' -require 'action_view/helpers/url_helper' -require 'action_view/helpers/tag_helper' - -module ActionView - module Helpers #:nodoc: - # This module provides methods for generating HTML that links views to assets such - # as images, javascripts, stylesheets, and feeds. These methods do not verify - # the assets exist before linking to them: - # - # image_tag("rails.png") - # # => Rails src= - # stylesheet_link_tag("application") - # # => - # - # === Using asset hosts - # - # By default, Rails links to these assets on the current host in the public - # folder, but you can direct Rails to link to assets from a dedicated asset - # server by setting ActionController::Base.asset_host in the application - # configuration, typically in config/environments/production.rb. - # For example, you'd define assets.example.com to be your asset - # host this way: - # - # ActionController::Base.asset_host = "assets.example.com" - # - # Helpers take that into account: - # - # image_tag("rails.png") - # # => Rails - # stylesheet_link_tag("application") - # # => - # - # Browsers typically open at most two simultaneous connections to a single - # host, which means your assets often have to wait for other assets to finish - # downloading. You can alleviate this by using a %d wildcard in the - # +asset_host+. For example, "assets%d.example.com". If that wildcard is - # present Rails distributes asset requests among the corresponding four hosts - # "assets0.example.com", ..., "assets3.example.com". With this trick browsers - # will open eight simultaneous connections rather than two. - # - # image_tag("rails.png") - # # => Rails - # stylesheet_link_tag("application") - # # => - # - # To do this, you can either setup four actual hosts, or you can use wildcard - # DNS to CNAME the wildcard to a single asset host. You can read more about - # setting up your DNS CNAME records from your ISP. - # - # Note: This is purely a browser performance optimization and is not meant - # for server load balancing. See http://www.die.net/musings/page_load_time/ - # for background. - # - # Alternatively, you can exert more control over the asset host by setting - # +asset_host+ to a proc like this: - # - # ActionController::Base.asset_host = Proc.new { |source| - # "http://assets#{rand(2) + 1}.example.com" - # } - # image_tag("rails.png") - # # => Rails - # stylesheet_link_tag("application") - # # => - # - # The example above generates "http://assets1.example.com" and - # "http://assets2.example.com" randomly. This option is useful for example if - # you need fewer/more than four hosts, custom host names, etc. - # - # As you see the proc takes a +source+ parameter. That's a string with the - # absolute path of the asset with any extensions and timestamps in place, - # for example "/images/rails.png?1230601161". - # - # ActionController::Base.asset_host = Proc.new { |source| - # if source.starts_with?('/images') - # "http://images.example.com" - # else - # "http://assets.example.com" - # end - # } - # image_tag("rails.png") - # # => Rails - # stylesheet_link_tag("application") - # # => - # - # Alternatively you may ask for a second parameter +request+. That one is - # particularly useful for serving assets from an SSL-protected page. The - # example proc below disables asset hosting for HTTPS connections, while - # still sending assets for plain HTTP requests from asset hosts. If you don't - # have SSL certificates for each of the asset hosts this technique allows you - # to avoid warnings in the client about mixed media. - # - # ActionController::Base.asset_host = Proc.new { |source, request| - # if request.ssl? - # "#{request.protocol}#{request.host_with_port}" - # else - # "#{request.protocol}assets.example.com" - # end - # } - # - # You can also implement a custom asset host object that responds to +call+ - # and takes either one or two parameters just like the proc. - # - # config.action_controller.asset_host = AssetHostingWithMinimumSsl.new( - # "http://asset%d.example.com", "https://asset1.example.com" - # ) - # - # === Using asset timestamps - # - # By default, Rails appends asset's timestamps to all asset paths. This allows - # you to set a cache-expiration date for the asset far into the future, but - # still be able to instantly invalidate it by simply updating the file (and - # hence updating the timestamp, which then updates the URL as the timestamp - # is part of that, which in turn busts the cache). - # - # It's the responsibility of the web server you use to set the far-future - # expiration date on cache assets that you need to take advantage of this - # feature. Here's an example for Apache: - # - # # Asset Expiration - # ExpiresActive On - # - # ExpiresDefault "access plus 1 year" - # - # - # Also note that in order for this to work, all your application servers must - # return the same timestamps. This means that they must have their clocks - # synchronized. If one of them drifts out of sync, you'll see different - # timestamps at random and the cache won't work. In that case the browser - # will request the same assets over and over again even thought they didn't - # change. You can use something like Live HTTP Headers for Firefox to verify - # that the cache is indeed working. - module AssetTagHelper - ASSETS_DIR = defined?(Rails.public_path) ? Rails.public_path : "public" - JAVASCRIPTS_DIR = "#{ASSETS_DIR}/javascripts" - STYLESHEETS_DIR = "#{ASSETS_DIR}/stylesheets" - JAVASCRIPT_DEFAULT_SOURCES = ['prototype', 'effects', 'dragdrop', 'controls'].freeze unless const_defined?(:JAVASCRIPT_DEFAULT_SOURCES) - - # Returns a link tag that browsers and news readers can use to auto-detect - # an RSS or ATOM feed. The +type+ can either be :rss (default) or - # :atom. Control the link options in url_for format using the - # +url_options+. You can modify the LINK tag itself in +tag_options+. - # - # ==== Options - # * :rel - Specify the relation of this link, defaults to "alternate" - # * :type - Override the auto-generated mime type - # * :title - Specify the title of the link, defaults to the +type+ - # - # ==== Examples - # auto_discovery_link_tag # => - # - # auto_discovery_link_tag(:atom) # => - # - # auto_discovery_link_tag(:rss, {:action => "feed"}) # => - # - # auto_discovery_link_tag(:rss, {:action => "feed"}, {:title => "My RSS"}) # => - # - # auto_discovery_link_tag(:rss, {:controller => "news", :action => "feed"}) # => - # - # auto_discovery_link_tag(:rss, "http://www.example.com/feed.rss", {:title => "Example RSS"}) # => - # - def auto_discovery_link_tag(type = :rss, url_options = {}, tag_options = {}) - tag( - "link", - "rel" => tag_options[:rel] || "alternate", - "type" => tag_options[:type] || Mime::Type.lookup_by_extension(type.to_s).to_s, - "title" => tag_options[:title] || type.to_s.upcase, - "href" => url_options.is_a?(Hash) ? url_for(url_options.merge(:only_path => false)) : url_options - ) - end - - # Computes the path to a javascript asset in the public javascripts directory. - # If the +source+ filename has no extension, .js will be appended. - # Full paths from the document root will be passed through. - # Used internally by javascript_include_tag to build the script path. - # - # ==== Examples - # javascript_path "xmlhr" # => /javascripts/xmlhr.js - # javascript_path "dir/xmlhr.js" # => /javascripts/dir/xmlhr.js - # javascript_path "/dir/xmlhr" # => /dir/xmlhr.js - # javascript_path "http://www.railsapplication.com/js/xmlhr" # => http://www.railsapplication.com/js/xmlhr.js - # javascript_path "http://www.railsapplication.com/js/xmlhr.js" # => http://www.railsapplication.com/js/xmlhr.js - def javascript_path(source) - compute_public_path(source, 'javascripts', 'js') - end - alias_method :path_to_javascript, :javascript_path # aliased to avoid conflicts with a javascript_path named route - - # Returns an html script tag for each of the +sources+ provided. You - # can pass in the filename (.js extension is optional) of javascript files - # that exist in your public/javascripts directory for inclusion into the - # current page or you can pass the full path relative to your document - # root. To include the Prototype and Scriptaculous javascript libraries in - # your application, pass :defaults as the source. When using - # :defaults, if an application.js file exists in your public - # javascripts directory, it will be included as well. You can modify the - # html attributes of the script tag by passing a hash as the last argument. - # - # ==== Examples - # javascript_include_tag "xmlhr" # => - # - # - # javascript_include_tag "xmlhr.js" # => - # - # - # javascript_include_tag "common.javascript", "/elsewhere/cools" # => - # - # - # - # javascript_include_tag "http://www.railsapplication.com/xmlhr" # => - # - # - # javascript_include_tag "http://www.railsapplication.com/xmlhr.js" # => - # - # - # javascript_include_tag :defaults # => - # - # - # ... - # - # - # * = The application.js file is only referenced if it exists - # - # Though it's not really recommended practice, if you need to extend the default JavaScript set for any reason - # (e.g., you're going to be using a certain .js file in every action), then take a look at the register_javascript_include_default method. - # - # You can also include all javascripts in the javascripts directory using :all as the source: - # - # javascript_include_tag :all # => - # - # - # ... - # - # - # - # - # Note that the default javascript files will be included first. So Prototype and Scriptaculous are available to - # all subsequently included files. - # - # If you want Rails to search in all the subdirectories under javascripts, you should explicitly set :recursive: - # - # javascript_include_tag :all, :recursive => true - # - # == Caching multiple javascripts into one - # - # You can also cache multiple javascripts into one file, which requires less HTTP connections to download and can better be - # compressed by gzip (leading to faster transfers). Caching will only happen if ActionController::Base.perform_caching - # is set to true (which is the case by default for the Rails production environment, but not for the development - # environment). - # - # ==== Examples - # javascript_include_tag :all, :cache => true # when ActionController::Base.perform_caching is false => - # - # - # ... - # - # - # - # - # javascript_include_tag :all, :cache => true # when ActionController::Base.perform_caching is true => - # - # - # javascript_include_tag "prototype", "cart", "checkout", :cache => "shop" # when ActionController::Base.perform_caching is false => - # - # - # - # - # javascript_include_tag "prototype", "cart", "checkout", :cache => "shop" # when ActionController::Base.perform_caching is true => - # - # - # The :recursive option is also available for caching: - # - # javascript_include_tag :all, :cache => true, :recursive => true - def javascript_include_tag(*sources) - options = sources.extract_options!.stringify_keys - cache = options.delete("cache") - recursive = options.delete("recursive") - - if ActionController::Base.perform_caching && cache - joined_javascript_name = (cache == true ? "all" : cache) + ".js" - joined_javascript_path = File.join(JAVASCRIPTS_DIR, joined_javascript_name) - - write_asset_file_contents(joined_javascript_path, compute_javascript_paths(sources, recursive)) unless File.exists?(joined_javascript_path) - javascript_src_tag(joined_javascript_name, options) - else - expand_javascript_sources(sources, recursive).collect { |source| javascript_src_tag(source, options) }.join("\n") - end - end - - @@javascript_expansions = { :defaults => JAVASCRIPT_DEFAULT_SOURCES.dup } - - # Register one or more javascript files to be included when symbol - # is passed to javascript_include_tag. This method is typically intended - # to be called from plugin initialization to register javascript files - # that the plugin installed in public/javascripts. - # - # ActionView::Helpers::AssetTagHelper.register_javascript_expansion :monkey => ["head", "body", "tail"] - # - # javascript_include_tag :monkey # => - # - # - # - def self.register_javascript_expansion(expansions) - @@javascript_expansions.merge!(expansions) - end - - @@stylesheet_expansions = {} - - # Register one or more stylesheet files to be included when symbol - # is passed to stylesheet_link_tag. This method is typically intended - # to be called from plugin initialization to register stylesheet files - # that the plugin installed in public/stylesheets. - # - # ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :monkey => ["head", "body", "tail"] - # - # stylesheet_link_tag :monkey # => - # - # - # - def self.register_stylesheet_expansion(expansions) - @@stylesheet_expansions.merge!(expansions) - end - - # Register one or more additional JavaScript files to be included when - # javascript_include_tag :defaults is called. This method is - # typically intended to be called from plugin initialization to register additional - # .js files that the plugin installed in public/javascripts. - def self.register_javascript_include_default(*sources) - @@javascript_expansions[:defaults].concat(sources) - end - - def self.reset_javascript_include_default #:nodoc: - @@javascript_expansions[:defaults] = JAVASCRIPT_DEFAULT_SOURCES.dup - end - - # Computes the path to a stylesheet asset in the public stylesheets directory. - # If the +source+ filename has no extension, .css will be appended. - # Full paths from the document root will be passed through. - # Used internally by +stylesheet_link_tag+ to build the stylesheet path. - # - # ==== Examples - # stylesheet_path "style" # => /stylesheets/style.css - # stylesheet_path "dir/style.css" # => /stylesheets/dir/style.css - # stylesheet_path "/dir/style.css" # => /dir/style.css - # stylesheet_path "http://www.railsapplication.com/css/style" # => http://www.railsapplication.com/css/style.css - # stylesheet_path "http://www.railsapplication.com/css/style.js" # => http://www.railsapplication.com/css/style.css - def stylesheet_path(source) - compute_public_path(source, 'stylesheets', 'css') - end - alias_method :path_to_stylesheet, :stylesheet_path # aliased to avoid conflicts with a stylesheet_path named route - - # Returns a stylesheet link tag for the sources specified as arguments. If - # you don't specify an extension, .css will be appended automatically. - # You can modify the link attributes by passing a hash as the last argument. - # - # ==== Examples - # stylesheet_link_tag "style" # => - # - # - # stylesheet_link_tag "style.css" # => - # - # - # stylesheet_link_tag "http://www.railsapplication.com/style.css" # => - # - # - # stylesheet_link_tag "style", :media => "all" # => - # - # - # stylesheet_link_tag "style", :media => "print" # => - # - # - # stylesheet_link_tag "random.styles", "/css/stylish" # => - # - # - # - # You can also include all styles in the stylesheets directory using :all as the source: - # - # stylesheet_link_tag :all # => - # - # - # - # - # If you want Rails to search in all the subdirectories under stylesheets, you should explicitly set :recursive: - # - # stylesheet_link_tag :all, :recursive => true - # - # == Caching multiple stylesheets into one - # - # You can also cache multiple stylesheets into one file, which requires less HTTP connections and can better be - # compressed by gzip (leading to faster transfers). Caching will only happen if ActionController::Base.perform_caching - # is set to true (which is the case by default for the Rails production environment, but not for the development - # environment). Examples: - # - # ==== Examples - # stylesheet_link_tag :all, :cache => true # when ActionController::Base.perform_caching is false => - # - # - # - # - # stylesheet_link_tag :all, :cache => true # when ActionController::Base.perform_caching is true => - # - # - # stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" # when ActionController::Base.perform_caching is false => - # - # - # - # - # stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" # when ActionController::Base.perform_caching is true => - # - # - # The :recursive option is also available for caching: - # - # stylesheet_link_tag :all, :cache => true, :recursive => true - def stylesheet_link_tag(*sources) - options = sources.extract_options!.stringify_keys - cache = options.delete("cache") - recursive = options.delete("recursive") - - if ActionController::Base.perform_caching && cache - joined_stylesheet_name = (cache == true ? "all" : cache) + ".css" - joined_stylesheet_path = File.join(STYLESHEETS_DIR, joined_stylesheet_name) - - write_asset_file_contents(joined_stylesheet_path, compute_stylesheet_paths(sources, recursive)) unless File.exists?(joined_stylesheet_path) - stylesheet_tag(joined_stylesheet_name, options) - else - expand_stylesheet_sources(sources, recursive).collect { |source| stylesheet_tag(source, options) }.join("\n") - end - end - - # Computes the path to an image asset in the public images directory. - # Full paths from the document root will be passed through. - # Used internally by +image_tag+ to build the image path. - # - # ==== Examples - # image_path("edit") # => /images/edit - # image_path("edit.png") # => /images/edit.png - # image_path("icons/edit.png") # => /images/icons/edit.png - # image_path("/icons/edit.png") # => /icons/edit.png - # image_path("http://www.railsapplication.com/img/edit.png") # => http://www.railsapplication.com/img/edit.png - def image_path(source) - compute_public_path(source, 'images') - end - alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route - - # Returns an html image tag for the +source+. The +source+ can be a full - # path or a file that exists in your public images directory. - # - # ==== Options - # You can add HTML attributes using the +options+. The +options+ supports - # three additional keys for convenience and conformance: - # - # * :alt - If no alt text is given, the file name part of the - # +source+ is used (capitalized and without the extension) - # * :size - Supplied as "{Width}x{Height}", so "30x45" becomes - # width="30" and height="45". :size will be ignored if the - # value is not in the correct format. - # * :mouseover - Set an alternate image to be used when the onmouseover - # event is fired, and sets the original image to be replaced onmouseout. - # This can be used to implement an easy image toggle that fires on onmouseover. - # - # ==== Examples - # image_tag("icon") # => - # Icon - # image_tag("icon.png") # => - # Icon - # image_tag("icon.png", :size => "16x10", :alt => "Edit Entry") # => - # Edit Entry - # image_tag("/icons/icon.gif", :size => "16x16") # => - # Icon - # image_tag("/icons/icon.gif", :height => '32', :width => '32') # => - # Icon - # image_tag("/icons/icon.gif", :class => "menu_icon") # => - # Icon - # image_tag("mouse.png", :mouseover => "/images/mouse_over.png") # => - # Mouse - # image_tag("mouse.png", :mouseover => image_path("mouse_over.png")) # => - # Mouse - def image_tag(source, options = {}) - options.symbolize_keys! - - options[:src] = path_to_image(source) - options[:alt] ||= File.basename(options[:src], '.*').split('.').first.to_s.capitalize - - if size = options.delete(:size) - options[:width], options[:height] = size.split("x") if size =~ %r{^\d+x\d+$} - end - - if mouseover = options.delete(:mouseover) - options[:onmouseover] = "this.src='#{image_path(mouseover)}'" - options[:onmouseout] = "this.src='#{image_path(options[:src])}'" - end - - tag("img", options) - end - - def self.cache_asset_timestamps - @@cache_asset_timestamps - end - - # You can enable or disable the asset tag timestamps cache. - # With the cache enabled, the asset tag helper methods will make fewer - # expense file system calls. However this prevents you from modifying - # any asset files while the server is running. - # - # ActionView::Helpers::AssetTagHelper.cache_asset_timestamps = false - def self.cache_asset_timestamps=(value) - @@cache_asset_timestamps = value - end - - @@cache_asset_timestamps = true - - private - # Add the the extension +ext+ if not present. Return full URLs otherwise untouched. - # Prefix with /dir/ if lacking a leading +/+. Account for relative URL - # roots. Rewrite the asset path for cache-busting asset ids. Include - # asset host, if configured, with the correct request protocol. - def compute_public_path(source, dir, ext = nil, include_host = true) - has_request = @controller.respond_to?(:request) - - source_ext = File.extname(source)[1..-1] - if ext && (source_ext.blank? || (ext != source_ext && File.exist?(File.join(ASSETS_DIR, dir, "#{source}.#{ext}")))) - source += ".#{ext}" - end - - unless source =~ %r{^[-a-z]+://} - source = "/#{dir}/#{source}" unless source[0] == ?/ - - source = rewrite_asset_path(source) - - if has_request && include_host - unless source =~ %r{^#{ActionController::Base.relative_url_root}/} - source = "#{ActionController::Base.relative_url_root}#{source}" - end - end - end - - if include_host && source !~ %r{^[-a-z]+://} - host = compute_asset_host(source) - - if has_request && !host.blank? && host !~ %r{^[-a-z]+://} - host = "#{@controller.request.protocol}#{host}" - end - - "#{host}#{source}" - else - source - end - end - - # Pick an asset host for this source. Returns +nil+ if no host is set, - # the host if no wildcard is set, the host interpolated with the - # numbers 0-3 if it contains %d (the number is the source hash mod 4), - # or the value returned from invoking the proc if it's a proc or the value from - # invoking call if it's an object responding to call. - def compute_asset_host(source) - if host = ActionController::Base.asset_host - if host.is_a?(Proc) || host.respond_to?(:call) - case host.is_a?(Proc) ? host.arity : host.method(:call).arity - when 2 - request = @controller.respond_to?(:request) && @controller.request - host.call(source, request) - else - host.call(source) - end - else - (host =~ /%d/) ? host % (source.hash % 4) : host - end - end - end - - @@asset_timestamps_cache = {} - @@asset_timestamps_cache_guard = Mutex.new - - # Use the RAILS_ASSET_ID environment variable or the source's - # modification time as its cache-busting asset id. - def rails_asset_id(source) - if asset_id = ENV["RAILS_ASSET_ID"] - asset_id - else - if @@cache_asset_timestamps && (asset_id = @@asset_timestamps_cache[source]) - asset_id - else - path = File.join(ASSETS_DIR, source) - asset_id = File.exist?(path) ? File.mtime(path).to_i.to_s : '' - - if @@cache_asset_timestamps - @@asset_timestamps_cache_guard.synchronize do - @@asset_timestamps_cache[source] = asset_id - end - end - - asset_id - end - end - end - - # Break out the asset path rewrite in case plugins wish to put the asset id - # someplace other than the query string. - def rewrite_asset_path(source) - asset_id = rails_asset_id(source) - if asset_id.blank? - source - else - source + "?#{asset_id}" - end - end - - def javascript_src_tag(source, options) - content_tag("script", "", { "type" => Mime::JS, "src" => path_to_javascript(source) }.merge(options)) - end - - def stylesheet_tag(source, options) - tag("link", { "rel" => "stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => html_escape(path_to_stylesheet(source)) }.merge(options), false, false) - end - - def compute_javascript_paths(*args) - expand_javascript_sources(*args).collect { |source| compute_public_path(source, 'javascripts', 'js', false) } - end - - def compute_stylesheet_paths(*args) - expand_stylesheet_sources(*args).collect { |source| compute_public_path(source, 'stylesheets', 'css', false) } - end - - def expand_javascript_sources(sources, recursive = false) - if sources.include?(:all) - all_javascript_files = collect_asset_files(JAVASCRIPTS_DIR, ('**' if recursive), '*.js') - ((determine_source(:defaults, @@javascript_expansions).dup & all_javascript_files) + all_javascript_files).uniq - else - expanded_sources = sources.collect do |source| - determine_source(source, @@javascript_expansions) - end.flatten - expanded_sources << "application" if sources.include?(:defaults) && File.exist?(File.join(JAVASCRIPTS_DIR, "application.js")) - expanded_sources - end - end - - def expand_stylesheet_sources(sources, recursive) - if sources.first == :all - collect_asset_files(STYLESHEETS_DIR, ('**' if recursive), '*.css') - else - sources.collect do |source| - determine_source(source, @@stylesheet_expansions) - end.flatten - end - end - - def determine_source(source, collection) - case source - when Symbol - collection[source] || raise(ArgumentError, "No expansion found for #{source.inspect}") - else - source - end - end - - def join_asset_file_contents(paths) - paths.collect { |path| File.read(asset_file_path(path)) }.join("\n\n") - end - - def write_asset_file_contents(joined_asset_path, asset_paths) - FileUtils.mkdir_p(File.dirname(joined_asset_path)) - File.open(joined_asset_path, "w+") { |cache| cache.write(join_asset_file_contents(asset_paths)) } - - # Set mtime to the latest of the combined files to allow for - # consistent ETag without a shared filesystem. - mt = asset_paths.map { |p| File.mtime(asset_file_path(p)) }.max - File.utime(mt, mt, joined_asset_path) - end - - def asset_file_path(path) - File.join(ASSETS_DIR, path.split('?').first) - end - - def collect_asset_files(*path) - dir = path.first - - Dir[File.join(*path.compact)].collect do |file| - file[-(file.size - dir.size - 1)..-1].sub(/\.\w+$/, '') - end.sort - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb b/vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb deleted file mode 100644 index dc44975..0000000 --- a/vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb +++ /dev/null @@ -1,198 +0,0 @@ -require 'set' - -# Adds easy defaults to writing Atom feeds with the Builder template engine (this does not work on ERb or any other -# template languages). -module ActionView - module Helpers #:nodoc: - module AtomFeedHelper - # Full usage example: - # - # config/routes.rb: - # ActionController::Routing::Routes.draw do |map| - # map.resources :posts - # map.root :controller => "posts" - # end - # - # app/controllers/posts_controller.rb: - # class PostsController < ApplicationController::Base - # # GET /posts.html - # # GET /posts.atom - # def index - # @posts = Post.find(:all) - # - # respond_to do |format| - # format.html - # format.atom - # end - # end - # end - # - # app/views/posts/index.atom.builder: - # atom_feed do |feed| - # feed.title("My great blog!") - # feed.updated(@posts.first.created_at) - # - # for post in @posts - # feed.entry(post) do |entry| - # entry.title(post.title) - # entry.content(post.body, :type => 'html') - # - # entry.author do |author| - # author.name("DHH") - # end - # end - # end - # end - # - # The options for atom_feed are: - # - # * :language: Defaults to "en-US". - # * :root_url: The HTML alternative that this feed is doubling for. Defaults to / on the current host. - # * :url: The URL for this feed. Defaults to the current URL. - # * :id: The id for this feed. Defaults to "tag:#{request.host},#{options[:schema_date]}:#{request.request_uri.split(".")[0]}" - # * :schema_date: The date at which the tag scheme for the feed was first used. A good default is the year you - # created the feed. See http://feedvalidator.org/docs/error/InvalidTAG.html for more information. If not specified, - # 2005 is used (as an "I don't care" value). - # * :instruct: Hash of XML processing instructions in the form {target => {attribute => value, }} or {target => [{attribute => value, }, ]} - # - # Other namespaces can be added to the root element: - # - # app/views/posts/index.atom.builder: - # atom_feed({'xmlns:app' => 'http://www.w3.org/2007/app', - # 'xmlns:openSearch' => 'http://a9.com/-/spec/opensearch/1.1/'}) do |feed| - # feed.title("My great blog!") - # feed.updated((@posts.first.created_at)) - # feed.tag!(openSearch:totalResults, 10) - # - # for post in @posts - # feed.entry(post) do |entry| - # entry.title(post.title) - # entry.content(post.body, :type => 'html') - # entry.tag!('app:edited', Time.now) - # - # entry.author do |author| - # author.name("DHH") - # end - # end - # end - # end - # - # The Atom spec defines five elements (content rights title subtitle - # summary) which may directly contain xhtml content if :type => 'xhtml' - # is specified as an attribute. If so, this helper will take care of - # the enclosing div and xhtml namespace declaration. Example usage: - # - # entry.summary :type => 'xhtml' do |xhtml| - # xhtml.p pluralize(order.line_items.count, "line item") - # xhtml.p "Shipped to #{order.address}" - # xhtml.p "Paid by #{order.pay_type}" - # end - # - # - # atom_feed yields an AtomFeedBuilder instance. Nested elements yield - # an AtomBuilder instance. - def atom_feed(options = {}, &block) - if options[:schema_date] - options[:schema_date] = options[:schema_date].strftime("%Y-%m-%d") if options[:schema_date].respond_to?(:strftime) - else - options[:schema_date] = "2005" # The Atom spec copyright date - end - - xml = options[:xml] || eval("xml", block.binding) - xml.instruct! - if options[:instruct] - options[:instruct].each do |target,attrs| - if attrs.respond_to?(:keys) - xml.instruct!(target, attrs) - elsif attrs.respond_to?(:each) - attrs.each { |attr_group| xml.instruct!(target, attr_group) } - end - end - end - - feed_opts = {"xml:lang" => options[:language] || "en-US", "xmlns" => 'http://www.w3.org/2005/Atom'} - feed_opts.merge!(options).reject!{|k,v| !k.to_s.match(/^xml/)} - - xml.feed(feed_opts) do - xml.id(options[:id] || "tag:#{request.host},#{options[:schema_date]}:#{request.request_uri.split(".")[0]}") - xml.link(:rel => 'alternate', :type => 'text/html', :href => options[:root_url] || (request.protocol + request.host_with_port)) - xml.link(:rel => 'self', :type => 'application/atom+xml', :href => options[:url] || request.url) - - yield AtomFeedBuilder.new(xml, self, options) - end - end - - class AtomBuilder - XHTML_TAG_NAMES = %w(content rights title subtitle summary).to_set - - def initialize(xml) - @xml = xml - end - - private - # Delegate to xml builder, first wrapping the element in a xhtml - # namespaced div element if the method and arguments indicate - # that an xhtml_block? is desired. - def method_missing(method, *arguments, &block) - if xhtml_block?(method, arguments) - @xml.__send__(method, *arguments) do - @xml.div(:xmlns => 'http://www.w3.org/1999/xhtml') do |xhtml| - block.call(xhtml) - end - end - else - @xml.__send__(method, *arguments, &block) - end - end - - # True if the method name matches one of the five elements defined - # in the Atom spec as potentially containing XHTML content and - # if :type => 'xhtml' is, in fact, specified. - def xhtml_block?(method, arguments) - if XHTML_TAG_NAMES.include?(method.to_s) - last = arguments.last - last.is_a?(Hash) && last[:type].to_s == 'xhtml' - end - end - end - - class AtomFeedBuilder < AtomBuilder - def initialize(xml, view, feed_options = {}) - @xml, @view, @feed_options = xml, view, feed_options - end - - # Accepts a Date or Time object and inserts it in the proper format. If nil is passed, current time in UTC is used. - def updated(date_or_time = nil) - @xml.updated((date_or_time || Time.now.utc).xmlschema) - end - - # Creates an entry tag for a specific record and prefills the id using class and id. - # - # Options: - # - # * :published: Time first published. Defaults to the created_at attribute on the record if one such exists. - # * :updated: Time of update. Defaults to the updated_at attribute on the record if one such exists. - # * :url: The URL for this entry. Defaults to the polymorphic_url for the record. - # * :id: The ID for this entry. Defaults to "tag:#{@view.request.host},#{@feed_options[:schema_date]}:#{record.class}/#{record.id}" - def entry(record, options = {}) - @xml.entry do - @xml.id(options[:id] || "tag:#{@view.request.host},#{@feed_options[:schema_date]}:#{record.class}/#{record.id}") - - if options[:published] || (record.respond_to?(:created_at) && record.created_at) - @xml.published((options[:published] || record.created_at).xmlschema) - end - - if options[:updated] || (record.respond_to?(:updated_at) && record.updated_at) - @xml.updated((options[:updated] || record.updated_at).xmlschema) - end - - @xml.link(:rel => 'alternate', :type => 'text/html', :href => options[:url] || @view.polymorphic_url(record)) - - yield AtomBuilder.new(@xml) - end - end - end - - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/helpers/benchmark_helper.rb b/vendor/rails/actionpack/lib/action_view/helpers/benchmark_helper.rb deleted file mode 100644 index 61c2cec..0000000 --- a/vendor/rails/actionpack/lib/action_view/helpers/benchmark_helper.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'benchmark' - -module ActionView - module Helpers - # This helper offers a method to measure the execution time of a block - # in a template. - module BenchmarkHelper - # Allows you to measure the execution time of a block - # in a template and records the result to the log. Wrap this block around - # expensive operations or possible bottlenecks to get a time reading - # for the operation. For example, let's say you thought your file - # processing method was taking too long; you could wrap it in a benchmark block. - # - # <% benchmark "Process data files" do %> - # <%= expensive_files_operation %> - # <% end %> - # - # That would add something like "Process data files (345.2ms)" to the log, - # which you can then use to compare timings when optimizing your code. - # - # You may give an optional logger level as the :level option. - # (:debug, :info, :warn, :error); the default value is :info. - # - # <% benchmark "Low-level files", :level => :debug do %> - # <%= lowlevel_files_operation %> - # <% end %> - # - # Finally, you can pass true as the third argument to silence all log activity - # inside the block. This is great for boiling down a noisy block to just a single statement: - # - # <% benchmark "Process data files", :level => :info, :silence => true do %> - # <%= expensive_and_chatty_files_operation %> - # <% end %> - def benchmark(message = "Benchmarking", options = {}) - if controller.logger - if options.is_a?(Symbol) - ActiveSupport::Deprecation.warn("use benchmark('#{message}', :level => :#{options}) instead", caller) - options = { :level => options, :silence => false } - else - options.assert_valid_keys(:level, :silence) - options[:level] ||= :info - end - - result = nil - ms = Benchmark.ms { result = options[:silence] ? controller.logger.silence { yield } : yield } - controller.logger.send(options[:level], '%s (%.1fms)' % [ message, ms ]) - result - else - yield - end - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/helpers/cache_helper.rb b/vendor/rails/actionpack/lib/action_view/helpers/cache_helper.rb deleted file mode 100644 index 64d1ad2..0000000 --- a/vendor/rails/actionpack/lib/action_view/helpers/cache_helper.rb +++ /dev/null @@ -1,39 +0,0 @@ -module ActionView - module Helpers - # This helper to exposes a method for caching of view fragments. - # See ActionController::Caching::Fragments for usage instructions. - module CacheHelper - # A method for caching fragments of a view rather than an entire - # action or page. This technique is useful caching pieces like - # menus, lists of news topics, static HTML fragments, and so on. - # This method takes a block that contains the content you wish - # to cache. See ActionController::Caching::Fragments for more - # information. - # - # ==== Examples - # If you wanted to cache a navigation menu, you could do the - # following. - # - # <% cache do %> - # <%= render :partial => "menu" %> - # <% end %> - # - # You can also cache static content... - # - # <% cache do %> - #

    Hello users! Welcome to our website!

    - # <% end %> - # - # ...and static content mixed with RHTML content. - # - # <% cache do %> - # Topics: - # <%= render :partial => "topics", :collection => @topic_list %> - # Topics listed alphabetically - # <% end %> - def cache(name = {}, options = nil, &block) - @controller.fragment_for(output_buffer, name, options, &block) - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb b/vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb deleted file mode 100644 index e86ca27..0000000 --- a/vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb +++ /dev/null @@ -1,136 +0,0 @@ -module ActionView - module Helpers - # CaptureHelper exposes methods to let you extract generated markup which - # can be used in other parts of a template or layout file. - # It provides a method to capture blocks into variables through capture and - # a way to capture a block of markup for use in a layout through content_for. - module CaptureHelper - # The capture method allows you to extract part of a template into a - # variable. You can then use this variable anywhere in your templates or layout. - # - # ==== Examples - # The capture method can be used in ERb templates... - # - # <% @greeting = capture do %> - # Welcome to my shiny new web page! The date and time is - # <%= Time.now %> - # <% end %> - # - # ...and Builder (RXML) templates. - # - # @timestamp = capture do - # "The current timestamp is #{Time.now}." - # end - # - # You can then use that variable anywhere else. For example: - # - # - # <%= @greeting %> - # - # <%= @greeting %> - # - # - def capture(*args, &block) - # Return captured buffer in erb. - if block_called_from_erb?(block) - with_output_buffer { block.call(*args) } - else - # Return block result otherwise, but protect buffer also. - with_output_buffer { return block.call(*args) } - end - end - - # Calling content_for stores a block of markup in an identifier for later use. - # You can make subsequent calls to the stored content in other templates or the layout - # by passing the identifier as an argument to yield. - # - # ==== Examples - # - # <% content_for :not_authorized do %> - # alert('You are not authorized to do that!') - # <% end %> - # - # You can then use yield :not_authorized anywhere in your templates. - # - # <%= yield :not_authorized if current_user.nil? %> - # - # You can also use this syntax alongside an existing call to yield in a layout. For example: - # - # <%# This is the layout %> - # - # - # My Website - # <%= yield :script %> - # - # - # <%= yield %> - # - # - # - # And now, we'll create a view that has a content_for call that - # creates the script identifier. - # - # <%# This is our view %> - # Please login! - # - # <% content_for :script do %> - # - # <% end %> - # - # Then, in another view, you could to do something like this: - # - # <%= link_to_remote 'Logout', :action => 'logout' %> - # - # <% content_for :script do %> - # <%= javascript_include_tag :defaults %> - # <% end %> - # - # That will place - # - # +html_options+ may be a hash of attributes for the - # - # Instead of passing the content as an argument, you can also use a block - # in which case, you pass your +html_options+ as the first parameter. - # <% javascript_tag :defer => 'defer' do -%> - # alert('All is good') - # <% end -%> - def javascript_tag(content_or_options_with_block = nil, html_options = {}, &block) - content = - if block_given? - html_options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash) - capture(&block) - else - content_or_options_with_block - end - - tag = content_tag(:script, javascript_cdata_section(content), html_options.merge(:type => Mime::JS)) - - if block_called_from_erb?(block) - concat(tag) - else - tag - end - end - - def javascript_cdata_section(content) #:nodoc: - "\n//#{cdata_section("\n#{content}\n//")}\n" - end - - protected - def options_for_javascript(options) - if options.empty? - '{}' - else - "{#{options.keys.map { |k| "#{k}:#{options[k]}" }.sort.join(', ')}}" - end - end - - def array_or_string_for_javascript(option) - if option.kind_of?(Array) - "['#{option.join('\',\'')}']" - elsif !option.nil? - "'#{option}'" - end - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb b/vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb deleted file mode 100644 index 539f43c..0000000 --- a/vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb +++ /dev/null @@ -1,303 +0,0 @@ -module ActionView - module Helpers #:nodoc: - # Provides methods for converting numbers into formatted strings. - # Methods are provided for phone numbers, currency, percentage, - # precision, positional notation, and file size. - module NumberHelper - # Formats a +number+ into a US phone number (e.g., (555) 123-9876). You can customize the format - # in the +options+ hash. - # - # ==== Options - # * :area_code - Adds parentheses around the area code. - # * :delimiter - Specifies the delimiter to use (defaults to "-"). - # * :extension - Specifies an extension to add to the end of the - # generated number. - # * :country_code - Sets the country code for the phone number. - # - # ==== Examples - # number_to_phone(5551234) # => 555-1234 - # number_to_phone(1235551234) # => 123-555-1234 - # number_to_phone(1235551234, :area_code => true) # => (123) 555-1234 - # number_to_phone(1235551234, :delimiter => " ") # => 123 555 1234 - # number_to_phone(1235551234, :area_code => true, :extension => 555) # => (123) 555-1234 x 555 - # number_to_phone(1235551234, :country_code => 1) # => +1-123-555-1234 - # - # number_to_phone(1235551234, :country_code => 1, :extension => 1343, :delimiter => ".") - # => +1.123.555.1234 x 1343 - def number_to_phone(number, options = {}) - number = number.to_s.strip unless number.nil? - options = options.symbolize_keys - area_code = options[:area_code] || nil - delimiter = options[:delimiter] || "-" - extension = options[:extension].to_s.strip || nil - country_code = options[:country_code] || nil - - begin - str = "" - str << "+#{country_code}#{delimiter}" unless country_code.blank? - str << if area_code - number.gsub!(/([0-9]{1,3})([0-9]{3})([0-9]{4}$)/,"(\\1) \\2#{delimiter}\\3") - else - number.gsub!(/([0-9]{0,3})([0-9]{3})([0-9]{4})$/,"\\1#{delimiter}\\2#{delimiter}\\3") - number.starts_with?('-') ? number.slice!(1..-1) : number - end - str << " x #{extension}" unless extension.blank? - str - rescue - number - end - end - - # Formats a +number+ into a currency string (e.g., $13.65). You can customize the format - # in the +options+ hash. - # - # ==== Options - # * :precision - Sets the level of precision (defaults to 2). - # * :unit - Sets the denomination of the currency (defaults to "$"). - # * :separator - Sets the separator between the units (defaults to "."). - # * :delimiter - Sets the thousands delimiter (defaults to ","). - # * :format - Sets the format of the output string (defaults to "%u%n"). The field types are: - # - # %u The currency unit - # %n The number - # - # ==== Examples - # number_to_currency(1234567890.50) # => $1,234,567,890.50 - # number_to_currency(1234567890.506) # => $1,234,567,890.51 - # number_to_currency(1234567890.506, :precision => 3) # => $1,234,567,890.506 - # - # number_to_currency(1234567890.50, :unit => "£", :separator => ",", :delimiter => "") - # # => £1234567890,50 - # number_to_currency(1234567890.50, :unit => "£", :separator => ",", :delimiter => "", :format => "%n %u") - # # => 1234567890,50 £ - def number_to_currency(number, options = {}) - options.symbolize_keys! - - defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {} - currency = I18n.translate(:'number.currency.format', :locale => options[:locale], :raise => true) rescue {} - defaults = defaults.merge(currency) - - precision = options[:precision] || defaults[:precision] - unit = options[:unit] || defaults[:unit] - separator = options[:separator] || defaults[:separator] - delimiter = options[:delimiter] || defaults[:delimiter] - format = options[:format] || defaults[:format] - separator = '' if precision == 0 - - begin - format.gsub(/%n/, number_with_precision(number, - :precision => precision, - :delimiter => delimiter, - :separator => separator) - ).gsub(/%u/, unit) - rescue - number - end - end - - # Formats a +number+ as a percentage string (e.g., 65%). You can customize the - # format in the +options+ hash. - # - # ==== Options - # * :precision - Sets the level of precision (defaults to 3). - # * :separator - Sets the separator between the units (defaults to "."). - # * :delimiter - Sets the thousands delimiter (defaults to ""). - # - # ==== Examples - # number_to_percentage(100) # => 100.000% - # number_to_percentage(100, :precision => 0) # => 100% - # number_to_percentage(1000, :delimiter => '.', :separator => ',') # => 1.000,000% - # number_to_percentage(302.24398923423, :precision => 5) # => 302.24399% - def number_to_percentage(number, options = {}) - options.symbolize_keys! - - defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {} - percentage = I18n.translate(:'number.percentage.format', :locale => options[:locale], :raise => true) rescue {} - defaults = defaults.merge(percentage) - - precision = options[:precision] || defaults[:precision] - separator = options[:separator] || defaults[:separator] - delimiter = options[:delimiter] || defaults[:delimiter] - - begin - number_with_precision(number, - :precision => precision, - :separator => separator, - :delimiter => delimiter) + "%" - rescue - number - end - end - - # Formats a +number+ with grouped thousands using +delimiter+ (e.g., 12,324). You can - # customize the format in the +options+ hash. - # - # ==== Options - # * :delimiter - Sets the thousands delimiter (defaults to ","). - # * :separator - Sets the separator between the units (defaults to "."). - # - # ==== Examples - # number_with_delimiter(12345678) # => 12,345,678 - # number_with_delimiter(12345678.05) # => 12,345,678.05 - # number_with_delimiter(12345678, :delimiter => ".") # => 12.345.678 - # number_with_delimiter(12345678, :seperator => ",") # => 12,345,678 - # number_with_delimiter(98765432.98, :delimiter => " ", :separator => ",") - # # => 98 765 432,98 - # - # You can still use number_with_delimiter with the old API that accepts the - # +delimiter+ as its optional second and the +separator+ as its - # optional third parameter: - # number_with_delimiter(12345678, " ") # => 12 345.678 - # number_with_delimiter(12345678.05, ".", ",") # => 12.345.678,05 - def number_with_delimiter(number, *args) - options = args.extract_options! - options.symbolize_keys! - - defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {} - - unless args.empty? - ActiveSupport::Deprecation.warn('number_with_delimiter takes an option hash ' + - 'instead of separate delimiter and precision arguments.', caller) - delimiter = args[0] || defaults[:delimiter] - separator = args[1] || defaults[:separator] - end - - delimiter ||= (options[:delimiter] || defaults[:delimiter]) - separator ||= (options[:separator] || defaults[:separator]) - - begin - parts = number.to_s.split('.') - parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}") - parts.join(separator) - rescue - number - end - end - - # Formats a +number+ with the specified level of :precision (e.g., 112.32 has a precision of 2). - # You can customize the format in the +options+ hash. - # - # ==== Options - # * :precision - Sets the level of precision (defaults to 3). - # * :separator - Sets the separator between the units (defaults to "."). - # * :delimiter - Sets the thousands delimiter (defaults to ""). - # - # ==== Examples - # number_with_precision(111.2345) # => 111.235 - # number_with_precision(111.2345, :precision => 2) # => 111.23 - # number_with_precision(13, :precision => 5) # => 13.00000 - # number_with_precision(389.32314, :precision => 0) # => 389 - # number_with_precision(1111.2345, :precision => 2, :separator => ',', :delimiter => '.') - # # => 1.111,23 - # - # You can still use number_with_precision with the old API that accepts the - # +precision+ as its optional second parameter: - # number_with_precision(number_with_precision(111.2345, 2) # => 111.23 - def number_with_precision(number, *args) - options = args.extract_options! - options.symbolize_keys! - - defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {} - precision_defaults = I18n.translate(:'number.precision.format', :locale => options[:locale], - :raise => true) rescue {} - defaults = defaults.merge(precision_defaults) - - unless args.empty? - ActiveSupport::Deprecation.warn('number_with_precision takes an option hash ' + - 'instead of a separate precision argument.', caller) - precision = args[0] || defaults[:precision] - end - - precision ||= (options[:precision] || defaults[:precision]) - separator ||= (options[:separator] || defaults[:separator]) - delimiter ||= (options[:delimiter] || defaults[:delimiter]) - - begin - rounded_number = (Float(number) * (10 ** precision)).round.to_f / 10 ** precision - number_with_delimiter("%01.#{precision}f" % rounded_number, - :separator => separator, - :delimiter => delimiter) - rescue - number - end - end - - STORAGE_UNITS = [:byte, :kb, :mb, :gb, :tb].freeze - - # Formats the bytes in +size+ into a more understandable representation - # (e.g., giving it 1500 yields 1.5 KB). This method is useful for - # reporting file sizes to users. This method returns nil if - # +size+ cannot be converted into a number. You can customize the - # format in the +options+ hash. - # - # ==== Options - # * :precision - Sets the level of precision (defaults to 1). - # * :separator - Sets the separator between the units (defaults to "."). - # * :delimiter - Sets the thousands delimiter (defaults to ""). - # - # ==== Examples - # number_to_human_size(123) # => 123 Bytes - # number_to_human_size(1234) # => 1.2 KB - # number_to_human_size(12345) # => 12.1 KB - # number_to_human_size(1234567) # => 1.2 MB - # number_to_human_size(1234567890) # => 1.1 GB - # number_to_human_size(1234567890123) # => 1.1 TB - # number_to_human_size(1234567, :precision => 2) # => 1.18 MB - # number_to_human_size(483989, :precision => 0) # => 473 KB - # number_to_human_size(1234567, :precision => 2, :separator => ',') # => 1,18 MB - # - # You can still use number_to_human_size with the old API that accepts the - # +precision+ as its optional second parameter: - # number_to_human_size(1234567, 2) # => 1.18 MB - # number_to_human_size(483989, 0) # => 473 KB - def number_to_human_size(number, *args) - return nil if number.nil? - - options = args.extract_options! - options.symbolize_keys! - - defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {} - human = I18n.translate(:'number.human.format', :locale => options[:locale], :raise => true) rescue {} - defaults = defaults.merge(human) - - unless args.empty? - ActiveSupport::Deprecation.warn('number_to_human_size takes an option hash ' + - 'instead of a separate precision argument.', caller) - precision = args[0] || defaults[:precision] - end - - precision ||= (options[:precision] || defaults[:precision]) - separator ||= (options[:separator] || defaults[:separator]) - delimiter ||= (options[:delimiter] || defaults[:delimiter]) - - storage_units_format = I18n.translate(:'number.human.storage_units.format', :locale => options[:locale], :raise => true) - - if number.to_i < 1024 - unit = I18n.translate(:'number.human.storage_units.units.byte', :locale => options[:locale], :count => number.to_i, :raise => true) - storage_units_format.gsub(/%n/, number.to_i.to_s).gsub(/%u/, unit) - else - max_exp = STORAGE_UNITS.size - 1 - number = Float(number) - exponent = (Math.log(number) / Math.log(1024)).to_i # Convert to base 1024 - exponent = max_exp if exponent > max_exp # we need this to avoid overflow for the highest unit - number /= 1024 ** exponent - - unit_key = STORAGE_UNITS[exponent] - unit = I18n.translate(:"number.human.storage_units.units.#{unit_key}", :locale => options[:locale], :count => number, :raise => true) - - begin - escaped_separator = Regexp.escape(separator) - formatted_number = number_with_precision(number, - :precision => precision, - :separator => separator, - :delimiter => delimiter - ).sub(/(\d)(#{escaped_separator}[1-9]*)?0+\z/, '\1\2').sub(/#{escaped_separator}\z/, '') - storage_units_format.gsub(/%n/, formatted_number).gsub(/%u/, unit) - rescue - number - end - end - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb b/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb deleted file mode 100644 index 91ef72e..0000000 --- a/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb +++ /dev/null @@ -1,1305 +0,0 @@ -require 'set' -require 'active_support/json' - -module ActionView - module Helpers - # Prototype[http://www.prototypejs.org/] is a JavaScript library that provides - # DOM[http://en.wikipedia.org/wiki/Document_Object_Model] manipulation, - # Ajax[http://www.adaptivepath.com/publications/essays/archives/000385.php] - # functionality, and more traditional object-oriented facilities for JavaScript. - # This module provides a set of helpers to make it more convenient to call - # functions from Prototype using Rails, including functionality to call remote - # Rails methods (that is, making a background request to a Rails action) using Ajax. - # This means that you can call actions in your controllers without - # reloading the page, but still update certain parts of it using - # injections into the DOM. A common use case is having a form that adds - # a new element to a list without reloading the page or updating a shopping - # cart total when a new item is added. - # - # == Usage - # To be able to use these helpers, you must first include the Prototype - # JavaScript framework in your pages. - # - # javascript_include_tag 'prototype' - # - # (See the documentation for - # ActionView::Helpers::JavaScriptHelper for more information on including - # this and other JavaScript files in your Rails templates.) - # - # Now you're ready to call a remote action either through a link... - # - # link_to_remote "Add to cart", - # :url => { :action => "add", :id => product.id }, - # :update => { :success => "cart", :failure => "error" } - # - # ...through a form... - # - # <% form_remote_tag :url => '/shipping' do -%> - #
    <%= submit_tag 'Recalculate Shipping' %>
    - # <% end -%> - # - # ...periodically... - # - # periodically_call_remote(:url => 'update', :frequency => '5', :update => 'ticker') - # - # ...or through an observer (i.e., a form or field that is observed and calls a remote - # action when changed). - # - # <%= observe_field(:searchbox, - # :url => { :action => :live_search }), - # :frequency => 0.5, - # :update => :hits, - # :with => 'query' - # %> - # - # As you can see, there are numerous ways to use Prototype's Ajax functions (and actually more than - # are listed here); check out the documentation for each method to find out more about its usage and options. - # - # === Common Options - # See link_to_remote for documentation of options common to all Ajax - # helpers; any of the options specified by link_to_remote can be used - # by the other helpers. - # - # == Designing your Rails actions for Ajax - # When building your action handlers (that is, the Rails actions that receive your background requests), it's - # important to remember a few things. First, whatever your action would normally return to the browser, it will - # return to the Ajax call. As such, you typically don't want to render with a layout. This call will cause - # the layout to be transmitted back to your page, and, if you have a full HTML/CSS, will likely mess a lot of things up. - # You can turn the layout off on particular actions by doing the following: - # - # class SiteController < ActionController::Base - # layout "standard", :except => [:ajax_method, :more_ajax, :another_ajax] - # end - # - # Optionally, you could do this in the method you wish to lack a layout: - # - # render :layout => false - # - # You can tell the type of request from within your action using the request.xhr? (XmlHttpRequest, the - # method that Ajax uses to make background requests) method. - # def name - # # Is this an XmlHttpRequest request? - # if (request.xhr?) - # render :text => @name.to_s - # else - # # No? Then render an action. - # render :action => 'view_attribute', :attr => @name - # end - # end - # - # The else clause can be left off and the current action will render with full layout and template. An extension - # to this solution was posted to Ryan Heneise's blog at ArtOfMission["http://www.artofmission.com/"]. - # - # layout proc{ |c| c.request.xhr? ? false : "application" } - # - # Dropping this in your ApplicationController turns the layout off for every request that is an "xhr" request. - # - # If you are just returning a little data or don't want to build a template for your output, you may opt to simply - # render text output, like this: - # - # render :text => 'Return this from my method!' - # - # Since whatever the method returns is injected into the DOM, this will simply inject some text (or HTML, if you - # tell it to). This is usually how small updates, such updating a cart total or a file count, are handled. - # - # == Updating multiple elements - # See JavaScriptGenerator for information on updating multiple elements - # on the page in an Ajax response. - module PrototypeHelper - unless const_defined? :CALLBACKS - CALLBACKS = Set.new([ :create, :uninitialized, :loading, :loaded, - :interactive, :complete, :failure, :success ] + - (100..599).to_a) - AJAX_OPTIONS = Set.new([ :before, :after, :condition, :url, - :asynchronous, :method, :insertion, :position, - :form, :with, :update, :script, :type ]).merge(CALLBACKS) - end - - # Returns a link to a remote action defined by options[:url] - # (using the url_for format) that's called in the background using - # XMLHttpRequest. The result of that request can then be inserted into a - # DOM object whose id can be specified with options[:update]. - # Usually, the result would be a partial prepared by the controller with - # render :partial. - # - # Examples: - # # Generates: Delete this post - # link_to_remote "Delete this post", :update => "posts", - # :url => { :action => "destroy", :id => post.id } - # - # # Generates: Refresh - # link_to_remote(image_tag("refresh"), :update => "emails", - # :url => { :action => "list_emails" }) - # - # You can override the generated HTML options by specifying a hash in - # options[:html]. - # - # link_to_remote "Delete this post", :update => "posts", - # :url => post_url(@post), :method => :delete, - # :html => { :class => "destructive" } - # - # You can also specify a hash for options[:update] to allow for - # easy redirection of output to an other DOM element if a server-side - # error occurs: - # - # Example: - # # Generates: Delete this post - # link_to_remote "Delete this post", - # :url => { :action => "destroy", :id => post.id }, - # :update => { :success => "posts", :failure => "error" } - # - # Optionally, you can use the options[:position] parameter to - # influence how the target DOM element is updated. It must be one of - # :before, :top, :bottom, or :after. - # - # The method used is by default POST. You can also specify GET or you - # can simulate PUT or DELETE over POST. All specified with options[:method] - # - # Example: - # # Generates: Destroy - # link_to_remote "Destroy", :url => person_url(:id => person), :method => :delete - # - # By default, these remote requests are processed asynchronous during - # which various JavaScript callbacks can be triggered (for progress - # indicators and the likes). All callbacks get access to the - # request object, which holds the underlying XMLHttpRequest. - # - # To access the server response, use request.responseText, to - # find out the HTTP status, use request.status. - # - # Example: - # # Generates: hello - # word = 'hello' - # link_to_remote word, - # :url => { :action => "undo", :n => word_counter }, - # :complete => "undoRequestCompleted(request)" - # - # The callbacks that may be specified are (in order): - # - # :loading:: Called when the remote document is being - # loaded with data by the browser. - # :loaded:: Called when the browser has finished loading - # the remote document. - # :interactive:: Called when the user can interact with the - # remote document, even though it has not - # finished loading. - # :success:: Called when the XMLHttpRequest is completed, - # and the HTTP status code is in the 2XX range. - # :failure:: Called when the XMLHttpRequest is completed, - # and the HTTP status code is not in the 2XX - # range. - # :complete:: Called when the XMLHttpRequest is complete - # (fires after success/failure if they are - # present). - # - # You can further refine :success and :failure by - # adding additional callbacks for specific status codes. - # - # Example: - # # Generates: hello - # link_to_remote word, - # :url => { :action => "action" }, - # 404 => "alert('Not found...? Wrong URL...?')", - # :failure => "alert('HTTP Error ' + request.status + '!')" - # - # A status code callback overrides the success/failure handlers if - # present. - # - # If you for some reason or another need synchronous processing (that'll - # block the browser while the request is happening), you can specify - # options[:type] = :synchronous. - # - # You can customize further browser side call logic by passing in - # JavaScript code snippets via some optional parameters. In their order - # of use these are: - # - # :confirm:: Adds confirmation dialog. - # :condition:: Perform remote request conditionally - # by this expression. Use this to - # describe browser-side conditions when - # request should not be initiated. - # :before:: Called before request is initiated. - # :after:: Called immediately after request was - # initiated and before :loading. - # :submit:: Specifies the DOM element ID that's used - # as the parent of the form elements. By - # default this is the current form, but - # it could just as well be the ID of a - # table row or any other DOM element. - # :with:: A JavaScript expression specifying - # the parameters for the XMLHttpRequest. - # Any expressions should return a valid - # URL query string. - # - # Example: - # - # :with => "'name=' + $('name').value" - # - # You can generate a link that uses AJAX in the general case, while - # degrading gracefully to plain link behavior in the absence of - # JavaScript by setting html_options[:href] to an alternate URL. - # Note the extra curly braces around the options hash separate - # it as the second parameter from html_options, the third. - # - # Example: - # link_to_remote "Delete this post", - # { :update => "posts", :url => { :action => "destroy", :id => post.id } }, - # :href => url_for(:action => "destroy", :id => post.id) - def link_to_remote(name, options = {}, html_options = nil) - link_to_function(name, remote_function(options), html_options || options.delete(:html)) - end - - # Creates a button with an onclick event which calls a remote action - # via XMLHttpRequest - # The options for specifying the target with :url - # and defining callbacks is the same as link_to_remote. - def button_to_remote(name, options = {}, html_options = {}) - button_to_function(name, remote_function(options), html_options) - end - - # Periodically calls the specified url (options[:url]) every - # options[:frequency] seconds (default is 10). Usually used to - # update a specified div (options[:update]) with the results - # of the remote call. The options for specifying the target with :url - # and defining callbacks is the same as link_to_remote. - # Examples: - # # Call get_averages and put its results in 'avg' every 10 seconds - # # Generates: - # # new PeriodicalExecuter(function() {new Ajax.Updater('avg', '/grades/get_averages', - # # {asynchronous:true, evalScripts:true})}, 10) - # periodically_call_remote(:url => { :action => 'get_averages' }, :update => 'avg') - # - # # Call invoice every 10 seconds with the id of the customer - # # If it succeeds, update the invoice DIV; if it fails, update the error DIV - # # Generates: - # # new PeriodicalExecuter(function() {new Ajax.Updater({success:'invoice',failure:'error'}, - # # '/testing/invoice/16', {asynchronous:true, evalScripts:true})}, 10) - # periodically_call_remote(:url => { :action => 'invoice', :id => customer.id }, - # :update => { :success => "invoice", :failure => "error" } - # - # # Call update every 20 seconds and update the new_block DIV - # # Generates: - # # new PeriodicalExecuter(function() {new Ajax.Updater('news_block', 'update', {asynchronous:true, evalScripts:true})}, 20) - # periodically_call_remote(:url => 'update', :frequency => '20', :update => 'news_block') - # - def periodically_call_remote(options = {}) - frequency = options[:frequency] || 10 # every ten seconds by default - code = "new PeriodicalExecuter(function() {#{remote_function(options)}}, #{frequency})" - javascript_tag(code) - end - - # Returns a form tag that will submit using XMLHttpRequest in the - # background instead of the regular reloading POST arrangement. Even - # though it's using JavaScript to serialize the form elements, the form - # submission will work just like a regular submission as viewed by the - # receiving side (all elements available in params). The options for - # specifying the target with :url and defining callbacks is the same as - # +link_to_remote+. - # - # A "fall-through" target for browsers that doesn't do JavaScript can be - # specified with the :action/:method options on :html. - # - # Example: - # # Generates: - # #
    - # form_remote_tag :html => { :action => - # url_for(:controller => "some", :action => "place") } - # - # The Hash passed to the :html key is equivalent to the options (2nd) - # argument in the FormTagHelper.form_tag method. - # - # By default the fall-through action is the same as the one specified in - # the :url (and the default method is :post). - # - # form_remote_tag also takes a block, like form_tag: - # # Generates: - # #
    - # #
    - # <% form_remote_tag :url => '/posts' do -%> - #
    <%= submit_tag 'Save' %>
    - # <% end -%> - def form_remote_tag(options = {}, &block) - options[:form] = true - - options[:html] ||= {} - options[:html][:onsubmit] = - (options[:html][:onsubmit] ? options[:html][:onsubmit] + "; " : "") + - "#{remote_function(options)}; return false;" - - form_tag(options[:html].delete(:action) || url_for(options[:url]), options[:html], &block) - end - - # Creates a form that will submit using XMLHttpRequest in the background - # instead of the regular reloading POST arrangement and a scope around a - # specific resource that is used as a base for questioning about - # values for the fields. - # - # === Resource - # - # Example: - # <% remote_form_for(@post) do |f| %> - # ... - # <% end %> - # - # This will expand to be the same as: - # - # <% remote_form_for :post, @post, :url => post_path(@post), :html => { :method => :put, :class => "edit_post", :id => "edit_post_45" } do |f| %> - # ... - # <% end %> - # - # === Nested Resource - # - # Example: - # <% remote_form_for([@post, @comment]) do |f| %> - # ... - # <% end %> - # - # This will expand to be the same as: - # - # <% remote_form_for :comment, @comment, :url => post_comment_path(@post, @comment), :html => { :method => :put, :class => "edit_comment", :id => "edit_comment_45" } do |f| %> - # ... - # <% end %> - # - # If you don't need to attach a form to a resource, then check out form_remote_tag. - # - # See FormHelper#form_for for additional semantics. - def remote_form_for(record_or_name_or_array, *args, &proc) - options = args.extract_options! - - case record_or_name_or_array - when String, Symbol - object_name = record_or_name_or_array - when Array - object = record_or_name_or_array.last - object_name = ActionController::RecordIdentifier.singular_class_name(object) - apply_form_for_options!(record_or_name_or_array, options) - args.unshift object - else - object = record_or_name_or_array - object_name = ActionController::RecordIdentifier.singular_class_name(record_or_name_or_array) - apply_form_for_options!(object, options) - args.unshift object - end - - concat(form_remote_tag(options)) - fields_for(object_name, *(args << options), &proc) - concat('') - end - alias_method :form_remote_for, :remote_form_for - - # Returns a button input tag with the element name of +name+ and a value (i.e., display text) of +value+ - # that will submit form using XMLHttpRequest in the background instead of a regular POST request that - # reloads the page. - # - # # Create a button that submits to the create action - # # - # # Generates: - # <%= submit_to_remote 'create_btn', 'Create', :url => { :action => 'create' } %> - # - # # Submit to the remote action update and update the DIV succeed or fail based - # # on the success or failure of the request - # # - # # Generates: - # <%= submit_to_remote 'update_btn', 'Update', :url => { :action => 'update' }, - # :update => { :success => "succeed", :failure => "fail" } - # - # options argument is the same as in form_remote_tag. - def submit_to_remote(name, value, options = {}) - options[:with] ||= 'Form.serialize(this.form)' - - html_options = options.delete(:html) || {} - html_options[:name] = name - - button_to_remote(value, options, html_options) - end - - # Returns 'eval(request.responseText)' which is the JavaScript function - # that +form_remote_tag+ can call in :complete to evaluate a multiple - # update return document using +update_element_function+ calls. - def evaluate_remote_response - "eval(request.responseText)" - end - - # Returns the JavaScript needed for a remote function. - # Takes the same arguments as link_to_remote. - # - # Example: - # # Generates: { :action => :update_options }) %>"> - # - # - # - def remote_function(options) - javascript_options = options_for_ajax(options) - - update = '' - if options[:update] && options[:update].is_a?(Hash) - update = [] - update << "success:'#{options[:update][:success]}'" if options[:update][:success] - update << "failure:'#{options[:update][:failure]}'" if options[:update][:failure] - update = '{' + update.join(',') + '}' - elsif options[:update] - update << "'#{options[:update]}'" - end - - function = update.empty? ? - "new Ajax.Request(" : - "new Ajax.Updater(#{update}, " - - url_options = options[:url] - url_options = url_options.merge(:escape => false) if url_options.is_a?(Hash) - function << "'#{escape_javascript(url_for(url_options))}'" - function << ", #{javascript_options})" - - function = "#{options[:before]}; #{function}" if options[:before] - function = "#{function}; #{options[:after]}" if options[:after] - function = "if (#{options[:condition]}) { #{function}; }" if options[:condition] - function = "if (confirm('#{escape_javascript(options[:confirm])}')) { #{function}; }" if options[:confirm] - - return function - end - - # Observes the field with the DOM ID specified by +field_id+ and calls a - # callback when its contents have changed. The default callback is an - # Ajax call. By default the value of the observed field is sent as a - # parameter with the Ajax call. - # - # Example: - # # Generates: new Form.Element.Observer('suggest', 0.25, function(element, value) {new Ajax.Updater('suggest', - # # '/testing/find_suggestion', {asynchronous:true, evalScripts:true, parameters:'q=' + value})}) - # <%= observe_field :suggest, :url => { :action => :find_suggestion }, - # :frequency => 0.25, - # :update => :suggest, - # :with => 'q' - # %> - # - # Required +options+ are either of: - # :url:: +url_for+-style options for the action to call - # when the field has changed. - # :function:: Instead of making a remote call to a URL, you - # can specify javascript code to be called instead. - # Note that the value of this option is used as the - # *body* of the javascript function, a function definition - # with parameters named element and value will be generated for you - # for example: - # observe_field("glass", :frequency => 1, :function => "alert('Element changed')") - # will generate: - # new Form.Element.Observer('glass', 1, function(element, value) {alert('Element changed')}) - # The element parameter is the DOM element being observed, and the value is its value at the - # time the observer is triggered. - # - # Additional options are: - # :frequency:: The frequency (in seconds) at which changes to - # this field will be detected. Not setting this - # option at all or to a value equal to or less than - # zero will use event based observation instead of - # time based observation. - # :update:: Specifies the DOM ID of the element whose - # innerHTML should be updated with the - # XMLHttpRequest response text. - # :with:: A JavaScript expression specifying the parameters - # for the XMLHttpRequest. The default is to send the - # key and value of the observed field. Any custom - # expressions should return a valid URL query string. - # The value of the field is stored in the JavaScript - # variable +value+. - # - # Examples - # - # :with => "'my_custom_key=' + value" - # :with => "'person[name]=' + prompt('New name')" - # :with => "Form.Element.serialize('other-field')" - # - # Finally - # :with => 'name' - # is shorthand for - # :with => "'name=' + value" - # This essentially just changes the key of the parameter. - # - # Additionally, you may specify any of the options documented in the - # Common options section at the top of this document. - # - # Example: - # - # # Sends params: {:title => 'Title of the book'} when the book_title input - # # field is changed. - # observe_field 'book_title', - # :url => 'http://example.com/books/edit/1', - # :with => 'title' - # - # - def observe_field(field_id, options = {}) - if options[:frequency] && options[:frequency] > 0 - build_observer('Form.Element.Observer', field_id, options) - else - build_observer('Form.Element.EventObserver', field_id, options) - end - end - - # Observes the form with the DOM ID specified by +form_id+ and calls a - # callback when its contents have changed. The default callback is an - # Ajax call. By default all fields of the observed field are sent as - # parameters with the Ajax call. - # - # The +options+ for +observe_form+ are the same as the options for - # +observe_field+. The JavaScript variable +value+ available to the - # :with option is set to the serialized form by default. - def observe_form(form_id, options = {}) - if options[:frequency] - build_observer('Form.Observer', form_id, options) - else - build_observer('Form.EventObserver', form_id, options) - end - end - - # All the methods were moved to GeneratorMethods so that - # #include_helpers_from_context has nothing to overwrite. - class JavaScriptGenerator #:nodoc: - def initialize(context, &block) #:nodoc: - @context, @lines = context, [] - include_helpers_from_context - @context.with_output_buffer(@lines) do - @context.instance_exec(self, &block) - end - end - - private - def include_helpers_from_context - extend @context.helpers if @context.respond_to?(:helpers) - extend GeneratorMethods - end - - # JavaScriptGenerator generates blocks of JavaScript code that allow you - # to change the content and presentation of multiple DOM elements. Use - # this in your Ajax response bodies, either in a - # - # mail_to "me@domain.com", "My email", :encode => "hex" - # # => My email - # - # mail_to "me@domain.com", nil, :replace_at => "_at_", :replace_dot => "_dot_", :class => "email" - # # => - # - # mail_to "me@domain.com", "My email", :cc => "ccaddress@domain.com", - # :subject => "This is an example email" - # # => My email - def mail_to(email_address, name = nil, html_options = {}) - html_options = html_options.stringify_keys - encode = html_options.delete("encode").to_s - cc, bcc, subject, body = html_options.delete("cc"), html_options.delete("bcc"), html_options.delete("subject"), html_options.delete("body") - - string = '' - extras = '' - extras << "cc=#{CGI.escape(cc).gsub("+", "%20")}&" unless cc.nil? - extras << "bcc=#{CGI.escape(bcc).gsub("+", "%20")}&" unless bcc.nil? - extras << "body=#{CGI.escape(body).gsub("+", "%20")}&" unless body.nil? - extras << "subject=#{CGI.escape(subject).gsub("+", "%20")}&" unless subject.nil? - extras = "?" << extras.gsub!(/&?$/,"") unless extras.empty? - - email_address = email_address.to_s - - email_address_obfuscated = email_address.dup - email_address_obfuscated.gsub!(/@/, html_options.delete("replace_at")) if html_options.has_key?("replace_at") - email_address_obfuscated.gsub!(/\./, html_options.delete("replace_dot")) if html_options.has_key?("replace_dot") - - if encode == "javascript" - "document.write('#{content_tag("a", name || email_address_obfuscated, html_options.merge({ "href" => "mailto:"+email_address+extras }))}');".each_byte do |c| - string << sprintf("%%%x", c) - end - "" - elsif encode == "hex" - email_address_encoded = '' - email_address_obfuscated.each_byte do |c| - email_address_encoded << sprintf("&#%d;", c) - end - - protocol = 'mailto:' - protocol.each_byte { |c| string << sprintf("&#%d;", c) } - - email_address.each_byte do |c| - char = c.chr - string << (char =~ /\w/ ? sprintf("%%%x", c) : char) - end - content_tag "a", name || email_address_encoded, html_options.merge({ "href" => "#{string}#{extras}" }) - else - content_tag "a", name || email_address_obfuscated, html_options.merge({ "href" => "mailto:#{email_address}#{extras}" }) - end - end - - # True if the current request URI was generated by the given +options+. - # - # ==== Examples - # Let's say we're in the /shop/checkout?order=desc action. - # - # current_page?(:action => 'process') - # # => false - # - # current_page?(:controller => 'shop', :action => 'checkout') - # # => true - # - # current_page?(:controller => 'shop', :action => 'checkout', :order => 'asc') - # # => false - # - # current_page?(:action => 'checkout') - # # => true - # - # current_page?(:controller => 'library', :action => 'checkout') - # # => false - # - # Let's say we're in the /shop/checkout?order=desc&page=1 action. - # - # current_page?(:action => 'process') - # # => false - # - # current_page?(:controller => 'shop', :action => 'checkout') - # # => true - # - # current_page?(:controller => 'shop', :action => 'checkout', :order => 'desc', :page=>'1') - # # => true - # - # current_page?(:controller => 'shop', :action => 'checkout', :order => 'desc', :page=>'2') - # # => false - # - # current_page?(:controller => 'shop', :action => 'checkout', :order => 'desc') - # # => false - # - # current_page?(:action => 'checkout') - # # => true - # - # current_page?(:controller => 'library', :action => 'checkout') - # # => false - def current_page?(options) - url_string = CGI.unescapeHTML(url_for(options)) - request = @controller.request - # We ignore any extra parameters in the request_uri if the - # submitted url doesn't have any either. This lets the function - # work with things like ?order=asc - if url_string.index("?") - request_uri = request.request_uri - else - request_uri = request.request_uri.split('?').first - end - if url_string =~ /^\w+:\/\// - url_string == "#{request.protocol}#{request.host_with_port}#{request_uri}" - else - url_string == request_uri - end - end - - private - def convert_options_to_javascript!(html_options, url = '') - confirm, popup = html_options.delete("confirm"), html_options.delete("popup") - - method, href = html_options.delete("method"), html_options['href'] - - html_options["onclick"] = case - when popup && method - raise ActionView::ActionViewError, "You can't use :popup and :method in the same link" - when confirm && popup - "if (#{confirm_javascript_function(confirm)}) { #{popup_javascript_function(popup)} };return false;" - when confirm && method - "if (#{confirm_javascript_function(confirm)}) { #{method_javascript_function(method)} };return false;" - when confirm - "return #{confirm_javascript_function(confirm)};" - when method - "#{method_javascript_function(method, url, href)}return false;" - when popup - "#{popup_javascript_function(popup)}return false;" - else - html_options["onclick"] - end - end - - def confirm_javascript_function(confirm) - "confirm('#{escape_javascript(confirm)}')" - end - - def popup_javascript_function(popup) - popup.is_a?(Array) ? "window.open(this.href,'#{popup.first}','#{popup.last}');" : "window.open(this.href);" - end - - def method_javascript_function(method, url = '', href = nil) - action = (href && url.size > 0) ? "'#{url}'" : 'this.href' - submit_function = - "var f = document.createElement('form'); f.style.display = 'none'; " + - "this.parentNode.appendChild(f); f.method = 'POST'; f.action = #{action};" - - unless method == :post - submit_function << "var m = document.createElement('input'); m.setAttribute('type', 'hidden'); " - submit_function << "m.setAttribute('name', '_method'); m.setAttribute('value', '#{method}'); f.appendChild(m);" - end - - if protect_against_forgery? - submit_function << "var s = document.createElement('input'); s.setAttribute('type', 'hidden'); " - submit_function << "s.setAttribute('name', '#{request_forgery_protection_token}'); s.setAttribute('value', '#{escape_javascript form_authenticity_token}'); f.appendChild(s);" - end - submit_function << "f.submit();" - end - - # Processes the _html_options_ hash, converting the boolean - # attributes from true/false form into the form required by - # HTML/XHTML. (An attribute is considered to be boolean if - # its name is listed in the given _bool_attrs_ array.) - # - # More specifically, for each boolean attribute in _html_options_ - # given as: - # - # "attr" => bool_value - # - # if the associated _bool_value_ evaluates to true, it is - # replaced with the attribute's name; otherwise the attribute is - # removed from the _html_options_ hash. (See the XHTML 1.0 spec, - # section 4.5 "Attribute Minimization" for more: - # http://www.w3.org/TR/xhtml1/#h-4.5) - # - # Returns the updated _html_options_ hash, which is also modified - # in place. - # - # Example: - # - # convert_boolean_attributes!( html_options, - # %w( checked disabled readonly ) ) - def convert_boolean_attributes!(html_options, bool_attrs) - bool_attrs.each { |x| html_options[x] = x if html_options.delete(x) } - html_options - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/inline_template.rb b/vendor/rails/actionpack/lib/action_view/inline_template.rb deleted file mode 100644 index 54efa54..0000000 --- a/vendor/rails/actionpack/lib/action_view/inline_template.rb +++ /dev/null @@ -1,19 +0,0 @@ -module ActionView #:nodoc: - class InlineTemplate #:nodoc: - include Renderable - - attr_reader :source, :extension, :method_segment - - def initialize(source, type = nil) - @source = source - @extension = type - @method_segment = "inline_#{@source.hash.abs}" - end - - private - # Always recompile inline templates - def recompile? - true - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/locale/en.yml b/vendor/rails/actionpack/lib/action_view/locale/en.yml deleted file mode 100644 index afe3569..0000000 --- a/vendor/rails/actionpack/lib/action_view/locale/en.yml +++ /dev/null @@ -1,110 +0,0 @@ -"en": - number: - # Used in number_with_delimiter() - # These are also the defaults for 'currency', 'percentage', 'precision', and 'human' - format: - # Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5) - separator: "." - # Delimets thousands (e.g. 1,000,000 is a million) (always in groups of three) - delimiter: "," - # Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00) - precision: 3 - - # Used in number_to_currency() - currency: - format: - # Where is the currency sign? %u is the currency unit, %n the number (default: $5.00) - format: "%u%n" - unit: "$" - # These three are to override number.format and are optional - separator: "." - delimiter: "," - precision: 2 - - # Used in number_to_percentage() - percentage: - format: - # These three are to override number.format and are optional - # separator: - delimiter: "" - # precision: - - # Used in number_to_precision() - precision: - format: - # These three are to override number.format and are optional - # separator: - delimiter: "" - # precision: - - # Used in number_to_human_size() - human: - format: - # These three are to override number.format and are optional - # separator: - delimiter: "" - precision: 1 - storage_units: - # Storage units output formatting. - # %u is the storage unit, %n is the number (default: 2 MB) - format: "%n %u" - units: - byte: - one: "Byte" - other: "Bytes" - kb: "KB" - mb: "MB" - gb: "GB" - tb: "TB" - - # Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words() - datetime: - distance_in_words: - half_a_minute: "half a minute" - less_than_x_seconds: - one: "less than 1 second" - other: "less than {{count}} seconds" - x_seconds: - one: "1 second" - other: "{{count}} seconds" - less_than_x_minutes: - one: "less than a minute" - other: "less than {{count}} minutes" - x_minutes: - one: "1 minute" - other: "{{count}} minutes" - about_x_hours: - one: "about 1 hour" - other: "about {{count}} hours" - x_days: - one: "1 day" - other: "{{count}} days" - about_x_months: - one: "about 1 month" - other: "about {{count}} months" - x_months: - one: "1 month" - other: "{{count}} months" - about_x_years: - one: "about 1 year" - other: "about {{count}} years" - over_x_years: - one: "over 1 year" - other: "over {{count}} years" - prompts: - year: "Year" - month: "Month" - day: "Day" - hour: "Hour" - minute: "Minute" - second: "Seconds" - - activerecord: - errors: - template: - header: - one: "1 error prohibited this {{model}} from being saved" - other: "{{count}} errors prohibited this {{model}} from being saved" - # The variable :count is also available - body: "There were problems with the following fields:" - diff --git a/vendor/rails/actionpack/lib/action_view/partials.rb b/vendor/rails/actionpack/lib/action_view/partials.rb deleted file mode 100644 index 9e5e0f7..0000000 --- a/vendor/rails/actionpack/lib/action_view/partials.rb +++ /dev/null @@ -1,240 +0,0 @@ -module ActionView - # There's also a convenience method for rendering sub templates within the current controller that depends on a - # single object (we call this kind of sub templates for partials). It relies on the fact that partials should - # follow the naming convention of being prefixed with an underscore -- as to separate them from regular - # templates that could be rendered on their own. - # - # In a template for Advertiser#account: - # - # <%= render :partial => "account" %> - # - # This would render "advertiser/_account.erb" and pass the instance variable @account in as a local variable - # +account+ to the template for display. - # - # In another template for Advertiser#buy, we could have: - # - # <%= render :partial => "account", :locals => { :account => @buyer } %> - # - # <% for ad in @advertisements %> - # <%= render :partial => "ad", :locals => { :ad => ad } %> - # <% end %> - # - # This would first render "advertiser/_account.erb" with @buyer passed in as the local variable +account+, then - # render "advertiser/_ad.erb" and pass the local variable +ad+ to the template for display. - # - # == Rendering a collection of partials - # - # The example of partial use describes a familiar pattern where a template needs to iterate over an array and - # render a sub template for each of the elements. This pattern has been implemented as a single method that - # accepts an array and renders a partial by the same name as the elements contained within. So the three-lined - # example in "Using partials" can be rewritten with a single line: - # - # <%= render :partial => "ad", :collection => @advertisements %> - # - # This will render "advertiser/_ad.erb" and pass the local variable +ad+ to the template for display. An - # iteration counter will automatically be made available to the template with a name of the form - # +partial_name_counter+. In the case of the example above, the template would be fed +ad_counter+. - # - # NOTE: Due to backwards compatibility concerns, the collection can't be one of hashes. Normally you'd also - # just keep domain objects, like Active Records, in there. - # - # == Rendering shared partials - # - # Two controllers can share a set of partials and render them like this: - # - # <%= render :partial => "advertisement/ad", :locals => { :ad => @advertisement } %> - # - # This will render the partial "advertisement/_ad.erb" regardless of which controller this is being called from. - # - # == Rendering objects with the RecordIdentifier - # - # Instead of explicitly naming the location of a partial, you can also let the RecordIdentifier do the work if - # you're following its conventions for RecordIdentifier#partial_path. Examples: - # - # # @account is an Account instance, so it uses the RecordIdentifier to replace - # # <%= render :partial => "accounts/account", :locals => { :account => @buyer } %> - # <%= render :partial => @account %> - # - # # @posts is an array of Post instances, so it uses the RecordIdentifier to replace - # # <%= render :partial => "posts/post", :collection => @posts %> - # <%= render :partial => @posts %> - # - # == Rendering the default case - # - # If you're not going to be using any of the options like collections or layouts, you can also use the short-hand - # defaults of render to render partials. Examples: - # - # # Instead of <%= render :partial => "account" %> - # <%= render "account" %> - # - # # Instead of <%= render :partial => "account", :locals => { :account => @buyer } %> - # <%= render "account", :account => @buyer %> - # - # # @account is an Account instance, so it uses the RecordIdentifier to replace - # # <%= render :partial => "accounts/account", :locals => { :account => @account } %> - # <%= render(@account) %> - # - # # @posts is an array of Post instances, so it uses the RecordIdentifier to replace - # # <%= render :partial => "posts/post", :collection => @posts %> - # <%= render(@posts) %> - # - # == Rendering partials with layouts - # - # Partials can have their own layouts applied to them. These layouts are different than the ones that are - # specified globally for the entire action, but they work in a similar fashion. Imagine a list with two types - # of users: - # - # <%# app/views/users/index.html.erb &> - # Here's the administrator: - # <%= render :partial => "user", :layout => "administrator", :locals => { :user => administrator } %> - # - # Here's the editor: - # <%= render :partial => "user", :layout => "editor", :locals => { :user => editor } %> - # - # <%# app/views/users/_user.html.erb &> - # Name: <%= user.name %> - # - # <%# app/views/users/_administrator.html.erb &> - #
    - # Budget: $<%= user.budget %> - # <%= yield %> - #
    - # - # <%# app/views/users/_editor.html.erb &> - #
    - # Deadline: <%= user.deadline %> - # <%= yield %> - #
    - # - # ...this will return: - # - # Here's the administrator: - #
    - # Budget: $<%= user.budget %> - # Name: <%= user.name %> - #
    - # - # Here's the editor: - #
    - # Deadline: <%= user.deadline %> - # Name: <%= user.name %> - #
    - # - # You can also apply a layout to a block within any template: - # - # <%# app/views/users/_chief.html.erb &> - # <% render(:layout => "administrator", :locals => { :user => chief }) do %> - # Title: <%= chief.title %> - # <% end %> - # - # ...this will return: - # - #
    - # Budget: $<%= user.budget %> - # Title: <%= chief.name %> - #
    - # - # As you can see, the :locals hash is shared between both the partial and its layout. - # - # If you pass arguments to "yield" then this will be passed to the block. One way to use this is to pass - # an array to layout and treat it as an enumerable. - # - # <%# app/views/users/_user.html.erb &> - #
    - # Budget: $<%= user.budget %> - # <%= yield user %> - #
    - # - # <%# app/views/users/index.html.erb &> - # <% render :layout => @users do |user| %> - # Title: <%= user.title %> - # <% end %> - # - # This will render the layout for each user and yield to the block, passing the user, each time. - # - # You can also yield multiple times in one layout and use block arguments to differentiate the sections. - # - # <%# app/views/users/_user.html.erb &> - #
    - # <%= yield user, :header %> - # Budget: $<%= user.budget %> - # <%= yield user, :footer %> - #
    - # - # <%# app/views/users/index.html.erb &> - # <% render :layout => @users do |user, section| %> - # <%- case section when :header -%> - # Title: <%= user.title %> - # <%- when :footer -%> - # Deadline: <%= user.deadline %> - # <%- end -%> - # <% end %> - module Partials - extend ActiveSupport::Memoizable - - private - def render_partial(options = {}) #:nodoc: - local_assigns = options[:locals] || {} - - case partial_path = options[:partial] - when String, Symbol, NilClass - if options.has_key?(:collection) - render_partial_collection(options) - else - _pick_partial_template(partial_path).render_partial(self, options[:object], local_assigns) - end - when ActionView::Helpers::FormBuilder - builder_partial_path = partial_path.class.to_s.demodulize.underscore.sub(/_builder$/, '') - local_assigns.merge!(builder_partial_path.to_sym => partial_path) - render_partial(:partial => builder_partial_path, :object => options[:object], :locals => local_assigns) - else - if Array === partial_path || - (defined?(ActiveRecord) && - (ActiveRecord::Associations::AssociationCollection === partial_path || - ActiveRecord::NamedScope::Scope === partial_path)) - render_partial_collection(options.except(:partial).merge(:collection => partial_path)) - else - object = partial_path - render_partial( - :partial => ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path), - :object => object, - :locals => local_assigns - ) - end - end - end - - def render_partial_collection(options = {}) #:nodoc: - return nil if options[:collection].blank? - - partial = options[:partial] - spacer = options[:spacer_template] ? render(:partial => options[:spacer_template]) : '' - local_assigns = options[:locals] ? options[:locals].clone : {} - as = options[:as] - - index = 0 - options[:collection].map do |object| - _partial_path ||= partial || - ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path) - template = _pick_partial_template(_partial_path) - local_assigns[template.counter_name] = index - result = template.render_partial(self, object, local_assigns.dup, as) - index += 1 - result - end.join(spacer) - end - - def _pick_partial_template(partial_path) #:nodoc: - if partial_path.include?('/') - path = File.join(File.dirname(partial_path), "_#{File.basename(partial_path)}") - elsif controller - path = "#{controller.class.controller_path}/_#{partial_path}" - else - path = "_#{partial_path}" - end - - self.view_paths.find_template(path, self.template_format) - end - memoize :_pick_partial_template - end -end diff --git a/vendor/rails/actionpack/lib/action_view/paths.rb b/vendor/rails/actionpack/lib/action_view/paths.rb deleted file mode 100644 index 37d96b2..0000000 --- a/vendor/rails/actionpack/lib/action_view/paths.rb +++ /dev/null @@ -1,69 +0,0 @@ -module ActionView #:nodoc: - class PathSet < Array #:nodoc: - def self.type_cast(obj) - if obj.is_a?(String) - if Base.cache_template_loading? - Template::EagerPath.new(obj.to_s) - else - ReloadableTemplate::ReloadablePath.new(obj.to_s) - end - else - obj - end - end - - def initialize(*args) - super(*args).map! { |obj| self.class.type_cast(obj) } - end - - def <<(obj) - super(self.class.type_cast(obj)) - end - - def concat(array) - super(array.map! { |obj| self.class.type_cast(obj) }) - end - - def insert(index, obj) - super(index, self.class.type_cast(obj)) - end - - def push(*objs) - super(*objs.map { |obj| self.class.type_cast(obj) }) - end - - def unshift(*objs) - super(*objs.map { |obj| self.class.type_cast(obj) }) - end - - def load! - each(&:load!) - end - - def find_template(original_template_path, format = nil, html_fallback = true) - return original_template_path if original_template_path.respond_to?(:render) - template_path = original_template_path.sub(/^\//, '') - - each do |load_path| - if format && (template = load_path["#{template_path}.#{I18n.locale}.#{format}"]) - return template - elsif format && (template = load_path["#{template_path}.#{format}"]) - return template - elsif template = load_path["#{template_path}.#{I18n.locale}"] - return template - elsif template = load_path[template_path] - return template - # Try to find html version if the format is javascript - elsif format == :js && html_fallback && template = load_path["#{template_path}.#{I18n.locale}.html"] - return template - elsif format == :js && html_fallback && template = load_path["#{template_path}.html"] - return template - end - end - - return Template.new(original_template_path, original_template_path =~ /\A\// ? "" : ".") if File.file?(original_template_path) - - raise MissingTemplate.new(self, original_template_path, format) - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/reloadable_template.rb b/vendor/rails/actionpack/lib/action_view/reloadable_template.rb deleted file mode 100644 index 5ef833d..0000000 --- a/vendor/rails/actionpack/lib/action_view/reloadable_template.rb +++ /dev/null @@ -1,117 +0,0 @@ -module ActionView #:nodoc: - class ReloadableTemplate < Template - - class TemplateDeleted < ActionView::ActionViewError - end - - class ReloadablePath < Template::Path - - def initialize(path) - super - @paths = {} - new_request! - end - - def new_request! - @disk_cache = {} - end - alias_method :load!, :new_request! - - def [](path) - if found_template = @paths[path] - begin - found_template.reset_cache_if_stale! - rescue TemplateDeleted - unregister_template(found_template) - self[path] - end - else - load_all_templates_from_dir(templates_dir_from_path(path)) - # don't ever hand out a template without running a stale check - (new_template = @paths[path]) && new_template.reset_cache_if_stale! - end - end - - private - def register_template_from_file(template_full_file_path) - if !@paths[relative_path = relative_path_for_template_file(template_full_file_path)] && File.file?(template_full_file_path) - register_template(ReloadableTemplate.new(relative_path, self)) - end - end - - def register_template(template) - template.accessible_paths.each do |path| - @paths[path] = template - end - end - - # remove (probably deleted) template from cache - def unregister_template(template) - template.accessible_paths.each do |template_path| - @paths.delete(template_path) if @paths[template_path] == template - end - # fill in any newly created gaps - @paths.values.uniq.each do |template| - template.accessible_paths.each {|path| @paths[path] ||= template} - end - end - - # load all templates from the directory of the requested template - def load_all_templates_from_dir(dir) - # hit disk only once per template-dir/request - @disk_cache[dir] ||= template_files_from_dir(dir).each {|template_file| register_template_from_file(template_file)} - end - - def templates_dir_from_path(path) - dirname = File.dirname(path) - File.join(@path, dirname == '.' ? '' : dirname) - end - - # get all the template filenames from the dir - def template_files_from_dir(dir) - Dir.glob(File.join(dir, '*')) - end - end - - module Unfreezable - def freeze; self; end - end - - def initialize(*args) - super - - # we don't ever want to get frozen - extend Unfreezable - end - - def mtime - File.mtime(filename) - end - - attr_accessor :previously_last_modified - - def stale? - previously_last_modified.nil? || previously_last_modified < mtime - rescue Errno::ENOENT => e - undef_my_compiled_methods! - raise TemplateDeleted - end - - def reset_cache_if_stale! - if stale? - flush_cache 'source', 'compiled_source' - undef_my_compiled_methods! - @previously_last_modified = mtime - end - self - end - - # remove any compiled methods that look like they might belong to me - def undef_my_compiled_methods! - ActionView::Base::CompiledTemplates.public_instance_methods.grep(/#{Regexp.escape(method_name_without_locals)}(?:_locals_)?/).each do |m| - ActionView::Base::CompiledTemplates.send(:remove_method, m) - end - end - - end -end diff --git a/vendor/rails/actionpack/lib/action_view/renderable.rb b/vendor/rails/actionpack/lib/action_view/renderable.rb deleted file mode 100644 index ff7bc7d..0000000 --- a/vendor/rails/actionpack/lib/action_view/renderable.rb +++ /dev/null @@ -1,95 +0,0 @@ -# encoding: utf-8 - -module ActionView - # NOTE: The template that this mixin is being included into is frozen - # so you cannot set or modify any instance variables - module Renderable #:nodoc: - extend ActiveSupport::Memoizable - - def filename - 'compiled-template' - end - - def handler - Template.handler_class_for_extension(extension) - end - memoize :handler - - def compiled_source - handler.call(self) - end - - def method_name_without_locals - ['_run', extension, method_segment].compact.join('_') - end - memoize :method_name_without_locals - - def render(view, local_assigns = {}) - compile(local_assigns) - - view.with_template self do - view.send(:_evaluate_assigns_and_ivars) - view.send(:_set_controller_content_type, mime_type) if respond_to?(:mime_type) - - view.send(method_name(local_assigns), local_assigns) do |*names| - ivar = :@_proc_for_layout - if !view.instance_variable_defined?(:"@content_for_#{names.first}") && view.instance_variable_defined?(ivar) && (proc = view.instance_variable_get(ivar)) - view.capture(*names, &proc) - elsif view.instance_variable_defined?(ivar = :"@content_for_#{names.first || :layout}") - view.instance_variable_get(ivar) - end - end - end - end - - def method_name(local_assigns) - if local_assigns && local_assigns.any? - method_name = method_name_without_locals.dup - method_name << "_locals_#{local_assigns.keys.map { |k| k.to_s }.sort.join('_')}" - else - method_name = method_name_without_locals - end - method_name.to_sym - end - - private - # Compile and evaluate the template's code (if necessary) - def compile(local_assigns) - render_symbol = method_name(local_assigns) - - if !Base::CompiledTemplates.method_defined?(render_symbol) || recompile? - compile!(render_symbol, local_assigns) - end - end - - def compile!(render_symbol, local_assigns) - locals_code = local_assigns.keys.map { |key| "#{key} = local_assigns[:#{key}];" }.join - - source = <<-end_src - def #{render_symbol}(local_assigns) - old_output_buffer = output_buffer;#{locals_code};#{compiled_source} - ensure - self.output_buffer = old_output_buffer - end - end_src - - begin - ActionView::Base::CompiledTemplates.module_eval(source, filename, 0) - rescue Errno::ENOENT => e - raise e # Missing template file, re-raise for Base to rescue - rescue Exception => e # errors from template code - if logger = defined?(ActionController) && Base.logger - logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}" - logger.debug "Function body: #{source}" - logger.debug "Backtrace: #{e.backtrace.join("\n")}" - end - - raise ActionView::TemplateError.new(self, {}, e) - end - end - - def recompile? - false - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/renderable_partial.rb b/vendor/rails/actionpack/lib/action_view/renderable_partial.rb deleted file mode 100644 index 3ea836f..0000000 --- a/vendor/rails/actionpack/lib/action_view/renderable_partial.rb +++ /dev/null @@ -1,47 +0,0 @@ -module ActionView - # NOTE: The template that this mixin is being included into is frozen - # so you cannot set or modify any instance variables - module RenderablePartial #:nodoc: - extend ActiveSupport::Memoizable - - def variable_name - name.sub(/\A_/, '').to_sym - end - memoize :variable_name - - def counter_name - "#{variable_name}_counter".to_sym - end - memoize :counter_name - - def render(view, local_assigns = {}) - if defined? ActionController - ActionController::Base.benchmark("Rendered #{path_without_format_and_extension}", Logger::DEBUG, false) do - super - end - else - super - end - end - - def render_partial(view, object = nil, local_assigns = {}, as = nil) - object ||= local_assigns[:object] || local_assigns[variable_name] - - if object.nil? && view.respond_to?(:controller) - ivar = :"@#{variable_name}" - object = - if view.controller.instance_variable_defined?(ivar) - ActiveSupport::Deprecation::DeprecatedObjectProxy.new( - view.controller.instance_variable_get(ivar), - "#{ivar} will no longer be implicitly assigned to #{variable_name}") - end - end - - # Ensure correct object is reassigned to other accessors - local_assigns[:object] = local_assigns[variable_name] = object - local_assigns[as] = object if as - - render_template(view, local_assigns) - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/template.rb b/vendor/rails/actionpack/lib/action_view/template.rb deleted file mode 100644 index c339c8a..0000000 --- a/vendor/rails/actionpack/lib/action_view/template.rb +++ /dev/null @@ -1,257 +0,0 @@ -module ActionView #:nodoc: - class Template - class Path - attr_reader :path, :paths - delegate :hash, :inspect, :to => :path - - def initialize(path) - raise ArgumentError, "path already is a Path class" if path.is_a?(Path) - @path = (path.ends_with?(File::SEPARATOR) ? path.to(-2) : path).freeze - end - - def to_s - if defined?(RAILS_ROOT) - path.to_s.sub(/^#{Regexp.escape(File.expand_path(RAILS_ROOT))}\//, '') - else - path.to_s - end - end - - def to_str - path.to_str - end - - def ==(path) - to_str == path.to_str - end - - def eql?(path) - to_str == path.to_str - end - - # Returns a ActionView::Template object for the given path string. The - # input path should be relative to the view path directory, - # +hello/index.html.erb+. This method also has a special exception to - # match partial file names without a handler extension. So - # +hello/index.html+ will match the first template it finds with a - # known template extension, +hello/index.html.erb+. Template extensions - # should not be confused with format extensions +html+, +js+, +xml+, - # etc. A format must be supplied to match a formated file. +hello/index+ - # will never match +hello/index.html.erb+. - def [](path) - end - - def load! - end - - def self.new_and_loaded(path) - returning new(path) do |path| - path.load! - end - end - - private - def relative_path_for_template_file(full_file_path) - full_file_path.split("#{@path}/").last - end - end - - class EagerPath < Path - def load! - return if @loaded - - @paths = {} - templates_in_path do |template| - template.load! - template.accessible_paths.each do |path| - @paths[path] = template - end - end - @paths.freeze - @loaded = true - end - - def [](path) - load! unless @loaded - @paths[path] - end - - private - def templates_in_path - (Dir.glob("#{@path}/**/*/**") | Dir.glob("#{@path}/**")).each do |file| - yield create_template(file) unless File.directory?(file) - end - end - - def create_template(file) - Template.new(relative_path_for_template_file(file), self) - end - end - - extend TemplateHandlers - extend ActiveSupport::Memoizable - include Renderable - - # Templates that are exempt from layouts - @@exempt_from_layout = Set.new([/\.rjs$/]) - - # Don't render layouts for templates with the given extensions. - def self.exempt_from_layout(*extensions) - regexps = extensions.collect do |extension| - extension.is_a?(Regexp) ? extension : /\.#{Regexp.escape(extension.to_s)}$/ - end - @@exempt_from_layout.merge(regexps) - end - - attr_accessor :template_path, :filename, :load_path, :base_path - attr_accessor :locale, :name, :format, :extension - delegate :to_s, :to => :path - - def initialize(template_path, load_path) - @template_path = template_path.dup - @load_path, @filename = load_path, File.join(load_path, template_path) - @base_path, @name, @locale, @format, @extension = split(template_path) - @base_path.to_s.gsub!(/\/$/, '') # Push to split method - - # Extend with partial super powers - extend RenderablePartial if @name =~ /^_/ - end - - def accessible_paths - paths = [] - - if valid_extension?(extension) - paths << path - paths << path_without_extension - if multipart? - formats = format.split(".") - paths << "#{path_without_format_and_extension}.#{formats.first}" - paths << "#{path_without_format_and_extension}.#{formats.second}" - end - else - # template without explicit template handler should only be reachable through its exact path - paths << template_path - end - - paths - end - - def format_and_extension - (extensions = [format, extension].compact.join(".")).blank? ? nil : extensions - end - memoize :format_and_extension - - def multipart? - format && format.include?('.') - end - - def content_type - format.gsub('.', '/') - end - - def mime_type - Mime::Type.lookup_by_extension(format) if format && defined?(::Mime) - end - memoize :mime_type - - def path - [base_path, [name, locale, format, extension].compact.join('.')].compact.join('/') - end - memoize :path - - def path_without_extension - [base_path, [name, locale, format].compact.join('.')].compact.join('/') - end - memoize :path_without_extension - - def path_without_format_and_extension - [base_path, [name, locale].compact.join('.')].compact.join('/') - end - memoize :path_without_format_and_extension - - def relative_path - path = File.expand_path(filename) - path.sub!(/^#{Regexp.escape(File.expand_path(RAILS_ROOT))}\//, '') if defined?(RAILS_ROOT) - path - end - memoize :relative_path - - def exempt_from_layout? - @@exempt_from_layout.any? { |exempted| path =~ exempted } - end - - def source - File.read(filename) - end - memoize :source - - def method_segment - relative_path.to_s.gsub(/([^a-zA-Z0-9_])/) { $1.ord } - end - memoize :method_segment - - def render_template(view, local_assigns = {}) - render(view, local_assigns) - rescue Exception => e - raise e unless filename - if TemplateError === e - e.sub_template_of(self) - raise e - else - raise TemplateError.new(self, view.assigns, e) - end - end - - def load! - freeze - end - - private - def valid_extension?(extension) - !Template.registered_template_handler(extension).nil? - end - - def valid_locale?(locale) - I18n.available_locales.include?(locale.to_sym) - end - - # Returns file split into an array - # [base_path, name, locale, format, extension] - def split(file) - if m = file.to_s.match(/^(.*\/)?([^\.]+)\.(.*)$/) - base_path = m[1] - name = m[2] - extensions = m[3] - else - return - end - - locale = nil - format = nil - extension = nil - - if m = extensions.split(".") - if valid_locale?(m[0]) && m[1] && valid_extension?(m[2]) # All three - locale = m[0] - format = m[1] - extension = m[2] - elsif m[0] && m[1] && valid_extension?(m[2]) # Multipart formats - format = "#{m[0]}.#{m[1]}" - extension = m[2] - elsif valid_locale?(m[0]) && valid_extension?(m[1]) # locale and extension - locale = m[0] - extension = m[1] - elsif valid_extension?(m[1]) # format and extension - format = m[0] - extension = m[1] - elsif valid_extension?(m[0]) # Just extension - extension = m[0] - else # No extension - format = m[0] - end - end - - [base_path, name, locale, format, extension] - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/template_error.rb b/vendor/rails/actionpack/lib/action_view/template_error.rb deleted file mode 100644 index 37cb1c7..0000000 --- a/vendor/rails/actionpack/lib/action_view/template_error.rb +++ /dev/null @@ -1,99 +0,0 @@ -module ActionView - # The TemplateError exception is raised when the compilation of the template fails. This exception then gathers a - # bunch of intimate details and uses it to report a very precise exception message. - class TemplateError < ActionViewError #:nodoc: - SOURCE_CODE_RADIUS = 3 - - attr_reader :original_exception - - def initialize(template, assigns, original_exception) - @template, @assigns, @original_exception = template, assigns.dup, original_exception - @backtrace = compute_backtrace - end - - def file_name - @template.relative_path - end - - def message - ActiveSupport::Deprecation.silence { original_exception.message } - end - - def clean_backtrace - if defined?(Rails) && Rails.respond_to?(:backtrace_cleaner) - Rails.backtrace_cleaner.clean(original_exception.backtrace) - else - original_exception.backtrace - end - end - - def sub_template_message - if @sub_templates - "Trace of template inclusion: " + - @sub_templates.collect { |template| template.relative_path }.join(", ") - else - "" - end - end - - def source_extract(indentation = 0) - return unless num = line_number - num = num.to_i - - source_code = @template.source.split("\n") - - start_on_line = [ num - SOURCE_CODE_RADIUS - 1, 0 ].max - end_on_line = [ num + SOURCE_CODE_RADIUS - 1, source_code.length].min - - indent = ' ' * indentation - line_counter = start_on_line - return unless source_code = source_code[start_on_line..end_on_line] - - source_code.sum do |line| - line_counter += 1 - "#{indent}#{line_counter}: #{line}\n" - end - end - - def sub_template_of(template_path) - @sub_templates ||= [] - @sub_templates << template_path - end - - def line_number - @line_number ||= - if file_name - regexp = /#{Regexp.escape File.basename(file_name)}:(\d+)/ - - $1 if message =~ regexp or clean_backtrace.find { |line| line =~ regexp } - end - end - - def to_s - "\n#{self.class} (#{message}) #{source_location}:\n" + - "#{source_extract}\n #{clean_backtrace.join("\n ")}\n\n" - end - - # don't do anything nontrivial here. Any raised exception from here becomes fatal - # (and can't be rescued). - def backtrace - @backtrace - end - - private - def compute_backtrace - [ - "#{source_location.capitalize}\n\n#{source_extract(4)}\n " + - clean_backtrace.join("\n ") - ] - end - - def source_location - if line_number - "on line ##{line_number} of " - else - 'in ' - end + file_name - end - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/lib/action_view/template_handler.rb b/vendor/rails/actionpack/lib/action_view/template_handler.rb deleted file mode 100644 index 672da0e..0000000 --- a/vendor/rails/actionpack/lib/action_view/template_handler.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Legacy TemplateHandler stub -module ActionView - module TemplateHandlers #:nodoc: - module Compilable - def self.included(base) - base.extend(ClassMethods) - end - - module ClassMethods - def call(template) - new.compile(template) - end - end - - def compile(template) - raise "Need to implement #{self.class.name}#compile(template)" - end - end - end - - class TemplateHandler - def self.call(template) - "#{name}.new(self).render(template, local_assigns)" - end - - def initialize(view = nil) - @view = view - end - - def render(template, local_assigns) - raise "Need to implement #{self.class.name}#render(template, local_assigns)" - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/template_handlers.rb b/vendor/rails/actionpack/lib/action_view/template_handlers.rb deleted file mode 100644 index 205f862..0000000 --- a/vendor/rails/actionpack/lib/action_view/template_handlers.rb +++ /dev/null @@ -1,48 +0,0 @@ -module ActionView #:nodoc: - module TemplateHandlers #:nodoc: - autoload :ERB, 'action_view/template_handlers/erb' - autoload :RJS, 'action_view/template_handlers/rjs' - autoload :Builder, 'action_view/template_handlers/builder' - - def self.extended(base) - base.register_default_template_handler :erb, TemplateHandlers::ERB - base.register_template_handler :rjs, TemplateHandlers::RJS - base.register_template_handler :builder, TemplateHandlers::Builder - - # TODO: Depreciate old template extensions - base.register_template_handler :rhtml, TemplateHandlers::ERB - base.register_template_handler :rxml, TemplateHandlers::Builder - end - - @@template_handlers = {} - @@default_template_handlers = nil - - # Register a class that knows how to handle template files with the given - # extension. This can be used to implement new template types. - # The constructor for the class must take the ActiveView::Base instance - # as a parameter, and the class must implement a +render+ method that - # takes the contents of the template to render as well as the Hash of - # local assigns available to the template. The +render+ method ought to - # return the rendered template as a string. - def register_template_handler(extension, klass) - @@template_handlers[extension.to_sym] = klass - end - - def template_handler_extensions - @@template_handlers.keys.map(&:to_s).sort - end - - def registered_template_handler(extension) - extension && @@template_handlers[extension.to_sym] - end - - def register_default_template_handler(extension, klass) - register_template_handler(extension, klass) - @@default_template_handlers = klass - end - - def handler_class_for_extension(extension) - registered_template_handler(extension) || @@default_template_handlers - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/template_handlers/builder.rb b/vendor/rails/actionpack/lib/action_view/template_handlers/builder.rb deleted file mode 100644 index 788dc93..0000000 --- a/vendor/rails/actionpack/lib/action_view/template_handlers/builder.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'builder' - -module ActionView - module TemplateHandlers - class Builder < TemplateHandler - include Compilable - - def compile(template) - "_set_controller_content_type(Mime::XML);" + - "xml = ::Builder::XmlMarkup.new(:indent => 2);" + - "self.output_buffer = xml.target!;" + - template.source + - ";xml.target!;" - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/template_handlers/erb.rb b/vendor/rails/actionpack/lib/action_view/template_handlers/erb.rb deleted file mode 100644 index e3120ba..0000000 --- a/vendor/rails/actionpack/lib/action_view/template_handlers/erb.rb +++ /dev/null @@ -1,22 +0,0 @@ -module ActionView - module TemplateHandlers - class ERB < TemplateHandler - include Compilable - - ## - # :singleton-method: - # Specify trim mode for the ERB compiler. Defaults to '-'. - # See ERb documentation for suitable values. - cattr_accessor :erb_trim_mode - self.erb_trim_mode = '-' - - def compile(template) - src = ::ERB.new("<% __in_erb_template=true %>#{template.source}", nil, erb_trim_mode, '@output_buffer').src - - # Ruby 1.9 prepends an encoding to the source. However this is - # useless because you can only set an encoding on the first line - RUBY_VERSION >= '1.9' ? src.sub(/\A#coding:.*\n/, '') : src - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/template_handlers/rjs.rb b/vendor/rails/actionpack/lib/action_view/template_handlers/rjs.rb deleted file mode 100644 index 41a1fdd..0000000 --- a/vendor/rails/actionpack/lib/action_view/template_handlers/rjs.rb +++ /dev/null @@ -1,13 +0,0 @@ -module ActionView - module TemplateHandlers - class RJS < TemplateHandler - include Compilable - - def compile(template) - "@template_format = :html;" + - "controller.response.content_type ||= Mime::JS;" + - "update_page do |page|;#{template.source}\nend" - end - end - end -end diff --git a/vendor/rails/actionpack/lib/action_view/test_case.rb b/vendor/rails/actionpack/lib/action_view/test_case.rb deleted file mode 100644 index ec337bb..0000000 --- a/vendor/rails/actionpack/lib/action_view/test_case.rb +++ /dev/null @@ -1,87 +0,0 @@ -require 'active_support/test_case' - -module ActionView - class Base - alias_method :initialize_without_template_tracking, :initialize - def initialize(*args) - @_rendered = { :template => nil, :partials => Hash.new(0) } - initialize_without_template_tracking(*args) - end - end - - module Renderable - alias_method :render_without_template_tracking, :render - def render(view, local_assigns = {}) - if respond_to?(:path) && !is_a?(InlineTemplate) - rendered = view.instance_variable_get(:@_rendered) - rendered[:partials][self] += 1 if is_a?(RenderablePartial) - rendered[:template] ||= self - end - render_without_template_tracking(view, local_assigns) - end - end - - class TestCase < ActiveSupport::TestCase - include ActionController::TestCase::Assertions - include ActionController::TestProcess - - class_inheritable_accessor :helper_class - @@helper_class = nil - - class << self - def tests(helper_class) - self.helper_class = helper_class - end - - def helper_class - if current_helper_class = read_inheritable_attribute(:helper_class) - current_helper_class - else - self.helper_class = determine_default_helper_class(name) - end - end - - def determine_default_helper_class(name) - name.sub(/Test$/, '').constantize - rescue NameError - nil - end - end - - include ActionView::Helpers - include ActionController::PolymorphicRoutes - include ActionController::RecordIdentifier - - setup :setup_with_helper_class - - def setup_with_helper_class - if helper_class && !self.class.ancestors.include?(helper_class) - self.class.send(:include, helper_class) - end - - self.output_buffer = '' - end - - class TestController < ActionController::Base - attr_accessor :request, :response, :params - - def initialize - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - - @params = {} - send(:initialize_current_url) - end - end - - protected - attr_accessor :output_buffer - - private - def method_missing(selector, *args) - controller = TestController.new - return controller.__send__(selector, *args) if ActionController::Routing::Routes.named_routes.helpers.include?(selector) - super - end - end -end diff --git a/vendor/rails/actionpack/lib/actionpack.rb b/vendor/rails/actionpack/lib/actionpack.rb deleted file mode 100644 index 2fe2832..0000000 --- a/vendor/rails/actionpack/lib/actionpack.rb +++ /dev/null @@ -1 +0,0 @@ -require 'action_pack' diff --git a/vendor/rails/actionpack/test/abstract_unit.rb b/vendor/rails/actionpack/test/abstract_unit.rb deleted file mode 100644 index cdeee93..0000000 --- a/vendor/rails/actionpack/test/abstract_unit.rb +++ /dev/null @@ -1,45 +0,0 @@ -$:.unshift(File.dirname(__FILE__) + '/../lib') -$:.unshift(File.dirname(__FILE__) + '/../../activesupport/lib') -$:.unshift(File.dirname(__FILE__) + '/fixtures/helpers') -$:.unshift(File.dirname(__FILE__) + '/fixtures/alternate_helpers') - -require 'rubygems' -require 'yaml' -require 'stringio' -require 'test/unit' - -gem 'mocha', '>= 0.9.5' -require 'mocha' - -begin - require 'ruby-debug' - Debugger.settings[:autoeval] = true - Debugger.start -rescue LoadError - # Debugging disabled. `gem install ruby-debug` to enable. -end - -require 'action_controller' -require 'action_controller/cgi_ext' -require 'action_controller/test_process' -require 'action_view/test_case' - -# Show backtraces for deprecated behavior for quicker cleanup. -ActiveSupport::Deprecation.debug = true - -ActionController::Base.logger = nil -ActionController::Routing::Routes.reload rescue nil - -ActionController::Base.session_store = nil - -# Register danish language for testing -I18n.backend.store_translations 'da', {} -I18n.backend.store_translations 'pt-BR', {} -ORIGINAL_LOCALES = I18n.available_locales.map(&:to_s).sort - -FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures') -ActionView::Base.cache_template_loading = true -ActionController::Base.view_paths = FIXTURE_LOAD_PATH -CACHED_VIEW_PATHS = ActionView::Base.cache_template_loading? ? - ActionController::Base.view_paths : - ActionController::Base.view_paths.map {|path| ActionView::Template::EagerPath.new(path.to_s)} diff --git a/vendor/rails/actionpack/test/active_record_unit.rb b/vendor/rails/actionpack/test/active_record_unit.rb deleted file mode 100644 index 9e0c660..0000000 --- a/vendor/rails/actionpack/test/active_record_unit.rb +++ /dev/null @@ -1,104 +0,0 @@ -require 'abstract_unit' - -# Define the essentials -class ActiveRecordTestConnector - cattr_accessor :able_to_connect - cattr_accessor :connected - - # Set our defaults - self.connected = false - self.able_to_connect = true -end - -# Try to grab AR -if defined?(ActiveRecord) && defined?(Fixtures) - $stderr.puts 'Active Record is already loaded, running tests' -else - $stderr.print 'Attempting to load Active Record... ' - begin - PATH_TO_AR = "#{File.dirname(__FILE__)}/../../activerecord/lib" - raise LoadError, "#{PATH_TO_AR} doesn't exist" unless File.directory?(PATH_TO_AR) - $LOAD_PATH.unshift PATH_TO_AR - require 'active_record' - require 'active_record/fixtures' - $stderr.puts 'success' - rescue LoadError => e - $stderr.print "failed. Skipping Active Record assertion tests: #{e}" - ActiveRecordTestConnector.able_to_connect = false - end -end -$stderr.flush - - -# Define the rest of the connector -class ActiveRecordTestConnector - class << self - def setup - unless self.connected || !self.able_to_connect - setup_connection - load_schema - require_fixture_models - self.connected = true - end - rescue Exception => e # errors from ActiveRecord setup - $stderr.puts "\nSkipping ActiveRecord assertion tests: #{e}" - #$stderr.puts " #{e.backtrace.join("\n ")}\n" - self.able_to_connect = false - end - - private - def setup_connection - if Object.const_defined?(:ActiveRecord) - defaults = { :database => ':memory:' } - begin - adapter = defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' - options = defaults.merge :adapter => adapter, :timeout => 500 - ActiveRecord::Base.establish_connection(options) - ActiveRecord::Base.configurations = { 'sqlite3_ar_integration' => options } - ActiveRecord::Base.connection - rescue Exception # errors from establishing a connection - $stderr.puts 'SQLite 3 unavailable; trying SQLite 2.' - options = defaults.merge :adapter => 'sqlite' - ActiveRecord::Base.establish_connection(options) - ActiveRecord::Base.configurations = { 'sqlite2_ar_integration' => options } - ActiveRecord::Base.connection - end - - Object.send(:const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')) unless Object.const_defined?(:QUOTED_TYPE) - else - raise "Can't setup connection since ActiveRecord isn't loaded." - end - end - - # Load actionpack sqlite tables - def load_schema - File.read(File.dirname(__FILE__) + "/fixtures/db_definitions/sqlite.sql").split(';').each do |sql| - ActiveRecord::Base.connection.execute(sql) unless sql.blank? - end - end - - def require_fixture_models - Dir.glob(File.dirname(__FILE__) + "/fixtures/*.rb").each {|f| require f} - end - end -end - -class ActiveRecordTestCase < ActionController::TestCase - include ActiveRecord::TestFixtures - - # Set our fixture path - if ActiveRecordTestConnector.able_to_connect - self.fixture_path = [FIXTURE_LOAD_PATH] - self.use_transactional_fixtures = false - end - - def self.fixtures(*args) - super if ActiveRecordTestConnector.connected - end - - def run(*args) - super if ActiveRecordTestConnector.connected - end -end - -ActiveRecordTestConnector.setup diff --git a/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb b/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb deleted file mode 100644 index c98892e..0000000 --- a/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb +++ /dev/null @@ -1,174 +0,0 @@ -require 'active_record_unit' - -class ActiveRecordStoreTest < ActionController::IntegrationTest - DispatcherApp = ActionController::Dispatcher.new - SessionApp = ActiveRecord::SessionStore.new(DispatcherApp, - :key => '_session_id') - SessionAppWithFixation = ActiveRecord::SessionStore.new(DispatcherApp, - :key => '_session_id', :cookie_only => false) - - class TestController < ActionController::Base - def no_session_access - head :ok - end - - def set_session_value - session[:foo] = params[:foo] || "bar" - head :ok - end - - def get_session_value - render :text => "foo: #{session[:foo].inspect}" - end - - def get_session_id - session[:foo] - render :text => "#{request.session_options[:id]}" - end - - def call_reset_session - session[:bar] - reset_session - session[:bar] = "baz" - head :ok - end - - def rescue_action(e) raise end - end - - def setup - ActiveRecord::SessionStore.session_class.create_table! - @integration_session = open_session(SessionApp) - end - - def teardown - ActiveRecord::SessionStore.session_class.drop_table! - end - - def test_setting_and_getting_session_value - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: "bar"', response.body - - get '/set_session_value', :foo => "baz" - assert_response :success - assert cookies['_session_id'] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: "baz"', response.body - end - end - - def test_getting_nil_session_value - with_test_route_set do - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - end - end - - def test_setting_session_value_after_session_reset - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - session_id = cookies['_session_id'] - - get '/call_reset_session' - assert_response :success - assert_not_equal [], headers['Set-Cookie'] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - - get '/get_session_id' - assert_response :success - assert_not_equal session_id, response.body - end - end - - def test_getting_session_id - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - session_id = cookies['_session_id'] - - get '/get_session_id' - assert_response :success - assert_equal session_id, response.body - end - end - - def test_prevents_session_fixation - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: "bar"', response.body - session_id = cookies['_session_id'] - assert session_id - - reset! - - get '/set_session_value', :_session_id => session_id, :foo => "baz" - assert_response :success - assert_equal nil, cookies['_session_id'] - - get '/get_session_value', :_session_id => session_id - assert_response :success - assert_equal 'foo: nil', response.body - assert_equal nil, cookies['_session_id'] - end - end - - def test_allows_session_fixation - @integration_session = open_session(SessionAppWithFixation) - - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: "bar"', response.body - session_id = cookies['_session_id'] - assert session_id - - reset! - @integration_session = open_session(SessionAppWithFixation) - - get '/set_session_value', :_session_id => session_id, :foo => "baz" - assert_response :success - assert_equal session_id, cookies['_session_id'] - - get '/get_session_value', :_session_id => session_id - assert_response :success - assert_equal 'foo: "baz"', response.body - assert_equal session_id, cookies['_session_id'] - end - end - - private - def with_test_route_set - with_routing do |set| - set.draw do |map| - map.with_options :controller => "active_record_store_test/test" do |c| - c.connect "/:action" - end - end - yield - end - end -end diff --git a/vendor/rails/actionpack/test/activerecord/render_partial_with_record_identification_test.rb b/vendor/rails/actionpack/test/activerecord/render_partial_with_record_identification_test.rb deleted file mode 100644 index 0a596c7..0000000 --- a/vendor/rails/actionpack/test/activerecord/render_partial_with_record_identification_test.rb +++ /dev/null @@ -1,188 +0,0 @@ -require 'active_record_unit' - -class RenderPartialWithRecordIdentificationController < ActionController::Base - def render_with_has_many_and_belongs_to_association - @developer = Developer.find(1) - render :partial => @developer.projects - end - - def render_with_has_many_association - @topic = Topic.find(1) - render :partial => @topic.replies - end - - def render_with_named_scope - render :partial => Reply.base - end - - def render_with_has_many_through_association - @developer = Developer.find(:first) - render :partial => @developer.topics - end - - def render_with_has_one_association - @company = Company.find(1) - render :partial => @company.mascot - end - - def render_with_belongs_to_association - @reply = Reply.find(1) - render :partial => @reply.topic - end - - def render_with_record - @developer = Developer.find(:first) - render :partial => @developer - end - - def render_with_record_collection - @developers = Developer.find(:all) - render :partial => @developers - end - - def render_with_record_collection_and_spacer_template - @developer = Developer.find(1) - render :partial => @developer.projects, :spacer_template => 'test/partial_only' - end -end - -class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase - tests RenderPartialWithRecordIdentificationController - fixtures :developers, :projects, :developers_projects, :topics, :replies, :companies, :mascots - - def test_rendering_partial_with_has_many_and_belongs_to_association - get :render_with_has_many_and_belongs_to_association - assert_template 'projects/_project' - assert_equal assigns(:developer).projects.map(&:name).join, @response.body - end - - def test_rendering_partial_with_has_many_association - get :render_with_has_many_association - assert_template 'replies/_reply' - assert_equal 'Birdman is better!', @response.body - end - - def test_rendering_partial_with_named_scope - get :render_with_named_scope - assert_template 'replies/_reply' - assert_equal 'Birdman is better!Nuh uh!', @response.body - end - - def test_render_with_record - get :render_with_record - assert_template 'developers/_developer' - assert_equal 'David', @response.body - end - - def test_render_with_record_collection - get :render_with_record_collection - assert_template 'developers/_developer' - assert_equal 'DavidJamisfixture_3fixture_4fixture_5fixture_6fixture_7fixture_8fixture_9fixture_10Jamis', @response.body - end - - def test_render_with_record_collection_and_spacer_template - get :render_with_record_collection_and_spacer_template - assert_equal assigns(:developer).projects.map(&:name).join('only partial'), @response.body - end - - def test_rendering_partial_with_has_one_association - mascot = Company.find(1).mascot - get :render_with_has_one_association - assert_template 'mascots/_mascot' - assert_equal mascot.name, @response.body - end -end - -class RenderPartialWithRecordIdentificationController < ActionController::Base - def render_with_has_many_and_belongs_to_association - @developer = Developer.find(1) - render :partial => @developer.projects - end - - def render_with_has_many_association - @topic = Topic.find(1) - render :partial => @topic.replies - end - - def render_with_has_many_through_association - @developer = Developer.find(:first) - render :partial => @developer.topics - end - - def render_with_belongs_to_association - @reply = Reply.find(1) - render :partial => @reply.topic - end - - def render_with_record - @developer = Developer.find(:first) - render :partial => @developer - end - - def render_with_record_collection - @developers = Developer.find(:all) - render :partial => @developers - end -end - -class Game < Struct.new(:name, :id) - def to_param - id.to_s - end -end - -module Fun - class NestedController < ActionController::Base - def render_with_record_in_nested_controller - render :partial => Game.new("Pong") - end - - def render_with_record_collection_in_nested_controller - render :partial => [ Game.new("Pong"), Game.new("Tank") ] - end - end - - module Serious - class NestedDeeperController < ActionController::Base - def render_with_record_in_deeper_nested_controller - render :partial => Game.new("Chess") - end - - def render_with_record_collection_in_deeper_nested_controller - render :partial => [ Game.new("Chess"), Game.new("Sudoku"), Game.new("Solitaire") ] - end - end - end -end - -class RenderPartialWithRecordIdentificationAndNestedControllersTest < ActiveRecordTestCase - tests Fun::NestedController - - def test_render_with_record_in_nested_controller - get :render_with_record_in_nested_controller - assert_template 'fun/games/_game' - assert_equal 'Pong', @response.body - end - - def test_render_with_record_collection_in_nested_controller - get :render_with_record_collection_in_nested_controller - assert_template 'fun/games/_game' - assert_equal 'PongTank', @response.body - end -end - -class RenderPartialWithRecordIdentificationAndNestedDeeperControllersTest < ActiveRecordTestCase - tests Fun::Serious::NestedDeeperController - - def test_render_with_record_in_deeper_nested_controller - get :render_with_record_in_deeper_nested_controller - assert_template 'fun/serious/games/_game' - assert_equal 'Chess', @response.body - end - - def test_render_with_record_collection_in_deeper_nested_controller - get :render_with_record_collection_in_deeper_nested_controller - assert_template 'fun/serious/games/_game' - assert_equal 'ChessSudokuSolitaire', @response.body - end -end diff --git a/vendor/rails/actionpack/test/adv_attr_test.rb b/vendor/rails/actionpack/test/adv_attr_test.rb deleted file mode 100644 index fdda4ad..0000000 --- a/vendor/rails/actionpack/test/adv_attr_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' -require 'action_mailer/adv_attr_accessor' - -class AdvAttrTest < Test::Unit::TestCase - class Person - include ActionMailer::AdvAttrAccessor - adv_attr_accessor :name - end - - def test_adv_attr - bob = Person.new - assert_nil bob.name - bob.name 'Bob' - assert_equal 'Bob', bob.name - - assert_raise(ArgumentError) {bob.name 'x', 'y'} - end - - -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb b/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb deleted file mode 100644 index cb7922e..0000000 --- a/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb +++ /dev/null @@ -1,516 +0,0 @@ -require 'abstract_unit' - -# a controller class to facilitate the tests -class ActionPackAssertionsController < ActionController::Base - - # this does absolutely nothing - def nothing() head :ok end - - # a standard template - def hello_world() render :template => "test/hello_world"; end - - # a standard template - def hello_xml_world() render :template => "test/hello_xml_world"; end - - # a redirect to an internal location - def redirect_internal() redirect_to "/nothing"; end - - def redirect_to_action() redirect_to :action => "flash_me", :id => 1, :params => { "panda" => "fun" }; end - - def redirect_to_controller() redirect_to :controller => "elsewhere", :action => "flash_me"; end - - def redirect_to_controller_with_symbol() redirect_to :controller => :elsewhere, :action => :flash_me; end - - def redirect_to_path() redirect_to '/some/path' end - - def redirect_to_named_route() redirect_to route_one_url end - - # a redirect to an external location - def redirect_external() redirect_to "http://www.rubyonrails.org"; end - - # a 404 - def response404() head '404 AWOL' end - - # a 500 - def response500() head '500 Sorry' end - - # a fictional 599 - def response599() head '599 Whoah!' end - - # putting stuff in the flash - def flash_me - flash['hello'] = 'my name is inigo montoya...' - render :text => "Inconceivable!" - end - - # we have a flash, but nothing is in it - def flash_me_naked - flash.clear - render :text => "wow!" - end - - # assign some template instance variables - def assign_this - @howdy = "ho" - render :inline => "Mr. Henke" - end - - def render_based_on_parameters - render :text => "Mr. #{params[:name]}" - end - - def render_url - render :text => "
    #{url_for(:action => 'flash_me', :only_path => true)}
    " - end - - def render_text_with_custom_content_type - render :text => "Hello!", :content_type => Mime::RSS - end - - # puts something in the session - def session_stuffing - session['xmas'] = 'turkey' - render :text => "ho ho ho" - end - - # raises exception on get requests - def raise_on_get - raise "get" if request.get? - render :text => "request method: #{request.env['REQUEST_METHOD']}" - end - - # raises exception on post requests - def raise_on_post - raise "post" if request.post? - render :text => "request method: #{request.env['REQUEST_METHOD']}" - end - - def get_valid_record - @record = Class.new do - def valid? - true - end - - def errors - Class.new do - def full_messages; []; end - end.new - end - - end.new - - render :nothing => true - end - - - def get_invalid_record - @record = Class.new do - - def valid? - false - end - - def errors - Class.new do - def full_messages; ['...stuff...']; end - end.new - end - end.new - - render :nothing => true - end - - # 911 - def rescue_action(e) raise; end -end - -# Used to test that assert_response includes the exception message -# in the failure message when an action raises and assert_response -# is expecting something other than an error. -class AssertResponseWithUnexpectedErrorController < ActionController::Base - def index - raise 'FAIL' - end - - def show - render :text => "Boom", :status => 500 - end -end - -class UserController < ActionController::Base -end - -module Admin - class InnerModuleController < ActionController::Base - def index - render :nothing => true - end - - def redirect_to_index - redirect_to admin_inner_module_path - end - - def redirect_to_absolute_controller - redirect_to :controller => '/content' - end - - def redirect_to_fellow_controller - redirect_to :controller => 'user' - end - - def redirect_to_top_level_named_route - redirect_to top_level_url(:id => "foo") - end - end -end - -# a test case to exercise the new capabilities TestRequest & TestResponse -class ActionPackAssertionsControllerTest < ActionController::TestCase - # let's get this party started - def setup - ActionController::Routing::Routes.reload - ActionController::Routing.use_controllers!(%w(action_pack_assertions admin/inner_module user content admin/user)) - end - - def teardown - ActionController::Routing::Routes.reload - end - - # -- assertion-based testing ------------------------------------------------ - - def test_assert_tag_and_url_for - get :render_url - assert_tag :content => "/action_pack_assertions/flash_me" - end - - # test the get method, make sure the request really was a get - def test_get - assert_raise(RuntimeError) { get :raise_on_get } - get :raise_on_post - assert_equal @response.body, 'request method: GET' - end - - # test the get method, make sure the request really was a get - def test_post - assert_raise(RuntimeError) { post :raise_on_post } - post :raise_on_get - assert_equal @response.body, 'request method: POST' - end - -# the following test fails because the request_method is now cached on the request instance -# test the get/post switch within one test action -# def test_get_post_switch -# post :raise_on_get -# assert_equal @response.body, 'request method: POST' -# get :raise_on_post -# assert_equal @response.body, 'request method: GET' -# post :raise_on_get -# assert_equal @response.body, 'request method: POST' -# get :raise_on_post -# assert_equal @response.body, 'request method: GET' -# end - - # test the redirection to a named route - def test_assert_redirect_to_named_route - with_routing do |set| - set.draw do |map| - map.route_one 'route_one', :controller => 'action_pack_assertions', :action => 'nothing' - map.connect ':controller/:action/:id' - end - set.install_helpers - - process :redirect_to_named_route - assert_redirected_to 'http://test.host/route_one' - assert_redirected_to route_one_url - end - end - - def test_assert_redirect_to_named_route_failure - with_routing do |set| - set.draw do |map| - map.route_one 'route_one', :controller => 'action_pack_assertions', :action => 'nothing', :id => 'one' - map.route_two 'route_two', :controller => 'action_pack_assertions', :action => 'nothing', :id => 'two' - map.connect ':controller/:action/:id' - end - process :redirect_to_named_route - assert_raise(ActiveSupport::TestCase::Assertion) do - assert_redirected_to 'http://test.host/route_two' - end - assert_raise(ActiveSupport::TestCase::Assertion) do - assert_redirected_to :controller => 'action_pack_assertions', :action => 'nothing', :id => 'two' - end - assert_raise(ActiveSupport::TestCase::Assertion) do - assert_redirected_to route_two_url - end - end - end - - def test_assert_redirect_to_nested_named_route - with_routing do |set| - set.draw do |map| - map.admin_inner_module 'admin/inner_module', :controller => 'admin/inner_module', :action => 'index' - map.connect ':controller/:action/:id' - end - @controller = Admin::InnerModuleController.new - process :redirect_to_index - # redirection is <{"action"=>"index", "controller"=>"admin/admin/inner_module"}> - assert_redirected_to admin_inner_module_path - end - end - - def test_assert_redirected_to_top_level_named_route_from_nested_controller - with_routing do |set| - set.draw do |map| - map.top_level '/action_pack_assertions/:id', :controller => 'action_pack_assertions', :action => 'index' - map.connect ':controller/:action/:id' - end - @controller = Admin::InnerModuleController.new - process :redirect_to_top_level_named_route - # assert_redirected_to "http://test.host/action_pack_assertions/foo" would pass because of exact match early return - assert_redirected_to "/action_pack_assertions/foo" - end - end - - def test_assert_redirected_to_top_level_named_route_with_same_controller_name_in_both_namespaces - with_routing do |set| - set.draw do |map| - # this controller exists in the admin namespace as well which is the only difference from previous test - map.top_level '/user/:id', :controller => 'user', :action => 'index' - map.connect ':controller/:action/:id' - end - @controller = Admin::InnerModuleController.new - process :redirect_to_top_level_named_route - # assert_redirected_to top_level_url('foo') would pass because of exact match early return - assert_redirected_to top_level_path('foo') - end - end - - # -- standard request/response object testing -------------------------------- - - # make sure that the template objects exist - def test_template_objects_alive - process :assign_this - assert !@response.has_template_object?('hi') - assert @response.has_template_object?('howdy') - end - - # make sure we don't have template objects when we shouldn't - def test_template_object_missing - process :nothing - assert_nil @response.template_objects['howdy'] - end - - # check the empty flashing - def test_flash_me_naked - process :flash_me_naked - assert !@response.has_flash? - assert !@response.has_flash_with_contents? - end - - # check if we have flash objects - def test_flash_haves - process :flash_me - assert @response.has_flash? - assert @response.has_flash_with_contents? - assert @response.has_flash_object?('hello') - end - - # ensure we don't have flash objects - def test_flash_have_nots - process :nothing - assert !@response.has_flash? - assert !@response.has_flash_with_contents? - assert_nil @response.flash['hello'] - end - - # check if we were rendered by a file-based template? - def test_rendered_action - process :nothing - assert_nil @response.rendered[:template] - - process :hello_world - assert @response.rendered[:template] - assert 'hello_world', @response.rendered[:template].to_s - end - - # check the redirection location - def test_redirection_location - process :redirect_internal - assert_equal 'http://test.host/nothing', @response.redirect_url - - process :redirect_external - assert_equal 'http://www.rubyonrails.org', @response.redirect_url - end - - def test_no_redirect_url - process :nothing - assert_nil @response.redirect_url - end - - - # check server errors - def test_server_error_response_code - process :response500 - assert @response.server_error? - - process :response599 - assert @response.server_error? - - process :response404 - assert !@response.server_error? - end - - # check a 404 response code - def test_missing_response_code - process :response404 - assert @response.missing? - end - - # check client errors - def test_client_error_response_code - process :response404 - assert @response.client_error? - end - - # check to see if our redirection matches a pattern - def test_redirect_url_match - process :redirect_external - assert @response.redirect? - assert @response.redirect_url_match?("rubyonrails") - assert @response.redirect_url_match?(/rubyonrails/) - assert !@response.redirect_url_match?("phpoffrails") - assert !@response.redirect_url_match?(/perloffrails/) - end - - # check for a redirection - def test_redirection - process :redirect_internal - assert @response.redirect? - - process :redirect_external - assert @response.redirect? - - process :nothing - assert !@response.redirect? - end - - # check a successful response code - def test_successful_response_code - process :nothing - assert @response.success? - end - - # a basic check to make sure we have a TestResponse object - def test_has_response - process :nothing - assert_kind_of ActionController::TestResponse, @response - end - - def test_render_based_on_parameters - process :render_based_on_parameters, "name" => "David" - assert_equal "Mr. David", @response.body - end - - - def test_assert_redirection_fails_with_incorrect_controller - process :redirect_to_controller - assert_raise(ActiveSupport::TestCase::Assertion) do - assert_redirected_to :controller => "action_pack_assertions", :action => "flash_me" - end - end - - def test_assert_redirection_with_extra_controller_option - get :redirect_to_action - assert_redirected_to :controller => 'action_pack_assertions', :action => "flash_me", :id => 1, :params => { :panda => 'fun' } - end - - def test_redirected_to_url_leading_slash - process :redirect_to_path - assert_redirected_to '/some/path' - end - - def test_redirected_to_url_no_leadling_slash - process :redirect_to_path - assert_redirected_to 'some/path' - end - - def test_redirected_to_url_full_url - process :redirect_to_path - assert_redirected_to 'http://test.host/some/path' - end - - def test_assert_redirection_with_symbol - process :redirect_to_controller_with_symbol - assert_nothing_raised { - assert_redirected_to :controller => "elsewhere", :action => "flash_me" - } - process :redirect_to_controller_with_symbol - assert_nothing_raised { - assert_redirected_to :controller => :elsewhere, :action => :flash_me - } - end - - def test_redirected_to_with_nested_controller - @controller = Admin::InnerModuleController.new - get :redirect_to_absolute_controller - assert_redirected_to :controller => '/content' - - get :redirect_to_fellow_controller - assert_redirected_to :controller => 'admin/user' - end - - def test_assert_valid - get :get_valid_record - assert_deprecated { assert_valid assigns('record') } - end - - def test_assert_valid_failing - get :get_invalid_record - - begin - assert_deprecated { assert_valid assigns('record') } - assert false - rescue ActiveSupport::TestCase::Assertion => e - end - end - - def test_assert_response_uses_exception_message - @controller = AssertResponseWithUnexpectedErrorController.new - get :index - assert_response :success - flunk 'Expected non-success response' - rescue ActiveSupport::TestCase::Assertion => e - assert e.message.include?('FAIL') - end - - def test_assert_response_failure_response_with_no_exception - @controller = AssertResponseWithUnexpectedErrorController.new - get :show - assert_response :success - flunk 'Expected non-success response' - rescue ActiveSupport::TestCase::Assertion - # success - rescue - flunk "assert_response failed to handle failure response with missing, but optional, exception." - end -end - -class ActionPackHeaderTest < ActionController::TestCase - tests ActionPackAssertionsController - - def test_rendering_xml_sets_content_type - process :hello_xml_world - assert_equal('application/xml; charset=utf-8', @response.headers['Content-Type']) - end - - def test_rendering_xml_respects_content_type - @response.headers['type'] = 'application/pdf' - process :hello_xml_world - assert_equal('application/pdf; charset=utf-8', @response.headers['Content-Type']) - end - - def test_render_text_with_custom_content_type - get :render_text_with_custom_content_type - assert_equal 'application/rss+xml; charset=utf-8', @response.headers['Content-Type'] - end -end diff --git a/vendor/rails/actionpack/test/controller/addresses_render_test.rb b/vendor/rails/actionpack/test/controller/addresses_render_test.rb deleted file mode 100644 index 556b059..0000000 --- a/vendor/rails/actionpack/test/controller/addresses_render_test.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'abstract_unit' - -class Address - def Address.count(conditions = nil, join = nil) - nil - end - - def Address.find_all(arg1, arg2, arg3, arg4) - [] - end - - def self.find(*args) - [] - end -end - -class AddressesTestController < ActionController::Base - def self.controller_name; "addresses"; end - def self.controller_path; "addresses"; end -end - -class AddressesTest < ActionController::TestCase - tests AddressesTestController - - def setup - # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get - # a more accurate simulation of what happens in "real life". - @controller.logger = Logger.new(nil) - - @request.host = "www.nextangle.com" - end - - def test_list - get :list - assert_equal "We only need to get this far!", @response.body.chomp - end -end diff --git a/vendor/rails/actionpack/test/controller/assert_select_test.rb b/vendor/rails/actionpack/test/controller/assert_select_test.rb deleted file mode 100644 index 298c7e4..0000000 --- a/vendor/rails/actionpack/test/controller/assert_select_test.rb +++ /dev/null @@ -1,734 +0,0 @@ -#-- -# Copyright (c) 2006 Assaf Arkin (http://labnotes.org) -# Under MIT and/or CC By license. -#++ - -require 'abstract_unit' -require 'controller/fake_controllers' - - -unless defined?(ActionMailer) - begin - $:.unshift("#{File.dirname(__FILE__)}/../../../actionmailer/lib") - require 'action_mailer' - rescue LoadError => e - raise unless e.message =~ /action_mailer/ - require 'rubygems' - gem 'actionmailer' - end -end - -ActionMailer::Base.template_root = FIXTURE_LOAD_PATH - -class AssertSelectTest < ActionController::TestCase - Assertion = ActiveSupport::TestCase::Assertion - - class AssertSelectMailer < ActionMailer::Base - def test(html) - recipients "test " - from "test@test.host" - subject "Test e-mail" - part :content_type=>"text/html", :body=>html - end - end - - class AssertSelectController < ActionController::Base - def response_with=(content) - @content = content - end - - def response_with(&block) - @update = block - end - - def html() - render :text=>@content, :layout=>false, :content_type=>Mime::HTML - @content = nil - end - - def rjs() - render :update do |page| - @update.call page - end - @update = nil - end - - def xml() - render :text=>@content, :layout=>false, :content_type=>Mime::XML - @content = nil - end - - def rescue_action(e) - raise e - end - end - - tests AssertSelectController - - def setup - ActionMailer::Base.delivery_method = :test - ActionMailer::Base.perform_deliveries = true - ActionMailer::Base.deliveries = [] - end - - def teardown - ActionMailer::Base.deliveries.clear - end - - def assert_failure(message, &block) - e = assert_raise(Assertion, &block) - assert_match(message, e.message) if Regexp === message - assert_equal(message, e.message) if String === message - end - - # - # Test assert select. - # - - def test_assert_select - render_html %Q{
    } - assert_select "div", 2 - assert_failure(/Expected at least 3 elements matching \"div\", found 2/) { assert_select "div", 3 } - assert_failure(/Expected at least 1 element matching \"p\", found 0/) { assert_select "p" } - end - - def test_equality_true_false - render_html %Q{
    } - assert_nothing_raised { assert_select "div" } - assert_raise(Assertion) { assert_select "p" } - assert_nothing_raised { assert_select "div", true } - assert_raise(Assertion) { assert_select "p", true } - assert_raise(Assertion) { assert_select "div", false } - assert_nothing_raised { assert_select "p", false } - end - - def test_equality_string_and_regexp - render_html %Q{
    foo
    foo
    } - assert_nothing_raised { assert_select "div", "foo" } - assert_raise(Assertion) { assert_select "div", "bar" } - assert_nothing_raised { assert_select "div", :text=>"foo" } - assert_raise(Assertion) { assert_select "div", :text=>"bar" } - assert_nothing_raised { assert_select "div", /(foo|bar)/ } - assert_raise(Assertion) { assert_select "div", /foobar/ } - assert_nothing_raised { assert_select "div", :text=>/(foo|bar)/ } - assert_raise(Assertion) { assert_select "div", :text=>/foobar/ } - assert_raise(Assertion) { assert_select "p", :text=>/foobar/ } - end - - def test_equality_of_html - render_html %Q{

    \n"This is not a big problem," he said.\n

    } - text = "\"This is not a big problem,\" he said." - html = "\"This is not a big problem,\" he said." - assert_nothing_raised { assert_select "p", text } - assert_raise(Assertion) { assert_select "p", html } - assert_nothing_raised { assert_select "p", :html=>html } - assert_raise(Assertion) { assert_select "p", :html=>text } - # No stripping for pre. - render_html %Q{
    \n"This is not a big problem," he said.\n
    } - text = "\n\"This is not a big problem,\" he said.\n" - html = "\n\"This is not a big problem,\" he said.\n" - assert_nothing_raised { assert_select "pre", text } - assert_raise(Assertion) { assert_select "pre", html } - assert_nothing_raised { assert_select "pre", :html=>html } - assert_raise(Assertion) { assert_select "pre", :html=>text } - end - - def test_counts - render_html %Q{
    foo
    foo
    } - assert_nothing_raised { assert_select "div", 2 } - assert_failure(/Expected at least 3 elements matching \"div\", found 2/) do - assert_select "div", 3 - end - assert_nothing_raised { assert_select "div", 1..2 } - assert_failure(/Expected between 3 and 4 elements matching \"div\", found 2/) do - assert_select "div", 3..4 - end - assert_nothing_raised { assert_select "div", :count=>2 } - assert_failure(/Expected at least 3 elements matching \"div\", found 2/) do - assert_select "div", :count=>3 - end - assert_nothing_raised { assert_select "div", :minimum=>1 } - assert_nothing_raised { assert_select "div", :minimum=>2 } - assert_failure(/Expected at least 3 elements matching \"div\", found 2/) do - assert_select "div", :minimum=>3 - end - assert_nothing_raised { assert_select "div", :maximum=>2 } - assert_nothing_raised { assert_select "div", :maximum=>3 } - assert_failure(/Expected at most 1 element matching \"div\", found 2/) do - assert_select "div", :maximum=>1 - end - assert_nothing_raised { assert_select "div", :minimum=>1, :maximum=>2 } - assert_failure(/Expected between 3 and 4 elements matching \"div\", found 2/) do - assert_select "div", :minimum=>3, :maximum=>4 - end - end - - def test_substitution_values - render_html %Q{
    foo
    foo
    } - assert_select "div#?", /\d+/ do |elements| - assert_equal 2, elements.size - end - assert_select "div" do - assert_select "div#?", /\d+/ do |elements| - assert_equal 2, elements.size - assert_select "#1" - assert_select "#2" - end - end - end - - def test_nested_assert_select - render_html %Q{
    foo
    foo
    } - assert_select "div" do |elements| - assert_equal 2, elements.size - assert_select elements[0], "#1" - assert_select elements[1], "#2" - end - assert_select "div" do - assert_select "div" do |elements| - assert_equal 2, elements.size - # Testing in a group is one thing - assert_select "#1,#2" - # Testing individually is another. - assert_select "#1" - assert_select "#2" - assert_select "#3", false - end - end - - assert_failure(/Expected at least 1 element matching \"#4\", found 0\./) do - assert_select "div" do - assert_select "#4" - end - end - end - - def test_assert_select_text_match - render_html %Q{
    foo
    bar
    } - assert_select "div" do - assert_nothing_raised { assert_select "div", "foo" } - assert_nothing_raised { assert_select "div", "bar" } - assert_nothing_raised { assert_select "div", /\w*/ } - assert_nothing_raised { assert_select "div", /\w*/, :count=>2 } - assert_raise(Assertion) { assert_select "div", :text=>"foo", :count=>2 } - assert_nothing_raised { assert_select "div", :html=>"bar" } - assert_nothing_raised { assert_select "div", :html=>"bar" } - assert_nothing_raised { assert_select "div", :html=>/\w*/ } - assert_nothing_raised { assert_select "div", :html=>/\w*/, :count=>2 } - assert_raise(Assertion) { assert_select "div", :html=>"foo", :count=>2 } - end - end - - # With single result. - def test_assert_select_from_rjs_with_single_result - render_rjs do |page| - page.replace_html "test", "
    foo
    \n
    foo
    " - end - assert_select "div" do |elements| - assert elements.size == 2 - assert_select "#1" - assert_select "#2" - end - assert_select "div#?", /\d+/ do |elements| - assert_select "#1" - assert_select "#2" - end - end - - # With multiple results. - def test_assert_select_from_rjs_with_multiple_results - render_rjs do |page| - page.replace_html "test", "
    foo
    " - page.replace_html "test2", "
    foo
    " - end - assert_select "div" do |elements| - assert elements.size == 2 - assert_select "#1" - assert_select "#2" - end - end - - def test_assert_select_rjs_for_positioned_insert_should_fail_when_mixing_arguments - render_rjs do |page| - page.insert_html :top, "test1", "
    foo
    " - page.insert_html :bottom, "test2", "
    foo
    " - end - assert_raise(Assertion) {assert_select_rjs :insert, :top, "test2"} - end - - def test_elect_with_xml_namespace_attributes - render_html %Q{} - assert_nothing_raised { assert_select "link[xlink:href=http://nowhere.com]" } - end - - # - # Test css_select. - # - - def test_css_select - render_html %Q{
    } - assert 2, css_select("div").size - assert 0, css_select("p").size - end - - def test_nested_css_select - render_html %Q{
    foo
    foo
    } - assert_select "div#?", /\d+/ do |elements| - assert_equal 1, css_select(elements[0], "div").size - assert_equal 1, css_select(elements[1], "div").size - end - assert_select "div" do - assert_equal 2, css_select("div").size - css_select("div").each do |element| - # Testing as a group is one thing - assert !css_select("#1,#2").empty? - # Testing individually is another - assert !css_select("#1").empty? - assert !css_select("#2").empty? - end - end - end - - # With one result. - def test_css_select_from_rjs_with_single_result - render_rjs do |page| - page.replace_html "test", "
    foo
    \n
    foo
    " - end - assert_equal 2, css_select("div").size - assert_equal 1, css_select("#1").size - assert_equal 1, css_select("#2").size - end - - # With multiple results. - def test_css_select_from_rjs_with_multiple_results - render_rjs do |page| - page.replace_html "test", "
    foo
    " - page.replace_html "test2", "
    foo
    " - end - - assert_equal 2, css_select("div").size - assert_equal 1, css_select("#1").size - assert_equal 1, css_select("#2").size - end - - # - # Test assert_select_rjs. - # - - # Test that we can pick up all statements in the result. - def test_assert_select_rjs_picks_up_all_statements - render_rjs do |page| - page.replace "test", "
    foo
    " - page.replace_html "test2", "
    foo
    " - page.insert_html :top, "test3", "
    foo
    " - end - - found = false - assert_select_rjs do - assert_select "#1" - assert_select "#2" - assert_select "#3" - found = true - end - assert found - end - - # Test that we fail if there is nothing to pick. - def test_assert_select_rjs_fails_if_nothing_to_pick - render_rjs { } - assert_raise(Assertion) { assert_select_rjs } - end - - def test_assert_select_rjs_with_unicode - # Test that non-ascii characters (which are converted into \uXXXX in RJS) are decoded correctly. - render_rjs do |page| - page.replace "test", "
    \343\203\201\343\202\261\343\203\203\343\203\210
    " - end - assert_select_rjs do - str = "#1" - assert_select str, :text => "\343\203\201\343\202\261\343\203\203\343\203\210" - assert_select str, "\343\203\201\343\202\261\343\203\203\343\203\210" - if str.respond_to?(:force_encoding) - str.force_encoding(Encoding::UTF_8) - assert_select str, /\343\203\201..\343\203\210/u - assert_raise(Assertion) { assert_select str, /\343\203\201.\343\203\210/u } - else - assert_select str, Regexp.new("\343\203\201..\343\203\210",0,'U') - assert_raise(Assertion) { assert_select str, Regexp.new("\343\203\201.\343\203\210",0,'U') } - end - end - end - - def test_assert_select_rjs_with_id - # Test that we can pick up all statements in the result. - render_rjs do |page| - page.replace "test1", "
    foo
    " - page.replace_html "test2", "
    foo
    " - page.insert_html :top, "test3", "
    foo
    " - end - assert_select_rjs "test1" do - assert_select "div", 1 - assert_select "#1" - end - assert_select_rjs "test2" do - assert_select "div", 1 - assert_select "#2" - end - assert_select_rjs "test3" do - assert_select "div", 1 - assert_select "#3" - end - assert_raise(Assertion) { assert_select_rjs "test4" } - end - - def test_assert_select_rjs_for_replace - render_rjs do |page| - page.replace "test1", "
    foo
    " - page.replace_html "test2", "
    foo
    " - page.insert_html :top, "test3", "
    foo
    " - end - # Replace. - assert_select_rjs :replace do - assert_select "div", 1 - assert_select "#1" - end - assert_select_rjs :replace, "test1" do - assert_select "div", 1 - assert_select "#1" - end - assert_raise(Assertion) { assert_select_rjs :replace, "test2" } - # Replace HTML. - assert_select_rjs :replace_html do - assert_select "div", 1 - assert_select "#2" - end - assert_select_rjs :replace_html, "test2" do - assert_select "div", 1 - assert_select "#2" - end - assert_raise(Assertion) { assert_select_rjs :replace_html, "test1" } - end - - def test_assert_select_rjs_for_chained_replace - render_rjs do |page| - page['test1'].replace "
    foo
    " - page['test2'].replace_html "
    foo
    " - page.insert_html :top, "test3", "
    foo
    " - end - # Replace. - assert_select_rjs :chained_replace do - assert_select "div", 1 - assert_select "#1" - end - assert_select_rjs :chained_replace, "test1" do - assert_select "div", 1 - assert_select "#1" - end - assert_raise(Assertion) { assert_select_rjs :chained_replace, "test2" } - # Replace HTML. - assert_select_rjs :chained_replace_html do - assert_select "div", 1 - assert_select "#2" - end - assert_select_rjs :chained_replace_html, "test2" do - assert_select "div", 1 - assert_select "#2" - end - assert_raise(Assertion) { assert_select_rjs :replace_html, "test1" } - end - - # Simple remove - def test_assert_select_rjs_for_remove - render_rjs do |page| - page.remove "test1" - end - - assert_select_rjs :remove, "test1" - end - - def test_assert_select_rjs_for_remove_offers_useful_error_when_assertion_fails - render_rjs do |page| - page.remove "test_with_typo" - end - - assert_select_rjs :remove, "test1" - - rescue Assertion - assert_equal "No RJS statement that removes 'test1' was rendered.", $!.message - end - - def test_assert_select_rjs_for_remove_ignores_block - render_rjs do |page| - page.remove "test1" - end - - assert_nothing_raised do - assert_select_rjs :remove, "test1" do - assert_select "p" - end - end - end - - # Simple show - def test_assert_select_rjs_for_show - render_rjs do |page| - page.show "test1" - end - - assert_select_rjs :show, "test1" - end - - def test_assert_select_rjs_for_show_offers_useful_error_when_assertion_fails - render_rjs do |page| - page.show "test_with_typo" - end - - assert_select_rjs :show, "test1" - - rescue Assertion - assert_equal "No RJS statement that shows 'test1' was rendered.", $!.message - end - - def test_assert_select_rjs_for_show_ignores_block - render_rjs do |page| - page.show "test1" - end - - assert_nothing_raised do - assert_select_rjs :show, "test1" do - assert_select "p" - end - end - end - - # Simple hide - def test_assert_select_rjs_for_hide - render_rjs do |page| - page.hide "test1" - end - - assert_select_rjs :hide, "test1" - end - - def test_assert_select_rjs_for_hide_offers_useful_error_when_assertion_fails - render_rjs do |page| - page.hide "test_with_typo" - end - - assert_select_rjs :hide, "test1" - - rescue Assertion - assert_equal "No RJS statement that hides 'test1' was rendered.", $!.message - end - - def test_assert_select_rjs_for_hide_ignores_block - render_rjs do |page| - page.hide "test1" - end - - assert_nothing_raised do - assert_select_rjs :hide, "test1" do - assert_select "p" - end - end - end - - # Simple toggle - def test_assert_select_rjs_for_toggle - render_rjs do |page| - page.toggle "test1" - end - - assert_select_rjs :toggle, "test1" - end - - def test_assert_select_rjs_for_toggle_offers_useful_error_when_assertion_fails - render_rjs do |page| - page.toggle "test_with_typo" - end - - assert_select_rjs :toggle, "test1" - - rescue Assertion - assert_equal "No RJS statement that toggles 'test1' was rendered.", $!.message - end - - def test_assert_select_rjs_for_toggle_ignores_block - render_rjs do |page| - page.toggle "test1" - end - - assert_nothing_raised do - assert_select_rjs :toggle, "test1" do - assert_select "p" - end - end - end - - # Non-positioned insert. - def test_assert_select_rjs_for_nonpositioned_insert - render_rjs do |page| - page.replace "test1", "
    foo
    " - page.replace_html "test2", "
    foo
    " - page.insert_html :top, "test3", "
    foo
    " - end - assert_select_rjs :insert_html do - assert_select "div", 1 - assert_select "#3" - end - assert_select_rjs :insert_html, "test3" do - assert_select "div", 1 - assert_select "#3" - end - assert_raise(Assertion) { assert_select_rjs :insert_html, "test1" } - end - - # Positioned insert. - def test_assert_select_rjs_for_positioned_insert - render_rjs do |page| - page.insert_html :top, "test1", "
    foo
    " - page.insert_html :bottom, "test2", "
    foo
    " - page.insert_html :before, "test3", "
    foo
    " - page.insert_html :after, "test4", "
    foo
    " - end - assert_select_rjs :insert, :top do - assert_select "div", 1 - assert_select "#1" - end - assert_select_rjs :insert, :bottom do - assert_select "div", 1 - assert_select "#2" - end - assert_select_rjs :insert, :before do - assert_select "div", 1 - assert_select "#3" - end - assert_select_rjs :insert, :after do - assert_select "div", 1 - assert_select "#4" - end - assert_select_rjs :insert_html do - assert_select "div", 4 - end - end - - def test_assert_select_rjs_raise_errors - assert_raise(ArgumentError) { assert_select_rjs(:destroy) } - assert_raise(ArgumentError) { assert_select_rjs(:insert, :left) } - end - - # Simple selection from a single result. - def test_nested_assert_select_rjs_with_single_result - render_rjs do |page| - page.replace_html "test", "
    foo
    \n
    foo
    " - end - - assert_select_rjs "test" do |elements| - assert_equal 2, elements.size - assert_select "#1" - assert_select "#2" - end - end - - # Deal with two results. - def test_nested_assert_select_rjs_with_two_results - render_rjs do |page| - page.replace_html "test", "
    foo
    " - page.replace_html "test2", "
    foo
    " - end - - assert_select_rjs "test" do |elements| - assert_equal 1, elements.size - assert_select "#1" - end - - assert_select_rjs "test2" do |elements| - assert_equal 1, elements.size - assert_select "#2" - end - end - - def test_feed_item_encoded - render_xml <<-EOF - - - - - Test 1

    - ]]> -
    -
    - - - Test 2

    - ]]> -
    -
    -
    -
    -EOF - assert_select "channel item description" do - # Test element regardless of wrapper. - assert_select_encoded do - assert_select "p", :count=>2, :text=>/Test/ - end - # Test through encoded wrapper. - assert_select_encoded do - assert_select "encoded p", :count=>2, :text=>/Test/ - end - # Use :root instead (recommended) - assert_select_encoded do - assert_select ":root p", :count=>2, :text=>/Test/ - end - # Test individually. - assert_select "description" do |elements| - assert_select_encoded elements[0] do - assert_select "p", "Test 1" - end - assert_select_encoded elements[1] do - assert_select "p", "Test 2" - end - end - end - - # Test that we only un-encode element itself. - assert_select "channel item" do - assert_select_encoded do - assert_select "p", 0 - end - end - end - - # - # Test assert_select_email - # - - def test_assert_select_email - assert_raise(Assertion) { assert_select_email {} } - AssertSelectMailer.deliver_test "

    foo

    bar

    " - assert_select_email do - assert_select "div:root" do - assert_select "p:first-child", "foo" - assert_select "p:last-child", "bar" - end - end - end - - protected - def render_html(html) - @controller.response_with = html - get :html - end - - def render_rjs(&block) - @controller.response_with &block - get :rjs - end - - def render_xml(xml) - @controller.response_with = xml - get :xml - end -end diff --git a/vendor/rails/actionpack/test/controller/base_test.rb b/vendor/rails/actionpack/test/controller/base_test.rb deleted file mode 100644 index 9523189..0000000 --- a/vendor/rails/actionpack/test/controller/base_test.rb +++ /dev/null @@ -1,217 +0,0 @@ -require 'abstract_unit' -require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late - -# Provide some controller to run the tests on. -module Submodule - class ContainedEmptyController < ActionController::Base - end - class ContainedNonEmptyController < ActionController::Base - def public_action - render :nothing => true - end - - hide_action :hidden_action - def hidden_action - raise "Noooo!" - end - - def another_hidden_action - end - hide_action :another_hidden_action - end - class SubclassedController < ContainedNonEmptyController - hide_action :public_action # Hiding it here should not affect the superclass. - end -end -class EmptyController < ActionController::Base -end -class NonEmptyController < ActionController::Base - def public_action - end - - hide_action :hidden_action - def hidden_action - end -end - -class MethodMissingController < ActionController::Base - - hide_action :shouldnt_be_called - def shouldnt_be_called - raise "NO WAY!" - end - -protected - - def method_missing(selector) - render :text => selector.to_s - end - -end - -class DefaultUrlOptionsController < ActionController::Base - def default_url_options_action - end - - def default_url_options(options = nil) - { :host => 'www.override.com', :action => 'new', :bacon => 'chunky' } - end -end - -class ControllerClassTests < Test::Unit::TestCase - def test_controller_path - assert_equal 'empty', EmptyController.controller_path - assert_equal EmptyController.controller_path, EmptyController.new.controller_path - assert_equal 'submodule/contained_empty', Submodule::ContainedEmptyController.controller_path - assert_equal Submodule::ContainedEmptyController.controller_path, Submodule::ContainedEmptyController.new.controller_path - end - def test_controller_name - assert_equal 'empty', EmptyController.controller_name - assert_equal 'contained_empty', Submodule::ContainedEmptyController.controller_name - end -end - -class ControllerInstanceTests < Test::Unit::TestCase - def setup - @empty = EmptyController.new - @contained = Submodule::ContainedEmptyController.new - @empty_controllers = [@empty, @contained, Submodule::SubclassedController.new] - - @non_empty_controllers = [NonEmptyController.new, - Submodule::ContainedNonEmptyController.new] - end - - def test_action_methods - @empty_controllers.each do |c| - hide_mocha_methods_from_controller(c) - assert_equal Set.new, c.__send__(:action_methods), "#{c.controller_path} should be empty!" - end - @non_empty_controllers.each do |c| - hide_mocha_methods_from_controller(c) - assert_equal Set.new(%w(public_action)), c.__send__(:action_methods), "#{c.controller_path} should not be empty!" - end - end - - protected - # Mocha adds some public instance methods to Object that would be - # considered actions, so explicitly hide_action them. - def hide_mocha_methods_from_controller(controller) - mocha_methods = [ - :expects, :mocha, :mocha_inspect, :reset_mocha, :stubba_object, - :stubba_method, :stubs, :verify, :__metaclass__, :__is_a__, :to_matcher, - ] - controller.class.__send__(:hide_action, *mocha_methods) - end -end - - -class PerformActionTest < ActionController::TestCase - class MockLogger - attr_reader :logged - - def initialize - @logged = [] - end - - def method_missing(method, *args) - @logged << args.first - end - end - - def use_controller(controller_class) - @controller = controller_class.new - - # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get - # a more accurate simulation of what happens in "real life". - @controller.logger = Logger.new(nil) - - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - - @request.host = "www.nextangle.com" - - rescue_action_in_public! - end - - def test_get_on_priv_should_show_selector - use_controller MethodMissingController - get :shouldnt_be_called - assert_response :success - assert_equal 'shouldnt_be_called', @response.body - end - - def test_method_missing_is_not_an_action_name - use_controller MethodMissingController - assert ! @controller.__send__(:action_methods).include?('method_missing') - - get :method_missing - assert_response :success - assert_equal 'method_missing', @response.body - end - - def test_get_on_hidden_should_fail - use_controller NonEmptyController - get :hidden_action - assert_response 404 - - get :another_hidden_action - assert_response 404 - end - - def test_namespaced_action_should_log_module_name - use_controller Submodule::ContainedNonEmptyController - @controller.logger = MockLogger.new - get :public_action - assert_match /Processing\sSubmodule::ContainedNonEmptyController#public_action/, @controller.logger.logged[1] - end -end - -class DefaultUrlOptionsTest < ActionController::TestCase - tests DefaultUrlOptionsController - - def setup - @request.host = 'www.example.com' - rescue_action_in_public! - end - - def test_default_url_options_are_used_if_set - ActionController::Routing::Routes.draw do |map| - map.default_url_options 'default_url_options', :controller => 'default_url_options' - map.connect ':controller/:action/:id' - end - - get :default_url_options_action # Make a dummy request so that the controller is initialized properly. - - assert_equal 'http://www.override.com/default_url_options/new?bacon=chunky', @controller.url_for(:controller => 'default_url_options') - assert_equal 'http://www.override.com/default_url_options?bacon=chunky', @controller.send(:default_url_options_url) - ensure - ActionController::Routing::Routes.load! - end -end - -class EmptyUrlOptionsTest < ActionController::TestCase - tests NonEmptyController - - def setup - @request.host = 'www.example.com' - rescue_action_in_public! - end - - def test_ensure_url_for_works_as_expected_when_called_with_no_options_if_default_url_options_is_not_set - get :public_action - assert_equal "http://www.example.com/non_empty/public_action", @controller.url_for - end -end - -class EnsureNamedRoutesWorksTicket22BugTest < Test::Unit::TestCase - def test_named_routes_still_work - ActionController::Routing::Routes.draw do |map| - map.resources :things - end - EmptyController.send :include, ActionController::UrlWriter - - assert_equal '/things', EmptyController.new.send(:things_path) - ensure - ActionController::Routing::Routes.load! - end -end diff --git a/vendor/rails/actionpack/test/controller/benchmark_test.rb b/vendor/rails/actionpack/test/controller/benchmark_test.rb deleted file mode 100644 index f9100a2..0000000 --- a/vendor/rails/actionpack/test/controller/benchmark_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'abstract_unit' - -# Provide some static controllers. -class BenchmarkedController < ActionController::Base - def public_action - render :nothing => true - end - - def rescue_action(e) - raise e - end -end - -class BenchmarkTest < ActionController::TestCase - tests BenchmarkedController - - class MockLogger - def method_missing(*args) - end - end - - def setup - # benchmark doesn't do anything unless a logger is set - @controller.logger = MockLogger.new - @request.host = "test.actioncontroller.i" - end - - def test_with_http_1_0_request - @request.host = nil - assert_nothing_raised { get :public_action } - end -end diff --git a/vendor/rails/actionpack/test/controller/caching_test.rb b/vendor/rails/actionpack/test/controller/caching_test.rb deleted file mode 100644 index 86dafd9..0000000 --- a/vendor/rails/actionpack/test/controller/caching_test.rb +++ /dev/null @@ -1,690 +0,0 @@ -require 'fileutils' -require 'abstract_unit' - -CACHE_DIR = 'test_cache' -# Don't change '/../temp/' cavalierly or you might hose something you don't want hosed -FILE_STORE_PATH = File.join(File.dirname(__FILE__), '/../temp/', CACHE_DIR) -ActionController::Base.page_cache_directory = FILE_STORE_PATH -ActionController::Base.cache_store = :file_store, FILE_STORE_PATH - -class PageCachingTestController < ActionController::Base - caches_page :ok, :no_content, :if => Proc.new { |c| !c.request.format.json? } - caches_page :found, :not_found - - def ok - head :ok - end - - def no_content - head :no_content - end - - def found - redirect_to :action => 'ok' - end - - def not_found - head :not_found - end - - def custom_path - render :text => "Super soaker" - cache_page("Super soaker", "/index.html") - end - - def expire_custom_path - expire_page("/index.html") - head :ok - end - - def trailing_slash - render :text => "Sneak attack" - end -end - -class PageCachingTest < ActionController::TestCase - def setup - ActionController::Base.perform_caching = true - - ActionController::Routing::Routes.draw do |map| - map.main '', :controller => 'posts' - map.formatted_posts 'posts.:format', :controller => 'posts' - map.resources :posts - map.connect ':controller/:action/:id' - end - - @request = ActionController::TestRequest.new - @request.host = 'hostname.com' - - @response = ActionController::TestResponse.new - @controller = PageCachingTestController.new - - @params = {:controller => 'posts', :action => 'index', :only_path => true, :skip_relative_url_root => true} - @rewriter = ActionController::UrlRewriter.new(@request, @params) - - FileUtils.rm_rf(File.dirname(FILE_STORE_PATH)) - FileUtils.mkdir_p(FILE_STORE_PATH) - end - - def teardown - FileUtils.rm_rf(File.dirname(FILE_STORE_PATH)) - ActionController::Routing::Routes.clear! - ActionController::Base.perform_caching = false - end - - def test_page_caching_resources_saves_to_correct_path_with_extension_even_if_default_route - @params[:format] = 'rss' - assert_equal '/posts.rss', @rewriter.rewrite(@params) - @params[:format] = nil - assert_equal '/', @rewriter.rewrite(@params) - end - - def test_should_cache_get_with_ok_status - get :ok - assert_response :ok - assert_page_cached :ok, "get with ok status should have been cached" - end - - def test_should_cache_with_custom_path - get :custom_path - assert File.exist?("#{FILE_STORE_PATH}/index.html") - end - - def test_should_expire_cache_with_custom_path - get :custom_path - assert File.exist?("#{FILE_STORE_PATH}/index.html") - - get :expire_custom_path - assert !File.exist?("#{FILE_STORE_PATH}/index.html") - end - - def test_should_cache_without_trailing_slash_on_url - @controller.class.cache_page 'cached content', '/page_caching_test/trailing_slash' - assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/trailing_slash.html") - end - - def test_should_cache_with_trailing_slash_on_url - @controller.class.cache_page 'cached content', '/page_caching_test/trailing_slash/' - assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/trailing_slash.html") - end - - def test_should_cache_ok_at_custom_path - @request.stubs(:path).returns("/index.html") - get :ok - assert_response :ok - assert File.exist?("#{FILE_STORE_PATH}/index.html") - end - - [:ok, :no_content, :found, :not_found].each do |status| - [:get, :post, :put, :delete].each do |method| - unless method == :get and status == :ok - define_method "test_shouldnt_cache_#{method}_with_#{status}_status" do - send(method, status) - assert_response status - assert_page_not_cached status, "#{method} with #{status} status shouldn't have been cached" - end - end - end - end - - def test_page_caching_conditional_options - get :ok, :format=>'json' - assert_page_not_cached :ok - end - - private - def assert_page_cached(action, message = "#{action} should have been cached") - assert page_cached?(action), message - end - - def assert_page_not_cached(action, message = "#{action} shouldn't have been cached") - assert !page_cached?(action), message - end - - def page_cached?(action) - File.exist? "#{FILE_STORE_PATH}/page_caching_test/#{action}.html" - end -end - -class ActionCachingTestController < ActionController::Base - caches_action :index, :redirected, :forbidden, :if => Proc.new { |c| !c.request.format.json? }, :expires_in => 1.hour - caches_action :show, :cache_path => 'http://test.host/custom/show' - caches_action :edit, :cache_path => Proc.new { |c| c.params[:id] ? "http://test.host/#{c.params[:id]};edit" : "http://test.host/edit" } - caches_action :with_layout - caches_action :layout_false, :layout => false - - layout 'talk_from_action.erb' - - def index - @cache_this = MockTime.now.to_f.to_s - render :text => @cache_this - end - - def redirected - redirect_to :action => 'index' - end - - def forbidden - render :text => "Forbidden" - response.status = "403 Forbidden" - end - - def with_layout - @cache_this = MockTime.now.to_f.to_s - render :text => @cache_this, :layout => true - end - - alias_method :show, :index - alias_method :edit, :index - alias_method :destroy, :index - alias_method :layout_false, :with_layout - - def expire - expire_action :controller => 'action_caching_test', :action => 'index' - render :nothing => true - end - - def expire_xml - expire_action :controller => 'action_caching_test', :action => 'index', :format => 'xml' - render :nothing => true - end -end - -class MockTime < Time - # Let Time spicy to assure that Time.now != Time.now - def to_f - super+rand - end -end - -class ActionCachingMockController - attr_accessor :mock_url_for - attr_accessor :mock_path - - def initialize - yield self if block_given? - end - - def url_for(*args) - @mock_url_for - end - - def request - mocked_path = @mock_path - Object.new.instance_eval(<<-EVAL) - def path; '#{@mock_path}' end - def format; 'all' end - def cache_format; nil end - self - EVAL - end -end - -class ActionCacheTest < ActionController::TestCase - def setup - reset! - FileUtils.mkdir_p(FILE_STORE_PATH) - @path_class = ActionController::Caching::Actions::ActionCachePath - @mock_controller = ActionCachingMockController.new - end - - def teardown - FileUtils.rm_rf(File.dirname(FILE_STORE_PATH)) - end - - def test_simple_action_cache - get :index - cached_time = content_to_cache - assert_equal cached_time, @response.body - assert fragment_exist?('hostname.com/action_caching_test') - reset! - - get :index - assert_equal cached_time, @response.body - end - - def test_simple_action_not_cached - get :destroy - cached_time = content_to_cache - assert_equal cached_time, @response.body - assert !fragment_exist?('hostname.com/action_caching_test/destroy') - reset! - - get :destroy - assert_not_equal cached_time, @response.body - end - - def test_action_cache_with_layout - get :with_layout - cached_time = content_to_cache - assert_not_equal cached_time, @response.body - assert fragment_exist?('hostname.com/action_caching_test/with_layout') - reset! - - get :with_layout - assert_not_equal cached_time, @response.body - - assert_equal @response.body, read_fragment('hostname.com/action_caching_test/with_layout') - end - - def test_action_cache_with_layout_and_layout_cache_false - get :layout_false - cached_time = content_to_cache - assert_not_equal cached_time, @response.body - assert fragment_exist?('hostname.com/action_caching_test/layout_false') - reset! - - get :layout_false - assert_not_equal cached_time, @response.body - - assert_equal cached_time, read_fragment('hostname.com/action_caching_test/layout_false') - end - - def test_action_cache_conditional_options - old_use_accept_header = ActionController::Base.use_accept_header - ActionController::Base.use_accept_header = true - @request.env['HTTP_ACCEPT'] = 'application/json' - get :index - assert !fragment_exist?('hostname.com/action_caching_test') - ActionController::Base.use_accept_header = old_use_accept_header - end - - def test_action_cache_with_store_options - MockTime.expects(:now).returns(12345).once - @controller.expects(:read_fragment).with('hostname.com/action_caching_test', :expires_in => 1.hour).once - @controller.expects(:write_fragment).with('hostname.com/action_caching_test', '12345.0', :expires_in => 1.hour).once - get :index - end - - def test_action_cache_with_custom_cache_path - get :show - cached_time = content_to_cache - assert_equal cached_time, @response.body - assert fragment_exist?('test.host/custom/show') - reset! - - get :show - assert_equal cached_time, @response.body - end - - def test_action_cache_with_custom_cache_path_in_block - get :edit - assert fragment_exist?('test.host/edit') - reset! - - get :edit, :id => 1 - assert fragment_exist?('test.host/1;edit') - end - - def test_cache_expiration - get :index - cached_time = content_to_cache - reset! - - get :index - assert_equal cached_time, @response.body - reset! - - get :expire - reset! - - get :index - new_cached_time = content_to_cache - assert_not_equal cached_time, @response.body - reset! - - get :index - assert_response :success - assert_equal new_cached_time, @response.body - end - - def test_cache_expiration_isnt_affected_by_request_format - get :index - cached_time = content_to_cache - reset! - - @request.set_REQUEST_URI "/action_caching_test/expire.xml" - get :expire, :format => :xml - reset! - - get :index - new_cached_time = content_to_cache - assert_not_equal cached_time, @response.body - end - - def test_cache_is_scoped_by_subdomain - @request.host = 'jamis.hostname.com' - get :index - jamis_cache = content_to_cache - - reset! - - @request.host = 'david.hostname.com' - get :index - david_cache = content_to_cache - assert_not_equal jamis_cache, @response.body - - reset! - - @request.host = 'jamis.hostname.com' - get :index - assert_equal jamis_cache, @response.body - - reset! - - @request.host = 'david.hostname.com' - get :index - assert_equal david_cache, @response.body - end - - def test_redirect_is_not_cached - get :redirected - assert_response :redirect - reset! - - get :redirected - assert_response :redirect - end - - def test_forbidden_is_not_cached - get :forbidden - assert_response :forbidden - reset! - - get :forbidden - assert_response :forbidden - end - - def test_xml_version_of_resource_is_treated_as_different_cache - with_routing do |set| - set.draw do |map| - map.connect ':controller/:action.:format' - map.connect ':controller/:action' - end - - get :index, :format => 'xml' - cached_time = content_to_cache - assert_equal cached_time, @response.body - assert fragment_exist?('hostname.com/action_caching_test/index.xml') - reset! - - get :index, :format => 'xml' - assert_equal cached_time, @response.body - assert_equal 'application/xml', @response.content_type - reset! - - get :expire_xml - reset! - - get :index, :format => 'xml' - assert_not_equal cached_time, @response.body - end - end - - def test_correct_content_type_is_returned_for_cache_hit - # run it twice to cache it the first time - get :index, :id => 'content-type.xml' - get :index, :id => 'content-type.xml' - assert_equal 'application/xml', @response.content_type - end - - def test_correct_content_type_is_returned_for_cache_hit_on_action_with_string_key - # run it twice to cache it the first time - get :show, :format => 'xml' - get :show, :format => 'xml' - assert_equal 'application/xml', @response.content_type - end - - def test_correct_content_type_is_returned_for_cache_hit_on_action_with_string_key_from_proc - # run it twice to cache it the first time - get :edit, :id => 1, :format => 'xml' - get :edit, :id => 1, :format => 'xml' - assert_equal 'application/xml', @response.content_type - end - - def test_empty_path_is_normalized - @mock_controller.mock_url_for = 'http://example.org/' - @mock_controller.mock_path = '/' - - assert_equal 'example.org/index', @path_class.path_for(@mock_controller, {}) - end - - def test_file_extensions - get :index, :id => 'kitten.jpg' - get :index, :id => 'kitten.jpg' - - assert_response :success - end - - private - def content_to_cache - assigns(:cache_this) - end - - def reset! - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @controller = ActionCachingTestController.new - @request.host = 'hostname.com' - end - - def fragment_exist?(path) - @controller.fragment_exist?(path) - end - - def read_fragment(path) - @controller.read_fragment(path) - end -end - -class FragmentCachingTestController < ActionController::Base - def some_action; end; -end - -class FragmentCachingTest < ActionController::TestCase - def setup - ActionController::Base.perform_caching = true - @store = ActiveSupport::Cache::MemoryStore.new - ActionController::Base.cache_store = @store - @controller = FragmentCachingTestController.new - @params = {:controller => 'posts', :action => 'index'} - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @controller.params = @params - @controller.request = @request - @controller.response = @response - @controller.send(:initialize_current_url) - @controller.send(:initialize_template_class, @response) - @controller.send(:assign_shortcuts, @request, @response) - end - - def test_fragment_cache_key - assert_equal 'views/what a key', @controller.fragment_cache_key('what a key') - assert_equal "views/test.host/fragment_caching_test/some_action", - @controller.fragment_cache_key(:controller => 'fragment_caching_test',:action => 'some_action') - end - - def test_read_fragment_with_caching_enabled - @store.write('views/name', 'value') - assert_equal 'value', @controller.read_fragment('name') - end - - def test_read_fragment_with_caching_disabled - ActionController::Base.perform_caching = false - @store.write('views/name', 'value') - assert_nil @controller.read_fragment('name') - end - - def test_fragment_exist_with_caching_enabled - @store.write('views/name', 'value') - assert @controller.fragment_exist?('name') - assert !@controller.fragment_exist?('other_name') - end - - def test_fragment_exist_with_caching_disabled - ActionController::Base.perform_caching = false - @store.write('views/name', 'value') - assert !@controller.fragment_exist?('name') - assert !@controller.fragment_exist?('other_name') - end - - def test_write_fragment_with_caching_enabled - assert_nil @store.read('views/name') - assert_equal 'value', @controller.write_fragment('name', 'value') - assert_equal 'value', @store.read('views/name') - end - - def test_write_fragment_with_caching_disabled - assert_nil @store.read('views/name') - ActionController::Base.perform_caching = false - assert_equal 'value', @controller.write_fragment('name', 'value') - assert_nil @store.read('views/name') - end - - def test_expire_fragment_with_simple_key - @store.write('views/name', 'value') - @controller.expire_fragment 'name' - assert_nil @store.read('views/name') - end - - def test_expire_fragment_with_regexp - @store.write('views/name', 'value') - @store.write('views/another_name', 'another_value') - @store.write('views/primalgrasp', 'will not expire ;-)') - - @controller.expire_fragment /name/ - - assert_nil @store.read('views/name') - assert_nil @store.read('views/another_name') - assert_equal 'will not expire ;-)', @store.read('views/primalgrasp') - end - - def test_fragment_for_with_disabled_caching - ActionController::Base.perform_caching = false - - @store.write('views/expensive', 'fragment content') - fragment_computed = false - - buffer = 'generated till now -> ' - @controller.fragment_for(buffer, 'expensive') { fragment_computed = true } - - assert fragment_computed - assert_equal 'generated till now -> ', buffer - end - - def test_fragment_for - @store.write('views/expensive', 'fragment content') - fragment_computed = false - - buffer = 'generated till now -> ' - @controller.fragment_for(buffer, 'expensive') { fragment_computed = true } - - assert !fragment_computed - assert_equal 'generated till now -> fragment content', buffer - end -end - -class FunctionalCachingController < ActionController::Base - def fragment_cached - end - - def html_fragment_cached_with_partial - respond_to do |format| - format.html - end - end - - def js_fragment_cached_with_partial - respond_to do |format| - format.js - end - end - - def formatted_fragment_cached - respond_to do |format| - format.html - format.xml - format.js - end - end - - def rescue_action(e) - raise e - end -end - -class FunctionalFragmentCachingTest < ActionController::TestCase - def setup - ActionController::Base.perform_caching = true - @store = ActiveSupport::Cache::MemoryStore.new - ActionController::Base.cache_store = @store - @controller = FunctionalCachingController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def test_fragment_caching - get :fragment_cached - assert_response :success - expected_body = <<-CACHED -Hello -This bit's fragment cached -CACHED - assert_equal expected_body, @response.body - - assert_equal "This bit's fragment cached", @store.read('views/test.host/functional_caching/fragment_cached') - end - - def test_fragment_caching_in_partials - get :html_fragment_cached_with_partial - assert_response :success - assert_match /Fragment caching in a partial/, @response.body - assert_match "Fragment caching in a partial", @store.read('views/test.host/functional_caching/html_fragment_cached_with_partial') - end - - def test_render_inline_before_fragment_caching - get :inline_fragment_cached - assert_response :success - assert_match /Some inline content/, @response.body - assert_match /Some cached content/, @response.body - assert_match "Some cached content", @store.read('views/test.host/functional_caching/inline_fragment_cached') - end - - def test_fragment_caching_in_rjs_partials - xhr :get, :js_fragment_cached_with_partial - assert_response :success - assert_match /Fragment caching in a partial/, @response.body - assert_match "Fragment caching in a partial", @store.read('views/test.host/functional_caching/js_fragment_cached_with_partial') - end - - def test_html_formatted_fragment_caching - get :formatted_fragment_cached, :format => "html" - assert_response :success - expected_body = "\n

    ERB

    \n" - - assert_equal expected_body, @response.body - - assert_equal "

    ERB

    ", @store.read('views/test.host/functional_caching/formatted_fragment_cached') - end - - def test_xml_formatted_fragment_caching - get :formatted_fragment_cached, :format => "xml" - assert_response :success - expected_body = "\n

    Builder

    \n\n" - - assert_equal expected_body, @response.body - - assert_equal "

    Builder

    \n", @store.read('views/test.host/functional_caching/formatted_fragment_cached') - end - - def test_js_formatted_fragment_caching - get :formatted_fragment_cached, :format => "js" - assert_response :success - expected_body = %(title = "Hey";\n$("element_1").visualEffect("highlight");\n) + - %($("element_2").visualEffect("highlight");\nfooter = "Bye";) - assert_equal expected_body, @response.body - - assert_equal ['$("element_1").visualEffect("highlight");', '$("element_2").visualEffect("highlight");'], - @store.read('views/test.host/functional_caching/formatted_fragment_cached') - end -end diff --git a/vendor/rails/actionpack/test/controller/capture_test.rb b/vendor/rails/actionpack/test/controller/capture_test.rb deleted file mode 100644 index 6dfa099..0000000 --- a/vendor/rails/actionpack/test/controller/capture_test.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'abstract_unit' - -class CaptureController < ActionController::Base - def self.controller_name; "test"; end - def self.controller_path; "test"; end - - def content_for - render :layout => "talk_from_action" - end - - def content_for_with_parameter - render :layout => "talk_from_action" - end - - def content_for_concatenated - render :layout => "talk_from_action" - end - - def non_erb_block_content_for - render :layout => "talk_from_action" - end - - def rescue_action(e) raise end -end - -class CaptureTest < ActionController::TestCase - tests CaptureController - - def setup - # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get - # a more accurate simulation of what happens in "real life". - @controller.logger = Logger.new(nil) - - @request.host = "www.nextangle.com" - end - - def test_simple_capture - get :capturing - assert_equal "Dreamy days", @response.body.strip - end - - def test_content_for - get :content_for - assert_equal expected_content_for_output, @response.body - end - - def test_should_concatentate_content_for - get :content_for_concatenated - assert_equal expected_content_for_output, @response.body - end - - def test_should_set_content_for_with_parameter - get :content_for_with_parameter - assert_equal expected_content_for_output, @response.body - end - - def test_non_erb_block_content_for - get :non_erb_block_content_for - assert_equal expected_content_for_output, @response.body - end - - private - def expected_content_for_output - "Putting stuff in the title!\n\nGreat stuff!" - end -end diff --git a/vendor/rails/actionpack/test/controller/content_type_test.rb b/vendor/rails/actionpack/test/controller/content_type_test.rb deleted file mode 100644 index 32c1757..0000000 --- a/vendor/rails/actionpack/test/controller/content_type_test.rb +++ /dev/null @@ -1,168 +0,0 @@ -require 'abstract_unit' - -class ContentTypeController < ActionController::Base - def render_content_type_from_body - response.content_type = Mime::RSS - render :text => "hello world!" - end - - def render_defaults - render :text => "hello world!" - end - - def render_content_type_from_render - render :text => "hello world!", :content_type => Mime::RSS - end - - def render_charset_from_body - response.charset = "utf-16" - render :text => "hello world!" - end - - def render_nil_charset_from_body - response.charset = nil - render :text => "hello world!" - end - - def render_default_for_rhtml - end - - def render_default_for_rxml - end - - def render_default_for_rjs - end - - def render_change_for_rxml - response.content_type = Mime::HTML - render :action => "render_default_for_rxml" - end - - def render_default_content_types_for_respond_to - respond_to do |format| - format.html { render :text => "hello world!" } - format.xml { render :action => "render_default_content_types_for_respond_to.rhtml" } - format.js { render :text => "hello world!" } - format.rss { render :text => "hello world!", :content_type => Mime::XML } - end - end - - def rescue_action(e) raise end -end - -class ContentTypeTest < ActionController::TestCase - tests ContentTypeController - - def setup - # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get - # a more accurate simulation of what happens in "real life". - @controller.logger = Logger.new(nil) - end - - def test_render_defaults - get :render_defaults - assert_equal "utf-8", @response.charset - assert_equal Mime::HTML, @response.content_type - end - - def test_render_changed_charset_default - ContentTypeController.default_charset = "utf-16" - get :render_defaults - assert_equal "utf-16", @response.charset - assert_equal Mime::HTML, @response.content_type - ContentTypeController.default_charset = "utf-8" - end - - def test_content_type_from_body - get :render_content_type_from_body - assert_equal "application/rss+xml", @response.content_type - assert_equal "utf-8", @response.charset - end - - def test_content_type_from_render - get :render_content_type_from_render - assert_equal "application/rss+xml", @response.content_type - assert_equal "utf-8", @response.charset - end - - def test_charset_from_body - get :render_charset_from_body - assert_equal Mime::HTML, @response.content_type - assert_equal "utf-16", @response.charset - end - - def test_nil_charset_from_body - get :render_nil_charset_from_body - assert_equal Mime::HTML, @response.content_type - assert_equal "utf-8", @response.charset, @response.headers.inspect - end - - def test_nil_default_for_rhtml - ContentTypeController.default_charset = nil - get :render_default_for_rhtml - assert_equal Mime::HTML, @response.content_type - assert_nil @response.charset, @response.headers.inspect - ensure - ContentTypeController.default_charset = "utf-8" - end - - def test_default_for_rhtml - get :render_default_for_rhtml - assert_equal Mime::HTML, @response.content_type - assert_equal "utf-8", @response.charset - end - - def test_default_for_rxml - get :render_default_for_rxml - assert_equal Mime::XML, @response.content_type - assert_equal "utf-8", @response.charset - end - - def test_default_for_rjs - xhr :post, :render_default_for_rjs - assert_equal Mime::JS, @response.content_type - assert_equal "utf-8", @response.charset - end - - def test_change_for_rxml - get :render_change_for_rxml - assert_equal Mime::HTML, @response.content_type - assert_equal "utf-8", @response.charset - end -end - -class AcceptBasedContentTypeTest < ActionController::TestCase - - tests ContentTypeController - - def setup - ActionController::Base.use_accept_header = true - end - - def teardown - ActionController::Base.use_accept_header = false - end - - - def test_render_default_content_types_for_respond_to - @request.accept = Mime::HTML.to_s - get :render_default_content_types_for_respond_to - assert_equal Mime::HTML, @response.content_type - - @request.accept = Mime::JS.to_s - get :render_default_content_types_for_respond_to - assert_equal Mime::JS, @response.content_type - end - - def test_render_default_content_types_for_respond_to_with_template - @request.accept = Mime::XML.to_s - get :render_default_content_types_for_respond_to - assert_equal Mime::XML, @response.content_type - end - - def test_render_default_content_types_for_respond_to_with_overwrite - @request.accept = Mime::RSS.to_s - get :render_default_content_types_for_respond_to - assert_equal Mime::XML, @response.content_type - end -end diff --git a/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/admin/user_controller.rb b/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/admin/user_controller.rb deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/user_controller.rb b/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/user_controller.rb deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/rails/actionpack/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb b/vendor/rails/actionpack/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/rails/actionpack/test/controller/cookie_test.rb b/vendor/rails/actionpack/test/controller/cookie_test.rb deleted file mode 100644 index 657be3c..0000000 --- a/vendor/rails/actionpack/test/controller/cookie_test.rb +++ /dev/null @@ -1,111 +0,0 @@ -require 'abstract_unit' - -class CookieTest < ActionController::TestCase - class TestController < ActionController::Base - def authenticate - cookies["user_name"] = "david" - end - - def authenticate_for_fourteen_days - cookies["user_name"] = { "value" => "david", "expires" => Time.utc(2005, 10, 10,5) } - end - - def authenticate_for_fourteen_days_with_symbols - cookies[:user_name] = { :value => "david", :expires => Time.utc(2005, 10, 10,5) } - end - - def set_multiple_cookies - cookies["user_name"] = { "value" => "david", "expires" => Time.utc(2005, 10, 10,5) } - cookies["login"] = "XJ-122" - end - - def access_frozen_cookies - cookies["will"] = "work" - end - - def logout - cookies.delete("user_name") - end - - def delete_cookie_with_path - cookies.delete("user_name", :path => '/beaten') - render :text => "hello world" - end - - def authenticate_with_http_only - cookies["user_name"] = { :value => "david", :httponly => true } - end - - def rescue_action(e) - raise unless ActionView::MissingTemplate # No templates here, and we don't care about the output - end - end - - tests TestController - - def setup - @request.host = "www.nextangle.com" - end - - def test_setting_cookie - get :authenticate - assert_equal ["user_name=david; path=/"], @response.headers["Set-Cookie"] - assert_equal({"user_name" => "david"}, @response.cookies) - end - - def test_setting_cookie_for_fourteen_days - get :authenticate_for_fourteen_days - assert_equal ["user_name=david; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT"], @response.headers["Set-Cookie"] - assert_equal({"user_name" => "david"}, @response.cookies) - end - - def test_setting_cookie_for_fourteen_days_with_symbols - get :authenticate_for_fourteen_days_with_symbols - assert_equal ["user_name=david; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT"], @response.headers["Set-Cookie"] - assert_equal({"user_name" => "david"}, @response.cookies) - end - - def test_setting_cookie_with_http_only - get :authenticate_with_http_only - assert_equal ["user_name=david; path=/; HttpOnly"], @response.headers["Set-Cookie"] - assert_equal({"user_name" => "david"}, @response.cookies) - end - - def test_multiple_cookies - get :set_multiple_cookies - assert_equal 2, @response.cookies.size - assert_equal "user_name=david; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT", @response.headers["Set-Cookie"][0] - assert_equal "login=XJ-122; path=/", @response.headers["Set-Cookie"][1] - assert_equal({"login" => "XJ-122", "user_name" => "david"}, @response.cookies) - end - - def test_setting_test_cookie - assert_nothing_raised { get :access_frozen_cookies } - end - - def test_expiring_cookie - get :logout - assert_equal ["user_name=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT"], @response.headers["Set-Cookie"] - assert_equal({"user_name" => nil}, @response.cookies) - end - - def test_cookiejar_accessor - @request.cookies["user_name"] = "david" - @controller.request = @request - jar = ActionController::CookieJar.new(@controller) - assert_equal "david", jar["user_name"] - assert_equal nil, jar["something_else"] - end - - def test_cookiejar_accessor_with_array_value - @request.cookies["pages"] = %w{1 2 3} - @controller.request = @request - jar = ActionController::CookieJar.new(@controller) - assert_equal %w{1 2 3}, jar["pages"] - end - - def test_delete_cookie_with_path - get :delete_cookie_with_path - assert_equal ["user_name=; path=/beaten; expires=Thu, 01-Jan-1970 00:00:00 GMT"], @response.headers["Set-Cookie"] - end -end diff --git a/vendor/rails/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb b/vendor/rails/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb deleted file mode 100644 index dd69a63..0000000 --- a/vendor/rails/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'abstract_unit' - -class DeprecatedBaseMethodsTest < ActionController::TestCase - class Target < ActionController::Base - def home_url(greeting) - "http://example.com/#{greeting}" - end - - def raises_name_error - this_method_doesnt_exist - end - - def rescue_action(e) raise e end - end - - tests Target - - def test_log_error_silences_deprecation_warnings - get :raises_name_error - rescue => e - assert_not_deprecated { @controller.send :log_error, e } - end - - if defined? Test::Unit::Error - def test_assertion_failed_error_silences_deprecation_warnings - get :raises_name_error - rescue => e - error = Test::Unit::Error.new('testing ur doodz', e) - assert_not_deprecated { error.message } - end - end -end diff --git a/vendor/rails/actionpack/test/controller/dispatcher_test.rb b/vendor/rails/actionpack/test/controller/dispatcher_test.rb deleted file mode 100644 index 7887b71..0000000 --- a/vendor/rails/actionpack/test/controller/dispatcher_test.rb +++ /dev/null @@ -1,103 +0,0 @@ -require 'abstract_unit' - -class DispatcherTest < Test::Unit::TestCase - Dispatcher = ActionController::Dispatcher - - def setup - ENV['REQUEST_METHOD'] = 'GET' - - Dispatcher.middleware = ActionController::MiddlewareStack.new do |middleware| - middlewares = File.expand_path(File.join(File.dirname(__FILE__), "../../lib/action_controller/middlewares.rb")) - middleware.instance_eval(File.read(middlewares)) - end - - # Clear callbacks as they are redefined by Dispatcher#define_dispatcher_callbacks - Dispatcher.instance_variable_set("@prepare_dispatch_callbacks", ActiveSupport::Callbacks::CallbackChain.new) - Dispatcher.instance_variable_set("@before_dispatch_callbacks", ActiveSupport::Callbacks::CallbackChain.new) - Dispatcher.instance_variable_set("@after_dispatch_callbacks", ActiveSupport::Callbacks::CallbackChain.new) - - Dispatcher.stubs(:require_dependency) - end - - def teardown - ENV.delete 'REQUEST_METHOD' - end - - def test_clears_dependencies_after_dispatch_if_in_loading_mode - ActiveSupport::Dependencies.expects(:clear).once - dispatch(false) - end - - def test_reloads_routes_before_dispatch_if_in_loading_mode - ActionController::Routing::Routes.expects(:reload).once - dispatch(false) - end - - def test_leaves_dependencies_after_dispatch_if_not_in_loading_mode - ActionController::Routing::Routes.expects(:reload).never - ActiveSupport::Dependencies.expects(:clear).never - - dispatch - end - - # Stub out dispatch error logger - class << Dispatcher - def log_failsafe_exception(status, exception); end - end - - def test_failsafe_response - Dispatcher.any_instance.expects(:dispatch).raises('b00m') - ActionController::Failsafe.any_instance.expects(:log_failsafe_exception) - - assert_nothing_raised do - assert_equal [ - 500, - {"Content-Type" => "text/html"}, - "

    500 Internal Server Error

    " - ], dispatch - end - end - - def test_prepare_callbacks - a = b = c = nil - Dispatcher.to_prepare { |*args| a = b = c = 1 } - Dispatcher.to_prepare { |*args| b = c = 2 } - Dispatcher.to_prepare { |*args| c = 3 } - - # Ensure to_prepare callbacks are not run when defined - assert_nil a || b || c - - # Run callbacks - Dispatcher.run_prepare_callbacks - - assert_equal 1, a - assert_equal 2, b - assert_equal 3, c - - # Make sure they are only run once - a = b = c = nil - dispatch - assert_nil a || b || c - end - - def test_to_prepare_with_identifier_replaces - a = b = nil - Dispatcher.to_prepare(:unique_id) { |*args| a = b = 1 } - Dispatcher.to_prepare(:unique_id) { |*args| a = 2 } - - Dispatcher.run_prepare_callbacks - assert_equal 2, a - assert_equal nil, b - end - - private - def dispatch(cache_classes = true) - ActionController::Routing::RouteSet.any_instance.stubs(:call).returns([200, {}, 'response']) - Dispatcher.define_dispatcher_callbacks(cache_classes) - Dispatcher.new.call({}) - end - - def assert_subclasses(howmany, klass, message = klass.subclasses.inspect) - assert_equal howmany, klass.subclasses.size, message - end -end diff --git a/vendor/rails/actionpack/test/controller/fake_controllers.rb b/vendor/rails/actionpack/test/controller/fake_controllers.rb deleted file mode 100644 index 75c114c..0000000 --- a/vendor/rails/actionpack/test/controller/fake_controllers.rb +++ /dev/null @@ -1,33 +0,0 @@ -class << Object; alias_method :const_available?, :const_defined?; end - -class ContentController < Class.new(ActionController::Base) -end -class NotAController -end -module Admin - class << self; alias_method :const_available?, :const_defined?; end - class UserController < Class.new(ActionController::Base); end - class NewsFeedController < Class.new(ActionController::Base); end -end - -# For speed test -class SpeedController < ActionController::Base; end -class SearchController < SpeedController; end -class VideosController < SpeedController; end -class VideoFileController < SpeedController; end -class VideoSharesController < SpeedController; end -class VideoAbusesController < SpeedController; end -class VideoUploadsController < SpeedController; end -class VideoVisitsController < SpeedController; end -class UsersController < SpeedController; end -class SettingsController < SpeedController; end -class ChannelsController < SpeedController; end -class ChannelVideosController < SpeedController; end -class SessionsController < SpeedController; end -class LostPasswordsController < SpeedController; end -class PagesController < SpeedController; end - -ActionController::Routing::Routes.draw do |map| - map.route_one 'route_one', :controller => 'elsewhere', :action => 'flash_me' - map.connect ':controller/:action/:id' -end diff --git a/vendor/rails/actionpack/test/controller/fake_models.rb b/vendor/rails/actionpack/test/controller/fake_models.rb deleted file mode 100644 index 0b30c79..0000000 --- a/vendor/rails/actionpack/test/controller/fake_models.rb +++ /dev/null @@ -1,19 +0,0 @@ -class Customer < Struct.new(:name, :id) - def to_param - id.to_s - end -end - -class BadCustomer < Customer -end - -class GoodCustomer < Customer -end - -module Quiz - class Question < Struct.new(:name, :id) - def to_param - id.to_s - end - end -end diff --git a/vendor/rails/actionpack/test/controller/filter_params_test.rb b/vendor/rails/actionpack/test/controller/filter_params_test.rb deleted file mode 100644 index 0b259a7..0000000 --- a/vendor/rails/actionpack/test/controller/filter_params_test.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'abstract_unit' - -class FilterParamController < ActionController::Base -end - -class FilterParamTest < Test::Unit::TestCase - def setup - @controller = FilterParamController.new - end - - def test_filter_parameters - assert FilterParamController.respond_to?(:filter_parameter_logging) - assert !@controller.respond_to?(:filter_parameters) - - FilterParamController.filter_parameter_logging - assert @controller.respond_to?(:filter_parameters) - - test_hashes = [[{},{},[]], - [{'foo'=>nil},{'foo'=>nil},[]], - [{'foo'=>'bar'},{'foo'=>'bar'},[]], - [{'foo'=>'bar'},{'foo'=>'bar'},%w'food'], - [{'foo'=>'bar'},{'foo'=>'[FILTERED]'},%w'foo'], - [{'foo'=>'bar', 'bar'=>'foo'},{'foo'=>'[FILTERED]', 'bar'=>'foo'},%w'foo baz'], - [{'foo'=>'bar', 'baz'=>'foo'},{'foo'=>'[FILTERED]', 'baz'=>'[FILTERED]'},%w'foo baz'], - [{'bar'=>{'foo'=>'bar','bar'=>'foo'}},{'bar'=>{'foo'=>'[FILTERED]','bar'=>'foo'}},%w'fo'], - [{'foo'=>{'foo'=>'bar','bar'=>'foo'}},{'foo'=>'[FILTERED]'},%w'f banana']] - - test_hashes.each do |before_filter, after_filter, filter_words| - FilterParamController.filter_parameter_logging(*filter_words) - assert_equal after_filter, @controller.__send__(:filter_parameters, before_filter) - - filter_words.push('blah') - FilterParamController.filter_parameter_logging(*filter_words) do |key, value| - value.reverse! if key =~ /bargain/ - end - - before_filter['barg'] = {'bargain'=>'gain', 'blah'=>'bar', 'bar'=>{'bargain'=>{'blah'=>'foo'}}} - after_filter['barg'] = {'bargain'=>'niag', 'blah'=>'[FILTERED]', 'bar'=>{'bargain'=>{'blah'=>'[FILTERED]'}}} - - assert_equal after_filter, @controller.__send__(:filter_parameters, before_filter) - end - end - - def test_filter_parameters_is_protected - FilterParamController.filter_parameter_logging(:foo) - assert !FilterParamController.action_methods.include?('filter_parameters') - assert_raise(NoMethodError) { @controller.filter_parameters([{'password' => '[FILTERED]'}]) } - end -end diff --git a/vendor/rails/actionpack/test/controller/filters_test.rb b/vendor/rails/actionpack/test/controller/filters_test.rb deleted file mode 100644 index e83fde2..0000000 --- a/vendor/rails/actionpack/test/controller/filters_test.rb +++ /dev/null @@ -1,885 +0,0 @@ -require 'abstract_unit' - -# FIXME: crashes Ruby 1.9 -class FilterTest < Test::Unit::TestCase - class TestController < ActionController::Base - before_filter :ensure_login - after_filter :clean_up - - def show - render :inline => "ran action" - end - - private - def ensure_login - @ran_filter ||= [] - @ran_filter << "ensure_login" - end - - def clean_up - @ran_after_filter ||= [] - @ran_after_filter << "clean_up" - end - end - - class ChangingTheRequirementsController < TestController - before_filter :ensure_login, :except => [:go_wild] - - def go_wild - render :text => "gobble" - end - end - - class TestMultipleFiltersController < ActionController::Base - before_filter :try_1 - before_filter :try_2 - before_filter :try_3 - - (1..3).each do |i| - define_method "fail_#{i}" do - render :text => i.to_s - end - end - - protected - (1..3).each do |i| - define_method "try_#{i}" do - instance_variable_set :@try, i - if action_name == "fail_#{i}" - head(404) - end - end - end - end - - class RenderingController < ActionController::Base - before_filter :render_something_else - - def show - @ran_action = true - render :inline => "ran action" - end - - private - def render_something_else - render :inline => "something else" - end - end - - class ConditionalFilterController < ActionController::Base - def show - render :inline => "ran action" - end - - def another_action - render :inline => "ran action" - end - - def show_without_filter - render :inline => "ran action without filter" - end - - private - def ensure_login - @ran_filter ||= [] - @ran_filter << "ensure_login" - end - - def clean_up_tmp - @ran_filter ||= [] - @ran_filter << "clean_up_tmp" - end - - def rescue_action(e) raise(e) end - end - - class ConditionalCollectionFilterController < ConditionalFilterController - before_filter :ensure_login, :except => [ :show_without_filter, :another_action ] - end - - class OnlyConditionSymController < ConditionalFilterController - before_filter :ensure_login, :only => :show - end - - class ExceptConditionSymController < ConditionalFilterController - before_filter :ensure_login, :except => :show_without_filter - end - - class BeforeAndAfterConditionController < ConditionalFilterController - before_filter :ensure_login, :only => :show - after_filter :clean_up_tmp, :only => :show - end - - class OnlyConditionProcController < ConditionalFilterController - before_filter(:only => :show) {|c| c.instance_variable_set(:"@ran_proc_filter", true) } - end - - class ExceptConditionProcController < ConditionalFilterController - before_filter(:except => :show_without_filter) {|c| c.instance_variable_set(:"@ran_proc_filter", true) } - end - - class ConditionalClassFilter - def self.filter(controller) controller.instance_variable_set(:"@ran_class_filter", true) end - end - - class OnlyConditionClassController < ConditionalFilterController - before_filter ConditionalClassFilter, :only => :show - end - - class ExceptConditionClassController < ConditionalFilterController - before_filter ConditionalClassFilter, :except => :show_without_filter - end - - class AnomolousYetValidConditionController < ConditionalFilterController - before_filter(ConditionalClassFilter, :ensure_login, Proc.new {|c| c.instance_variable_set(:"@ran_proc_filter1", true)}, :except => :show_without_filter) { |c| c.instance_variable_set(:"@ran_proc_filter2", true)} - end - - class ConditionalOptionsFilter < ConditionalFilterController - before_filter :ensure_login, :if => Proc.new { |c| true } - before_filter :clean_up_tmp, :if => Proc.new { |c| false } - end - - class EmptyFilterChainController < TestController - self.filter_chain.clear - def show - @action_executed = true - render :text => "yawp!" - end - end - - class PrependingController < TestController - prepend_before_filter :wonderful_life - # skip_before_filter :fire_flash - - private - def wonderful_life - @ran_filter ||= [] - @ran_filter << "wonderful_life" - end - end - - class SkippingAndLimitedController < TestController - skip_before_filter :ensure_login - before_filter :ensure_login, :only => :index - - def index - render :text => 'ok' - end - - def public - end - end - - class SkippingAndReorderingController < TestController - skip_before_filter :ensure_login - before_filter :find_record - before_filter :ensure_login - - private - def find_record - @ran_filter ||= [] - @ran_filter << "find_record" - end - end - - class ConditionalSkippingController < TestController - skip_before_filter :ensure_login, :only => [ :login ] - skip_after_filter :clean_up, :only => [ :login ] - - before_filter :find_user, :only => [ :change_password ] - - def login - render :inline => "ran action" - end - - def change_password - render :inline => "ran action" - end - - protected - def find_user - @ran_filter ||= [] - @ran_filter << "find_user" - end - end - - class ConditionalParentOfConditionalSkippingController < ConditionalFilterController - before_filter :conditional_in_parent, :only => [:show, :another_action] - after_filter :conditional_in_parent, :only => [:show, :another_action] - - private - - def conditional_in_parent - @ran_filter ||= [] - @ran_filter << 'conditional_in_parent' - end - end - - class ChildOfConditionalParentController < ConditionalParentOfConditionalSkippingController - skip_before_filter :conditional_in_parent, :only => :another_action - skip_after_filter :conditional_in_parent, :only => :another_action - end - - class AnotherChildOfConditionalParentController < ConditionalParentOfConditionalSkippingController - skip_before_filter :conditional_in_parent, :only => :show - end - - class ProcController < PrependingController - before_filter(proc { |c| c.instance_variable_set(:"@ran_proc_filter", true) }) - end - - class ImplicitProcController < PrependingController - before_filter { |c| c.instance_variable_set(:"@ran_proc_filter", true) } - end - - class AuditFilter - def self.filter(controller) - controller.instance_variable_set(:"@was_audited", true) - end - end - - class AroundFilter - def before(controller) - @execution_log = "before" - controller.class.execution_log << " before aroundfilter " if controller.respond_to? :execution_log - controller.instance_variable_set(:"@before_ran", true) - end - - def after(controller) - controller.instance_variable_set(:"@execution_log", @execution_log + " and after") - controller.instance_variable_set(:"@after_ran", true) - controller.class.execution_log << " after aroundfilter " if controller.respond_to? :execution_log - end - end - - class AppendedAroundFilter - def before(controller) - controller.class.execution_log << " before appended aroundfilter " - end - - def after(controller) - controller.class.execution_log << " after appended aroundfilter " - end - end - - class AuditController < ActionController::Base - before_filter(AuditFilter) - - def show - render :text => "hello" - end - end - - class AroundFilterController < PrependingController - around_filter AroundFilter.new - end - - class BeforeAfterClassFilterController < PrependingController - begin - filter = AroundFilter.new - before_filter filter - after_filter filter - end - end - - class MixedFilterController < PrependingController - cattr_accessor :execution_log - - def initialize - @@execution_log = "" - end - - before_filter { |c| c.class.execution_log << " before procfilter " } - prepend_around_filter AroundFilter.new - - after_filter { |c| c.class.execution_log << " after procfilter " } - append_around_filter AppendedAroundFilter.new - end - - class MixedSpecializationController < ActionController::Base - class OutOfOrder < StandardError; end - - before_filter :first - before_filter :second, :only => :foo - - def foo - render :text => 'foo' - end - - def bar - render :text => 'bar' - end - - protected - def first - @first = true - end - - def second - raise OutOfOrder unless @first - end - end - - class DynamicDispatchController < ActionController::Base - before_filter :choose - - %w(foo bar baz).each do |action| - define_method(action) { render :text => action } - end - - private - def choose - self.action_name = params[:choose] - end - end - - class PrependingBeforeAndAfterController < ActionController::Base - prepend_before_filter :before_all - prepend_after_filter :after_all - before_filter :between_before_all_and_after_all - - def before_all - @ran_filter ||= [] - @ran_filter << 'before_all' - end - - def after_all - @ran_filter ||= [] - @ran_filter << 'after_all' - end - - def between_before_all_and_after_all - @ran_filter ||= [] - @ran_filter << 'between_before_all_and_after_all' - end - def show - render :text => 'hello' - end - end - - class ErrorToRescue < Exception; end - - class RescuingAroundFilterWithBlock - def filter(controller) - begin - yield - rescue ErrorToRescue => ex - controller.__send__ :render, :text => "I rescued this: #{ex.inspect}" - end - end - end - - class RescuedController < ActionController::Base - around_filter RescuingAroundFilterWithBlock.new - - def show - raise ErrorToRescue.new("Something made the bad noise.") - end - - private - def rescue_action(exception) - raise exception - end - end - - class NonYieldingAroundFilterController < ActionController::Base - - before_filter :filter_one - around_filter :non_yielding_filter - before_filter :filter_two - after_filter :filter_three - - def index - render :inline => "index" - end - - #make sure the controller complains - def rescue_action(e); raise e; end - - private - - def filter_one - @filters ||= [] - @filters << "filter_one" - end - - def filter_two - @filters << "filter_two" - end - - def non_yielding_filter - @filters << "zomg it didn't yield" - @filter_return_value - end - - def filter_three - @filters << "filter_three" - end - - end - - def test_non_yielding_around_filters_not_returning_false_do_not_raise - controller = NonYieldingAroundFilterController.new - controller.instance_variable_set "@filter_return_value", true - assert_nothing_raised do - test_process(controller, "index") - end - end - - def test_non_yielding_around_filters_returning_false_do_not_raise - controller = NonYieldingAroundFilterController.new - controller.instance_variable_set "@filter_return_value", false - assert_nothing_raised do - test_process(controller, "index") - end - end - - def test_after_filters_are_not_run_if_around_filter_returns_false - controller = NonYieldingAroundFilterController.new - controller.instance_variable_set "@filter_return_value", false - test_process(controller, "index") - assert_equal ["filter_one", "zomg it didn't yield"], controller.assigns['filters'] - end - - def test_after_filters_are_not_run_if_around_filter_does_not_yield - controller = NonYieldingAroundFilterController.new - controller.instance_variable_set "@filter_return_value", true - test_process(controller, "index") - assert_equal ["filter_one", "zomg it didn't yield"], controller.assigns['filters'] - end - - def test_empty_filter_chain - assert_equal 0, EmptyFilterChainController.filter_chain.size - assert test_process(EmptyFilterChainController).template.assigns['action_executed'] - end - - def test_added_filter_to_inheritance_graph - assert_equal [ :ensure_login ], TestController.before_filters - end - - def test_base_class_in_isolation - assert_equal [ ], ActionController::Base.before_filters - end - - def test_prepending_filter - assert_equal [ :wonderful_life, :ensure_login ], PrependingController.before_filters - end - - def test_running_filters - assert_equal %w( wonderful_life ensure_login ), test_process(PrependingController).template.assigns["ran_filter"] - end - - def test_running_filters_with_proc - assert test_process(ProcController).template.assigns["ran_proc_filter"] - end - - def test_running_filters_with_implicit_proc - assert test_process(ImplicitProcController).template.assigns["ran_proc_filter"] - end - - def test_running_filters_with_class - assert test_process(AuditController).template.assigns["was_audited"] - end - - def test_running_anomolous_yet_valid_condition_filters - response = test_process(AnomolousYetValidConditionController) - assert_equal %w( ensure_login ), response.template.assigns["ran_filter"] - assert response.template.assigns["ran_class_filter"] - assert response.template.assigns["ran_proc_filter1"] - assert response.template.assigns["ran_proc_filter2"] - - response = test_process(AnomolousYetValidConditionController, "show_without_filter") - assert_equal nil, response.template.assigns["ran_filter"] - assert !response.template.assigns["ran_class_filter"] - assert !response.template.assigns["ran_proc_filter1"] - assert !response.template.assigns["ran_proc_filter2"] - end - - def test_running_conditional_options - response = test_process(ConditionalOptionsFilter) - assert_equal %w( ensure_login ), response.template.assigns["ran_filter"] - end - - def test_running_collection_condition_filters - assert_equal %w( ensure_login ), test_process(ConditionalCollectionFilterController).template.assigns["ran_filter"] - assert_equal nil, test_process(ConditionalCollectionFilterController, "show_without_filter").template.assigns["ran_filter"] - assert_equal nil, test_process(ConditionalCollectionFilterController, "another_action").template.assigns["ran_filter"] - end - - def test_running_only_condition_filters - assert_equal %w( ensure_login ), test_process(OnlyConditionSymController).template.assigns["ran_filter"] - assert_equal nil, test_process(OnlyConditionSymController, "show_without_filter").template.assigns["ran_filter"] - - assert test_process(OnlyConditionProcController).template.assigns["ran_proc_filter"] - assert !test_process(OnlyConditionProcController, "show_without_filter").template.assigns["ran_proc_filter"] - - assert test_process(OnlyConditionClassController).template.assigns["ran_class_filter"] - assert !test_process(OnlyConditionClassController, "show_without_filter").template.assigns["ran_class_filter"] - end - - def test_running_except_condition_filters - assert_equal %w( ensure_login ), test_process(ExceptConditionSymController).template.assigns["ran_filter"] - assert_equal nil, test_process(ExceptConditionSymController, "show_without_filter").template.assigns["ran_filter"] - - assert test_process(ExceptConditionProcController).template.assigns["ran_proc_filter"] - assert !test_process(ExceptConditionProcController, "show_without_filter").template.assigns["ran_proc_filter"] - - assert test_process(ExceptConditionClassController).template.assigns["ran_class_filter"] - assert !test_process(ExceptConditionClassController, "show_without_filter").template.assigns["ran_class_filter"] - end - - def test_running_before_and_after_condition_filters - assert_equal %w( ensure_login clean_up_tmp), test_process(BeforeAndAfterConditionController).template.assigns["ran_filter"] - assert_equal nil, test_process(BeforeAndAfterConditionController, "show_without_filter").template.assigns["ran_filter"] - end - - def test_around_filter - controller = test_process(AroundFilterController) - assert controller.template.assigns["before_ran"] - assert controller.template.assigns["after_ran"] - end - - def test_before_after_class_filter - controller = test_process(BeforeAfterClassFilterController) - assert controller.template.assigns["before_ran"] - assert controller.template.assigns["after_ran"] - end - - def test_having_properties_in_around_filter - controller = test_process(AroundFilterController) - assert_equal "before and after", controller.template.assigns["execution_log"] - end - - def test_prepending_and_appending_around_filter - controller = test_process(MixedFilterController) - assert_equal " before aroundfilter before procfilter before appended aroundfilter " + - " after appended aroundfilter after aroundfilter after procfilter ", - MixedFilterController.execution_log - end - - def test_rendering_breaks_filtering_chain - response = test_process(RenderingController) - assert_equal "something else", response.body - assert !response.template.assigns["ran_action"] - end - - def test_filters_with_mixed_specialization_run_in_order - assert_nothing_raised do - response = test_process(MixedSpecializationController, 'bar') - assert_equal 'bar', response.body - end - - assert_nothing_raised do - response = test_process(MixedSpecializationController, 'foo') - assert_equal 'foo', response.body - end - end - - def test_dynamic_dispatch - %w(foo bar baz).each do |action| - request = ActionController::TestRequest.new - request.query_parameters[:choose] = action - response = DynamicDispatchController.process(request, ActionController::TestResponse.new) - assert_equal action, response.body - end - end - - def test_running_prepended_before_and_after_filter - assert_equal 3, PrependingBeforeAndAfterController.filter_chain.length - response = test_process(PrependingBeforeAndAfterController) - assert_equal %w( before_all between_before_all_and_after_all after_all ), response.template.assigns["ran_filter"] - end - - def test_skipping_and_limiting_controller - assert_equal %w( ensure_login ), test_process(SkippingAndLimitedController, "index").template.assigns["ran_filter"] - assert_nil test_process(SkippingAndLimitedController, "public").template.assigns["ran_filter"] - end - - def test_skipping_and_reordering_controller - assert_equal %w( find_record ensure_login ), test_process(SkippingAndReorderingController, "index").template.assigns["ran_filter"] - end - - def test_conditional_skipping_of_filters - assert_nil test_process(ConditionalSkippingController, "login").template.assigns["ran_filter"] - assert_equal %w( ensure_login find_user ), test_process(ConditionalSkippingController, "change_password").template.assigns["ran_filter"] - - assert_nil test_process(ConditionalSkippingController, "login").template.controller.instance_variable_get("@ran_after_filter") - assert_equal %w( clean_up ), test_process(ConditionalSkippingController, "change_password").template.controller.instance_variable_get("@ran_after_filter") - end - - def test_conditional_skipping_of_filters_when_parent_filter_is_also_conditional - assert_equal %w( conditional_in_parent conditional_in_parent ), test_process(ChildOfConditionalParentController).template.assigns['ran_filter'] - assert_nil test_process(ChildOfConditionalParentController, 'another_action').template.assigns['ran_filter'] - end - - def test_condition_skipping_of_filters_when_siblings_also_have_conditions - assert_equal %w( conditional_in_parent conditional_in_parent ), test_process(ChildOfConditionalParentController).template.assigns['ran_filter'], "1" - assert_equal nil, test_process(AnotherChildOfConditionalParentController).template.assigns['ran_filter'] - assert_equal %w( conditional_in_parent conditional_in_parent ), test_process(ChildOfConditionalParentController).template.assigns['ran_filter'] - end - - def test_changing_the_requirements - assert_equal nil, test_process(ChangingTheRequirementsController, "go_wild").template.assigns['ran_filter'] - end - - def test_a_rescuing_around_filter - response = nil - assert_nothing_raised do - response = test_process(RescuedController) - end - - assert response.success? - assert_equal("I rescued this: #", response.body) - end - - private - def test_process(controller, action = "show") - ActionController::Base.class_eval { include ActionController::ProcessWithTest } unless ActionController::Base < ActionController::ProcessWithTest - request = ActionController::TestRequest.new - request.action = action - controller = controller.new if controller.is_a?(Class) - controller.process_with_test(request, ActionController::TestResponse.new) - end -end - - - -class PostsController < ActionController::Base - def rescue_action(e); raise e; end - - module AroundExceptions - class Error < StandardError ; end - class Before < Error ; end - class After < Error ; end - end - include AroundExceptions - - class DefaultFilter - include AroundExceptions - end - - module_eval %w(raises_before raises_after raises_both no_raise no_filter).map { |action| "def #{action}; default_action end" }.join("\n") - - private - def default_action - render :inline => "#{action_name} called" - end -end - -class ControllerWithSymbolAsFilter < PostsController - around_filter :raise_before, :only => :raises_before - around_filter :raise_after, :only => :raises_after - around_filter :without_exception, :only => :no_raise - - private - def raise_before - raise Before - yield - end - - def raise_after - yield - raise After - end - - def without_exception - # Do stuff... - 1 + 1 - - yield - - # Do stuff... - 1 + 1 - end -end - -class ControllerWithFilterClass < PostsController - class YieldingFilter < DefaultFilter - def self.filter(controller) - yield - raise After - end - end - - around_filter YieldingFilter, :only => :raises_after -end - -class ControllerWithFilterInstance < PostsController - class YieldingFilter < DefaultFilter - def filter(controller) - yield - raise After - end - end - - around_filter YieldingFilter.new, :only => :raises_after -end - -class ControllerWithFilterMethod < PostsController - class YieldingFilter < DefaultFilter - def filter(controller) - yield - raise After - end - end - - around_filter YieldingFilter.new.method(:filter), :only => :raises_after -end - -class ControllerWithProcFilter < PostsController - around_filter(:only => :no_raise) do |c,b| - c.instance_variable_set(:"@before", true) - b.call - c.instance_variable_set(:"@after", true) - end -end - -class ControllerWithNestedFilters < ControllerWithSymbolAsFilter - around_filter :raise_before, :raise_after, :without_exception, :only => :raises_both -end - -class ControllerWithAllTypesOfFilters < PostsController - before_filter :before - around_filter :around - after_filter :after - around_filter :around_again - - private - def before - @ran_filter ||= [] - @ran_filter << 'before' - end - - def around - @ran_filter << 'around (before yield)' - yield - @ran_filter << 'around (after yield)' - end - - def after - @ran_filter << 'after' - end - - def around_again - @ran_filter << 'around_again (before yield)' - yield - @ran_filter << 'around_again (after yield)' - end -end - -class ControllerWithTwoLessFilters < ControllerWithAllTypesOfFilters - skip_filter :around_again - skip_filter :after -end - -class YieldingAroundFiltersTest < Test::Unit::TestCase - include PostsController::AroundExceptions - - def test_filters_registering - assert_equal 1, ControllerWithFilterMethod.filter_chain.size - assert_equal 1, ControllerWithFilterClass.filter_chain.size - assert_equal 1, ControllerWithFilterInstance.filter_chain.size - assert_equal 3, ControllerWithSymbolAsFilter.filter_chain.size - assert_equal 6, ControllerWithNestedFilters.filter_chain.size - assert_equal 4, ControllerWithAllTypesOfFilters.filter_chain.size - end - - def test_base - controller = PostsController - assert_nothing_raised { test_process(controller,'no_raise') } - assert_nothing_raised { test_process(controller,'raises_before') } - assert_nothing_raised { test_process(controller,'raises_after') } - assert_nothing_raised { test_process(controller,'no_filter') } - end - - def test_with_symbol - controller = ControllerWithSymbolAsFilter - assert_nothing_raised { test_process(controller,'no_raise') } - assert_raise(Before) { test_process(controller,'raises_before') } - assert_raise(After) { test_process(controller,'raises_after') } - assert_nothing_raised { test_process(controller,'no_raise') } - end - - def test_with_class - controller = ControllerWithFilterClass - assert_nothing_raised { test_process(controller,'no_raise') } - assert_raise(After) { test_process(controller,'raises_after') } - end - - def test_with_instance - controller = ControllerWithFilterInstance - assert_nothing_raised { test_process(controller,'no_raise') } - assert_raise(After) { test_process(controller,'raises_after') } - end - - def test_with_method - controller = ControllerWithFilterMethod - assert_nothing_raised { test_process(controller,'no_raise') } - assert_raise(After) { test_process(controller,'raises_after') } - end - - def test_with_proc - controller = test_process(ControllerWithProcFilter,'no_raise') - assert controller.template.assigns['before'] - assert controller.template.assigns['after'] - end - - def test_nested_filters - controller = ControllerWithNestedFilters - assert_nothing_raised do - begin - test_process(controller,'raises_both') - rescue Before, After - end - end - assert_raise Before do - begin - test_process(controller,'raises_both') - rescue After - end - end - end - - def test_filter_order_with_all_filter_types - controller = test_process(ControllerWithAllTypesOfFilters,'no_raise') - assert_equal 'before around (before yield) around_again (before yield) around_again (after yield) around (after yield) after',controller.template.assigns['ran_filter'].join(' ') - end - - def test_filter_order_with_skip_filter_method - controller = test_process(ControllerWithTwoLessFilters,'no_raise') - assert_equal 'before around (before yield) around (after yield)',controller.template.assigns['ran_filter'].join(' ') - end - - def test_first_filter_in_multiple_before_filter_chain_halts - controller = ::FilterTest::TestMultipleFiltersController.new - response = test_process(controller, 'fail_1') - assert_equal ' ', response.body - assert_equal 1, controller.instance_variable_get(:@try) - assert controller.instance_variable_get(:@before_filter_chain_aborted) - end - - def test_second_filter_in_multiple_before_filter_chain_halts - controller = ::FilterTest::TestMultipleFiltersController.new - response = test_process(controller, 'fail_2') - assert_equal ' ', response.body - assert_equal 2, controller.instance_variable_get(:@try) - assert controller.instance_variable_get(:@before_filter_chain_aborted) - end - - def test_last_filter_in_multiple_before_filter_chain_halts - controller = ::FilterTest::TestMultipleFiltersController.new - response = test_process(controller, 'fail_3') - assert_equal ' ', response.body - assert_equal 3, controller.instance_variable_get(:@try) - assert controller.instance_variable_get(:@before_filter_chain_aborted) - end - - protected - def test_process(controller, action = "show") - ActionController::Base.class_eval { include ActionController::ProcessWithTest } unless ActionController::Base < ActionController::ProcessWithTest - request = ActionController::TestRequest.new - request.action = action - controller = controller.new if controller.is_a?(Class) - controller.process_with_test(request, ActionController::TestResponse.new) - end -end diff --git a/vendor/rails/actionpack/test/controller/flash_test.rb b/vendor/rails/actionpack/test/controller/flash_test.rb deleted file mode 100644 index d8a8928..0000000 --- a/vendor/rails/actionpack/test/controller/flash_test.rb +++ /dev/null @@ -1,142 +0,0 @@ -require 'abstract_unit' - -class FlashTest < ActionController::TestCase - class TestController < ActionController::Base - def set_flash - flash["that"] = "hello" - render :inline => "hello" - end - - def set_flash_now - flash.now["that"] = "hello" - flash.now["foo"] ||= "bar" - flash.now["foo"] ||= "err" - @flashy = flash.now["that"] - @flash_copy = {}.update flash - render :inline => "hello" - end - - def attempt_to_use_flash_now - @flash_copy = {}.update flash - @flashy = flash["that"] - render :inline => "hello" - end - - def use_flash - @flash_copy = {}.update flash - @flashy = flash["that"] - render :inline => "hello" - end - - def use_flash_and_keep_it - @flash_copy = {}.update flash - @flashy = flash["that"] - flash.keep - render :inline => "hello" - end - - def use_flash_and_update_it - flash.update("this" => "hello again") - @flash_copy = {}.update flash - render :inline => "hello" - end - - def use_flash_after_reset_session - flash["that"] = "hello" - @flashy_that = flash["that"] - reset_session - @flashy_that_reset = flash["that"] - flash["this"] = "good-bye" - @flashy_this = flash["this"] - render :inline => "hello" - end - - def rescue_action(e) - raise unless ActionView::MissingTemplate === e - end - - # methods for test_sweep_after_halted_filter_chain - before_filter :halt_and_redir, :only => "filter_halting_action" - - def std_action - @flash_copy = {}.update(flash) - end - - def filter_halting_action - @flash_copy = {}.update(flash) - end - - def halt_and_redir - flash["foo"] = "bar" - redirect_to :action => "std_action" - @flash_copy = {}.update(flash) - end - end - - tests TestController - - def test_flash - get :set_flash - - get :use_flash - assert_equal "hello", @response.template.assigns["flash_copy"]["that"] - assert_equal "hello", @response.template.assigns["flashy"] - - get :use_flash - assert_nil @response.template.assigns["flash_copy"]["that"], "On second flash" - end - - def test_keep_flash - get :set_flash - - get :use_flash_and_keep_it - assert_equal "hello", @response.template.assigns["flash_copy"]["that"] - assert_equal "hello", @response.template.assigns["flashy"] - - get :use_flash - assert_equal "hello", @response.template.assigns["flash_copy"]["that"], "On second flash" - - get :use_flash - assert_nil @response.template.assigns["flash_copy"]["that"], "On third flash" - end - - def test_flash_now - get :set_flash_now - assert_equal "hello", @response.template.assigns["flash_copy"]["that"] - assert_equal "bar" , @response.template.assigns["flash_copy"]["foo"] - assert_equal "hello", @response.template.assigns["flashy"] - - get :attempt_to_use_flash_now - assert_nil @response.template.assigns["flash_copy"]["that"] - assert_nil @response.template.assigns["flash_copy"]["foo"] - assert_nil @response.template.assigns["flashy"] - end - - def test_update_flash - get :set_flash - get :use_flash_and_update_it - assert_equal "hello", @response.template.assigns["flash_copy"]["that"] - assert_equal "hello again", @response.template.assigns["flash_copy"]["this"] - get :use_flash - assert_nil @response.template.assigns["flash_copy"]["that"], "On second flash" - assert_equal "hello again", @response.template.assigns["flash_copy"]["this"], "On second flash" - end - - def test_flash_after_reset_session - get :use_flash_after_reset_session - assert_equal "hello", @response.template.assigns["flashy_that"] - assert_equal "good-bye", @response.template.assigns["flashy_this"] - assert_nil @response.template.assigns["flashy_that_reset"] - end - - def test_sweep_after_halted_filter_chain - get :std_action - assert_nil @response.template.assigns["flash_copy"]["foo"] - get :filter_halting_action - assert_equal "bar", @response.template.assigns["flash_copy"]["foo"] - get :std_action # follow redirection - assert_equal "bar", @response.template.assigns["flash_copy"]["foo"] - get :std_action - assert_nil @response.template.assigns["flash_copy"]["foo"] - end -end diff --git a/vendor/rails/actionpack/test/controller/header_test.rb b/vendor/rails/actionpack/test/controller/header_test.rb deleted file mode 100644 index 33c14a1..0000000 --- a/vendor/rails/actionpack/test/controller/header_test.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'abstract_unit' - -class HeaderTest < Test::Unit::TestCase - def setup - @headers = ActionController::Http::Headers.new("HTTP_CONTENT_TYPE"=>"text/plain") - end - - def test_content_type_works - assert_equal "text/plain", @headers["Content-Type"] - assert_equal "text/plain", @headers["content-type"] - assert_equal "text/plain", @headers["CONTENT_TYPE"] - assert_equal "text/plain", @headers["HTTP_CONTENT_TYPE"] - end -end diff --git a/vendor/rails/actionpack/test/controller/helper_test.rb b/vendor/rails/actionpack/test/controller/helper_test.rb deleted file mode 100644 index 5f36461..0000000 --- a/vendor/rails/actionpack/test/controller/helper_test.rb +++ /dev/null @@ -1,224 +0,0 @@ -require 'abstract_unit' - -ActionController::Base.helpers_dir = File.dirname(__FILE__) + '/../fixtures/helpers' - -class TestController < ActionController::Base - attr_accessor :delegate_attr - def delegate_method() end - def rescue_action(e) raise end -end - -module Fun - class GamesController < ActionController::Base - def render_hello_world - render :inline => "hello: <%= stratego %>" - end - - def rescue_action(e) raise end - end - - class PdfController < ActionController::Base - def test - render :inline => "test: <%= foobar %>" - end - - def rescue_action(e) raise end - end -end - -class ApplicationController < ActionController::Base - helper :all -end - -module LocalAbcHelper - def a() end - def b() end - def c() end -end - -class HelperTest < Test::Unit::TestCase - def setup - # Increment symbol counter. - @symbol = (@@counter ||= 'A0').succ!.dup - - # Generate new controller class. - controller_class_name = "Helper#{@symbol}Controller" - eval("class #{controller_class_name} < TestController; end") - @controller_class = self.class.const_get(controller_class_name) - - # Set default test helper. - self.test_helper = LocalAbcHelper - end - - def test_deprecated_helper - assert_equal expected_helper_methods, missing_methods - assert_nothing_raised { @controller_class.helper TestHelper } - assert_equal [], missing_methods - end - - def test_declare_helper - require 'abc_helper' - self.test_helper = AbcHelper - assert_equal expected_helper_methods, missing_methods - assert_nothing_raised { @controller_class.helper :abc } - assert_equal [], missing_methods - end - - def test_declare_missing_helper - assert_equal expected_helper_methods, missing_methods - assert_raise(MissingSourceFile) { @controller_class.helper :missing } - end - - def test_declare_missing_file_from_helper - require 'broken_helper' - rescue LoadError => e - assert_nil(/\bbroken_helper\b/.match(e.to_s)[1]) - end - - def test_helper_block - assert_nothing_raised { - @controller_class.helper { def block_helper_method; end } - } - assert master_helper_methods.include?('block_helper_method') - end - - def test_helper_block_include - assert_equal expected_helper_methods, missing_methods - assert_nothing_raised { - @controller_class.helper { include HelperTest::TestHelper } - } - assert [], missing_methods - end - - def test_helper_method - assert_nothing_raised { @controller_class.helper_method :delegate_method } - assert master_helper_methods.include?('delegate_method') - end - - def test_helper_attr - assert_nothing_raised { @controller_class.helper_attr :delegate_attr } - assert master_helper_methods.include?('delegate_attr') - assert master_helper_methods.include?('delegate_attr=') - end - - def test_helper_for_nested_controller - request = ActionController::TestRequest.new - response = ActionController::TestResponse.new - request.action = 'render_hello_world' - - assert_equal 'hello: Iz guuut!', Fun::GamesController.process(request, response).body - end - - def test_helper_for_acronym_controller - request = ActionController::TestRequest.new - response = ActionController::TestResponse.new - request.action = 'test' - - assert_equal 'test: baz', Fun::PdfController.process(request, response).body - end - - def test_all_helpers - methods = ApplicationController.master_helper_module.instance_methods.map(&:to_s) - - # abc_helper.rb - assert methods.include?('bare_a') - - # fun/games_helper.rb - assert methods.include?('stratego') - - # fun/pdf_helper.rb - assert methods.include?('foobar') - end - - def test_all_helpers_with_alternate_helper_dir - @controller_class.helpers_dir = File.dirname(__FILE__) + '/../fixtures/alternate_helpers' - - # Reload helpers - @controller_class.master_helper_module = Module.new - @controller_class.helper :all - - # helpers/abc_helper.rb should not be included - assert !master_helper_methods.include?('bare_a') - - # alternate_helpers/foo_helper.rb - assert master_helper_methods.include?('baz') - end - - def test_helper_proxy - methods = ApplicationController.helpers.methods.map(&:to_s) - - # ActionView - assert methods.include?('pluralize') - - # abc_helper.rb - assert methods.include?('bare_a') - - # fun/games_helper.rb - assert methods.include?('stratego') - - # fun/pdf_helper.rb - assert methods.include?('foobar') - end - - private - def expected_helper_methods - TestHelper.instance_methods.map(&:to_s) - end - - def master_helper_methods - @controller_class.master_helper_module.instance_methods.map(&:to_s) - end - - def missing_methods - expected_helper_methods - master_helper_methods - end - - def test_helper=(helper_module) - silence_warnings { self.class.const_set('TestHelper', helper_module) } - end -end - - -class IsolatedHelpersTest < Test::Unit::TestCase - class A < ActionController::Base - def index - render :inline => '<%= shout %>' - end - - def rescue_action(e) raise end - end - - class B < A - helper { def shout; 'B' end } - - def index - render :inline => '<%= shout %>' - end - end - - class C < A - helper { def shout; 'C' end } - - def index - render :inline => '<%= shout %>' - end - end - - def setup - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @request.action = 'index' - end - - def test_helper_in_a - assert_raise(NameError) { A.process(@request, @response) } - end - - def test_helper_in_b - assert_equal 'B', B.process(@request, @response).body - end - - def test_helper_in_c - assert_equal 'C', C.process(@request, @response).body - end -end diff --git a/vendor/rails/actionpack/test/controller/html-scanner/cdata_node_test.rb b/vendor/rails/actionpack/test/controller/html-scanner/cdata_node_test.rb deleted file mode 100644 index 1822cc5..0000000 --- a/vendor/rails/actionpack/test/controller/html-scanner/cdata_node_test.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'abstract_unit' - -class CDATANodeTest < Test::Unit::TestCase - def setup - @node = HTML::CDATA.new(nil, 0, 0, "

    howdy

    ") - end - - def test_to_s - assert_equal "howdy

    ]]>", @node.to_s - end - - def test_content - assert_equal "

    howdy

    ", @node.content - end -end diff --git a/vendor/rails/actionpack/test/controller/html-scanner/document_test.rb b/vendor/rails/actionpack/test/controller/html-scanner/document_test.rb deleted file mode 100644 index c68f04f..0000000 --- a/vendor/rails/actionpack/test/controller/html-scanner/document_test.rb +++ /dev/null @@ -1,148 +0,0 @@ -require 'abstract_unit' - -class DocumentTest < Test::Unit::TestCase - def test_handle_doctype - doc = nil - assert_nothing_raised do - doc = HTML::Document.new <<-HTML.strip - - - - HTML - end - assert_equal 3, doc.root.children.length - assert_equal %{}, doc.root.children[0].content - assert_match %r{\s+}m, doc.root.children[1].content - assert_equal "html", doc.root.children[2].name - end - - def test_find_img - doc = HTML::Document.new <<-HTML.strip - - -

    - - - HTML - assert doc.find(:tag=>"img", :attributes=>{"src"=>"hello.gif"}) - end - - def test_find_all - doc = HTML::Document.new <<-HTML.strip - - -

    -
    -

    something

    -

    here is more

    -
    - - - HTML - all = doc.find_all :attributes => { :class => "test" } - assert_equal 3, all.length - assert_equal [ "p", "p", "em" ], all.map { |n| n.name } - end - - def test_find_with_text - doc = HTML::Document.new <<-HTML.strip - - -

    Some text

    - - - HTML - assert doc.find(:content => "Some text") - assert doc.find(:tag => "p", :child => { :content => "Some text" }) - assert doc.find(:tag => "p", :child => "Some text") - assert doc.find(:tag => "p", :content => "Some text") - end - - def test_parse_xml - assert_nothing_raised { HTML::Document.new("", true, true) } - assert_nothing_raised { HTML::Document.new("something", true, true) } - end - - def test_parse_document - doc = HTML::Document.new(<<-HTML) -
    -

    blah

    - -
    -
    - HTML - assert_not_nil doc.find(:tag => "div", :children => { :count => 1, :only => { :tag => "table" } }) - end - - def test_tag_nesting_nothing_to_s - doc = HTML::Document.new("") - assert_equal "", doc.root.to_s - end - - def test_tag_nesting_space_to_s - doc = HTML::Document.new(" ") - assert_equal " ", doc.root.to_s - end - - def test_tag_nesting_text_to_s - doc = HTML::Document.new("text") - assert_equal "text", doc.root.to_s - end - - def test_tag_nesting_tag_to_s - doc = HTML::Document.new("") - assert_equal "", doc.root.to_s - end - - def test_parse_cdata - doc = HTML::Document.new(<<-HTML) - - - - <![CDATA[<br>]]> - - -

    this document has <br> for a title

    - - -HTML - - assert_nil doc.find(:tag => "title", :descendant => { :tag => "br" }) - assert doc.find(:tag => "title", :child => "
    ") - end - - def test_find_empty_tag - doc = HTML::Document.new("
    ") - assert_nil doc.find(:tag => "div", :attributes => { :id => "map" }, :content => /./) - assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => /\A\Z/) - assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => /^$/) - assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => "") - assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => nil) - end - - def test_parse_invalid_document - assert_nothing_raised do - doc = HTML::Document.new(" - - - - -
    About Us
    - ") - end - end - - def test_invalid_document_raises_exception_when_strict - assert_raise RuntimeError do - doc = HTML::Document.new(" - - - - -
    About Us
    - ", true) - end - end - -end diff --git a/vendor/rails/actionpack/test/controller/html-scanner/node_test.rb b/vendor/rails/actionpack/test/controller/html-scanner/node_test.rb deleted file mode 100644 index b0df368..0000000 --- a/vendor/rails/actionpack/test/controller/html-scanner/node_test.rb +++ /dev/null @@ -1,89 +0,0 @@ -require 'abstract_unit' - -class NodeTest < Test::Unit::TestCase - - class MockNode - def initialize(matched, value) - @matched = matched - @value = value - end - - def find(conditions) - @matched && self - end - - def to_s - @value.to_s - end - end - - def setup - @node = HTML::Node.new("parent") - @node.children.concat [MockNode.new(false,1), MockNode.new(true,"two"), MockNode.new(false,:three)] - end - - def test_match - assert !@node.match("foo") - end - - def test_tag - assert !@node.tag? - end - - def test_to_s - assert_equal "1twothree", @node.to_s - end - - def test_find - assert_equal "two", @node.find('blah').to_s - end - - def test_parse_strict - s = "" - assert_raise(RuntimeError) { HTML::Node.parse(nil,0,0,s) } - end - - def test_parse_relaxed - s = "" - node = nil - assert_nothing_raised { node = HTML::Node.parse(nil,0,0,s,false) } - assert node.attributes.has_key?("foo") - assert !node.attributes.has_key?("bar") - end - - def test_to_s_with_boolean_attrs - s = "" - node = HTML::Node.parse(nil,0,0,s) - assert node.attributes.has_key?("foo") - assert node.attributes.has_key?("bar") - assert "", node.to_s - end - - def test_parse_with_unclosed_tag - s = "contents', node.content - end - - def test_parse_strict_with_unterminated_cdata_section - s = "")) - assert_equal("Dont touch me", sanitizer.sanitize("Dont touch me")) - assert_equal("This is a test.", sanitizer.sanitize("

    This is a test.

    ")) - assert_equal("Weirdos", sanitizer.sanitize("Wei<a onclick='alert(document.cookie);'/>rdos")) - assert_equal("This is a test.", sanitizer.sanitize("This is a test.")) - assert_equal( - %{This is a test.\n\n\nIt no longer contains any HTML.\n}, sanitizer.sanitize( - %{This is <b>a <a href="" target="_blank">test</a></b>.\n\n\n\n

    It no longer contains any HTML.

    \n})) - assert_equal "This has a here.", sanitizer.sanitize("This has a here.") - assert_equal "This has a here.", sanitizer.sanitize("This has a ]]> here.") - assert_equal "This has an unclosed ", sanitizer.sanitize("This has an unclosed ]] here...") - [nil, '', ' '].each { |blank| assert_equal blank, sanitizer.sanitize(blank) } - end - - def test_strip_links - sanitizer = HTML::LinkSanitizer.new - assert_equal "Dont touch me", sanitizer.sanitize("Dont touch me") - assert_equal "on my mind\nall day long", sanitizer.sanitize("on my mind\nall day long") - assert_equal "0wn3d", sanitizer.sanitize("0wn3d") - assert_equal "Magic", sanitizer.sanitize("Magic") - assert_equal "FrrFox", sanitizer.sanitize("FrrFox") - assert_equal "My mind\nall day long", sanitizer.sanitize("My mind\nall day long") - assert_equal "all day long", sanitizer.sanitize("<a href='hello'>all day long</a>") - - assert_equal "", '' - end - - def test_sanitize_plaintext - raw = "<span>foo</span></plaintext>" - assert_sanitized raw, "<span>foo</span>" - end - - def test_sanitize_script - assert_sanitized "a b c<script language=\"Javascript\">blah blah blah</script>d e f", "a b cd e f" - end - - # fucked - def test_sanitize_js_handlers - raw = %{onthis="do that" <a href="#" onclick="hello" name="foo" onbogus="remove me">hello</a>} - assert_sanitized raw, %{onthis="do that" <a name="foo" href="#">hello</a>} - end - - def test_sanitize_javascript_href - raw = %{href="javascript:bang" <a href="javascript:bang" name="hello">foo</a>, <span href="javascript:bang">bar</span>} - assert_sanitized raw, %{href="javascript:bang" <a name="hello">foo</a>, <span>bar</span>} - end - - def test_sanitize_image_src - raw = %{src="javascript:bang" <img src="javascript:bang" width="5">foo</img>, <span src="javascript:bang">bar</span>} - assert_sanitized raw, %{src="javascript:bang" <img width="5">foo</img>, <span>bar</span>} - end - - HTML::WhiteListSanitizer.allowed_tags.each do |tag_name| - define_method "test_should_allow_#{tag_name}_tag" do - assert_sanitized "start <#{tag_name} title=\"1\" onclick=\"foo\">foo <bad>bar</bad> baz</#{tag_name}> end", %(start <#{tag_name} title="1">foo bar baz</#{tag_name}> end) - end - end - - def test_should_allow_anchors - assert_sanitized %(<a href="foo" onclick="bar"><script>baz</script></a>), %(<a href="foo"></a>) - end - - # RFC 3986, sec 4.2 - def test_allow_colons_in_path_component - assert_sanitized("<a href=\"./this:that\">foo</a>") - end - - %w(src width height alt).each do |img_attr| - define_method "test_should_allow_image_#{img_attr}_attribute" do - assert_sanitized %(<img #{img_attr}="foo" onclick="bar" />), %(<img #{img_attr}="foo" />) - end - end - - def test_should_handle_non_html - assert_sanitized 'abc' - end - - def test_should_handle_blank_text - assert_sanitized nil - assert_sanitized '' - end - - def test_should_allow_custom_tags - text = "<u>foo</u>" - sanitizer = HTML::WhiteListSanitizer.new - assert_equal(text, sanitizer.sanitize(text, :tags => %w(u))) - end - - def test_should_allow_only_custom_tags - text = "<u>foo</u> with <i>bar</i>" - sanitizer = HTML::WhiteListSanitizer.new - assert_equal("<u>foo</u> with bar", sanitizer.sanitize(text, :tags => %w(u))) - end - - def test_should_allow_custom_tags_with_attributes - text = %(<blockquote cite="http://example.com/">foo</blockquote>) - sanitizer = HTML::WhiteListSanitizer.new - assert_equal(text, sanitizer.sanitize(text)) - end - - def test_should_allow_custom_tags_with_custom_attributes - text = %(<blockquote foo="bar">Lorem ipsum</blockquote>) - sanitizer = HTML::WhiteListSanitizer.new - assert_equal(text, sanitizer.sanitize(text, :attributes => ['foo'])) - end - - [%w(img src), %w(a href)].each do |(tag, attr)| - define_method "test_should_strip_#{attr}_attribute_in_#{tag}_with_bad_protocols" do - assert_sanitized %(<#{tag} #{attr}="javascript:bang" title="1">boo</#{tag}>), %(<#{tag} title="1">boo</#{tag}>) - end - end - - def test_should_flag_bad_protocols - sanitizer = HTML::WhiteListSanitizer.new - %w(about chrome data disk hcp help javascript livescript lynxcgi lynxexec ms-help ms-its mhtml mocha opera res resource shell vbscript view-source vnd.ms.radio wysiwyg).each do |proto| - assert sanitizer.send(:contains_bad_protocols?, 'src', "#{proto}://bad") - end - end - - def test_should_accept_good_protocols - sanitizer = HTML::WhiteListSanitizer.new - HTML::WhiteListSanitizer.allowed_protocols.each do |proto| - assert !sanitizer.send(:contains_bad_protocols?, 'src', "#{proto}://good") - end - end - - def test_should_reject_hex_codes_in_protocol - assert_sanitized %(<a href="&#37;6A&#37;61&#37;76&#37;61&#37;73&#37;63&#37;72&#37;69&#37;70&#37;74&#37;3A&#37;61&#37;6C&#37;65&#37;72&#37;74&#37;28&#37;22&#37;58&#37;53&#37;53&#37;22&#37;29">1</a>), "<a>1</a>" - assert @sanitizer.send(:contains_bad_protocols?, 'src', "%6A%61%76%61%73%63%72%69%70%74%3A%61%6C%65%72%74%28%22%58%53%53%22%29") - end - - def test_should_block_script_tag - assert_sanitized %(<SCRIPT\nSRC=http://ha.ckers.org/xss.js></SCRIPT>), "" - end - - [%(<IMG SRC="javascript:alert('XSS');">), - %(<IMG SRC=javascript:alert('XSS')>), - %(<IMG SRC=JaVaScRiPt:alert('XSS')>), - %(<IMG """><SCRIPT>alert("XSS")</SCRIPT>">), - %(<IMG SRC=javascript:alert(&quot;XSS&quot;)>), - %(<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>), - %(<IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>), - %(<IMG SRC=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041>), - %(<IMG SRC=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x27&#x58&#x53&#x53&#x27&#x29>), - %(<IMG SRC="jav\tascript:alert('XSS');">), - %(<IMG SRC="jav&#x09;ascript:alert('XSS');">), - %(<IMG SRC="jav&#x0A;ascript:alert('XSS');">), - %(<IMG SRC="jav&#x0D;ascript:alert('XSS');">), - %(<IMG SRC=" &#14; javascript:alert('XSS');">), - %(<IMG SRC=`javascript:alert("RSnake says, 'XSS'")`>)].each_with_index do |img_hack, i| - define_method "test_should_not_fall_for_xss_image_hack_#{i+1}" do - assert_sanitized img_hack, "<img>" - end - end - - def test_should_sanitize_tag_broken_up_by_null - assert_sanitized %(<SCR\0IPT>alert(\"XSS\")</SCR\0IPT>), "alert(\"XSS\")" - end - - def test_should_sanitize_invalid_script_tag - assert_sanitized %(<SCRIPT/XSS SRC="http://ha.ckers.org/xss.js"></SCRIPT>), "" - end - - def test_should_sanitize_script_tag_with_multiple_open_brackets - assert_sanitized %(<<SCRIPT>alert("XSS");//<</SCRIPT>), "&lt;" - assert_sanitized %(<iframe src=http://ha.ckers.org/scriptlet.html\n<a), %(&lt;a) - end - - def test_should_sanitize_unclosed_script - assert_sanitized %(<SCRIPT SRC=http://ha.ckers.org/xss.js?<B>), "<b>" - end - - def test_should_sanitize_half_open_scripts - assert_sanitized %(<IMG SRC="javascript:alert('XSS')"), "<img>" - end - - def test_should_not_fall_for_ridiculous_hack - img_hack = %(<IMG\nSRC\n=\n"\nj\na\nv\na\ns\nc\nr\ni\np\nt\n:\na\nl\ne\nr\nt\n(\n'\nX\nS\nS\n'\n)\n"\n>) - assert_sanitized img_hack, "<img>" - end - - # fucked - def test_should_sanitize_attributes - assert_sanitized %(<SPAN title="'><script>alert()</script>">blah</SPAN>), %(<span title="'&gt;&lt;script&gt;alert()&lt;/script&gt;">blah</span>) - end - - def test_should_sanitize_illegal_style_properties - raw = %(display:block; position:absolute; left:0; top:0; width:100%; height:100%; z-index:1; background-color:black; background-image:url(http://www.ragingplatypus.com/i/cam-full.jpg); background-x:center; background-y:center; background-repeat:repeat;) - expected = %(display: block; width: 100%; height: 100%; background-color: black; background-image: ; background-x: center; background-y: center;) - assert_equal expected, sanitize_css(raw) - end - - def test_should_sanitize_with_trailing_space - raw = "display:block; " - expected = "display: block;" - assert_equal expected, sanitize_css(raw) - end - - def test_should_sanitize_xul_style_attributes - raw = %(-moz-binding:url('http://ha.ckers.org/xssmoz.xml#xss')) - assert_equal '', sanitize_css(raw) - end - - def test_should_sanitize_invalid_tag_names - assert_sanitized(%(a b c<script/XSS src="http://ha.ckers.org/xss.js"></script>d e f), "a b cd e f") - end - - def test_should_sanitize_non_alpha_and_non_digit_characters_in_tags - assert_sanitized('<a onclick!#$%&()*~+-_.,:;?@[/|\]^`=alert("XSS")>foo</a>', "<a>foo</a>") - end - - def test_should_sanitize_invalid_tag_names_in_single_tags - assert_sanitized('<img/src="http://ha.ckers.org/xss.js"/>', "<img />") - end - - def test_should_sanitize_img_dynsrc_lowsrc - assert_sanitized(%(<img lowsrc="javascript:alert('XSS')" />), "<img />") - end - - def test_should_sanitize_div_background_image_unicode_encoded - raw = %(background-image:\0075\0072\006C\0028'\006a\0061\0076\0061\0073\0063\0072\0069\0070\0074\003a\0061\006c\0065\0072\0074\0028.1027\0058.1053\0053\0027\0029'\0029) - assert_equal '', sanitize_css(raw) - end - - def test_should_sanitize_div_style_expression - raw = %(width: expression(alert('XSS'));) - assert_equal '', sanitize_css(raw) - end - - def test_should_sanitize_img_vbscript - assert_sanitized %(<img src='vbscript:msgbox("XSS")' />), '<img />' - end - - def test_should_sanitize_cdata_section - assert_sanitized "<![CDATA[<span>section</span>]]>", "&lt;![CDATA[&lt;span>section&lt;/span>]]>" - end - - def test_should_sanitize_unterminated_cdata_section - assert_sanitized "<![CDATA[<span>neverending...", "&lt;![CDATA[&lt;span>neverending...]]>" - end - - def test_should_not_mangle_urls_with_ampersand - assert_sanitized %{<a href=\"http://www.domain.com?var1=1&amp;var2=2\">my link</a>} - end - -protected - def assert_sanitized(input, expected = nil) - @sanitizer ||= HTML::WhiteListSanitizer.new - if input - assert_dom_equal expected || input, @sanitizer.sanitize(input) - else - assert_nil @sanitizer.sanitize(input) - end - end - - def sanitize_css(input) - (@sanitizer ||= HTML::WhiteListSanitizer.new).sanitize_css(input) - end -end diff --git a/vendor/rails/actionpack/test/controller/html-scanner/tag_node_test.rb b/vendor/rails/actionpack/test/controller/html-scanner/tag_node_test.rb deleted file mode 100644 index d1d4667..0000000 --- a/vendor/rails/actionpack/test/controller/html-scanner/tag_node_test.rb +++ /dev/null @@ -1,238 +0,0 @@ -require 'abstract_unit' - -class TagNodeTest < Test::Unit::TestCase - def test_open_without_attributes - node = tag("<tag>") - assert_equal "tag", node.name - assert_equal Hash.new, node.attributes - assert_nil node.closing - end - - def test_open_with_attributes - node = tag("<TAG1 foo=hey_ho x:bar=\"blah blah\" BAZ='blah blah blah' >") - assert_equal "tag1", node.name - assert_equal "hey_ho", node["foo"] - assert_equal "blah blah", node["x:bar"] - assert_equal "blah blah blah", node["baz"] - end - - def test_self_closing_without_attributes - node = tag("<tag/>") - assert_equal "tag", node.name - assert_equal Hash.new, node.attributes - assert_equal :self, node.closing - end - - def test_self_closing_with_attributes - node = tag("<tag a=b/>") - assert_equal "tag", node.name - assert_equal( { "a" => "b" }, node.attributes ) - assert_equal :self, node.closing - end - - def test_closing_without_attributes - node = tag("</tag>") - assert_equal "tag", node.name - assert_nil node.attributes - assert_equal :close, node.closing - end - - def test_bracket_op_when_no_attributes - node = tag("</tag>") - assert_nil node["foo"] - end - - def test_bracket_op_when_attributes - node = tag("<tag a=b/>") - assert_equal "b", node["a"] - end - - def test_attributes_with_escaped_quotes - node = tag("<tag a='b\\'c' b=\"bob \\\"float\\\"\">") - assert_equal "b\\'c", node["a"] - assert_equal "bob \\\"float\\\"", node["b"] - end - - def test_to_s - node = tag("<a b=c d='f' g=\"h 'i'\" />") - assert_equal %(<a b='c' d='f' g='h \\'i\\'' />), node.to_s - end - - def test_tag - assert tag("<tag>").tag? - end - - def test_match_tag_as_string - assert tag("<tag>").match(:tag => "tag") - assert !tag("<tag>").match(:tag => "b") - end - - def test_match_tag_as_regexp - assert tag("<tag>").match(:tag => /t.g/) - assert !tag("<tag>").match(:tag => /t[bqs]g/) - end - - def test_match_attributes_as_string - t = tag("<tag a=something b=else />") - assert t.match(:attributes => {"a" => "something"}) - assert t.match(:attributes => {"b" => "else"}) - end - - def test_match_attributes_as_regexp - t = tag("<tag a=something b=else />") - assert t.match(:attributes => {"a" => /^something$/}) - assert t.match(:attributes => {"b" => /e.*e/}) - assert t.match(:attributes => {"a" => /me..i/, "b" => /.ls.$/}) - end - - def test_match_attributes_as_number - t = tag("<tag a=15 b=3.1415 />") - assert t.match(:attributes => {"a" => 15}) - assert t.match(:attributes => {"b" => 3.1415}) - assert t.match(:attributes => {"a" => 15, "b" => 3.1415}) - end - - def test_match_attributes_exist - t = tag("<tag a=15 b=3.1415 />") - assert t.match(:attributes => {"a" => true}) - assert t.match(:attributes => {"b" => true}) - assert t.match(:attributes => {"a" => true, "b" => true}) - end - - def test_match_attributes_not_exist - t = tag("<tag a=15 b=3.1415 />") - assert t.match(:attributes => {"c" => false}) - assert t.match(:attributes => {"c" => nil}) - assert t.match(:attributes => {"a" => true, "c" => false}) - end - - def test_match_parent_success - t = tag("<tag a=15 b='hello'>", tag("<foo k='value'>")) - assert t.match(:parent => {:tag => "foo", :attributes => {"k" => /v.l/, "j" => false}}) - end - - def test_match_parent_fail - t = tag("<tag a=15 b='hello'>", tag("<foo k='value'>")) - assert !t.match(:parent => {:tag => /kafka/}) - end - - def test_match_child_success - t = tag("<tag x:k='something'>") - tag("<child v=john a=kelly>", t) - tag("<sib m=vaughn v=james>", t) - assert t.match(:child => { :tag => "sib", :attributes => {"v" => /j/}}) - assert t.match(:child => { :attributes => {"a" => "kelly"}}) - end - - def test_match_child_fail - t = tag("<tag x:k='something'>") - tag("<child v=john a=kelly>", t) - tag("<sib m=vaughn v=james>", t) - assert !t.match(:child => { :tag => "sib", :attributes => {"v" => /r/}}) - assert !t.match(:child => { :attributes => {"v" => false}}) - end - - def test_match_ancestor_success - t = tag("<tag x:k='something'>", tag("<parent v=john a=kelly>", tag("<grandparent m=vaughn v=james>"))) - assert t.match(:ancestor => {:tag => "parent", :attributes => {"a" => /ll/}}) - assert t.match(:ancestor => {:attributes => {"m" => "vaughn"}}) - end - - def test_match_ancestor_fail - t = tag("<tag x:k='something'>", tag("<parent v=john a=kelly>", tag("<grandparent m=vaughn v=james>"))) - assert !t.match(:ancestor => {:tag => /^parent/, :attributes => {"v" => /m/}}) - assert !t.match(:ancestor => {:attributes => {"v" => false}}) - end - - def test_match_descendant_success - tag("<grandchild m=vaughn v=james>", tag("<child v=john a=kelly>", t = tag("<tag x:k='something'>"))) - assert t.match(:descendant => {:tag => "child", :attributes => {"a" => /ll/}}) - assert t.match(:descendant => {:attributes => {"m" => "vaughn"}}) - end - - def test_match_descendant_fail - tag("<grandchild m=vaughn v=james>", tag("<child v=john a=kelly>", t = tag("<tag x:k='something'>"))) - assert !t.match(:descendant => {:tag => /^child/, :attributes => {"v" => /m/}}) - assert !t.match(:descendant => {:attributes => {"v" => false}}) - end - - def test_match_child_count - t = tag("<tag x:k='something'>") - tag("hello", t) - tag("<child v=john a=kelly>", t) - tag("<sib m=vaughn v=james>", t) - assert t.match(:children => { :count => 2 }) - assert t.match(:children => { :count => 2..4 }) - assert t.match(:children => { :less_than => 4 }) - assert t.match(:children => { :greater_than => 1 }) - assert !t.match(:children => { :count => 3 }) - end - - def test_conditions_as_strings - t = tag("<tag x:k='something'>") - assert t.match("tag" => "tag") - assert t.match("attributes" => { "x:k" => "something" }) - assert !t.match("tag" => "gat") - assert !t.match("attributes" => { "x:j" => "something" }) - end - - def test_attributes_as_symbols - t = tag("<child v=john a=kelly>") - assert t.match(:attributes => { :v => /oh/ }) - assert t.match(:attributes => { :a => /ll/ }) - end - - def test_match_sibling - t = tag("<tag x:k='something'>") - tag("hello", t) - tag("<span a=b>", t) - tag("world", t) - m = tag("<span k=r>", t) - tag("<span m=l>", t) - - assert m.match(:sibling => {:tag => "span", :attributes => {:a => true}}) - assert m.match(:sibling => {:tag => "span", :attributes => {:m => true}}) - assert !m.match(:sibling => {:tag => "span", :attributes => {:k => true}}) - end - - def test_match_sibling_before - t = tag("<tag x:k='something'>") - tag("hello", t) - tag("<span a=b>", t) - tag("world", t) - m = tag("<span k=r>", t) - tag("<span m=l>", t) - - assert m.match(:before => {:tag => "span", :attributes => {:m => true}}) - assert !m.match(:before => {:tag => "span", :attributes => {:a => true}}) - assert !m.match(:before => {:tag => "span", :attributes => {:k => true}}) - end - - def test_match_sibling_after - t = tag("<tag x:k='something'>") - tag("hello", t) - tag("<span a=b>", t) - tag("world", t) - m = tag("<span k=r>", t) - tag("<span m=l>", t) - - assert m.match(:after => {:tag => "span", :attributes => {:a => true}}) - assert !m.match(:after => {:tag => "span", :attributes => {:m => true}}) - assert !m.match(:after => {:tag => "span", :attributes => {:k => true}}) - end - - def test_to_s - t = tag("<b x='foo'>") - tag("hello", t) - tag("<hr />", t) - assert_equal %(<b x="foo">hello<hr /></b>), t.to_s - end - - private - - def tag(content, parent=nil) - node = HTML::Node.parse(parent,0,0,content) - parent.children << node if parent - node - end -end diff --git a/vendor/rails/actionpack/test/controller/html-scanner/text_node_test.rb b/vendor/rails/actionpack/test/controller/html-scanner/text_node_test.rb deleted file mode 100644 index 1ab3f44..0000000 --- a/vendor/rails/actionpack/test/controller/html-scanner/text_node_test.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'abstract_unit' - -class TextNodeTest < Test::Unit::TestCase - def setup - @node = HTML::Text.new(nil, 0, 0, "hello, howdy, aloha, annyeong") - end - - def test_to_s - assert_equal "hello, howdy, aloha, annyeong", @node.to_s - end - - def test_find_string - assert_equal @node, @node.find("hello, howdy, aloha, annyeong") - assert_equal false, @node.find("bogus") - end - - def test_find_regexp - assert_equal @node, @node.find(/an+y/) - assert_nil @node.find(/b/) - end - - def test_find_hash - assert_equal @node, @node.find(:content => /howdy/) - assert_nil @node.find(:content => /^howdy$/) - assert_equal false, @node.find(:content => "howdy") - end - - def test_find_other - assert_nil @node.find(:hello) - end - - def test_match_string - assert @node.match("hello, howdy, aloha, annyeong") - assert_equal false, @node.match("bogus") - end - - def test_match_regexp - assert_not_nil @node, @node.match(/an+y/) - assert_nil @node.match(/b/) - end - - def test_match_hash - assert_not_nil @node, @node.match(:content => "howdy") - assert_nil @node.match(:content => /^howdy$/) - end - - def test_match_other - assert_nil @node.match(:hello) - end -end diff --git a/vendor/rails/actionpack/test/controller/html-scanner/tokenizer_test.rb b/vendor/rails/actionpack/test/controller/html-scanner/tokenizer_test.rb deleted file mode 100644 index a001bcb..0000000 --- a/vendor/rails/actionpack/test/controller/html-scanner/tokenizer_test.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'abstract_unit' - -class TokenizerTest < Test::Unit::TestCase - - def test_blank - tokenize "" - assert_end - end - - def test_space - tokenize " " - assert_next " " - assert_end - end - - def test_tag_simple_open - tokenize "<tag>" - assert_next "<tag>" - assert_end - end - - def test_tag_simple_self_closing - tokenize "<tag />" - assert_next "<tag />" - assert_end - end - - def test_tag_simple_closing - tokenize "</tag>" - assert_next "</tag>" - end - - def test_tag_with_single_quoted_attribute - tokenize %{<tag a='hello'>x} - assert_next %{<tag a='hello'>} - end - - def test_tag_with_single_quoted_attribute_with_escape - tokenize %{<tag a='hello\\''>x} - assert_next %{<tag a='hello\\''>} - end - - def test_tag_with_double_quoted_attribute - tokenize %{<tag a="hello">x} - assert_next %{<tag a="hello">} - end - - def test_tag_with_double_quoted_attribute_with_escape - tokenize %{<tag a="hello\\"">x} - assert_next %{<tag a="hello\\"">} - end - - def test_tag_with_unquoted_attribute - tokenize %{<tag a=hello>x} - assert_next %{<tag a=hello>} - end - - def test_tag_with_lt_char_in_attribute - tokenize %{<tag a="x < y">x} - assert_next %{<tag a="x < y">} - end - - def test_tag_with_gt_char_in_attribute - tokenize %{<tag a="x > y">x} - assert_next %{<tag a="x > y">} - end - - def test_doctype_tag - tokenize %{<!DOCTYPE "blah" "blah" "blah">\n <html>} - assert_next %{<!DOCTYPE "blah" "blah" "blah">} - assert_next %{\n } - assert_next %{<html>} - end - - def test_cdata_tag - tokenize %{<![CDATA[<br>]]>} - assert_next %{<![CDATA[<br>]]>} - assert_end - end - - def test_unterminated_cdata_tag - tokenize %{<content:encoded><![CDATA[ neverending...} - assert_next %{<content:encoded>} - assert_next %{<![CDATA[ neverending...} - assert_end - end - - def test_less_than_with_space - tokenize %{original < hello > world} - assert_next %{original } - assert_next %{< hello > world} - end - - def test_less_than_without_matching_greater_than - tokenize %{hello <span onmouseover="gotcha"\n<b>foo</b>\nbar</span>} - assert_next %{hello } - assert_next %{<span onmouseover="gotcha"\n} - assert_next %{<b>} - assert_next %{foo} - assert_next %{</b>} - assert_next %{\nbar} - assert_next %{</span>} - assert_end - end - - def test_unterminated_comment - tokenize %{hello <!-- neverending...} - assert_next %{hello } - assert_next %{<!-- neverending...} - assert_end - end - - private - - def tokenize(text) - @tokenizer = HTML::Tokenizer.new(text) - end - - def assert_next(expected, message=nil) - token = @tokenizer.next - assert_equal expected, token, message - end - - def assert_sequence(*expected) - assert_next expected.shift until expected.empty? - end - - def assert_end(message=nil) - assert_nil @tokenizer.next, message - end -end diff --git a/vendor/rails/actionpack/test/controller/http_basic_authentication_test.rb b/vendor/rails/actionpack/test/controller/http_basic_authentication_test.rb deleted file mode 100644 index fbc94a0..0000000 --- a/vendor/rails/actionpack/test/controller/http_basic_authentication_test.rb +++ /dev/null @@ -1,88 +0,0 @@ -require 'abstract_unit' - -class HttpBasicAuthenticationTest < ActionController::TestCase - class DummyController < ActionController::Base - before_filter :authenticate, :only => :index - before_filter :authenticate_with_request, :only => :display - - def index - render :text => "Hello Secret" - end - - def display - render :text => 'Definitely Maybe' - end - - private - - def authenticate - authenticate_or_request_with_http_basic do |username, password| - username == 'lifo' && password == 'world' - end - end - - def authenticate_with_request - if authenticate_with_http_basic { |username, password| username == 'pretty' && password == 'please' } - @logged_in = true - else - request_http_basic_authentication("SuperSecret") - end - end - end - - AUTH_HEADERS = ['HTTP_AUTHORIZATION', 'X-HTTP_AUTHORIZATION', 'X_HTTP_AUTHORIZATION', 'REDIRECT_X_HTTP_AUTHORIZATION'] - - tests DummyController - - AUTH_HEADERS.each do |header| - test "successful authentication with #{header.downcase}" do - @request.env[header] = encode_credentials('lifo', 'world') - get :index - - assert_response :success - assert_equal 'Hello Secret', @response.body, "Authentication failed for request header #{header}" - end - end - - AUTH_HEADERS.each do |header| - test "unsuccessful authentication with #{header.downcase}" do - @request.env[header] = encode_credentials('h4x0r', 'world') - get :index - - assert_response :unauthorized - assert_equal "HTTP Basic: Access denied.\n", @response.body, "Authentication didn't fail for request header #{header}" - end - end - - test "authentication request without credential" do - get :display - - assert_response :unauthorized - assert_equal "HTTP Basic: Access denied.\n", @response.body - assert_equal 'Basic realm="SuperSecret"', @response.headers['WWW-Authenticate'] - end - - test "authentication request with invalid credential" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials('pretty', 'foo') - get :display - - assert_response :unauthorized - assert_equal "HTTP Basic: Access denied.\n", @response.body - assert_equal 'Basic realm="SuperSecret"', @response.headers['WWW-Authenticate'] - end - - test "authentication request with valid credential" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials('pretty', 'please') - get :display - - assert_response :success - assert assigns(:logged_in) - assert_equal 'Definitely Maybe', @response.body - end - - private - - def encode_credentials(username, password) - "Basic #{ActiveSupport::Base64.encode64("#{username}:#{password}")}" - end -end diff --git a/vendor/rails/actionpack/test/controller/http_digest_authentication_test.rb b/vendor/rails/actionpack/test/controller/http_digest_authentication_test.rb deleted file mode 100644 index 00789ee..0000000 --- a/vendor/rails/actionpack/test/controller/http_digest_authentication_test.rb +++ /dev/null @@ -1,178 +0,0 @@ -require 'abstract_unit' - -class HttpDigestAuthenticationTest < ActionController::TestCase - class DummyDigestController < ActionController::Base - before_filter :authenticate, :only => :index - before_filter :authenticate_with_request, :only => :display - - USERS = { 'lifo' => 'world', 'pretty' => 'please', - 'dhh' => ::Digest::MD5::hexdigest(["dhh","SuperSecret","secret"].join(":"))} - - def index - render :text => "Hello Secret" - end - - def display - render :text => 'Definitely Maybe' - end - - private - - def authenticate - authenticate_or_request_with_http_digest("SuperSecret") do |username| - # Return the password - USERS[username] - end - end - - def authenticate_with_request - if authenticate_with_http_digest("SuperSecret") { |username| USERS[username] } - @logged_in = true - else - request_http_digest_authentication("SuperSecret", "Authentication Failed") - end - end - end - - AUTH_HEADERS = ['HTTP_AUTHORIZATION', 'X-HTTP_AUTHORIZATION', 'X_HTTP_AUTHORIZATION', 'REDIRECT_X_HTTP_AUTHORIZATION'] - - tests DummyDigestController - - AUTH_HEADERS.each do |header| - test "successful authentication with #{header.downcase}" do - @request.env[header] = encode_credentials(:username => 'lifo', :password => 'world') - get :index - - assert_response :success - assert_equal 'Hello Secret', @response.body, "Authentication failed for request header #{header}" - end - end - - AUTH_HEADERS.each do |header| - test "unsuccessful authentication with #{header.downcase}" do - @request.env[header] = encode_credentials(:username => 'h4x0r', :password => 'world') - get :index - - assert_response :unauthorized - assert_equal "HTTP Digest: Access denied.\n", @response.body, "Authentication didn't fail for request header #{header}" - end - end - - test "authentication request without credential" do - get :display - - assert_response :unauthorized - assert_equal "Authentication Failed", @response.body - credentials = decode_credentials(@response.headers['WWW-Authenticate']) - assert_equal 'SuperSecret', credentials[:realm] - end - - test "authentication request with invalid password" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'foo') - get :display - - assert_response :unauthorized - assert_equal "Authentication Failed", @response.body - end - - test "authentication request with invalid nonce" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'please', :nonce => "xxyyzz") - get :display - - assert_response :unauthorized - assert_equal "Authentication Failed", @response.body - end - - test "authentication request with invalid opaque" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'foo', :opaque => "xxyyzz") - get :display - - assert_response :unauthorized - assert_equal "Authentication Failed", @response.body - end - - test "authentication request with invalid realm" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'foo', :realm => "NotSecret") - get :display - - assert_response :unauthorized - assert_equal "Authentication Failed", @response.body - end - - test "authentication request with valid credential" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'please') - get :display - - assert_response :success - assert assigns(:logged_in) - assert_equal 'Definitely Maybe', @response.body - end - - test "authentication request with valid credential and nil session" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'please') - - # session_id = "" in functional test, but is +nil+ in real life - @request.session.session_id = nil - get :display - - assert_response :success - assert assigns(:logged_in) - assert_equal 'Definitely Maybe', @response.body - end - - test "authentication request with request-uri that doesn't match credentials digest-uri" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'pretty', :password => 'please') - @request.env['REQUEST_URI'] = "/http_digest_authentication_test/dummy_digest/altered/uri" - get :display - - assert_response :unauthorized - assert_equal "Authentication Failed", @response.body - end - - test "authentication request with absolute uri" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:uri => "http://test.host/http_digest_authentication_test/dummy_digest/display", - :username => 'pretty', :password => 'please') - @request.env['REQUEST_URI'] = "http://test.host/http_digest_authentication_test/dummy_digest/display" - get :display - - assert_response :success - assert assigns(:logged_in) - assert_equal 'Definitely Maybe', @response.body - end - - test "authentication request with password stored as ha1 digest hash" do - @request.env['HTTP_AUTHORIZATION'] = encode_credentials(:username => 'dhh', - :password => ::Digest::MD5::hexdigest(["dhh","SuperSecret","secret"].join(":")), - :password_is_ha1 => true) - get :display - - assert_response :success - assert assigns(:logged_in) - assert_equal 'Definitely Maybe', @response.body - end - - private - - def encode_credentials(options) - options.reverse_merge!(:nc => "00000001", :cnonce => "0a4f113b", :password_is_ha1 => false) - password = options.delete(:password) - - # Set in /initializers/session_store.rb. Used as secret in generating nonce - # to prevent tampering of timestamp - ActionController::Base.session_options[:secret] = "session_options_secret" - - # Perform unauthenticated GET to retrieve digest parameters to use on subsequent request - get :index - - assert_response :unauthorized - - credentials = decode_credentials(@response.headers['WWW-Authenticate']) - credentials.merge!(options) - credentials.reverse_merge!(:uri => "#{@request.env['REQUEST_URI']}") - ActionController::HttpAuthentication::Digest.encode_credentials("GET", credentials, password, options[:password_is_ha1]) - end - - def decode_credentials(header) - ActionController::HttpAuthentication::Digest.decode_credentials(@response.headers['WWW-Authenticate']) - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/controller/integration_test.rb b/vendor/rails/actionpack/test/controller/integration_test.rb deleted file mode 100644 index b3f40fb..0000000 --- a/vendor/rails/actionpack/test/controller/integration_test.rb +++ /dev/null @@ -1,417 +0,0 @@ -require 'abstract_unit' - -class SessionTest < Test::Unit::TestCase - StubApp = lambda { |env| - [200, {"Content-Type" => "text/html", "Content-Length" => "13"}, "Hello, World!"] - } - - def setup - @session = ActionController::Integration::Session.new(StubApp) - end - - def test_https_bang_works_and_sets_truth_by_default - assert !@session.https? - @session.https! - assert @session.https? - @session.https! false - assert !@session.https? - end - - def test_host! - assert_not_equal "glu.ttono.us", @session.host - @session.host! "rubyonrails.com" - assert_equal "rubyonrails.com", @session.host - end - - def test_follow_redirect_raises_when_no_redirect - @session.stubs(:redirect?).returns(false) - assert_raise(RuntimeError) { @session.follow_redirect! } - end - - def test_request_via_redirect_uses_given_method - path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"} - @session.expects(:put).with(path, args, headers) - @session.stubs(:redirect?).returns(false) - @session.request_via_redirect(:put, path, args, headers) - end - - def test_request_via_redirect_follows_redirects - path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"} - @session.stubs(:redirect?).returns(true, true, false) - @session.expects(:follow_redirect!).times(2) - @session.request_via_redirect(:get, path, args, headers) - end - - def test_request_via_redirect_returns_status - path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"} - @session.stubs(:redirect?).returns(false) - @session.stubs(:status).returns(200) - assert_equal 200, @session.request_via_redirect(:get, path, args, headers) - end - - def test_get_via_redirect - path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } - @session.expects(:request_via_redirect).with(:get, path, args, headers) - @session.get_via_redirect(path, args, headers) - end - - def test_post_via_redirect - path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } - @session.expects(:request_via_redirect).with(:post, path, args, headers) - @session.post_via_redirect(path, args, headers) - end - - def test_put_via_redirect - path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } - @session.expects(:request_via_redirect).with(:put, path, args, headers) - @session.put_via_redirect(path, args, headers) - end - - def test_delete_via_redirect - path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" } - @session.expects(:request_via_redirect).with(:delete, path, args, headers) - @session.delete_via_redirect(path, args, headers) - end - - def test_url_for_with_controller - options = {:action => 'show'} - mock_controller = mock() - mock_controller.expects(:url_for).with(options).returns('/show') - @session.stubs(:controller).returns(mock_controller) - assert_equal '/show', @session.url_for(options) - end - - def test_url_for_without_controller - options = {:action => 'show'} - mock_rewriter = mock() - mock_rewriter.expects(:rewrite).with(options).returns('/show') - @session.stubs(:generic_url_rewriter).returns(mock_rewriter) - @session.stubs(:controller).returns(nil) - assert_equal '/show', @session.url_for(options) - end - - def test_redirect_bool_with_status_in_300s - @session.stubs(:status).returns 301 - assert @session.redirect? - end - - def test_redirect_bool_with_status_in_200s - @session.stubs(:status).returns 200 - assert !@session.redirect? - end - - def test_get - path = "/index"; params = "blah"; headers = {:location => 'blah'} - @session.expects(:process).with(:get,path,params,headers) - @session.get(path,params,headers) - end - - def test_post - path = "/index"; params = "blah"; headers = {:location => 'blah'} - @session.expects(:process).with(:post,path,params,headers) - @session.post(path,params,headers) - end - - def test_put - path = "/index"; params = "blah"; headers = {:location => 'blah'} - @session.expects(:process).with(:put,path,params,headers) - @session.put(path,params,headers) - end - - def test_delete - path = "/index"; params = "blah"; headers = {:location => 'blah'} - @session.expects(:process).with(:delete,path,params,headers) - @session.delete(path,params,headers) - end - - def test_head - path = "/index"; params = "blah"; headers = {:location => 'blah'} - @session.expects(:process).with(:head,path,params,headers) - @session.head(path,params,headers) - end - - def test_xml_http_request_get - path = "/index"; params = "blah"; headers = {:location => 'blah'} - headers_after_xhr = headers.merge( - "X-Requested-With" => "XMLHttpRequest", - "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" - ) - @session.expects(:process).with(:get,path,params,headers_after_xhr) - @session.xml_http_request(:get,path,params,headers) - end - - def test_xml_http_request_post - path = "/index"; params = "blah"; headers = {:location => 'blah'} - headers_after_xhr = headers.merge( - "X-Requested-With" => "XMLHttpRequest", - "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" - ) - @session.expects(:process).with(:post,path,params,headers_after_xhr) - @session.xml_http_request(:post,path,params,headers) - end - - def test_xml_http_request_put - path = "/index"; params = "blah"; headers = {:location => 'blah'} - headers_after_xhr = headers.merge( - "X-Requested-With" => "XMLHttpRequest", - "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" - ) - @session.expects(:process).with(:put,path,params,headers_after_xhr) - @session.xml_http_request(:put,path,params,headers) - end - - def test_xml_http_request_delete - path = "/index"; params = "blah"; headers = {:location => 'blah'} - headers_after_xhr = headers.merge( - "X-Requested-With" => "XMLHttpRequest", - "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" - ) - @session.expects(:process).with(:delete,path,params,headers_after_xhr) - @session.xml_http_request(:delete,path,params,headers) - end - - def test_xml_http_request_head - path = "/index"; params = "blah"; headers = {:location => 'blah'} - headers_after_xhr = headers.merge( - "X-Requested-With" => "XMLHttpRequest", - "Accept" => "text/javascript, text/html, application/xml, text/xml, */*" - ) - @session.expects(:process).with(:head,path,params,headers_after_xhr) - @session.xml_http_request(:head,path,params,headers) - end - - def test_xml_http_request_override_accept - path = "/index"; params = "blah"; headers = {:location => 'blah', "Accept" => "application/xml"} - headers_after_xhr = headers.merge( - "X-Requested-With" => "XMLHttpRequest" - ) - @session.expects(:process).with(:post,path,params,headers_after_xhr) - @session.xml_http_request(:post,path,params,headers) - end -end - -class IntegrationTestTest < Test::Unit::TestCase - def setup - @test = ::ActionController::IntegrationTest.new(:default_test) - @test.class.stubs(:fixture_table_names).returns([]) - @session = @test.open_session - end - - def test_opens_new_session - @test.class.expects(:fixture_table_names).times(2).returns(['foo']) - - session1 = @test.open_session { |sess| } - session2 = @test.open_session # implicit session - - assert_equal ::ActionController::Integration::Session, session1.class - assert_equal ::ActionController::Integration::Session, session2.class - assert_not_equal session1, session2 - end -end - -# Tests that integration tests don't call Controller test methods for processing. -# Integration tests have their own setup and teardown. -class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest - def self.fixture_table_names - [] - end - - def test_integration_methods_called - reset! - @integration_session.stubs(:generic_url_rewriter) - @integration_session.stubs(:process) - - %w( get post head put delete ).each do |verb| - assert_nothing_raised("'#{verb}' should use integration test methods") { __send__(verb, '/') } - end - end -end - -class IntegrationProcessTest < ActionController::IntegrationTest - class IntegrationController < ActionController::Base - def get - respond_to do |format| - format.html { render :text => "OK", :status => 200 } - format.js { render :text => "JS OK", :status => 200 } - end - end - - def get_with_params - render :text => "foo: #{params[:foo]}", :status => 200 - end - - def post - render :text => "Created", :status => 201 - end - - def cookie_monster - cookies["cookie_1"] = nil - cookies["cookie_3"] = "chocolate" - render :text => "Gone", :status => 410 - end - - def redirect - redirect_to :action => "get" - end - end - - def test_get - with_test_route_set do - get '/get' - assert_equal 200, status - assert_equal "OK", status_message - assert_response 200 - assert_response :success - assert_response :ok - assert_equal({}, cookies) - assert_equal "OK", body - assert_equal "OK", response.body - assert_kind_of HTML::Document, html_document - assert_equal 1, request_count - end - end - - def test_post - with_test_route_set do - post '/post' - assert_equal 201, status - assert_equal "Created", status_message - assert_response 201 - assert_response :success - assert_response :created - assert_equal({}, cookies) - assert_equal "Created", body - assert_equal "Created", response.body - assert_kind_of HTML::Document, html_document - assert_equal 1, request_count - end - end - - def test_cookie_monster - with_test_route_set do - self.cookies['cookie_1'] = "sugar" - self.cookies['cookie_2'] = "oatmeal" - get '/cookie_monster' - assert_equal 410, status - assert_equal "Gone", status_message - assert_response 410 - assert_response :gone - assert_equal "cookie_1=; path=/\ncookie_3=chocolate; path=/", headers["Set-Cookie"] - assert_equal({"cookie_1"=>"", "cookie_2"=>"oatmeal", "cookie_3"=>"chocolate"}, cookies) - assert_equal "Gone", response.body - end - end - - def test_redirect - with_test_route_set do - get '/redirect' - assert_equal 302, status - assert_equal "Found", status_message - assert_response 302 - assert_response :redirect - assert_response :found - assert_equal "<html><body>You are being <a href=\"http://www.example.com/get\">redirected</a>.</body></html>", response.body - assert_kind_of HTML::Document, html_document - assert_equal 1, request_count - - follow_redirect! - assert_response :success - assert_equal "/get", path - end - end - - def test_xml_http_request_get - with_test_route_set do - xhr :get, '/get' - assert_equal 200, status - assert_equal "OK", status_message - assert_response 200 - assert_response :success - assert_response :ok - assert_equal "JS OK", response.body - end - end - - def test_get_with_query_string - with_test_route_set do - get '/get_with_params?foo=bar' - assert_equal '/get_with_params?foo=bar', request.env["REQUEST_URI"] - assert_equal '/get_with_params?foo=bar', request.request_uri - assert_equal "", request.env["QUERY_STRING"] - assert_equal 'foo=bar', request.query_string - assert_equal 'bar', request.parameters['foo'] - - assert_equal 200, status - assert_equal "foo: bar", response.body - end - end - - def test_get_with_parameters - with_test_route_set do - get '/get_with_params', :foo => "bar" - assert_equal '/get_with_params', request.env["REQUEST_URI"] - assert_equal '/get_with_params', request.request_uri - assert_equal 'foo=bar', request.env["QUERY_STRING"] - assert_equal 'foo=bar', request.query_string - assert_equal 'bar', request.parameters['foo'] - - assert_equal 200, status - assert_equal "foo: bar", response.body - end - end - - def test_head - with_test_route_set do - head '/get' - assert_equal 200, status - assert_equal "", body - - head '/post' - assert_equal 201, status - assert_equal "", body - end - end - - private - def with_test_route_set - with_routing do |set| - set.draw do |map| - map.with_options :controller => "IntegrationProcessTest::Integration" do |c| - c.connect "/:action" - end - end - yield - end - end -end - -class MetalTest < ActionController::IntegrationTest - class Poller - def self.call(env) - if env["PATH_INFO"] =~ /^\/success/ - [200, {"Content-Type" => "text/plain", "Content-Length" => "12"}, "Hello World!"] - else - [404, {"Content-Type" => "text/plain", "Content-Length" => "0"}, ''] - end - end - end - - def setup - @integration_session = ActionController::Integration::Session.new(Poller) - end - - def test_successful_get - get "/success" - assert_response 200 - assert_response :success - assert_response :ok - assert_equal "Hello World!", response.body - end - - def test_failed_get - get "/failure" - assert_response 404 - assert_response :not_found - assert_equal '', response.body - end -end diff --git a/vendor/rails/actionpack/test/controller/layout_test.rb b/vendor/rails/actionpack/test/controller/layout_test.rb deleted file mode 100644 index 1575674..0000000 --- a/vendor/rails/actionpack/test/controller/layout_test.rb +++ /dev/null @@ -1,204 +0,0 @@ -require 'abstract_unit' - -# The view_paths array must be set on Base and not LayoutTest so that LayoutTest's inherited -# method has access to the view_paths array when looking for a layout to automatically assign. -old_load_paths = ActionController::Base.view_paths - -ActionView::Template::register_template_handler :mab, - lambda { |template| template.source.inspect } - -ActionController::Base.view_paths = [ File.dirname(__FILE__) + '/../fixtures/layout_tests/' ] - -class LayoutTest < ActionController::Base - def self.controller_path; 'views' end - self.view_paths = ActionController::Base.view_paths.dup -end - -# Restore view_paths to previous value -ActionController::Base.view_paths = old_load_paths - -class ProductController < LayoutTest -end - -class ItemController < LayoutTest -end - -class ThirdPartyTemplateLibraryController < LayoutTest -end - -module ControllerNameSpace -end - -class ControllerNameSpace::NestedController < LayoutTest -end - -class MultipleExtensions < LayoutTest -end - -class LayoutAutoDiscoveryTest < ActionController::TestCase - def setup - @request.host = "www.nextangle.com" - end - - def test_application_layout_is_default_when_no_controller_match - @controller = ProductController.new - get :hello - assert_equal 'layout_test.rhtml hello.rhtml', @response.body - end - - def test_controller_name_layout_name_match - @controller = ItemController.new - get :hello - assert_equal 'item.rhtml hello.rhtml', @response.body - end - - def test_third_party_template_library_auto_discovers_layout - @controller = ThirdPartyTemplateLibraryController.new - get :hello - assert_equal 'layouts/third_party_template_library.mab', @controller.active_layout.to_s - assert_equal 'layouts/third_party_template_library', @response.layout - assert_response :success - assert_equal 'Mab', @response.body - end - - def test_namespaced_controllers_auto_detect_layouts - @controller = ControllerNameSpace::NestedController.new - get :hello - assert_equal 'layouts/controller_name_space/nested', @controller.active_layout.to_s - assert_equal 'controller_name_space/nested.rhtml hello.rhtml', @response.body - end - - def test_namespaced_controllers_auto_detect_layouts - @controller = MultipleExtensions.new - get :hello - assert_equal 'layouts/multiple_extensions.html.erb', @controller.active_layout.to_s - assert_equal 'multiple_extensions.html.erb hello.rhtml', @response.body.strip - end -end - -class DefaultLayoutController < LayoutTest -end - -class AbsolutePathLayoutController < LayoutTest - layout File.expand_path(File.expand_path(__FILE__) + '/../../fixtures/layout_tests/layouts/layout_test.rhtml') -end - -class HasOwnLayoutController < LayoutTest - layout 'item' -end - -class PrependsViewPathController < LayoutTest - def hello - prepend_view_path File.dirname(__FILE__) + '/../fixtures/layout_tests/alt/' - render :layout => 'alt' - end -end - -class SetsLayoutInRenderController < LayoutTest - def hello - render :layout => 'third_party_template_library' - end -end - -class RendersNoLayoutController < LayoutTest - def hello - render :layout => false - end -end - -class LayoutSetInResponseTest < ActionController::TestCase - def test_layout_set_when_using_default_layout - @controller = DefaultLayoutController.new - get :hello - assert_equal 'layouts/layout_test', @response.layout - end - - def test_layout_set_when_set_in_controller - @controller = HasOwnLayoutController.new - get :hello - assert_equal 'layouts/item', @response.layout - end - - def test_layout_set_when_using_render - @controller = SetsLayoutInRenderController.new - get :hello - assert_equal 'layouts/third_party_template_library', @response.layout - end - - def test_layout_is_not_set_when_none_rendered - @controller = RendersNoLayoutController.new - get :hello - assert_nil @response.layout - end - - def test_exempt_from_layout_honored_by_render_template - ActionController::Base.exempt_from_layout :rhtml - @controller = RenderWithTemplateOptionController.new - - get :hello - assert_equal "alt/hello.rhtml", @response.body.strip - - ensure - ActionController::Base.exempt_from_layout.delete(/\.rhtml$/) - end - - def test_layout_is_picked_from_the_controller_instances_view_path - @controller = PrependsViewPathController.new - get :hello - assert_equal 'layouts/alt', @response.layout - end - - def test_absolute_pathed_layout - @controller = AbsolutePathLayoutController.new - get :hello - assert_equal "layout_test.rhtml hello.rhtml", @response.body.strip - end -end - -class RenderWithTemplateOptionController < LayoutTest - def hello - render :template => 'alt/hello' - end -end - -class SetsNonExistentLayoutFile < LayoutTest - layout "nofile.rhtml" -end - -class LayoutExceptionRaised < ActionController::TestCase - def test_exception_raised_when_layout_file_not_found - @controller = SetsNonExistentLayoutFile.new - get :hello - assert_kind_of ActionView::MissingTemplate, @response.template.instance_eval { @exception } - end -end - -class LayoutStatusIsRendered < LayoutTest - def hello - render :status => 401 - end -end - -class LayoutStatusIsRenderedTest < ActionController::TestCase - def test_layout_status_is_rendered - @controller = LayoutStatusIsRendered.new - get :hello - assert_response 401 - end -end - -unless RUBY_PLATFORM =~ /(:?mswin|mingw|bccwin)/ - class LayoutSymlinkedTest < LayoutTest - layout "symlinked/symlinked_layout" - end - - class LayoutSymlinkedIsRenderedTest < ActionController::TestCase - def test_symlinked_layout_is_rendered - @controller = LayoutSymlinkedTest.new - get :hello - assert_response 200 - assert_equal "layouts/symlinked/symlinked_layout", @response.layout - end - end -end - diff --git a/vendor/rails/actionpack/test/controller/logging_test.rb b/vendor/rails/actionpack/test/controller/logging_test.rb deleted file mode 100644 index 3c93685..0000000 --- a/vendor/rails/actionpack/test/controller/logging_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'abstract_unit' - -class LoggingController < ActionController::Base - def show - render :nothing => true - end -end - -class LoggingTest < ActionController::TestCase - tests LoggingController - - class MockLogger - attr_reader :logged - - def method_missing(method, *args) - @logged ||= [] - @logged << args.first - end - end - - setup :set_logger - - def test_logging_without_parameters - get :show - assert_equal 2, logs.size - assert_nil logs.detect {|l| l =~ /Parameters/ } - end - - def test_logging_with_parameters - get :show, :id => 10 - assert_equal 3, logs.size - - params = logs.detect {|l| l =~ /Parameters/ } - assert_equal 'Parameters: {"id"=>"10"}', params - end - - private - - def set_logger - @controller.logger = MockLogger.new - end - - def logs - @logs ||= @controller.logger.logged.compact.map {|l| l.strip} - end -end diff --git a/vendor/rails/actionpack/test/controller/middleware_stack_test.rb b/vendor/rails/actionpack/test/controller/middleware_stack_test.rb deleted file mode 100644 index 9182310..0000000 --- a/vendor/rails/actionpack/test/controller/middleware_stack_test.rb +++ /dev/null @@ -1,90 +0,0 @@ -require 'abstract_unit' - -class MiddlewareStackTest < ActiveSupport::TestCase - class FooMiddleware; end - class BarMiddleware; end - class BazMiddleware; end - - def setup - @stack = ActionController::MiddlewareStack.new - @stack.use FooMiddleware - @stack.use BarMiddleware - end - - test "use should push middleware as class onto the stack" do - assert_difference "@stack.size" do - @stack.use BazMiddleware - end - assert_equal BazMiddleware, @stack.last.klass - end - - test "use should push middleware as a string onto the stack" do - assert_difference "@stack.size" do - @stack.use "MiddlewareStackTest::BazMiddleware" - end - assert_equal BazMiddleware, @stack.last.klass - end - - test "use should push middleware as a symbol onto the stack" do - assert_difference "@stack.size" do - @stack.use :"MiddlewareStackTest::BazMiddleware" - end - assert_equal BazMiddleware, @stack.last.klass - end - - test "use should push middleware class with arguments onto the stack" do - assert_difference "@stack.size" do - @stack.use BazMiddleware, true, :foo => "bar" - end - assert_equal BazMiddleware, @stack.last.klass - assert_equal([true, {:foo => "bar"}], @stack.last.args) - end - - test "insert inserts middleware at the integer index" do - @stack.insert(1, BazMiddleware) - assert_equal BazMiddleware, @stack[1].klass - end - - test "insert_after inserts middleware after the integer index" do - @stack.insert_after(1, BazMiddleware) - assert_equal BazMiddleware, @stack[2].klass - end - - test "insert_before inserts middleware before another middleware class" do - @stack.insert_before(BarMiddleware, BazMiddleware) - assert_equal BazMiddleware, @stack[1].klass - end - - test "insert_after inserts middleware after another middleware class" do - @stack.insert_after(BarMiddleware, BazMiddleware) - assert_equal BazMiddleware, @stack[2].klass - end - - test "swaps one middleware out for another" do - assert_equal FooMiddleware, @stack[0].klass - @stack.swap(FooMiddleware, BazMiddleware) - assert_equal BazMiddleware, @stack[0].klass - end - - test "active returns all only enabled middleware" do - assert_no_difference "@stack.active.size" do - assert_difference "@stack.size" do - @stack.use BazMiddleware, :if => lambda { false } - end - end - end - - test "lazy evaluates middleware class" do - assert_difference "@stack.size" do - @stack.use lambda { BazMiddleware } - end - assert_equal BazMiddleware, @stack.last.klass - end - - test "lazy evaluates middleware arguments" do - assert_difference "@stack.size" do - @stack.use BazMiddleware, lambda { :foo } - end - assert_equal [:foo], @stack.last.send(:build_args) - end -end diff --git a/vendor/rails/actionpack/test/controller/mime_responds_test.rb b/vendor/rails/actionpack/test/controller/mime_responds_test.rb deleted file mode 100644 index edd7162..0000000 --- a/vendor/rails/actionpack/test/controller/mime_responds_test.rb +++ /dev/null @@ -1,536 +0,0 @@ -require 'abstract_unit' - -class RespondToController < ActionController::Base - layout :set_layout - - def html_xml_or_rss - respond_to do |type| - type.html { render :text => "HTML" } - type.xml { render :text => "XML" } - type.rss { render :text => "RSS" } - type.all { render :text => "Nothing" } - end - end - - def js_or_html - respond_to do |type| - type.html { render :text => "HTML" } - type.js { render :text => "JS" } - type.all { render :text => "Nothing" } - end - end - - def json_or_yaml - respond_to do |type| - type.json { render :text => "JSON" } - type.yaml { render :text => "YAML" } - end - end - - def html_or_xml - respond_to do |type| - type.html { render :text => "HTML" } - type.xml { render :text => "XML" } - type.all { render :text => "Nothing" } - end - end - - def forced_xml - request.format = :xml - - respond_to do |type| - type.html { render :text => "HTML" } - type.xml { render :text => "XML" } - end - end - - def just_xml - respond_to do |type| - type.xml { render :text => "XML" } - end - end - - def using_defaults - respond_to do |type| - type.html - type.js - type.xml - end - end - - def using_defaults_with_type_list - respond_to(:html, :js, :xml) - end - - def made_for_content_type - respond_to do |type| - type.rss { render :text => "RSS" } - type.atom { render :text => "ATOM" } - type.all { render :text => "Nothing" } - end - end - - def custom_type_handling - respond_to do |type| - type.html { render :text => "HTML" } - type.custom("application/crazy-xml") { render :text => "Crazy XML" } - type.all { render :text => "Nothing" } - end - end - - def custom_constant_handling - Mime::Type.register("text/x-mobile", :mobile) - - respond_to do |type| - type.html { render :text => "HTML" } - type.mobile { render :text => "Mobile" } - end - ensure - Mime.module_eval { remove_const :MOBILE if const_defined?(:MOBILE) } - end - - def custom_constant_handling_without_block - Mime::Type.register("text/x-mobile", :mobile) - - respond_to do |type| - type.html { render :text => "HTML" } - type.mobile - end - - ensure - Mime.module_eval { remove_const :MOBILE if const_defined?(:MOBILE) } - end - - def handle_any - respond_to do |type| - type.html { render :text => "HTML" } - type.any(:js, :xml) { render :text => "Either JS or XML" } - end - end - - def handle_any_any - respond_to do |type| - type.html { render :text => 'HTML' } - type.any { render :text => 'Whatever you ask for, I got it' } - end - end - - def all_types_with_layout - respond_to do |type| - type.html - type.js - end - end - - def iphone_with_html_response_type - Mime::Type.register_alias("text/html", :iphone) - request.format = :iphone if request.env["HTTP_ACCEPT"] == "text/iphone" - - respond_to do |type| - type.html { @type = "Firefox" } - type.iphone { @type = "iPhone" } - end - - ensure - Mime.module_eval { remove_const :IPHONE if const_defined?(:IPHONE) } - end - - def iphone_with_html_response_type_without_layout - Mime::Type.register_alias("text/html", :iphone) - request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone" - - respond_to do |type| - type.html { @type = "Firefox"; render :action => "iphone_with_html_response_type" } - type.iphone { @type = "iPhone" ; render :action => "iphone_with_html_response_type" } - end - - ensure - Mime.module_eval { remove_const :IPHONE if const_defined?(:IPHONE) } - end - - def rescue_action(e) - raise - end - - protected - def set_layout - if ["all_types_with_layout", "iphone_with_html_response_type"].include?(action_name) - "respond_to/layouts/standard" - elsif action_name == "iphone_with_html_response_type_without_layout" - "respond_to/layouts/missing" - end - end -end - -class MimeControllerTest < ActionController::TestCase - tests RespondToController - - def setup - ActionController::Base.use_accept_header = true - @request.host = "www.example.com" - end - - def teardown - ActionController::Base.use_accept_header = false - end - - def test_html - @request.accept = "text/html" - get :js_or_html - assert_equal 'HTML', @response.body - - get :html_or_xml - assert_equal 'HTML', @response.body - - get :just_xml - assert_response 406 - end - - def test_all - @request.accept = "*/*" - get :js_or_html - assert_equal 'HTML', @response.body # js is not part of all - - get :html_or_xml - assert_equal 'HTML', @response.body - - get :just_xml - assert_equal 'XML', @response.body - end - - def test_xml - @request.accept = "application/xml" - get :html_xml_or_rss - assert_equal 'XML', @response.body - end - - def test_js_or_html - @request.accept = "text/javascript, text/html" - get :js_or_html - assert_equal 'JS', @response.body - - get :html_or_xml - assert_equal 'HTML', @response.body - - get :just_xml - assert_response 406 - end - - def test_json_or_yaml - get :json_or_yaml - assert_equal 'JSON', @response.body - - get :json_or_yaml, :format => 'json' - assert_equal 'JSON', @response.body - - get :json_or_yaml, :format => 'yaml' - assert_equal 'YAML', @response.body - - { 'YAML' => %w(text/yaml), - 'JSON' => %w(application/json text/x-json) - }.each do |body, content_types| - content_types.each do |content_type| - @request.accept = content_type - get :json_or_yaml - assert_equal body, @response.body - end - end - end - - def test_js_or_anything - @request.accept = "text/javascript, */*" - get :js_or_html - assert_equal 'JS', @response.body - - get :html_or_xml - assert_equal 'HTML', @response.body - - get :just_xml - assert_equal 'XML', @response.body - end - - def test_using_defaults - @request.accept = "*/*" - get :using_defaults - assert_equal "text/html", @response.content_type - assert_equal 'Hello world!', @response.body - - @request.accept = "text/javascript" - get :using_defaults - assert_equal "text/javascript", @response.content_type - assert_equal '$("body").visualEffect("highlight");', @response.body - - @request.accept = "application/xml" - get :using_defaults - assert_equal "application/xml", @response.content_type - assert_equal "<p>Hello world!</p>\n", @response.body - end - - def test_using_defaults_with_type_list - @request.accept = "*/*" - get :using_defaults_with_type_list - assert_equal "text/html", @response.content_type - assert_equal 'Hello world!', @response.body - - @request.accept = "text/javascript" - get :using_defaults_with_type_list - assert_equal "text/javascript", @response.content_type - assert_equal '$("body").visualEffect("highlight");', @response.body - - @request.accept = "application/xml" - get :using_defaults_with_type_list - assert_equal "application/xml", @response.content_type - assert_equal "<p>Hello world!</p>\n", @response.body - end - - def test_with_atom_content_type - @request.env["CONTENT_TYPE"] = "application/atom+xml" - get :made_for_content_type - assert_equal "ATOM", @response.body - end - - def test_with_rss_content_type - @request.env["CONTENT_TYPE"] = "application/rss+xml" - get :made_for_content_type - assert_equal "RSS", @response.body - end - - def test_synonyms - @request.accept = "application/javascript" - get :js_or_html - assert_equal 'JS', @response.body - - @request.accept = "application/x-xml" - get :html_xml_or_rss - assert_equal "XML", @response.body - end - - def test_custom_types - @request.accept = "application/crazy-xml" - get :custom_type_handling - assert_equal "application/crazy-xml", @response.content_type - assert_equal 'Crazy XML', @response.body - - @request.accept = "text/html" - get :custom_type_handling - assert_equal "text/html", @response.content_type - assert_equal 'HTML', @response.body - end - - def test_xhtml_alias - @request.accept = "application/xhtml+xml,application/xml" - get :html_or_xml - assert_equal 'HTML', @response.body - end - - def test_firefox_simulation - @request.accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" - get :html_or_xml - assert_equal 'HTML', @response.body - end - - def test_handle_any - @request.accept = "*/*" - get :handle_any - assert_equal 'HTML', @response.body - - @request.accept = "text/javascript" - get :handle_any - assert_equal 'Either JS or XML', @response.body - - @request.accept = "text/xml" - get :handle_any - assert_equal 'Either JS or XML', @response.body - end - - def test_handle_any_any - @request.accept = "*/*" - get :handle_any_any - assert_equal 'HTML', @response.body - end - - def test_handle_any_any_parameter_format - get :handle_any_any, {:format=>'html'} - assert_equal 'HTML', @response.body - end - - def test_handle_any_any_explicit_html - @request.accept = "text/html" - get :handle_any_any - assert_equal 'HTML', @response.body - end - - def test_handle_any_any_javascript - @request.accept = "text/javascript" - get :handle_any_any - assert_equal 'Whatever you ask for, I got it', @response.body - end - - def test_handle_any_any_xml - @request.accept = "text/xml" - get :handle_any_any - assert_equal 'Whatever you ask for, I got it', @response.body - end - - def test_rjs_type_skips_layout - @request.accept = "text/javascript" - get :all_types_with_layout - assert_equal 'RJS for all_types_with_layout', @response.body - end - - def test_html_type_with_layout - @request.accept = "text/html" - get :all_types_with_layout - assert_equal '<html><div id="html">HTML for all_types_with_layout</div></html>', @response.body - end - - def test_xhr - xhr :get, :js_or_html - assert_equal 'JS', @response.body - - xhr :get, :using_defaults - assert_equal '$("body").visualEffect("highlight");', @response.body - end - - def test_custom_constant - get :custom_constant_handling, :format => "mobile" - assert_equal "text/x-mobile", @response.content_type - assert_equal "Mobile", @response.body - end - - def test_custom_constant_handling_without_block - get :custom_constant_handling_without_block, :format => "mobile" - assert_equal "text/x-mobile", @response.content_type - assert_equal "Mobile", @response.body - end - - def test_forced_format - get :html_xml_or_rss - assert_equal "HTML", @response.body - - get :html_xml_or_rss, :format => "html" - assert_equal "HTML", @response.body - - get :html_xml_or_rss, :format => "xml" - assert_equal "XML", @response.body - - get :html_xml_or_rss, :format => "rss" - assert_equal "RSS", @response.body - end - - def test_internally_forced_format - get :forced_xml - assert_equal "XML", @response.body - - get :forced_xml, :format => "html" - assert_equal "XML", @response.body - end - - def test_extension_synonyms - get :html_xml_or_rss, :format => "xhtml" - assert_equal "HTML", @response.body - end - - def test_render_action_for_html - @controller.instance_eval do - def render(*args) - unless args.empty? - @action = args.first[:action] - end - response.body = "#{@action} - #{@template.template_format}" - end - end - - get :using_defaults - assert_equal "using_defaults - html", @response.body - - get :using_defaults, :format => "xml" - assert_equal "using_defaults - xml", @response.body - end - - def test_format_with_custom_response_type - get :iphone_with_html_response_type - assert_equal '<html><div id="html">Hello future from Firefox!</div></html>', @response.body - - get :iphone_with_html_response_type, :format => "iphone" - assert_equal "text/html", @response.content_type - assert_equal '<html><div id="iphone">Hello iPhone future from iPhone!</div></html>', @response.body - end - - def test_format_with_custom_response_type_and_request_headers - @request.accept = "text/iphone" - get :iphone_with_html_response_type - assert_equal '<html><div id="iphone">Hello iPhone future from iPhone!</div></html>', @response.body - assert_equal "text/html", @response.content_type - end - - def test_format_with_custom_response_type_and_request_headers_with_only_one_layout_present - get :iphone_with_html_response_type_without_layout - assert_equal '<html><div id="html_missing">Hello future from Firefox!</div></html>', @response.body - - @request.accept = "text/iphone" - assert_raise(ActionView::MissingTemplate) { get :iphone_with_html_response_type_without_layout } - end -end - -class AbstractPostController < ActionController::Base - self.view_paths = File.dirname(__FILE__) + "/../fixtures/post_test/" -end - -# For testing layouts which are set automatically -class PostController < AbstractPostController - around_filter :with_iphone - - def index - respond_to do |type| - type.html - type.iphone - end - end - - protected - def with_iphone - Mime::Type.register_alias("text/html", :iphone) - request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone" - yield - ensure - Mime.module_eval { remove_const :IPHONE if const_defined?(:IPHONE) } - end -end - -class SuperPostController < PostController - def index - respond_to do |type| - type.html - type.iphone - end - end -end - -class MimeControllerLayoutsTest < ActionController::TestCase - tests PostController - - def setup - @request.host = "www.example.com" - end - - def test_missing_layout_renders_properly - get :index - assert_equal '<html><div id="html">Hello Firefox</div></html>', @response.body - - @request.accept = "text/iphone" - get :index - assert_equal 'Hello iPhone', @response.body - end - - def test_format_with_inherited_layouts - @controller = SuperPostController.new - - get :index - assert_equal 'Super Firefox', @response.body - - @request.accept = "text/iphone" - get :index - assert_equal '<html><div id="super_iphone">Super iPhone</div></html>', @response.body - end -end diff --git a/vendor/rails/actionpack/test/controller/mime_type_test.rb b/vendor/rails/actionpack/test/controller/mime_type_test.rb deleted file mode 100644 index c7faa62..0000000 --- a/vendor/rails/actionpack/test/controller/mime_type_test.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'abstract_unit' - -class MimeTypeTest < Test::Unit::TestCase - Mime::Type.register "image/png", :png - Mime::Type.register "application/pdf", :pdf - - def test_parse_single - Mime::LOOKUP.keys.each do |mime_type| - assert_equal [Mime::Type.lookup(mime_type)], Mime::Type.parse(mime_type) - end - end - - def test_parse_without_q - accept = "text/xml,application/xhtml+xml,text/yaml,application/xml,text/html,image/png,text/plain,application/pdf,*/*" - expect = [Mime::HTML, Mime::XML, Mime::YAML, Mime::PNG, Mime::TEXT, Mime::PDF, Mime::ALL] - assert_equal expect, Mime::Type.parse(accept) - end - - def test_parse_with_q - accept = "text/xml,application/xhtml+xml,text/yaml; q=0.3,application/xml,text/html; q=0.8,image/png,text/plain; q=0.5,application/pdf,*/*; q=0.2" - expect = [Mime::HTML, Mime::XML, Mime::PNG, Mime::PDF, Mime::TEXT, Mime::YAML, Mime::ALL] - assert_equal expect, Mime::Type.parse(accept) - end - - # Accept header send with user HTTP_USER_AGENT: Sunrise/0.42j (Windows XP) - def test_parse_crappy_broken_acceptlines - accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/*,,*/*;q=0.5" - expect = [Mime::HTML, Mime::XML, "image/*", Mime::TEXT, Mime::ALL] - assert_equal expect, Mime::Type.parse(accept).collect { |c| c.to_s } - end - - # Accept header send with user HTTP_USER_AGENT: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1) - def test_parse_crappy_broken_acceptlines2 - accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, , pronto/1.00.00, sslvpn/1.00.00.00, */*" - expect = ['image/gif', 'image/x-xbitmap', 'image/jpeg','image/pjpeg', 'application/x-shockwave-flash', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/msword', 'pronto/1.00.00', 'sslvpn/1.00.00.00', Mime::ALL ] - assert_equal expect, Mime::Type.parse(accept).collect { |c| c.to_s } - end - - def test_custom_type - Mime::Type.register("image/gif", :gif) - assert_nothing_raised do - Mime::GIF - assert_equal Mime::GIF, Mime::SET.last - end - ensure - Mime.module_eval { remove_const :GIF if const_defined?(:GIF) } - end - - def test_type_should_be_equal_to_symbol - assert_equal Mime::HTML, 'application/xhtml+xml' - assert_equal Mime::HTML, :html - end - - def test_type_convenience_methods - # Don't test Mime::ALL, since it Mime::ALL#html? == true - types = Mime::SET.to_a.map(&:to_sym).uniq - [:all] - - # Remove custom Mime::Type instances set in other tests, like Mime::GIF and Mime::IPHONE - types.delete_if { |type| !Mime.const_defined?(type.to_s.upcase) } - - types.each do |type| - mime = Mime.const_get(type.to_s.upcase) - assert mime.send("#{type}?"), "#{mime.inspect} is not #{type}?" - invalid_types = types - [type] - invalid_types.delete(:html) if Mime::Type.html_types.include?(type) - invalid_types.each { |other_type| assert !mime.send("#{other_type}?"), "#{mime.inspect} is #{other_type}?" } - end - end - - def test_mime_all_is_html - assert Mime::ALL.all?, "Mime::ALL is not all?" - assert Mime::ALL.html?, "Mime::ALL is not html?" - end - - def test_verifiable_mime_types - all_types = Mime::SET.to_a.map(&:to_sym) - all_types.uniq! - # Remove custom Mime::Type instances set in other tests, like Mime::GIF and Mime::IPHONE - all_types.delete_if { |type| !Mime.const_defined?(type.to_s.upcase) } - verified, unverified = all_types.partition { |type| Mime::Type.browser_generated_types.include? type } - assert verified.each { |type| assert Mime.const_get(type.to_s.upcase).verify_request?, "Verifiable Mime Type is not verified: #{type.inspect}" } - assert unverified.each { |type| assert !Mime.const_get(type.to_s.upcase).verify_request?, "Nonverifiable Mime Type is verified: #{type.inspect}" } - end - - def test_regexp_matcher - assert Mime::JS =~ "text/javascript" - assert Mime::JS =~ "application/javascript" - assert Mime::JS !~ "text/html" - assert !(Mime::JS !~ "text/javascript") - assert !(Mime::JS !~ "application/javascript") - assert Mime::HTML =~ 'application/xhtml+xml' - end -end diff --git a/vendor/rails/actionpack/test/controller/polymorphic_routes_test.rb b/vendor/rails/actionpack/test/controller/polymorphic_routes_test.rb deleted file mode 100644 index 146d703..0000000 --- a/vendor/rails/actionpack/test/controller/polymorphic_routes_test.rb +++ /dev/null @@ -1,293 +0,0 @@ -require 'abstract_unit' - -class Article - attr_reader :id - def save; @id = 1 end - def new_record?; @id.nil? end - def name - model = self.class.name.downcase - @id.nil? ? "new #{model}" : "#{model} ##{@id}" - end -end - -class Response < Article - def post_id; 1 end -end - -class Tag < Article - def response_id; 1 end -end - -class Tax - attr_reader :id - def save; @id = 1 end - def new_record?; @id.nil? end - def name - model = self.class.name.downcase - @id.nil? ? "new #{model}" : "#{model} ##{@id}" - end -end - -class Fax < Tax - def store_id; 1 end -end - -# TODO: test nested models -class Response::Nested < Response; end - -class PolymorphicRoutesTest < ActiveSupport::TestCase - include ActionController::PolymorphicRoutes - - def setup - @article = Article.new - @response = Response.new - @tax = Tax.new - @fax = Fax.new - end - - def test_with_record - @article.save - expects(:article_url).with(@article) - polymorphic_url(@article) - end - - def test_with_new_record - expects(:articles_url).with() - @article.expects(:new_record?).returns(true) - polymorphic_url(@article) - end - - def test_with_record_and_action - expects(:new_article_url).with() - @article.expects(:new_record?).never - polymorphic_url(@article, :action => 'new') - end - - def test_url_helper_prefixed_with_new - expects(:new_article_url).with() - new_polymorphic_url(@article) - end - - def test_url_helper_prefixed_with_edit - @article.save - expects(:edit_article_url).with(@article) - edit_polymorphic_url(@article) - end - - def test_url_helper_prefixed_with_edit_with_url_options - @article.save - expects(:edit_article_url).with(@article, :param1 => '10') - edit_polymorphic_url(@article, :param1 => '10') - end - - def test_url_helper_with_url_options - @article.save - expects(:article_url).with(@article, :param1 => '10') - polymorphic_url(@article, :param1 => '10') - end - - def test_formatted_url_helper_is_deprecated - expects(:articles_url).with(:format => :pdf) - assert_deprecated do - formatted_polymorphic_url([@article, :pdf]) - end - end - - def test_format_option - @article.save - expects(:article_url).with(@article, :format => :pdf) - polymorphic_url(@article, :format => :pdf) - end - - def test_format_option_with_url_options - @article.save - expects(:article_url).with(@article, :format => :pdf, :param1 => '10') - polymorphic_url(@article, :format => :pdf, :param1 => '10') - end - - def test_id_and_format_option - @article.save - expects(:article_url).with(:id => @article, :format => :pdf) - polymorphic_url(:id => @article, :format => :pdf) - end - - def test_with_nested - @response.save - expects(:article_response_url).with(@article, @response) - polymorphic_url([@article, @response]) - end - - def test_with_nested_unsaved - expects(:article_responses_url).with(@article) - polymorphic_url([@article, @response]) - end - - def test_new_with_array_and_namespace - expects(:new_admin_article_url).with() - polymorphic_url([:admin, @article], :action => 'new') - end - - def test_unsaved_with_array_and_namespace - expects(:admin_articles_url).with() - polymorphic_url([:admin, @article]) - end - - def test_nested_unsaved_with_array_and_namespace - @article.save - expects(:admin_article_url).with(@article) - polymorphic_url([:admin, @article]) - expects(:admin_article_responses_url).with(@article) - polymorphic_url([:admin, @article, @response]) - end - - def test_nested_with_array_and_namespace - @response.save - expects(:admin_article_response_url).with(@article, @response) - polymorphic_url([:admin, @article, @response]) - - # a ridiculously long named route tests correct ordering of namespaces and nesting: - @tag = Tag.new - @tag.save - expects(:site_admin_article_response_tag_url).with(@article, @response, @tag) - polymorphic_url([:site, :admin, @article, @response, @tag]) - end - - def test_nesting_with_array_ending_in_singleton_resource - expects(:article_response_url).with(@article) - polymorphic_url([@article, :response]) - end - - def test_nesting_with_array_containing_singleton_resource - @tag = Tag.new - @tag.save - expects(:article_response_tag_url).with(@article, @tag) - polymorphic_url([@article, :response, @tag]) - end - - def test_nesting_with_array_containing_namespace_and_singleton_resource - @tag = Tag.new - @tag.save - expects(:admin_article_response_tag_url).with(@article, @tag) - polymorphic_url([:admin, @article, :response, @tag]) - end - - def test_nesting_with_array_containing_singleton_resource_and_format - @tag = Tag.new - @tag.save - expects(:article_response_tag_url).with(@article, @tag, :format => :pdf) - polymorphic_url([@article, :response, @tag], :format => :pdf) - end - - def test_nesting_with_array_containing_singleton_resource_and_format_option - @tag = Tag.new - @tag.save - expects(:article_response_tag_url).with(@article, @tag, :format => :pdf) - polymorphic_url([@article, :response, @tag], :format => :pdf) - end - - def test_nesting_with_array_containing_nil - expects(:article_response_url).with(@article) - polymorphic_url([@article, nil, :response]) - end - - def test_with_array_containing_single_object - @article.save - expects(:article_url).with(@article) - polymorphic_url([nil, @article]) - end - - def test_with_array_containing_single_name - @article.save - expects(:articles_url) - polymorphic_url([:articles]) - end - - # TODO: Needs to be updated to correctly know about whether the object is in a hash or not - def xtest_with_hash - expects(:article_url).with(@article) - @article.save - polymorphic_url(:id => @article) - end - - def test_polymorphic_path_accepts_options - expects(:new_article_path).with() - polymorphic_path(@article, :action => :new) - end - - def test_polymorphic_path_does_not_modify_arguments - expects(:admin_article_responses_url).with(@article) - path = [:admin, @article, @response] - assert_no_difference 'path.size' do - polymorphic_url(path) - end - end - - # Tests for names where .plural.singular doesn't round-trip - def test_with_irregular_plural_record - @tax.save - expects(:taxis_url).with(@tax) - polymorphic_url(@tax) - end - - def test_with_irregular_plural_new_record - expects(:taxes_url).with() - @tax.expects(:new_record?).returns(true) - polymorphic_url(@tax) - end - - def test_with_irregular_plural_record_and_action - expects(:new_taxis_url).with() - @tax.expects(:new_record?).never - polymorphic_url(@tax, :action => 'new') - end - - def test_irregular_plural_url_helper_prefixed_with_new - expects(:new_taxis_url).with() - new_polymorphic_url(@tax) - end - - def test_irregular_plural_url_helper_prefixed_with_edit - @tax.save - expects(:edit_taxis_url).with(@tax) - edit_polymorphic_url(@tax) - end - - def test_with_nested_irregular_plurals - @fax.save - expects(:taxis_faxis_url).with(@tax, @fax) - polymorphic_url([@tax, @fax]) - end - - def test_with_nested_unsaved_irregular_plurals - expects(:taxis_faxes_url).with(@tax) - polymorphic_url([@tax, @fax]) - end - - def test_new_with_irregular_plural_array_and_namespace - expects(:new_admin_taxis_url).with() - polymorphic_url([:admin, @tax], :action => 'new') - end - - def test_unsaved_with_irregular_plural_array_and_namespace - expects(:admin_taxes_url).with() - polymorphic_url([:admin, @tax]) - end - - def test_nesting_with_irregular_plurals_and_array_ending_in_singleton_resource - expects(:taxis_faxis_url).with(@tax) - polymorphic_url([@tax, :faxis]) - end - - def test_with_array_containing_single_irregular_plural_object - @tax.save - expects(:taxis_url).with(@tax) - polymorphic_url([nil, @tax]) - end - - def test_with_array_containing_single_name_irregular_plural - @tax.save - expects(:taxes_url) - polymorphic_url([:taxes]) - end - -end diff --git a/vendor/rails/actionpack/test/controller/rack_test.rb b/vendor/rails/actionpack/test/controller/rack_test.rb deleted file mode 100644 index b550d3d..0000000 --- a/vendor/rails/actionpack/test/controller/rack_test.rb +++ /dev/null @@ -1,294 +0,0 @@ -require 'abstract_unit' - -class BaseRackTest < Test::Unit::TestCase - def setup - @env = { - "HTTP_MAX_FORWARDS" => "10", - "SERVER_NAME" => "glu.ttono.us", - "FCGI_ROLE" => "RESPONDER", - "AUTH_TYPE" => "Basic", - "HTTP_X_FORWARDED_HOST" => "glu.ttono.us", - "HTTP_ACCEPT_CHARSET" => "UTF-8", - "HTTP_ACCEPT_ENCODING" => "gzip, deflate", - "HTTP_CACHE_CONTROL" => "no-cache, max-age=0", - "HTTP_PRAGMA" => "no-cache", - "HTTP_USER_AGENT" => "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en)", - "PATH_INFO" => "/homepage/", - "HTTP_ACCEPT_LANGUAGE" => "en", - "HTTP_NEGOTIATE" => "trans", - "HTTP_HOST" => "glu.ttono.us:8007", - "HTTP_REFERER" => "http://www.google.com/search?q=glu.ttono.us", - "HTTP_FROM" => "googlebot", - "SERVER_PROTOCOL" => "HTTP/1.1", - "REDIRECT_URI" => "/dispatch.fcgi", - "SCRIPT_NAME" => "/dispatch.fcgi", - "SERVER_ADDR" => "207.7.108.53", - "REMOTE_ADDR" => "207.7.108.53", - "REMOTE_HOST" => "google.com", - "REMOTE_IDENT" => "kevin", - "REMOTE_USER" => "kevin", - "SERVER_SOFTWARE" => "lighttpd/1.4.5", - "HTTP_COOKIE" => "_session_id=c84ace84796670c052c6ceb2451fb0f2; is_admin=yes", - "HTTP_X_FORWARDED_SERVER" => "glu.ttono.us", - "REQUEST_URI" => "/admin", - "DOCUMENT_ROOT" => "/home/kevinc/sites/typo/public", - "PATH_TRANSLATED" => "/home/kevinc/sites/typo/public/homepage/", - "SERVER_PORT" => "8007", - "QUERY_STRING" => "", - "REMOTE_PORT" => "63137", - "GATEWAY_INTERFACE" => "CGI/1.1", - "HTTP_X_FORWARDED_FOR" => "65.88.180.234", - "HTTP_ACCEPT" => "*/*", - "SCRIPT_FILENAME" => "/home/kevinc/sites/typo/public/dispatch.fcgi", - "REDIRECT_STATUS" => "200", - "REQUEST_METHOD" => "GET" - } - @request = ActionController::Request.new(@env) - # some Nokia phone browsers omit the space after the semicolon separator. - # some developers have grown accustomed to using comma in cookie values. - @alt_cookie_fmt_request = ActionController::Request.new(@env.merge({"HTTP_COOKIE"=>"_session_id=c84ace847,96670c052c6ceb2451fb0f2;is_admin=yes"})) - end - - def default_test; end - - private - - def set_content_data(data) - @request.env['REQUEST_METHOD'] = 'POST' - @request.env['CONTENT_LENGTH'] = data.length - @request.env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded; charset=utf-8' - @request.env['rack.input'] = StringIO.new(data) - end -end - -class RackRequestTest < BaseRackTest - def test_proxy_request - assert_equal 'glu.ttono.us', @request.host_with_port - end - - def test_http_host - @env.delete "HTTP_X_FORWARDED_HOST" - @env['HTTP_HOST'] = "rubyonrails.org:8080" - assert_equal "rubyonrails.org", @request.host - assert_equal "rubyonrails.org:8080", @request.host_with_port - - @env['HTTP_X_FORWARDED_HOST'] = "www.firsthost.org, www.secondhost.org" - assert_equal "www.secondhost.org", @request.host - end - - def test_http_host_with_default_port_overrides_server_port - @env.delete "HTTP_X_FORWARDED_HOST" - @env['HTTP_HOST'] = "rubyonrails.org" - assert_equal "rubyonrails.org", @request.host_with_port - end - - def test_host_with_port_defaults_to_server_name_if_no_host_headers - @env.delete "HTTP_X_FORWARDED_HOST" - @env.delete "HTTP_HOST" - assert_equal "glu.ttono.us:8007", @request.host_with_port - end - - def test_host_with_port_falls_back_to_server_addr_if_necessary - @env.delete "HTTP_X_FORWARDED_HOST" - @env.delete "HTTP_HOST" - @env.delete "SERVER_NAME" - assert_equal "207.7.108.53", @request.host - assert_equal 8007, @request.port - assert_equal "207.7.108.53:8007", @request.host_with_port - end - - def test_host_with_port_if_http_standard_port_is_specified - @env['HTTP_X_FORWARDED_HOST'] = "glu.ttono.us:80" - assert_equal "glu.ttono.us", @request.host_with_port - end - - def test_host_with_port_if_https_standard_port_is_specified - @env['HTTP_X_FORWARDED_PROTO'] = "https" - @env['HTTP_X_FORWARDED_HOST'] = "glu.ttono.us:443" - assert_equal "glu.ttono.us", @request.host_with_port - end - - def test_host_if_ipv6_reference - @env.delete "HTTP_X_FORWARDED_HOST" - @env['HTTP_HOST'] = "[2001:1234:5678:9abc:def0::dead:beef]" - assert_equal "[2001:1234:5678:9abc:def0::dead:beef]", @request.host - end - - def test_host_if_ipv6_reference_with_port - @env.delete "HTTP_X_FORWARDED_HOST" - @env['HTTP_HOST'] = "[2001:1234:5678:9abc:def0::dead:beef]:8008" - assert_equal "[2001:1234:5678:9abc:def0::dead:beef]", @request.host - end - - def test_cgi_environment_variables - assert_equal "Basic", @request.auth_type - assert_equal 0, @request.content_length - assert_equal nil, @request.content_type - assert_equal "CGI/1.1", @request.gateway_interface - assert_equal "*/*", @request.accept - assert_equal "UTF-8", @request.accept_charset - assert_equal "gzip, deflate", @request.accept_encoding - assert_equal "en", @request.accept_language - assert_equal "no-cache, max-age=0", @request.cache_control - assert_equal "googlebot", @request.from - assert_equal "glu.ttono.us", @request.host - assert_equal "trans", @request.negotiate - assert_equal "no-cache", @request.pragma - assert_equal "http://www.google.com/search?q=glu.ttono.us", @request.referer - assert_equal "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en)", @request.user_agent - assert_equal "/homepage/", @request.path_info - assert_equal "/home/kevinc/sites/typo/public/homepage/", @request.path_translated - assert_equal "", @request.query_string - assert_equal "207.7.108.53", @request.remote_addr - assert_equal "google.com", @request.remote_host - assert_equal "kevin", @request.remote_ident - assert_equal "kevin", @request.remote_user - assert_equal :get, @request.request_method - assert_equal "/dispatch.fcgi", @request.script_name - assert_equal "glu.ttono.us", @request.server_name - assert_equal 8007, @request.server_port - assert_equal "HTTP/1.1", @request.server_protocol - assert_equal "lighttpd", @request.server_software - end - - def test_cookie_syntax_resilience - cookies = @request.cookies - assert_equal "c84ace84796670c052c6ceb2451fb0f2", cookies["_session_id"], cookies.inspect - assert_equal "yes", cookies["is_admin"], cookies.inspect - - alt_cookies = @alt_cookie_fmt_request.cookies - #assert_equal "c84ace847,96670c052c6ceb2451fb0f2", alt_cookies["_session_id"], alt_cookies.inspect - assert_equal "yes", alt_cookies["is_admin"], alt_cookies.inspect - end -end - -class RackRequestParamsParsingTest < BaseRackTest - def test_doesnt_break_when_content_type_has_charset - set_content_data 'flamenco=love' - - assert_equal({"flamenco"=> "love"}, @request.request_parameters) - end - - def test_doesnt_interpret_request_uri_as_query_string_when_missing - @request.env['REQUEST_URI'] = 'foo' - assert_equal({}, @request.query_parameters) - end -end - -class RackRequestContentTypeTest < BaseRackTest - def test_html_content_type_verification - @request.env['CONTENT_TYPE'] = Mime::HTML.to_s - assert @request.content_type.verify_request? - end - - def test_xml_content_type_verification - @request.env['CONTENT_TYPE'] = Mime::XML.to_s - assert !@request.content_type.verify_request? - end -end - -class RackRequestNeedsRewoundTest < BaseRackTest - def test_body_should_be_rewound - data = 'foo' - @env['rack.input'] = StringIO.new(data) - @env['CONTENT_LENGTH'] = data.length - @env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded; charset=utf-8' - - # Read the request body by parsing params. - request = ActionController::Request.new(@env) - request.request_parameters - - # Should have rewound the body. - assert_equal 0, request.body.pos - end -end - -class RackResponseTest < BaseRackTest - def setup - super - @response = ActionController::Response.new - end - - def test_simple_output - @response.body = "Hello, World!" - @response.prepare! - - status, headers, body = @response.to_a - assert_equal 200, status - assert_equal({ - "Content-Type" => "text/html; charset=utf-8", - "Cache-Control" => "private, max-age=0, must-revalidate", - "ETag" => '"65a8e27d8879283831b664bd8b7f0ad4"', - "Set-Cookie" => "", - "Content-Length" => "13" - }, headers) - - parts = [] - body.each { |part| parts << part } - assert_equal ["Hello, World!"], parts - end - - def test_utf8_output - @response.body = [1090, 1077, 1089, 1090].pack("U*") - @response.prepare! - - status, headers, body = @response.to_a - assert_equal 200, status - assert_equal({ - "Content-Type" => "text/html; charset=utf-8", - "Cache-Control" => "private, max-age=0, must-revalidate", - "ETag" => '"ebb5e89e8a94e9dd22abf5d915d112b2"', - "Set-Cookie" => "", - "Content-Length" => "8" - }, headers) - end - - def test_streaming_block - @response.body = Proc.new do |response, output| - 5.times { |n| output.write(n) } - end - @response.prepare! - - status, headers, body = @response.to_a - assert_equal 200, status - assert_equal({ - "Content-Type" => "text/html; charset=utf-8", - "Cache-Control" => "no-cache", - "Set-Cookie" => "" - }, headers) - - parts = [] - body.each { |part| parts << part } - assert_equal ["0", "1", "2", "3", "4"], parts - end -end - -class RackResponseHeadersTest < BaseRackTest - def setup - super - @response = ActionController::Response.new - @response.status = "200 OK" - end - - def test_content_type - [204, 304].each do |c| - @response.status = c.to_s - assert !response_headers.has_key?("Content-Type"), "#{c} should not have Content-Type header" - end - - [200, 302, 404, 500].each do |c| - @response.status = c.to_s - assert response_headers.has_key?("Content-Type"), "#{c} did not have Content-Type header" - end - end - - def test_status - assert !response_headers.has_key?('Status') - end - - private - def response_headers - @response.prepare! - @response.to_a[1] - end -end diff --git a/vendor/rails/actionpack/test/controller/record_identifier_test.rb b/vendor/rails/actionpack/test/controller/record_identifier_test.rb deleted file mode 100644 index 12c1eae..0000000 --- a/vendor/rails/actionpack/test/controller/record_identifier_test.rb +++ /dev/null @@ -1,139 +0,0 @@ -require 'abstract_unit' - -class Comment - attr_reader :id - def save; @id = 1 end - def new_record?; @id.nil? end - def name - @id.nil? ? 'new comment' : "comment ##{@id}" - end -end - -class Comment::Nested < Comment; end - -class Test::Unit::TestCase - protected - def comments_url - 'http://www.example.com/comments' - end - - def comment_url(comment) - "http://www.example.com/comments/#{comment.id}" - end -end - - -class RecordIdentifierTest < Test::Unit::TestCase - include ActionController::RecordIdentifier - - def setup - @klass = Comment - @record = @klass.new - @singular = 'comment' - @plural = 'comments' - end - - def test_dom_id_with_new_record - assert_equal "new_#{@singular}", dom_id(@record) - end - - def test_dom_id_with_new_record_and_prefix - assert_equal "custom_prefix_#{@singular}", dom_id(@record, :custom_prefix) - end - - def test_dom_id_with_saved_record - @record.save - assert_equal "#{@singular}_1", dom_id(@record) - end - - def test_dom_id_with_prefix - @record.save - assert_equal "edit_#{@singular}_1", dom_id(@record, :edit) - end - - def test_partial_path - expected = "#{@plural}/#{@singular}" - assert_equal expected, partial_path(@record) - assert_equal expected, partial_path(Comment) - end - - def test_partial_path_with_namespaced_controller_path - expected = "admin/#{@plural}/#{@singular}" - assert_equal expected, partial_path(@record, "admin/posts") - assert_equal expected, partial_path(@klass, "admin/posts") - end - - def test_partial_path_with_not_namespaced_controller_path - expected = "#{@plural}/#{@singular}" - assert_equal expected, partial_path(@record, "posts") - assert_equal expected, partial_path(@klass, "posts") - end - - def test_dom_class - assert_equal @singular, dom_class(@record) - end - - def test_dom_class_with_prefix - assert_equal "custom_prefix_#{@singular}", dom_class(@record, :custom_prefix) - end - - def test_singular_class_name - assert_equal @singular, singular_class_name(@record) - end - - def test_singular_class_name_for_class - assert_equal @singular, singular_class_name(@klass) - end - - def test_plural_class_name - assert_equal @plural, plural_class_name(@record) - end - - def test_plural_class_name_for_class - assert_equal @plural, plural_class_name(@klass) - end - - private - def method_missing(method, *args) - RecordIdentifier.send(method, *args) - end -end - -class NestedRecordIdentifierTest < RecordIdentifierTest - def setup - @klass = Comment::Nested - @record = @klass.new - @singular = 'comment_nested' - @plural = 'comment_nesteds' - end - - def test_partial_path - expected = "comment/nesteds/nested" - assert_equal expected, partial_path(@record) - assert_equal expected, partial_path(Comment::Nested) - end - - def test_partial_path_with_namespaced_controller_path - expected = "admin/comment/nesteds/nested" - assert_equal expected, partial_path(@record, "admin/posts") - assert_equal expected, partial_path(@klass, "admin/posts") - end - - def test_partial_path_with_deeper_namespaced_controller_path - expected = "deeper/admin/comment/nesteds/nested" - assert_equal expected, partial_path(@record, "deeper/admin/posts") - assert_equal expected, partial_path(@klass, "deeper/admin/posts") - end - - def test_partial_path_with_even_deeper_namespaced_controller_path - expected = "even/more/deeper/admin/comment/nesteds/nested" - assert_equal expected, partial_path(@record, "even/more/deeper/admin/posts") - assert_equal expected, partial_path(@klass, "even/more/deeper/admin/posts") - end - - def test_partial_path_with_not_namespaced_controller_path - expected = "comment/nesteds/nested" - assert_equal expected, partial_path(@record, "posts") - assert_equal expected, partial_path(@klass, "posts") - end -end diff --git a/vendor/rails/actionpack/test/controller/redirect_test.rb b/vendor/rails/actionpack/test/controller/redirect_test.rb deleted file mode 100644 index 91e21db..0000000 --- a/vendor/rails/actionpack/test/controller/redirect_test.rb +++ /dev/null @@ -1,282 +0,0 @@ -require 'abstract_unit' - -class WorkshopsController < ActionController::Base -end - -class Workshop - attr_accessor :id, :new_record - - def initialize(id, new_record) - @id, @new_record = id, new_record - end - - def new_record? - @new_record - end - - def to_s - id.to_s - end -end - -class RedirectController < ActionController::Base - def simple_redirect - redirect_to :action => "hello_world" - end - - def redirect_with_status - redirect_to({:action => "hello_world", :status => 301}) - end - - def redirect_with_status_hash - redirect_to({:action => "hello_world"}, {:status => 301}) - end - - def url_redirect_with_status - redirect_to("http://www.example.com", :status => :moved_permanently) - end - - def url_redirect_with_status_hash - redirect_to("http://www.example.com", {:status => 301}) - end - - def relative_url_redirect_with_status - redirect_to("/things/stuff", :status => :found) - end - - def relative_url_redirect_with_status_hash - redirect_to("/things/stuff", {:status => 301}) - end - - def redirect_to_back_with_status - redirect_to :back, :status => 307 - end - - def host_redirect - redirect_to :action => "other_host", :only_path => false, :host => 'other.test.host' - end - - def module_redirect - redirect_to :controller => 'module_test/module_redirect', :action => "hello_world" - end - - def redirect_with_assigns - @hello = "world" - redirect_to :action => "hello_world" - end - - def redirect_to_url - redirect_to "http://www.rubyonrails.org/" - end - - def redirect_to_url_with_unescaped_query_string - redirect_to "http://dev.rubyonrails.org/query?status=new" - end - - def redirect_to_url_with_complex_scheme - redirect_to "x-test+scheme.complex:redirect" - end - - def redirect_to_back - redirect_to :back - end - - def redirect_to_existing_record - redirect_to Workshop.new(5, false) - end - - def redirect_to_new_record - redirect_to Workshop.new(5, true) - end - - def redirect_to_nil - redirect_to nil - end - - def rescue_errors(e) raise e end - - def rescue_action(e) raise end - - protected - def dashbord_url(id, message) - url_for :action => "dashboard", :params => { "id" => id, "message" => message } - end -end - -class RedirectTest < ActionController::TestCase - tests RedirectController - - def test_simple_redirect - get :simple_redirect - assert_response :redirect - assert_equal "http://test.host/redirect/hello_world", redirect_to_url - end - - def test_redirect_with_no_status - get :simple_redirect - assert_response 302 - assert_equal "http://test.host/redirect/hello_world", redirect_to_url - end - - def test_redirect_with_status - get :redirect_with_status - assert_response 301 - assert_equal "http://test.host/redirect/hello_world", redirect_to_url - end - - def test_redirect_with_status_hash - get :redirect_with_status_hash - assert_response 301 - assert_equal "http://test.host/redirect/hello_world", redirect_to_url - end - - def test_url_redirect_with_status - get :url_redirect_with_status - assert_response 301 - assert_equal "http://www.example.com", redirect_to_url - end - - def test_url_redirect_with_status_hash - get :url_redirect_with_status_hash - assert_response 301 - assert_equal "http://www.example.com", redirect_to_url - end - - - def test_relative_url_redirect_with_status - get :relative_url_redirect_with_status - assert_response 302 - assert_equal "http://test.host/things/stuff", redirect_to_url - end - - def test_relative_url_redirect_with_status_hash - get :relative_url_redirect_with_status_hash - assert_response 301 - assert_equal "http://test.host/things/stuff", redirect_to_url - end - - def test_redirect_to_back_with_status - @request.env["HTTP_REFERER"] = "http://www.example.com/coming/from" - get :redirect_to_back_with_status - assert_response 307 - assert_equal "http://www.example.com/coming/from", redirect_to_url - end - - def test_simple_redirect_using_options - get :host_redirect - assert_response :redirect - assert_redirected_to :action => "other_host", :only_path => false, :host => 'other.test.host' - end - - def test_module_redirect - get :module_redirect - assert_response :redirect - assert_redirected_to "http://test.host/module_test/module_redirect/hello_world" - end - - def test_module_redirect_using_options - get :module_redirect - assert_response :redirect - assert_redirected_to :controller => 'module_test/module_redirect', :action => 'hello_world' - end - - def test_redirect_with_assigns - get :redirect_with_assigns - assert_response :redirect - assert_equal "world", assigns["hello"] - end - - def test_redirect_to_url - get :redirect_to_url - assert_response :redirect - assert_redirected_to "http://www.rubyonrails.org/" - end - - def test_redirect_to_url_with_unescaped_query_string - get :redirect_to_url_with_unescaped_query_string - assert_response :redirect - assert_redirected_to "http://dev.rubyonrails.org/query?status=new" - end - - def test_redirect_to_url_with_complex_scheme - get :redirect_to_url_with_complex_scheme - assert_response :redirect - assert_equal "x-test+scheme.complex:redirect", redirect_to_url - end - - def test_redirect_to_back - @request.env["HTTP_REFERER"] = "http://www.example.com/coming/from" - get :redirect_to_back - assert_response :redirect - assert_equal "http://www.example.com/coming/from", redirect_to_url - end - - def test_redirect_to_back_with_no_referer - assert_raise(ActionController::RedirectBackError) { - @request.env["HTTP_REFERER"] = nil - get :redirect_to_back - } - end - - def test_redirect_to_record - ActionController::Routing::Routes.draw do |map| - map.resources :workshops - map.connect ':controller/:action/:id' - end - - get :redirect_to_existing_record - assert_equal "http://test.host/workshops/5", redirect_to_url - assert_redirected_to Workshop.new(5, false) - - get :redirect_to_new_record - assert_equal "http://test.host/workshops", redirect_to_url - assert_redirected_to Workshop.new(5, true) - end - - def test_redirect_with_partial_params - get :module_redirect - assert_redirected_to :action => 'hello_world' - end - - def test_redirect_to_nil - assert_raise(ActionController::ActionControllerError) do - get :redirect_to_nil - end - end -end - -module ModuleTest - class ModuleRedirectController < ::RedirectController - def module_redirect - redirect_to :controller => '/redirect', :action => "hello_world" - end - end - - class ModuleRedirectTest < ActionController::TestCase - tests ModuleRedirectController - - def test_simple_redirect - get :simple_redirect - assert_response :redirect - assert_equal "http://test.host/module_test/module_redirect/hello_world", redirect_to_url - end - - def test_simple_redirect_using_options - get :host_redirect - assert_response :redirect - assert_redirected_to :action => "other_host", :only_path => false, :host => 'other.test.host' - end - - def test_module_redirect - get :module_redirect - assert_response :redirect - assert_equal "http://test.host/redirect/hello_world", redirect_to_url - end - - def test_module_redirect_using_options - get :module_redirect - assert_response :redirect - assert_redirected_to :controller => '/redirect', :action => "hello_world" - end - end -end diff --git a/vendor/rails/actionpack/test/controller/render_test.rb b/vendor/rails/actionpack/test/controller/render_test.rb deleted file mode 100644 index a529315..0000000 --- a/vendor/rails/actionpack/test/controller/render_test.rb +++ /dev/null @@ -1,1752 +0,0 @@ -require 'abstract_unit' -require 'controller/fake_models' - -module Fun - class GamesController < ActionController::Base - def hello_world - end - end -end - -class MockLogger - attr_reader :logged - - def initialize - @logged = [] - end - - def method_missing(method, *args) - @logged << args.first - end -end - -class TestController < ActionController::Base - protect_from_forgery - - class LabellingFormBuilder < ActionView::Helpers::FormBuilder - end - - layout :determine_layout - - def hello_world - end - - def conditional_hello - if stale?(:last_modified => Time.now.utc.beginning_of_day, :etag => [:foo, 123]) - render :action => 'hello_world' - end - end - - def conditional_hello_with_public_header - if stale?(:last_modified => Time.now.utc.beginning_of_day, :etag => [:foo, 123], :public => true) - render :action => 'hello_world' - end - end - - def conditional_hello_with_public_header_and_expires_at - expires_in 1.minute - if stale?(:last_modified => Time.now.utc.beginning_of_day, :etag => [:foo, 123], :public => true) - render :action => 'hello_world' - end - end - - def conditional_hello_with_expires_in - expires_in 1.minute - render :action => 'hello_world' - end - - def conditional_hello_with_expires_in_with_public - expires_in 1.minute, :public => true - render :action => 'hello_world' - end - - def conditional_hello_with_expires_in_with_public_with_more_keys - expires_in 1.minute, :public => true, 'max-stale' => 5.hours - render :action => 'hello_world' - end - - def conditional_hello_with_expires_in_with_public_with_more_keys_old_syntax - expires_in 1.minute, :public => true, :private => nil, 'max-stale' => 5.hours - render :action => 'hello_world' - end - - def conditional_hello_with_bangs - render :action => 'hello_world' - end - before_filter :handle_last_modified_and_etags, :only=>:conditional_hello_with_bangs - - def handle_last_modified_and_etags - fresh_when(:last_modified => Time.now.utc.beginning_of_day, :etag => [ :foo, 123 ]) - end - - def render_hello_world - render :template => "test/hello_world" - end - - def render_hello_world_with_last_modified_set - response.last_modified = Date.new(2008, 10, 10).to_time - render :template => "test/hello_world" - end - - def render_hello_world_with_etag_set - response.etag = "hello_world" - render :template => "test/hello_world" - end - - def render_hello_world_with_forward_slash - render :template => "/test/hello_world" - end - - def render_template_in_top_directory - render :template => 'shared' - end - - def render_template_in_top_directory_with_slash - render :template => '/shared' - end - - def render_hello_world_from_variable - @person = "david" - render :text => "hello #{@person}" - end - - def render_action_hello_world - render :action => "hello_world" - end - - def render_action_hello_world_as_string - render "hello_world" - end - - def render_action_hello_world_with_symbol - render :action => :hello_world - end - - def render_text_hello_world - render :text => "hello world" - end - - def render_text_hello_world_with_layout - @variable_for_layout = ", I'm here!" - render :text => "hello world", :layout => true - end - - def hello_world_with_layout_false - render :layout => false - end - - def render_file_with_instance_variables - @secret = 'in the sauce' - path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.erb') - render :file => path - end - - def render_file_as_string_with_instance_variables - @secret = 'in the sauce' - path = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.erb')) - render path - end - - def render_file_not_using_full_path - @secret = 'in the sauce' - render :file => 'test/render_file_with_ivar' - end - - def render_file_not_using_full_path_with_dot_in_path - @secret = 'in the sauce' - render :file => 'test/dot.directory/render_file_with_ivar' - end - - def render_file_using_pathname - @secret = 'in the sauce' - render :file => Pathname.new(File.dirname(__FILE__)).join('..', 'fixtures', 'test', 'dot.directory', 'render_file_with_ivar.erb') - end - - def render_file_from_template - @secret = 'in the sauce' - @path = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.erb')) - end - - def render_file_with_locals - path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_locals.erb') - render :file => path, :locals => {:secret => 'in the sauce'} - end - - def render_file_as_string_with_locals - path = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_locals.erb')) - render path, :locals => {:secret => 'in the sauce'} - end - - def accessing_request_in_template - render :inline => "Hello: <%= request.host %>" - end - - def accessing_logger_in_template - render :inline => "<%= logger.class %>" - end - - def accessing_action_name_in_template - render :inline => "<%= action_name %>" - end - - def accessing_controller_name_in_template - render :inline => "<%= controller_name %>" - end - - def render_json_hello_world - render :json => {:hello => 'world'}.to_json - end - - def render_json_hello_world_with_callback - render :json => {:hello => 'world'}.to_json, :callback => 'alert' - end - - def render_json_with_custom_content_type - render :json => {:hello => 'world'}.to_json, :content_type => 'text/javascript' - end - - def render_symbol_json - render :json => {:hello => 'world'}.to_json - end - - def render_json_with_render_to_string - render :json => {:hello => render_to_string(:partial => 'partial')} - end - - def render_custom_code - render :text => "hello world", :status => 404 - end - - def render_custom_code_rjs - render :update, :status => 404 do |page| - page.replace :foo, :partial => 'partial' - end - end - - def render_text_with_nil - render :text => nil - end - - def render_text_with_false - render :text => false - end - - def render_nothing_with_appendix - render :text => "appended" - end - - def render_vanilla_js_hello - render :js => "alert('hello')" - end - - def render_xml_hello - @name = "David" - render :template => "test/hello" - end - - def render_xml_hello_as_string_template - @name = "David" - render "test/hello" - end - - def render_xml_with_custom_content_type - render :xml => "<blah/>", :content_type => "application/atomsvc+xml" - end - - def render_line_offset - render :inline => '<% raise %>', :locals => {:foo => 'bar'} - end - - def heading - head :ok - end - - def greeting - # let's just rely on the template - end - - def blank_response - render :text => ' ' - end - - def layout_test - render :action => "hello_world" - end - - def builder_layout_test - render :action => "hello", :layout => "layouts/builder" - end - - def builder_partial_test - render :action => "hello_world_container" - end - - def partials_list - @test_unchanged = 'hello' - @customers = [ Customer.new("david"), Customer.new("mary") ] - render :action => "list" - end - - def partial_only - render :partial => true - end - - def hello_in_a_string - @customers = [ Customer.new("david"), Customer.new("mary") ] - render :text => "How's there? " + render_to_string(:template => "test/list") - end - - def accessing_params_in_template - render :inline => "Hello: <%= params[:name] %>" - end - - def accessing_local_assigns_in_inline_template - name = params[:local_name] - render :inline => "<%= 'Goodbye, ' + local_name %>", - :locals => { :local_name => name } - end - - def render_implicit_html_template - end - - def render_explicit_html_template - end - - def render_implicit_html_template_from_xhr_request - end - - def render_implicit_js_template_without_layout - end - - def render_html_explicit_template_and_layout - render :template => 'test/render_implicit_html_template_from_xhr_request', :layout => 'layouts/default_html' - end - - def formatted_html_erb - end - - def formatted_xml_erb - end - - def render_to_string_test - @foo = render_to_string :inline => "this is a test" - end - - def default_render - if @alternate_default_render - @alternate_default_render.call - else - super - end - end - - def render_action_hello_world_as_symbol - render :action => :hello_world - end - - def layout_test_with_different_layout - render :action => "hello_world", :layout => "standard" - end - - def layout_test_with_different_layout_and_string_action - render "hello_world", :layout => "standard" - end - - def layout_test_with_different_layout_and_symbol_action - render :hello_world, :layout => "standard" - end - - def rendering_without_layout - render :action => "hello_world", :layout => false - end - - def layout_overriding_layout - render :action => "hello_world", :layout => "standard" - end - - def rendering_nothing_on_layout - render :nothing => true - end - - def render_to_string_with_assigns - @before = "i'm before the render" - render_to_string :text => "foo" - @after = "i'm after the render" - render :action => "test/hello_world" - end - - def render_to_string_with_exception - render_to_string :file => "exception that will not be caught - this will certainly not work" - end - - def render_to_string_with_caught_exception - @before = "i'm before the render" - begin - render_to_string :file => "exception that will be caught- hope my future instance vars still work!" - rescue - end - @after = "i'm after the render" - render :action => "test/hello_world" - end - - def accessing_params_in_template_with_layout - render :layout => nil, :inline => "Hello: <%= params[:name] %>" - end - - def render_with_explicit_template - render :template => "test/hello_world" - end - - def render_with_explicit_string_template - render "test/hello_world" - end - - def render_with_explicit_template_with_locals - render :template => "test/render_file_with_locals", :locals => { :secret => 'area51' } - end - - def double_render - render :text => "hello" - render :text => "world" - end - - def double_redirect - redirect_to :action => "double_render" - redirect_to :action => "double_render" - end - - def render_and_redirect - render :text => "hello" - redirect_to :action => "double_render" - end - - def render_to_string_and_render - @stuff = render_to_string :text => "here is some cached stuff" - render :text => "Hi web users! #{@stuff}" - end - - def render_to_string_with_inline_and_render - render_to_string :inline => "<%= 'dlrow olleh'.reverse %>" - render :template => "test/hello_world" - end - - def rendering_with_conflicting_local_vars - @name = "David" - def @template.name() nil end - render :action => "potential_conflicts" - end - - def hello_world_from_rxml_using_action - render :action => "hello_world_from_rxml.builder" - end - - def hello_world_from_rxml_using_template - render :template => "test/hello_world_from_rxml.builder" - end - - module RenderTestHelper - def rjs_helper_method_from_module - page.visual_effect :highlight - end - end - - helper RenderTestHelper - helper do - def rjs_helper_method(value) - page.visual_effect :highlight, value - end - end - - def enum_rjs_test - render :update do |page| - page.select('.product').each do |value| - page.rjs_helper_method_from_module - page.rjs_helper_method(value) - page.sortable(value, :url => { :action => "order" }) - page.draggable(value) - end - end - end - - def delete_with_js - @project_id = 4 - end - - def render_js_with_explicit_template - @project_id = 4 - render :template => 'test/delete_with_js' - end - - def render_js_with_explicit_action_template - @project_id = 4 - render :action => 'delete_with_js' - end - - def update_page - render :update do |page| - page.replace_html 'balance', '$37,000,000.00' - page.visual_effect :highlight, 'balance' - end - end - - def update_page_with_instance_variables - @money = '$37,000,000.00' - @div_id = 'balance' - render :update do |page| - page.replace_html @div_id, @money - page.visual_effect :highlight, @div_id - end - end - - def update_page_with_view_method - render :update do |page| - page.replace_html 'person', pluralize(2, 'person') - end - end - - def action_talk_to_layout - # Action template sets variable that's picked up by layout - end - - def render_text_with_assigns - @hello = "world" - render :text => "foo" - end - - def yield_content_for - render :action => "content_for", :layout => "yield" - end - - def render_content_type_from_body - response.content_type = Mime::RSS - render :text => "hello world!" - end - - def head_with_location_header - head :location => "/foo" - end - - def head_with_symbolic_status - head :status => params[:status].intern - end - - def head_with_integer_status - head :status => params[:status].to_i - end - - def head_with_string_status - head :status => params[:status] - end - - def head_with_custom_header - head :x_custom_header => "something" - end - - def head_with_status_code_first - head :forbidden, :x_custom_header => "something" - end - - def render_with_location - render :xml => "<hello/>", :location => "http://example.com", :status => 201 - end - - def render_with_object_location - customer = Customer.new("Some guy", 1) - render :xml => "<customer/>", :location => customer_url(customer), :status => :created - end - - def render_with_to_xml - to_xmlable = Class.new do - def to_xml - "<i-am-xml/>" - end - end.new - - render :xml => to_xmlable - end - - def render_using_layout_around_block - render :action => "using_layout_around_block" - end - - def render_using_layout_around_block_with_args - render :action => "using_layout_around_block_with_args" - end - - def render_using_layout_around_block_in_main_layout_and_within_content_for_layout - render :action => "using_layout_around_block", :layout => "layouts/block_with_layout" - end - - def partial_dot_html - render :partial => 'partial.html.erb' - end - - def partial_as_rjs - render :update do |page| - page.replace :foo, :partial => 'partial' - end - end - - def respond_to_partial_as_rjs - respond_to do |format| - format.js do - render :update do |page| - page.replace :foo, :partial => 'partial' - end - end - end - end - - def partial - render :partial => 'partial' - end - - def render_alternate_default - # For this test, the method "default_render" is overridden: - @alternate_default_render = lambda do - render :update do |page| - page.replace :foo, :partial => 'partial' - end - end - end - - def partial_only_with_layout - render :partial => "partial_only", :layout => true - end - - def render_to_string_with_partial - @partial_only = render_to_string :partial => "partial_only" - @partial_with_locals = render_to_string :partial => "customer", :locals => { :customer => Customer.new("david") } - render :action => "test/hello_world" - end - - def partial_with_counter - render :partial => "counter", :locals => { :counter_counter => 5 } - end - - def partial_with_locals - render :partial => "customer", :locals => { :customer => Customer.new("david") } - end - - def partial_with_form_builder - render :partial => ActionView::Helpers::FormBuilder.new(:post, nil, @template, {}, Proc.new {}) - end - - def partial_with_form_builder_subclass - render :partial => LabellingFormBuilder.new(:post, nil, @template, {}, Proc.new {}) - end - - def partial_collection - render :partial => "customer", :collection => [ Customer.new("david"), Customer.new("mary") ] - end - - def partial_collection_with_as - render :partial => "customer_with_var", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => :customer - end - - def partial_collection_with_counter - render :partial => "customer_counter", :collection => [ Customer.new("david"), Customer.new("mary") ] - end - - def partial_collection_with_locals - render :partial => "customer_greeting", :collection => [ Customer.new("david"), Customer.new("mary") ], :locals => { :greeting => "Bonjour" } - end - - def partial_collection_with_spacer - render :partial => "customer", :spacer_template => "partial_only", :collection => [ Customer.new("david"), Customer.new("mary") ] - end - - def partial_collection_shorthand_with_locals - render :partial => [ Customer.new("david"), Customer.new("mary") ], :locals => { :greeting => "Bonjour" } - end - - def partial_collection_shorthand_with_different_types_of_records - render :partial => [ - BadCustomer.new("mark"), - GoodCustomer.new("craig"), - BadCustomer.new("john"), - GoodCustomer.new("zach"), - GoodCustomer.new("brandon"), - BadCustomer.new("dan") ], - :locals => { :greeting => "Bonjour" } - end - - def empty_partial_collection - render :partial => "customer", :collection => [] - end - - def partial_collection_shorthand_with_different_types_of_records_with_counter - partial_collection_shorthand_with_different_types_of_records - end - - def missing_partial - render :partial => 'thisFileIsntHere' - end - - def partial_with_hash_object - render :partial => "hash_object", :object => {:first_name => "Sam"} - end - - def partial_with_nested_object - render :partial => "quiz/questions/question", :object => Quiz::Question.new("first") - end - - def partial_with_nested_object_shorthand - render Quiz::Question.new("first") - end - - def partial_hash_collection - render :partial => "hash_object", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ] - end - - def partial_hash_collection_with_locals - render :partial => "hash_greeting", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ], :locals => { :greeting => "Hola" } - end - - def partial_with_implicit_local_assignment - @customer = Customer.new("Marcel") - render :partial => "customer" - end - - def render_call_to_partial_with_layout - render :action => "calling_partial_with_layout" - end - - def render_call_to_partial_with_layout_in_main_layout_and_within_content_for_layout - render :action => "calling_partial_with_layout", :layout => "layouts/partial_with_layout" - end - - def rescue_action(e) - raise - end - - private - def determine_layout - case action_name - when "hello_world", "layout_test", "rendering_without_layout", - "rendering_nothing_on_layout", "render_text_hello_world", - "render_text_hello_world_with_layout", - "hello_world_with_layout_false", - "partial_only", "partial_only_with_layout", - "accessing_params_in_template", - "accessing_params_in_template_with_layout", - "render_with_explicit_template", - "render_with_explicit_string_template", - "render_js_with_explicit_template", - "render_js_with_explicit_action_template", - "delete_with_js", "update_page", "update_page_with_instance_variables" - - "layouts/standard" - when "render_implicit_js_template_without_layout" - "layouts/default_html" - when "action_talk_to_layout", "layout_overriding_layout" - "layouts/talk_from_action" - when "render_implicit_html_template_from_xhr_request" - (request.xhr? ? 'layouts/xhr' : 'layouts/standard') - end - end -end - -class RenderTest < ActionController::TestCase - tests TestController - - def setup - # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get - # a more accurate simulation of what happens in "real life". - @controller.logger = Logger.new(nil) - - @request.host = "www.nextangle.com" - end - - def test_simple_show - get :hello_world - assert_response 200 - assert_response :success - assert_template "test/hello_world" - assert_equal "<html>Hello world!</html>", @response.body - end - - def test_renders_default_template_for_missing_action - get :'hyphen-ated' - assert_template 'test/hyphen-ated' - end - - def test_render - get :render_hello_world - assert_template "test/hello_world" - end - - def test_line_offset - begin - get :render_line_offset - flunk "the action should have raised an exception" - rescue RuntimeError => exc - line = exc.backtrace.first - assert(line =~ %r{:(\d+):}) - assert_equal "1", $1, - "The line offset is wrong, perhaps the wrong exception has been raised, exception was: #{exc.inspect}" - end - end - - def test_render_with_forward_slash - get :render_hello_world_with_forward_slash - assert_template "test/hello_world" - end - - def test_render_in_top_directory - get :render_template_in_top_directory - assert_template "shared" - assert_equal "Elastica", @response.body - end - - def test_render_in_top_directory_with_slash - get :render_template_in_top_directory_with_slash - assert_template "shared" - assert_equal "Elastica", @response.body - end - - def test_render_from_variable - get :render_hello_world_from_variable - assert_equal "hello david", @response.body - end - - def test_render_action - get :render_action_hello_world - assert_template "test/hello_world" - end - - def test_render_action_hello_world_as_string - get :render_action_hello_world_as_string - assert_equal "Hello world!", @response.body - assert_template "test/hello_world" - end - - def test_render_action_with_symbol - get :render_action_hello_world_with_symbol - assert_template "test/hello_world" - end - - def test_render_text - get :render_text_hello_world - assert_equal "hello world", @response.body - end - - def test_do_with_render_text_and_layout - get :render_text_hello_world_with_layout - assert_equal "<html>hello world, I'm here!</html>", @response.body - end - - def test_xhr_with_render_text_and_layout - xhr :get, :render_text_hello_world_with_layout - assert_equal "<html>hello world, I'm here!</html>", @response.body - end - - def test_do_with_render_action_and_layout_false - get :hello_world_with_layout_false - assert_equal 'Hello world!', @response.body - end - - def test_render_file_with_instance_variables - get :render_file_with_instance_variables - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_file_as_string_with_instance_variables - get :render_file_as_string_with_instance_variables - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_file_not_using_full_path - get :render_file_not_using_full_path - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_file_not_using_full_path_with_dot_in_path - get :render_file_not_using_full_path_with_dot_in_path - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_file_using_pathname - get :render_file_using_pathname - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_file_with_locals - get :render_file_with_locals - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_file_as_string_with_locals - get :render_file_as_string_with_locals - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_file_from_template - get :render_file_from_template - assert_equal "The secret is in the sauce\n", @response.body - end - - def test_render_json - get :render_json_hello_world - assert_equal '{"hello": "world"}', @response.body - assert_equal 'application/json', @response.content_type - end - - def test_render_json_with_callback - get :render_json_hello_world_with_callback - assert_equal 'alert({"hello": "world"})', @response.body - assert_equal 'application/json', @response.content_type - end - - def test_render_json_with_custom_content_type - get :render_json_with_custom_content_type - assert_equal '{"hello": "world"}', @response.body - assert_equal 'text/javascript', @response.content_type - end - - def test_render_symbol_json - get :render_symbol_json - assert_equal '{"hello": "world"}', @response.body - assert_equal 'application/json', @response.content_type - end - - def test_render_json_with_render_to_string - get :render_json_with_render_to_string - assert_equal '{"hello": "partial html"}', @response.body - assert_equal 'application/json', @response.content_type - end - - def test_render_custom_code - get :render_custom_code - assert_response 404 - assert_response :missing - assert_equal 'hello world', @response.body - end - - def test_render_custom_code_rjs - get :render_custom_code_rjs - assert_response 404 - assert_equal %(Element.replace("foo", "partial html");), @response.body - end - - def test_render_text_with_nil - get :render_text_with_nil - assert_response 200 - assert_equal ' ', @response.body - end - - def test_render_text_with_false - get :render_text_with_false - assert_equal 'false', @response.body - end - - def test_render_nothing_with_appendix - get :render_nothing_with_appendix - assert_response 200 - assert_equal 'appended', @response.body - end - - def test_attempt_to_access_object_method - assert_raise(ActionController::UnknownAction, "No action responded to [clone]") { get :clone } - end - - def test_private_methods - assert_raise(ActionController::UnknownAction, "No action responded to [determine_layout]") { get :determine_layout } - end - - def test_access_to_request_in_view - get :accessing_request_in_template - assert_equal "Hello: www.nextangle.com", @response.body - end - - def test_access_to_logger_in_view - get :accessing_logger_in_template - assert_equal "Logger", @response.body - end - - def test_access_to_action_name_in_view - get :accessing_action_name_in_template - assert_equal "accessing_action_name_in_template", @response.body - end - - def test_access_to_controller_name_in_view - get :accessing_controller_name_in_template - assert_equal "test", @response.body # name is explicitly set to 'test' inside the controller. - end - - def test_render_vanilla_js - get :render_vanilla_js_hello - assert_equal "alert('hello')", @response.body - assert_equal "text/javascript", @response.content_type - end - - def test_render_xml - get :render_xml_hello - assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body - assert_equal "application/xml", @response.content_type - end - - def test_render_xml_as_string_template - get :render_xml_hello_as_string_template - assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body - assert_equal "application/xml", @response.content_type - end - - def test_render_xml_with_default - get :greeting - assert_equal "<p>This is grand!</p>\n", @response.body - end - - def test_render_xml_with_partial - get :builder_partial_test - assert_equal "<test>\n <hello/>\n</test>\n", @response.body - end - - def test_enum_rjs_test - ActiveSupport::SecureRandom.stubs(:base64).returns("asdf") - get :enum_rjs_test - body = %{ - $$(".product").each(function(value, index) { - new Effect.Highlight(element,{}); - new Effect.Highlight(value,{}); - Sortable.create(value, {onUpdate:function(){new Ajax.Request('/test/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(value) + '&authenticity_token=' + encodeURIComponent('asdf')})}}); - new Draggable(value, {}); - }); - }.gsub(/^ /, '').strip - assert_equal body, @response.body - end - - def test_layout_rendering - get :layout_test - assert_equal "<html>Hello world!</html>", @response.body - end - - def test_render_xml_with_layouts - get :builder_layout_test - assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", @response.body - end - - def test_partials_list - get :partials_list - assert_equal "goodbyeHello: davidHello: marygoodbye\n", @response.body - end - - def test_render_to_string - get :hello_in_a_string - assert_equal "How's there? goodbyeHello: davidHello: marygoodbye\n", @response.body - end - - def test_render_to_string_resets_assigns - get :render_to_string_test - assert_equal "The value of foo is: ::this is a test::\n", @response.body - end - - def test_render_to_string_inline - get :render_to_string_with_inline_and_render - assert_template "test/hello_world" - end - - def test_nested_rendering - @controller = Fun::GamesController.new - get :hello_world - assert_equal "Living in a nested world", @response.body - end - - def test_accessing_params_in_template - get :accessing_params_in_template, :name => "David" - assert_equal "Hello: David", @response.body - end - - def test_accessing_local_assigns_in_inline_template - get :accessing_local_assigns_in_inline_template, :local_name => "Local David" - assert_equal "Goodbye, Local David", @response.body - end - - def test_render_in_an_rjs_template_should_pick_html_templates_when_available - [:js, "js"].each do |format| - assert_nothing_raised do - get :render_implicit_html_template, :format => format - assert_equal %(document.write("Hello world\\n");), @response.body - end - end - end - - def test_explicitly_rendering_an_html_template_with_implicit_html_template_renders_should_be_possible_from_an_rjs_template - [:js, "js"].each do |format| - assert_nothing_raised do - get :render_explicit_html_template, :format => format - assert_equal %(document.write("Hello world\\n");), @response.body - end - end - end - - def test_should_implicitly_render_html_template_from_xhr_request - xhr :get, :render_implicit_html_template_from_xhr_request - assert_equal "XHR!\nHello HTML!", @response.body - end - - def test_should_render_explicit_html_template_with_html_layout - xhr :get, :render_html_explicit_template_and_layout - assert_equal "<html>Hello HTML!</html>\n", @response.body - end - - def test_should_implicitly_render_js_template_without_layout - get :render_implicit_js_template_without_layout, :format => :js - assert_no_match /<html>/, @response.body - end - - def test_should_render_formatted_template - get :formatted_html_erb - assert_equal 'formatted html erb', @response.body - end - - def test_should_render_formatted_xml_erb_template - get :formatted_xml_erb, :format => :xml - assert_equal '<test>passed formatted xml erb</test>', @response.body - end - - def test_should_render_formatted_html_erb_template - get :formatted_xml_erb - assert_equal '<test>passed formatted html erb</test>', @response.body - end - - def test_should_render_formatted_html_erb_template_with_faulty_accepts_header - @request.accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, appliction/x-shockwave-flash, */*" - get :formatted_xml_erb - assert_equal '<test>passed formatted html erb</test>', @response.body - end - - def test_should_render_xml_but_keep_custom_content_type - get :render_xml_with_custom_content_type - assert_equal "application/atomsvc+xml", @response.content_type - end - - def test_render_with_default_from_accept_header - xhr :get, :greeting - assert_equal "$(\"body\").visualEffect(\"highlight\");", @response.body - end - - def test_render_rjs_with_default - get :delete_with_js - assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body - end - - def test_render_rjs_template_explicitly - get :render_js_with_explicit_template - assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body - end - - def test_rendering_rjs_action_explicitly - get :render_js_with_explicit_action_template - assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body - end - - def test_layout_test_with_different_layout - get :layout_test_with_different_layout - assert_equal "<html>Hello world!</html>", @response.body - end - - def test_layout_test_with_different_layout_and_string_action - get :layout_test_with_different_layout_and_string_action - assert_equal "<html>Hello world!</html>", @response.body - end - - def test_layout_test_with_different_layout_and_symbol_action - get :layout_test_with_different_layout_and_symbol_action - assert_equal "<html>Hello world!</html>", @response.body - end - - def test_rendering_without_layout - get :rendering_without_layout - assert_equal "Hello world!", @response.body - end - - def test_layout_overriding_layout - get :layout_overriding_layout - assert_no_match %r{<title>}, @response.body - end - - def test_rendering_nothing_on_layout - get :rendering_nothing_on_layout - assert_equal " ", @response.body - end - - def test_render_to_string - assert_not_deprecated { get :hello_in_a_string } - assert_equal "How's there? goodbyeHello: davidHello: marygoodbye\n", @response.body - end - - def test_render_to_string_doesnt_break_assigns - get :render_to_string_with_assigns - assert_equal "i'm before the render", assigns(:before) - assert_equal "i'm after the render", assigns(:after) - end - - def test_bad_render_to_string_still_throws_exception - assert_raise(ActionView::MissingTemplate) { get :render_to_string_with_exception } - end - - def test_render_to_string_that_throws_caught_exception_doesnt_break_assigns - assert_nothing_raised { get :render_to_string_with_caught_exception } - assert_equal "i'm before the render", assigns(:before) - assert_equal "i'm after the render", assigns(:after) - end - - def test_accessing_params_in_template_with_layout - get :accessing_params_in_template_with_layout, :name => "David" - assert_equal "<html>Hello: David</html>", @response.body - end - - def test_render_with_explicit_template - get :render_with_explicit_template - assert_response :success - end - - def test_render_with_explicit_string_template - get :render_with_explicit_string_template - assert_equal "<html>Hello world!</html>", @response.body - end - - def test_double_render - assert_raise(ActionController::DoubleRenderError) { get :double_render } - end - - def test_double_redirect - assert_raise(ActionController::DoubleRenderError) { get :double_redirect } - end - - def test_render_and_redirect - assert_raise(ActionController::DoubleRenderError) { get :render_and_redirect } - end - - # specify the one exception to double render rule - render_to_string followed by render - def test_render_to_string_and_render - get :render_to_string_and_render - assert_equal("Hi web users! here is some cached stuff", @response.body) - end - - def test_rendering_with_conflicting_local_vars - get :rendering_with_conflicting_local_vars - assert_equal("First: David\nSecond: Stephan\nThird: David\nFourth: David\nFifth: ", @response.body) - end - - def test_action_talk_to_layout - get :action_talk_to_layout - assert_equal "<title>Talking to the layout</title>\nAction was here!", @response.body - end - - def test_render_text_with_assigns - get :render_text_with_assigns - assert_equal "world", assigns["hello"] - end - - def test_template_with_locals - get :render_with_explicit_template_with_locals - assert_equal "The secret is area51\n", @response.body - end - - def test_update_page - get :update_page - assert_template nil - assert_equal 'text/javascript; charset=utf-8', @response.headers['Content-Type'] - assert_equal 2, @response.body.split($/).length - end - - def test_update_page_with_instance_variables - get :update_page_with_instance_variables - assert_template nil - assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"] - assert_match /balance/, @response.body - assert_match /\$37/, @response.body - end - - def test_update_page_with_view_method - get :update_page_with_view_method - assert_template nil - assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"] - assert_match /2 people/, @response.body - end - - def test_yield_content_for - assert_not_deprecated { get :yield_content_for } - assert_equal "<title>Putting stuff in the title!</title>\n\nGreat stuff!\n", @response.body - end - - def test_overwritting_rendering_relative_file_with_extension - get :hello_world_from_rxml_using_template - assert_equal "<html>\n <p>Hello</p>\n</html>\n", @response.body - - get :hello_world_from_rxml_using_action - assert_equal "<html>\n <p>Hello</p>\n</html>\n", @response.body - end - - def test_head_with_location_header - get :head_with_location_header - assert @response.body.blank? - assert_equal "/foo", @response.headers["Location"] - assert_response :ok - end - - def test_head_with_custom_header - get :head_with_custom_header - assert @response.body.blank? - assert_equal "something", @response.headers["X-Custom-Header"] - assert_response :ok - end - - def test_head_with_symbolic_status - get :head_with_symbolic_status, :status => "ok" - assert_equal "200 OK", @response.status - assert_response :ok - - get :head_with_symbolic_status, :status => "not_found" - assert_equal "404 Not Found", @response.status - assert_response :not_found - - get :head_with_symbolic_status, :status => "no_content" - assert_equal "204 No Content", @response.status - assert !@response.headers.include?('Content-Length') - assert_response :no_content - - ActionController::StatusCodes::SYMBOL_TO_STATUS_CODE.each do |status, code| - get :head_with_symbolic_status, :status => status.to_s - assert_equal code, @response.response_code - assert_response status - end - end - - def test_head_with_integer_status - ActionController::StatusCodes::STATUS_CODES.each do |code, message| - get :head_with_integer_status, :status => code.to_s - assert_equal message, @response.message - end - end - - def test_head_with_string_status - get :head_with_string_status, :status => "404 Eat Dirt" - assert_equal 404, @response.response_code - assert_equal "Eat Dirt", @response.message - assert_response :not_found - end - - def test_head_with_status_code_first - get :head_with_status_code_first - assert_equal 403, @response.response_code - assert_equal "Forbidden", @response.message - assert_equal "something", @response.headers["X-Custom-Header"] - assert_response :forbidden - end - - def test_rendering_with_location_should_set_header - get :render_with_location - assert_equal "http://example.com", @response.headers["Location"] - end - - def test_rendering_xml_should_call_to_xml_if_possible - get :render_with_to_xml - assert_equal "<i-am-xml/>", @response.body - end - - def test_rendering_with_object_location_should_set_header_with_url_for - ActionController::Routing::Routes.draw do |map| - map.resources :customers - map.connect ':controller/:action/:id' - end - - get :render_with_object_location - assert_equal "http://www.nextangle.com/customers/1", @response.headers["Location"] - end - - def test_should_use_implicit_content_type - get :implicit_content_type, :format => 'atom' - assert_equal Mime::ATOM, @response.content_type - end - - def test_using_layout_around_block - get :render_using_layout_around_block - assert_equal "Before (David)\nInside from block\nAfter", @response.body - end - - def test_using_layout_around_block_in_main_layout_and_within_content_for_layout - get :render_using_layout_around_block_in_main_layout_and_within_content_for_layout - assert_equal "Before (Anthony)\nInside from first block in layout\nAfter\nBefore (David)\nInside from block\nAfter\nBefore (Ramm)\nInside from second block in layout\nAfter\n", @response.body - end - - def test_using_layout_around_block_with_args - get :render_using_layout_around_block_with_args - assert_equal "Before\narg1arg2\nAfter", @response.body - end - - def test_partial_only - get :partial_only - assert_equal "only partial", @response.body - end - - def test_should_render_html_formatted_partial - get :partial - assert_equal 'partial html', @response.body - end - - def test_should_render_html_partial_with_dot - get :partial_dot_html - assert_equal 'partial html', @response.body - end - - def test_should_render_html_formatted_partial_with_rjs - xhr :get, :partial_as_rjs - assert_equal %(Element.replace("foo", "partial html");), @response.body - end - - def test_should_render_html_formatted_partial_with_rjs_and_js_format - xhr :get, :respond_to_partial_as_rjs - assert_equal %(Element.replace("foo", "partial html");), @response.body - end - - def test_should_render_js_partial - xhr :get, :partial, :format => 'js' - assert_equal 'partial js', @response.body - end - - def test_should_render_with_alternate_default_render - xhr :get, :render_alternate_default - assert_equal %(Element.replace("foo", "partial html");), @response.body - end - - def test_partial_only_with_layout - get :partial_only_with_layout - assert_equal "<html>only partial</html>", @response.body - end - - def test_render_to_string_partial - get :render_to_string_with_partial - assert_equal "only partial", assigns(:partial_only) - assert_equal "Hello: david", assigns(:partial_with_locals) - end - - def test_partial_with_counter - get :partial_with_counter - assert_equal "5", @response.body - end - - def test_partial_with_locals - get :partial_with_locals - assert_equal "Hello: david", @response.body - end - - def test_partial_with_form_builder - get :partial_with_form_builder - assert_match(/<label/, @response.body) - assert_template('test/_form') - end - - def test_partial_with_form_builder_subclass - get :partial_with_form_builder_subclass - assert_match(/<label/, @response.body) - assert_template('test/_labelling_form') - end - - def test_partial_collection - get :partial_collection - assert_equal "Hello: davidHello: mary", @response.body - end - - def test_partial_collection_with_as - get :partial_collection_with_as - assert_equal "david david davidmary mary mary", @response.body - end - - def test_partial_collection_with_counter - get :partial_collection_with_counter - assert_equal "david0mary1", @response.body - end - - def test_partial_collection_with_locals - get :partial_collection_with_locals - assert_equal "Bonjour: davidBonjour: mary", @response.body - end - - def test_partial_collection_with_spacer - get :partial_collection_with_spacer - assert_equal "Hello: davidonly partialHello: mary", @response.body - assert_template :partial => 'test/_partial_only' - assert_template :partial => '_customer' - end - - def test_partial_collection_shorthand_with_locals - get :partial_collection_shorthand_with_locals - assert_equal "Bonjour: davidBonjour: mary", @response.body - assert_template :partial => 'customers/_customer', :count => 2 - assert_template :partial => '_completely_fake_and_made_up_template_that_cannot_possibly_be_rendered', :count => 0 - end - - def test_partial_collection_shorthand_with_different_types_of_records - get :partial_collection_shorthand_with_different_types_of_records - assert_equal "Bonjour bad customer: mark0Bonjour good customer: craig1Bonjour bad customer: john2Bonjour good customer: zach3Bonjour good customer: brandon4Bonjour bad customer: dan5", @response.body - assert_template :partial => 'good_customers/_good_customer', :count => 3 - assert_template :partial => 'bad_customers/_bad_customer', :count => 3 - end - - def test_empty_partial_collection - get :empty_partial_collection - assert_equal " ", @response.body - assert_template :partial => false - end - - def test_partial_with_hash_object - get :partial_with_hash_object - assert_equal "Sam\nmaS\n", @response.body - end - - def test_partial_with_nested_object - get :partial_with_nested_object - assert_equal "first", @response.body - end - - def test_partial_with_nested_object_shorthand - get :partial_with_nested_object_shorthand - assert_equal "first", @response.body - end - - def test_hash_partial_collection - get :partial_hash_collection - assert_equal "Pratik\nkitarP\nAmy\nymA\n", @response.body - end - - def test_partial_hash_collection_with_locals - get :partial_hash_collection_with_locals - assert_equal "Hola: PratikHola: Amy", @response.body - end - - def test_partial_with_implicit_local_assignment - assert_deprecated do - get :partial_with_implicit_local_assignment - assert_equal "Hello: Marcel", @response.body - end - end - - def test_render_missing_partial_template - assert_raise(ActionView::MissingTemplate) do - get :missing_partial - end - end - - def test_render_call_to_partial_with_layout - get :render_call_to_partial_with_layout - assert_equal "Before (David)\nInside from partial (David)\nAfter", @response.body - end - - def test_render_call_to_partial_with_layout_in_main_layout_and_within_content_for_layout - get :render_call_to_partial_with_layout_in_main_layout_and_within_content_for_layout - assert_equal "Before (Anthony)\nInside from partial (Anthony)\nAfter\nBefore (David)\nInside from partial (David)\nAfter\nBefore (Ramm)\nInside from partial (Ramm)\nAfter", @response.body - end -end - -class ExpiresInRenderTest < ActionController::TestCase - tests TestController - - def setup - @request.host = "www.nextangle.com" - end - - def test_expires_in_header - get :conditional_hello_with_expires_in - assert_equal "max-age=60, private", @response.headers["Cache-Control"] - end - - def test_expires_in_header_with_public - get :conditional_hello_with_expires_in_with_public - assert_equal "max-age=60, public", @response.headers["Cache-Control"] - end - - def test_expires_in_header_with_additional_headers - get :conditional_hello_with_expires_in_with_public_with_more_keys - assert_equal "max-age=60, public, max-stale=18000", @response.headers["Cache-Control"] - end - - def test_expires_in_old_syntax - get :conditional_hello_with_expires_in_with_public_with_more_keys_old_syntax - assert_equal "max-age=60, public, max-stale=18000", @response.headers["Cache-Control"] - end -end - - -class EtagRenderTest < ActionController::TestCase - tests TestController - - def setup - @request.host = "www.nextangle.com" - @expected_bang_etag = etag_for(expand_key([:foo, 123])) - end - - def test_render_blank_body_shouldnt_set_etag - get :blank_response - assert !@response.etag? - end - - def test_render_200_should_set_etag - get :render_hello_world_from_variable - assert_equal etag_for("hello david"), @response.headers['ETag'] - assert_equal "private, max-age=0, must-revalidate", @response.headers['Cache-Control'] - end - - def test_render_against_etag_request_should_304_when_match - @request.if_none_match = etag_for("hello david") - get :render_hello_world_from_variable - assert_equal "304 Not Modified", @response.status - assert @response.body.empty? - end - - def test_render_against_etag_request_should_have_no_content_length_when_match - @request.if_none_match = etag_for("hello david") - get :render_hello_world_from_variable - assert !@response.headers.has_key?("Content-Length"), @response.headers['Content-Length'] - end - - def test_render_against_etag_request_should_200_when_no_match - @request.if_none_match = etag_for("hello somewhere else") - get :render_hello_world_from_variable - assert_equal "200 OK", @response.status - assert !@response.body.empty? - end - - def test_render_should_not_set_etag_when_last_modified_has_been_specified - get :render_hello_world_with_last_modified_set - assert_equal "200 OK", @response.status - assert_not_nil @response.last_modified - assert_nil @response.etag - assert @response.body.present? - end - - def test_render_with_etag - get :render_hello_world_from_variable - expected_etag = etag_for('hello david') - assert_equal expected_etag, @response.headers['ETag'] - @response = ActionController::TestResponse.new - - @request.if_none_match = expected_etag - get :render_hello_world_from_variable - assert_equal "304 Not Modified", @response.status - - @request.if_none_match = "\"diftag\"" - get :render_hello_world_from_variable - assert_equal "200 OK", @response.status - end - - def render_with_404_shouldnt_have_etag - get :render_custom_code - assert_nil @response.headers['ETag'] - end - - def test_etag_should_not_be_changed_when_already_set - get :render_hello_world_with_etag_set - assert_equal etag_for("hello_world"), @response.headers['ETag'] - end - - def test_etag_should_govern_renders_with_layouts_too - get :builder_layout_test - assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", @response.body - assert_equal etag_for("<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n"), @response.headers['ETag'] - end - - def test_etag_with_bang_should_set_etag - get :conditional_hello_with_bangs - assert_equal @expected_bang_etag, @response.headers["ETag"] - assert_response :success - end - - def test_etag_with_bang_should_obey_if_none_match - @request.if_none_match = @expected_bang_etag - get :conditional_hello_with_bangs - assert_response :not_modified - end - - def test_etag_with_public_true_should_set_header - get :conditional_hello_with_public_header - assert_equal "public", @response.headers['Cache-Control'] - end - - def test_etag_with_public_true_should_set_header_and_retain_other_headers - get :conditional_hello_with_public_header_and_expires_at - assert_equal "max-age=60, public", @response.headers['Cache-Control'] - end - - protected - def etag_for(text) - %("#{Digest::MD5.hexdigest(text)}") - end - - def expand_key(args) - ActiveSupport::Cache.expand_cache_key(args) - end -end - -class LastModifiedRenderTest < ActionController::TestCase - tests TestController - - def setup - @request.host = "www.nextangle.com" - @last_modified = Time.now.utc.beginning_of_day.httpdate - end - - def test_responds_with_last_modified - get :conditional_hello - assert_equal @last_modified, @response.headers['Last-Modified'] - end - - def test_request_not_modified - @request.if_modified_since = @last_modified - get :conditional_hello - assert_equal "304 Not Modified", @response.status - assert @response.body.blank?, @response.body - assert_equal @last_modified, @response.headers['Last-Modified'] - end - - def test_request_not_modified_but_etag_differs - @request.if_modified_since = @last_modified - @request.if_none_match = "234" - get :conditional_hello - assert_response :success - end - - def test_request_modified - @request.if_modified_since = 'Thu, 16 Jul 2008 00:00:00 GMT' - get :conditional_hello - assert_equal "200 OK", @response.status - assert !@response.body.blank? - assert_equal @last_modified, @response.headers['Last-Modified'] - end - - def test_request_with_bang_gets_last_modified - get :conditional_hello_with_bangs - assert_equal @last_modified, @response.headers['Last-Modified'] - assert_response :success - end - - def test_request_with_bang_obeys_last_modified - @request.if_modified_since = @last_modified - get :conditional_hello_with_bangs - assert_response :not_modified - end - - def test_last_modified_works_with_less_than_too - @request.if_modified_since = 5.years.ago.httpdate - get :conditional_hello_with_bangs - assert_response :success - end -end - -class RenderingLoggingTest < ActionController::TestCase - tests TestController - - def setup - @request.host = "www.nextangle.com" - end - - def test_logger_prints_layout_and_template_rendering_info - @controller.logger = MockLogger.new - get :layout_test - logged = @controller.logger.logged.find_all {|l| l =~ /render/i } - assert_equal "Rendering template within layouts/standard", logged[0] - assert_equal "Rendering test/hello_world", logged[1] - end -end diff --git a/vendor/rails/actionpack/test/controller/request/json_params_parsing_test.rb b/vendor/rails/actionpack/test/controller/request/json_params_parsing_test.rb deleted file mode 100644 index a3dde72..0000000 --- a/vendor/rails/actionpack/test/controller/request/json_params_parsing_test.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'abstract_unit' - -class JsonParamsParsingTest < ActionController::IntegrationTest - class TestController < ActionController::Base - class << self - attr_accessor :last_request_parameters - end - - def parse - self.class.last_request_parameters = request.request_parameters - head :ok - end - end - - def teardown - TestController.last_request_parameters = nil - end - - test "parses json params for application json" do - assert_parses( - {"person" => {"name" => "David"}}, - "{\"person\": {\"name\": \"David\"}}", { 'CONTENT_TYPE' => 'application/json' } - ) - end - - test "parses json params for application jsonrequest" do - assert_parses( - {"person" => {"name" => "David"}}, - "{\"person\": {\"name\": \"David\"}}", { 'CONTENT_TYPE' => 'application/jsonrequest' } - ) - end - - private - def assert_parses(expected, actual, headers = {}) - with_routing do |set| - set.draw do |map| - map.connect ':action', :controller => "json_params_parsing_test/test" - end - - post "/parse", actual, headers - assert_response :ok - assert_equal(expected, TestController.last_request_parameters) - end - end -end diff --git a/vendor/rails/actionpack/test/controller/request/multipart_params_parsing_test.rb b/vendor/rails/actionpack/test/controller/request/multipart_params_parsing_test.rb deleted file mode 100644 index b812072..0000000 --- a/vendor/rails/actionpack/test/controller/request/multipart_params_parsing_test.rb +++ /dev/null @@ -1,223 +0,0 @@ -require 'abstract_unit' - -class MultipartParamsParsingTest < ActionController::IntegrationTest - class TestController < ActionController::Base - class << self - attr_accessor :last_request_parameters - end - - def parse - self.class.last_request_parameters = request.request_parameters - head :ok - end - - def read - render :text => "File: #{params[:uploaded_data].read}" - end - end - - FIXTURE_PATH = File.dirname(__FILE__) + '/../../fixtures/multipart' - - def teardown - TestController.last_request_parameters = nil - end - - test "parses single parameter" do - assert_equal({ 'foo' => 'bar' }, parse_multipart('single_parameter')) - end - - test "parses bracketed parameters" do - assert_equal({ 'foo' => { 'baz' => 'bar'}}, parse_multipart('bracketed_param')) - end - - test "parses text file" do - params = parse_multipart('text_file') - assert_equal %w(file foo), params.keys.sort - assert_equal 'bar', params['foo'] - - file = params['file'] - assert_kind_of Tempfile, file - assert_equal 'file.txt', file.original_filename - assert_equal "text/plain", file.content_type - assert_equal 'contents', file.read - end - - test "parses boundary problem file" do - params = parse_multipart('boundary_problem_file') - assert_equal %w(file foo), params.keys.sort - - file = params['file'] - foo = params['foo'] - - assert_kind_of Tempfile, file - - assert_equal 'file.txt', file.original_filename - assert_equal "text/plain", file.content_type - - assert_equal 'bar', foo - end - - test "parses large text file" do - params = parse_multipart('large_text_file') - assert_equal %w(file foo), params.keys.sort - assert_equal 'bar', params['foo'] - - file = params['file'] - - assert_kind_of Tempfile, file - - assert_equal 'file.txt', file.original_filename - assert_equal "text/plain", file.content_type - assert ('a' * 20480) == file.read - end - - test "parses binary file" do - params = parse_multipart('binary_file') - assert_equal %w(file flowers foo), params.keys.sort - assert_equal 'bar', params['foo'] - - file = params['file'] - assert_kind_of Tempfile, file - assert_equal 'file.csv', file.original_filename - assert_nil file.content_type - assert_equal 'contents', file.read - - file = params['flowers'] - assert_kind_of Tempfile, file - assert_equal 'flowers.jpg', file.original_filename - assert_equal "image/jpeg", file.content_type - assert_equal 19512, file.size - end - - test "parses mixed files" do - params = parse_multipart('mixed_files') - assert_equal %w(files foo), params.keys.sort - assert_equal 'bar', params['foo'] - - # Ruby CGI doesn't handle multipart/mixed for us. - files = params['files'] - assert_kind_of String, files - files.force_encoding('ASCII-8BIT') if files.respond_to?(:force_encoding) - assert_equal 19756, files.size - end - - test "does not create tempfile if no file has been selected" do - params = parse_multipart('none') - assert_equal %w(submit-name), params.keys.sort - assert_equal 'Larry', params['submit-name'] - assert_equal nil, params['files'] - end - - test "parses empty upload file" do - params = parse_multipart('empty') - assert_equal %w(files submit-name), params.keys.sort - assert_equal 'Larry', params['submit-name'] - assert params['files'] - assert_equal "", params['files'].read - end - - test "uploads and reads binary file" do - with_test_routing do - fixture = FIXTURE_PATH + "/mona_lisa.jpg" - params = { :uploaded_data => fixture_file_upload(fixture, "image/jpg") } - post '/read', params - expected_length = 'File: '.length + File.size(fixture) - assert_equal expected_length, response.content_length - end - end - - test "uploads and reads file" do - with_test_routing do - post '/read', :uploaded_data => fixture_file_upload(FIXTURE_PATH + "/hello.txt", "text/plain") - assert_equal "File: Hello", response.body - end - end - - # The lint wrapper is used in integration tests - # instead of a normal StringIO class - InputWrapper = Rack::Lint::InputWrapper - - test "parses unwindable stream" do - InputWrapper.any_instance.stubs(:rewind).raises(Errno::ESPIPE) - params = parse_multipart('large_text_file') - assert_equal %w(file foo), params.keys.sort - assert_equal 'bar', params['foo'] - end - - test "uploads and reads file with unwindable input" do - InputWrapper.any_instance.stubs(:rewind).raises(Errno::ESPIPE) - - with_test_routing do - post '/read', :uploaded_data => fixture_file_upload(FIXTURE_PATH + "/hello.txt", "text/plain") - assert_equal "File: Hello", response.body - end - end - - test "passes through rack middleware and uploads file" do - with_muck_middleware do - with_test_routing do - post '/read', :uploaded_data => fixture_file_upload(FIXTURE_PATH + "/hello.txt", "text/plain") - assert_equal "File: Hello", response.body - end - end - end - - test "passes through rack middleware and uploads file with unwindable input" do - InputWrapper.any_instance.stubs(:rewind).raises(Errno::ESPIPE) - - with_muck_middleware do - with_test_routing do - post '/read', :uploaded_data => fixture_file_upload(FIXTURE_PATH + "/hello.txt", "text/plain") - assert_equal "File: Hello", response.body - end - end - end - - private - def fixture(name) - File.open(File.join(FIXTURE_PATH, name), 'rb') do |file| - { "rack.input" => file.read, - "CONTENT_TYPE" => "multipart/form-data; boundary=AaB03x", - "CONTENT_LENGTH" => file.stat.size.to_s } - end - end - - def parse_multipart(name) - with_test_routing do - headers = fixture(name) - post "/parse", headers.delete("rack.input"), headers - assert_response :ok - TestController.last_request_parameters - end - end - - def with_test_routing - with_routing do |set| - set.draw do |map| - map.connect ':action', :controller => "multipart_params_parsing_test/test" - end - yield - end - end - - class MuckMiddleware - def initialize(app) - @app = app - end - - def call(env) - req = Rack::Request.new(env) - req.params # Parse params - @app.call(env) - end - end - - def with_muck_middleware - original_middleware = ActionController::Dispatcher.middleware - middleware = original_middleware.dup - middleware.insert_after ActionController::RewindableInput, MuckMiddleware - ActionController::Dispatcher.middleware = middleware - yield - ActionController::Dispatcher.middleware = original_middleware - end -end diff --git a/vendor/rails/actionpack/test/controller/request/query_string_parsing_test.rb b/vendor/rails/actionpack/test/controller/request/query_string_parsing_test.rb deleted file mode 100644 index a31e326..0000000 --- a/vendor/rails/actionpack/test/controller/request/query_string_parsing_test.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'abstract_unit' - -class QueryStringParsingTest < ActionController::IntegrationTest - class TestController < ActionController::Base - class << self - attr_accessor :last_query_parameters - end - - def parse - self.class.last_query_parameters = request.query_parameters - head :ok - end - end - - def teardown - TestController.last_query_parameters = nil - end - - test "query string" do - assert_parses( - {"action" => "create_customer", "full_name" => "David Heinemeier Hansson", "customerId" => "1"}, - "action=create_customer&full_name=David%20Heinemeier%20Hansson&customerId=1" - ) - end - - test "deep query string" do - assert_parses( - {'x' => {'y' => {'z' => '10'}}}, - "x[y][z]=10" - ) - end - - test "deep query string with array" do - assert_parses({'x' => {'y' => {'z' => ['10']}}}, 'x[y][z][]=10') - assert_parses({'x' => {'y' => {'z' => ['10', '5']}}}, 'x[y][z][]=10&x[y][z][]=5') - end - - test "deep query string with array of hash" do - assert_parses({'x' => {'y' => [{'z' => '10'}]}}, 'x[y][][z]=10') - assert_parses({'x' => {'y' => [{'z' => '10', 'w' => '10'}]}}, 'x[y][][z]=10&x[y][][w]=10') - assert_parses({'x' => {'y' => [{'z' => '10', 'v' => {'w' => '10'}}]}}, 'x[y][][z]=10&x[y][][v][w]=10') - end - - test "deep query string with array of hashes with one pair" do - assert_parses({'x' => {'y' => [{'z' => '10'}, {'z' => '20'}]}}, 'x[y][][z]=10&x[y][][z]=20') - end - - test "deep query string with array of hashes with multiple pairs" do - assert_parses( - {'x' => {'y' => [{'z' => '10', 'w' => 'a'}, {'z' => '20', 'w' => 'b'}]}}, - 'x[y][][z]=10&x[y][][w]=a&x[y][][z]=20&x[y][][w]=b' - ) - end - - test "query string with nil" do - assert_parses( - { "action" => "create_customer", "full_name" => ''}, - "action=create_customer&full_name=" - ) - end - - test "query string with array" do - assert_parses( - { "action" => "create_customer", "selected" => ["1", "2", "3"]}, - "action=create_customer&selected[]=1&selected[]=2&selected[]=3" - ) - end - - test "query string with amps" do - assert_parses( - { "action" => "create_customer", "name" => "Don't & Does"}, - "action=create_customer&name=Don%27t+%26+Does" - ) - end - - test "query string with many equal" do - assert_parses( - { "action" => "create_customer", "full_name" => "abc=def=ghi"}, - "action=create_customer&full_name=abc=def=ghi" - ) - end - - test "query string without equal" do - assert_parses({ "action" => nil }, "action") - end - - test "query string with empty key" do - assert_parses( - { "action" => "create_customer", "full_name" => "David Heinemeier Hansson" }, - "action=create_customer&full_name=David%20Heinemeier%20Hansson&=Save" - ) - end - - test "query string with many ampersands" do - assert_parses( - { "action" => "create_customer", "full_name" => "David Heinemeier Hansson"}, - "&action=create_customer&&&full_name=David%20Heinemeier%20Hansson" - ) - end - - test "unbalanced query string with array" do - assert_parses( - {'location' => ["1", "2"], 'age_group' => ["2"]}, - "location[]=1&location[]=2&age_group[]=2" - ) - end - - private - def assert_parses(expected, actual) - with_routing do |set| - set.draw do |map| - map.connect ':action', :controller => "query_string_parsing_test/test" - end - - get "/parse", actual - assert_response :ok - assert_equal(expected, TestController.last_query_parameters) - end - end -end diff --git a/vendor/rails/actionpack/test/controller/request/url_encoded_params_parsing_test.rb b/vendor/rails/actionpack/test/controller/request/url_encoded_params_parsing_test.rb deleted file mode 100644 index 7e6099a..0000000 --- a/vendor/rails/actionpack/test/controller/request/url_encoded_params_parsing_test.rb +++ /dev/null @@ -1,184 +0,0 @@ -require 'abstract_unit' - -class UrlEncodedParamsParsingTest < ActionController::IntegrationTest - class TestController < ActionController::Base - class << self - attr_accessor :last_request_parameters, :last_request_type - end - - def parse - self.class.last_request_parameters = request.request_parameters - head :ok - end - end - - def teardown - TestController.last_request_parameters = nil - end - - test "parses unbalanced query string with array" do - assert_parses( - {'location' => ["1", "2"], 'age_group' => ["2"]}, - "location[]=1&location[]=2&age_group[]=2" - ) - end - - test "parses nested hash" do - query = [ - "note[viewers][viewer][][type]=User", - "note[viewers][viewer][][id]=1", - "note[viewers][viewer][][type]=Group", - "note[viewers][viewer][][id]=2" - ].join("&") - - expected = { "note" => { "viewers"=>{"viewer"=>[{ "id"=>"1", "type"=>"User"}, {"type"=>"Group", "id"=>"2"} ]} } } - assert_parses(expected, query) - end - - test "parses more complex nesting" do - query = [ - "customers[boston][first][name]=David", - "customers[boston][first][url]=http://David", - "customers[boston][second][name]=Allan", - "customers[boston][second][url]=http://Allan", - "something_else=blah", - "something_nil=", - "something_empty=", - "products[first]=Apple Computer", - "products[second]=Pc", - "=Save" - ].join("&") - - expected = { - "customers" => { - "boston" => { - "first" => { - "name" => "David", - "url" => "http://David" - }, - "second" => { - "name" => "Allan", - "url" => "http://Allan" - } - } - }, - "something_else" => "blah", - "something_empty" => "", - "something_nil" => "", - "products" => { - "first" => "Apple Computer", - "second" => "Pc" - } - } - - assert_parses expected, query - end - - test "parses params with array" do - query = "selected[]=1&selected[]=2&selected[]=3" - expected = { "selected" => [ "1", "2", "3" ] } - assert_parses expected, query - end - - test "parses params with nil key" do - query = "=&test2=value1" - expected = { "test2" => "value1" } - assert_parses expected, query - end - - test "parses params with array prefix and hashes" do - query = "a[][b][c]=d" - expected = {"a" => [{"b" => {"c" => "d"}}]} - assert_parses expected, query - end - - test "parses params with complex nesting" do - query = "a[][b][c][][d][]=e" - expected = {"a" => [{"b" => {"c" => [{"d" => ["e"]}]}}]} - assert_parses expected, query - end - - test "parses params with file path" do - query = [ - "customers[boston][first][name]=David", - "something_else=blah", - "logo=#{File.expand_path(__FILE__)}" - ].join("&") - - expected = { - "customers" => { - "boston" => { - "first" => { - "name" => "David" - } - } - }, - "something_else" => "blah", - "logo" => File.expand_path(__FILE__), - } - - assert_parses expected, query - end - - test "parses params with Safari 2 trailing null character" do - query = "selected[]=1&selected[]=2&selected[]=3\0" - expected = { "selected" => [ "1", "2", "3" ] } - assert_parses expected, query - end - - test "passes through rack middleware and parses params" do - with_muck_middleware do - assert_parses({ "a" => { "b" => "c" } }, "a[b]=c") - end - end - - # The lint wrapper is used in integration tests - # instead of a normal StringIO class - InputWrapper = Rack::Lint::InputWrapper - - test "passes through rack middleware and parses params with unwindable input" do - InputWrapper.any_instance.stubs(:rewind).raises(Errno::ESPIPE) - with_muck_middleware do - assert_parses({ "a" => { "b" => "c" } }, "a[b]=c") - end - end - - private - class MuckMiddleware - def initialize(app) - @app = app - end - - def call(env) - req = Rack::Request.new(env) - req.params # Parse params - @app.call(env) - end - end - - def with_muck_middleware - original_middleware = ActionController::Dispatcher.middleware - middleware = original_middleware.dup - middleware.insert_after ActionController::RewindableInput, MuckMiddleware - ActionController::Dispatcher.middleware = middleware - yield - ActionController::Dispatcher.middleware = original_middleware - end - - def with_test_routing - with_routing do |set| - set.draw do |map| - map.connect ':action', :controller => "url_encoded_params_parsing_test/test" - end - yield - end - end - - def assert_parses(expected, actual) - with_test_routing do - post "/parse", actual - assert_response :ok - assert_equal(expected, TestController.last_request_parameters) - end - end -end diff --git a/vendor/rails/actionpack/test/controller/request/xml_params_parsing_test.rb b/vendor/rails/actionpack/test/controller/request/xml_params_parsing_test.rb deleted file mode 100644 index ee764e7..0000000 --- a/vendor/rails/actionpack/test/controller/request/xml_params_parsing_test.rb +++ /dev/null @@ -1,88 +0,0 @@ -require 'abstract_unit' - -class XmlParamsParsingTest < ActionController::IntegrationTest - class TestController < ActionController::Base - class << self - attr_accessor :last_request_parameters - end - - def parse - self.class.last_request_parameters = request.request_parameters - head :ok - end - end - - def teardown - TestController.last_request_parameters = nil - end - - test "parses hash params" do - with_test_routing do - xml = "<person><name>David</name></person>" - post "/parse", xml, default_headers - assert_response :ok - assert_equal({"person" => {"name" => "David"}}, TestController.last_request_parameters) - end - end - - test "parses single file" do - with_test_routing do - xml = "<person><name>David</name><avatar type='file' name='me.jpg' content_type='image/jpg'>#{ActiveSupport::Base64.encode64('ABC')}</avatar></person>" - post "/parse", xml, default_headers - assert_response :ok - - person = TestController.last_request_parameters - assert_equal "image/jpg", person['person']['avatar'].content_type - assert_equal "me.jpg", person['person']['avatar'].original_filename - assert_equal "ABC", person['person']['avatar'].read - end - end - - test "parses multiple files" do - xml = <<-end_body - <person> - <name>David</name> - <avatars> - <avatar type='file' name='me.jpg' content_type='image/jpg'>#{ActiveSupport::Base64.encode64('ABC')}</avatar> - <avatar type='file' name='you.gif' content_type='image/gif'>#{ActiveSupport::Base64.encode64('DEF')}</avatar> - </avatars> - </person> - end_body - - with_test_routing do - post "/parse", xml, default_headers - assert_response :ok - end - - person = TestController.last_request_parameters - - assert_equal "image/jpg", person['person']['avatars']['avatar'].first.content_type - assert_equal "me.jpg", person['person']['avatars']['avatar'].first.original_filename - assert_equal "ABC", person['person']['avatars']['avatar'].first.read - - assert_equal "image/gif", person['person']['avatars']['avatar'].last.content_type - assert_equal "you.gif", person['person']['avatars']['avatar'].last.original_filename - assert_equal "DEF", person['person']['avatars']['avatar'].last.read - end - - private - def with_test_routing - with_routing do |set| - set.draw do |map| - map.connect ':action', :controller => "xml_params_parsing_test/test" - end - yield - end - end - - def default_headers - {'CONTENT_TYPE' => 'application/xml'} - end -end - -class LegacyXmlParamsParsingTest < XmlParamsParsingTest - private - def default_headers - {'HTTP_X_POST_DATA_FORMAT' => 'xml'} - end -end diff --git a/vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb b/vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb deleted file mode 100644 index 835e73e..0000000 --- a/vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb +++ /dev/null @@ -1,246 +0,0 @@ -require 'abstract_unit' -require 'digest/sha1' - -ActionController::Routing::Routes.draw do |map| - map.connect ':controller/:action/:id' -end - -# common controller actions -module RequestForgeryProtectionActions - def index - render :inline => "<%= form_tag('/') {} %>" - end - - def show_button - render :inline => "<%= button_to('New', '/') {} %>" - end - - def remote_form - render :inline => "<% form_remote_tag(:url => '/') {} %>" - end - - def unsafe - render :text => 'pwn' - end - - def rescue_action(e) raise e end -end - -# sample controllers -class RequestForgeryProtectionController < ActionController::Base - include RequestForgeryProtectionActions - protect_from_forgery :only => :index -end - -class FreeCookieController < RequestForgeryProtectionController - self.allow_forgery_protection = false - - def index - render :inline => "<%= form_tag('/') {} %>" - end - - def show_button - render :inline => "<%= button_to('New', '/') {} %>" - end -end - -# common test methods - -module RequestForgeryProtectionTests - def teardown - ActionController::Base.request_forgery_protection_token = nil - end - - - def test_should_render_form_with_token_tag - get :index - assert_select 'form>div>input[name=?][value=?]', 'authenticity_token', @token - end - - def test_should_render_button_to_with_token_tag - get :show_button - assert_select 'form>div>input[name=?][value=?]', 'authenticity_token', @token - end - - def test_should_render_remote_form_with_only_one_token_parameter - get :remote_form - assert_equal 1, @response.body.scan(@token).size - end - - def test_should_allow_get - get :index - assert_response :success - end - - def test_should_allow_post_without_token_on_unsafe_action - post :unsafe - assert_response :success - end - - def test_should_not_allow_html_post_without_token - @request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s - assert_raise(ActionController::InvalidAuthenticityToken) { post :index, :format => :html } - end - - def test_should_not_allow_html_put_without_token - @request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s - assert_raise(ActionController::InvalidAuthenticityToken) { put :index, :format => :html } - end - - def test_should_not_allow_html_delete_without_token - @request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s - assert_raise(ActionController::InvalidAuthenticityToken) { delete :index, :format => :html } - end - - def test_should_allow_api_formatted_post_without_token - assert_nothing_raised do - post :index, :format => 'xml' - end - end - - def test_should_not_allow_api_formatted_put_without_token - assert_nothing_raised do - put :index, :format => 'xml' - end - end - - def test_should_allow_api_formatted_delete_without_token - assert_nothing_raised do - delete :index, :format => 'xml' - end - end - - def test_should_not_allow_api_formatted_post_sent_as_url_encoded_form_without_token - assert_raise(ActionController::InvalidAuthenticityToken) do - @request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s - post :index, :format => 'xml' - end - end - - def test_should_not_allow_api_formatted_put_sent_as_url_encoded_form_without_token - assert_raise(ActionController::InvalidAuthenticityToken) do - @request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s - put :index, :format => 'xml' - end - end - - def test_should_not_allow_api_formatted_delete_sent_as_url_encoded_form_without_token - assert_raise(ActionController::InvalidAuthenticityToken) do - @request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s - delete :index, :format => 'xml' - end - end - - def test_should_not_allow_api_formatted_post_sent_as_multipart_form_without_token - assert_raise(ActionController::InvalidAuthenticityToken) do - @request.env['CONTENT_TYPE'] = Mime::MULTIPART_FORM.to_s - post :index, :format => 'xml' - end - end - - def test_should_not_allow_api_formatted_put_sent_as_multipart_form_without_token - assert_raise(ActionController::InvalidAuthenticityToken) do - @request.env['CONTENT_TYPE'] = Mime::MULTIPART_FORM.to_s - put :index, :format => 'xml' - end - end - - def test_should_not_allow_api_formatted_delete_sent_as_multipart_form_without_token - assert_raise(ActionController::InvalidAuthenticityToken) do - @request.env['CONTENT_TYPE'] = Mime::MULTIPART_FORM.to_s - delete :index, :format => 'xml' - end - end - - def test_should_allow_xhr_post_without_token - assert_nothing_raised { xhr :post, :index } - end - def test_should_not_allow_xhr_post_with_html_without_token - @request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s - assert_raise(ActionController::InvalidAuthenticityToken) { xhr :post, :index } - end - - def test_should_allow_xhr_put_without_token - assert_nothing_raised { xhr :put, :index } - end - - def test_should_allow_xhr_delete_without_token - assert_nothing_raised { xhr :delete, :index } - end - - def test_should_allow_post_with_token - post :index, :authenticity_token => @token - assert_response :success - end - - def test_should_allow_put_with_token - put :index, :authenticity_token => @token - assert_response :success - end - - def test_should_allow_delete_with_token - delete :index, :authenticity_token => @token - assert_response :success - end - - def test_should_allow_post_with_xml - @request.env['CONTENT_TYPE'] = Mime::XML.to_s - post :index, :format => 'xml' - assert_response :success - end - - def test_should_allow_put_with_xml - @request.env['CONTENT_TYPE'] = Mime::XML.to_s - put :index, :format => 'xml' - assert_response :success - end - - def test_should_allow_delete_with_xml - @request.env['CONTENT_TYPE'] = Mime::XML.to_s - delete :index, :format => 'xml' - assert_response :success - end -end - -# OK let's get our test on - -class RequestForgeryProtectionControllerTest < ActionController::TestCase - include RequestForgeryProtectionTests - def setup - @controller = RequestForgeryProtectionController.new - @request = ActionController::TestRequest.new - @request.format = :html - @response = ActionController::TestResponse.new - @token = "cf50faa3fe97702ca1ae" - - ActiveSupport::SecureRandom.stubs(:base64).returns(@token) - ActionController::Base.request_forgery_protection_token = :authenticity_token - end -end - -class FreeCookieControllerTest < ActionController::TestCase - def setup - @controller = FreeCookieController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @token = "cf50faa3fe97702ca1ae" - - ActiveSupport::SecureRandom.stubs(:base64).returns(@token) - end - - def test_should_not_render_form_with_token_tag - get :index - assert_select 'form>div>input[name=?][value=?]', 'authenticity_token', @token, false - end - - def test_should_not_render_button_to_with_token_tag - get :show_button - assert_select 'form>div>input[name=?][value=?]', 'authenticity_token', @token, false - end - - def test_should_allow_all_methods_without_token - [:post, :put, :delete].each do |method| - assert_nothing_raised { send(method, :index)} - end - end -end diff --git a/vendor/rails/actionpack/test/controller/request_test.rb b/vendor/rails/actionpack/test/controller/request_test.rb deleted file mode 100644 index c72f885..0000000 --- a/vendor/rails/actionpack/test/controller/request_test.rb +++ /dev/null @@ -1,407 +0,0 @@ -require 'abstract_unit' - -class RequestTest < ActiveSupport::TestCase - def setup - ActionController::Base.relative_url_root = nil - @request = ActionController::TestRequest.new - end - - def teardown - ActionController::Base.relative_url_root = nil - end - - def test_remote_ip - assert_equal '0.0.0.0', @request.remote_ip - - @request.remote_addr = '1.2.3.4' - assert_equal '1.2.3.4', @request.remote_ip - - @request.remote_addr = '1.2.3.4,3.4.5.6' - assert_equal '1.2.3.4', @request.remote_ip - - @request.env['HTTP_CLIENT_IP'] = '2.3.4.5' - assert_equal '1.2.3.4', @request.remote_ip - - @request.remote_addr = '192.168.0.1' - assert_equal '2.3.4.5', @request.remote_ip - @request.env.delete 'HTTP_CLIENT_IP' - - @request.remote_addr = '1.2.3.4' - @request.env['HTTP_X_FORWARDED_FOR'] = '3.4.5.6' - assert_equal '1.2.3.4', @request.remote_ip - - @request.remote_addr = '127.0.0.1' - @request.env['HTTP_X_FORWARDED_FOR'] = '3.4.5.6' - assert_equal '3.4.5.6', @request.remote_ip - - @request.env['HTTP_X_FORWARDED_FOR'] = 'unknown,3.4.5.6' - assert_equal '3.4.5.6', @request.remote_ip - - @request.env['HTTP_X_FORWARDED_FOR'] = '172.16.0.1,3.4.5.6' - assert_equal '3.4.5.6', @request.remote_ip - - @request.env['HTTP_X_FORWARDED_FOR'] = '192.168.0.1,3.4.5.6' - assert_equal '3.4.5.6', @request.remote_ip - - @request.env['HTTP_X_FORWARDED_FOR'] = '10.0.0.1,3.4.5.6' - assert_equal '3.4.5.6', @request.remote_ip - - @request.env['HTTP_X_FORWARDED_FOR'] = '10.0.0.1, 10.0.0.1, 3.4.5.6' - assert_equal '3.4.5.6', @request.remote_ip - - @request.env['HTTP_X_FORWARDED_FOR'] = '127.0.0.1,3.4.5.6' - assert_equal '3.4.5.6', @request.remote_ip - - @request.env['HTTP_X_FORWARDED_FOR'] = 'unknown,192.168.0.1' - assert_equal 'unknown', @request.remote_ip - - @request.env['HTTP_X_FORWARDED_FOR'] = '9.9.9.9, 3.4.5.6, 10.0.0.1, 172.31.4.4' - assert_equal '3.4.5.6', @request.remote_ip - - @request.env['HTTP_CLIENT_IP'] = '8.8.8.8' - e = assert_raise(ActionController::ActionControllerError) { - @request.remote_ip - } - assert_match /IP spoofing attack/, e.message - assert_match /HTTP_X_FORWARDED_FOR="9.9.9.9, 3.4.5.6, 10.0.0.1, 172.31.4.4"/, e.message - assert_match /HTTP_CLIENT_IP="8.8.8.8"/, e.message - - # turn IP Spoofing detection off. - # This is useful for sites that are aimed at non-IP clients. The typical - # example is WAP. Since the cellular network is not IP based, it's a - # leap of faith to assume that their proxies are ever going to set the - # HTTP_CLIENT_IP/HTTP_X_FORWARDED_FOR headers properly. - ActionController::Base.ip_spoofing_check = false - assert_equal('8.8.8.8', @request.remote_ip) - ActionController::Base.ip_spoofing_check = true - - @request.env['HTTP_X_FORWARDED_FOR'] = '8.8.8.8, 9.9.9.9' - assert_equal '8.8.8.8', @request.remote_ip - - @request.env.delete 'HTTP_CLIENT_IP' - @request.env.delete 'HTTP_X_FORWARDED_FOR' - end - - def test_domains - @request.host = "www.rubyonrails.org" - assert_equal "rubyonrails.org", @request.domain - - @request.host = "www.rubyonrails.co.uk" - assert_equal "rubyonrails.co.uk", @request.domain(2) - - @request.host = "192.168.1.200" - assert_nil @request.domain - - @request.host = "foo.192.168.1.200" - assert_nil @request.domain - - @request.host = "192.168.1.200.com" - assert_equal "200.com", @request.domain - - @request.host = nil - assert_nil @request.domain - end - - def test_subdomains - @request.host = "www.rubyonrails.org" - assert_equal %w( www ), @request.subdomains - - @request.host = "www.rubyonrails.co.uk" - assert_equal %w( www ), @request.subdomains(2) - - @request.host = "dev.www.rubyonrails.co.uk" - assert_equal %w( dev www ), @request.subdomains(2) - - @request.host = "foobar.foobar.com" - assert_equal %w( foobar ), @request.subdomains - - @request.host = "192.168.1.200" - assert_equal [], @request.subdomains - - @request.host = "foo.192.168.1.200" - assert_equal [], @request.subdomains - - @request.host = "192.168.1.200.com" - assert_equal %w( 192 168 1 ), @request.subdomains - - @request.host = nil - assert_equal [], @request.subdomains - end - - def test_port_string - @request.port = 80 - assert_equal "", @request.port_string - - @request.port = 8080 - assert_equal ":8080", @request.port_string - end - - def test_request_uri - @request.env['SERVER_SOFTWARE'] = 'Apache 42.342.3432' - - @request.set_REQUEST_URI "http://www.rubyonrails.org/path/of/some/uri?mapped=1" - assert_equal "/path/of/some/uri?mapped=1", @request.request_uri - assert_equal "/path/of/some/uri", @request.path - - @request.set_REQUEST_URI "http://www.rubyonrails.org/path/of/some/uri" - assert_equal "/path/of/some/uri", @request.request_uri - assert_equal "/path/of/some/uri", @request.path - - @request.set_REQUEST_URI "/path/of/some/uri" - assert_equal "/path/of/some/uri", @request.request_uri - assert_equal "/path/of/some/uri", @request.path - - @request.set_REQUEST_URI "/" - assert_equal "/", @request.request_uri - assert_equal "/", @request.path - - @request.set_REQUEST_URI "/?m=b" - assert_equal "/?m=b", @request.request_uri - assert_equal "/", @request.path - - @request.set_REQUEST_URI "/" - @request.env['SCRIPT_NAME'] = "/dispatch.cgi" - assert_equal "/", @request.request_uri - assert_equal "/", @request.path - - ActionController::Base.relative_url_root = "/hieraki" - @request.set_REQUEST_URI "/hieraki/" - @request.env['SCRIPT_NAME'] = "/hieraki/dispatch.cgi" - assert_equal "/hieraki/", @request.request_uri - assert_equal "/", @request.path - ActionController::Base.relative_url_root = nil - - ActionController::Base.relative_url_root = "/collaboration/hieraki" - @request.set_REQUEST_URI "/collaboration/hieraki/books/edit/2" - @request.env['SCRIPT_NAME'] = "/collaboration/hieraki/dispatch.cgi" - assert_equal "/collaboration/hieraki/books/edit/2", @request.request_uri - assert_equal "/books/edit/2", @request.path - ActionController::Base.relative_url_root = nil - - # The following tests are for when REQUEST_URI is not supplied (as in IIS) - @request.env['PATH_INFO'] = "/path/of/some/uri?mapped=1" - @request.env['SCRIPT_NAME'] = nil #"/path/dispatch.rb" - @request.set_REQUEST_URI nil - assert_equal "/path/of/some/uri?mapped=1", @request.request_uri - assert_equal "/path/of/some/uri", @request.path - - ActionController::Base.relative_url_root = '/path' - @request.env['PATH_INFO'] = "/path/of/some/uri?mapped=1" - @request.env['SCRIPT_NAME'] = "/path/dispatch.rb" - @request.set_REQUEST_URI nil - assert_equal "/path/of/some/uri?mapped=1", @request.request_uri - assert_equal "/of/some/uri", @request.path - ActionController::Base.relative_url_root = nil - - @request.env['PATH_INFO'] = "/path/of/some/uri" - @request.env['SCRIPT_NAME'] = nil - @request.set_REQUEST_URI nil - assert_equal "/path/of/some/uri", @request.request_uri - assert_equal "/path/of/some/uri", @request.path - - @request.env['PATH_INFO'] = "/" - @request.set_REQUEST_URI nil - assert_equal "/", @request.request_uri - assert_equal "/", @request.path - - @request.env['PATH_INFO'] = "/?m=b" - @request.set_REQUEST_URI nil - assert_equal "/?m=b", @request.request_uri - assert_equal "/", @request.path - - @request.env['PATH_INFO'] = "/" - @request.env['SCRIPT_NAME'] = "/dispatch.cgi" - @request.set_REQUEST_URI nil - assert_equal "/", @request.request_uri - assert_equal "/", @request.path - - ActionController::Base.relative_url_root = '/hieraki' - @request.env['PATH_INFO'] = "/hieraki/" - @request.env['SCRIPT_NAME'] = "/hieraki/dispatch.cgi" - @request.set_REQUEST_URI nil - assert_equal "/hieraki/", @request.request_uri - assert_equal "/", @request.path - ActionController::Base.relative_url_root = nil - - @request.set_REQUEST_URI '/hieraki/dispatch.cgi' - ActionController::Base.relative_url_root = '/hieraki' - assert_equal "/dispatch.cgi", @request.path - ActionController::Base.relative_url_root = nil - - @request.set_REQUEST_URI '/hieraki/dispatch.cgi' - ActionController::Base.relative_url_root = '/foo' - assert_equal "/hieraki/dispatch.cgi", @request.path - ActionController::Base.relative_url_root = nil - - # This test ensures that Rails uses REQUEST_URI over PATH_INFO - ActionController::Base.relative_url_root = nil - @request.env['REQUEST_URI'] = "/some/path" - @request.env['PATH_INFO'] = "/another/path" - @request.env['SCRIPT_NAME'] = "/dispatch.cgi" - assert_equal "/some/path", @request.request_uri - assert_equal "/some/path", @request.path - end - - def test_host_with_default_port - @request.host = "rubyonrails.org" - @request.port = 80 - assert_equal "rubyonrails.org", @request.host_with_port - end - - def test_host_with_non_default_port - @request.host = "rubyonrails.org" - @request.port = 81 - assert_equal "rubyonrails.org:81", @request.host_with_port - end - - def test_server_software - assert_equal nil, @request.server_software - - @request.env['SERVER_SOFTWARE'] = 'Apache3.422' - assert_equal 'apache', @request.server_software - - @request.env['SERVER_SOFTWARE'] = 'lighttpd(1.1.4)' - assert_equal 'lighttpd', @request.server_software - end - - def test_xml_http_request - assert !@request.xml_http_request? - assert !@request.xhr? - - @request.env['HTTP_X_REQUESTED_WITH'] = "DefinitelyNotAjax1.0" - assert !@request.xml_http_request? - assert !@request.xhr? - - @request.env['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest" - assert @request.xml_http_request? - assert @request.xhr? - end - - def test_reports_ssl - assert !@request.ssl? - @request.env['HTTPS'] = 'on' - assert @request.ssl? - end - - def test_reports_ssl_when_proxied_via_lighttpd - assert !@request.ssl? - @request.env['HTTP_X_FORWARDED_PROTO'] = 'https' - assert @request.ssl? - end - - def test_symbolized_request_methods - [:get, :post, :put, :delete].each do |method| - self.request_method = method - assert_equal method, @request.method - end - end - - def test_invalid_http_method_raises_exception - assert_raise(ActionController::UnknownHttpMethod) do - self.request_method = :random_method - @request.request_method - end - end - - def test_allow_method_hacking_on_post - [:get, :head, :options, :put, :post, :delete].each do |method| - self.request_method = method - assert_equal(method == :head ? :get : method, @request.method) - end - end - - def test_invalid_method_hacking_on_post_raises_exception - assert_raise(ActionController::UnknownHttpMethod) do - self.request_method = :_random_method - @request.request_method - end - end - - def test_restrict_method_hacking - @request.instance_eval { @parameters = { :_method => 'put' } } - [:get, :put, :delete].each do |method| - self.request_method = method - assert_equal method, @request.method - end - end - - def test_head_masquerading_as_get - self.request_method = :head - assert_equal :get, @request.method - assert @request.get? - assert @request.head? - end - - def test_xml_format - @request.instance_eval { @parameters = { :format => 'xml' } } - assert_equal Mime::XML, @request.format - end - - def test_xhtml_format - @request.instance_eval { @parameters = { :format => 'xhtml' } } - assert_equal Mime::HTML, @request.format - end - - def test_txt_format - @request.instance_eval { @parameters = { :format => 'txt' } } - assert_equal Mime::TEXT, @request.format - end - - def test_nil_format - ActionController::Base.use_accept_header, old = - false, ActionController::Base.use_accept_header - - @request.instance_eval { @parameters = {} } - @request.env["HTTP_X_REQUESTED_WITH"] = "XMLHttpRequest" - assert @request.xhr? - assert_equal Mime::JS, @request.format - - ensure - ActionController::Base.use_accept_header = old - end - - def test_content_type - @request.env["CONTENT_TYPE"] = "text/html" - assert_equal Mime::HTML, @request.content_type - end - - def test_format_assignment_should_set_format - @request.instance_eval { self.format = :txt } - assert !@request.format.xml? - @request.instance_eval { self.format = :xml } - assert @request.format.xml? - end - - def test_content_no_type - assert_equal nil, @request.content_type - end - - def test_content_type_xml - @request.env["CONTENT_TYPE"] = "application/xml" - assert_equal Mime::XML, @request.content_type - end - - def test_content_type_with_charset - @request.env["CONTENT_TYPE"] = "application/xml; charset=UTF-8" - assert_equal Mime::XML, @request.content_type - end - - def test_user_agent - assert_not_nil @request.user_agent - end - - def test_parameters - @request.stubs(:request_parameters).returns({ "foo" => 1 }) - @request.stubs(:query_parameters).returns({ "bar" => 2 }) - - assert_equal({"foo" => 1, "bar" => 2}, @request.parameters) - assert_equal({"foo" => 1}, @request.request_parameters) - assert_equal({"bar" => 2}, @request.query_parameters) - end - - protected - def request_method=(method) - @request.env['REQUEST_METHOD'] = method.to_s.upcase - @request.request_method = nil # Reset the ivar cache - end -end diff --git a/vendor/rails/actionpack/test/controller/rescue_test.rb b/vendor/rails/actionpack/test/controller/rescue_test.rb deleted file mode 100644 index 5709f37..0000000 --- a/vendor/rails/actionpack/test/controller/rescue_test.rb +++ /dev/null @@ -1,536 +0,0 @@ -require 'abstract_unit' - -class RescueController < ActionController::Base - class NotAuthorized < StandardError - end - class NotAuthorizedToRescueAsString < StandardError - end - - class RecordInvalid < StandardError - end - class RecordInvalidToRescueAsString < StandardError - end - - class NotAllowed < StandardError - end - class NotAllowedToRescueAsString < StandardError - end - - class InvalidRequest < StandardError - end - class InvalidRequestToRescueAsString < StandardError - end - - class BadGateway < StandardError - end - class BadGatewayToRescueAsString < StandardError - end - - class ResourceUnavailable < StandardError - end - class ResourceUnavailableToRescueAsString < StandardError - end - - # We use a fully-qualified name in some strings, and a relative constant - # name in some other to test correct handling of both cases. - - rescue_from NotAuthorized, :with => :deny_access - rescue_from 'RescueController::NotAuthorizedToRescueAsString', :with => :deny_access - - rescue_from RecordInvalid, :with => :show_errors - rescue_from 'RescueController::RecordInvalidToRescueAsString', :with => :show_errors - - rescue_from NotAllowed, :with => proc { head :forbidden } - rescue_from 'RescueController::NotAllowedToRescueAsString', :with => proc { head :forbidden } - - rescue_from InvalidRequest, :with => proc { |exception| render :text => exception.message } - rescue_from 'InvalidRequestToRescueAsString', :with => proc { |exception| render :text => exception.message } - - rescue_from BadGateway do - head :status => 502 - end - rescue_from 'BadGatewayToRescueAsString' do - head :status => 502 - end - - rescue_from ResourceUnavailable do |exception| - render :text => exception.message - end - rescue_from 'ResourceUnavailableToRescueAsString' do |exception| - render :text => exception.message - end - - # This is a Dispatcher exception and should be in ApplicationController. - rescue_from ActionController::RoutingError do - render :text => 'no way' - end - - before_filter(:only => :before_filter_raises) { raise 'umm nice' } - - def before_filter_raises - end - - def raises - render :text => 'already rendered' - raise "don't panic!" - end - - def method_not_allowed - raise ActionController::MethodNotAllowed.new(:get, :head, :put) - end - - def not_implemented - raise ActionController::NotImplemented.new(:get, :put) - end - - def not_authorized - raise NotAuthorized - end - def not_authorized_raise_as_string - raise NotAuthorizedToRescueAsString - end - - def not_allowed - raise NotAllowed - end - def not_allowed_raise_as_string - raise NotAllowedToRescueAsString - end - - def invalid_request - raise InvalidRequest - end - def invalid_request_raise_as_string - raise InvalidRequestToRescueAsString - end - - def record_invalid - raise RecordInvalid - end - def record_invalid_raise_as_string - raise RecordInvalidToRescueAsString - end - - def bad_gateway - raise BadGateway - end - def bad_gateway_raise_as_string - raise BadGatewayToRescueAsString - end - - def resource_unavailable - raise ResourceUnavailable - end - def resource_unavailable_raise_as_string - raise ResourceUnavailableToRescueAsString - end - - def missing_template - end - - protected - def deny_access - head :forbidden - end - - def show_errors(exception) - head :unprocessable_entity - end -end - -class RescueControllerTest < ActionController::TestCase - FIXTURE_PUBLIC = "#{File.dirname(__FILE__)}/../fixtures".freeze - - setup :set_all_requests_local - setup :populate_exception_object - - def set_all_requests_local - RescueController.consider_all_requests_local = true - @request.remote_addr = '1.2.3.4' - @request.host = 'example.com' - end - - def populate_exception_object - begin - raise 'foo' - rescue => @exception - end - end - - def test_rescue_exceptions_raised_by_filters - with_rails_root FIXTURE_PUBLIC do - with_all_requests_local false do - get :before_filter_raises - end - end - - assert_response :internal_server_error - end - - def test_rescue_action_locally_if_all_requests_local - @controller.expects(:local_request?).never - @controller.expects(:rescue_action_locally).with(@exception) - @controller.expects(:rescue_action_in_public).never - - with_all_requests_local do - @controller.send :rescue_action, @exception - end - end - - def test_rescue_action_locally_if_remote_addr_is_localhost - @controller.expects(:local_request?).returns(true) - @controller.expects(:rescue_action_locally).with(@exception) - @controller.expects(:rescue_action_in_public).never - - with_all_requests_local false do - @controller.send :rescue_action, @exception - end - end - - def test_rescue_action_in_public_otherwise - @controller.expects(:local_request?).returns(false) - @controller.expects(:rescue_action_locally).never - @controller.expects(:rescue_action_in_public).with(@exception) - - with_all_requests_local false do - @controller.send :rescue_action, @exception - end - end - - def test_rescue_action_in_public_with_localized_error_file - # Change locale - old_locale = I18n.locale - I18n.locale = :da - - with_rails_root FIXTURE_PUBLIC do - with_all_requests_local false do - get :raises - end - end - - assert_response :internal_server_error - body = File.read("#{FIXTURE_PUBLIC}/public/500.da.html") - assert_equal body, @response.body - ensure - I18n.locale = old_locale - end - - def test_rescue_action_in_public_with_error_file - with_rails_root FIXTURE_PUBLIC do - with_all_requests_local false do - get :raises - end - end - - assert_response :internal_server_error - body = File.read("#{FIXTURE_PUBLIC}/public/500.html") - assert_equal body, @response.body - end - - def test_rescue_action_in_public_without_error_file - with_rails_root '/tmp' do - with_all_requests_local false do - get :raises - end - end - - assert_response :internal_server_error - assert_equal ' ', @response.body - end - - def test_rescue_unknown_action_in_public_with_error_file - with_rails_root FIXTURE_PUBLIC do - with_all_requests_local false do - get :foobar_doesnt_exist - end - end - - assert_response :not_found - body = File.read("#{FIXTURE_PUBLIC}/public/404.html") - assert_equal body, @response.body - end - - def test_rescue_unknown_action_in_public_without_error_file - with_rails_root '/tmp' do - with_all_requests_local false do - get :foobar_doesnt_exist - end - end - - assert_response :not_found - assert_equal ' ', @response.body - end - - def test_rescue_missing_template_in_public - with_rails_root FIXTURE_PUBLIC do - with_all_requests_local true do - get :missing_template - end - end - - assert_response :internal_server_error - assert @response.body.include?('missing_template'), "Response should include the template name." - end - - def test_rescue_action_locally - get :raises - assert_response :internal_server_error - assert_template 'diagnostics.erb' - assert @response.body.include?('RescueController#raises'), "Response should include controller and action." - assert @response.body.include?("don't panic"), "Response should include exception message." - end - - def test_local_request_when_remote_addr_is_localhost - @controller.expects(:request).returns(@request).at_least_once - with_remote_addr '127.0.0.1' do - assert @controller.send(:local_request?) - end - end - - def test_local_request_when_remote_addr_isnt_locahost - @controller.expects(:request).returns(@request) - with_remote_addr '1.2.3.4' do - assert !@controller.send(:local_request?) - end - end - - def test_rescue_responses - responses = ActionController::Base.rescue_responses - - assert_equal ActionController::Rescue::DEFAULT_RESCUE_RESPONSE, responses.default - assert_equal ActionController::Rescue::DEFAULT_RESCUE_RESPONSE, responses[Exception.new] - - assert_equal :not_found, responses[ActionController::RoutingError.name] - assert_equal :not_found, responses[ActionController::UnknownAction.name] - assert_equal :not_found, responses['ActiveRecord::RecordNotFound'] - assert_equal :conflict, responses['ActiveRecord::StaleObjectError'] - assert_equal :unprocessable_entity, responses['ActiveRecord::RecordInvalid'] - assert_equal :unprocessable_entity, responses['ActiveRecord::RecordNotSaved'] - assert_equal :method_not_allowed, responses['ActionController::MethodNotAllowed'] - assert_equal :not_implemented, responses['ActionController::NotImplemented'] - end - - def test_rescue_templates - templates = ActionController::Base.rescue_templates - - assert_equal ActionController::Rescue::DEFAULT_RESCUE_TEMPLATE, templates.default - assert_equal ActionController::Rescue::DEFAULT_RESCUE_TEMPLATE, templates[Exception.new] - - assert_equal 'missing_template', templates[ActionView::MissingTemplate.name] - assert_equal 'routing_error', templates[ActionController::RoutingError.name] - assert_equal 'unknown_action', templates[ActionController::UnknownAction.name] - assert_equal 'template_error', templates[ActionView::TemplateError.name] - end - - def test_not_implemented - with_all_requests_local false do - with_rails_public_path(".") do - head :not_implemented - end - end - assert_response :not_implemented - assert_equal "GET, PUT", @response.headers['Allow'] - end - - def test_method_not_allowed - with_all_requests_local false do - with_rails_public_path(".") do - get :method_not_allowed - end - end - assert_response :method_not_allowed - assert_equal "GET, HEAD, PUT", @response.headers['Allow'] - end - - def test_rescue_handler - get :not_authorized - assert_response :forbidden - end - def test_rescue_handler_string - get :not_authorized_raise_as_string - assert_response :forbidden - end - - def test_rescue_handler_with_argument - @controller.expects(:show_errors).once.with { |e| e.is_a?(Exception) } - get :record_invalid - end - def test_rescue_handler_with_argument_as_string - @controller.expects(:show_errors).once.with { |e| e.is_a?(Exception) } - get :record_invalid_raise_as_string - end - - def test_proc_rescue_handler - get :not_allowed - assert_response :forbidden - end - def test_proc_rescue_handler_as_string - get :not_allowed_raise_as_string - assert_response :forbidden - end - - def test_proc_rescue_handle_with_argument - get :invalid_request - assert_equal "RescueController::InvalidRequest", @response.body - end - def test_proc_rescue_handle_with_argument_as_string - get :invalid_request_raise_as_string - assert_equal "RescueController::InvalidRequestToRescueAsString", @response.body - end - - def test_block_rescue_handler - get :bad_gateway - assert_response 502 - end - def test_block_rescue_handler_as_string - get :bad_gateway_raise_as_string - assert_response 502 - end - - def test_block_rescue_handler_with_argument - get :resource_unavailable - assert_equal "RescueController::ResourceUnavailable", @response.body - end - - def test_block_rescue_handler_with_argument_as_string - get :resource_unavailable_raise_as_string - assert_equal "RescueController::ResourceUnavailableToRescueAsString", @response.body - end - - def test_rescue_dispatcher_exceptions - env = @request.env - env["action_controller.rescue.request"] = @request - env["action_controller.rescue.response"] = @response - - RescueController.call_with_exception(env, ActionController::RoutingError.new("Route not found")) - assert_equal "no way", @response.body - end - - def test_rescue_dispatcher_exceptions_without_request_set - @request.env['REQUEST_URI'] = '/no_way' - response = RescueController.call_with_exception(@request.env, ActionController::RoutingError.new("Route not found")) - assert_kind_of ActionController::Response, response - assert_equal "no way", response.body - end - - protected - def with_all_requests_local(local = true) - old_local, ActionController::Base.consider_all_requests_local = - ActionController::Base.consider_all_requests_local, local - yield - ensure - ActionController::Base.consider_all_requests_local = old_local - end - - def with_remote_addr(addr) - old_remote_addr, @request.remote_addr = @request.remote_addr, addr - yield - ensure - @request.remote_addr = old_remote_addr - end - - def with_rails_public_path(rails_root) - old_rails = Object.const_get(:Rails) rescue nil - mod = Object.const_set(:Rails, Module.new) - (class << mod; self; end).instance_eval do - define_method(:public_path) { "#{rails_root}/public" } - end - yield - ensure - Object.module_eval { remove_const(:Rails) } if defined?(Rails) - Object.const_set(:Rails, old_rails) if old_rails - end - - def with_rails_root(path = nil,&block) - old_rails_root = RAILS_ROOT if defined?(RAILS_ROOT) - if path - silence_warnings { Object.const_set(:RAILS_ROOT, path) } - else - Object.remove_const(:RAILS_ROOT) rescue nil - end - - with_rails_public_path(path, &block) - - ensure - if old_rails_root - silence_warnings { Object.const_set(:RAILS_ROOT, old_rails_root) } - else - Object.remove_const(:RAILS_ROOT) rescue nil - end - end -end - -class ExceptionInheritanceRescueController < ActionController::Base - - class ParentException < StandardError - end - - class ChildException < ParentException - end - - class GrandchildException < ChildException - end - - rescue_from ChildException, :with => lambda { head :ok } - rescue_from ParentException, :with => lambda { head :created } - rescue_from GrandchildException, :with => lambda { head :no_content } - - def raise_parent_exception - raise ParentException - end - - def raise_child_exception - raise ChildException - end - - def raise_grandchild_exception - raise GrandchildException - end -end - -class ExceptionInheritanceRescueControllerTest < ActionController::TestCase - def test_bottom_first - get :raise_grandchild_exception - assert_response :no_content - end - - def test_inheritance_works - get :raise_child_exception - assert_response :created - end -end - -class ControllerInheritanceRescueController < ExceptionInheritanceRescueController - class FirstExceptionInChildController < StandardError - end - - class SecondExceptionInChildController < StandardError - end - - rescue_from FirstExceptionInChildController, 'SecondExceptionInChildController', :with => lambda { head :gone } - - def raise_first_exception_in_child_controller - raise FirstExceptionInChildController - end - - def raise_second_exception_in_child_controller - raise SecondExceptionInChildController - end -end - -class ControllerInheritanceRescueControllerTest < ActionController::TestCase - def test_first_exception_in_child_controller - get :raise_first_exception_in_child_controller - assert_response :gone - end - - def test_second_exception_in_child_controller - get :raise_second_exception_in_child_controller - assert_response :gone - end - - def test_exception_in_parent_controller - get :raise_parent_exception - assert_response :created - end -end diff --git a/vendor/rails/actionpack/test/controller/resources_test.rb b/vendor/rails/actionpack/test/controller/resources_test.rb deleted file mode 100644 index c807e71..0000000 --- a/vendor/rails/actionpack/test/controller/resources_test.rb +++ /dev/null @@ -1,1341 +0,0 @@ -require 'abstract_unit' - -class ResourcesController < ActionController::Base - def index() render :nothing => true end - alias_method :show, :index - def rescue_action(e) raise e end -end - -class ThreadsController < ResourcesController; end -class MessagesController < ResourcesController; end -class CommentsController < ResourcesController; end -class AuthorsController < ResourcesController; end -class LogosController < ResourcesController; end - -class AccountsController < ResourcesController; end -class AdminController < ResourcesController; end -class ProductsController < ResourcesController; end -class ImagesController < ResourcesController; end - -module Backoffice - class ProductsController < ResourcesController; end - class TagsController < ResourcesController; end - class ManufacturersController < ResourcesController; end - class ImagesController < ResourcesController; end - - module Admin - class ProductsController < ResourcesController; end - class ImagesController < ResourcesController; end - end -end - -class ResourcesTest < ActionController::TestCase - # The assertions in these tests are incompatible with the hash method - # optimisation. This could indicate user level problems - def setup - ActionController::Base.optimise_named_routes = false - end - - def teardown - ActionController::Base.optimise_named_routes = true - end - - def test_should_arrange_actions - resource = ActionController::Resources::Resource.new(:messages, - :collection => { :rss => :get, :reorder => :post, :csv => :post }, - :member => { :rss => :get, :atom => :get, :upload => :post, :fix => :post }, - :new => { :preview => :get, :draft => :get }) - - assert_resource_methods [:rss], resource, :collection, :get - assert_resource_methods [:csv, :reorder], resource, :collection, :post - assert_resource_methods [:edit, :rss, :atom], resource, :member, :get - assert_resource_methods [:upload, :fix], resource, :member, :post - assert_resource_methods [:new, :preview, :draft], resource, :new, :get - end - - def test_should_resource_controller_name_equal_resource_name_by_default - resource = ActionController::Resources::Resource.new(:messages, {}) - assert_equal 'messages', resource.controller - end - - def test_should_resource_controller_name_equal_controller_option - resource = ActionController::Resources::Resource.new(:messages, :controller => 'posts') - assert_equal 'posts', resource.controller - end - - def test_should_all_singleton_paths_be_the_same - [ :path, :nesting_path_prefix, :member_path ].each do |method| - resource = ActionController::Resources::SingletonResource.new(:messages, :path_prefix => 'admin') - assert_equal 'admin/messages', resource.send(method) - end - end - - def test_default_restful_routes - with_restful_routing :messages do - assert_simply_restful_for :messages - end - end - - def test_override_paths_for_default_restful_actions - resource = ActionController::Resources::Resource.new(:messages, - :path_names => {:new => 'nuevo', :edit => 'editar'}) - assert_equal resource.new_path, "#{resource.path}/nuevo" - end - - def test_multiple_default_restful_routes - with_restful_routing :messages, :comments do - assert_simply_restful_for :messages - assert_simply_restful_for :comments - end - end - - def test_with_custom_conditions - with_restful_routing :messages, :conditions => { :subdomain => 'app' } do - assert_equal 'app', ActionController::Routing::Routes.named_routes.routes[:messages].conditions[:subdomain] - end - end - - def test_irregular_id_with_no_requirements_should_raise_error - expected_options = {:controller => 'messages', :action => 'show', :id => '1.1.1'} - - with_restful_routing :messages do - assert_raise(ActionController::RoutingError) do - assert_recognizes(expected_options, :path => 'messages/1.1.1', :method => :get) - end - end - end - - def test_irregular_id_with_requirements_should_pass - expected_options = {:controller => 'messages', :action => 'show', :id => '1.1.1'} - - with_restful_routing(:messages, :requirements => {:id => /[0-9]\.[0-9]\.[0-9]/}) do - assert_recognizes(expected_options, :path => 'messages/1.1.1', :method => :get) - end - end - - def test_with_path_prefix_requirements - expected_options = {:controller => 'messages', :action => 'show', :thread_id => '1.1.1', :id => '1'} - with_restful_routing :messages, :path_prefix => '/thread/:thread_id', :requirements => {:thread_id => /[0-9]\.[0-9]\.[0-9]/} do - assert_recognizes(expected_options, :path => 'thread/1.1.1/messages/1', :method => :get) - end - end - - def test_with_path_prefix - with_restful_routing :messages, :path_prefix => '/thread/:thread_id' do - assert_simply_restful_for :messages, :path_prefix => 'thread/5/', :options => { :thread_id => '5' } - end - end - - def test_multiple_with_path_prefix - with_restful_routing :messages, :comments, :path_prefix => '/thread/:thread_id' do - assert_simply_restful_for :messages, :path_prefix => 'thread/5/', :options => { :thread_id => '5' } - assert_simply_restful_for :comments, :path_prefix => 'thread/5/', :options => { :thread_id => '5' } - end - end - - def test_with_name_prefix - with_restful_routing :messages, :name_prefix => 'post_' do - assert_simply_restful_for :messages, :name_prefix => 'post_' - end - end - - def test_with_collection_actions - actions = { 'a' => :get, 'b' => :put, 'c' => :post, 'd' => :delete } - - with_restful_routing :messages, :collection => actions do - assert_restful_routes_for :messages do |options| - actions.each do |action, method| - assert_recognizes(options.merge(:action => action), :path => "/messages/#{action}", :method => method) - end - end - - assert_restful_named_routes_for :messages do |options| - actions.keys.each do |action| - assert_named_route "/messages/#{action}", "#{action}_messages_path", :action => action - end - end - end - end - - def test_with_collection_actions_and_name_prefix - actions = { 'a' => :get, 'b' => :put, 'c' => :post, 'd' => :delete } - - with_restful_routing :messages, :path_prefix => '/threads/:thread_id', :name_prefix => "thread_", :collection => actions do - assert_restful_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - actions.each do |action, method| - assert_recognizes(options.merge(:action => action), :path => "/threads/1/messages/#{action}", :method => method) - end - end - - assert_restful_named_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - actions.keys.each do |action| - assert_named_route "/threads/1/messages/#{action}", "#{action}_thread_messages_path", :action => action - end - end - end - end - - def test_with_collection_actions_and_name_prefix_and_member_action_with_same_name - actions = { 'a' => :get } - - with_restful_routing :messages, :path_prefix => '/threads/:thread_id', :name_prefix => "thread_", :collection => actions, :member => actions do - assert_restful_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - actions.each do |action, method| - assert_recognizes(options.merge(:action => action), :path => "/threads/1/messages/#{action}", :method => method) - end - end - - assert_restful_named_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - actions.keys.each do |action| - assert_named_route "/threads/1/messages/#{action}", "#{action}_thread_messages_path", :action => action - end - end - end - end - - def test_with_collection_action_and_name_prefix_and_formatted - actions = { 'a' => :get, 'b' => :put, 'c' => :post, 'd' => :delete } - - with_restful_routing :messages, :path_prefix => '/threads/:thread_id', :name_prefix => "thread_", :collection => actions do - assert_restful_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - actions.each do |action, method| - assert_recognizes(options.merge(:action => action, :format => 'xml'), :path => "/threads/1/messages/#{action}.xml", :method => method) - end - end - - assert_restful_named_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - actions.keys.each do |action| - assert_named_route "/threads/1/messages/#{action}.xml", "#{action}_thread_messages_path", :action => action, :format => 'xml' - end - end - end - end - - def test_with_member_action - [:put, :post].each do |method| - with_restful_routing :messages, :member => { :mark => method } do - mark_options = {:action => 'mark', :id => '1'} - mark_path = "/messages/1/mark" - assert_restful_routes_for :messages do |options| - assert_recognizes(options.merge(mark_options), :path => mark_path, :method => method) - end - - assert_restful_named_routes_for :messages do |options| - assert_named_route mark_path, :mark_message_path, mark_options - end - end - end - end - - def test_with_member_action_and_requirement - expected_options = {:controller => 'messages', :action => 'mark', :id => '1.1.1'} - - with_restful_routing(:messages, :requirements => {:id => /[0-9]\.[0-9]\.[0-9]/}, :member => { :mark => :get }) do - assert_recognizes(expected_options, :path => 'messages/1.1.1/mark', :method => :get) - end - end - - def test_member_when_override_paths_for_default_restful_actions_with - [:put, :post].each do |method| - with_restful_routing :messages, :member => { :mark => method }, :path_names => {:new => 'nuevo'} do - mark_options = {:action => 'mark', :id => '1', :controller => "messages"} - mark_path = "/messages/1/mark" - - assert_restful_routes_for :messages, :path_names => {:new => 'nuevo'} do |options| - assert_recognizes(options.merge(mark_options), :path => mark_path, :method => method) - end - - assert_restful_named_routes_for :messages, :path_names => {:new => 'nuevo'} do |options| - assert_named_route mark_path, :mark_message_path, mark_options - end - end - end - end - - def test_member_when_changed_default_restful_actions_and_path_names_not_specified - default_path_names = ActionController::Base.resources_path_names - ActionController::Base.resources_path_names = {:new => 'nuevo', :edit => 'editar'} - - with_restful_routing :messages do - new_options = { :action => 'new', :controller => 'messages' } - new_path = "/messages/nuevo" - edit_options = { :action => 'edit', :id => '1', :controller => 'messages' } - edit_path = "/messages/1/editar" - - assert_restful_routes_for :messages do |options| - assert_recognizes(options.merge(new_options), :path => new_path, :method => :get) - end - - assert_restful_routes_for :messages do |options| - assert_recognizes(options.merge(edit_options), :path => edit_path, :method => :get) - end - end - ensure - ActionController::Base.resources_path_names = default_path_names - end - - def test_with_two_member_actions_with_same_method - [:put, :post].each do |method| - with_restful_routing :messages, :member => { :mark => method, :unmark => method } do - %w(mark unmark).each do |action| - action_options = {:action => action, :id => '1'} - action_path = "/messages/1/#{action}" - assert_restful_routes_for :messages do |options| - assert_recognizes(options.merge(action_options), :path => action_path, :method => method) - end - - assert_restful_named_routes_for :messages do |options| - assert_named_route action_path, "#{action}_message_path".to_sym, action_options - end - end - end - end - end - - def test_array_as_collection_or_member_method_value - with_restful_routing :messages, :collection => { :search => [:get, :post] }, :member => { :toggle => [:get, :post] } do - assert_restful_routes_for :messages do |options| - [:get, :post].each do |method| - assert_recognizes(options.merge(:action => 'search'), :path => "/messages/search", :method => method) - end - [:get, :post].each do |method| - assert_recognizes(options.merge(:action => 'toggle', :id => '1'), :path => '/messages/1/toggle', :method => method) - end - end - end - end - - def test_with_new_action - with_restful_routing :messages, :new => { :preview => :post } do - preview_options = {:action => 'preview'} - preview_path = "/messages/new/preview" - assert_restful_routes_for :messages do |options| - assert_recognizes(options.merge(preview_options), :path => preview_path, :method => :post) - end - - assert_restful_named_routes_for :messages do |options| - assert_named_route preview_path, :preview_new_message_path, preview_options - end - end - end - - def test_with_new_action_with_name_prefix - with_restful_routing :messages, :new => { :preview => :post }, :path_prefix => '/threads/:thread_id', :name_prefix => 'thread_' do - preview_options = {:action => 'preview', :thread_id => '1'} - preview_path = "/threads/1/messages/new/preview" - assert_restful_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - assert_recognizes(options.merge(preview_options), :path => preview_path, :method => :post) - end - - assert_restful_named_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - assert_named_route preview_path, :preview_new_thread_message_path, preview_options - end - end - end - - def test_with_formatted_new_action_with_name_prefix - with_restful_routing :messages, :new => { :preview => :post }, :path_prefix => '/threads/:thread_id', :name_prefix => 'thread_' do - preview_options = {:action => 'preview', :thread_id => '1', :format => 'xml'} - preview_path = "/threads/1/messages/new/preview.xml" - assert_restful_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - assert_recognizes(options.merge(preview_options), :path => preview_path, :method => :post) - end - - assert_restful_named_routes_for :messages, :path_prefix => 'threads/1/', :name_prefix => 'thread_', :options => { :thread_id => '1' } do |options| - assert_named_route preview_path, :preview_new_thread_message_path, preview_options - end - end - end - - def test_override_new_method - with_restful_routing :messages do - assert_restful_routes_for :messages do |options| - assert_recognizes(options.merge(:action => "new"), :path => "/messages/new", :method => :get) - assert_raise(ActionController::MethodNotAllowed) do - ActionController::Routing::Routes.recognize_path("/messages/new", :method => :post) - end - end - end - - with_restful_routing :messages, :new => { :new => :any } do - assert_restful_routes_for :messages do |options| - assert_recognizes(options.merge(:action => "new"), :path => "/messages/new", :method => :post) - assert_recognizes(options.merge(:action => "new"), :path => "/messages/new", :method => :get) - end - end - end - - def test_nested_restful_routes - with_routing do |set| - set.draw do |map| - map.resources :threads do |map| - map.resources :messages do |map| - map.resources :comments - end - end - end - - assert_simply_restful_for :threads - assert_simply_restful_for :messages, - :name_prefix => 'thread_', - :path_prefix => 'threads/1/', - :options => { :thread_id => '1' } - assert_simply_restful_for :comments, - :name_prefix => 'thread_message_', - :path_prefix => 'threads/1/messages/2/', - :options => { :thread_id => '1', :message_id => '2' } - end - end - - def test_nested_restful_routes_with_overwritten_defaults - with_routing do |set| - set.draw do |map| - map.resources :threads do |map| - map.resources :messages, :name_prefix => nil do |map| - map.resources :comments, :name_prefix => nil - end - end - end - - assert_simply_restful_for :threads - assert_simply_restful_for :messages, - :path_prefix => 'threads/1/', - :options => { :thread_id => '1' } - assert_simply_restful_for :comments, - :path_prefix => 'threads/1/messages/2/', - :options => { :thread_id => '1', :message_id => '2' } - end - end - - def test_shallow_nested_restful_routes - with_routing do |set| - set.draw do |map| - map.resources :threads, :shallow => true do |map| - map.resources :messages do |map| - map.resources :comments - end - end - end - - assert_simply_restful_for :threads, - :shallow => true - assert_simply_restful_for :messages, - :name_prefix => 'thread_', - :path_prefix => 'threads/1/', - :shallow => true, - :options => { :thread_id => '1' } - assert_simply_restful_for :comments, - :name_prefix => 'message_', - :path_prefix => 'messages/2/', - :shallow => true, - :options => { :message_id => '2' } - end - end - - def test_shallow_nested_restful_routes_with_namespaces - with_routing do |set| - set.draw do |map| - map.namespace :backoffice do |map| - map.namespace :admin do |map| - map.resources :products, :shallow => true do |map| - map.resources :images - end - end - end - end - - assert_simply_restful_for :products, - :controller => 'backoffice/admin/products', - :namespace => 'backoffice/admin/', - :name_prefix => 'backoffice_admin_', - :path_prefix => 'backoffice/admin/', - :shallow => true - assert_simply_restful_for :images, - :controller => 'backoffice/admin/images', - :namespace => 'backoffice/admin/', - :name_prefix => 'backoffice_admin_product_', - :path_prefix => 'backoffice/admin/products/1/', - :shallow => true, - :options => { :product_id => '1' } - end - end - - def test_restful_routes_dont_generate_duplicates - with_restful_routing :messages do - routes = ActionController::Routing::Routes.routes - routes.each do |route| - routes.each do |r| - next if route === r # skip the comparison instance - assert distinct_routes?(route, r), "Duplicate Route: #{route}" - end - end - end - end - - def test_should_create_singleton_resource_routes - with_singleton_resources :account do - assert_singleton_restful_for :account - end - end - - def test_should_create_multiple_singleton_resource_routes - with_singleton_resources :account, :logo do - assert_singleton_restful_for :account - assert_singleton_restful_for :logo - end - end - - def test_should_create_nested_singleton_resource_routes - with_routing do |set| - set.draw do |map| - map.resource :admin, :controller => 'admin' do |admin| - admin.resource :account - end - end - - assert_singleton_restful_for :admin, :controller => 'admin' - assert_singleton_restful_for :account, :name_prefix => "admin_", :path_prefix => 'admin/' - end - end - - def test_resource_has_many_should_become_nested_resources - with_routing do |set| - set.draw do |map| - map.resources :messages, :has_many => [ :comments, :authors ] - end - - assert_simply_restful_for :messages - assert_simply_restful_for :comments, :name_prefix => "message_", :path_prefix => 'messages/1/', :options => { :message_id => '1' } - assert_simply_restful_for :authors, :name_prefix => "message_", :path_prefix => 'messages/1/', :options => { :message_id => '1' } - end - end - - def test_resources_has_many_hash_should_become_nested_resources - with_routing do |set| - set.draw do |map| - map.resources :threads, :has_many => { :messages => [ :comments, { :authors => :threads } ] } - end - - assert_simply_restful_for :threads - assert_simply_restful_for :messages, :name_prefix => "thread_", :path_prefix => 'threads/1/', :options => { :thread_id => '1' } - assert_simply_restful_for :comments, :name_prefix => "thread_message_", :path_prefix => 'threads/1/messages/1/', :options => { :thread_id => '1', :message_id => '1' } - assert_simply_restful_for :authors, :name_prefix => "thread_message_", :path_prefix => 'threads/1/messages/1/', :options => { :thread_id => '1', :message_id => '1' } - assert_simply_restful_for :threads, :name_prefix => "thread_message_author_", :path_prefix => 'threads/1/messages/1/authors/1/', :options => { :thread_id => '1', :message_id => '1', :author_id => '1' } - end - end - - def test_shallow_resource_has_many_should_become_shallow_nested_resources - with_routing do |set| - set.draw do |map| - map.resources :messages, :has_many => [ :comments, :authors ], :shallow => true - end - - assert_simply_restful_for :messages, :shallow => true - assert_simply_restful_for :comments, :name_prefix => "message_", :path_prefix => 'messages/1/', :shallow => true, :options => { :message_id => '1' } - assert_simply_restful_for :authors, :name_prefix => "message_", :path_prefix => 'messages/1/', :shallow => true, :options => { :message_id => '1' } - end - end - - def test_resource_has_one_should_become_nested_resources - with_routing do |set| - set.draw do |map| - map.resources :messages, :has_one => :logo - end - - assert_simply_restful_for :messages - assert_singleton_restful_for :logo, :name_prefix => 'message_', :path_prefix => 'messages/1/', :options => { :message_id => '1' } - end - end - - def test_shallow_resource_has_one_should_become_shallow_nested_resources - with_routing do |set| - set.draw do |map| - map.resources :messages, :has_one => :logo, :shallow => true - end - - assert_simply_restful_for :messages, :shallow => true - assert_singleton_restful_for :logo, :name_prefix => 'message_', :path_prefix => 'messages/1/', :shallow => true, :options => { :message_id => '1' } - end - end - - def test_singleton_resource_with_member_action - [:put, :post].each do |method| - with_singleton_resources :account, :member => { :reset => method } do - reset_options = {:action => 'reset'} - reset_path = "/account/reset" - assert_singleton_routes_for :account do |options| - assert_recognizes(options.merge(reset_options), :path => reset_path, :method => method) - end - - assert_singleton_named_routes_for :account do |options| - assert_named_route reset_path, :reset_account_path, reset_options - end - end - end - end - - def test_singleton_resource_with_two_member_actions_with_same_method - [:put, :post].each do |method| - with_singleton_resources :account, :member => { :reset => method, :disable => method } do - %w(reset disable).each do |action| - action_options = {:action => action} - action_path = "/account/#{action}" - assert_singleton_routes_for :account do |options| - assert_recognizes(options.merge(action_options), :path => action_path, :method => method) - end - - assert_singleton_named_routes_for :account do |options| - assert_named_route action_path, "#{action}_account_path".to_sym, action_options - end - end - end - end - end - - def test_should_nest_resources_in_singleton_resource - with_routing do |set| - set.draw do |map| - map.resource :account do |account| - account.resources :messages - end - end - - assert_singleton_restful_for :account - assert_simply_restful_for :messages, :name_prefix => "account_", :path_prefix => 'account/' - end - end - - def test_should_nest_resources_in_singleton_resource_with_path_prefix - with_routing do |set| - set.draw do |map| - map.resource(:account, :path_prefix => ':site_id') do |account| - account.resources :messages - end - end - - assert_singleton_restful_for :account, :path_prefix => '7/', :options => { :site_id => '7' } - assert_simply_restful_for :messages, :name_prefix => "account_", :path_prefix => '7/account/', :options => { :site_id => '7' } - end - end - - def test_should_nest_singleton_resource_in_resources - with_routing do |set| - set.draw do |map| - map.resources :threads do |thread| - thread.resource :admin, :controller => 'admin' - end - end - - assert_simply_restful_for :threads - assert_singleton_restful_for :admin, :controller => 'admin', :name_prefix => 'thread_', :path_prefix => 'threads/5/', :options => { :thread_id => '5' } - end - end - - def test_should_not_allow_delete_or_put_on_collection_path - controller_name = :messages - with_restful_routing controller_name do - options = { :controller => controller_name.to_s } - collection_path = "/#{controller_name}" - - assert_raise(ActionController::MethodNotAllowed) do - assert_recognizes(options.merge(:action => 'update'), :path => collection_path, :method => :put) - end - - assert_raise(ActionController::MethodNotAllowed) do - assert_recognizes(options.merge(:action => 'destroy'), :path => collection_path, :method => :delete) - end - end - end - - def test_should_not_allow_invalid_head_method_for_member_routes - with_routing do |set| - set.draw do |map| - assert_raise(ArgumentError) do - map.resources :messages, :member => {:something => :head} - end - end - end - end - - def test_should_not_allow_invalid_http_methods_for_member_routes - with_routing do |set| - set.draw do |map| - assert_raise(ArgumentError) do - map.resources :messages, :member => {:something => :invalid} - end - end - end - end - - def test_resource_action_separator - with_routing do |set| - set.draw do |map| - map.resources :messages, :collection => {:search => :get}, :new => {:preview => :any}, :name_prefix => 'thread_', :path_prefix => '/threads/:thread_id' - map.resource :account, :member => {:login => :get}, :new => {:preview => :any}, :name_prefix => 'admin_', :path_prefix => '/admin' - end - - action_separator = ActionController::Base.resource_action_separator - - assert_simply_restful_for :messages, :name_prefix => 'thread_', :path_prefix => 'threads/1/', :options => { :thread_id => '1' } - assert_named_route "/threads/1/messages#{action_separator}search", "search_thread_messages_path", {} - assert_named_route "/threads/1/messages/new", "new_thread_message_path", {} - assert_named_route "/threads/1/messages/new#{action_separator}preview", "preview_new_thread_message_path", {} - assert_singleton_restful_for :account, :name_prefix => 'admin_', :path_prefix => 'admin/' - assert_named_route "/admin/account#{action_separator}login", "login_admin_account_path", {} - assert_named_route "/admin/account/new", "new_admin_account_path", {} - assert_named_route "/admin/account/new#{action_separator}preview", "preview_new_admin_account_path", {} - end - end - - def test_new_style_named_routes_for_resource - with_routing do |set| - set.draw do |map| - map.resources :messages, :collection => {:search => :get}, :new => {:preview => :any}, :name_prefix => 'thread_', :path_prefix => '/threads/:thread_id' - end - assert_simply_restful_for :messages, :name_prefix => 'thread_', :path_prefix => 'threads/1/', :options => { :thread_id => '1' } - assert_named_route "/threads/1/messages/search", "search_thread_messages_path", {} - assert_named_route "/threads/1/messages/new", "new_thread_message_path", {} - assert_named_route "/threads/1/messages/new/preview", "preview_new_thread_message_path", {} - end - end - - def test_new_style_named_routes_for_singleton_resource - with_routing do |set| - set.draw do |map| - map.resource :account, :member => {:login => :get}, :new => {:preview => :any}, :name_prefix => 'admin_', :path_prefix => '/admin' - end - assert_singleton_restful_for :account, :name_prefix => 'admin_', :path_prefix => 'admin/' - assert_named_route "/admin/account/login", "login_admin_account_path", {} - assert_named_route "/admin/account/new", "new_admin_account_path", {} - assert_named_route "/admin/account/new/preview", "preview_new_admin_account_path", {} - end - end - - def test_resources_in_namespace - with_routing do |set| - set.draw do |map| - map.namespace :backoffice do |backoffice| - backoffice.resources :products - end - end - - assert_simply_restful_for :products, :controller => "backoffice/products", :name_prefix => 'backoffice_', :path_prefix => 'backoffice/' - end - end - - def test_resource_has_many_in_namespace - with_routing do |set| - set.draw do |map| - map.namespace :backoffice do |backoffice| - backoffice.resources :products, :has_many => :tags - end - end - - assert_simply_restful_for :products, :controller => "backoffice/products", :name_prefix => 'backoffice_', :path_prefix => 'backoffice/' - assert_simply_restful_for :tags, :controller => "backoffice/tags", :name_prefix => "backoffice_product_", :path_prefix => 'backoffice/products/1/', :options => { :product_id => '1' } - end - end - - def test_resource_has_one_in_namespace - with_routing do |set| - set.draw do |map| - map.namespace :backoffice do |backoffice| - backoffice.resources :products, :has_one => :manufacturer - end - end - - assert_simply_restful_for :products, :controller => "backoffice/products", :name_prefix => 'backoffice_', :path_prefix => 'backoffice/' - assert_singleton_restful_for :manufacturer, :controller => "backoffice/manufacturers", :name_prefix => 'backoffice_product_', :path_prefix => 'backoffice/products/1/', :options => { :product_id => '1' } - end - end - - def test_resources_in_nested_namespace - with_routing do |set| - set.draw do |map| - map.namespace :backoffice do |backoffice| - backoffice.namespace :admin do |admin| - admin.resources :products - end - end - end - - assert_simply_restful_for :products, :controller => "backoffice/admin/products", :name_prefix => 'backoffice_admin_', :path_prefix => 'backoffice/admin/' - end - end - - def test_resources_using_namespace - with_routing do |set| - set.draw do |map| - map.resources :products, :namespace => "backoffice/" - end - - assert_simply_restful_for :products, :controller => "backoffice/products" - end - end - - def test_nested_resources_using_namespace - with_routing do |set| - set.draw do |map| - map.namespace :backoffice do |backoffice| - backoffice.resources :products do |products| - products.resources :images - end - end - end - - assert_simply_restful_for :images, :controller => "backoffice/images", :name_prefix => 'backoffice_product_', :path_prefix => 'backoffice/products/1/', :options => {:product_id => '1'} - end - end - - def test_nested_resources_in_nested_namespace - with_routing do |set| - set.draw do |map| - map.namespace :backoffice do |backoffice| - backoffice.namespace :admin do |admin| - admin.resources :products do |products| - products.resources :images - end - end - end - end - - assert_simply_restful_for :images, :controller => "backoffice/admin/images", :name_prefix => 'backoffice_admin_product_', :path_prefix => 'backoffice/admin/products/1/', :options => {:product_id => '1'} - end - end - - def test_with_path_segment - with_restful_routing :messages do - assert_simply_restful_for :messages - assert_recognizes({:controller => "messages", :action => "index"}, "/messages") - assert_recognizes({:controller => "messages", :action => "index"}, "/messages/") - end - - with_restful_routing :messages, :as => 'reviews' do - assert_simply_restful_for :messages, :as => 'reviews' - assert_recognizes({:controller => "messages", :action => "index"}, "/reviews") - assert_recognizes({:controller => "messages", :action => "index"}, "/reviews/") - end - end - - def test_multiple_with_path_segment_and_controller - with_routing do |set| - set.draw do |map| - map.resources :products do |products| - products.resources :product_reviews, :as => 'reviews', :controller => 'messages' - end - map.resources :tutors do |tutors| - tutors.resources :tutor_reviews, :as => 'reviews', :controller => 'comments' - end - end - - assert_simply_restful_for :product_reviews, :controller=>'messages', :as => 'reviews', :name_prefix => 'product_', :path_prefix => 'products/1/', :options => {:product_id => '1'} - assert_simply_restful_for :tutor_reviews,:controller=>'comments', :as => 'reviews', :name_prefix => 'tutor_', :path_prefix => 'tutors/1/', :options => {:tutor_id => '1'} - end - end - - def test_with_path_segment_path_prefix_requirements - expected_options = {:controller => 'messages', :action => 'show', :thread_id => '1.1.1', :id => '1'} - with_restful_routing :messages, :as => 'comments',:path_prefix => '/thread/:thread_id', :requirements => { :thread_id => /[0-9]\.[0-9]\.[0-9]/ } do - assert_recognizes(expected_options, :path => 'thread/1.1.1/comments/1', :method => :get) - end - end - - def test_resource_has_only_show_action - with_routing do |set| - set.draw do |map| - map.resources :products, :only => :show - end - - assert_resource_allowed_routes('products', {}, { :id => '1' }, :show, [:index, :new, :create, :edit, :update, :destroy]) - assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, :show, [:index, :new, :create, :edit, :update, :destroy]) - end - end - - def test_singleton_resource_has_only_show_action - with_routing do |set| - set.draw do |map| - map.resource :account, :only => :show - end - - assert_singleton_resource_allowed_routes('accounts', {}, :show, [:index, :new, :create, :edit, :update, :destroy]) - assert_singleton_resource_allowed_routes('accounts', { :format => 'xml' }, :show, [:index, :new, :create, :edit, :update, :destroy]) - end - end - - def test_resource_does_not_have_destroy_action - with_routing do |set| - set.draw do |map| - map.resources :products, :except => :destroy - end - - assert_resource_allowed_routes('products', {}, { :id => '1' }, [:index, :new, :create, :show, :edit, :update], :destroy) - assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, [:index, :new, :create, :show, :edit, :update], :destroy) - end - end - - def test_singleton_resource_does_not_have_destroy_action - with_routing do |set| - set.draw do |map| - map.resource :account, :except => :destroy - end - - assert_singleton_resource_allowed_routes('accounts', {}, [:new, :create, :show, :edit, :update], :destroy) - assert_singleton_resource_allowed_routes('accounts', { :format => 'xml' }, [:new, :create, :show, :edit, :update], :destroy) - end - end - - def test_resource_has_only_create_action_and_named_route - with_routing do |set| - set.draw do |map| - map.resources :products, :only => :create - end - - assert_resource_allowed_routes('products', {}, { :id => '1' }, :create, [:index, :new, :show, :edit, :update, :destroy]) - assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, :create, [:index, :new, :show, :edit, :update, :destroy]) - - assert_not_nil set.named_routes[:products] - end - end - - def test_resource_has_only_update_action_and_named_route - with_routing do |set| - set.draw do |map| - map.resources :products, :only => :update - end - - assert_resource_allowed_routes('products', {}, { :id => '1' }, :update, [:index, :new, :create, :show, :edit, :destroy]) - assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, :update, [:index, :new, :create, :show, :edit, :destroy]) - - assert_not_nil set.named_routes[:product] - end - end - - def test_resource_has_only_destroy_action_and_named_route - with_routing do |set| - set.draw do |map| - map.resources :products, :only => :destroy - end - - assert_resource_allowed_routes('products', {}, { :id => '1' }, :destroy, [:index, :new, :create, :show, :edit, :update]) - assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, :destroy, [:index, :new, :create, :show, :edit, :update]) - - assert_not_nil set.named_routes[:product] - end - end - - def test_singleton_resource_has_only_create_action_and_named_route - with_routing do |set| - set.draw do |map| - map.resource :account, :only => :create - end - - assert_singleton_resource_allowed_routes('accounts', {}, :create, [:new, :show, :edit, :update, :destroy]) - assert_singleton_resource_allowed_routes('accounts', { :format => 'xml' }, :create, [:new, :show, :edit, :update, :destroy]) - - assert_not_nil set.named_routes[:account] - end - end - - def test_singleton_resource_has_only_update_action_and_named_route - with_routing do |set| - set.draw do |map| - map.resource :account, :only => :update - end - - assert_singleton_resource_allowed_routes('accounts', {}, :update, [:new, :create, :show, :edit, :destroy]) - assert_singleton_resource_allowed_routes('accounts', { :format => 'xml' }, :update, [:new, :create, :show, :edit, :destroy]) - - assert_not_nil set.named_routes[:account] - end - end - - def test_singleton_resource_has_only_destroy_action_and_named_route - with_routing do |set| - set.draw do |map| - map.resource :account, :only => :destroy - end - - assert_singleton_resource_allowed_routes('accounts', {}, :destroy, [:new, :create, :show, :edit, :update]) - assert_singleton_resource_allowed_routes('accounts', { :format => 'xml' }, :destroy, [:new, :create, :show, :edit, :update]) - - assert_not_nil set.named_routes[:account] - end - end - - def test_resource_has_only_collection_action - with_routing do |set| - set.draw do |map| - map.resources :products, :except => :all, :collection => { :sale => :get } - end - - assert_resource_allowed_routes('products', {}, { :id => '1' }, [], [:index, :new, :create, :show, :edit, :update, :destroy]) - assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, [], [:index, :new, :create, :show, :edit, :update, :destroy]) - - assert_recognizes({ :controller => 'products', :action => 'sale' }, :path => 'products/sale', :method => :get) - assert_recognizes({ :controller => 'products', :action => 'sale', :format => 'xml' }, :path => 'products/sale.xml', :method => :get) - end - end - - def test_resource_has_only_member_action - with_routing do |set| - set.draw do |map| - map.resources :products, :except => :all, :member => { :preview => :get } - end - - assert_resource_allowed_routes('products', {}, { :id => '1' }, [], [:index, :new, :create, :show, :edit, :update, :destroy]) - assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, [], [:index, :new, :create, :show, :edit, :update, :destroy]) - - assert_recognizes({ :controller => 'products', :action => 'preview', :id => '1' }, :path => 'products/1/preview', :method => :get) - assert_recognizes({ :controller => 'products', :action => 'preview', :id => '1', :format => 'xml' }, :path => 'products/1/preview.xml', :method => :get) - end - end - - def test_singleton_resource_has_only_member_action - with_routing do |set| - set.draw do |map| - map.resource :account, :except => :all, :member => { :signup => :get } - end - - assert_singleton_resource_allowed_routes('accounts', {}, [], [:new, :create, :show, :edit, :update, :destroy]) - assert_singleton_resource_allowed_routes('accounts', { :format => 'xml' }, [], [:new, :create, :show, :edit, :update, :destroy]) - - assert_recognizes({ :controller => 'accounts', :action => 'signup' }, :path => 'account/signup', :method => :get) - assert_recognizes({ :controller => 'accounts', :action => 'signup', :format => 'xml' }, :path => 'account/signup.xml', :method => :get) - end - end - - def test_nested_resource_has_only_show_and_member_action - with_routing do |set| - set.draw do |map| - map.resources :products, :only => [:index, :show] do |product| - product.resources :images, :member => { :thumbnail => :get }, :only => :show - end - end - - assert_resource_allowed_routes('images', { :product_id => '1' }, { :id => '2' }, :show, [:index, :new, :create, :edit, :update, :destroy], 'products/1/images') - assert_resource_allowed_routes('images', { :product_id => '1', :format => 'xml' }, { :id => '2' }, :show, [:index, :new, :create, :edit, :update, :destroy], 'products/1/images') - - assert_recognizes({ :controller => 'images', :action => 'thumbnail', :product_id => '1', :id => '2' }, :path => 'products/1/images/2/thumbnail', :method => :get) - assert_recognizes({ :controller => 'images', :action => 'thumbnail', :product_id => '1', :id => '2', :format => 'jpg' }, :path => 'products/1/images/2/thumbnail.jpg', :method => :get) - end - end - - def test_nested_resource_does_not_inherit_only_option - with_routing do |set| - set.draw do |map| - map.resources :products, :only => :show do |product| - product.resources :images, :except => :destroy - end - end - - assert_resource_allowed_routes('images', { :product_id => '1' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update], :destroy, 'products/1/images') - assert_resource_allowed_routes('images', { :product_id => '1', :format => 'xml' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update], :destroy, 'products/1/images') - end - end - - def test_nested_resource_does_not_inherit_only_option_by_default - with_routing do |set| - set.draw do |map| - map.resources :products, :only => :show do |product| - product.resources :images - end - end - - assert_resource_allowed_routes('images', { :product_id => '1' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update, :destory], [], 'products/1/images') - assert_resource_allowed_routes('images', { :product_id => '1', :format => 'xml' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update, :destroy], [], 'products/1/images') - end - end - - def test_nested_resource_does_not_inherit_except_option - with_routing do |set| - set.draw do |map| - map.resources :products, :except => :show do |product| - product.resources :images, :only => :destroy - end - end - - assert_resource_allowed_routes('images', { :product_id => '1' }, { :id => '2' }, :destroy, [:index, :new, :create, :show, :edit, :update], 'products/1/images') - assert_resource_allowed_routes('images', { :product_id => '1', :format => 'xml' }, { :id => '2' }, :destroy, [:index, :new, :create, :show, :edit, :update], 'products/1/images') - end - end - - def test_nested_resource_does_not_inherit_except_option_by_default - with_routing do |set| - set.draw do |map| - map.resources :products, :except => :show do |product| - product.resources :images - end - end - - assert_resource_allowed_routes('images', { :product_id => '1' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update, :destroy], [], 'products/1/images') - assert_resource_allowed_routes('images', { :product_id => '1', :format => 'xml' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update, :destroy], [], 'products/1/images') - end - end - - def test_default_singleton_restful_route_uses_get - with_routing do |set| - set.draw do |map| - map.resource :product - end - - assert_equal :get, set.named_routes.routes[:product].conditions[:method] - end - end - - protected - def with_restful_routing(*args) - with_routing do |set| - set.draw { |map| map.resources(*args) } - yield - end - end - - def with_singleton_resources(*args) - with_routing do |set| - set.draw { |map| map.resource(*args) } - yield - end - end - - # runs assert_restful_routes_for and assert_restful_named_routes for on the controller_name and options, without passing a block. - def assert_simply_restful_for(controller_name, options = {}) - assert_restful_routes_for controller_name, options - assert_restful_named_routes_for controller_name, nil, options - end - - def assert_singleton_restful_for(singleton_name, options = {}) - assert_singleton_routes_for singleton_name, options - assert_singleton_named_routes_for singleton_name, options - end - - def assert_restful_routes_for(controller_name, options = {}) - options[:options] ||= {} - options[:options][:controller] = options[:controller] || controller_name.to_s - - if options[:shallow] - options[:shallow_options] ||= {} - options[:shallow_options][:controller] = options[:options][:controller] - else - options[:shallow_options] = options[:options] - end - - new_action = ActionController::Base.resources_path_names[:new] || "new" - edit_action = ActionController::Base.resources_path_names[:edit] || "edit" - if options[:path_names] - new_action = options[:path_names][:new] if options[:path_names][:new] - edit_action = options[:path_names][:edit] if options[:path_names][:edit] - end - - path = "#{options[:as] || controller_name}" - collection_path = "/#{options[:path_prefix]}#{path}" - shallow_path = "/#{options[:shallow] ? options[:namespace] : options[:path_prefix]}#{path}" - member_path = "#{shallow_path}/1" - new_path = "#{collection_path}/#{new_action}" - edit_member_path = "#{member_path}/#{edit_action}" - formatted_edit_member_path = "#{member_path}/#{edit_action}.xml" - - with_options(options[:options]) do |controller| - controller.assert_routing collection_path, :action => 'index' - controller.assert_routing new_path, :action => 'new' - controller.assert_routing "#{collection_path}.xml", :action => 'index', :format => 'xml' - controller.assert_routing "#{new_path}.xml", :action => 'new', :format => 'xml' - end - - with_options(options[:shallow_options]) do |controller| - controller.assert_routing member_path, :action => 'show', :id => '1' - controller.assert_routing edit_member_path, :action => 'edit', :id => '1' - controller.assert_routing "#{member_path}.xml", :action => 'show', :id => '1', :format => 'xml' - controller.assert_routing formatted_edit_member_path, :action => 'edit', :id => '1', :format => 'xml' - end - - assert_recognizes(options[:options].merge(:action => 'index'), :path => collection_path, :method => :get) - assert_recognizes(options[:options].merge(:action => 'new'), :path => new_path, :method => :get) - assert_recognizes(options[:options].merge(:action => 'create'), :path => collection_path, :method => :post) - assert_recognizes(options[:shallow_options].merge(:action => 'show', :id => '1'), :path => member_path, :method => :get) - assert_recognizes(options[:shallow_options].merge(:action => 'edit', :id => '1'), :path => edit_member_path, :method => :get) - assert_recognizes(options[:shallow_options].merge(:action => 'update', :id => '1'), :path => member_path, :method => :put) - assert_recognizes(options[:shallow_options].merge(:action => 'destroy', :id => '1'), :path => member_path, :method => :delete) - - assert_recognizes(options[:options].merge(:action => 'index', :format => 'xml'), :path => "#{collection_path}.xml", :method => :get) - assert_recognizes(options[:options].merge(:action => 'new', :format => 'xml'), :path => "#{new_path}.xml", :method => :get) - assert_recognizes(options[:options].merge(:action => 'create', :format => 'xml'), :path => "#{collection_path}.xml", :method => :post) - assert_recognizes(options[:shallow_options].merge(:action => 'show', :id => '1', :format => 'xml'), :path => "#{member_path}.xml", :method => :get) - assert_recognizes(options[:shallow_options].merge(:action => 'edit', :id => '1', :format => 'xml'), :path => formatted_edit_member_path, :method => :get) - assert_recognizes(options[:shallow_options].merge(:action => 'update', :id => '1', :format => 'xml'), :path => "#{member_path}.xml", :method => :put) - assert_recognizes(options[:shallow_options].merge(:action => 'destroy', :id => '1', :format => 'xml'), :path => "#{member_path}.xml", :method => :delete) - - yield options[:options] if block_given? - end - - # test named routes like foo_path and foos_path map to the correct options. - def assert_restful_named_routes_for(controller_name, singular_name = nil, options = {}) - if singular_name.is_a?(Hash) - options = singular_name - singular_name = nil - end - singular_name ||= controller_name.to_s.singularize - - options[:options] ||= {} - options[:options][:controller] = options[:controller] || controller_name.to_s - - if options[:shallow] - options[:shallow_options] ||= {} - options[:shallow_options][:controller] = options[:options][:controller] - else - options[:shallow_options] = options[:options] - end - - @controller = "#{options[:options][:controller].camelize}Controller".constantize.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - get :index, options[:options] - options[:options].delete :action - - path = "#{options[:as] || controller_name}" - shallow_path = "/#{options[:shallow] ? options[:namespace] : options[:path_prefix]}#{path}" - full_path = "/#{options[:path_prefix]}#{path}" - name_prefix = options[:name_prefix] - shallow_prefix = options[:shallow] ? options[:namespace].try(:gsub, /\//, '_') : options[:name_prefix] - - new_action = "new" - edit_action = "edit" - if options[:path_names] - new_action = options[:path_names][:new] || "new" - edit_action = options[:path_names][:edit] || "edit" - end - - assert_named_route "#{full_path}", "#{name_prefix}#{controller_name}_path", options[:options] - assert_named_route "#{full_path}.xml", "#{name_prefix}#{controller_name}_path", options[:options].merge(:format => 'xml') - assert_named_route "#{shallow_path}/1", "#{shallow_prefix}#{singular_name}_path", options[:shallow_options].merge(:id => '1') - assert_named_route "#{shallow_path}/1.xml", "#{shallow_prefix}#{singular_name}_path", options[:shallow_options].merge(:id => '1', :format => 'xml') - - assert_named_route "#{full_path}/#{new_action}", "new_#{name_prefix}#{singular_name}_path", options[:options] - assert_named_route "#{full_path}/#{new_action}.xml", "new_#{name_prefix}#{singular_name}_path", options[:options].merge(:format => 'xml') - assert_named_route "#{shallow_path}/1/#{edit_action}", "edit_#{shallow_prefix}#{singular_name}_path", options[:shallow_options].merge(:id => '1') - assert_named_route "#{shallow_path}/1/#{edit_action}.xml", "edit_#{shallow_prefix}#{singular_name}_path", options[:shallow_options].merge(:id => '1', :format => 'xml') - - yield options[:options] if block_given? - end - - def assert_singleton_routes_for(singleton_name, options = {}) - options[:options] ||= {} - options[:options][:controller] = options[:controller] || singleton_name.to_s.pluralize - - full_path = "/#{options[:path_prefix]}#{options[:as] || singleton_name}" - new_path = "#{full_path}/new" - edit_path = "#{full_path}/edit" - formatted_edit_path = "#{full_path}/edit.xml" - - with_options options[:options] do |controller| - controller.assert_routing full_path, :action => 'show' - controller.assert_routing new_path, :action => 'new' - controller.assert_routing edit_path, :action => 'edit' - controller.assert_routing "#{full_path}.xml", :action => 'show', :format => 'xml' - controller.assert_routing "#{new_path}.xml", :action => 'new', :format => 'xml' - controller.assert_routing formatted_edit_path, :action => 'edit', :format => 'xml' - end - - assert_recognizes(options[:options].merge(:action => 'show'), :path => full_path, :method => :get) - assert_recognizes(options[:options].merge(:action => 'new'), :path => new_path, :method => :get) - assert_recognizes(options[:options].merge(:action => 'edit'), :path => edit_path, :method => :get) - assert_recognizes(options[:options].merge(:action => 'create'), :path => full_path, :method => :post) - assert_recognizes(options[:options].merge(:action => 'update'), :path => full_path, :method => :put) - assert_recognizes(options[:options].merge(:action => 'destroy'), :path => full_path, :method => :delete) - - assert_recognizes(options[:options].merge(:action => 'show', :format => 'xml'), :path => "#{full_path}.xml", :method => :get) - assert_recognizes(options[:options].merge(:action => 'new', :format => 'xml'), :path => "#{new_path}.xml", :method => :get) - assert_recognizes(options[:options].merge(:action => 'edit', :format => 'xml'), :path => formatted_edit_path, :method => :get) - assert_recognizes(options[:options].merge(:action => 'create', :format => 'xml'), :path => "#{full_path}.xml", :method => :post) - assert_recognizes(options[:options].merge(:action => 'update', :format => 'xml'), :path => "#{full_path}.xml", :method => :put) - assert_recognizes(options[:options].merge(:action => 'destroy', :format => 'xml'), :path => "#{full_path}.xml", :method => :delete) - - yield options[:options] if block_given? - end - - def assert_singleton_named_routes_for(singleton_name, options = {}) - (options[:options] ||= {})[:controller] ||= singleton_name.to_s.pluralize - @controller = "#{options[:options][:controller].camelize}Controller".constantize.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - get :show, options[:options] - options[:options].delete :action - - full_path = "/#{options[:path_prefix]}#{options[:as] || singleton_name}" - name_prefix = options[:name_prefix] - - assert_named_route "#{full_path}", "#{name_prefix}#{singleton_name}_path", options[:options] - assert_named_route "#{full_path}.xml", "#{name_prefix}#{singleton_name}_path", options[:options].merge(:format => 'xml') - - assert_named_route "#{full_path}/new", "new_#{name_prefix}#{singleton_name}_path", options[:options] - assert_named_route "#{full_path}/new.xml", "new_#{name_prefix}#{singleton_name}_path", options[:options].merge(:format => 'xml') - assert_named_route "#{full_path}/edit", "edit_#{name_prefix}#{singleton_name}_path", options[:options] - assert_named_route "#{full_path}/edit.xml", "edit_#{name_prefix}#{singleton_name}_path", options[:options].merge(:format => 'xml') - end - - def assert_named_route(expected, route, options) - actual = @controller.send(route, options) rescue $!.class.name - assert_equal expected, actual, "Error on route: #{route}(#{options.inspect})" - end - - def assert_resource_methods(expected, resource, action_method, method) - assert_equal expected.length, resource.send("#{action_method}_methods")[method].size, "#{resource.send("#{action_method}_methods")[method].inspect}" - expected.each do |action| - assert resource.send("#{action_method}_methods")[method].include?(action), - "#{method} not in #{action_method} methods: #{resource.send("#{action_method}_methods")[method].inspect}" - end - end - - def assert_resource_allowed_routes(controller, options, shallow_options, allowed, not_allowed, path = controller) - shallow_path = "#{path}/#{shallow_options[:id]}" - format = options[:format] && ".#{options[:format]}" - options.merge!(:controller => controller) - shallow_options.merge!(options) - - assert_whether_allowed(allowed, not_allowed, options, 'index', "#{path}#{format}", :get) - assert_whether_allowed(allowed, not_allowed, options, 'new', "#{path}/new#{format}", :get) - assert_whether_allowed(allowed, not_allowed, options, 'create', "#{path}#{format}", :post) - assert_whether_allowed(allowed, not_allowed, shallow_options, 'show', "#{shallow_path}#{format}", :get) - assert_whether_allowed(allowed, not_allowed, shallow_options, 'edit', "#{shallow_path}/edit#{format}", :get) - assert_whether_allowed(allowed, not_allowed, shallow_options, 'update', "#{shallow_path}#{format}", :put) - assert_whether_allowed(allowed, not_allowed, shallow_options, 'destroy', "#{shallow_path}#{format}", :delete) - end - - def assert_singleton_resource_allowed_routes(controller, options, allowed, not_allowed, path = controller.singularize) - format = options[:format] && ".#{options[:format]}" - options.merge!(:controller => controller) - - assert_whether_allowed(allowed, not_allowed, options, 'new', "#{path}/new#{format}", :get) - assert_whether_allowed(allowed, not_allowed, options, 'create', "#{path}#{format}", :post) - assert_whether_allowed(allowed, not_allowed, options, 'show', "#{path}#{format}", :get) - assert_whether_allowed(allowed, not_allowed, options, 'edit', "#{path}/edit#{format}", :get) - assert_whether_allowed(allowed, not_allowed, options, 'update', "#{path}#{format}", :put) - assert_whether_allowed(allowed, not_allowed, options, 'destroy', "#{path}#{format}", :delete) - end - - def assert_whether_allowed(allowed, not_allowed, options, action, path, method) - action = action.to_sym - options = options.merge(:action => action.to_s) - path_options = { :path => path, :method => method } - - if Array(allowed).include?(action) - assert_recognizes options, path_options - elsif Array(not_allowed).include?(action) - assert_not_recognizes options, path_options - end - end - - def assert_not_recognizes(expected_options, path) - assert_raise ActionController::RoutingError, ActionController::MethodNotAllowed, Assertion do - assert_recognizes(expected_options, path) - end - end - - def distinct_routes? (r1, r2) - if r1.conditions == r2.conditions and r1.requirements == r2.requirements then - if r1.segments.collect(&:to_s) == r2.segments.collect(&:to_s) then - return false - end - end - true - end -end diff --git a/vendor/rails/actionpack/test/controller/routing_test.rb b/vendor/rails/actionpack/test/controller/routing_test.rb deleted file mode 100644 index ef56119..0000000 --- a/vendor/rails/actionpack/test/controller/routing_test.rb +++ /dev/null @@ -1,2557 +0,0 @@ -require 'abstract_unit' -require 'controller/fake_controllers' - -class MilestonesController < ActionController::Base - def index() head :ok end - alias_method :show, :index - def rescue_action(e) raise e end -end - -RunTimeTests = ARGV.include? 'time' -ROUTING = ActionController::Routing - -class ROUTING::RouteBuilder - attr_reader :warn_output - - def warn(msg) - (@warn_output ||= []) << msg - end -end - -# See RFC 3986, section 3.3 for allowed path characters. -class UriReservedCharactersRoutingTest < Test::Unit::TestCase - def setup - ActionController::Routing.use_controllers! ['controller'] - @set = ActionController::Routing::RouteSet.new - @set.draw do |map| - map.connect ':controller/:action/:variable/*additional' - end - - safe, unsafe = %w(: @ & = + $ , ;), %w(^ / ? # [ ]) - hex = unsafe.map { |char| '%' + char.unpack('H2').first.upcase } - - @segment = "#{safe.join}#{unsafe.join}".freeze - @escaped = "#{safe.join}#{hex.join}".freeze - end - - def test_route_generation_escapes_unsafe_path_characters - assert_equal "/contr#{@segment}oller/act#{@escaped}ion/var#{@escaped}iable/add#{@escaped}itional-1/add#{@escaped}itional-2", - @set.generate(:controller => "contr#{@segment}oller", - :action => "act#{@segment}ion", - :variable => "var#{@segment}iable", - :additional => ["add#{@segment}itional-1", "add#{@segment}itional-2"]) - end - - def test_route_recognition_unescapes_path_components - options = { :controller => "controller", - :action => "act#{@segment}ion", - :variable => "var#{@segment}iable", - :additional => ["add#{@segment}itional-1", "add#{@segment}itional-2"] } - assert_equal options, @set.recognize_path("/controller/act#{@escaped}ion/var#{@escaped}iable/add#{@escaped}itional-1/add#{@escaped}itional-2") - end - - def test_route_generation_allows_passing_non_string_values_to_generated_helper - assert_equal "/controller/action/variable/1/2", @set.generate(:controller => "controller", - :action => "action", - :variable => "variable", - :additional => [1, 2]) - end -end - -class SegmentTest < Test::Unit::TestCase - def test_first_segment_should_interpolate_for_structure - s = ROUTING::Segment.new - def s.interpolation_statement(array) 'hello' end - assert_equal 'hello', s.continue_string_structure([]) - end - - def test_interpolation_statement - s = ROUTING::StaticSegment.new("Hello") - assert_equal "Hello", eval(s.interpolation_statement([])) - assert_equal "HelloHello", eval(s.interpolation_statement([s])) - - s2 = ROUTING::StaticSegment.new("-") - assert_equal "Hello-Hello", eval(s.interpolation_statement([s, s2])) - - s3 = ROUTING::StaticSegment.new("World") - assert_equal "Hello-World", eval(s3.interpolation_statement([s, s2])) - end -end - -class StaticSegmentTest < Test::Unit::TestCase - def test_interpolation_chunk_should_respect_raw - s = ROUTING::StaticSegment.new('Hello World') - assert !s.raw? - assert_equal 'Hello%20World', s.interpolation_chunk - - s = ROUTING::StaticSegment.new('Hello World', :raw => true) - assert s.raw? - assert_equal 'Hello World', s.interpolation_chunk - end - - def test_regexp_chunk_should_escape_specials - s = ROUTING::StaticSegment.new('Hello*World') - assert_equal 'Hello\*World', s.regexp_chunk - - s = ROUTING::StaticSegment.new('HelloWorld') - assert_equal 'HelloWorld', s.regexp_chunk - end - - def test_regexp_chunk_should_add_question_mark_for_optionals - s = ROUTING::StaticSegment.new("/", :optional => true) - assert_equal "/?", s.regexp_chunk - - s = ROUTING::StaticSegment.new("hello", :optional => true) - assert_equal "(?:hello)?", s.regexp_chunk - end -end - -class DynamicSegmentTest < Test::Unit::TestCase - def segment(options = {}) - unless @segment - @segment = ROUTING::DynamicSegment.new(:a, options) - end - @segment - end - - def test_extract_value - s = ROUTING::DynamicSegment.new(:a) - - hash = {:a => '10', :b => '20'} - assert_equal '10', eval(s.extract_value) - - hash = {:b => '20'} - assert_equal nil, eval(s.extract_value) - - s.default = '20' - assert_equal '20', eval(s.extract_value) - end - - def test_default_local_name - assert_equal 'a_value', segment.local_name, - "Unexpected name -- all value_check tests will fail!" - end - - def test_presence_value_check - a_value = 10 - assert eval(segment.value_check) - end - - def test_regexp_value_check_rejects_nil - segment = segment(:regexp => /\d+/) - - a_value = nil - assert !eval(segment.value_check) - end - - def test_optional_regexp_value_check_should_accept_nil - segment = segment(:regexp => /\d+/, :optional => true) - - a_value = nil - assert eval(segment.value_check) - end - - def test_regexp_value_check_rejects_no_match - segment = segment(:regexp => /\d+/) - - a_value = "Hello20World" - assert !eval(segment.value_check) - - a_value = "20Hi" - assert !eval(segment.value_check) - end - - def test_regexp_value_check_accepts_match - segment = segment(:regexp => /\d+/) - a_value = "30" - assert eval(segment.value_check) - end - - def test_value_check_fails_on_nil - a_value = nil - assert ! eval(segment.value_check) - end - - def test_optional_value_needs_no_check - segment = segment(:optional => true) - - a_value = nil - assert_equal nil, segment.value_check - end - - def test_regexp_value_check_should_accept_match_with_default - segment = segment(:regexp => /\d+/, :default => '200') - - a_value = '100' - assert eval(segment.value_check) - end - - def test_expiry_should_not_trigger_once_expired - expired = true - hash = merged = {:a => 2, :b => 3} - options = {:b => 3} - expire_on = Hash.new { raise 'No!!!' } - - eval(segment.expiry_statement) - rescue RuntimeError - flunk "Expiry check should not have occurred!" - end - - def test_expiry_should_occur_according_to_expire_on - expired = false - hash = merged = {:a => 2, :b => 3} - options = {:b => 3} - - expire_on = {:b => true, :a => false} - eval(segment.expiry_statement) - assert !expired - assert_equal({:a => 2, :b => 3}, hash) - - expire_on = {:b => true, :a => true} - eval(segment.expiry_statement) - assert expired - assert_equal({:b => 3}, hash) - end - - def test_extraction_code_should_return_on_nil - hash = merged = {:b => 3} - options = {:b => 3} - a_value = nil - - # Local jump because of return inside eval. - assert_raise(LocalJumpError) { eval(segment.extraction_code) } - end - - def test_extraction_code_should_return_on_mismatch - segment = segment(:regexp => /\d+/) - hash = merged = {:a => 'Hi', :b => '3'} - options = {:b => '3'} - a_value = nil - - # Local jump because of return inside eval. - assert_raise(LocalJumpError) { eval(segment.extraction_code) } - end - - def test_extraction_code_should_accept_value_and_set_local - hash = merged = {:a => 'Hi', :b => '3'} - options = {:b => '3'} - a_value = nil - expired = true - - eval(segment.extraction_code) - assert_equal 'Hi', a_value - end - - def test_extraction_should_work_without_value_check - segment.default = 'hi' - hash = merged = {:b => '3'} - options = {:b => '3'} - a_value = nil - expired = true - - eval(segment.extraction_code) - assert_equal 'hi', a_value - end - - def test_extraction_code_should_perform_expiry - expired = false - hash = merged = {:a => 'Hi', :b => '3'} - options = {:b => '3'} - expire_on = {:a => true} - a_value = nil - - eval(segment.extraction_code) - assert_equal 'Hi', a_value - assert expired - assert_equal options, hash - end - - def test_interpolation_chunk_should_replace_value - a_value = 'Hi' - assert_equal a_value, eval(%("#{segment.interpolation_chunk}")) - end - - def test_interpolation_chunk_should_accept_nil - a_value = nil - assert_equal '', eval(%("#{segment.interpolation_chunk('a_value')}")) - end - - def test_value_regexp_should_be_nil_without_regexp - assert_equal nil, segment.value_regexp - end - - def test_value_regexp_should_match_exacly - segment = segment(:regexp => /\d+/) - assert_no_match segment.value_regexp, "Hello 10 World" - assert_no_match segment.value_regexp, "Hello 10" - assert_no_match segment.value_regexp, "10 World" - assert_match segment.value_regexp, "10" - end - - def test_regexp_chunk_should_return_string - segment = segment(:regexp => /\d+/) - assert_kind_of String, segment.regexp_chunk - end - - def test_build_pattern_non_optional_with_no_captures - # Non optional - a_segment = ROUTING::DynamicSegment.new(nil, :regexp => /\d+/) - assert_equal "(\\d+)stuff", a_segment.build_pattern('stuff') - end - - def test_build_pattern_non_optional_with_captures - # Non optional - a_segment = ROUTING::DynamicSegment.new(nil, :regexp => /(\d+)(.*?)/) - assert_equal "((\\d+)(.*?))stuff", a_segment.build_pattern('stuff') - end - - def test_optionality_implied - a_segment = ROUTING::DynamicSegment.new(:id) - assert a_segment.optionality_implied? - - a_segment = ROUTING::DynamicSegment.new(:action) - assert a_segment.optionality_implied? - end - - def test_modifiers_must_be_handled_sensibly - a_segment = ROUTING::DynamicSegment.new(nil, :regexp => /david|jamis/i) - assert_equal "((?i-mx:david|jamis))stuff", a_segment.build_pattern('stuff') - a_segment = ROUTING::DynamicSegment.new(nil, :regexp => /david|jamis/x) - assert_equal "((?x-mi:david|jamis))stuff", a_segment.build_pattern('stuff') - a_segment = ROUTING::DynamicSegment.new(nil, :regexp => /david|jamis/) - assert_equal "(david|jamis)stuff", a_segment.build_pattern('stuff') - end -end - -class ControllerSegmentTest < Test::Unit::TestCase - def test_regexp_should_only_match_possible_controllers - ActionController::Routing.with_controllers %w(admin/accounts admin/users account pages) do - cs = ROUTING::ControllerSegment.new :controller - regexp = %r{\A#{cs.regexp_chunk}\Z} - - ActionController::Routing.possible_controllers.each do |name| - assert_match regexp, name - assert_no_match regexp, "#{name}_fake" - - match = regexp.match name - assert_equal name, match[1] - end - end - end -end - -class PathSegmentTest < Test::Unit::TestCase - def segment(options = {}) - unless @segment - @segment = ROUTING::PathSegment.new(:path, options) - end - @segment - end - - def test_regexp_chunk_should_return_string - segment = segment(:regexp => /[a-z]+/) - assert_kind_of String, segment.regexp_chunk - end - - def test_regexp_chunk_should_be_wrapped_with_parenthesis - segment = segment(:regexp => /[a-z]+/) - assert_equal "([a-z]+)", segment.regexp_chunk - end - - def test_regexp_chunk_should_respect_options - segment = segment(:regexp => /[a-z]+/i) - assert_equal "((?i-mx:[a-z]+))", segment.regexp_chunk - end -end - -class RouteBuilderTest < Test::Unit::TestCase - def builder - @builder ||= ROUTING::RouteBuilder.new - end - - def build(path, options) - builder.build(path, options) - end - - def test_options_should_not_be_modified - requirements1 = { :id => /\w+/, :controller => /(?:[a-z](?:-?[a-z]+)*)/ } - requirements2 = requirements1.dup - - assert_equal requirements1, requirements2 - - with_options(:controller => 'folder', - :requirements => requirements2) do |m| - m.build 'folders/new', :action => 'new' - end - - assert_equal requirements1, requirements2 - end - - def test_segment_for_static - segment, rest = builder.segment_for 'ulysses' - assert_equal '', rest - assert_kind_of ROUTING::StaticSegment, segment - assert_equal 'ulysses', segment.value - end - - def test_segment_for_action - segment, rest = builder.segment_for ':action' - assert_equal '', rest - assert_kind_of ROUTING::DynamicSegment, segment - assert_equal :action, segment.key - assert_equal 'index', segment.default - end - - def test_segment_for_dynamic - segment, rest = builder.segment_for ':login' - assert_equal '', rest - assert_kind_of ROUTING::DynamicSegment, segment - assert_equal :login, segment.key - assert_equal nil, segment.default - assert ! segment.optional? - end - - def test_segment_for_with_rest - segment, rest = builder.segment_for ':login/:action' - assert_equal :login, segment.key - assert_equal '/:action', rest - segment, rest = builder.segment_for rest - assert_equal '/', segment.value - assert_equal ':action', rest - segment, rest = builder.segment_for rest - assert_equal :action, segment.key - assert_equal '', rest - end - - def test_segments_for - segments = builder.segments_for_route_path '/:controller/:action/:id' - - assert_kind_of ROUTING::DividerSegment, segments[0] - assert_equal '/', segments[2].value - - assert_kind_of ROUTING::DynamicSegment, segments[1] - assert_equal :controller, segments[1].key - - assert_kind_of ROUTING::DividerSegment, segments[2] - assert_equal '/', segments[2].value - - assert_kind_of ROUTING::DynamicSegment, segments[3] - assert_equal :action, segments[3].key - - assert_kind_of ROUTING::DividerSegment, segments[4] - assert_equal '/', segments[4].value - - assert_kind_of ROUTING::DynamicSegment, segments[5] - assert_equal :id, segments[5].key - end - - def test_segment_for_action - s, r = builder.segment_for(':action/something/else') - assert_equal '/something/else', r - assert_equal :action, s.key - end - - def test_action_default_should_not_trigger_on_prefix - s, r = builder.segment_for ':action_name/something/else' - assert_equal '/something/else', r - assert_equal :action_name, s.key - assert_equal nil, s.default - end - - def test_divide_route_options - segments = builder.segments_for_route_path '/cars/:action/:person/:car/' - defaults, requirements = builder.divide_route_options(segments, - :action => 'buy', :person => /\w+/, :car => /\w+/, - :defaults => {:person => nil, :car => nil} - ) - - assert_equal({:action => 'buy', :person => nil, :car => nil}, defaults) - assert_equal({:person => /\w+/, :car => /\w+/}, requirements) - end - - def test_assign_route_options - segments = builder.segments_for_route_path '/cars/:action/:person/:car/' - defaults = {:action => 'buy', :person => nil, :car => nil} - requirements = {:person => /\w+/, :car => /\w+/} - - route_requirements = builder.assign_route_options(segments, defaults, requirements) - assert_equal({}, route_requirements) - - assert_equal :action, segments[3].key - assert_equal 'buy', segments[3].default - - assert_equal :person, segments[5].key - assert_equal %r/\w+/, segments[5].regexp - assert segments[5].optional? - - assert_equal :car, segments[7].key - assert_equal %r/\w+/, segments[7].regexp - assert segments[7].optional? - end - - def test_assign_route_options_with_anchor_chars - segments = builder.segments_for_route_path '/cars/:action/:person/:car/' - defaults = {:action => 'buy', :person => nil, :car => nil} - requirements = {:person => /\w+/, :car => /^\w+$/} - - assert_raise ArgumentError do - route_requirements = builder.assign_route_options(segments, defaults, requirements) - end - - requirements[:car] = /[^\/]+/ - route_requirements = builder.assign_route_options(segments, defaults, requirements) - end - - def test_optional_segments_preceding_required_segments - segments = builder.segments_for_route_path '/cars/:action/:person/:car/' - defaults = {:action => 'buy', :person => nil, :car => "model-t"} - assert builder.assign_route_options(segments, defaults, {}).empty? - - 0.upto(1) { |i| assert !segments[i].optional?, "segment #{i} is optional and it shouldn't be" } - assert segments[2].optional? - - assert_equal nil, builder.warn_output # should only warn on the :person segment - end - - def test_segmentation_of_dot_path - segments = builder.segments_for_route_path '/books/:action.rss' - assert builder.assign_route_options(segments, {}, {}).empty? - assert_equal 6, segments.length # "/", "books", "/", ":action", ".", "rss" - assert !segments.any? { |seg| seg.optional? } - end - - def test_segmentation_of_dynamic_dot_path - segments = builder.segments_for_route_path '/books/:action.:format' - assert builder.assign_route_options(segments, {}, {}).empty? - assert_equal 6, segments.length # "/", "books", "/", ":action", ".", ":format" - assert !segments.any? { |seg| seg.optional? } - assert_kind_of ROUTING::DynamicSegment, segments.last - end - - def test_assignment_of_default_options - segments = builder.segments_for_route_path '/:controller/:action/:id/' - action, id = segments[-4], segments[-2] - - assert_equal :action, action.key - assert_equal :id, id.key - assert ! action.optional? - assert ! id.optional? - - builder.assign_default_route_options(segments) - - assert_equal 'index', action.default - assert action.optional? - assert id.optional? - end - - def test_assignment_of_default_options_respects_existing_defaults - segments = builder.segments_for_route_path '/:controller/:action/:id/' - action, id = segments[-4], segments[-2] - - assert_equal :action, action.key - assert_equal :id, id.key - action.default = 'show' - action.is_optional = true - - id.default = 'Welcome' - id.is_optional = true - - builder.assign_default_route_options(segments) - - assert_equal 'show', action.default - assert action.optional? - assert_equal 'Welcome', id.default - assert id.optional? - end - - def test_assignment_of_default_options_respects_regexps - segments = builder.segments_for_route_path '/:controller/:action/:id/' - action = segments[-4] - - assert_equal :action, action.key - segments[-4] = ROUTING::DynamicSegment.new(:action, :regexp => /show|in/) - - builder.assign_default_route_options(segments) - - assert_equal nil, action.default - assert ! action.optional? - end - - def test_assignment_of_is_optional_when_default - segments = builder.segments_for_route_path '/books/:action.rss' - assert_equal segments[3].key, :action - segments[3].default = 'changes' - builder.ensure_required_segments(segments) - assert ! segments[3].optional? - end - - def test_is_optional_is_assigned_to_default_segments - segments = builder.segments_for_route_path '/books/:action' - builder.assign_route_options(segments, {:action => 'index'}, {}) - - assert_equal segments[3].key, :action - assert segments[3].optional? - assert_kind_of ROUTING::DividerSegment, segments[2] - assert segments[2].optional? - end - - # XXX is optional not being set right? - # /blah/:defaulted_segment <-- is the second slash optional? it should be. - - def test_route_build - ActionController::Routing.with_controllers %w(users pages) do - r = builder.build '/:controller/:action/:id/', :action => nil - - [0, 2, 4].each do |i| - assert_kind_of ROUTING::DividerSegment, r.segments[i] - assert_equal '/', r.segments[i].value - assert r.segments[i].optional? if i > 1 - end - - assert_kind_of ROUTING::DynamicSegment, r.segments[1] - assert_equal :controller, r.segments[1].key - assert_equal nil, r.segments[1].default - - assert_kind_of ROUTING::DynamicSegment, r.segments[3] - assert_equal :action, r.segments[3].key - assert_equal 'index', r.segments[3].default - - assert_kind_of ROUTING::DynamicSegment, r.segments[5] - assert_equal :id, r.segments[5].key - assert r.segments[5].optional? - end - end - - def test_slashes_are_implied - routes = [ - builder.build('/:controller/:action/:id/', :action => nil), - builder.build('/:controller/:action/:id', :action => nil), - builder.build(':controller/:action/:id', :action => nil), - builder.build('/:controller/:action/:id/', :action => nil) - ] - expected = routes.first.segments.length - routes.each_with_index do |route, i| - found = route.segments.length - assert_equal expected, found, "Route #{i + 1} has #{found} segments, expected #{expected}" - end - end -end - -class RoutingTest < Test::Unit::TestCase - def test_possible_controllers - true_controller_paths = ActionController::Routing.controller_paths - - ActionController::Routing.use_controllers! nil - - silence_warnings do - Object.send(:const_set, :RAILS_ROOT, File.dirname(__FILE__) + '/controller_fixtures') - end - - ActionController::Routing.controller_paths = [ - RAILS_ROOT, RAILS_ROOT + '/app/controllers', RAILS_ROOT + '/vendor/plugins/bad_plugin/lib' - ] - - assert_equal ["admin/user", "plugin", "user"], ActionController::Routing.possible_controllers.sort - ensure - if true_controller_paths - ActionController::Routing.controller_paths = true_controller_paths - end - ActionController::Routing.use_controllers! nil - Object.send(:remove_const, :RAILS_ROOT) rescue nil - end - - def test_possible_controllers_are_reset_on_each_load - true_possible_controllers = ActionController::Routing.possible_controllers - true_controller_paths = ActionController::Routing.controller_paths - - ActionController::Routing.use_controllers! nil - root = File.dirname(__FILE__) + '/controller_fixtures' - - ActionController::Routing.controller_paths = [] - assert_equal [], ActionController::Routing.possible_controllers - - ActionController::Routing.controller_paths = [ - root, root + '/app/controllers', root + '/vendor/plugins/bad_plugin/lib' - ] - ActionController::Routing::Routes.load! - - assert_equal ["admin/user", "plugin", "user"], ActionController::Routing.possible_controllers.sort - ensure - ActionController::Routing.controller_paths = true_controller_paths - ActionController::Routing.use_controllers! true_possible_controllers - Object.send(:remove_const, :RAILS_ROOT) rescue nil - - ActionController::Routing::Routes.clear! - ActionController::Routing::Routes.load_routes! - end - - def test_with_controllers - c = %w(admin/accounts admin/users account pages) - ActionController::Routing.with_controllers c do - assert_equal c, ActionController::Routing.possible_controllers - end - end - - def test_normalize_unix_paths - load_paths = %w(. config/../app/controllers config/../app//helpers script/../config/../vendor/rails/actionpack/lib vendor/rails/railties/builtin/rails_info app/models lib script/../config/../foo/bar/../../app/models .foo/../.bar foo.bar/../config) - paths = ActionController::Routing.normalize_paths(load_paths) - assert_equal %w(vendor/rails/railties/builtin/rails_info vendor/rails/actionpack/lib app/controllers app/helpers app/models config .bar lib .), paths - end - - def test_normalize_windows_paths - load_paths = %w(. config\\..\\app\\controllers config\\..\\app\\\\helpers script\\..\\config\\..\\vendor\\rails\\actionpack\\lib vendor\\rails\\railties\\builtin\\rails_info app\\models lib script\\..\\config\\..\\foo\\bar\\..\\..\\app\\models .foo\\..\\.bar foo.bar\\..\\config) - paths = ActionController::Routing.normalize_paths(load_paths) - assert_equal %w(vendor\\rails\\railties\\builtin\\rails_info vendor\\rails\\actionpack\\lib app\\controllers app\\helpers app\\models config .bar lib .), paths - end - - def test_routing_helper_module - assert_kind_of Module, ActionController::Routing::Helpers - - h = ActionController::Routing::Helpers - c = Class.new - assert ! c.ancestors.include?(h) - ActionController::Routing::Routes.install_helpers c - assert c.ancestors.include?(h) - end -end - -class MockController - attr_accessor :routes - - def initialize(routes) - self.routes = routes - end - - def url_for(options) - only_path = options.delete(:only_path) - - port = options.delete(:port) || 80 - port_string = port == 80 ? '' : ":#{port}" - - protocol = options.delete(:protocol) || "http" - host = options.delete(:host) || "test.host" - anchor = "##{options.delete(:anchor)}" if options.key?(:anchor) - - path = routes.generate(options) - - only_path ? "#{path}#{anchor}" : "#{protocol}://#{host}#{port_string}#{path}#{anchor}" - end - - def request - @request ||= ActionController::TestRequest.new - end -end - -class LegacyRouteSetTests < Test::Unit::TestCase - attr_reader :rs - - def setup - # These tests assume optimisation is on, so re-enable it. - ActionController::Base.optimise_named_routes = true - - @rs = ::ActionController::Routing::RouteSet.new - - ActionController::Routing.use_controllers! %w(content admin/user admin/news_feed) - end - - def teardown - @rs.clear! - end - - def test_default_setup - @rs.draw {|m| m.connect ':controller/:action/:id' } - assert_equal({:controller => "content", :action => 'index'}, rs.recognize_path("/content")) - assert_equal({:controller => "content", :action => 'list'}, rs.recognize_path("/content/list")) - assert_equal({:controller => "content", :action => 'show', :id => '10'}, rs.recognize_path("/content/show/10")) - - assert_equal({:controller => "admin/user", :action => 'show', :id => '10'}, rs.recognize_path("/admin/user/show/10")) - - assert_equal '/admin/user/show/10', rs.generate(:controller => 'admin/user', :action => 'show', :id => 10) - - assert_equal '/admin/user/show', rs.generate({:action => 'show'}, {:controller => 'admin/user', :action => 'list', :id => '10'}) - assert_equal '/admin/user/list/10', rs.generate({}, {:controller => 'admin/user', :action => 'list', :id => '10'}) - - assert_equal '/admin/stuff', rs.generate({:controller => 'stuff'}, {:controller => 'admin/user', :action => 'list', :id => '10'}) - assert_equal '/stuff', rs.generate({:controller => '/stuff'}, {:controller => 'admin/user', :action => 'list', :id => '10'}) - end - - def test_ignores_leading_slash - @rs.clear! - @rs.draw {|m| m.connect '/:controller/:action/:id'} - test_default_setup - end - - def test_time_recognition - # We create many routes to make situation more realistic - @rs = ::ActionController::Routing::RouteSet.new - @rs.draw { |map| - map.frontpage '', :controller => 'search', :action => 'new' - map.resources :videos do |video| - video.resources :comments - video.resource :file, :controller => 'video_file' - video.resource :share, :controller => 'video_shares' - video.resource :abuse, :controller => 'video_abuses' - end - map.resources :abuses, :controller => 'video_abuses' - map.resources :video_uploads - map.resources :video_visits - - map.resources :users do |user| - user.resource :settings - user.resources :videos - end - map.resources :channels do |channel| - channel.resources :videos, :controller => 'channel_videos' - end - map.resource :session - map.resource :lost_password - map.search 'search', :controller => 'search' - map.resources :pages - map.connect ':controller/:action/:id' - } - n = 1000 - if RunTimeTests - GC.start - rectime = Benchmark.realtime do - n.times do - rs.recognize_path("/videos/1234567", {:method => :get}) - rs.recognize_path("/videos/1234567/abuse", {:method => :get}) - rs.recognize_path("/users/1234567/settings", {:method => :get}) - rs.recognize_path("/channels/1234567", {:method => :get}) - rs.recognize_path("/session/new", {:method => :get}) - rs.recognize_path("/admin/user/show/10", {:method => :get}) - end - end - puts "\n\nRecognition (#{rs.routes.size} routes):" - per_url = rectime / (n * 6) - puts "#{per_url * 1000} ms/url" - puts "#{1 / per_url} url/s\n\n" - end - end - - def test_time_generation - n = 5000 - if RunTimeTests - GC.start - pairs = [ - [{:controller => 'content', :action => 'index'}, {:controller => 'content', :action => 'show'}], - [{:controller => 'content'}, {:controller => 'content', :action => 'index'}], - [{:controller => 'content', :action => 'list'}, {:controller => 'content', :action => 'index'}], - [{:controller => 'content', :action => 'show', :id => '10'}, {:controller => 'content', :action => 'list'}], - [{:controller => 'admin/user', :action => 'index'}, {:controller => 'admin/user', :action => 'show'}], - [{:controller => 'admin/user'}, {:controller => 'admin/user', :action => 'index'}], - [{:controller => 'admin/user', :action => 'list'}, {:controller => 'admin/user', :action => 'index'}], - [{:controller => 'admin/user', :action => 'show', :id => '10'}, {:controller => 'admin/user', :action => 'list'}], - ] - p = nil - gentime = Benchmark.realtime do - n.times do - pairs.each {|(a, b)| rs.generate(a, b)} - end - end - - puts "\n\nGeneration (RouteSet): (#{(n * 8)} urls)" - per_url = gentime / (n * 8) - puts "#{per_url * 1000} ms/url" - puts "#{1 / per_url} url/s\n\n" - end - end - - def test_route_with_colon_first - rs.draw do |map| - map.connect '/:controller/:action/:id', :action => 'index', :id => nil - map.connect ':url', :controller => 'tiny_url', :action => 'translate' - end - end - - def test_route_with_regexp_for_controller - rs.draw do |map| - map.connect ':controller/:admintoken/:action/:id', :controller => /admin\/.+/ - map.connect ':controller/:action/:id' - end - assert_equal({:controller => "admin/user", :admintoken => "foo", :action => "index"}, - rs.recognize_path("/admin/user/foo")) - assert_equal({:controller => "content", :action => "foo"}, rs.recognize_path("/content/foo")) - assert_equal '/admin/user/foo', rs.generate(:controller => "admin/user", :admintoken => "foo", :action => "index") - assert_equal '/content/foo', rs.generate(:controller => "content", :action => "foo") - end - - def test_route_with_regexp_and_captures_for_controller - rs.draw do |map| - map.connect ':controller/:action/:id', :controller => /admin\/(accounts|users)/ - end - assert_equal({:controller => "admin/accounts", :action => "index"}, rs.recognize_path("/admin/accounts")) - assert_equal({:controller => "admin/users", :action => "index"}, rs.recognize_path("/admin/users")) - assert_raise(ActionController::RoutingError) { rs.recognize_path("/admin/products") } - end - - def test_route_with_regexp_and_dot - rs.draw do |map| - map.connect ':controller/:action/:file', - :controller => /admin|user/, - :action => /upload|download/, - :defaults => {:file => nil}, - :requirements => {:file => %r{[^/]+(\.[^/]+)?}} - end - # Without a file extension - assert_equal '/user/download/file', - rs.generate(:controller => "user", :action => "download", :file => "file") - assert_equal( - {:controller => "user", :action => "download", :file => "file"}, - rs.recognize_path("/user/download/file")) - - # Now, let's try a file with an extension, really a dot (.) - assert_equal '/user/download/file.jpg', - rs.generate( - :controller => "user", :action => "download", :file => "file.jpg") - assert_equal( - {:controller => "user", :action => "download", :file => "file.jpg"}, - rs.recognize_path("/user/download/file.jpg")) - end - - def test_basic_named_route - rs.add_named_route :home, '', :controller => 'content', :action => 'list' - x = setup_for_named_route - assert_equal("http://test.host/", - x.send(:home_url)) - end - - def test_basic_named_route_with_relative_url_root - rs.add_named_route :home, '', :controller => 'content', :action => 'list' - x = setup_for_named_route - ActionController::Base.relative_url_root = "/foo" - assert_equal("http://test.host/foo/", - x.send(:home_url)) - assert_equal "/foo/", x.send(:home_path) - ActionController::Base.relative_url_root = nil - end - - def test_named_route_with_option - rs.add_named_route :page, 'page/:title', :controller => 'content', :action => 'show_page' - x = setup_for_named_route - assert_equal("http://test.host/page/new%20stuff", - x.send(:page_url, :title => 'new stuff')) - end - - def test_named_route_with_default - rs.add_named_route :page, 'page/:title', :controller => 'content', :action => 'show_page', :title => 'AboutPage' - x = setup_for_named_route - assert_equal("http://test.host/page/AboutRails", - x.send(:page_url, :title => "AboutRails")) - - end - - def test_named_route_with_name_prefix - rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :name_prefix => 'my_' - x = setup_for_named_route - assert_equal("http://test.host/page", - x.send(:my_page_url)) - end - - def test_named_route_with_path_prefix - rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :path_prefix => 'my' - x = setup_for_named_route - assert_equal("http://test.host/my/page", - x.send(:page_url)) - end - - def test_named_route_with_blank_path_prefix - rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :path_prefix => '' - x = setup_for_named_route - assert_equal("http://test.host/page", - x.send(:page_url)) - end - - def test_named_route_with_nested_controller - rs.add_named_route :users, 'admin/user', :controller => 'admin/user', :action => 'index' - x = setup_for_named_route - assert_equal("http://test.host/admin/user", - x.send(:users_url)) - end - - def test_optimised_named_route_call_never_uses_url_for - rs.add_named_route :users, 'admin/user', :controller => '/admin/user', :action => 'index' - rs.add_named_route :user, 'admin/user/:id', :controller=>'/admin/user', :action=>'show' - x = setup_for_named_route - x.expects(:url_for).never - x.send(:users_url) - x.send(:users_path) - x.send(:user_url, 2, :foo=>"bar") - x.send(:user_path, 3, :bar=>"foo") - end - - def test_optimised_named_route_with_host - rs.add_named_route :pages, 'pages', :controller => 'content', :action => 'show_page', :host => 'foo.com' - x = setup_for_named_route - x.expects(:url_for).with(:host => 'foo.com', :only_path => false, :controller => 'content', :action => 'show_page', :use_route => :pages).once - x.send(:pages_url) - end - - def setup_for_named_route - klass = Class.new(MockController) - rs.install_helpers(klass) - klass.new(rs) - end - - def test_named_route_without_hash - rs.draw do |map| - map.normal ':controller/:action/:id' - end - end - - def test_named_route_root - rs.draw do |map| - map.root :controller => "hello" - end - x = setup_for_named_route - assert_equal("http://test.host/", x.send(:root_url)) - assert_equal("/", x.send(:root_path)) - end - - def test_named_route_with_regexps - rs.draw do |map| - map.article 'page/:year/:month/:day/:title', :controller => 'page', :action => 'show', - :year => /\d+/, :month => /\d+/, :day => /\d+/ - map.connect ':controller/:action/:id' - end - x = setup_for_named_route - # assert_equal( - # {:controller => 'page', :action => 'show', :title => 'hi', :use_route => :article, :only_path => false}, - # x.send(:article_url, :title => 'hi') - # ) - assert_equal( - "http://test.host/page/2005/6/10/hi", - x.send(:article_url, :title => 'hi', :day => 10, :year => 2005, :month => 6) - ) - end - - def test_changing_controller - @rs.draw {|m| m.connect ':controller/:action/:id' } - - assert_equal '/admin/stuff/show/10', rs.generate( - {:controller => 'stuff', :action => 'show', :id => 10}, - {:controller => 'admin/user', :action => 'index'} - ) - end - - def test_paths_escaped - rs.draw do |map| - map.path 'file/*path', :controller => 'content', :action => 'show_file' - map.connect ':controller/:action/:id' - end - - # No + to space in URI escaping, only for query params. - results = rs.recognize_path "/file/hello+world/how+are+you%3F" - assert results, "Recognition should have succeeded" - assert_equal ['hello+world', 'how+are+you?'], results[:path] - - # Use %20 for space instead. - results = rs.recognize_path "/file/hello%20world/how%20are%20you%3F" - assert results, "Recognition should have succeeded" - assert_equal ['hello world', 'how are you?'], results[:path] - - results = rs.recognize_path "/file" - assert results, "Recognition should have succeeded" - assert_equal [], results[:path] - end - - def test_paths_slashes_unescaped_with_ordered_parameters - rs.add_named_route :path, '/file/*path', :controller => 'content' - - # No / to %2F in URI, only for query params. - x = setup_for_named_route - assert_equal("/file/hello/world", x.send(:path_path, 'hello/world')) - end - - def test_non_controllers_cannot_be_matched - rs.draw do |map| - map.connect ':controller/:action/:id' - end - assert_raise(ActionController::RoutingError) { rs.recognize_path("/not_a/show/10") } - end - - def test_paths_do_not_accept_defaults - assert_raise(ActionController::RoutingError) do - rs.draw do |map| - map.path 'file/*path', :controller => 'content', :action => 'show_file', :path => %w(fake default) - map.connect ':controller/:action/:id' - end - end - - rs.draw do |map| - map.path 'file/*path', :controller => 'content', :action => 'show_file', :path => [] - map.connect ':controller/:action/:id' - end - end - - def test_should_list_options_diff_when_routing_requirements_dont_match - rs.draw do |map| - map.post 'post/:id', :controller=> 'post', :action=> 'show', :requirements => {:id => /\d+/} - end - exception = assert_raise(ActionController::RoutingError) { rs.generate(:controller => 'post', :action => 'show', :bad_param => "foo", :use_route => "post") } - assert_match /^post_url failed to generate/, exception.message - from_match = exception.message.match(/from \{[^\}]+\}/).to_s - assert_match /:bad_param=>"foo"/, from_match - assert_match /:action=>"show"/, from_match - assert_match /:controller=>"post"/, from_match - - expected_match = exception.message.match(/expected: \{[^\}]+\}/).to_s - assert_no_match /:bad_param=>"foo"/, expected_match - assert_match /:action=>"show"/, expected_match - assert_match /:controller=>"post"/, expected_match - - diff_match = exception.message.match(/diff: \{[^\}]+\}/).to_s - assert_match /:bad_param=>"foo"/, diff_match - assert_no_match /:action=>"show"/, diff_match - assert_no_match /:controller=>"post"/, diff_match - end - - # this specifies the case where your formerly would get a very confusing error message with an empty diff - def test_should_have_better_error_message_when_options_diff_is_empty - rs.draw do |map| - map.content '/content/:query', :controller => 'content', :action => 'show' - end - - exception = assert_raise(ActionController::RoutingError) { rs.generate(:controller => 'content', :action => 'show', :use_route => "content") } - assert_match %r[:action=>"show"], exception.message - assert_match %r[:controller=>"content"], exception.message - assert_match %r[you may have ambiguous routes, or you may need to supply additional parameters for this route], exception.message - assert_match %r[content_url has the following required parameters: \["content", :query\] - are they all satisfied?], exception.message - end - - def test_dynamic_path_allowed - rs.draw do |map| - map.connect '*path', :controller => 'content', :action => 'show_file' - end - - assert_equal '/pages/boo', rs.generate(:controller => 'content', :action => 'show_file', :path => %w(pages boo)) - end - - def test_dynamic_recall_paths_allowed - rs.draw do |map| - map.connect '*path', :controller => 'content', :action => 'show_file' - end - - recall_path = ActionController::Routing::PathSegment::Result.new(%w(pages boo)) - assert_equal '/pages/boo', rs.generate({}, :controller => 'content', :action => 'show_file', :path => recall_path) - end - - def test_backwards - rs.draw do |map| - map.connect 'page/:id/:action', :controller => 'pages', :action => 'show' - map.connect ':controller/:action/:id' - end - - assert_equal '/page/20', rs.generate({:id => 20}, {:controller => 'pages', :action => 'show'}) - assert_equal '/page/20', rs.generate(:controller => 'pages', :id => 20, :action => 'show') - assert_equal '/pages/boo', rs.generate(:controller => 'pages', :action => 'boo') - end - - def test_route_with_fixnum_default - rs.draw do |map| - map.connect 'page/:id', :controller => 'content', :action => 'show_page', :id => 1 - map.connect ':controller/:action/:id' - end - - assert_equal '/page', rs.generate(:controller => 'content', :action => 'show_page') - assert_equal '/page', rs.generate(:controller => 'content', :action => 'show_page', :id => 1) - assert_equal '/page', rs.generate(:controller => 'content', :action => 'show_page', :id => '1') - assert_equal '/page/10', rs.generate(:controller => 'content', :action => 'show_page', :id => 10) - - assert_equal({:controller => "content", :action => 'show_page', :id => '1'}, rs.recognize_path("/page")) - assert_equal({:controller => "content", :action => 'show_page', :id => '1'}, rs.recognize_path("/page/1")) - assert_equal({:controller => "content", :action => 'show_page', :id => '10'}, rs.recognize_path("/page/10")) - end - - # For newer revision - def test_route_with_text_default - rs.draw do |map| - map.connect 'page/:id', :controller => 'content', :action => 'show_page', :id => 1 - map.connect ':controller/:action/:id' - end - - assert_equal '/page/foo', rs.generate(:controller => 'content', :action => 'show_page', :id => 'foo') - assert_equal({:controller => "content", :action => 'show_page', :id => 'foo'}, rs.recognize_path("/page/foo")) - - token = "\321\202\320\265\320\272\321\201\321\202" # 'text' in russian - token.force_encoding("UTF-8") if token.respond_to?(:force_encoding) - escaped_token = CGI::escape(token) - - assert_equal '/page/' + escaped_token, rs.generate(:controller => 'content', :action => 'show_page', :id => token) - assert_equal({:controller => "content", :action => 'show_page', :id => token}, rs.recognize_path("/page/#{escaped_token}")) - end - - def test_action_expiry - @rs.draw {|m| m.connect ':controller/:action/:id' } - assert_equal '/content', rs.generate({:controller => 'content'}, {:controller => 'content', :action => 'show'}) - end - - def test_recognition_with_uppercase_controller_name - @rs.draw {|m| m.connect ':controller/:action/:id' } - assert_equal({:controller => "content", :action => 'index'}, rs.recognize_path("/Content")) - assert_equal({:controller => "content", :action => 'list'}, rs.recognize_path("/ConTent/list")) - assert_equal({:controller => "content", :action => 'show', :id => '10'}, rs.recognize_path("/CONTENT/show/10")) - - # these used to work, before the routes rewrite, but support for this was pulled in the new version... - #assert_equal({'controller' => "admin/news_feed", 'action' => 'index'}, rs.recognize_path("Admin/NewsFeed")) - #assert_equal({'controller' => "admin/news_feed", 'action' => 'index'}, rs.recognize_path("Admin/News_Feed")) - end - - def test_requirement_should_prevent_optional_id - rs.draw do |map| - map.post 'post/:id', :controller=> 'post', :action=> 'show', :requirements => {:id => /\d+/} - end - - assert_equal '/post/10', rs.generate(:controller => 'post', :action => 'show', :id => 10) - - assert_raise ActionController::RoutingError do - rs.generate(:controller => 'post', :action => 'show') - end - end - - def test_both_requirement_and_optional - rs.draw do |map| - map.blog('test/:year', :controller => 'post', :action => 'show', - :defaults => { :year => nil }, - :requirements => { :year => /\d{4}/ } - ) - map.connect ':controller/:action/:id' - end - - assert_equal '/test', rs.generate(:controller => 'post', :action => 'show') - assert_equal '/test', rs.generate(:controller => 'post', :action => 'show', :year => nil) - - x = setup_for_named_route - assert_equal("http://test.host/test", - x.send(:blog_url)) - end - - def test_set_to_nil_forgets - rs.draw do |map| - map.connect 'pages/:year/:month/:day', :controller => 'content', :action => 'list_pages', :month => nil, :day => nil - map.connect ':controller/:action/:id' - end - - assert_equal '/pages/2005', - rs.generate(:controller => 'content', :action => 'list_pages', :year => 2005) - assert_equal '/pages/2005/6', - rs.generate(:controller => 'content', :action => 'list_pages', :year => 2005, :month => 6) - assert_equal '/pages/2005/6/12', - rs.generate(:controller => 'content', :action => 'list_pages', :year => 2005, :month => 6, :day => 12) - - assert_equal '/pages/2005/6/4', - rs.generate({:day => 4}, {:controller => 'content', :action => 'list_pages', :year => '2005', :month => '6', :day => '12'}) - - assert_equal '/pages/2005/6', - rs.generate({:day => nil}, {:controller => 'content', :action => 'list_pages', :year => '2005', :month => '6', :day => '12'}) - - assert_equal '/pages/2005', - rs.generate({:day => nil, :month => nil}, {:controller => 'content', :action => 'list_pages', :year => '2005', :month => '6', :day => '12'}) - end - - def test_url_with_no_action_specified - rs.draw do |map| - map.connect '', :controller => 'content' - map.connect ':controller/:action/:id' - end - - assert_equal '/', rs.generate(:controller => 'content', :action => 'index') - assert_equal '/', rs.generate(:controller => 'content') - end - - def test_named_url_with_no_action_specified - rs.draw do |map| - map.home '', :controller => 'content' - map.connect ':controller/:action/:id' - end - - assert_equal '/', rs.generate(:controller => 'content', :action => 'index') - assert_equal '/', rs.generate(:controller => 'content') - - x = setup_for_named_route - assert_equal("http://test.host/", - x.send(:home_url)) - end - - def test_url_generated_when_forgetting_action - [{:controller => 'content', :action => 'index'}, {:controller => 'content'}].each do |hash| - rs.draw do |map| - map.home '', hash - map.connect ':controller/:action/:id' - end - assert_equal '/', rs.generate({:action => nil}, {:controller => 'content', :action => 'hello'}) - assert_equal '/', rs.generate({:controller => 'content'}) - assert_equal '/content/hi', rs.generate({:controller => 'content', :action => 'hi'}) - end - end - - def test_named_route_method - rs.draw do |map| - map.categories 'categories', :controller => 'content', :action => 'categories' - map.connect ':controller/:action/:id' - end - - assert_equal '/categories', rs.generate(:controller => 'content', :action => 'categories') - assert_equal '/content/hi', rs.generate({:controller => 'content', :action => 'hi'}) - end - - def test_named_routes_array - test_named_route_method - assert_equal [:categories], rs.named_routes.names - end - - def test_nil_defaults - rs.draw do |map| - map.connect 'journal', - :controller => 'content', - :action => 'list_journal', - :date => nil, :user_id => nil - map.connect ':controller/:action/:id' - end - - assert_equal '/journal', rs.generate(:controller => 'content', :action => 'list_journal', :date => nil, :user_id => nil) - end - - def setup_request_method_routes_for(method) - @request = ActionController::TestRequest.new - @request.env["REQUEST_METHOD"] = method - @request.request_uri = "/match" - - rs.draw do |r| - r.connect '/match', :controller => 'books', :action => 'get', :conditions => { :method => :get } - r.connect '/match', :controller => 'books', :action => 'post', :conditions => { :method => :post } - r.connect '/match', :controller => 'books', :action => 'put', :conditions => { :method => :put } - r.connect '/match', :controller => 'books', :action => 'delete', :conditions => { :method => :delete } - end - end - - %w(GET POST PUT DELETE).each do |request_method| - define_method("test_request_method_recognized_with_#{request_method}") do - begin - Object.const_set(:BooksController, Class.new(ActionController::Base)) - - setup_request_method_routes_for(request_method) - - assert_nothing_raised { rs.recognize(@request) } - assert_equal request_method.downcase, @request.path_parameters[:action] - ensure - Object.send(:remove_const, :BooksController) rescue nil - end - end - end - - def test_recognize_array_of_methods - Object.const_set(:BooksController, Class.new(ActionController::Base)) - rs.draw do |r| - r.connect '/match', :controller => 'books', :action => 'get_or_post', :conditions => { :method => [:get, :post] } - r.connect '/match', :controller => 'books', :action => 'not_get_or_post' - end - - @request = ActionController::TestRequest.new - @request.env["REQUEST_METHOD"] = 'POST' - @request.request_uri = "/match" - assert_nothing_raised { rs.recognize(@request) } - assert_equal 'get_or_post', @request.path_parameters[:action] - - # have to recreate or else the RouteSet uses a cached version: - @request = ActionController::TestRequest.new - @request.env["REQUEST_METHOD"] = 'PUT' - @request.request_uri = "/match" - assert_nothing_raised { rs.recognize(@request) } - assert_equal 'not_get_or_post', @request.path_parameters[:action] - ensure - Object.send(:remove_const, :BooksController) rescue nil - end - - def test_subpath_recognized - Object.const_set(:SubpathBooksController, Class.new(ActionController::Base)) - - rs.draw do |r| - r.connect '/books/:id/edit', :controller => 'subpath_books', :action => 'edit' - r.connect '/items/:id/:action', :controller => 'subpath_books' - r.connect '/posts/new/:action', :controller => 'subpath_books' - r.connect '/posts/:id', :controller => 'subpath_books', :action => "show" - end - - hash = rs.recognize_path "/books/17/edit" - assert_not_nil hash - assert_equal %w(subpath_books 17 edit), [hash[:controller], hash[:id], hash[:action]] - - hash = rs.recognize_path "/items/3/complete" - assert_not_nil hash - assert_equal %w(subpath_books 3 complete), [hash[:controller], hash[:id], hash[:action]] - - hash = rs.recognize_path "/posts/new/preview" - assert_not_nil hash - assert_equal %w(subpath_books preview), [hash[:controller], hash[:action]] - - hash = rs.recognize_path "/posts/7" - assert_not_nil hash - assert_equal %w(subpath_books show 7), [hash[:controller], hash[:action], hash[:id]] - ensure - Object.send(:remove_const, :SubpathBooksController) rescue nil - end - - def test_subpath_generated - Object.const_set(:SubpathBooksController, Class.new(ActionController::Base)) - - rs.draw do |r| - r.connect '/books/:id/edit', :controller => 'subpath_books', :action => 'edit' - r.connect '/items/:id/:action', :controller => 'subpath_books' - r.connect '/posts/new/:action', :controller => 'subpath_books' - end - - assert_equal "/books/7/edit", rs.generate(:controller => "subpath_books", :id => 7, :action => "edit") - assert_equal "/items/15/complete", rs.generate(:controller => "subpath_books", :id => 15, :action => "complete") - assert_equal "/posts/new/preview", rs.generate(:controller => "subpath_books", :action => "preview") - ensure - Object.send(:remove_const, :SubpathBooksController) rescue nil - end - - def test_failed_requirements_raises_exception_with_violated_requirements - rs.draw do |r| - r.foo_with_requirement 'foos/:id', :controller=>'foos', :requirements=>{:id=>/\d+/} - end - - x = setup_for_named_route - assert_raise(ActionController::RoutingError) do - x.send(:foo_with_requirement_url, "I am Against the requirements") - end - end - - def test_routes_changed_correctly_after_clear - ActionController::Base.optimise_named_routes = true - rs = ::ActionController::Routing::RouteSet.new - rs.draw do |r| - r.connect 'ca', :controller => 'ca', :action => "aa" - r.connect 'cb', :controller => 'cb', :action => "ab" - r.connect 'cc', :controller => 'cc', :action => "ac" - r.connect ':controller/:action/:id' - r.connect ':controller/:action/:id.:format' - end - - hash = rs.recognize_path "/cc" - - assert_not_nil hash - assert_equal %w(cc ac), [hash[:controller], hash[:action]] - - rs.draw do |r| - r.connect 'cb', :controller => 'cb', :action => "ab" - r.connect 'cc', :controller => 'cc', :action => "ac" - r.connect ':controller/:action/:id' - r.connect ':controller/:action/:id.:format' - end - - hash = rs.recognize_path "/cc" - - assert_not_nil hash - assert_equal %w(cc ac), [hash[:controller], hash[:action]] - - end -end - -class RouteTest < Test::Unit::TestCase - def setup - @route = ROUTING::Route.new - end - - def slash_segment(is_optional = false) - ROUTING::DividerSegment.new('/', :optional => is_optional) - end - - def default_route - unless defined?(@default_route) - segments = [] - segments << ROUTING::StaticSegment.new('/', :raw => true) - segments << ROUTING::DynamicSegment.new(:controller) - segments << slash_segment(:optional) - segments << ROUTING::DynamicSegment.new(:action, :default => 'index', :optional => true) - segments << slash_segment(:optional) - segments << ROUTING::DynamicSegment.new(:id, :optional => true) - segments << slash_segment(:optional) - @default_route = ROUTING::Route.new(segments).freeze - end - @default_route - end - - def test_default_route_recognition - expected = {:controller => 'accounts', :action => 'show', :id => '10'} - assert_equal expected, default_route.recognize('/accounts/show/10') - assert_equal expected, default_route.recognize('/accounts/show/10/') - - expected[:id] = 'jamis' - assert_equal expected, default_route.recognize('/accounts/show/jamis/') - - expected.delete :id - assert_equal expected, default_route.recognize('/accounts/show') - assert_equal expected, default_route.recognize('/accounts/show/') - - expected[:action] = 'index' - assert_equal expected, default_route.recognize('/accounts/') - assert_equal expected, default_route.recognize('/accounts') - - assert_equal nil, default_route.recognize('/') - assert_equal nil, default_route.recognize('/accounts/how/goood/it/is/to/be/free') - end - - def test_default_route_should_omit_default_action - o = {:controller => 'accounts', :action => 'index'} - assert_equal '/accounts', default_route.generate(o, o, {}) - end - - def test_default_route_should_include_default_action_when_id_present - o = {:controller => 'accounts', :action => 'index', :id => '20'} - assert_equal '/accounts/index/20', default_route.generate(o, o, {}) - end - - def test_default_route_should_work_with_action_but_no_id - o = {:controller => 'accounts', :action => 'list_all'} - assert_equal '/accounts/list_all', default_route.generate(o, o, {}) - end - - def test_default_route_should_uri_escape_pluses - expected = { :controller => 'accounts', :action => 'show', :id => 'hello world' } - assert_equal expected, default_route.recognize('/accounts/show/hello world') - assert_equal expected, default_route.recognize('/accounts/show/hello%20world') - assert_equal '/accounts/show/hello%20world', default_route.generate(expected, expected, {}) - - expected[:id] = 'hello+world' - assert_equal expected, default_route.recognize('/accounts/show/hello+world') - assert_equal expected, default_route.recognize('/accounts/show/hello%2Bworld') - assert_equal '/accounts/show/hello+world', default_route.generate(expected, expected, {}) - end - - def test_matches_controller_and_action - # requirement_for should only be called for the action and controller _once_ - @route.expects(:requirement_for).with(:controller).times(1).returns('pages') - @route.expects(:requirement_for).with(:action).times(1).returns('show') - - @route.requirements = {:controller => 'pages', :action => 'show'} - assert @route.matches_controller_and_action?('pages', 'show') - assert !@route.matches_controller_and_action?('not_pages', 'show') - assert !@route.matches_controller_and_action?('pages', 'not_show') - end - - def test_parameter_shell - page_url = ROUTING::Route.new - page_url.requirements = {:controller => 'pages', :action => 'show', :id => /\d+/} - assert_equal({:controller => 'pages', :action => 'show'}, page_url.parameter_shell) - end - - def test_defaults - route = ROUTING::RouteBuilder.new.build '/users/:id.:format', :controller => "users", :action => "show", :format => "html" - assert_equal( - { :controller => "users", :action => "show", :format => "html" }, - route.defaults) - end - - def test_builder_complains_without_controller - assert_raise(ArgumentError) do - ROUTING::RouteBuilder.new.build '/contact', :contoller => "contact", :action => "index" - end - end - - def test_significant_keys_for_default_route - keys = default_route.significant_keys.sort_by {|k| k.to_s } - assert_equal [:action, :controller, :id], keys - end - - def test_significant_keys - segments = [] - segments << ROUTING::StaticSegment.new('/', :raw => true) - segments << ROUTING::StaticSegment.new('user') - segments << ROUTING::StaticSegment.new('/', :raw => true, :optional => true) - segments << ROUTING::DynamicSegment.new(:user) - segments << ROUTING::StaticSegment.new('/', :raw => true, :optional => true) - - requirements = {:controller => 'users', :action => 'show'} - - user_url = ROUTING::Route.new(segments, requirements) - keys = user_url.significant_keys.sort_by { |k| k.to_s } - assert_equal [:action, :controller, :user], keys - end - - def test_build_empty_query_string - assert_equal '', @route.build_query_string({}) - end - - def test_build_query_string_with_nil_value - assert_equal '', @route.build_query_string({:x => nil}) - end - - def test_simple_build_query_string - assert_equal '?x=1&y=2', order_query_string(@route.build_query_string(:x => '1', :y => '2')) - end - - def test_convert_ints_build_query_string - assert_equal '?x=1&y=2', order_query_string(@route.build_query_string(:x => 1, :y => 2)) - end - - def test_escape_spaces_build_query_string - assert_equal '?x=hello+world&y=goodbye+world', order_query_string(@route.build_query_string(:x => 'hello world', :y => 'goodbye world')) - end - - def test_expand_array_build_query_string - assert_equal '?x%5B%5D=1&x%5B%5D=2', order_query_string(@route.build_query_string(:x => [1, 2])) - end - - def test_escape_spaces_build_query_string_selected_keys - assert_equal '?x=hello+world', order_query_string(@route.build_query_string({:x => 'hello world', :y => 'goodbye world'}, [:x])) - end - - private - def order_query_string(qs) - '?' + qs[1..-1].split('&').sort.join('&') - end -end - -class RouteSetTest < Test::Unit::TestCase - def set - @set ||= ROUTING::RouteSet.new - end - - def request - @request ||= ActionController::TestRequest.new - end - - def test_generate_extras - set.draw { |m| m.connect ':controller/:action/:id' } - path, extras = set.generate_extras(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world") - assert_equal "/foo/bar/15", path - assert_equal %w(that this), extras.map(&:to_s).sort - end - - def test_extra_keys - set.draw { |m| m.connect ':controller/:action/:id' } - extras = set.extra_keys(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world") - assert_equal %w(that this), extras.map(&:to_s).sort - end - - def test_generate_extras_not_first - set.draw do |map| - map.connect ':controller/:action/:id.:format' - map.connect ':controller/:action/:id' - end - path, extras = set.generate_extras(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world") - assert_equal "/foo/bar/15", path - assert_equal %w(that this), extras.map(&:to_s).sort - end - - def test_generate_not_first - set.draw do |map| - map.connect ':controller/:action/:id.:format' - map.connect ':controller/:action/:id' - end - assert_equal "/foo/bar/15?this=hello", set.generate(:controller => "foo", :action => "bar", :id => 15, :this => "hello") - end - - def test_extra_keys_not_first - set.draw do |map| - map.connect ':controller/:action/:id.:format' - map.connect ':controller/:action/:id' - end - extras = set.extra_keys(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world") - assert_equal %w(that this), extras.map(&:to_s).sort - end - - def test_draw - assert_equal 0, set.routes.size - set.draw do |map| - map.connect '/hello/world', :controller => 'a', :action => 'b' - end - assert_equal 1, set.routes.size - end - - def test_named_draw - assert_equal 0, set.routes.size - set.draw do |map| - map.hello '/hello/world', :controller => 'a', :action => 'b' - end - assert_equal 1, set.routes.size - assert_equal set.routes.first, set.named_routes[:hello] - end - - def test_later_named_routes_take_precedence - set.draw do |map| - map.hello '/hello/world', :controller => 'a', :action => 'b' - map.hello '/hello', :controller => 'a', :action => 'b' - end - assert_equal set.routes.last, set.named_routes[:hello] - end - - def setup_named_route_test - set.draw do |map| - map.show '/people/:id', :controller => 'people', :action => 'show' - map.index '/people', :controller => 'people', :action => 'index' - map.multi '/people/go/:foo/:bar/joe/:id', :controller => 'people', :action => 'multi' - map.users '/admin/users', :controller => 'admin/users', :action => 'index' - end - - klass = Class.new(MockController) - set.install_helpers(klass) - klass.new(set) - end - - def test_named_route_hash_access_method - controller = setup_named_route_test - - assert_equal( - { :controller => 'people', :action => 'show', :id => 5, :use_route => :show, :only_path => false }, - controller.send(:hash_for_show_url, :id => 5)) - - assert_equal( - { :controller => 'people', :action => 'index', :use_route => :index, :only_path => false }, - controller.send(:hash_for_index_url)) - - assert_equal( - { :controller => 'people', :action => 'show', :id => 5, :use_route => :show, :only_path => true }, - controller.send(:hash_for_show_path, :id => 5) - ) - end - - def test_named_route_url_method - controller = setup_named_route_test - - assert_equal "http://test.host/people/5", controller.send(:show_url, :id => 5) - assert_equal "/people/5", controller.send(:show_path, :id => 5) - - assert_equal "http://test.host/people", controller.send(:index_url) - assert_equal "/people", controller.send(:index_path) - - assert_equal "http://test.host/admin/users", controller.send(:users_url) - assert_equal '/admin/users', controller.send(:users_path) - assert_equal '/admin/users', set.generate(controller.send(:hash_for_users_url), {:controller => 'users', :action => 'index'}) - end - - def test_named_route_url_method_with_anchor - controller = setup_named_route_test - - assert_equal "http://test.host/people/5#location", controller.send(:show_url, :id => 5, :anchor => 'location') - assert_equal "/people/5#location", controller.send(:show_path, :id => 5, :anchor => 'location') - - assert_equal "http://test.host/people#location", controller.send(:index_url, :anchor => 'location') - assert_equal "/people#location", controller.send(:index_path, :anchor => 'location') - - assert_equal "http://test.host/admin/users#location", controller.send(:users_url, :anchor => 'location') - assert_equal '/admin/users#location', controller.send(:users_path, :anchor => 'location') - - assert_equal "http://test.host/people/go/7/hello/joe/5#location", - controller.send(:multi_url, 7, "hello", 5, :anchor => 'location') - - assert_equal "http://test.host/people/go/7/hello/joe/5?baz=bar#location", - controller.send(:multi_url, 7, "hello", 5, :baz => "bar", :anchor => 'location') - - assert_equal "http://test.host/people?baz=bar#location", - controller.send(:index_url, :baz => "bar", :anchor => 'location') - end - - def test_named_route_url_method_with_port - controller = setup_named_route_test - assert_equal "http://test.host:8080/people/5", controller.send(:show_url, 5, :port=>8080) - end - - def test_named_route_url_method_with_host - controller = setup_named_route_test - assert_equal "http://some.example.com/people/5", controller.send(:show_url, 5, :host=>"some.example.com") - end - - def test_named_route_url_method_with_protocol - controller = setup_named_route_test - assert_equal "https://test.host/people/5", controller.send(:show_url, 5, :protocol => "https") - end - - def test_named_route_url_method_with_ordered_parameters - controller = setup_named_route_test - assert_equal "http://test.host/people/go/7/hello/joe/5", - controller.send(:multi_url, 7, "hello", 5) - end - - def test_named_route_url_method_with_ordered_parameters_and_hash - controller = setup_named_route_test - assert_equal "http://test.host/people/go/7/hello/joe/5?baz=bar", - controller.send(:multi_url, 7, "hello", 5, :baz => "bar") - end - - def test_named_route_url_method_with_ordered_parameters_and_empty_hash - controller = setup_named_route_test - assert_equal "http://test.host/people/go/7/hello/joe/5", - controller.send(:multi_url, 7, "hello", 5, {}) - end - - def test_named_route_url_method_with_no_positional_arguments - controller = setup_named_route_test - assert_equal "http://test.host/people?baz=bar", - controller.send(:index_url, :baz => "bar") - end - - def test_draw_default_route - ActionController::Routing.with_controllers(['users']) do - set.draw do |map| - map.connect '/:controller/:action/:id' - end - - assert_equal 1, set.routes.size - route = set.routes.first - - assert route.segments.last.optional? - - assert_equal '/users/show/10', set.generate(:controller => 'users', :action => 'show', :id => 10) - assert_equal '/users/index/10', set.generate(:controller => 'users', :id => 10) - - assert_equal({:controller => 'users', :action => 'index', :id => '10'}, set.recognize_path('/users/index/10')) - assert_equal({:controller => 'users', :action => 'index', :id => '10'}, set.recognize_path('/users/index/10/')) - end - end - - def test_draw_default_route_with_default_controller - ActionController::Routing.with_controllers(['users']) do - set.draw do |map| - map.connect '/:controller/:action/:id', :controller => 'users' - end - assert_equal({:controller => 'users', :action => 'index'}, set.recognize_path('/')) - end - end - - def test_route_with_parameter_shell - ActionController::Routing.with_controllers(['users', 'pages']) do - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+/ - map.connect '/:controller/:action/:id' - end - - assert_equal({:controller => 'pages', :action => 'index'}, set.recognize_path('/pages')) - assert_equal({:controller => 'pages', :action => 'index'}, set.recognize_path('/pages/index')) - assert_equal({:controller => 'pages', :action => 'list'}, set.recognize_path('/pages/list')) - - assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/pages/show/10')) - assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/page/10')) - end - end - - def test_route_requirements_with_anchor_chars_are_invalid - assert_raise ArgumentError do - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /^\d+/ - end - end - assert_raise ArgumentError do - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\A\d+/ - end - end - assert_raise ArgumentError do - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+$/ - end - end - assert_raise ArgumentError do - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+\Z/ - end - end - assert_raise ArgumentError do - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+\z/ - end - end - assert_nothing_raised do - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /\d+/, :name => /^(david|jamis)/ - end - assert_raise ActionController::RoutingError do - set.generate :controller => 'pages', :action => 'show', :id => 10 - end - end - end - - def test_route_requirements_with_invalid_http_method_is_invalid - assert_raise ArgumentError do - set.draw do |map| - map.connect 'valid/route', :controller => 'pages', :action => 'show', :conditions => {:method => :invalid} - end - end - end - - def test_route_requirements_with_options_method_condition_is_valid - assert_nothing_raised do - set.draw do |map| - map.connect 'valid/route', :controller => 'pages', :action => 'show', :conditions => {:method => :options} - end - end - end - - def test_route_requirements_with_head_method_condition_is_invalid - assert_raise ArgumentError do - set.draw do |map| - map.connect 'valid/route', :controller => 'pages', :action => 'show', :conditions => {:method => :head} - end - end - end - - def test_non_path_route_requirements_match_all - set.draw do |map| - map.connect 'page/37s', :controller => 'pages', :action => 'show', :name => /(jamis|david)/ - end - assert_equal '/page/37s', set.generate(:controller => 'pages', :action => 'show', :name => 'jamis') - assert_raise ActionController::RoutingError do - set.generate(:controller => 'pages', :action => 'show', :name => 'not_jamis') - end - assert_raise ActionController::RoutingError do - set.generate(:controller => 'pages', :action => 'show', :name => 'nor_jamis_and_david') - end - end - - def test_recognize_with_encoded_id_and_regex - set.draw do |map| - map.connect 'page/:id', :controller => 'pages', :action => 'show', :id => /[a-zA-Z0-9\+]+/ - end - - assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/page/10')) - assert_equal({:controller => 'pages', :action => 'show', :id => 'hello+world'}, set.recognize_path('/page/hello+world')) - end - - def test_recognize_with_conditions - Object.const_set(:PeopleController, Class.new) - - set.draw do |map| - map.with_options(:controller => "people") do |people| - people.people "/people", :action => "index", :conditions => { :method => :get } - people.connect "/people", :action => "create", :conditions => { :method => :post } - people.person "/people/:id", :action => "show", :conditions => { :method => :get } - people.connect "/people/:id", :action => "update", :conditions => { :method => :put } - people.connect "/people/:id", :action => "destroy", :conditions => { :method => :delete } - end - end - - request.path = "/people" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("index", request.path_parameters[:action]) - request.recycle! - - request.env["REQUEST_METHOD"] = "POST" - assert_nothing_raised { set.recognize(request) } - assert_equal("create", request.path_parameters[:action]) - request.recycle! - - request.env["REQUEST_METHOD"] = "PUT" - assert_nothing_raised { set.recognize(request) } - assert_equal("update", request.path_parameters[:action]) - request.recycle! - - assert_raise(ActionController::UnknownHttpMethod) { - request.env["REQUEST_METHOD"] = "BACON" - set.recognize(request) - } - request.recycle! - - request.path = "/people/5" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("show", request.path_parameters[:action]) - assert_equal("5", request.path_parameters[:id]) - request.recycle! - - request.env["REQUEST_METHOD"] = "PUT" - assert_nothing_raised { set.recognize(request) } - assert_equal("update", request.path_parameters[:action]) - assert_equal("5", request.path_parameters[:id]) - request.recycle! - - request.env["REQUEST_METHOD"] = "DELETE" - assert_nothing_raised { set.recognize(request) } - assert_equal("destroy", request.path_parameters[:action]) - assert_equal("5", request.path_parameters[:id]) - request.recycle! - - begin - request.env["REQUEST_METHOD"] = "POST" - set.recognize(request) - flunk 'Should have raised MethodNotAllowed' - rescue ActionController::MethodNotAllowed => e - assert_equal [:get, :put, :delete], e.allowed_methods - end - request.recycle! - - ensure - Object.send(:remove_const, :PeopleController) - end - - def test_recognize_with_alias_in_conditions - Object.const_set(:PeopleController, Class.new) - - set.draw do |map| - map.people "/people", :controller => 'people', :action => "index", - :conditions => { :method => :get } - map.root :people - end - - request.path = "/people" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("people", request.path_parameters[:controller]) - assert_equal("index", request.path_parameters[:action]) - - request.path = "/" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("people", request.path_parameters[:controller]) - assert_equal("index", request.path_parameters[:action]) - ensure - Object.send(:remove_const, :PeopleController) - end - - def test_typo_recognition - Object.const_set(:ArticlesController, Class.new) - - set.draw do |map| - map.connect 'articles/:year/:month/:day/:title', - :controller => 'articles', :action => 'permalink', - :year => /\d{4}/, :day => /\d{1,2}/, :month => /\d{1,2}/ - end - - request.path = "/articles/2005/11/05/a-very-interesting-article" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("permalink", request.path_parameters[:action]) - assert_equal("2005", request.path_parameters[:year]) - assert_equal("11", request.path_parameters[:month]) - assert_equal("05", request.path_parameters[:day]) - assert_equal("a-very-interesting-article", request.path_parameters[:title]) - - ensure - Object.send(:remove_const, :ArticlesController) - end - - def test_routing_traversal_does_not_load_extra_classes - assert !Object.const_defined?("Profiler__"), "Profiler should not be loaded" - set.draw do |map| - map.connect '/profile', :controller => 'profile' - end - - request.path = '/profile' - - set.recognize(request) rescue nil - - assert !Object.const_defined?("Profiler__"), "Profiler should not be loaded" - end - - def test_recognize_with_conditions_and_format - Object.const_set(:PeopleController, Class.new) - - set.draw do |map| - map.with_options(:controller => "people") do |people| - people.person "/people/:id", :action => "show", :conditions => { :method => :get } - people.connect "/people/:id", :action => "update", :conditions => { :method => :put } - people.connect "/people/:id.:_format", :action => "show", :conditions => { :method => :get } - end - end - - request.path = "/people/5" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("show", request.path_parameters[:action]) - assert_equal("5", request.path_parameters[:id]) - request.recycle! - - request.env["REQUEST_METHOD"] = "PUT" - assert_nothing_raised { set.recognize(request) } - assert_equal("update", request.path_parameters[:action]) - request.recycle! - - request.path = "/people/5.png" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("show", request.path_parameters[:action]) - assert_equal("5", request.path_parameters[:id]) - assert_equal("png", request.path_parameters[:_format]) - ensure - Object.send(:remove_const, :PeopleController) - end - - def test_generate_with_default_action - set.draw do |map| - map.connect "/people", :controller => "people" - map.connect "/people/list", :controller => "people", :action => "list" - end - - url = set.generate(:controller => "people", :action => "list") - assert_equal "/people/list", url - end - - def test_root_map - Object.const_set(:PeopleController, Class.new) - - set.draw { |map| map.root :controller => "people" } - - request.path = "" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("people", request.path_parameters[:controller]) - assert_equal("index", request.path_parameters[:action]) - ensure - Object.send(:remove_const, :PeopleController) - end - - def test_namespace - Object.const_set(:Api, Module.new { |m| m.const_set(:ProductsController, Class.new) }) - - set.draw do |map| - - map.namespace 'api' do |api| - api.route 'inventory', :controller => "products", :action => 'inventory' - end - - end - - request.path = "/api/inventory" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("api/products", request.path_parameters[:controller]) - assert_equal("inventory", request.path_parameters[:action]) - ensure - Object.send(:remove_const, :Api) - end - - def test_namespaced_root_map - Object.const_set(:Api, Module.new { |m| m.const_set(:ProductsController, Class.new) }) - - set.draw do |map| - - map.namespace 'api' do |api| - api.root :controller => "products" - end - - end - - request.path = "/api" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("api/products", request.path_parameters[:controller]) - assert_equal("index", request.path_parameters[:action]) - ensure - Object.send(:remove_const, :Api) - end - - def test_namespace_with_path_prefix - Object.const_set(:Api, Module.new { |m| m.const_set(:ProductsController, Class.new) }) - - set.draw do |map| - map.namespace 'api', :path_prefix => 'prefix' do |api| - api.route 'inventory', :controller => "products", :action => 'inventory' - end - end - - request.path = "/prefix/inventory" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("api/products", request.path_parameters[:controller]) - assert_equal("inventory", request.path_parameters[:action]) - ensure - Object.send(:remove_const, :Api) - end - - def test_namespace_with_blank_path_prefix - Object.const_set(:Api, Module.new { |m| m.const_set(:ProductsController, Class.new) }) - - set.draw do |map| - map.namespace 'api', :path_prefix => '' do |api| - api.route 'inventory', :controller => "products", :action => 'inventory' - end - end - - request.path = "/inventory" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("api/products", request.path_parameters[:controller]) - assert_equal("inventory", request.path_parameters[:action]) - ensure - Object.send(:remove_const, :Api) - end - - def test_generate_finds_best_fit - set.draw do |map| - map.connect "/people", :controller => "people", :action => "index" - map.connect "/ws/people", :controller => "people", :action => "index", :ws => true - end - - url = set.generate(:controller => "people", :action => "index", :ws => true) - assert_equal "/ws/people", url - end - - def test_generate_changes_controller_module - set.draw { |map| map.connect ':controller/:action/:id' } - current = { :controller => "bling/bloop", :action => "bap", :id => 9 } - url = set.generate({:controller => "foo/bar", :action => "baz", :id => 7}, current) - assert_equal "/foo/bar/baz/7", url - end - - def test_id_is_not_impossibly_sticky - set.draw do |map| - map.connect 'foo/:number', :controller => "people", :action => "index" - map.connect ':controller/:action/:id' - end - - url = set.generate({:controller => "people", :action => "index", :number => 3}, - {:controller => "people", :action => "index", :id => "21"}) - assert_equal "/foo/3", url - end - - def test_id_is_sticky_when_it_ought_to_be - set.draw do |map| - map.connect ':controller/:id/:action' - end - - url = set.generate({:action => "destroy"}, {:controller => "people", :action => "show", :id => "7"}) - assert_equal "/people/7/destroy", url - end - - def test_use_static_path_when_possible - set.draw do |map| - map.connect 'about', :controller => "welcome", :action => "about" - map.connect ':controller/:action/:id' - end - - url = set.generate({:controller => "welcome", :action => "about"}, - {:controller => "welcome", :action => "get", :id => "7"}) - assert_equal "/about", url - end - - def test_generate - set.draw { |map| map.connect ':controller/:action/:id' } - - args = { :controller => "foo", :action => "bar", :id => "7", :x => "y" } - assert_equal "/foo/bar/7?x=y", set.generate(args) - assert_equal ["/foo/bar/7", [:x]], set.generate_extras(args) - assert_equal [:x], set.extra_keys(args) - end - - def test_generate_with_path_prefix - set.draw { |map| map.connect ':controller/:action/:id', :path_prefix => 'my' } - - args = { :controller => "foo", :action => "bar", :id => "7", :x => "y" } - assert_equal "/my/foo/bar/7?x=y", set.generate(args) - end - - def test_generate_with_blank_path_prefix - set.draw { |map| map.connect ':controller/:action/:id', :path_prefix => '' } - - args = { :controller => "foo", :action => "bar", :id => "7", :x => "y" } - assert_equal "/foo/bar/7?x=y", set.generate(args) - end - - def test_named_routes_are_never_relative_to_modules - set.draw do |map| - map.connect "/connection/manage/:action", :controller => 'connection/manage' - map.connect "/connection/connection", :controller => "connection/connection" - map.family_connection "/connection", :controller => "connection" - end - - url = set.generate({:controller => "connection"}, {:controller => 'connection/manage'}) - assert_equal "/connection/connection", url - - url = set.generate({:use_route => :family_connection, :controller => "connection"}, {:controller => 'connection/manage'}) - assert_equal "/connection", url - end - - def test_action_left_off_when_id_is_recalled - set.draw do |map| - map.connect ':controller/:action/:id' - end - assert_equal '/post', set.generate( - {:controller => 'post', :action => 'index'}, - {:controller => 'post', :action => 'show', :id => '10'} - ) - end - - def test_query_params_will_be_shown_when_recalled - set.draw do |map| - map.connect 'show_post/:parameter', :controller => 'post', :action => 'show' - map.connect ':controller/:action/:id' - end - assert_equal '/post/edit?parameter=1', set.generate( - {:action => 'edit', :parameter => 1}, - {:controller => 'post', :action => 'show', :parameter => 1} - ) - end - - def test_format_is_not_inherit - set.draw do |map| - map.connect '/posts.:format', :controller => 'posts' - end - - assert_equal '/posts', set.generate( - {:controller => 'posts'}, - {:controller => 'posts', :action => 'index', :format => 'xml'} - ) - - assert_equal '/posts.xml', set.generate( - {:controller => 'posts', :format => 'xml'}, - {:controller => 'posts', :action => 'index', :format => 'xml'} - ) - end - - def test_expiry_determination_should_consider_values_with_to_param - set.draw { |map| map.connect 'projects/:project_id/:controller/:action' } - assert_equal '/projects/1/post/show', set.generate( - {:action => 'show', :project_id => 1}, - {:controller => 'post', :action => 'show', :project_id => '1'}) - end - - def test_generate_all - set.draw do |map| - map.connect 'show_post/:id', :controller => 'post', :action => 'show' - map.connect ':controller/:action/:id' - end - all = set.generate( - {:action => 'show', :id => 10, :generate_all => true}, - {:controller => 'post', :action => 'show'} - ) - assert_equal 2, all.length - assert_equal '/show_post/10', all.first - assert_equal '/post/show/10', all.last - end - - def test_named_route_in_nested_resource - set.draw do |map| - map.resources :projects do |project| - project.milestones 'milestones', :controller => 'milestones', :action => 'index' - end - end - - request.path = "/projects/1/milestones" - request.env["REQUEST_METHOD"] = "GET" - assert_nothing_raised { set.recognize(request) } - assert_equal("milestones", request.path_parameters[:controller]) - assert_equal("index", request.path_parameters[:action]) - end - - def test_setting_root_in_namespace_using_symbol - assert_nothing_raised do - set.draw do |map| - map.namespace :admin do |admin| - admin.root :controller => 'home' - end - end - end - end - - def test_setting_root_in_namespace_using_string - assert_nothing_raised do - set.draw do |map| - map.namespace 'admin' do |admin| - admin.root :controller => 'home' - end - end - end - end - - def test_route_requirements_with_unsupported_regexp_options_must_error - assert_raise ArgumentError do - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => /(david|jamis)/m} - end - end - end - - def test_route_requirements_with_supported_options_must_not_error - assert_nothing_raised do - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => /(david|jamis)/i} - end - end - assert_nothing_raised do - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => / # Desperately overcommented regexp - ( #Either - david #The Creator - | #Or - jamis #The Deployer - )/x} - end - end - end - - def test_route_requirement_recognize_with_ignore_case - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => /(david|jamis)/i} - end - assert_equal({:controller => 'pages', :action => 'show', :name => 'jamis'}, set.recognize_path('/page/jamis')) - assert_raise ActionController::RoutingError do - set.recognize_path('/page/davidjamis') - end - assert_equal({:controller => 'pages', :action => 'show', :name => 'DAVID'}, set.recognize_path('/page/DAVID')) - end - - def test_route_requirement_generate_with_ignore_case - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => /(david|jamis)/i} - end - url = set.generate({:controller => 'pages', :action => 'show', :name => 'david'}) - assert_equal "/page/david", url - assert_raise ActionController::RoutingError do - url = set.generate({:controller => 'pages', :action => 'show', :name => 'davidjamis'}) - end - url = set.generate({:controller => 'pages', :action => 'show', :name => 'JAMIS'}) - assert_equal "/page/JAMIS", url - end - - def test_route_requirement_recognize_with_extended_syntax - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => / # Desperately overcommented regexp - ( #Either - david #The Creator - | #Or - jamis #The Deployer - )/x} - end - assert_equal({:controller => 'pages', :action => 'show', :name => 'jamis'}, set.recognize_path('/page/jamis')) - assert_equal({:controller => 'pages', :action => 'show', :name => 'david'}, set.recognize_path('/page/david')) - assert_raise ActionController::RoutingError do - set.recognize_path('/page/david #The Creator') - end - assert_raise ActionController::RoutingError do - set.recognize_path('/page/David') - end - end - - def test_route_requirement_generate_with_extended_syntax - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => / # Desperately overcommented regexp - ( #Either - david #The Creator - | #Or - jamis #The Deployer - )/x} - end - url = set.generate({:controller => 'pages', :action => 'show', :name => 'david'}) - assert_equal "/page/david", url - assert_raise ActionController::RoutingError do - url = set.generate({:controller => 'pages', :action => 'show', :name => 'davidjamis'}) - end - assert_raise ActionController::RoutingError do - url = set.generate({:controller => 'pages', :action => 'show', :name => 'JAMIS'}) - end - end - - def test_route_requirement_generate_with_xi_modifiers - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => / # Desperately overcommented regexp - ( #Either - david #The Creator - | #Or - jamis #The Deployer - )/xi} - end - url = set.generate({:controller => 'pages', :action => 'show', :name => 'JAMIS'}) - assert_equal "/page/JAMIS", url - end - - def test_route_requirement_recognize_with_xi_modifiers - set.draw do |map| - map.connect 'page/:name', :controller => 'pages', - :action => 'show', - :requirements => {:name => / # Desperately overcommented regexp - ( #Either - david #The Creator - | #Or - jamis #The Deployer - )/xi} - end - assert_equal({:controller => 'pages', :action => 'show', :name => 'JAMIS'}, set.recognize_path('/page/JAMIS')) - end -end - -class RouteLoadingTest < Test::Unit::TestCase - def setup - routes.instance_variable_set '@routes_last_modified', nil - silence_warnings { Object.const_set :RAILS_ROOT, '.' } - routes.add_configuration_file(File.join(RAILS_ROOT, 'config', 'routes.rb')) - - @stat = stub_everything - end - - def teardown - ActionController::Routing::Routes.configuration_files.clear - Object.send :remove_const, :RAILS_ROOT - end - - def test_load - File.expects(:stat).returns(@stat) - routes.expects(:load).with(regexp_matches(/routes\.rb$/)) - - routes.reload - end - - def test_no_reload_when_not_modified - @stat.expects(:mtime).times(2).returns(1) - File.expects(:stat).times(2).returns(@stat) - routes.expects(:load).with(regexp_matches(/routes\.rb$/)).at_most_once - - 2.times { routes.reload } - end - - def test_reload_when_modified - @stat.expects(:mtime).at_least(2).returns(1, 2) - File.expects(:stat).at_least(2).returns(@stat) - routes.expects(:load).with(regexp_matches(/routes\.rb$/)).times(2) - - 2.times { routes.reload } - end - - def test_bang_forces_reload - @stat.expects(:mtime).at_least(2).returns(1) - File.expects(:stat).at_least(2).returns(@stat) - routes.expects(:load).with(regexp_matches(/routes\.rb$/)).times(2) - - 2.times { routes.reload! } - end - - def test_adding_inflections_forces_reload - ActiveSupport::Inflector::Inflections.instance.expects(:uncountable).with('equipment') - routes.expects(:reload!) - - ActiveSupport::Inflector.inflections { |inflect| inflect.uncountable('equipment') } - end - - def test_load_with_configuration - routes.configuration_files.clear - routes.add_configuration_file("foobarbaz") - File.expects(:stat).returns(@stat) - routes.expects(:load).with("foobarbaz") - - routes.reload - end - - def test_load_multiple_configurations - routes.add_configuration_file("engines.rb") - - File.expects(:stat).at_least_once.returns(@stat) - - routes.expects(:load).with('./config/routes.rb') - routes.expects(:load).with('engines.rb') - - routes.reload - end - - private - def routes - ActionController::Routing::Routes - end -end diff --git a/vendor/rails/actionpack/test/controller/selector_test.rb b/vendor/rails/actionpack/test/controller/selector_test.rb deleted file mode 100644 index 9d0613d..0000000 --- a/vendor/rails/actionpack/test/controller/selector_test.rb +++ /dev/null @@ -1,628 +0,0 @@ -#-- -# Copyright (c) 2006 Assaf Arkin (http://labnotes.org) -# Under MIT and/or CC By license. -#++ - -require 'abstract_unit' -require 'controller/fake_controllers' - -class SelectorTest < Test::Unit::TestCase - # - # Basic selector: element, id, class, attributes. - # - - def test_element - parse(%Q{<div id="1"></div><p></p><div id="2"></div>}) - # Match element by name. - select("div") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "2", @matches[1].attributes["id"] - # Not case sensitive. - select("DIV") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "2", @matches[1].attributes["id"] - # Universal match (all elements). - select("*") - assert_equal 3, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal nil, @matches[1].attributes["id"] - assert_equal "2", @matches[2].attributes["id"] - end - - - def test_identifier - parse(%Q{<div id="1"></div><p></p><div id="2"></div>}) - # Match element by ID. - select("div#1") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - # Match element by ID, substitute value. - select("div#?", 2) - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Element name does not match ID. - select("p#?", 2) - assert_equal 0, @matches.size - # Use regular expression. - select("#?", /\d/) - assert_equal 2, @matches.size - end - - - def test_class_name - parse(%Q{<div id="1" class=" foo "></div><p id="2" class=" foo bar "></p><div id="3" class="bar"></div>}) - # Match element with specified class. - select("div.foo") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - # Match any element with specified class. - select("*.foo") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "2", @matches[1].attributes["id"] - # Match elements with other class. - select("*.bar") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - # Match only element with both class names. - select("*.bar.foo") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - end - - - def test_attribute - parse(%Q{<div id="1"></div><p id="2" title="" bar="foo"></p><div id="3" title="foo"></div>}) - # Match element with attribute. - select("div[title]") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - # Match any element with attribute. - select("*[title]") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - # Match element with attribute value. - select("*[title=foo]") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - # Match element with attribute and attribute value. - select("[bar=foo][title]") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Not case sensitive. - select("[BAR=foo][TiTle]") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - end - - - def test_attribute_quoted - parse(%Q{<div id="1" title="foo"></div><div id="2" title="bar"></div><div id="3" title=" bar "></div>}) - # Match without quotes. - select("[title = bar]") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Match with single quotes. - select("[title = 'bar' ]") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Match with double quotes. - select("[title = \"bar\" ]") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Match with spaces. - select("[title = \" bar \" ]") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - end - - - def test_attribute_equality - parse(%Q{<div id="1" title="foo bar"></div><div id="2" title="barbaz"></div>}) - # Match (fail) complete value. - select("[title=bar]") - assert_equal 0, @matches.size - # Match space-separate word. - select("[title~=foo]") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - select("[title~=bar]") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - # Match beginning of value. - select("[title^=ba]") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Match end of value. - select("[title$=ar]") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - # Match text in value. - select("[title*=bar]") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "2", @matches[1].attributes["id"] - # Match first space separated word. - select("[title|=foo]") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - select("[title|=bar]") - assert_equal 0, @matches.size - end - - - # - # Selector composition: groups, sibling, children - # - - - def test_selector_group - parse(%Q{<h1 id="1"></h1><h2 id="2"></h2><h3 id="3"></h3>}) - # Simple group selector. - select("h1,h3") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - select("h1 , h3") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - # Complex group selector. - parse(%Q{<h1 id="1"><a href="foo"></a></h1><h2 id="2"><a href="bar"></a></h2><h3 id="2"><a href="baz"></a></h3>}) - select("h1 a, h3 a") - assert_equal 2, @matches.size - assert_equal "foo", @matches[0].attributes["href"] - assert_equal "baz", @matches[1].attributes["href"] - # And now for the three selector challenge. - parse(%Q{<h1 id="1"><a href="foo"></a></h1><h2 id="2"><a href="bar"></a></h2><h3 id="2"><a href="baz"></a></h3>}) - select("h1 a, h2 a, h3 a") - assert_equal 3, @matches.size - assert_equal "foo", @matches[0].attributes["href"] - assert_equal "bar", @matches[1].attributes["href"] - assert_equal "baz", @matches[2].attributes["href"] - end - - - def test_sibling_selector - parse(%Q{<h1 id="1"></h1><h2 id="2"></h2><h3 id="3"></h3>}) - # Test next sibling. - select("h1+*") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - select("h1+h2") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - select("h1+h3") - assert_equal 0, @matches.size - select("*+h3") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - # Test any sibling. - select("h1~*") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - select("h2~*") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - end - - - def test_children_selector - parse(%Q{<div><p id="1"><span id="2"></span></p></div><div><p id="3"><span id="4" class="foo"></span></p></div>}) - # Test child selector. - select("div>p") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - select("div>span") - assert_equal 0, @matches.size - select("div>p#3") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - select("div>p>span") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - # Test descendant selector. - select("div p") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - select("div span") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - select("div *#3") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - select("div *#4") - assert_equal 1, @matches.size - assert_equal "4", @matches[0].attributes["id"] - # This is here because it failed before when whitespaces - # were not properly stripped. - select("div .foo") - assert_equal 1, @matches.size - assert_equal "4", @matches[0].attributes["id"] - end - - - # - # Pseudo selectors: root, nth-child, empty, content, etc - # - - - def test_root_selector - parse(%Q{<div id="1"><div id="2"></div></div>}) - # Can only find element if it's root. - select(":root") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - select("#1:root") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - select("#2:root") - assert_equal 0, @matches.size - # Opposite for nth-child. - select("#1:nth-child(1)") - assert_equal 0, @matches.size - end - - - def test_nth_child_odd_even - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # Test odd nth children. - select("tr:nth-child(odd)") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - # Test even nth children. - select("tr:nth-child(even)") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - end - - - def test_nth_child_a_is_zero - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # Test the third child. - select("tr:nth-child(0n+3)") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - # Same but an can be omitted when zero. - select("tr:nth-child(3)") - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - # Second element (but not every second element). - select("tr:nth-child(0n+2)") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Before first and past last returns nothing.: - assert_raise(ArgumentError) { select("tr:nth-child(-1)") } - select("tr:nth-child(0)") - assert_equal 0, @matches.size - select("tr:nth-child(5)") - assert_equal 0, @matches.size - end - - - def test_nth_child_a_is_one - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # a is group of one, pick every element in group. - select("tr:nth-child(1n+0)") - assert_equal 4, @matches.size - # Same but a can be omitted when one. - select("tr:nth-child(n+0)") - assert_equal 4, @matches.size - # Same but b can be omitted when zero. - select("tr:nth-child(n)") - assert_equal 4, @matches.size - end - - - def test_nth_child_b_is_zero - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # If b is zero, pick the n-th element (here each one). - select("tr:nth-child(n+0)") - assert_equal 4, @matches.size - # If b is zero, pick the n-th element (here every second). - select("tr:nth-child(2n+0)") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - # If a and b are both zero, no element selected. - select("tr:nth-child(0n+0)") - assert_equal 0, @matches.size - select("tr:nth-child(0)") - assert_equal 0, @matches.size - end - - - def test_nth_child_a_is_negative - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # Since a is -1, picks the first three elements. - select("tr:nth-child(-n+3)") - assert_equal 3, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "2", @matches[1].attributes["id"] - assert_equal "3", @matches[2].attributes["id"] - # Since a is -2, picks the first in every second of first four elements. - select("tr:nth-child(-2n+3)") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - # Since a is -2, picks the first in every second of first three elements. - select("tr:nth-child(-2n+2)") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - end - - - def test_nth_child_b_is_negative - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # Select last of four. - select("tr:nth-child(4n-1)") - assert_equal 1, @matches.size - assert_equal "4", @matches[0].attributes["id"] - # Select first of four. - select("tr:nth-child(4n-4)") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - # Select last of every second. - select("tr:nth-child(2n-1)") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - # Select nothing since an+b always < 0 - select("tr:nth-child(-1n-1)") - assert_equal 0, @matches.size - end - - - def test_nth_child_substitution_values - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # Test with ?n?. - select("tr:nth-child(?n?)", 2, 1) - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "3", @matches[1].attributes["id"] - select("tr:nth-child(?n?)", 2, 2) - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - select("tr:nth-child(?n?)", 4, 2) - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - # Test with ? (b only). - select("tr:nth-child(?)", 3) - assert_equal 1, @matches.size - assert_equal "3", @matches[0].attributes["id"] - select("tr:nth-child(?)", 5) - assert_equal 0, @matches.size - end - - - def test_nth_last_child - parse(%Q{<table><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # Last two elements. - select("tr:nth-last-child(-n+2)") - assert_equal 2, @matches.size - assert_equal "3", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - # All old elements counting from last one. - select("tr:nth-last-child(odd)") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - end - - - def test_nth_of_type - parse(%Q{<table><thead></thead><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # First two elements. - select("tr:nth-of-type(-n+2)") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "2", @matches[1].attributes["id"] - # All old elements counting from last one. - select("tr:nth-last-of-type(odd)") - assert_equal 2, @matches.size - assert_equal "2", @matches[0].attributes["id"] - assert_equal "4", @matches[1].attributes["id"] - end - - - def test_first_and_last - parse(%Q{<table><thead></thead><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>}) - # First child. - select("tr:first-child") - assert_equal 0, @matches.size - select(":first-child") - assert_equal 1, @matches.size - assert_equal "thead", @matches[0].name - # First of type. - select("tr:first-of-type") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - select("thead:first-of-type") - assert_equal 1, @matches.size - assert_equal "thead", @matches[0].name - select("div:first-of-type") - assert_equal 0, @matches.size - # Last child. - select("tr:last-child") - assert_equal 1, @matches.size - assert_equal "4", @matches[0].attributes["id"] - # Last of type. - select("tr:last-of-type") - assert_equal 1, @matches.size - assert_equal "4", @matches[0].attributes["id"] - select("thead:last-of-type") - assert_equal 1, @matches.size - assert_equal "thead", @matches[0].name - select("div:last-of-type") - assert_equal 0, @matches.size - end - - - def test_first_and_last - # Only child. - parse(%Q{<table><tr></tr></table>}) - select("table:only-child") - assert_equal 0, @matches.size - select("tr:only-child") - assert_equal 1, @matches.size - assert_equal "tr", @matches[0].name - parse(%Q{<table><tr></tr><tr></tr></table>}) - select("tr:only-child") - assert_equal 0, @matches.size - # Only of type. - parse(%Q{<table><thead></thead><tr></tr><tr></tr></table>}) - select("thead:only-of-type") - assert_equal 1, @matches.size - assert_equal "thead", @matches[0].name - select("td:only-of-type") - assert_equal 0, @matches.size - end - - - def test_empty - parse(%Q{<table><tr></tr></table>}) - select("table:empty") - assert_equal 0, @matches.size - select("tr:empty") - assert_equal 1, @matches.size - parse(%Q{<div> </div>}) - select("div:empty") - assert_equal 1, @matches.size - end - - - def test_content - parse(%Q{<div> </div>}) - select("div:content()") - assert_equal 1, @matches.size - parse(%Q{<div>something </div>}) - select("div:content()") - assert_equal 0, @matches.size - select("div:content(something)") - assert_equal 1, @matches.size - select("div:content( 'something' )") - assert_equal 1, @matches.size - select("div:content( \"something\" )") - assert_equal 1, @matches.size - select("div:content(?)", "something") - assert_equal 1, @matches.size - select("div:content(?)", /something/) - assert_equal 1, @matches.size - end - - - # - # Test negation. - # - - - def test_element_negation - parse(%Q{<p></p><div></div>}) - select("*") - assert_equal 2, @matches.size - select("*:not(p)") - assert_equal 1, @matches.size - assert_equal "div", @matches[0].name - select("*:not(div)") - assert_equal 1, @matches.size - assert_equal "p", @matches[0].name - select("*:not(span)") - assert_equal 2, @matches.size - end - - - def test_id_negation - parse(%Q{<p id="1"></p><p id="2"></p>}) - select("p") - assert_equal 2, @matches.size - select(":not(#1)") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - select(":not(#2)") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - end - - - def test_class_name_negation - parse(%Q{<p class="foo"></p><p class="bar"></p>}) - select("p") - assert_equal 2, @matches.size - select(":not(.foo)") - assert_equal 1, @matches.size - assert_equal "bar", @matches[0].attributes["class"] - select(":not(.bar)") - assert_equal 1, @matches.size - assert_equal "foo", @matches[0].attributes["class"] - end - - - def test_attribute_negation - parse(%Q{<p title="foo"></p><p title="bar"></p>}) - select("p") - assert_equal 2, @matches.size - select(":not([title=foo])") - assert_equal 1, @matches.size - assert_equal "bar", @matches[0].attributes["title"] - select(":not([title=bar])") - assert_equal 1, @matches.size - assert_equal "foo", @matches[0].attributes["title"] - end - - - def test_pseudo_class_negation - parse(%Q{<div><p id="1"></p><p id="2"></p></div>}) - select("p") - assert_equal 2, @matches.size - select("p:not(:first-child)") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - select("p:not(:nth-child(2))") - assert_equal 1, @matches.size - assert_equal "1", @matches[0].attributes["id"] - end - - - def test_negation_details - parse(%Q{<p id="1"></p><p id="2"></p><p id="3"></p>}) - assert_raise(ArgumentError) { select(":not(") } - assert_raise(ArgumentError) { select(":not(:not())") } - select("p:not(#1):not(#3)") - assert_equal 1, @matches.size - assert_equal "2", @matches[0].attributes["id"] - end - - - def test_select_from_element - parse(%Q{<div><p id="1"></p><p id="2"></p></div>}) - select("div") - @matches = @matches[0].select("p") - assert_equal 2, @matches.size - assert_equal "1", @matches[0].attributes["id"] - assert_equal "2", @matches[1].attributes["id"] - end - - -protected - - def parse(html) - @html = HTML::Document.new(html).root - end - - def select(*selector) - @matches = HTML.selector(*selector).select(@html) - end - -end diff --git a/vendor/rails/actionpack/test/controller/send_file_test.rb b/vendor/rails/actionpack/test/controller/send_file_test.rb deleted file mode 100644 index a27e951..0000000 --- a/vendor/rails/actionpack/test/controller/send_file_test.rb +++ /dev/null @@ -1,161 +0,0 @@ -require 'abstract_unit' - -module TestFileUtils - def file_name() File.basename(__FILE__) end - def file_path() File.expand_path(__FILE__) end - def file_data() File.open(file_path, 'rb') { |f| f.read } end -end - -class SendFileController < ActionController::Base - include TestFileUtils - layout "layouts/standard" # to make sure layouts don't interfere - - attr_writer :options - def options() @options ||= {} end - - def file() send_file(file_path, options) end - def data() send_data(file_data, options) end - - def rescue_action(e) raise end -end - -class SendFileTest < ActionController::TestCase - tests SendFileController - include TestFileUtils - - Mime::Type.register "image/png", :png unless defined? Mime::PNG - - def setup - @controller = SendFileController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def test_file_nostream - @controller.options = { :stream => false } - response = nil - assert_nothing_raised { response = process('file') } - assert_not_nil response - assert_kind_of String, response.body - assert_equal file_data, response.body - end - - def test_file_stream - response = nil - assert_nothing_raised { response = process('file') } - assert_not_nil response - assert_kind_of Proc, response.body - - require 'stringio' - output = StringIO.new - output.binmode - assert_nothing_raised { response.body.call(response, output) } - assert_equal file_data, output.string - end - - def test_file_url_based_filename - @controller.options = { :url_based_filename => true } - response = nil - assert_nothing_raised { response = process('file') } - assert_not_nil response - assert_equal "attachment", response.headers["Content-Disposition"] - end - - def test_x_sendfile_header - @controller.options = { :x_sendfile => true } - - response = nil - assert_nothing_raised { response = process('file') } - assert_not_nil response - - assert_equal @controller.file_path, response.headers['X-Sendfile'] - assert response.body.blank? - assert !response.etag? - end - - def test_data - response = nil - assert_nothing_raised { response = process('data') } - assert_not_nil response - - assert_kind_of String, response.body - assert_equal file_data, response.body - end - - def test_headers_after_send_shouldnt_include_charset - response = process('data') - assert_equal "application/octet-stream", response.content_type - - response = process('file') - assert_equal "application/octet-stream", response.content_type - end - - # Test that send_file_headers! is setting the correct HTTP headers. - def test_send_file_headers! - options = { - :length => 1, - :type => Mime::PNG, - :disposition => 'disposition', - :filename => 'filename' - } - - # Do it a few times: the resulting headers should be identical - # no matter how many times you send with the same options. - # Test resolving Ticket #458. - @controller.headers = {} - @controller.send(:send_file_headers!, options) - @controller.send(:send_file_headers!, options) - @controller.send(:send_file_headers!, options) - - h = @controller.headers - assert_equal 1, h['Content-Length'] - assert_equal 'image/png', h['Content-Type'] - assert_equal 'disposition; filename="filename"', h['Content-Disposition'] - assert_equal 'binary', h['Content-Transfer-Encoding'] - - # test overriding Cache-Control: no-cache header to fix IE open/save dialog - @controller.headers = { 'Cache-Control' => 'no-cache' } - @controller.send(:send_file_headers!, options) - h = @controller.headers - assert_equal 'private', h['Cache-Control'] - end - - def test_send_file_headers_with_mime_lookup_with_symbol - options = { - :length => 1, - :type => :png - } - - @controller.headers = {} - @controller.send(:send_file_headers!, options) - - headers = @controller.headers - - assert_equal 'image/png', headers['Content-Type'] - end - - - def test_send_file_headers_with_bad_symbol - options = { - :length => 1, - :type => :this_type_is_not_registered - } - - @controller.headers = {} - assert_raise(ArgumentError){ @controller.send(:send_file_headers!, options) } - end - - %w(file data).each do |method| - define_method "test_send_#{method}_status" do - @controller.options = { :stream => false, :status => 500 } - assert_nothing_raised { assert_not_nil process(method) } - assert_equal '500 Internal Server Error', @response.status - end - - define_method "test_default_send_#{method}_status" do - @controller.options = { :stream => false } - assert_nothing_raised { assert_not_nil process(method) } - assert_equal ActionController::Base::DEFAULT_RENDER_STATUS_CODE, @response.status - end - end -end diff --git a/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb b/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb deleted file mode 100644 index 9c93ca6..0000000 --- a/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb +++ /dev/null @@ -1,239 +0,0 @@ -require 'abstract_unit' -require 'stringio' - -class CookieStoreTest < ActionController::IntegrationTest - SessionKey = '_myapp_session' - SessionSecret = 'b3c631c314c0bbca50c1b2843150fe33' - - DispatcherApp = ActionController::Dispatcher.new - CookieStoreApp = ActionController::Session::CookieStore.new(DispatcherApp, :key => SessionKey, :secret => SessionSecret) - - Verifier = ActiveSupport::MessageVerifier.new(SessionSecret, 'SHA1') - - SignedBar = "BAh7BjoIZm9vIghiYXI%3D--fef868465920f415f2c0652d6910d3af288a0367" - - class TestController < ActionController::Base - def no_session_access - head :ok - end - - def persistent_session_id - render :text => session[:session_id] - end - - def set_session_value - session[:foo] = "bar" - render :text => Rack::Utils.escape(Verifier.generate(session.to_hash)) - end - - def get_session_value - render :text => "foo: #{session[:foo].inspect}" - end - - def get_session_id - render :text => "foo: #{session[:foo].inspect}; id: #{request.session_options[:id]}" - end - - def call_reset_session - reset_session - head :ok - end - - def raise_data_overflow - session[:foo] = 'bye!' * 1024 - head :ok - end - - def rescue_action(e) raise end - end - - def setup - @integration_session = open_session(CookieStoreApp) - end - - def test_raises_argument_error_if_missing_session_key - assert_raise(ArgumentError, nil.inspect) { - ActionController::Session::CookieStore.new(nil, - :key => nil, :secret => SessionSecret) - } - - assert_raise(ArgumentError, ''.inspect) { - ActionController::Session::CookieStore.new(nil, - :key => '', :secret => SessionSecret) - } - end - - def test_raises_argument_error_if_missing_secret - assert_raise(ArgumentError, nil.inspect) { - ActionController::Session::CookieStore.new(nil, - :key => SessionKey, :secret => nil) - } - - assert_raise(ArgumentError, ''.inspect) { - ActionController::Session::CookieStore.new(nil, - :key => SessionKey, :secret => '') - } - end - - def test_raises_argument_error_if_secret_is_probably_insecure - assert_raise(ArgumentError, "password".inspect) { - ActionController::Session::CookieStore.new(nil, - :key => SessionKey, :secret => "password") - } - - assert_raise(ArgumentError, "secret".inspect) { - ActionController::Session::CookieStore.new(nil, - :key => SessionKey, :secret => "secret") - } - - assert_raise(ArgumentError, "12345678901234567890123456789".inspect) { - ActionController::Session::CookieStore.new(nil, - :key => SessionKey, :secret => "12345678901234567890123456789") - } - end - - def test_setting_session_value - with_test_route_set do - get '/set_session_value' - assert_response :success - assert_equal "_myapp_session=#{response.body}; path=/; HttpOnly", - headers['Set-Cookie'] - end - end - - def test_getting_session_value - with_test_route_set do - cookies[SessionKey] = SignedBar - get '/get_session_value' - assert_response :success - assert_equal 'foo: "bar"', response.body - end - end - - def test_getting_session_id - with_test_route_set do - cookies[SessionKey] = SignedBar - get '/persistent_session_id' - assert_response :success - assert_equal response.body.size, 32 - session_id = response.body - - get '/get_session_id' - assert_response :success - assert_equal "foo: \"bar\"; id: #{session_id}", response.body - end - end - - def test_disregards_tampered_sessions - with_test_route_set do - cookies[SessionKey] = "BAh7BjoIZm9vIghiYXI%3D--123456780" - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - end - end - - def test_close_raises_when_data_overflows - with_test_route_set do - assert_raise(ActionController::Session::CookieStore::CookieOverflow) { - get '/raise_data_overflow' - } - end - end - - def test_doesnt_write_session_cookie_if_session_is_not_accessed - with_test_route_set do - get '/no_session_access' - assert_response :success - assert_equal "", headers['Set-Cookie'] - end - end - - def test_doesnt_write_session_cookie_if_session_is_unchanged - with_test_route_set do - cookies[SessionKey] = "BAh7BjoIZm9vIghiYXI%3D--" + - "fef868465920f415f2c0652d6910d3af288a0367" - get '/no_session_access' - assert_response :success - assert_equal "", headers['Set-Cookie'] - end - end - - def test_setting_session_value_after_session_reset - with_test_route_set do - get '/set_session_value' - assert_response :success - session_payload = response.body - assert_equal "_myapp_session=#{response.body}; path=/; HttpOnly", - headers['Set-Cookie'] - - get '/call_reset_session' - assert_response :success - assert_not_equal [], headers['Set-Cookie'] - assert_not_equal session_payload, cookies[SessionKey] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - end - end - - def test_persistent_session_id - with_test_route_set do - cookies[SessionKey] = SignedBar - get '/persistent_session_id' - assert_response :success - assert_equal response.body.size, 32 - session_id = response.body - get '/persistent_session_id' - assert_equal session_id, response.body - reset! - get '/persistent_session_id' - assert_not_equal session_id, response.body - end - end - - def test_session_store_with_expire_after - app = ActionController::Session::CookieStore.new(DispatcherApp, :key => SessionKey, :secret => SessionSecret, :expire_after => 5.hours) - @integration_session = open_session(app) - - with_test_route_set do - # First request accesses the session - time = Time.local(2008, 4, 24) - Time.stubs(:now).returns(time) - expected_expiry = (time + 5.hours).gmtime.strftime("%a, %d-%b-%Y %H:%M:%S GMT") - - cookies[SessionKey] = SignedBar - - get '/set_session_value' - assert_response :success - - cookie_body = response.body - assert_equal "_myapp_session=#{cookie_body}; path=/; expires=#{expected_expiry}; HttpOnly", - headers['Set-Cookie'] - - # Second request does not access the session - time = Time.local(2008, 4, 25) - Time.stubs(:now).returns(time) - expected_expiry = (time + 5.hours).gmtime.strftime("%a, %d-%b-%Y %H:%M:%S GMT") - - get '/no_session_access' - assert_response :success - - assert_equal "_myapp_session=#{cookie_body}; path=/; expires=#{expected_expiry}; HttpOnly", - headers['Set-Cookie'] - end - end - - private - def with_test_route_set - with_routing do |set| - set.draw do |map| - map.with_options :controller => "cookie_store_test/test" do |c| - c.connect "/:action" - end - end - yield - end - end -end diff --git a/vendor/rails/actionpack/test/controller/session/mem_cache_store_test.rb b/vendor/rails/actionpack/test/controller/session/mem_cache_store_test.rb deleted file mode 100644 index 2f80a3c..0000000 --- a/vendor/rails/actionpack/test/controller/session/mem_cache_store_test.rb +++ /dev/null @@ -1,127 +0,0 @@ -require 'abstract_unit' - -# You need to start a memcached server inorder to run these tests -class MemCacheStoreTest < ActionController::IntegrationTest - class TestController < ActionController::Base - def no_session_access - head :ok - end - - def set_session_value - session[:foo] = "bar" - head :ok - end - - def get_session_value - render :text => "foo: #{session[:foo].inspect}" - end - - def get_session_id - session[:foo] - render :text => "#{request.session_options[:id]}" - end - - def call_reset_session - session[:bar] - reset_session - session[:bar] = "baz" - head :ok - end - - def rescue_action(e) raise end - end - - begin - DispatcherApp = ActionController::Dispatcher.new - MemCacheStoreApp = ActionController::Session::MemCacheStore.new( - DispatcherApp, :key => '_session_id') - - - def setup - @integration_session = open_session(MemCacheStoreApp) - end - - def test_setting_and_getting_session_value - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: "bar"', response.body - end - end - - def test_getting_nil_session_value - with_test_route_set do - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - end - end - - def test_setting_session_value_after_session_reset - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - session_id = cookies['_session_id'] - - get '/call_reset_session' - assert_response :success - assert_not_equal [], headers['Set-Cookie'] - - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - - get '/get_session_id' - assert_response :success - assert_not_equal session_id, response.body - end - end - - def test_getting_session_id - with_test_route_set do - get '/set_session_value' - assert_response :success - assert cookies['_session_id'] - session_id = cookies['_session_id'] - - get '/get_session_id' - assert_response :success - assert_equal session_id, response.body - end - end - - def test_prevents_session_fixation - with_test_route_set do - get '/get_session_value' - assert_response :success - assert_equal 'foo: nil', response.body - session_id = cookies['_session_id'] - - reset! - - get '/set_session_value', :_session_id => session_id - assert_response :success - assert_equal nil, cookies['_session_id'] - end - end - rescue LoadError, RuntimeError - $stderr.puts "Skipping MemCacheStoreTest tests. Start memcached and try again." - end - - private - def with_test_route_set - with_routing do |set| - set.draw do |map| - map.with_options :controller => "mem_cache_store_test/test" do |c| - c.connect "/:action" - end - end - yield - end - end -end diff --git a/vendor/rails/actionpack/test/controller/session/test_session_test.rb b/vendor/rails/actionpack/test/controller/session/test_session_test.rb deleted file mode 100644 index de6539e..0000000 --- a/vendor/rails/actionpack/test/controller/session/test_session_test.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'abstract_unit' -require 'stringio' - -class ActionController::TestSessionTest < ActiveSupport::TestCase - - def test_calling_delete_without_parameters_raises_deprecation_warning_and_calls_to_clear_test_session - assert_deprecated(/use clear instead/){ ActionController::TestSession.new.delete } - end - - def test_calling_update_without_parameters_raises_deprecation_warning_and_calls_to_clear_test_session - assert_deprecated(/use replace instead/){ ActionController::TestSession.new.update } - end - - def test_calling_close_raises_deprecation_warning - assert_deprecated(/sessions should no longer be closed/){ ActionController::TestSession.new.close } - end - - def test_defaults - session = ActionController::TestSession.new - assert_equal({}, session.data) - assert_equal('', session.session_id) - end - - def test_ctor_allows_setting - session = ActionController::TestSession.new({:one => 'one', :two => 'two'}) - assert_equal('one', session[:one]) - assert_equal('two', session[:two]) - end - - def test_setting_session_item_sets_item - session = ActionController::TestSession.new - session[:key] = 'value' - assert_equal('value', session[:key]) - end - - def test_calling_delete_removes_item - session = ActionController::TestSession.new - session[:key] = 'value' - assert_equal('value', session[:key]) - session.delete(:key) - assert_nil(session[:key]) - end - - def test_calling_update_with_params_passes_to_attributes - session = ActionController::TestSession.new() - session.update('key' => 'value') - assert_equal('value', session[:key]) - end - - def test_clear_emptys_session - params = {:one => 'one', :two => 'two'} - session = ActionController::TestSession.new({:one => 'one', :two => 'two'}) - session.clear - assert_nil(session[:one]) - assert_nil(session[:two]) - end - -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/controller/test_test.rb b/vendor/rails/actionpack/test/controller/test_test.rb deleted file mode 100644 index 65c894c..0000000 --- a/vendor/rails/actionpack/test/controller/test_test.rb +++ /dev/null @@ -1,692 +0,0 @@ -require 'abstract_unit' -require 'controller/fake_controllers' - -class TestTest < ActionController::TestCase - class TestController < ActionController::Base - def no_op - render :text => 'dummy' - end - - def set_flash - flash["test"] = ">#{flash["test"]}<" - render :text => 'ignore me' - end - - def set_flash_now - flash.now["test_now"] = ">#{flash["test_now"]}<" - render :text => 'ignore me' - end - - def set_session - session['string'] = 'A wonder' - session[:symbol] = 'it works' - render :text => 'Success' - end - - def reset_the_session - reset_session - render :text => 'ignore me' - end - - def render_raw_post - raise ActiveSupport::TestCase::Assertion, "#raw_post is blank" if request.raw_post.blank? - render :text => request.raw_post - end - - def render_body - render :text => request.body.read - end - - def test_params - render :text => params.inspect - end - - def test_uri - render :text => request.request_uri - end - - def test_query_string - render :text => request.query_string - end - - def test_html_output - render :text => <<HTML -<html> - <body> - <a href="/"><img src="/images/button.png" /></a> - <div id="foo"> - <ul> - <li class="item">hello</li> - <li class="item">goodbye</li> - </ul> - </div> - <div id="bar"> - <form action="/somewhere"> - Name: <input type="text" name="person[name]" id="person_name" /> - </form> - </div> - </body> -</html> -HTML - end - - def test_xml_output - response.content_type = "application/xml" - render :text => <<XML -<?xml version="1.0" encoding="UTF-8"?> -<root> - <area>area is an empty tag in HTML, raising an error if not in xml mode</area> -</root> -XML - end - - def test_only_one_param - render :text => (params[:left] && params[:right]) ? "EEP, Both here!" : "OK" - end - - def test_remote_addr - render :text => (request.remote_addr || "not specified") - end - - def test_file_upload - render :text => params[:file].size - end - - def test_send_file - send_file(File.expand_path(__FILE__)) - end - - def redirect_to_same_controller - redirect_to :controller => 'test', :action => 'test_uri', :id => 5 - end - - def redirect_to_different_controller - redirect_to :controller => 'fail', :id => 5 - end - - def create - head :created, :location => 'created resource' - end - - private - def rescue_action(e) - raise e - end - - def generate_url(opts) - url_for(opts.merge(:action => "test_uri")) - end - end - - def setup - @controller = TestController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - ActionController::Routing.use_controllers! %w(content admin/user test_test/test) - ActionController::Routing::Routes.load_routes! - end - - def teardown - ActionController::Routing::Routes.reload - end - - def test_raw_post_handling - params = {:page => {:name => 'page name'}, 'some key' => 123} - post :render_raw_post, params.dup - - assert_equal params.to_query, @response.body - end - - def test_body_stream - params = { :page => { :name => 'page name' }, 'some key' => 123 } - - post :render_body, params.dup - - assert_equal params.to_query, @response.body - end - - def test_process_without_flash - process :set_flash - assert_equal '><', flash['test'] - end - - def test_process_with_flash - process :set_flash, nil, nil, { "test" => "value" } - assert_equal '>value<', flash['test'] - end - - def test_process_with_flash_now - process :set_flash_now, nil, nil, { "test_now" => "value_now" } - assert_equal '>value_now<', flash['test_now'] - end - - def test_process_with_session - process :set_session - assert_equal 'A wonder', session['string'], "A value stored in the session should be available by string key" - assert_equal 'A wonder', session[:string], "Test session hash should allow indifferent access" - assert_equal 'it works', session['symbol'], "Test session hash should allow indifferent access" - assert_equal 'it works', session[:symbol], "Test session hash should allow indifferent access" - end - - def test_process_with_session_arg - process :no_op, nil, { 'string' => 'value1', :symbol => 'value2' } - assert_equal 'value1', session['string'] - assert_equal 'value1', session[:string] - assert_equal 'value2', session['symbol'] - assert_equal 'value2', session[:symbol] - end - - def test_session_is_cleared_from_controller_after_reset_session - process :set_session - process :reset_the_session - assert_equal Hash.new, @controller.session.to_hash - end - - def test_session_is_cleared_from_response_after_reset_session - process :set_session - process :reset_the_session - assert_equal Hash.new, @response.session.to_hash - end - - def test_session_is_cleared_from_request_after_reset_session - process :set_session - process :reset_the_session - assert_equal Hash.new, @request.session.to_hash - end - - def test_process_with_request_uri_with_no_params - process :test_uri - assert_equal "/test_test/test/test_uri", @response.body - end - - def test_process_with_request_uri_with_params - process :test_uri, :id => 7 - assert_equal "/test_test/test/test_uri/7", @response.body - end - - def test_process_with_request_uri_with_params_with_explicit_uri - @request.set_REQUEST_URI "/explicit/uri" - process :test_uri, :id => 7 - assert_equal "/explicit/uri", @response.body - end - - def test_process_with_query_string - process :test_query_string, :q => 'test' - assert_equal "q=test", @response.body - end - - def test_process_with_query_string_with_explicit_uri - @request.set_REQUEST_URI "/explicit/uri?q=test?extra=question" - process :test_query_string - assert_equal "q=test?extra=question", @response.body - end - - def test_multiple_calls - process :test_only_one_param, :left => true - assert_equal "OK", @response.body - process :test_only_one_param, :right => true - assert_equal "OK", @response.body - end - - def test_assert_tag_tag - process :test_html_output - - # there is a 'form' tag - assert_tag :tag => 'form' - # there is not an 'hr' tag - assert_no_tag :tag => 'hr' - end - - def test_assert_tag_attributes - process :test_html_output - - # there is a tag with an 'id' of 'bar' - assert_tag :attributes => { :id => "bar" } - # there is no tag with a 'name' of 'baz' - assert_no_tag :attributes => { :name => "baz" } - end - - def test_assert_tag_parent - process :test_html_output - - # there is a tag with a parent 'form' tag - assert_tag :parent => { :tag => "form" } - # there is no tag with a parent of 'input' - assert_no_tag :parent => { :tag => "input" } - end - - def test_assert_tag_child - process :test_html_output - - # there is a tag with a child 'input' tag - assert_tag :child => { :tag => "input" } - # there is no tag with a child 'strong' tag - assert_no_tag :child => { :tag => "strong" } - end - - def test_assert_tag_ancestor - process :test_html_output - - # there is a 'li' tag with an ancestor having an id of 'foo' - assert_tag :ancestor => { :attributes => { :id => "foo" } }, :tag => "li" - # there is no tag of any kind with an ancestor having an href matching 'foo' - assert_no_tag :ancestor => { :attributes => { :href => /foo/ } } - end - - def test_assert_tag_descendant - process :test_html_output - - # there is a tag with a descendant 'li' tag - assert_tag :descendant => { :tag => "li" } - # there is no tag with a descendant 'html' tag - assert_no_tag :descendant => { :tag => "html" } - end - - def test_assert_tag_sibling - process :test_html_output - - # there is a tag with a sibling of class 'item' - assert_tag :sibling => { :attributes => { :class => "item" } } - # there is no tag with a sibling 'ul' tag - assert_no_tag :sibling => { :tag => "ul" } - end - - def test_assert_tag_after - process :test_html_output - - # there is a tag following a sibling 'div' tag - assert_tag :after => { :tag => "div" } - # there is no tag following a sibling tag with id 'bar' - assert_no_tag :after => { :attributes => { :id => "bar" } } - end - - def test_assert_tag_before - process :test_html_output - - # there is a tag preceding a tag with id 'bar' - assert_tag :before => { :attributes => { :id => "bar" } } - # there is no tag preceding a 'form' tag - assert_no_tag :before => { :tag => "form" } - end - - def test_assert_tag_children_count - process :test_html_output - - # there is a tag with 2 children - assert_tag :children => { :count => 2 } - # in particular, there is a <ul> tag with two children (a nameless pair of <li>s) - assert_tag :tag => 'ul', :children => { :count => 2 } - # there is no tag with 4 children - assert_no_tag :children => { :count => 4 } - end - - def test_assert_tag_children_less_than - process :test_html_output - - # there is a tag with less than 5 children - assert_tag :children => { :less_than => 5 } - # there is no 'ul' tag with less than 2 children - assert_no_tag :children => { :less_than => 2 }, :tag => "ul" - end - - def test_assert_tag_children_greater_than - process :test_html_output - - # there is a 'body' tag with more than 1 children - assert_tag :children => { :greater_than => 1 }, :tag => "body" - # there is no tag with more than 10 children - assert_no_tag :children => { :greater_than => 10 } - end - - def test_assert_tag_children_only - process :test_html_output - - # there is a tag containing only one child with an id of 'foo' - assert_tag :children => { :count => 1, - :only => { :attributes => { :id => "foo" } } } - # there is no tag containing only one 'li' child - assert_no_tag :children => { :count => 1, :only => { :tag => "li" } } - end - - def test_assert_tag_content - process :test_html_output - - # the output contains the string "Name" - assert_tag :content => /Name/ - # the output does not contain the string "test" - assert_no_tag :content => /test/ - end - - def test_assert_tag_multiple - process :test_html_output - - # there is a 'div', id='bar', with an immediate child whose 'action' - # attribute matches the regexp /somewhere/. - assert_tag :tag => "div", :attributes => { :id => "bar" }, - :child => { :attributes => { :action => /somewhere/ } } - - # there is no 'div', id='foo', with a 'ul' child with more than - # 2 "li" children. - assert_no_tag :tag => "div", :attributes => { :id => "foo" }, - :child => { - :tag => "ul", - :children => { :greater_than => 2, - :only => { :tag => "li" } } } - end - - def test_assert_tag_children_without_content - process :test_html_output - - # there is a form tag with an 'input' child which is a self closing tag - assert_tag :tag => "form", - :children => { :count => 1, - :only => { :tag => "input" } } - - # the body tag has an 'a' child which in turn has an 'img' child - assert_tag :tag => "body", - :children => { :count => 1, - :only => { :tag => "a", - :children => { :count => 1, - :only => { :tag => "img" } } } } - end - - def test_should_not_impose_childless_html_tags_in_xml - process :test_xml_output - - begin - $stderr = StringIO.new - assert_select 'area' #This will cause a warning if content is processed as HTML - $stderr.rewind && err = $stderr.read - ensure - $stderr = STDERR - end - - assert err.empty? - end - - def test_assert_tag_attribute_matching - @response.body = '<input type="text" name="my_name">' - assert_tag :tag => 'input', - :attributes => { :name => /my/, :type => 'text' } - assert_no_tag :tag => 'input', - :attributes => { :name => 'my', :type => 'text' } - assert_no_tag :tag => 'input', - :attributes => { :name => /^my$/, :type => 'text' } - end - - def test_assert_tag_content_matching - @response.body = "<p>hello world</p>" - assert_tag :tag => "p", :content => "hello world" - assert_tag :tag => "p", :content => /hello/ - assert_no_tag :tag => "p", :content => "hello" - end - - def test_assert_generates - assert_generates 'controller/action/5', :controller => 'controller', :action => 'action', :id => '5' - assert_generates 'controller/action/7', {:id => "7"}, {:controller => "controller", :action => "action"} - assert_generates 'controller/action/5', {:controller => "controller", :action => "action", :id => "5", :name => "bob"}, {}, {:name => "bob"} - assert_generates 'controller/action/7', {:id => "7", :name => "bob"}, {:controller => "controller", :action => "action"}, {:name => "bob"} - assert_generates 'controller/action/7', {:id => "7"}, {:controller => "controller", :action => "action", :name => "bob"}, {} - end - - def test_assert_routing - assert_routing 'content', :controller => 'content', :action => 'index' - end - - def test_assert_routing_with_method - with_routing do |set| - set.draw { |map| map.resources(:content) } - assert_routing({ :method => 'post', :path => 'content' }, { :controller => 'content', :action => 'create' }) - end - end - - def test_assert_routing_in_module - assert_routing 'admin/user', :controller => 'admin/user', :action => 'index' - end - - def test_params_passing - get :test_params, :page => {:name => "Page name", :month => '4', :year => '2004', :day => '6'} - parsed_params = eval(@response.body) - assert_equal( - {'controller' => 'test_test/test', 'action' => 'test_params', - 'page' => {'name' => "Page name", 'month' => '4', 'year' => '2004', 'day' => '6'}}, - parsed_params - ) - end - - def test_id_converted_to_string - get :test_params, :id => 20, :foo => Object.new - assert_kind_of String, @request.path_parameters['id'] - end - - def test_array_path_parameter_handled_properly - with_routing do |set| - set.draw do |map| - map.connect 'file/*path', :controller => 'test_test/test', :action => 'test_params' - map.connect ':controller/:action/:id' - end - - get :test_params, :path => ['hello', 'world'] - assert_equal ['hello', 'world'], @request.path_parameters['path'] - assert_equal 'hello/world', @request.path_parameters['path'].to_s - end - end - - def test_assert_realistic_path_parameters - get :test_params, :id => 20, :foo => Object.new - - # All elements of path_parameters should use string keys - @request.path_parameters.keys.each do |key| - assert_kind_of String, key - end - end - - def test_with_routing_places_routes_back - assert ActionController::Routing::Routes - routes_id = ActionController::Routing::Routes.object_id - - begin - with_routing { raise 'fail' } - fail 'Should not be here.' - rescue RuntimeError - end - - assert ActionController::Routing::Routes - assert_equal routes_id, ActionController::Routing::Routes.object_id - end - - def test_remote_addr - get :test_remote_addr - assert_equal "0.0.0.0", @response.body - - @request.remote_addr = "192.0.0.1" - get :test_remote_addr - assert_equal "192.0.0.1", @response.body - end - - def test_header_properly_reset_after_remote_http_request - xhr :get, :test_params - assert_nil @request.env['HTTP_X_REQUESTED_WITH'] - end - - def test_header_properly_reset_after_get_request - get :test_params - @request.recycle! - assert_nil @request.instance_variable_get("@request_method") - end - - %w(controller response request).each do |variable| - %w(get post put delete head process).each do |method| - define_method("test_#{variable}_missing_for_#{method}_raises_error") do - remove_instance_variable "@#{variable}" - begin - send(method, :test_remote_addr) - assert false, "expected RuntimeError, got nothing" - rescue RuntimeError => error - assert true - assert_match %r{@#{variable} is nil}, error.message - rescue => error - assert false, "expected RuntimeError, got #{error.class}" - end - end - end - end - - FILES_DIR = File.dirname(__FILE__) + '/../fixtures/multipart' - - if RUBY_VERSION < '1.9' - READ_BINARY = 'rb' - READ_PLAIN = 'r' - else - READ_BINARY = 'rb:binary' - READ_PLAIN = 'r:binary' - end - - def test_test_uploaded_file - filename = 'mona_lisa.jpg' - path = "#{FILES_DIR}/#{filename}" - content_type = 'image/png' - expected = File.read(path) - expected.force_encoding(Encoding::BINARY) if expected.respond_to?(:force_encoding) - - file = ActionController::TestUploadedFile.new(path, content_type) - assert_equal filename, file.original_filename - assert_equal content_type, file.content_type - assert_equal file.path, file.local_path - assert_equal expected, file.read - - new_content_type = "new content_type" - file.content_type = new_content_type - assert_equal new_content_type, file.content_type - - end - - def test_test_uploaded_file_with_binary - filename = 'mona_lisa.jpg' - path = "#{FILES_DIR}/#{filename}" - content_type = 'image/png' - - binary_uploaded_file = ActionController::TestUploadedFile.new(path, content_type, :binary) - assert_equal File.open(path, READ_BINARY).read, binary_uploaded_file.read - - plain_uploaded_file = ActionController::TestUploadedFile.new(path, content_type) - assert_equal File.open(path, READ_PLAIN).read, plain_uploaded_file.read - end - - def test_fixture_file_upload_with_binary - filename = 'mona_lisa.jpg' - path = "#{FILES_DIR}/#{filename}" - content_type = 'image/jpg' - - binary_file_upload = fixture_file_upload(path, content_type, :binary) - assert_equal File.open(path, READ_BINARY).read, binary_file_upload.read - - plain_file_upload = fixture_file_upload(path, content_type) - assert_equal File.open(path, READ_PLAIN).read, plain_file_upload.read - end - - def test_fixture_file_upload - post :test_file_upload, :file => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg") - assert_equal '159528', @response.body - end - - def test_test_uploaded_file_exception_when_file_doesnt_exist - assert_raise(RuntimeError) { ActionController::TestUploadedFile.new('non_existent_file') } - end - - def test_redirect_url_only_cares_about_location_header - get :create - assert_response :created - - # Redirect url doesn't care that it wasn't a :redirect response. - assert_equal 'created resource', @response.redirect_url - assert_equal @response.redirect_url, redirect_to_url - - # Must be a :redirect response. - assert_raise(ActiveSupport::TestCase::Assertion) do - assert_redirected_to 'created resource' - end - end - - def test_binary_content_works_with_send_file - get :test_send_file - assert_nothing_raised(NoMethodError) { @response.binary_content } - end - - protected - def with_foo_routing - with_routing do |set| - set.draw do |map| - map.generate_url 'foo', :controller => 'test' - map.connect ':controller/:action/:id' - end - yield set - end - end -end - -class CleanBacktraceTest < ActionController::TestCase - def test_should_reraise_the_same_object - exception = ActiveSupport::TestCase::Assertion.new('message') - clean_backtrace { raise exception } - rescue Exception => caught - assert_equal exception.object_id, caught.object_id - assert_equal exception.message, caught.message - end - - def test_should_clean_assertion_lines_from_backtrace - path = File.expand_path("#{File.dirname(__FILE__)}/../../lib/action_controller") - exception = ActiveSupport::TestCase::Assertion.new('message') - exception.set_backtrace ["#{path}/abc", "#{path}/assertions/def"] - clean_backtrace { raise exception } - rescue Exception => caught - assert_equal ["#{path}/abc"], caught.backtrace - end - - def test_should_only_clean_assertion_failure_errors - clean_backtrace do - raise "can't touch this", [File.expand_path("#{File.dirname(__FILE__)}/../../lib/action_controller/assertions/abc")] - end - rescue => caught - assert !caught.backtrace.empty? - end -end - -class InferringClassNameTest < ActionController::TestCase - def test_determine_controller_class - assert_equal ContentController, determine_class("ContentControllerTest") - end - - def test_determine_controller_class_with_nonsense_name - assert_nil determine_class("HelloGoodBye") - end - - def test_determine_controller_class_with_sensible_name_where_no_controller_exists - assert_nil determine_class("NoControllerWithThisNameTest") - end - - private - def determine_class(name) - ActionController::TestCase.determine_default_controller_class(name) - end -end - -class CrazyNameTest < ActionController::TestCase - tests ContentController - - def test_controller_class_can_be_set_manually_not_just_inferred - assert_equal ContentController, self.class.controller_class - end -end - -class NamedRoutesControllerTest < ActionController::TestCase - tests ContentController - - def test_should_be_able_to_use_named_routes_before_a_request_is_done - with_routing do |set| - set.draw { |map| map.resources :contents } - assert_equal 'http://test.host/contents/new', new_content_url - assert_equal 'http://test.host/contents/1', content_url(:id => 1) - end - end -end diff --git a/vendor/rails/actionpack/test/controller/translation_test.rb b/vendor/rails/actionpack/test/controller/translation_test.rb deleted file mode 100644 index 0bf61a6..0000000 --- a/vendor/rails/actionpack/test/controller/translation_test.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'abstract_unit' - -# class TranslatingController < ActionController::Base -# end - -class TranslationControllerTest < Test::Unit::TestCase - def setup - @controller = ActionController::Base.new - end - - def test_action_controller_base_responds_to_translate - assert @controller.respond_to?(:translate) - end - - def test_action_controller_base_responds_to_t - assert @controller.respond_to?(:t) - end - - def test_action_controller_base_responds_to_localize - assert @controller.respond_to?(:localize) - end - - def test_action_controller_base_responds_to_l - assert @controller.respond_to?(:l) - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/controller/url_rewriter_test.rb b/vendor/rails/actionpack/test/controller/url_rewriter_test.rb deleted file mode 100644 index 863f841..0000000 --- a/vendor/rails/actionpack/test/controller/url_rewriter_test.rb +++ /dev/null @@ -1,359 +0,0 @@ -require 'abstract_unit' - -ActionController::UrlRewriter - -class UrlRewriterTests < ActionController::TestCase - def setup - @request = ActionController::TestRequest.new - @params = {} - @rewriter = ActionController::UrlRewriter.new(@request, @params) - end - - def test_port - assert_equal('http://test.host:1271/c/a/i', - @rewriter.rewrite(:controller => 'c', :action => 'a', :id => 'i', :port => 1271) - ) - end - - def test_protocol_with_and_without_separator - assert_equal('https://test.host/c/a/i', - @rewriter.rewrite(:protocol => 'https', :controller => 'c', :action => 'a', :id => 'i') - ) - - assert_equal('https://test.host/c/a/i', - @rewriter.rewrite(:protocol => 'https://', :controller => 'c', :action => 'a', :id => 'i') - ) - end - - def test_user_name_and_password - assert_equal( - 'http://david:secret@test.host/c/a/i', - @rewriter.rewrite(:user => "david", :password => "secret", :controller => 'c', :action => 'a', :id => 'i') - ) - end - - def test_user_name_and_password_with_escape_codes - assert_equal( - 'http://openid.aol.com%2Fnextangler:one+two%3F@test.host/c/a/i', - @rewriter.rewrite(:user => "openid.aol.com/nextangler", :password => "one two?", :controller => 'c', :action => 'a', :id => 'i') - ) - end - - def test_anchor - assert_equal( - 'http://test.host/c/a/i#anchor', - @rewriter.rewrite(:controller => 'c', :action => 'a', :id => 'i', :anchor => 'anchor') - ) - end - - def test_overwrite_params - @params[:controller] = 'hi' - @params[:action] = 'bye' - @params[:id] = '2' - - assert_equal '/hi/hi/2', @rewriter.rewrite(:only_path => true, :overwrite_params => {:action => 'hi'}) - u = @rewriter.rewrite(:only_path => false, :overwrite_params => {:action => 'hi'}) - assert_match %r(/hi/hi/2$), u - end - - def test_overwrite_removes_original - @params[:controller] = 'search' - @params[:action] = 'list' - @params[:list_page] = 1 - - assert_equal '/search/list?list_page=2', @rewriter.rewrite(:only_path => true, :overwrite_params => {"list_page" => 2}) - u = @rewriter.rewrite(:only_path => false, :overwrite_params => {:list_page => 2}) - assert_equal 'http://test.host/search/list?list_page=2', u - end - - def test_to_str - @params[:controller] = 'hi' - @params[:action] = 'bye' - @request.parameters[:id] = '2' - - assert_equal 'http://, test.host, /, hi, bye, {"id"=>"2"}', @rewriter.to_str - end - - def test_trailing_slash - options = {:controller => 'foo', :action => 'bar', :id => '3', :only_path => true} - assert_equal '/foo/bar/3', @rewriter.rewrite(options) - assert_equal '/foo/bar/3?query=string', @rewriter.rewrite(options.merge({:query => 'string'})) - options.update({:trailing_slash => true}) - assert_equal '/foo/bar/3/', @rewriter.rewrite(options) - options.update({:query => 'string'}) - assert_equal '/foo/bar/3/?query=string', @rewriter.rewrite(options) - end -end - -class UrlWriterTests < ActionController::TestCase - class W - include ActionController::UrlWriter - end - - def teardown - W.default_url_options.clear - end - - def add_host! - W.default_url_options[:host] = 'www.basecamphq.com' - end - - def test_exception_is_thrown_without_host - assert_raise RuntimeError do - W.new.url_for :controller => 'c', :action => 'a', :id => 'i' - end - end - - def test_anchor - assert_equal('/c/a#anchor', - W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :anchor => 'anchor') - ) - end - - def test_default_host - add_host! - assert_equal('http://www.basecamphq.com/c/a/i', - W.new.url_for(:controller => 'c', :action => 'a', :id => 'i') - ) - end - - def test_host_may_be_overridden - add_host! - assert_equal('http://37signals.basecamphq.com/c/a/i', - W.new.url_for(:host => '37signals.basecamphq.com', :controller => 'c', :action => 'a', :id => 'i') - ) - end - - def test_port - add_host! - assert_equal('http://www.basecamphq.com:3000/c/a/i', - W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :port => 3000) - ) - end - - def test_protocol - add_host! - assert_equal('https://www.basecamphq.com/c/a/i', - W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https') - ) - end - - def test_protocol_with_and_without_separator - add_host! - assert_equal('https://www.basecamphq.com/c/a/i', - W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https') - ) - assert_equal('https://www.basecamphq.com/c/a/i', - W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https://') - ) - end - - def test_trailing_slash - add_host! - options = {:controller => 'foo', :trailing_slash => true, :action => 'bar', :id => '33'} - assert_equal('http://www.basecamphq.com/foo/bar/33/', W.new.url_for(options) ) - end - - def test_trailing_slash_with_protocol - add_host! - options = { :trailing_slash => true,:protocol => 'https', :controller => 'foo', :action => 'bar', :id => '33'} - assert_equal('https://www.basecamphq.com/foo/bar/33/', W.new.url_for(options) ) - assert_equal 'https://www.basecamphq.com/foo/bar/33/?query=string', W.new.url_for(options.merge({:query => 'string'})) - end - - def test_trailing_slash_with_only_path - options = {:controller => 'foo', :trailing_slash => true} - assert_equal '/foo/', W.new.url_for(options.merge({:only_path => true})) - options.update({:action => 'bar', :id => '33'}) - assert_equal '/foo/bar/33/', W.new.url_for(options.merge({:only_path => true})) - assert_equal '/foo/bar/33/?query=string', W.new.url_for(options.merge({:query => 'string',:only_path => true})) - end - - def test_trailing_slash_with_anchor - options = {:trailing_slash => true, :controller => 'foo', :action => 'bar', :id => '33', :only_path => true, :anchor=> 'chapter7'} - assert_equal '/foo/bar/33/#chapter7', W.new.url_for(options) - assert_equal '/foo/bar/33/?query=string#chapter7', W.new.url_for(options.merge({:query => 'string'})) - end - - def test_trailing_slash_with_params - url = W.new.url_for(:trailing_slash => true, :only_path => true, :controller => 'cont', :action => 'act', :p1 => 'cafe', :p2 => 'link') - params = extract_params(url) - assert_equal params[0], { :p1 => 'cafe' }.to_query - assert_equal params[1], { :p2 => 'link' }.to_query - end - - def test_relative_url_root_is_respected - orig_relative_url_root = ActionController::Base.relative_url_root - ActionController::Base.relative_url_root = '/subdir' - - add_host! - assert_equal('https://www.basecamphq.com/subdir/c/a/i', - W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https') - ) - ensure - ActionController::Base.relative_url_root = orig_relative_url_root - end - - def test_named_routes - ActionController::Routing::Routes.draw do |map| - map.no_args '/this/is/verbose', :controller => 'home', :action => 'index' - map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index' - map.connect ':controller/:action/:id' - end - - # We need to create a new class in order to install the new named route. - kls = Class.new { include ActionController::UrlWriter } - controller = kls.new - assert controller.respond_to?(:home_url) - assert_equal 'http://www.basecamphq.com/home/sweet/home/again', - controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again') - - assert_equal("/home/sweet/home/alabama", controller.send(:home_path, :user => 'alabama', :host => 'unused')) - assert_equal("http://www.basecamphq.com/home/sweet/home/alabama", controller.send(:home_url, :user => 'alabama', :host => 'www.basecamphq.com')) - assert_equal("http://www.basecamphq.com/this/is/verbose", controller.send(:no_args_url, :host=>'www.basecamphq.com')) - ensure - ActionController::Routing::Routes.load! - end - - def test_relative_url_root_is_respected_for_named_routes - orig_relative_url_root = ActionController::Base.relative_url_root - ActionController::Base.relative_url_root = '/subdir' - - ActionController::Routing::Routes.draw do |map| - map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index' - end - - kls = Class.new { include ActionController::UrlWriter } - controller = kls.new - - assert_equal 'http://www.basecamphq.com/subdir/home/sweet/home/again', - controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again') - ensure - ActionController::Routing::Routes.load! - ActionController::Base.relative_url_root = orig_relative_url_root - end - - def test_only_path - ActionController::Routing::Routes.draw do |map| - map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index' - map.connect ':controller/:action/:id' - end - - # We need to create a new class in order to install the new named route. - kls = Class.new { include ActionController::UrlWriter } - controller = kls.new - assert controller.respond_to?(:home_url) - assert_equal '/brave/new/world', - controller.send(:url_for, :controller => 'brave', :action => 'new', :id => 'world', :only_path => true) - - assert_equal("/home/sweet/home/alabama", controller.send(:home_url, :user => 'alabama', :host => 'unused', :only_path => true)) - assert_equal("/home/sweet/home/alabama", controller.send(:home_path, 'alabama')) - ensure - ActionController::Routing::Routes.load! - end - - def test_one_parameter - assert_equal('/c/a?param=val', - W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :param => 'val') - ) - end - - def test_two_parameters - url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :p1 => 'X1', :p2 => 'Y2') - params = extract_params(url) - assert_equal params[0], { :p1 => 'X1' }.to_query - assert_equal params[1], { :p2 => 'Y2' }.to_query - end - - def test_hash_parameter - url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :query => {:name => 'Bob', :category => 'prof'}) - params = extract_params(url) - assert_equal params[0], { 'query[category]' => 'prof' }.to_query - assert_equal params[1], { 'query[name]' => 'Bob' }.to_query - end - - def test_array_parameter - url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :query => ['Bob', 'prof']) - params = extract_params(url) - assert_equal params[0], { 'query[]' => 'Bob' }.to_query - assert_equal params[1], { 'query[]' => 'prof' }.to_query - end - - def test_hash_recursive_parameters - url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :query => {:person => {:name => 'Bob', :position => 'prof'}, :hobby => 'piercing'}) - params = extract_params(url) - assert_equal params[0], { 'query[hobby]' => 'piercing' }.to_query - assert_equal params[1], { 'query[person][name]' => 'Bob' }.to_query - assert_equal params[2], { 'query[person][position]' => 'prof' }.to_query - end - - def test_hash_recursive_and_array_parameters - url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :id => 101, :query => {:person => {:name => 'Bob', :position => ['prof', 'art director']}, :hobby => 'piercing'}) - assert_match %r(^/c/a/101), url - params = extract_params(url) - assert_equal params[0], { 'query[hobby]' => 'piercing' }.to_query - assert_equal params[1], { 'query[person][name]' => 'Bob' }.to_query - assert_equal params[2], { 'query[person][position][]' => 'prof' }.to_query - assert_equal params[3], { 'query[person][position][]' => 'art director' }.to_query - end - - def test_path_generation_for_symbol_parameter_keys - assert_generates("/image", :controller=> :image) - end - - def test_named_routes_with_nil_keys - ActionController::Routing::Routes.clear! - ActionController::Routing::Routes.draw do |map| - map.main '', :controller => 'posts' - map.resources :posts - map.connect ':controller/:action/:id' - end - # We need to create a new class in order to install the new named route. - kls = Class.new { include ActionController::UrlWriter } - kls.default_url_options[:host] = 'www.basecamphq.com' - - controller = kls.new - params = {:action => :index, :controller => :posts, :format => :xml} - assert_equal("http://www.basecamphq.com/posts.xml", controller.send(:url_for, params)) - params[:format] = nil - assert_equal("http://www.basecamphq.com/", controller.send(:url_for, params)) - ensure - ActionController::Routing::Routes.load! - end - - def test_formatted_url_methods_are_deprecated - ActionController::Routing::Routes.draw do |map| - map.resources :posts - end - # We need to create a new class in order to install the new named route. - kls = Class.new { include ActionController::UrlWriter } - controller = kls.new - params = {:id => 1, :format => :xml} - assert_deprecated do - assert_equal("/posts/1.xml", controller.send(:formatted_post_path, params)) - end - assert_deprecated do - assert_equal("/posts/1.xml", controller.send(:formatted_post_path, 1, :xml)) - end - ensure - ActionController::Routing::Routes.load! - end - - def test_multiple_includes_maintain_distinct_options - first_class = Class.new { include ActionController::UrlWriter } - second_class = Class.new { include ActionController::UrlWriter } - - first_host, second_host = 'firsthost.com', 'secondhost.com' - - first_class.default_url_options[:host] = first_host - second_class.default_url_options[:host] = second_host - - assert_equal first_class.default_url_options[:host], first_host - assert_equal second_class.default_url_options[:host], second_host - end - - private - def extract_params(url) - url.split('?', 2).last.split('&') - end -end diff --git a/vendor/rails/actionpack/test/controller/verification_test.rb b/vendor/rails/actionpack/test/controller/verification_test.rb deleted file mode 100644 index 418a81b..0000000 --- a/vendor/rails/actionpack/test/controller/verification_test.rb +++ /dev/null @@ -1,270 +0,0 @@ -require 'abstract_unit' - -class VerificationTest < ActionController::TestCase - class TestController < ActionController::Base - verify :only => :guarded_one, :params => "one", - :add_flash => { :error => 'unguarded' }, - :redirect_to => { :action => "unguarded" } - - verify :only => :guarded_two, :params => %w( one two ), - :redirect_to => { :action => "unguarded" } - - verify :only => :guarded_with_flash, :params => "one", - :add_flash => { :notice => "prereqs failed" }, - :redirect_to => { :action => "unguarded" } - - verify :only => :guarded_in_session, :session => "one", - :redirect_to => { :action => "unguarded" } - - verify :only => [:multi_one, :multi_two], :session => %w( one two ), - :redirect_to => { :action => "unguarded" } - - verify :only => :guarded_by_method, :method => :post, - :redirect_to => { :action => "unguarded" } - - verify :only => :guarded_by_xhr, :xhr => true, - :redirect_to => { :action => "unguarded" } - - verify :only => :guarded_by_not_xhr, :xhr => false, - :redirect_to => { :action => "unguarded" } - - before_filter :unconditional_redirect, :only => :two_redirects - verify :only => :two_redirects, :method => :post, - :redirect_to => { :action => "unguarded" } - - verify :only => :must_be_post, :method => :post, :render => { :status => 405, :text => "Must be post" }, :add_headers => { "Allow" => "POST" } - - verify :only => :guarded_one_for_named_route_test, :params => "one", - :redirect_to => :foo_url - - verify :only => :no_default_action, :params => "santa" - - verify :only => :guarded_with_back, :method => :post, - :redirect_to => :back - - def guarded_one - render :text => "#{params[:one]}" - end - - def guarded_one_for_named_route_test - render :text => "#{params[:one]}" - end - - def guarded_with_flash - render :text => "#{params[:one]}" - end - - def guarded_two - render :text => "#{params[:one]}:#{params[:two]}" - end - - def guarded_in_session - render :text => "#{session["one"]}" - end - - def multi_one - render :text => "#{session["one"]}:#{session["two"]}" - end - - def multi_two - render :text => "#{session["two"]}:#{session["one"]}" - end - - def guarded_by_method - render :text => "#{request.method}" - end - - def guarded_by_xhr - render :text => "#{request.xhr?}" - end - - def guarded_by_not_xhr - render :text => "#{request.xhr?}" - end - - def unguarded - render :text => "#{params[:one]}" - end - - def two_redirects - render :nothing => true - end - - def must_be_post - render :text => "Was a post!" - end - - def guarded_with_back - render :text => "#{params[:one]}" - end - - def no_default_action - # Will never run - end - - protected - def rescue_action(e) raise end - - def unconditional_redirect - redirect_to :action => "unguarded" - end - end - - def setup - @controller = TestController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - ActionController::Routing::Routes.add_named_route :foo, '/foo', :controller => 'test', :action => 'foo' - end - - def test_using_symbol_back_with_no_referrer - assert_raise(ActionController::RedirectBackError) { get :guarded_with_back } - end - - def test_using_symbol_back_redirects_to_referrer - @request.env["HTTP_REFERER"] = "/foo" - get :guarded_with_back - assert_redirected_to '/foo' - end - - def test_no_deprecation_warning_for_named_route - assert_not_deprecated do - get :guarded_one_for_named_route_test, :two => "not one" - assert_redirected_to '/foo' - end - end - - def test_guarded_one_with_prereqs - get :guarded_one, :one => "here" - assert_equal "here", @response.body - end - - def test_guarded_one_without_prereqs - get :guarded_one - assert_redirected_to :action => "unguarded" - assert_equal 'unguarded', flash[:error] - end - - def test_guarded_with_flash_with_prereqs - get :guarded_with_flash, :one => "here" - assert_equal "here", @response.body - assert flash.empty? - end - - def test_guarded_with_flash_without_prereqs - get :guarded_with_flash - assert_redirected_to :action => "unguarded" - assert_equal "prereqs failed", flash[:notice] - end - - def test_guarded_two_with_prereqs - get :guarded_two, :one => "here", :two => "there" - assert_equal "here:there", @response.body - end - - def test_guarded_two_without_prereqs_one - get :guarded_two, :two => "there" - assert_redirected_to :action => "unguarded" - end - - def test_guarded_two_without_prereqs_two - get :guarded_two, :one => "here" - assert_redirected_to :action => "unguarded" - end - - def test_guarded_two_without_prereqs_both - get :guarded_two - assert_redirected_to :action => "unguarded" - end - - def test_unguarded_with_params - get :unguarded, :one => "here" - assert_equal "here", @response.body - end - - def test_unguarded_without_params - get :unguarded - assert_equal "", @response.body - end - - def test_guarded_in_session_with_prereqs - get :guarded_in_session, {}, "one" => "here" - assert_equal "here", @response.body - end - - def test_guarded_in_session_without_prereqs - get :guarded_in_session - assert_redirected_to :action => "unguarded" - end - - def test_multi_one_with_prereqs - get :multi_one, {}, "one" => "here", "two" => "there" - assert_equal "here:there", @response.body - end - - def test_multi_one_without_prereqs - get :multi_one - assert_redirected_to :action => "unguarded" - end - - def test_multi_two_with_prereqs - get :multi_two, {}, "one" => "here", "two" => "there" - assert_equal "there:here", @response.body - end - - def test_multi_two_without_prereqs - get :multi_two - assert_redirected_to :action => "unguarded" - end - - def test_guarded_by_method_with_prereqs - post :guarded_by_method - assert_equal "post", @response.body - end - - def test_guarded_by_method_without_prereqs - get :guarded_by_method - assert_redirected_to :action => "unguarded" - end - - def test_guarded_by_xhr_with_prereqs - xhr :post, :guarded_by_xhr - assert_equal "true", @response.body - end - - def test_guarded_by_xhr_without_prereqs - get :guarded_by_xhr - assert_redirected_to :action => "unguarded" - end - - def test_guarded_by_not_xhr_with_prereqs - get :guarded_by_not_xhr - assert_equal "false", @response.body - end - - def test_guarded_by_not_xhr_without_prereqs - xhr :post, :guarded_by_not_xhr - assert_redirected_to :action => "unguarded" - end - - def test_guarded_post_and_calls_render_succeeds - post :must_be_post - assert_equal "Was a post!", @response.body - end - - def test_default_failure_should_be_a_bad_request - post :no_default_action - assert_response :bad_request - end - - def test_guarded_post_and_calls_render_fails_and_sets_allow_header - get :must_be_post - assert_response 405 - assert_equal "Must be post", @response.body - assert_equal "POST", @response.headers["Allow"] - end - - def test_second_redirect - assert_nothing_raised { get :two_redirects } - end -end diff --git a/vendor/rails/actionpack/test/controller/view_paths_test.rb b/vendor/rails/actionpack/test/controller/view_paths_test.rb deleted file mode 100644 index 8ea13fb..0000000 --- a/vendor/rails/actionpack/test/controller/view_paths_test.rb +++ /dev/null @@ -1,141 +0,0 @@ -require 'abstract_unit' - -class ViewLoadPathsTest < ActionController::TestCase - class TestController < ActionController::Base - def self.controller_path() "test" end - def rescue_action(e) raise end - - before_filter :add_view_path, :only => :hello_world_at_request_time - - def hello_world() end - def hello_world_at_request_time() render(:action => 'hello_world') end - - private - def add_view_path - prepend_view_path "#{FIXTURE_LOAD_PATH}/override" - end - end - - class Test::SubController < ActionController::Base - layout 'test/sub' - def hello_world; render(:template => 'test/hello_world'); end - end - - def setup - TestController.view_paths = nil - - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - - @controller = TestController.new - # Following is needed in order to setup @controller.template object properly - @controller.send :initialize_template_class, @response - @controller.send :assign_shortcuts, @request, @response - - # Track the last warning. - @old_behavior = ActiveSupport::Deprecation.behavior - @last_message = nil - ActiveSupport::Deprecation.behavior = Proc.new { |message, callback| @last_message = message } - end - - def teardown - ActiveSupport::Deprecation.behavior = @old_behavior - end - - def test_template_load_path_was_set_correctly - assert_equal [FIXTURE_LOAD_PATH], @controller.view_paths.map(&:to_s) - end - - def test_controller_appends_view_path_correctly - @controller.append_view_path 'foo' - assert_equal [FIXTURE_LOAD_PATH, 'foo'], @controller.view_paths.map(&:to_s) - - @controller.append_view_path(%w(bar baz)) - assert_equal [FIXTURE_LOAD_PATH, 'foo', 'bar', 'baz'], @controller.view_paths.map(&:to_s) - - @controller.append_view_path(FIXTURE_LOAD_PATH) - assert_equal [FIXTURE_LOAD_PATH, 'foo', 'bar', 'baz', FIXTURE_LOAD_PATH], @controller.view_paths.map(&:to_s) - end - - def test_controller_prepends_view_path_correctly - @controller.prepend_view_path 'baz' - assert_equal ['baz', FIXTURE_LOAD_PATH], @controller.view_paths.map(&:to_s) - - @controller.prepend_view_path(%w(foo bar)) - assert_equal ['foo', 'bar', 'baz', FIXTURE_LOAD_PATH], @controller.view_paths.map(&:to_s) - - @controller.prepend_view_path(FIXTURE_LOAD_PATH) - assert_equal [FIXTURE_LOAD_PATH, 'foo', 'bar', 'baz', FIXTURE_LOAD_PATH], @controller.view_paths.map(&:to_s) - end - - def test_template_appends_view_path_correctly - @controller.instance_variable_set :@template, ActionView::Base.new(TestController.view_paths, {}, @controller) - class_view_paths = TestController.view_paths - - @controller.append_view_path 'foo' - assert_equal [FIXTURE_LOAD_PATH, 'foo'], @controller.view_paths.map(&:to_s) - - @controller.append_view_path(%w(bar baz)) - assert_equal [FIXTURE_LOAD_PATH, 'foo', 'bar', 'baz'], @controller.view_paths.map(&:to_s) - assert_equal class_view_paths, TestController.view_paths - end - - def test_template_prepends_view_path_correctly - @controller.instance_variable_set :@template, ActionView::Base.new(TestController.view_paths, {}, @controller) - class_view_paths = TestController.view_paths - - @controller.prepend_view_path 'baz' - assert_equal ['baz', FIXTURE_LOAD_PATH], @controller.view_paths.map(&:to_s) - - @controller.prepend_view_path(%w(foo bar)) - assert_equal ['foo', 'bar', 'baz', FIXTURE_LOAD_PATH], @controller.view_paths.map(&:to_s) - assert_equal class_view_paths, TestController.view_paths - end - - def test_view_paths - get :hello_world - assert_response :success - assert_equal "Hello world!", @response.body - end - - def test_view_paths_override - TestController.prepend_view_path "#{FIXTURE_LOAD_PATH}/override" - get :hello_world - assert_response :success - assert_equal "Hello overridden world!", @response.body - end - - def test_view_paths_override_for_layouts_in_controllers_with_a_module - @controller = Test::SubController.new - Test::SubController.view_paths = [ "#{FIXTURE_LOAD_PATH}/override", FIXTURE_LOAD_PATH, "#{FIXTURE_LOAD_PATH}/override2" ] - get :hello_world - assert_response :success - assert_equal "layout: Hello overridden world!", @response.body - end - - def test_view_paths_override_at_request_time - get :hello_world_at_request_time - assert_response :success - assert_equal "Hello overridden world!", @response.body - end - - def test_inheritance - original_load_paths = ActionController::Base.view_paths - - self.class.class_eval %{ - class A < ActionController::Base; end - class B < A; end - class C < ActionController::Base; end - } - - A.view_paths = ['a/path'] - - assert_equal ['a/path'], A.view_paths.map(&:to_s) - assert_equal A.view_paths, B.view_paths - assert_equal original_load_paths, C.view_paths - - C.view_paths = [] - assert_nothing_raised { C.view_paths << 'c/path' } - assert_equal ['c/path'], C.view_paths.map(&:to_s) - end -end diff --git a/vendor/rails/actionpack/test/controller/webservice_test.rb b/vendor/rails/actionpack/test/controller/webservice_test.rb deleted file mode 100644 index e89d6bb..0000000 --- a/vendor/rails/actionpack/test/controller/webservice_test.rb +++ /dev/null @@ -1,260 +0,0 @@ -require 'abstract_unit' - -class WebServiceTest < ActionController::IntegrationTest - class TestController < ActionController::Base - def assign_parameters - if params[:full] - render :text => dump_params_keys - else - render :text => (params.keys - ['controller', 'action']).sort.join(", ") - end - end - - def dump_params_keys(hash = params) - hash.keys.sort.inject("") do |s, k| - value = hash[k] - value = Hash === value ? "(#{dump_params_keys(value)})" : "" - s << ", " unless s.empty? - s << "#{k}#{value}" - end - end - - def rescue_action(e) raise end - end - - def setup - @controller = TestController.new - @default_param_parsers = ActionController::Base.param_parsers.dup - end - - def teardown - ActionController::Base.param_parsers = @default_param_parsers - end - - def test_check_parameters - with_test_route_set do - get "/" - assert_equal '', @controller.response.body - end - end - - def test_post_xml - with_test_route_set do - post "/", '<entry attributed="true"><summary>content...</summary></entry>', - {'CONTENT_TYPE' => 'application/xml'} - - assert_equal 'entry', @controller.response.body - assert @controller.params.has_key?(:entry) - assert_equal 'content...', @controller.params["entry"]['summary'] - assert_equal 'true', @controller.params["entry"]['attributed'] - end - end - - def test_put_xml - with_test_route_set do - put "/", '<entry attributed="true"><summary>content...</summary></entry>', - {'CONTENT_TYPE' => 'application/xml'} - - assert_equal 'entry', @controller.response.body - assert @controller.params.has_key?(:entry) - assert_equal 'content...', @controller.params["entry"]['summary'] - assert_equal 'true', @controller.params["entry"]['attributed'] - end - end - - def test_put_xml_using_a_type_node - with_test_route_set do - put "/", '<type attributed="true"><summary>content...</summary></type>', - {'CONTENT_TYPE' => 'application/xml'} - - assert_equal 'type', @controller.response.body - assert @controller.params.has_key?(:type) - assert_equal 'content...', @controller.params["type"]['summary'] - assert_equal 'true', @controller.params["type"]['attributed'] - end - end - - def test_put_xml_using_a_type_node_and_attribute - with_test_route_set do - put "/", '<type attributed="true"><summary type="boolean">false</summary></type>', - {'CONTENT_TYPE' => 'application/xml'} - - assert_equal 'type', @controller.response.body - assert @controller.params.has_key?(:type) - assert_equal false, @controller.params["type"]['summary'] - assert_equal 'true', @controller.params["type"]['attributed'] - end - end - - def test_post_xml_using_a_type_node - with_test_route_set do - post "/", '<font attributed="true"><type>arial</type></font>', - {'CONTENT_TYPE' => 'application/xml'} - - assert_equal 'font', @controller.response.body - assert @controller.params.has_key?(:font) - assert_equal 'arial', @controller.params['font']['type'] - assert_equal 'true', @controller.params["font"]['attributed'] - end - end - - def test_post_xml_using_a_root_node_named_type - with_test_route_set do - post "/", '<type type="integer">33</type>', - {'CONTENT_TYPE' => 'application/xml'} - - assert @controller.params.has_key?(:type) - assert_equal 33, @controller.params['type'] - end - end - - def test_post_xml_using_an_attributted_node_named_type - with_test_route_set do - ActionController::Base.param_parsers[Mime::XML] = Proc.new { |data| Hash.from_xml(data)['request'].with_indifferent_access } - post "/", '<request><type type="string">Arial,12</type><z>3</z></request>', - {'CONTENT_TYPE' => 'application/xml'} - - assert_equal 'type, z', @controller.response.body - assert @controller.params.has_key?(:type) - assert_equal 'Arial,12', @controller.params['type'], @controller.params.inspect - assert_equal '3', @controller.params['z'], @controller.params.inspect - end - end - - def test_register_and_use_yaml - with_test_route_set do - ActionController::Base.param_parsers[Mime::YAML] = Proc.new { |d| YAML.load(d) } - post "/", {"entry" => "loaded from yaml"}.to_yaml, - {'CONTENT_TYPE' => 'application/x-yaml'} - - assert_equal 'entry', @controller.response.body - assert @controller.params.has_key?(:entry) - assert_equal 'loaded from yaml', @controller.params["entry"] - end - end - - def test_register_and_use_yaml_as_symbol - with_test_route_set do - ActionController::Base.param_parsers[Mime::YAML] = :yaml - post "/", {"entry" => "loaded from yaml"}.to_yaml, - {'CONTENT_TYPE' => 'application/x-yaml'} - - assert_equal 'entry', @controller.response.body - assert @controller.params.has_key?(:entry) - assert_equal 'loaded from yaml', @controller.params["entry"] - end - end - - def test_register_and_use_xml_simple - with_test_route_set do - ActionController::Base.param_parsers[Mime::XML] = Proc.new { |data| Hash.from_xml(data)['request'].with_indifferent_access } - post "/", '<request><summary>content...</summary><title>SimpleXml</title></request>', - {'CONTENT_TYPE' => 'application/xml'} - - assert_equal 'summary, title', @controller.response.body - assert @controller.params.has_key?(:summary) - assert @controller.params.has_key?(:title) - assert_equal 'content...', @controller.params["summary"] - assert_equal 'SimpleXml', @controller.params["title"] - end - end - - def test_use_xml_ximple_with_empty_request - with_test_route_set do - ActionController::Base.param_parsers[Mime::XML] = :xml_simple - assert_nothing_raised { post "/", "", {'CONTENT_TYPE' => 'application/xml'} } - assert_equal "", @controller.response.body - end - end - - def test_dasherized_keys_as_xml - with_test_route_set do - ActionController::Base.param_parsers[Mime::XML] = :xml_simple - post "/?full=1", "<first-key>\n<sub-key>...</sub-key>\n</first-key>", - {'CONTENT_TYPE' => 'application/xml'} - assert_equal 'action, controller, first_key(sub_key), full', @controller.response.body - assert_equal "...", @controller.params[:first_key][:sub_key] - end - end - - def test_typecast_as_xml - with_test_route_set do - ActionController::Base.param_parsers[Mime::XML] = :xml_simple - xml = <<-XML - <data> - <a type="integer">15</a> - <b type="boolean">false</b> - <c type="boolean">true</c> - <d type="date">2005-03-17</d> - <e type="datetime">2005-03-17T21:41:07Z</e> - <f>unparsed</f> - <g type="integer">1</g> - <g>hello</g> - <g type="date">1974-07-25</g> - </data> - XML - post "/", xml, {'CONTENT_TYPE' => 'application/xml'} - - params = @controller.params - assert_equal 15, params[:data][:a] - assert_equal false, params[:data][:b] - assert_equal true, params[:data][:c] - assert_equal Date.new(2005,3,17), params[:data][:d] - assert_equal Time.utc(2005,3,17,21,41,7), params[:data][:e] - assert_equal "unparsed", params[:data][:f] - assert_equal [1, "hello", Date.new(1974,7,25)], params[:data][:g] - end - end - - def test_entities_unescaped_as_xml_simple - with_test_route_set do - ActionController::Base.param_parsers[Mime::XML] = :xml_simple - xml = <<-XML - <data>&lt;foo &quot;bar&apos;s&quot; &amp; friends&gt;</data> - XML - post "/", xml, {'CONTENT_TYPE' => 'application/xml'} - assert_equal %(<foo "bar's" & friends>), @controller.params[:data] - end - end - - def test_typecast_as_yaml - with_test_route_set do - ActionController::Base.param_parsers[Mime::YAML] = :yaml - yaml = <<-YAML - --- - data: - a: 15 - b: false - c: true - d: 2005-03-17 - e: 2005-03-17T21:41:07Z - f: unparsed - g: - - 1 - - hello - - 1974-07-25 - YAML - post "/", yaml, {'CONTENT_TYPE' => 'application/x-yaml'} - params = @controller.params - assert_equal 15, params[:data][:a] - assert_equal false, params[:data][:b] - assert_equal true, params[:data][:c] - assert_equal Date.new(2005,3,17), params[:data][:d] - assert_equal Time.utc(2005,3,17,21,41,7), params[:data][:e] - assert_equal "unparsed", params[:data][:f] - assert_equal [1, "hello", Date.new(1974,7,25)], params[:data][:g] - end - end - - private - def with_test_route_set - with_routing do |set| - set.draw do |map| - map.with_options :controller => "web_service_test/test" do |c| - c.connect "/", :action => "assign_parameters" - end - end - yield - end - end -end diff --git a/vendor/rails/actionpack/test/fixtures/_top_level_partial.html.erb b/vendor/rails/actionpack/test/fixtures/_top_level_partial.html.erb deleted file mode 100644 index 0b1c2e4..0000000 --- a/vendor/rails/actionpack/test/fixtures/_top_level_partial.html.erb +++ /dev/null @@ -1 +0,0 @@ -top level partial html \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/_top_level_partial_only.erb b/vendor/rails/actionpack/test/fixtures/_top_level_partial_only.erb deleted file mode 100644 index 44f25b6..0000000 --- a/vendor/rails/actionpack/test/fixtures/_top_level_partial_only.erb +++ /dev/null @@ -1 +0,0 @@ -top level partial \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/addresses/list.erb b/vendor/rails/actionpack/test/fixtures/addresses/list.erb deleted file mode 100644 index c75e01e..0000000 --- a/vendor/rails/actionpack/test/fixtures/addresses/list.erb +++ /dev/null @@ -1 +0,0 @@ -We only need to get this far! diff --git a/vendor/rails/actionpack/test/fixtures/alternate_helpers/foo_helper.rb b/vendor/rails/actionpack/test/fixtures/alternate_helpers/foo_helper.rb deleted file mode 100644 index a956fce..0000000 --- a/vendor/rails/actionpack/test/fixtures/alternate_helpers/foo_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -module FooHelper - def baz() end -end diff --git a/vendor/rails/actionpack/test/fixtures/bad_customers/_bad_customer.html.erb b/vendor/rails/actionpack/test/fixtures/bad_customers/_bad_customer.html.erb deleted file mode 100644 index d22af43..0000000 --- a/vendor/rails/actionpack/test/fixtures/bad_customers/_bad_customer.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= greeting %> bad customer: <%= bad_customer.name %><%= bad_customer_counter %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/companies.yml b/vendor/rails/actionpack/test/fixtures/companies.yml deleted file mode 100644 index 707f72a..0000000 --- a/vendor/rails/actionpack/test/fixtures/companies.yml +++ /dev/null @@ -1,24 +0,0 @@ -thirty_seven_signals: - id: 1 - name: 37Signals - rating: 4 - -TextDrive: - id: 2 - name: TextDrive - rating: 4 - -PlanetArgon: - id: 3 - name: Planet Argon - rating: 4 - -Google: - id: 4 - name: Google - rating: 4 - -Ionist: - id: 5 - name: Ioni.st - rating: 4 \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/company.rb b/vendor/rails/actionpack/test/fixtures/company.rb deleted file mode 100644 index cbbd0ed..0000000 --- a/vendor/rails/actionpack/test/fixtures/company.rb +++ /dev/null @@ -1,10 +0,0 @@ -class Company < ActiveRecord::Base - has_one :mascot - attr_protected :rating - set_sequence_name :companies_nonstd_seq - - validates_presence_of :name - def validate - errors.add('rating', 'rating should not be 2') if rating == 2 - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/content_type/render_default_content_types_for_respond_to.rhtml b/vendor/rails/actionpack/test/fixtures/content_type/render_default_content_types_for_respond_to.rhtml deleted file mode 100644 index 25dc746..0000000 --- a/vendor/rails/actionpack/test/fixtures/content_type/render_default_content_types_for_respond_to.rhtml +++ /dev/null @@ -1 +0,0 @@ -<hello>world</hello> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rhtml.rhtml b/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rhtml.rhtml deleted file mode 100644 index c7926d4..0000000 --- a/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rhtml.rhtml +++ /dev/null @@ -1 +0,0 @@ -<%= 'hello world!' %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rjs.rjs b/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rjs.rjs deleted file mode 100644 index 8d614d0..0000000 --- a/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rjs.rjs +++ /dev/null @@ -1 +0,0 @@ -page.alert 'hello world!' \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rxml.rxml b/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rxml.rxml deleted file mode 100644 index 598d62e..0000000 --- a/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rxml.rxml +++ /dev/null @@ -1 +0,0 @@ -xml.p "Hello world!" \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/customers/_customer.html.erb b/vendor/rails/actionpack/test/fixtures/customers/_customer.html.erb deleted file mode 100644 index 483571e..0000000 --- a/vendor/rails/actionpack/test/fixtures/customers/_customer.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= greeting %>: <%= customer.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/db_definitions/sqlite.sql b/vendor/rails/actionpack/test/fixtures/db_definitions/sqlite.sql deleted file mode 100644 index 8e1947d..0000000 --- a/vendor/rails/actionpack/test/fixtures/db_definitions/sqlite.sql +++ /dev/null @@ -1,49 +0,0 @@ -CREATE TABLE 'companies' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'name' TEXT DEFAULT NULL, - 'rating' INTEGER DEFAULT 1 -); - -CREATE TABLE 'replies' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'content' text, - 'created_at' datetime, - 'updated_at' datetime, - 'topic_id' integer, - 'developer_id' integer -); - -CREATE TABLE 'topics' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'title' varchar(255), - 'subtitle' varchar(255), - 'content' text, - 'created_at' datetime, - 'updated_at' datetime -); - -CREATE TABLE 'developers' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'name' TEXT DEFAULT NULL, - 'salary' INTEGER DEFAULT 70000, - 'created_at' DATETIME DEFAULT NULL, - 'updated_at' DATETIME DEFAULT NULL -); - -CREATE TABLE 'projects' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'name' TEXT DEFAULT NULL -); - -CREATE TABLE 'developers_projects' ( - 'developer_id' INTEGER NOT NULL, - 'project_id' INTEGER NOT NULL, - 'joined_on' DATE DEFAULT NULL, - 'access_level' INTEGER DEFAULT 1 -); - -CREATE TABLE 'mascots' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'company_id' INTEGER NOT NULL, - 'name' TEXT DEFAULT NULL -); \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/developer.rb b/vendor/rails/actionpack/test/fixtures/developer.rb deleted file mode 100644 index c70eda3..0000000 --- a/vendor/rails/actionpack/test/fixtures/developer.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Developer < ActiveRecord::Base - has_and_belongs_to_many :projects - has_many :replies - has_many :topics, :through => :replies -end - -class DeVeLoPeR < ActiveRecord::Base - set_table_name "developers" -end diff --git a/vendor/rails/actionpack/test/fixtures/developers.yml b/vendor/rails/actionpack/test/fixtures/developers.yml deleted file mode 100644 index 308bf75..0000000 --- a/vendor/rails/actionpack/test/fixtures/developers.yml +++ /dev/null @@ -1,21 +0,0 @@ -david: - id: 1 - name: David - salary: 80000 - -jamis: - id: 2 - name: Jamis - salary: 150000 - -<% for digit in 3..10 %> -dev_<%= digit %>: - id: <%= digit %> - name: fixture_<%= digit %> - salary: 100000 -<% end %> - -poor_jamis: - id: 11 - name: Jamis - salary: 9000 \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/developers/_developer.erb b/vendor/rails/actionpack/test/fixtures/developers/_developer.erb deleted file mode 100644 index 904a313..0000000 --- a/vendor/rails/actionpack/test/fixtures/developers/_developer.erb +++ /dev/null @@ -1 +0,0 @@ -<%= developer.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/developers_projects.yml b/vendor/rails/actionpack/test/fixtures/developers_projects.yml deleted file mode 100644 index cee359c..0000000 --- a/vendor/rails/actionpack/test/fixtures/developers_projects.yml +++ /dev/null @@ -1,13 +0,0 @@ -david_action_controller: - developer_id: 1 - project_id: 2 - joined_on: 2004-10-10 - -david_active_record: - developer_id: 1 - project_id: 1 - joined_on: 2004-10-10 - -jamis_active_record: - developer_id: 2 - project_id: 1 \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/fun/games/_game.erb b/vendor/rails/actionpack/test/fixtures/fun/games/_game.erb deleted file mode 100644 index d51b7b3..0000000 --- a/vendor/rails/actionpack/test/fixtures/fun/games/_game.erb +++ /dev/null @@ -1 +0,0 @@ -<%= game.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/fun/games/hello_world.erb b/vendor/rails/actionpack/test/fixtures/fun/games/hello_world.erb deleted file mode 100644 index 1ebfbe2..0000000 --- a/vendor/rails/actionpack/test/fixtures/fun/games/hello_world.erb +++ /dev/null @@ -1 +0,0 @@ -Living in a nested world \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/fun/serious/games/_game.erb b/vendor/rails/actionpack/test/fixtures/fun/serious/games/_game.erb deleted file mode 100644 index d51b7b3..0000000 --- a/vendor/rails/actionpack/test/fixtures/fun/serious/games/_game.erb +++ /dev/null @@ -1 +0,0 @@ -<%= game.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/_partial.erb b/vendor/rails/actionpack/test/fixtures/functional_caching/_partial.erb deleted file mode 100644 index d0e4f72..0000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/_partial.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% cache do %> -Fragment caching in a partial -<% end %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.html.erb b/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.html.erb deleted file mode 100644 index d7f43ad..0000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<body> -<% cache do %><p>ERB</p><% end %> -</body> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs b/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs deleted file mode 100644 index 057f15e..0000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs +++ /dev/null @@ -1,6 +0,0 @@ -page.assign 'title', 'Hey' -cache do - page['element_1'].visual_effect :highlight - page['element_2'].visual_effect :highlight -end -page.assign 'footer', 'Bye' diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.xml.builder b/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.xml.builder deleted file mode 100644 index efdcc28..0000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.xml.builder +++ /dev/null @@ -1,5 +0,0 @@ -xml.body do - cache do - xml.p "Builder" - end -end diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/fragment_cached.html.erb b/vendor/rails/actionpack/test/fixtures/functional_caching/fragment_cached.html.erb deleted file mode 100644 index 268a298..0000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/fragment_cached.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Hello -<% cache do %>This bit's fragment cached<% end %> diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb b/vendor/rails/actionpack/test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb deleted file mode 100644 index a9462d3..0000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render :partial => 'partial' %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/inline_fragment_cached.html.erb b/vendor/rails/actionpack/test/fixtures/functional_caching/inline_fragment_cached.html.erb deleted file mode 100644 index 87309b8..0000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/inline_fragment_cached.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -<%= render :inline => 'Some inline content' %> -<% cache do %>Some cached content<% end %> diff --git a/vendor/rails/actionpack/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs b/vendor/rails/actionpack/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs deleted file mode 100644 index 248842c..0000000 --- a/vendor/rails/actionpack/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs +++ /dev/null @@ -1 +0,0 @@ -page.replace_html 'notices', :partial => 'partial' \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/good_customers/_good_customer.html.erb b/vendor/rails/actionpack/test/fixtures/good_customers/_good_customer.html.erb deleted file mode 100644 index a2d97eb..0000000 --- a/vendor/rails/actionpack/test/fixtures/good_customers/_good_customer.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= greeting %> good customer: <%= good_customer.name %><%= good_customer_counter %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/helpers/abc_helper.rb b/vendor/rails/actionpack/test/fixtures/helpers/abc_helper.rb deleted file mode 100644 index 7104ff3..0000000 --- a/vendor/rails/actionpack/test/fixtures/helpers/abc_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -module AbcHelper - def bare_a() end - def bare_b() end - def bare_c() end -end diff --git a/vendor/rails/actionpack/test/fixtures/helpers/fun/games_helper.rb b/vendor/rails/actionpack/test/fixtures/helpers/fun/games_helper.rb deleted file mode 100644 index bf60d9d..0000000 --- a/vendor/rails/actionpack/test/fixtures/helpers/fun/games_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Fun::GamesHelper - def stratego() "Iz guuut!" end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/helpers/fun/pdf_helper.rb b/vendor/rails/actionpack/test/fixtures/helpers/fun/pdf_helper.rb deleted file mode 100644 index c4aea5a..0000000 --- a/vendor/rails/actionpack/test/fixtures/helpers/fun/pdf_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Fun::PdfHelper - def foobar() 'baz' end -end diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/alt/hello.rhtml b/vendor/rails/actionpack/test/fixtures/layout_tests/alt/hello.rhtml deleted file mode 100644 index fcda6cf..0000000 --- a/vendor/rails/actionpack/test/fixtures/layout_tests/alt/hello.rhtml +++ /dev/null @@ -1 +0,0 @@ -alt/hello.rhtml diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/alt/layouts/alt.rhtml b/vendor/rails/actionpack/test/fixtures/layout_tests/alt/layouts/alt.rhtml deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/controller_name_space/nested.rhtml b/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/controller_name_space/nested.rhtml deleted file mode 100644 index 5f86a7d..0000000 --- a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/controller_name_space/nested.rhtml +++ /dev/null @@ -1 +0,0 @@ -controller_name_space/nested.rhtml <%= yield %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/item.rhtml b/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/item.rhtml deleted file mode 100644 index 1bc7cbd..0000000 --- a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/item.rhtml +++ /dev/null @@ -1 +0,0 @@ -item.rhtml <%= yield %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/layout_test.rhtml b/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/layout_test.rhtml deleted file mode 100644 index c0f2642..0000000 --- a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/layout_test.rhtml +++ /dev/null @@ -1 +0,0 @@ -layout_test.rhtml <%= yield %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/multiple_extensions.html.erb b/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/multiple_extensions.html.erb deleted file mode 100644 index 3b65e54..0000000 --- a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/multiple_extensions.html.erb +++ /dev/null @@ -1 +0,0 @@ -multiple_extensions.html.erb <%= yield %> diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/third_party_template_library.mab b/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/third_party_template_library.mab deleted file mode 100644 index 018abfb..0000000 --- a/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/third_party_template_library.mab +++ /dev/null @@ -1 +0,0 @@ -Mab \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layout_tests/views/hello.rhtml b/vendor/rails/actionpack/test/fixtures/layout_tests/views/hello.rhtml deleted file mode 100644 index bbccf09..0000000 --- a/vendor/rails/actionpack/test/fixtures/layout_tests/views/hello.rhtml +++ /dev/null @@ -1 +0,0 @@ -hello.rhtml \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layouts/_column.html.erb b/vendor/rails/actionpack/test/fixtures/layouts/_column.html.erb deleted file mode 100644 index 96db002..0000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/_column.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -<div id="column"><%= yield :column %></div> -<div id="content"><%= yield %></div> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layouts/block_with_layout.erb b/vendor/rails/actionpack/test/fixtures/layouts/block_with_layout.erb deleted file mode 100644 index 6a8b419..0000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/block_with_layout.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% render(:layout => "layout_for_partial", :locals => { :name => "Anthony" }) do %>Inside from first block in layout<% end %> -<%= yield %> -<% render(:layout => "layout_for_partial", :locals => { :name => "Ramm" }) do %>Inside from second block in layout<% end %> diff --git a/vendor/rails/actionpack/test/fixtures/layouts/builder.builder b/vendor/rails/actionpack/test/fixtures/layouts/builder.builder deleted file mode 100644 index 729af4b..0000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/builder.builder +++ /dev/null @@ -1,3 +0,0 @@ -xml.wrapper do - xml << @content_for_layout -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layouts/default_html.html.erb b/vendor/rails/actionpack/test/fixtures/layouts/default_html.html.erb deleted file mode 100644 index edd7191..0000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/default_html.html.erb +++ /dev/null @@ -1 +0,0 @@ -<html><%= @content_for_layout %></html> diff --git a/vendor/rails/actionpack/test/fixtures/layouts/partial_with_layout.erb b/vendor/rails/actionpack/test/fixtures/layouts/partial_with_layout.erb deleted file mode 100644 index a0349d7..0000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/partial_with_layout.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= render( :layout => "layout_for_partial", :partial => "partial_for_use_in_layout", :locals => {:name => 'Anthony' } ) %> -<%= yield %> -<%= render( :layout => "layout_for_partial", :partial => "partial_for_use_in_layout", :locals => {:name => 'Ramm' } ) %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layouts/standard.erb b/vendor/rails/actionpack/test/fixtures/layouts/standard.erb deleted file mode 100644 index 368764e..0000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/standard.erb +++ /dev/null @@ -1 +0,0 @@ -<html><%= @content_for_layout %><%= @variable_for_layout %></html> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layouts/talk_from_action.erb b/vendor/rails/actionpack/test/fixtures/layouts/talk_from_action.erb deleted file mode 100644 index 187aab0..0000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/talk_from_action.erb +++ /dev/null @@ -1,2 +0,0 @@ -<title><%= @title || @content_for_title %></title> -<%= @content_for_layout -%> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layouts/xhr.html.erb b/vendor/rails/actionpack/test/fixtures/layouts/xhr.html.erb deleted file mode 100644 index 8528532..0000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/xhr.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -XHR! -<%= yield %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/layouts/yield.erb b/vendor/rails/actionpack/test/fixtures/layouts/yield.erb deleted file mode 100644 index 482dc90..0000000 --- a/vendor/rails/actionpack/test/fixtures/layouts/yield.erb +++ /dev/null @@ -1,2 +0,0 @@ -<title><%= yield :title %></title> -<%= yield %> diff --git a/vendor/rails/actionpack/test/fixtures/mascot.rb b/vendor/rails/actionpack/test/fixtures/mascot.rb deleted file mode 100644 index f9f1448..0000000 --- a/vendor/rails/actionpack/test/fixtures/mascot.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Mascot < ActiveRecord::Base - belongs_to :company -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/mascots.yml b/vendor/rails/actionpack/test/fixtures/mascots.yml deleted file mode 100644 index 17b7dff..0000000 --- a/vendor/rails/actionpack/test/fixtures/mascots.yml +++ /dev/null @@ -1,4 +0,0 @@ -upload_bird: - id: 1 - company_id: 1 - name: The Upload Bird \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/mascots/_mascot.html.erb b/vendor/rails/actionpack/test/fixtures/mascots/_mascot.html.erb deleted file mode 100644 index 432773a..0000000 --- a/vendor/rails/actionpack/test/fixtures/mascots/_mascot.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= mascot.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/multipart/binary_file b/vendor/rails/actionpack/test/fixtures/multipart/binary_file deleted file mode 100644 index 556187a..0000000 Binary files a/vendor/rails/actionpack/test/fixtures/multipart/binary_file and /dev/null differ diff --git a/vendor/rails/actionpack/test/fixtures/multipart/boundary_problem_file b/vendor/rails/actionpack/test/fixtures/multipart/boundary_problem_file deleted file mode 100644 index 889c4aa..0000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/boundary_problem_file +++ /dev/null @@ -1,10 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="file"; filename="file.txt" -Content-Type: text/plain - -bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ---AaB03x -Content-Disposition: form-data; name="foo" - -bar ---AaB03x-- diff --git a/vendor/rails/actionpack/test/fixtures/multipart/bracketed_param b/vendor/rails/actionpack/test/fixtures/multipart/bracketed_param deleted file mode 100644 index 096bd8a..0000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/bracketed_param +++ /dev/null @@ -1,5 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="foo[baz]" - -bar ---AaB03x-- diff --git a/vendor/rails/actionpack/test/fixtures/multipart/empty b/vendor/rails/actionpack/test/fixtures/multipart/empty deleted file mode 100644 index f0f7983..0000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/empty +++ /dev/null @@ -1,10 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="submit-name" - -Larry ---AaB03x -Content-Disposition: form-data; name="files"; filename="file1.txt" -Content-Type: text/plain - - ---AaB03x-- diff --git a/vendor/rails/actionpack/test/fixtures/multipart/hello.txt b/vendor/rails/actionpack/test/fixtures/multipart/hello.txt deleted file mode 100644 index 5ab2f8a..0000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/hello.txt +++ /dev/null @@ -1 +0,0 @@ -Hello \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/multipart/large_text_file b/vendor/rails/actionpack/test/fixtures/multipart/large_text_file deleted file mode 100644 index 7f97fb1..0000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/large_text_file +++ /dev/null @@ -1,10 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="foo" - -bar ---AaB03x -Content-Disposition: form-data; name="file"; filename="file.txt" -Content-Type: text/plain - -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ---AaB03x-- diff --git a/vendor/rails/actionpack/test/fixtures/multipart/mixed_files b/vendor/rails/actionpack/test/fixtures/multipart/mixed_files deleted file mode 100644 index 5eba7a6..0000000 Binary files a/vendor/rails/actionpack/test/fixtures/multipart/mixed_files and /dev/null differ diff --git a/vendor/rails/actionpack/test/fixtures/multipart/mona_lisa.jpg b/vendor/rails/actionpack/test/fixtures/multipart/mona_lisa.jpg deleted file mode 100644 index 5cf3bef..0000000 Binary files a/vendor/rails/actionpack/test/fixtures/multipart/mona_lisa.jpg and /dev/null differ diff --git a/vendor/rails/actionpack/test/fixtures/multipart/none b/vendor/rails/actionpack/test/fixtures/multipart/none deleted file mode 100644 index d66f473..0000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/none +++ /dev/null @@ -1,9 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="submit-name" - -Larry ---AaB03x -Content-Disposition: form-data; name="files"; filename="" - - ---AaB03x-- diff --git a/vendor/rails/actionpack/test/fixtures/multipart/single_parameter b/vendor/rails/actionpack/test/fixtures/multipart/single_parameter deleted file mode 100644 index 8962c35..0000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/single_parameter +++ /dev/null @@ -1,5 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="foo" - -bar ---AaB03x-- diff --git a/vendor/rails/actionpack/test/fixtures/multipart/text_file b/vendor/rails/actionpack/test/fixtures/multipart/text_file deleted file mode 100644 index e0367d6..0000000 --- a/vendor/rails/actionpack/test/fixtures/multipart/text_file +++ /dev/null @@ -1,10 +0,0 @@ ---AaB03x -Content-Disposition: form-data; name="foo" - -bar ---AaB03x -Content-Disposition: form-data; name="file"; filename="file.txt" -Content-Type: text/plain - -contents ---AaB03x-- diff --git a/vendor/rails/actionpack/test/fixtures/override/test/hello_world.erb b/vendor/rails/actionpack/test/fixtures/override/test/hello_world.erb deleted file mode 100644 index 3e308d3..0000000 --- a/vendor/rails/actionpack/test/fixtures/override/test/hello_world.erb +++ /dev/null @@ -1 +0,0 @@ -Hello overridden world! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/override2/layouts/test/sub.erb b/vendor/rails/actionpack/test/fixtures/override2/layouts/test/sub.erb deleted file mode 100644 index 3863d5a..0000000 --- a/vendor/rails/actionpack/test/fixtures/override2/layouts/test/sub.erb +++ /dev/null @@ -1 +0,0 @@ -layout: <%= yield %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/post_test/layouts/post.html.erb b/vendor/rails/actionpack/test/fixtures/post_test/layouts/post.html.erb deleted file mode 100644 index c6c1a58..0000000 --- a/vendor/rails/actionpack/test/fixtures/post_test/layouts/post.html.erb +++ /dev/null @@ -1 +0,0 @@ -<html><div id="html"><%= yield %></div></html> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/post_test/layouts/super_post.iphone.erb b/vendor/rails/actionpack/test/fixtures/post_test/layouts/super_post.iphone.erb deleted file mode 100644 index db0e436..0000000 --- a/vendor/rails/actionpack/test/fixtures/post_test/layouts/super_post.iphone.erb +++ /dev/null @@ -1 +0,0 @@ -<html><div id="super_iphone"><%= yield %></div></html> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/post_test/post/index.html.erb b/vendor/rails/actionpack/test/fixtures/post_test/post/index.html.erb deleted file mode 100644 index b349b25..0000000 --- a/vendor/rails/actionpack/test/fixtures/post_test/post/index.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hello Firefox \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/post_test/post/index.iphone.erb b/vendor/rails/actionpack/test/fixtures/post_test/post/index.iphone.erb deleted file mode 100644 index d741e44..0000000 --- a/vendor/rails/actionpack/test/fixtures/post_test/post/index.iphone.erb +++ /dev/null @@ -1 +0,0 @@ -Hello iPhone \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.html.erb b/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.html.erb deleted file mode 100644 index 7fc2eb1..0000000 --- a/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.html.erb +++ /dev/null @@ -1 +0,0 @@ -Super Firefox \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.iphone.erb b/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.iphone.erb deleted file mode 100644 index 99063a8..0000000 --- a/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.iphone.erb +++ /dev/null @@ -1 +0,0 @@ -Super iPhone \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/project.rb b/vendor/rails/actionpack/test/fixtures/project.rb deleted file mode 100644 index 2b53d39..0000000 --- a/vendor/rails/actionpack/test/fixtures/project.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Project < ActiveRecord::Base - has_and_belongs_to_many :developers, :uniq => true -end diff --git a/vendor/rails/actionpack/test/fixtures/projects.yml b/vendor/rails/actionpack/test/fixtures/projects.yml deleted file mode 100644 index 02800c7..0000000 --- a/vendor/rails/actionpack/test/fixtures/projects.yml +++ /dev/null @@ -1,7 +0,0 @@ -action_controller: - id: 2 - name: Active Controller - -active_record: - id: 1 - name: Active Record diff --git a/vendor/rails/actionpack/test/fixtures/projects/_project.erb b/vendor/rails/actionpack/test/fixtures/projects/_project.erb deleted file mode 100644 index 480c4c2..0000000 --- a/vendor/rails/actionpack/test/fixtures/projects/_project.erb +++ /dev/null @@ -1 +0,0 @@ -<%= project.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/404.html b/vendor/rails/actionpack/test/fixtures/public/404.html deleted file mode 100644 index 497397c..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/404.html +++ /dev/null @@ -1 +0,0 @@ -404 error fixture diff --git a/vendor/rails/actionpack/test/fixtures/public/500.da.html b/vendor/rails/actionpack/test/fixtures/public/500.da.html deleted file mode 100644 index a497c13..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/500.da.html +++ /dev/null @@ -1 +0,0 @@ -500 localized error fixture diff --git a/vendor/rails/actionpack/test/fixtures/public/500.html b/vendor/rails/actionpack/test/fixtures/public/500.html deleted file mode 100644 index 7c66c7a..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/500.html +++ /dev/null @@ -1 +0,0 @@ -500 error fixture diff --git a/vendor/rails/actionpack/test/fixtures/public/images/rails.png b/vendor/rails/actionpack/test/fixtures/public/images/rails.png deleted file mode 100644 index b8441f1..0000000 Binary files a/vendor/rails/actionpack/test/fixtures/public/images/rails.png and /dev/null differ diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/application.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/application.js deleted file mode 100644 index 9702692..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/application.js +++ /dev/null @@ -1 +0,0 @@ -// application js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/bank.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/bank.js deleted file mode 100644 index 4a1bee7..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/bank.js +++ /dev/null @@ -1 +0,0 @@ -// bank js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/controls.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/controls.js deleted file mode 100644 index 88168d9..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/controls.js +++ /dev/null @@ -1 +0,0 @@ -// controls js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/dragdrop.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/dragdrop.js deleted file mode 100644 index c07061a..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/dragdrop.js +++ /dev/null @@ -1 +0,0 @@ -// dragdrop js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/effects.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/effects.js deleted file mode 100644 index b555d63..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/effects.js +++ /dev/null @@ -1 +0,0 @@ -// effects js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/prototype.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/prototype.js deleted file mode 100644 index 9780064..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/prototype.js +++ /dev/null @@ -1 +0,0 @@ -// prototype js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/robber.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/robber.js deleted file mode 100644 index eb82fcb..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/robber.js +++ /dev/null @@ -1 +0,0 @@ -// robber js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/subdir/subdir.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/subdir/subdir.js deleted file mode 100644 index 9d23a67..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/subdir/subdir.js +++ /dev/null @@ -1 +0,0 @@ -// subdir js diff --git a/vendor/rails/actionpack/test/fixtures/public/javascripts/version.1.0.js b/vendor/rails/actionpack/test/fixtures/public/javascripts/version.1.0.js deleted file mode 100644 index cfd5fce..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/javascripts/version.1.0.js +++ /dev/null @@ -1 +0,0 @@ -// version.1.0 js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/stylesheets/bank.css b/vendor/rails/actionpack/test/fixtures/public/stylesheets/bank.css deleted file mode 100644 index ea161b1..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/stylesheets/bank.css +++ /dev/null @@ -1 +0,0 @@ -/* bank.css */ \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/stylesheets/robber.css b/vendor/rails/actionpack/test/fixtures/public/stylesheets/robber.css deleted file mode 100644 index 0fdd00a..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/stylesheets/robber.css +++ /dev/null @@ -1 +0,0 @@ -/* robber.css */ \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/public/stylesheets/subdir/subdir.css b/vendor/rails/actionpack/test/fixtures/public/stylesheets/subdir/subdir.css deleted file mode 100644 index 241152a..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/stylesheets/subdir/subdir.css +++ /dev/null @@ -1 +0,0 @@ -/* subdir.css */ diff --git a/vendor/rails/actionpack/test/fixtures/public/stylesheets/version.1.0.css b/vendor/rails/actionpack/test/fixtures/public/stylesheets/version.1.0.css deleted file mode 100644 index 30f5f9b..0000000 --- a/vendor/rails/actionpack/test/fixtures/public/stylesheets/version.1.0.css +++ /dev/null @@ -1 +0,0 @@ -/* version.1.0.css */ \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/quiz/questions/_question.html.erb b/vendor/rails/actionpack/test/fixtures/quiz/questions/_question.html.erb deleted file mode 100644 index fb4dcfe..0000000 --- a/vendor/rails/actionpack/test/fixtures/quiz/questions/_question.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= question.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/replies.yml b/vendor/rails/actionpack/test/fixtures/replies.yml deleted file mode 100644 index 66020b7..0000000 --- a/vendor/rails/actionpack/test/fixtures/replies.yml +++ /dev/null @@ -1,15 +0,0 @@ -witty_retort: - id: 1 - topic_id: 1 - developer_id: 1 - content: Birdman is better! - created_at: <%= 6.hours.ago.to_s(:db) %> - updated_at: nil - -another: - id: 2 - topic_id: 2 - developer_id: 1 - content: Nuh uh! - created_at: <%= 1.hour.ago.to_s(:db) %> - updated_at: nil diff --git a/vendor/rails/actionpack/test/fixtures/replies/_reply.erb b/vendor/rails/actionpack/test/fixtures/replies/_reply.erb deleted file mode 100644 index 68baf54..0000000 --- a/vendor/rails/actionpack/test/fixtures/replies/_reply.erb +++ /dev/null @@ -1 +0,0 @@ -<%= reply.content %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/reply.rb b/vendor/rails/actionpack/test/fixtures/reply.rb deleted file mode 100644 index 0459843..0000000 --- a/vendor/rails/actionpack/test/fixtures/reply.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Reply < ActiveRecord::Base - named_scope :base - belongs_to :topic, :include => [:replies] - belongs_to :developer - - validates_presence_of :content -end diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.html.erb b/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.html.erb deleted file mode 100644 index 84a8404..0000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.html.erb +++ /dev/null @@ -1 +0,0 @@ -HTML for all_types_with_layout \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.js.rjs b/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.js.rjs deleted file mode 100644 index b7aec7c..0000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.js.rjs +++ /dev/null @@ -1 +0,0 @@ -page << "RJS for all_types_with_layout" \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb b/vendor/rails/actionpack/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb deleted file mode 100644 index 0cdfa41..0000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb +++ /dev/null @@ -1 +0,0 @@ -Mobile \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.html.erb b/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.html.erb deleted file mode 100644 index 1f3f1c6..0000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hello future from <%= @type -%>! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb b/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb deleted file mode 100644 index 17888ac..0000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb +++ /dev/null @@ -1 +0,0 @@ -Hello iPhone future from <%= @type -%>! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/layouts/missing.html.erb b/vendor/rails/actionpack/test/fixtures/respond_to/layouts/missing.html.erb deleted file mode 100644 index d6f92a3..0000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/layouts/missing.html.erb +++ /dev/null @@ -1 +0,0 @@ -<html><div id="html_missing"><%= yield %></div></html> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.html.erb b/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.html.erb deleted file mode 100644 index c6c1a58..0000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.html.erb +++ /dev/null @@ -1 +0,0 @@ -<html><div id="html"><%= yield %></div></html> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.iphone.erb b/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.iphone.erb deleted file mode 100644 index 8444451..0000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.iphone.erb +++ /dev/null @@ -1 +0,0 @@ -<html><div id="iphone"><%= yield %></div></html> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.html.erb b/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.html.erb deleted file mode 100644 index 6769dd6..0000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hello world! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.js.rjs b/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.js.rjs deleted file mode 100644 index 469fcd8..0000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.js.rjs +++ /dev/null @@ -1 +0,0 @@ -page[:body].visual_effect :highlight \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.xml.builder b/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.xml.builder deleted file mode 100644 index 598d62e..0000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.xml.builder +++ /dev/null @@ -1 +0,0 @@ -xml.p "Hello world!" \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.html.erb b/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.html.erb deleted file mode 100644 index 6769dd6..0000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hello world! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs b/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs deleted file mode 100644 index 469fcd8..0000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs +++ /dev/null @@ -1 +0,0 @@ -page[:body].visual_effect :highlight \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder b/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder deleted file mode 100644 index 598d62e..0000000 --- a/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder +++ /dev/null @@ -1 +0,0 @@ -xml.p "Hello world!" \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/scope/test/modgreet.erb b/vendor/rails/actionpack/test/fixtures/scope/test/modgreet.erb deleted file mode 100644 index 8947726..0000000 --- a/vendor/rails/actionpack/test/fixtures/scope/test/modgreet.erb +++ /dev/null @@ -1 +0,0 @@ -<p>Beautiful modules!</p> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/shared.html.erb b/vendor/rails/actionpack/test/fixtures/shared.html.erb deleted file mode 100644 index af262fc..0000000 --- a/vendor/rails/actionpack/test/fixtures/shared.html.erb +++ /dev/null @@ -1 +0,0 @@ -Elastica \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/symlink_parent/symlinked_layout.erb b/vendor/rails/actionpack/test/fixtures/symlink_parent/symlinked_layout.erb deleted file mode 100644 index bda57d0..0000000 --- a/vendor/rails/actionpack/test/fixtures/symlink_parent/symlinked_layout.erb +++ /dev/null @@ -1,5 +0,0 @@ -This is my layout - -<%= yield %> - -End. diff --git a/vendor/rails/actionpack/test/fixtures/test/_counter.html.erb b/vendor/rails/actionpack/test/fixtures/test/_counter.html.erb deleted file mode 100644 index fd245bf..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_counter.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= counter_counter %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_customer.erb b/vendor/rails/actionpack/test/fixtures/test/_customer.erb deleted file mode 100644 index d8220af..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_customer.erb +++ /dev/null @@ -1 +0,0 @@ -Hello: <%= customer.name rescue "Anonymous" %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_customer_counter.erb b/vendor/rails/actionpack/test/fixtures/test/_customer_counter.erb deleted file mode 100644 index 3435979..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_customer_counter.erb +++ /dev/null @@ -1 +0,0 @@ -<%= customer_counter.name %><%= customer_counter_counter %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_customer_greeting.erb b/vendor/rails/actionpack/test/fixtures/test/_customer_greeting.erb deleted file mode 100644 index 6acbcb2..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_customer_greeting.erb +++ /dev/null @@ -1 +0,0 @@ -<%= greeting %>: <%= customer_greeting.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_customer_with_var.erb b/vendor/rails/actionpack/test/fixtures/test/_customer_with_var.erb deleted file mode 100644 index 3379246..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_customer_with_var.erb +++ /dev/null @@ -1 +0,0 @@ -<%= customer.name %> <%= object.name %> <%= customer_with_var.name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_form.erb b/vendor/rails/actionpack/test/fixtures/test/_form.erb deleted file mode 100644 index 01107f1..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_form.erb +++ /dev/null @@ -1 +0,0 @@ -<%= form.label :title %> diff --git a/vendor/rails/actionpack/test/fixtures/test/_hash_greeting.erb b/vendor/rails/actionpack/test/fixtures/test/_hash_greeting.erb deleted file mode 100644 index fc54a36..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_hash_greeting.erb +++ /dev/null @@ -1 +0,0 @@ -<%= greeting %>: <%= hash_greeting[:first_name] %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_hash_object.erb b/vendor/rails/actionpack/test/fixtures/test/_hash_object.erb deleted file mode 100644 index 55c03af..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_hash_object.erb +++ /dev/null @@ -1,2 +0,0 @@ -<%= hash_object[:first_name] %> -<%= object[:first_name].reverse %> diff --git a/vendor/rails/actionpack/test/fixtures/test/_hello.builder b/vendor/rails/actionpack/test/fixtures/test/_hello.builder deleted file mode 100644 index ef52f63..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_hello.builder +++ /dev/null @@ -1 +0,0 @@ -xm.hello \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_labelling_form.erb b/vendor/rails/actionpack/test/fixtures/test/_labelling_form.erb deleted file mode 100644 index 1b95763..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_labelling_form.erb +++ /dev/null @@ -1 +0,0 @@ -<%= labelling_form.label :title %> diff --git a/vendor/rails/actionpack/test/fixtures/test/_layout_for_block_with_args.html.erb b/vendor/rails/actionpack/test/fixtures/test/_layout_for_block_with_args.html.erb deleted file mode 100644 index 3075332..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_layout_for_block_with_args.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -Before -<%= yield 'arg1', 'arg2' %> -After \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_layout_for_partial.html.erb b/vendor/rails/actionpack/test/fixtures/test/_layout_for_partial.html.erb deleted file mode 100644 index 666efad..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_layout_for_partial.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -Before (<%= name %>) -<%= yield %> -After \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_local_inspector.html.erb b/vendor/rails/actionpack/test/fixtures/test/_local_inspector.html.erb deleted file mode 100644 index c5a6e3e..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_local_inspector.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= local_assigns.keys.map(&:to_s).sort.join(",") -%> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_one.html.erb b/vendor/rails/actionpack/test/fixtures/test/_one.html.erb deleted file mode 100644 index f796291..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_one.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render :partial => "two" %> world diff --git a/vendor/rails/actionpack/test/fixtures/test/_partial.erb b/vendor/rails/actionpack/test/fixtures/test/_partial.erb deleted file mode 100644 index e466dcb..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_partial.erb +++ /dev/null @@ -1 +0,0 @@ -invalid \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_partial.html.erb b/vendor/rails/actionpack/test/fixtures/test/_partial.html.erb deleted file mode 100644 index e39f6c9..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_partial.html.erb +++ /dev/null @@ -1 +0,0 @@ -partial html \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_partial.js.erb b/vendor/rails/actionpack/test/fixtures/test/_partial.js.erb deleted file mode 100644 index b350cdd..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_partial.js.erb +++ /dev/null @@ -1 +0,0 @@ -partial js \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_partial_for_use_in_layout.html.erb b/vendor/rails/actionpack/test/fixtures/test/_partial_for_use_in_layout.html.erb deleted file mode 100644 index 3a03a64..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_partial_for_use_in_layout.html.erb +++ /dev/null @@ -1 +0,0 @@ -Inside from partial (<%= name %>) \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_partial_only.erb b/vendor/rails/actionpack/test/fixtures/test/_partial_only.erb deleted file mode 100644 index a44b3ee..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_partial_only.erb +++ /dev/null @@ -1 +0,0 @@ -only partial \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb b/vendor/rails/actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb deleted file mode 100644 index 00e6b6d..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb +++ /dev/null @@ -1 +0,0 @@ -partial with only html version \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_person.erb b/vendor/rails/actionpack/test/fixtures/test/_person.erb deleted file mode 100644 index b2e5688..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_person.erb +++ /dev/null @@ -1,2 +0,0 @@ -Second: <%= name %> -Third: <%= @name %> diff --git a/vendor/rails/actionpack/test/fixtures/test/_raise.html.erb b/vendor/rails/actionpack/test/fixtures/test/_raise.html.erb deleted file mode 100644 index 68b0818..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_raise.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= doesnt_exist %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/_two.html.erb b/vendor/rails/actionpack/test/fixtures/test/_two.html.erb deleted file mode 100644 index 5ab2f8a..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/_two.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hello \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/action_talk_to_layout.erb b/vendor/rails/actionpack/test/fixtures/test/action_talk_to_layout.erb deleted file mode 100644 index 36e896d..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/action_talk_to_layout.erb +++ /dev/null @@ -1,2 +0,0 @@ -<% @title = "Talking to the layout" -%> -Action was here! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/calling_partial_with_layout.html.erb b/vendor/rails/actionpack/test/fixtures/test/calling_partial_with_layout.html.erb deleted file mode 100644 index ac44bc0..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/calling_partial_with_layout.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render(:layout => "layout_for_partial", :partial => "partial_for_use_in_layout", :locals => { :name => "David" }) %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/capturing.erb b/vendor/rails/actionpack/test/fixtures/test/capturing.erb deleted file mode 100644 index 1addaa4..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/capturing.erb +++ /dev/null @@ -1,4 +0,0 @@ -<% days = capture do %> - Dreamy days -<% end %> -<%= days %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/content_for.erb b/vendor/rails/actionpack/test/fixtures/test/content_for.erb deleted file mode 100644 index 0e47ca8..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/content_for.erb +++ /dev/null @@ -1,2 +0,0 @@ -<% content_for :title do %>Putting stuff in the title!<% end %> -Great stuff! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/content_for_concatenated.erb b/vendor/rails/actionpack/test/fixtures/test/content_for_concatenated.erb deleted file mode 100644 index fb6b4b0..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/content_for_concatenated.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% content_for :title, "Putting stuff " - content_for :title, "in the title!" %> -Great stuff! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/content_for_with_parameter.erb b/vendor/rails/actionpack/test/fixtures/test/content_for_with_parameter.erb deleted file mode 100644 index 57aecba..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/content_for_with_parameter.erb +++ /dev/null @@ -1,2 +0,0 @@ -<% content_for :title, "Putting stuff in the title!" %> -Great stuff! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/delete_with_js.rjs b/vendor/rails/actionpack/test/fixtures/test/delete_with_js.rjs deleted file mode 100644 index 4b75a95..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/delete_with_js.rjs +++ /dev/null @@ -1,2 +0,0 @@ -page.remove 'person' -page.visual_effect :highlight, "project-#{@project_id}" diff --git a/vendor/rails/actionpack/test/fixtures/test/dont_pick_me b/vendor/rails/actionpack/test/fixtures/test/dont_pick_me deleted file mode 100644 index 0157c9e..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/dont_pick_me +++ /dev/null @@ -1 +0,0 @@ -non-template file \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/dot.directory/render_file_with_ivar.erb b/vendor/rails/actionpack/test/fixtures/test/dot.directory/render_file_with_ivar.erb deleted file mode 100644 index 8b8a449..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/dot.directory/render_file_with_ivar.erb +++ /dev/null @@ -1 +0,0 @@ -The secret is <%= @secret %> diff --git a/vendor/rails/actionpack/test/fixtures/test/enum_rjs_test.rjs b/vendor/rails/actionpack/test/fixtures/test/enum_rjs_test.rjs deleted file mode 100644 index e300407..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/enum_rjs_test.rjs +++ /dev/null @@ -1,6 +0,0 @@ -page.select('.product').each do |value| - page.visual_effect :highlight - page.visual_effect :highlight, value - page.sortable(value, :url => { :action => "order" }) - page.draggable(value) -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/formatted_html_erb.html.erb b/vendor/rails/actionpack/test/fixtures/test/formatted_html_erb.html.erb deleted file mode 100644 index 1c64efa..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/formatted_html_erb.html.erb +++ /dev/null @@ -1 +0,0 @@ -formatted html erb \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.builder b/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.builder deleted file mode 100644 index 14fd354..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.builder +++ /dev/null @@ -1 +0,0 @@ -xml.test 'failed' \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.html.erb b/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.html.erb deleted file mode 100644 index 0c855a6..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.html.erb +++ /dev/null @@ -1 +0,0 @@ -<test>passed formatted html erb</test> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.xml.erb b/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.xml.erb deleted file mode 100644 index 6ca09d5..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.xml.erb +++ /dev/null @@ -1 +0,0 @@ -<test>passed formatted xml erb</test> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/greeting.erb b/vendor/rails/actionpack/test/fixtures/test/greeting.erb deleted file mode 100644 index 62fb029..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/greeting.erb +++ /dev/null @@ -1 +0,0 @@ -<p>This is grand!</p> diff --git a/vendor/rails/actionpack/test/fixtures/test/greeting.js.rjs b/vendor/rails/actionpack/test/fixtures/test/greeting.js.rjs deleted file mode 100644 index 469fcd8..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/greeting.js.rjs +++ /dev/null @@ -1 +0,0 @@ -page[:body].visual_effect :highlight \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hello.builder b/vendor/rails/actionpack/test/fixtures/test/hello.builder deleted file mode 100644 index a471553..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello.builder +++ /dev/null @@ -1,4 +0,0 @@ -xml.html do - xml.p "Hello #{@name}" - xml << render(:file => "test/greeting") -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hello_world.da.html.erb b/vendor/rails/actionpack/test/fixtures/test/hello_world.da.html.erb deleted file mode 100644 index 10ec443..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello_world.da.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hey verden \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hello_world.erb b/vendor/rails/actionpack/test/fixtures/test/hello_world.erb deleted file mode 100644 index 6769dd6..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello_world.erb +++ /dev/null @@ -1 +0,0 @@ -Hello world! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hello_world.pt-BR.html.erb b/vendor/rails/actionpack/test/fixtures/test/hello_world.pt-BR.html.erb deleted file mode 100644 index 773b3c8..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello_world.pt-BR.html.erb +++ /dev/null @@ -1 +0,0 @@ -Ola mundo \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hello_world_container.builder b/vendor/rails/actionpack/test/fixtures/test/hello_world_container.builder deleted file mode 100644 index e48d75c..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello_world_container.builder +++ /dev/null @@ -1,3 +0,0 @@ -xml.test do - render :partial => 'hello', :locals => { :xm => xml } -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hello_world_from_rxml.builder b/vendor/rails/actionpack/test/fixtures/test/hello_world_from_rxml.builder deleted file mode 100644 index 8455b11..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello_world_from_rxml.builder +++ /dev/null @@ -1,4 +0,0 @@ -xml.html do - xml.p "Hello" -end -"String return value" diff --git a/vendor/rails/actionpack/test/fixtures/test/hello_world_with_layout_false.erb b/vendor/rails/actionpack/test/fixtures/test/hello_world_with_layout_false.erb deleted file mode 100644 index 6769dd6..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello_world_with_layout_false.erb +++ /dev/null @@ -1 +0,0 @@ -Hello world! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hello_xml_world.builder b/vendor/rails/actionpack/test/fixtures/test/hello_xml_world.builder deleted file mode 100644 index 02b14fe..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/hello_xml_world.builder +++ /dev/null @@ -1,11 +0,0 @@ -xml.html do - xml.head do - xml.title "Hello World" - end - - xml.body do - xml.p "abes" - xml.p "monks" - xml.p "wiseguys" - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/hyphen-ated.erb b/vendor/rails/actionpack/test/fixtures/test/hyphen-ated.erb deleted file mode 100644 index cd08755..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/hyphen-ated.erb +++ /dev/null @@ -1 +0,0 @@ -Hello world! diff --git a/vendor/rails/actionpack/test/fixtures/test/implicit_content_type.atom.builder b/vendor/rails/actionpack/test/fixtures/test/implicit_content_type.atom.builder deleted file mode 100644 index 2fcb32d..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/implicit_content_type.atom.builder +++ /dev/null @@ -1,2 +0,0 @@ -xml.atom do -end diff --git a/vendor/rails/actionpack/test/fixtures/test/list.erb b/vendor/rails/actionpack/test/fixtures/test/list.erb deleted file mode 100644 index 0a4bda5..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/list.erb +++ /dev/null @@ -1 +0,0 @@ -<%= @test_unchanged = 'goodbye' %><%= render :partial => 'customer', :collection => @customers %><%= @test_unchanged %> diff --git a/vendor/rails/actionpack/test/fixtures/test/nested_layout.erb b/vendor/rails/actionpack/test/fixtures/test/nested_layout.erb deleted file mode 100644 index 7b6dcbb..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/nested_layout.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% content_for :title, "title" -%> -<% content_for :column do -%>column<% end -%> -<% render :layout => 'layouts/column' do -%>content<% end -%> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/non_erb_block_content_for.builder b/vendor/rails/actionpack/test/fixtures/test/non_erb_block_content_for.builder deleted file mode 100644 index a946435..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/non_erb_block_content_for.builder +++ /dev/null @@ -1,4 +0,0 @@ -content_for :title do - 'Putting stuff in the title!' -end -xml << "\nGreat stuff!" diff --git a/vendor/rails/actionpack/test/fixtures/test/potential_conflicts.erb b/vendor/rails/actionpack/test/fixtures/test/potential_conflicts.erb deleted file mode 100644 index a5e964e..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/potential_conflicts.erb +++ /dev/null @@ -1,4 +0,0 @@ -First: <%= @name %> -<%= render :partial => "person", :locals => { :name => "Stephan" } -%> -Fourth: <%= @name %> -Fifth: <%= name %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/render_explicit_html_template.js.rjs b/vendor/rails/actionpack/test/fixtures/test/render_explicit_html_template.js.rjs deleted file mode 100644 index 4eb12fd..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_explicit_html_template.js.rjs +++ /dev/null @@ -1 +0,0 @@ -page.call "document.write", render(:partial => "one.html.erb") diff --git a/vendor/rails/actionpack/test/fixtures/test/render_file_from_template.html.erb b/vendor/rails/actionpack/test/fixtures/test/render_file_from_template.html.erb deleted file mode 100644 index fde9f4b..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_file_from_template.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render :file => @path %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/render_file_with_ivar.erb b/vendor/rails/actionpack/test/fixtures/test/render_file_with_ivar.erb deleted file mode 100644 index 8b8a449..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_file_with_ivar.erb +++ /dev/null @@ -1 +0,0 @@ -The secret is <%= @secret %> diff --git a/vendor/rails/actionpack/test/fixtures/test/render_file_with_locals.erb b/vendor/rails/actionpack/test/fixtures/test/render_file_with_locals.erb deleted file mode 100644 index ebe09fa..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_file_with_locals.erb +++ /dev/null @@ -1 +0,0 @@ -The secret is <%= secret %> diff --git a/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template.js.rjs b/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template.js.rjs deleted file mode 100644 index 3d68041..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template.js.rjs +++ /dev/null @@ -1 +0,0 @@ -page.call "document.write", render(:partial => "one") diff --git a/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.da.html.erb b/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.da.html.erb deleted file mode 100644 index 0740b2d..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.da.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hey HTML! diff --git a/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.html.erb b/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.html.erb deleted file mode 100644 index 4a11845..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hello HTML! \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/render_implicit_js_template_without_layout.js.erb b/vendor/rails/actionpack/test/fixtures/test/render_implicit_js_template_without_layout.js.erb deleted file mode 100644 index d5b94af..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_implicit_js_template_without_layout.js.erb +++ /dev/null @@ -1 +0,0 @@ -alert('hello'); diff --git a/vendor/rails/actionpack/test/fixtures/test/render_to_string_test.erb b/vendor/rails/actionpack/test/fixtures/test/render_to_string_test.erb deleted file mode 100644 index 6e267e8..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/render_to_string_test.erb +++ /dev/null @@ -1 +0,0 @@ -The value of foo is: ::<%= @foo %>:: diff --git a/vendor/rails/actionpack/test/fixtures/test/sub_template_raise.html.erb b/vendor/rails/actionpack/test/fixtures/test/sub_template_raise.html.erb deleted file mode 100644 index f38c0bd..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/sub_template_raise.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render :partial => "test/raise" %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/template.erb b/vendor/rails/actionpack/test/fixtures/test/template.erb deleted file mode 100644 index 785afa8..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/template.erb +++ /dev/null @@ -1 +0,0 @@ -<%= template.path %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/update_element_with_capture.erb b/vendor/rails/actionpack/test/fixtures/test/update_element_with_capture.erb deleted file mode 100644 index fa3ef20..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/update_element_with_capture.erb +++ /dev/null @@ -1,9 +0,0 @@ -<% replacement_function = update_element_function("products", :action => :update) do %> - <p>Product 1</p> - <p>Product 2</p> -<% end %> -<%= javascript_tag(replacement_function) %> - -<% update_element_function("status", :action => :update, :binding => binding) do %> - <b>You bought something!</b> -<% end %> diff --git a/vendor/rails/actionpack/test/fixtures/test/using_layout_around_block.html.erb b/vendor/rails/actionpack/test/fixtures/test/using_layout_around_block.html.erb deleted file mode 100644 index a93fa02..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/using_layout_around_block.html.erb +++ /dev/null @@ -1 +0,0 @@ -<% render(:layout => "layout_for_partial", :locals => { :name => "David" }) do %>Inside from block<% end %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/using_layout_around_block_with_args.html.erb b/vendor/rails/actionpack/test/fixtures/test/using_layout_around_block_with_args.html.erb deleted file mode 100644 index 71b1f30..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/using_layout_around_block_with_args.html.erb +++ /dev/null @@ -1 +0,0 @@ -<% render(:layout => "layout_for_block_with_args") do |*args| %><%= args.join %><% end %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/test/utf8.html.erb b/vendor/rails/actionpack/test/fixtures/test/utf8.html.erb deleted file mode 100644 index 0b4d19a..0000000 --- a/vendor/rails/actionpack/test/fixtures/test/utf8.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Русский текст -日本語のテキスト \ No newline at end of file diff --git a/vendor/rails/actionpack/test/fixtures/topic.rb b/vendor/rails/actionpack/test/fixtures/topic.rb deleted file mode 100644 index 9fa9746..0000000 --- a/vendor/rails/actionpack/test/fixtures/topic.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Topic < ActiveRecord::Base - has_many :replies, :dependent => :destroy -end diff --git a/vendor/rails/actionpack/test/fixtures/topics.yml b/vendor/rails/actionpack/test/fixtures/topics.yml deleted file mode 100644 index 61ea02d..0000000 --- a/vendor/rails/actionpack/test/fixtures/topics.yml +++ /dev/null @@ -1,22 +0,0 @@ -futurama: - id: 1 - title: Isnt futurama awesome? - subtitle: It really is, isnt it. - content: I like futurama - created_at: <%= 1.day.ago.to_s(:db) %> - updated_at: - -harvey_birdman: - id: 2 - title: Harvey Birdman is the king of all men - subtitle: yup - content: It really is - created_at: <%= 2.hours.ago.to_s(:db) %> - updated_at: - -rails: - id: 3 - title: Rails is nice - subtitle: It makes me happy - content: except when I have to hack internals to fix pagination. even then really. - created_at: <%= 20.minutes.ago.to_s(:db) %> diff --git a/vendor/rails/actionpack/test/fixtures/topics/_topic.html.erb b/vendor/rails/actionpack/test/fixtures/topics/_topic.html.erb deleted file mode 100644 index 98659ca..0000000 --- a/vendor/rails/actionpack/test/fixtures/topics/_topic.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= topic.title %> \ No newline at end of file diff --git a/vendor/rails/actionpack/test/template/active_record_helper_i18n_test.rb b/vendor/rails/actionpack/test/template/active_record_helper_i18n_test.rb deleted file mode 100644 index 4b6e8dd..0000000 --- a/vendor/rails/actionpack/test/template/active_record_helper_i18n_test.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'abstract_unit' - -class ActiveRecordHelperI18nTest < Test::Unit::TestCase - include ActionView::Helpers::ActiveRecordHelper - - attr_reader :request - def setup - @object = stub :errors => stub(:count => 1, :full_messages => ['full_messages']) - @object_name = 'book' - stubs(:content_tag).returns 'content_tag' - - I18n.stubs(:t).with(:'header', :locale => 'en', :scope => [:activerecord, :errors, :template], :count => 1, :model => '').returns "1 error prohibited this from being saved" - I18n.stubs(:t).with(:'body', :locale => 'en', :scope => [:activerecord, :errors, :template]).returns 'There were problems with the following fields:' - end - - def test_error_messages_for_given_a_header_option_it_does_not_translate_header_message - I18n.expects(:translate).with(:'header', :locale => 'en', :scope => [:activerecord, :errors, :template], :count => 1, :model => '').never - error_messages_for(:object => @object, :header_message => 'header message', :locale => 'en') - end - - def test_error_messages_for_given_no_header_option_it_translates_header_message - I18n.expects(:t).with(:'header', :locale => 'en', :scope => [:activerecord, :errors, :template], :count => 1, :model => '').returns 'header message' - I18n.expects(:t).with('', :default => '', :count => 1, :scope => [:activerecord, :models]).once.returns '' - error_messages_for(:object => @object, :locale => 'en') - end - - def test_error_messages_for_given_a_message_option_it_does_not_translate_message - I18n.expects(:t).with(:'body', :locale => 'en', :scope => [:activerecord, :errors, :template]).never - I18n.expects(:t).with('', :default => '', :count => 1, :scope => [:activerecord, :models]).once.returns '' - error_messages_for(:object => @object, :message => 'message', :locale => 'en') - end - - def test_error_messages_for_given_no_message_option_it_translates_message - I18n.expects(:t).with(:'body', :locale => 'en', :scope => [:activerecord, :errors, :template]).returns 'There were problems with the following fields:' - I18n.expects(:t).with('', :default => '', :count => 1, :scope => [:activerecord, :models]).once.returns '' - error_messages_for(:object => @object, :locale => 'en') - end - - def test_error_messages_for_given_object_name_it_translates_object_name - I18n.expects(:t).with(:header, :locale => 'en', :scope => [:activerecord, :errors, :template], :count => 1, :model => @object_name).returns "1 error prohibited this #{@object_name} from being saved" - I18n.expects(:t).with(@object_name, :default => @object_name, :count => 1, :scope => [:activerecord, :models]).once.returns @object_name - error_messages_for(:object => @object, :locale => 'en', :object_name => @object_name) - end -end diff --git a/vendor/rails/actionpack/test/template/active_record_helper_test.rb b/vendor/rails/actionpack/test/template/active_record_helper_test.rb deleted file mode 100644 index 83c028b..0000000 --- a/vendor/rails/actionpack/test/template/active_record_helper_test.rb +++ /dev/null @@ -1,302 +0,0 @@ -require 'abstract_unit' - -class ActiveRecordHelperTest < ActionView::TestCase - tests ActionView::Helpers::ActiveRecordHelper - - silence_warnings do - Post = Struct.new("Post", :title, :author_name, :body, :secret, :written_on) - Post.class_eval do - alias_method :title_before_type_cast, :title unless respond_to?(:title_before_type_cast) - alias_method :body_before_type_cast, :body unless respond_to?(:body_before_type_cast) - alias_method :author_name_before_type_cast, :author_name unless respond_to?(:author_name_before_type_cast) - end - - User = Struct.new("User", :email) - User.class_eval do - alias_method :email_before_type_cast, :email unless respond_to?(:email_before_type_cast) - end - - Column = Struct.new("Column", :type, :name, :human_name) - end - - class DirtyPost - class Errors - def empty? - false - end - - def count - 1 - end - - def full_messages - ["Author name can't be <em>empty</em>"] - end - - def on(field) - "can't be <em>empty</em>" - end - end - - def errors - Errors.new - end - end - - def setup_post - @post = Post.new - def @post.errors - Class.new { - def on(field) - case field.to_s - when "author_name" - "can't be empty" - when "body" - true - else - false - end - end - def empty?() false end - def count() 1 end - def full_messages() [ "Author name can't be empty" ] end - }.new - end - - def @post.new_record?() true end - def @post.to_param() nil end - - def @post.column_for_attribute(attr_name) - Post.content_columns.select { |column| column.name == attr_name }.first - end - - silence_warnings do - def Post.content_columns() [ Column.new(:string, "title", "Title"), Column.new(:text, "body", "Body") ] end - end - - @post.title = "Hello World" - @post.author_name = "" - @post.body = "Back to the hill and over it again!" - @post.secret = 1 - @post.written_on = Date.new(2004, 6, 15) - end - - def setup_user - @user = User.new - def @user.errors - Class.new { - def on(field) field == "email" end - def empty?() false end - def count() 1 end - def full_messages() [ "User email can't be empty" ] end - }.new - end - - def @user.new_record?() true end - def @user.to_param() nil end - - def @user.column_for_attribute(attr_name) - User.content_columns.select { |column| column.name == attr_name }.first - end - - silence_warnings do - def User.content_columns() [ Column.new(:string, "email", "Email") ] end - end - - @user.email = "" - end - - def protect_against_forgery? - @protect_against_forgery ? true : false - end - attr_accessor :request_forgery_protection_token, :form_authenticity_token - - def setup - setup_post - setup_user - - @response = ActionController::TestResponse.new - - @controller = Object.new - def @controller.url_for(options) - options = options.symbolize_keys - - [options[:action], options[:id].to_param].compact.join('/') - end - end - - def test_generic_input_tag - assert_dom_equal( - %(<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />), input("post", "title") - ) - end - - def test_text_area_with_errors - assert_dom_equal( - %(<div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div>), - text_area("post", "body") - ) - end - - def test_text_field_with_errors - assert_dom_equal( - %(<div class="fieldWithErrors"><input id="post_author_name" name="post[author_name]" size="30" type="text" value="" /></div>), - text_field("post", "author_name") - ) - end - - def test_form_with_string - assert_dom_equal( - %(<form action="create" method="post"><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>), - form("post") - ) - - silence_warnings do - class << @post - def new_record?() false end - def to_param() id end - def id() 1 end - end - end - - assert_dom_equal( - %(<form action="update/1" method="post"><input id="post_id" name="post[id]" type="hidden" value="1" /><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Update" /></form>), - form("post") - ) - end - - def test_form_with_protect_against_forgery - @protect_against_forgery = true - @request_forgery_protection_token = 'authenticity_token' - @form_authenticity_token = '123' - assert_dom_equal( - %(<form action="create" method="post"><div style='margin:0;padding:0'><input type='hidden' name='authenticity_token' value='123' /></div><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>), - form("post") - ) - end - - def test_form_with_method_option - assert_dom_equal( - %(<form action="create" method="get"><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>), - form("post", :method=>'get') - ) - end - - def test_form_with_action_option - @response.body = form("post", :action => "sign") - assert_select "form[action=sign]" do |form| - assert_select "input[type=submit][value=Sign]" - end - end - - def test_form_with_date - silence_warnings do - def Post.content_columns() [ Column.new(:date, "written_on", "Written on") ] end - end - - assert_dom_equal( - %(<form action="create" method="post"><p><label for="post_written_on">Written on</label><br /><select id="post_written_on_1i" name="post[written_on(1i)]">\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n</select>\n<select id="post_written_on_2i" name="post[written_on(2i)]">\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n</select>\n<select id="post_written_on_3i" name="post[written_on(3i)]">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n</select>\n</p><input name="commit" type="submit" value="Create" /></form>), - form("post") - ) - end - - def test_form_with_datetime - silence_warnings do - def Post.content_columns() [ Column.new(:datetime, "written_on", "Written on") ] end - end - @post.written_on = Time.gm(2004, 6, 15, 16, 30) - - assert_dom_equal( - %(<form action="create" method="post"><p><label for="post_written_on">Written on</label><br /><select id="post_written_on_1i" name="post[written_on(1i)]">\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n</select>\n<select id="post_written_on_2i" name="post[written_on(2i)]">\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n</select>\n<select id="post_written_on_3i" name="post[written_on(3i)]">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n</select>\n &mdash; <select id="post_written_on_4i" name="post[written_on(4i)]">\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n</select>\n : <select id="post_written_on_5i" name="post[written_on(5i)]">\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30" selected="selected">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n</select>\n</p><input name="commit" type="submit" value="Create" /></form>), - form("post") - ) - end - - def test_error_for_block - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post") - assert_equal %(<div class="errorDeathByClass" id="errorDeathById"><h1>1 error prohibited this post from being saved</h1><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post", :class => "errorDeathByClass", :id => "errorDeathById", :header_tag => "h1") - assert_equal %(<div id="errorDeathById"><h1>1 error prohibited this post from being saved</h1><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post", :class => nil, :id => "errorDeathById", :header_tag => "h1") - assert_equal %(<div class="errorDeathByClass"><h1>1 error prohibited this post from being saved</h1><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post", :class => "errorDeathByClass", :id => nil, :header_tag => "h1") - end - - def test_error_messages_for_escapes_html - @dirty_post = DirtyPost.new - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this dirty post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be &lt;em&gt;empty&lt;/em&gt;</li></ul></div>), error_messages_for("dirty_post") - end - - def test_error_messages_for_handles_nil - assert_equal "", error_messages_for("notthere") - end - - def test_error_message_on_escapes_html - @dirty_post = DirtyPost.new - assert_dom_equal "<div class=\"formError\">can't be &lt;em&gt;empty&lt;/em&gt;</div>", error_message_on(:dirty_post, :author_name) - end - - def test_error_message_on_handles_nil - assert_equal "", error_message_on("notthere", "notthere") - end - - def test_error_message_on - assert_dom_equal "<div class=\"formError\">can't be empty</div>", error_message_on(:post, :author_name) - end - - def test_error_message_on_no_instance_variable - other_post = @post - assert_dom_equal "<div class=\"formError\">can't be empty</div>", error_message_on(other_post, :author_name) - end - - def test_error_message_on_with_options_hash - assert_dom_equal "<div class=\"differentError\">beforecan't be emptyafter</div>", error_message_on(:post, :author_name, :css_class => 'differentError', :prepend_text => 'before', :append_text => 'after') - end - - def test_error_messages_for_many_objects - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li><li>User email can't be empty</li></ul></div>), error_messages_for("post", "user") - - # reverse the order, error order changes and so does the title - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this user from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for("user", "post") - - # add the default to put post back in the title - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for("user", "post", :object_name => "post") - - # symbols work as well - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for(:user, :post, :object_name => :post) - - # any default works too - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this monkey from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for(:user, :post, :object_name => "monkey") - - # should space object name - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this chunky bacon from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for(:user, :post, :object_name => "chunky_bacon") - - # hide header and explanation messages with nil or empty string - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for(:user, :post, :header_message => nil, :message => "") - - # override header and explanation messages - header_message = "Yikes! Some errors" - message = "Please fix the following fields and resubmit:" - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>#{header_message}</h2><p>#{message}</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for(:user, :post, :header_message => header_message, :message => message) - end - - def test_error_messages_for_non_instance_variable - actual_user = @user - actual_post = @post - @user = nil - @post = nil - - #explicitly set object - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post", :object => actual_post) - - #multiple objects - assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this user from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for("user", "post", :object => [actual_user, actual_post]) - - #nil object - assert_equal '', error_messages_for('user', :object => nil) - end - - def test_form_with_string_multipart - assert_dom_equal( - %(<form action="create" enctype="multipart/form-data" method="post"><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>), - form("post", :multipart => true) - ) - end -end diff --git a/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb b/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb deleted file mode 100644 index 32ad87c..0000000 --- a/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb +++ /dev/null @@ -1,713 +0,0 @@ -require 'abstract_unit' - -class AssetTagHelperTest < ActionView::TestCase - tests ActionView::Helpers::AssetTagHelper - - def setup - silence_warnings do - ActionView::Helpers::AssetTagHelper.send( - :const_set, - :JAVASCRIPTS_DIR, - File.dirname(__FILE__) + "/../fixtures/public/javascripts" - ) - - ActionView::Helpers::AssetTagHelper.send( - :const_set, - :STYLESHEETS_DIR, - File.dirname(__FILE__) + "/../fixtures/public/stylesheets" - ) - - ActionView::Helpers::AssetTagHelper.send( - :const_set, - :ASSETS_DIR, - File.dirname(__FILE__) + "/../fixtures/public" - ) - end - - @controller = Class.new do - attr_accessor :request - def url_for(*args) "http://www.example.com" end - end.new - - @request = Class.new do - def protocol() 'http://' end - def ssl?() false end - def host_with_port() 'localhost' end - end.new - - @controller.request = @request - - ActionView::Helpers::AssetTagHelper::reset_javascript_include_default - end - - def teardown - ActionController::Base.perform_caching = false - ActionController::Base.asset_host = nil - ENV.delete('RAILS_ASSET_ID') - end - - AutoDiscoveryToTag = { - %(auto_discovery_link_tag) => %(<link href="http://www.example.com" rel="alternate" title="RSS" type="application/rss+xml" />), - %(auto_discovery_link_tag(:rss)) => %(<link href="http://www.example.com" rel="alternate" title="RSS" type="application/rss+xml" />), - %(auto_discovery_link_tag(:atom)) => %(<link href="http://www.example.com" rel="alternate" title="ATOM" type="application/atom+xml" />), - %(auto_discovery_link_tag(:xml)) => %(<link href="http://www.example.com" rel="alternate" title="XML" type="application/xml" />), - %(auto_discovery_link_tag(:rss, :action => "feed")) => %(<link href="http://www.example.com" rel="alternate" title="RSS" type="application/rss+xml" />), - %(auto_discovery_link_tag(:rss, "http://localhost/feed")) => %(<link href="http://localhost/feed" rel="alternate" title="RSS" type="application/rss+xml" />), - %(auto_discovery_link_tag(:rss, {:action => "feed"}, {:title => "My RSS"})) => %(<link href="http://www.example.com" rel="alternate" title="My RSS" type="application/rss+xml" />), - %(auto_discovery_link_tag(:rss, {}, {:title => "My RSS"})) => %(<link href="http://www.example.com" rel="alternate" title="My RSS" type="application/rss+xml" />), - %(auto_discovery_link_tag(nil, {}, {:type => "text/html"})) => %(<link href="http://www.example.com" rel="alternate" title="" type="text/html" />), - %(auto_discovery_link_tag(nil, {}, {:title => "No stream.. really", :type => "text/html"})) => %(<link href="http://www.example.com" rel="alternate" title="No stream.. really" type="text/html" />), - %(auto_discovery_link_tag(:rss, {}, {:title => "My RSS", :type => "text/html"})) => %(<link href="http://www.example.com" rel="alternate" title="My RSS" type="text/html" />), - %(auto_discovery_link_tag(:atom, {}, {:rel => "Not so alternate"})) => %(<link href="http://www.example.com" rel="Not so alternate" title="ATOM" type="application/atom+xml" />), - } - - JavascriptPathToTag = { - %(javascript_path("xmlhr")) => %(/javascripts/xmlhr.js), - %(javascript_path("super/xmlhr")) => %(/javascripts/super/xmlhr.js), - %(javascript_path("/super/xmlhr.js")) => %(/super/xmlhr.js) - } - - PathToJavascriptToTag = { - %(path_to_javascript("xmlhr")) => %(/javascripts/xmlhr.js), - %(path_to_javascript("super/xmlhr")) => %(/javascripts/super/xmlhr.js), - %(path_to_javascript("/super/xmlhr.js")) => %(/super/xmlhr.js) - } - - JavascriptIncludeToTag = { - %(javascript_include_tag("xmlhr")) => %(<script src="/javascripts/xmlhr.js" type="text/javascript"></script>), - %(javascript_include_tag("xmlhr.js")) => %(<script src="/javascripts/xmlhr.js" type="text/javascript"></script>), - %(javascript_include_tag("xmlhr", :lang => "vbscript")) => %(<script lang="vbscript" src="/javascripts/xmlhr.js" type="text/javascript"></script>), - %(javascript_include_tag("common.javascript", "/elsewhere/cools")) => %(<script src="/javascripts/common.javascript" type="text/javascript"></script>\n<script src="/elsewhere/cools.js" type="text/javascript"></script>), - %(javascript_include_tag(:defaults)) => %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>), - %(javascript_include_tag(:all)) => %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>\n<script src="/javascripts/version.1.0.js" type="text/javascript"></script>), - %(javascript_include_tag(:all, :recursive => true)) => %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>\n<script src="/javascripts/subdir/subdir.js" type="text/javascript"></script>\n<script src="/javascripts/version.1.0.js" type="text/javascript"></script>), - %(javascript_include_tag(:defaults, "test")) => %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/test.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>), - %(javascript_include_tag("test", :defaults)) => %(<script src="/javascripts/test.js" type="text/javascript"></script>\n<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>) - } - - StylePathToTag = { - %(stylesheet_path("style")) => %(/stylesheets/style.css), - %(stylesheet_path("style.css")) => %(/stylesheets/style.css), - %(stylesheet_path('dir/file')) => %(/stylesheets/dir/file.css), - %(stylesheet_path('/dir/file.rcss')) => %(/dir/file.rcss) - } - - PathToStyleToTag = { - %(path_to_stylesheet("style")) => %(/stylesheets/style.css), - %(path_to_stylesheet("style.css")) => %(/stylesheets/style.css), - %(path_to_stylesheet('dir/file')) => %(/stylesheets/dir/file.css), - %(path_to_stylesheet('/dir/file.rcss')) => %(/dir/file.rcss) - } - - StyleLinkToTag = { - %(stylesheet_link_tag("style")) => %(<link href="/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag("style.css")) => %(<link href="/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag("/dir/file")) => %(<link href="/dir/file.css" media="screen" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag("dir/file")) => %(<link href="/stylesheets/dir/file.css" media="screen" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag("style", :media => "all")) => %(<link href="/stylesheets/style.css" media="all" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag(:all)) => %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/version.1.0.css" media="screen" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag(:all, :recursive => true)) => %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/subdir/subdir.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/version.1.0.css" media="screen" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag(:all, :media => "all")) => %(<link href="/stylesheets/bank.css" media="all" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="all" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/version.1.0.css" media="all" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag("random.styles", "/css/stylish")) => %(<link href="/stylesheets/random.styles" media="screen" rel="stylesheet" type="text/css" />\n<link href="/css/stylish.css" media="screen" rel="stylesheet" type="text/css" />), - %(stylesheet_link_tag("http://www.example.com/styles/style")) => %(<link href="http://www.example.com/styles/style.css" media="screen" rel="stylesheet" type="text/css" />) - } - - ImagePathToTag = { - %(image_path("xml")) => %(/images/xml), - %(image_path("xml.png")) => %(/images/xml.png), - %(image_path("dir/xml.png")) => %(/images/dir/xml.png), - %(image_path("/dir/xml.png")) => %(/dir/xml.png) - } - - PathToImageToTag = { - %(path_to_image("xml")) => %(/images/xml), - %(path_to_image("xml.png")) => %(/images/xml.png), - %(path_to_image("dir/xml.png")) => %(/images/dir/xml.png), - %(path_to_image("/dir/xml.png")) => %(/dir/xml.png) - } - - ImageLinkToTag = { - %(image_tag("xml.png")) => %(<img alt="Xml" src="/images/xml.png" />), - %(image_tag("..jpg")) => %(<img alt="" src="/images/..jpg" />), - %(image_tag("rss.gif", :alt => "rss syndication")) => %(<img alt="rss syndication" src="/images/rss.gif" />), - %(image_tag("gold.png", :size => "45x70")) => %(<img alt="Gold" height="70" src="/images/gold.png" width="45" />), - %(image_tag("gold.png", "size" => "45x70")) => %(<img alt="Gold" height="70" src="/images/gold.png" width="45" />), - %(image_tag("error.png", "size" => "45")) => %(<img alt="Error" src="/images/error.png" />), - %(image_tag("error.png", "size" => "45 x 70")) => %(<img alt="Error" src="/images/error.png" />), - %(image_tag("error.png", "size" => "x")) => %(<img alt="Error" src="/images/error.png" />), - %(image_tag("http://www.rubyonrails.com/images/rails.png")) => %(<img alt="Rails" src="http://www.rubyonrails.com/images/rails.png" />), - %(image_tag("http://www.rubyonrails.com/images/rails.png")) => %(<img alt="Rails" src="http://www.rubyonrails.com/images/rails.png" />), - %(image_tag("mouse.png", :mouseover => "/images/mouse_over.png")) => %(<img alt="Mouse" onmouseover="this.src='/images/mouse_over.png'" onmouseout="this.src='/images/mouse.png'" src="/images/mouse.png" />), - %(image_tag("mouse.png", :mouseover => image_path("mouse_over.png"))) => %(<img alt="Mouse" onmouseover="this.src='/images/mouse_over.png'" onmouseout="this.src='/images/mouse.png'" src="/images/mouse.png" />) - } - - - def test_auto_discovery_link_tag - AutoDiscoveryToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_javascript_path - JavascriptPathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_path_to_javascript_alias_for_javascript_path - PathToJavascriptToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_javascript_include_tag_with_blank_asset_id - ENV["RAILS_ASSET_ID"] = "" - JavascriptIncludeToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_javascript_include_tag_with_given_asset_id - ENV["RAILS_ASSET_ID"] = "1" - assert_dom_equal(%(<script src="/javascripts/prototype.js?1" type="text/javascript"></script>\n<script src="/javascripts/effects.js?1" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js?1" type="text/javascript"></script>\n<script src="/javascripts/controls.js?1" type="text/javascript"></script>\n<script src="/javascripts/application.js?1" type="text/javascript"></script>), javascript_include_tag(:defaults)) - end - - def test_register_javascript_include_default - ENV["RAILS_ASSET_ID"] = "" - ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'slider' - assert_dom_equal %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/slider.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>), javascript_include_tag(:defaults) - end - - def test_register_javascript_include_default_mixed_defaults - ENV["RAILS_ASSET_ID"] = "" - ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'slider' - ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'lib1', '/elsewhere/blub/lib2' - assert_dom_equal %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/slider.js" type="text/javascript"></script>\n<script src="/javascripts/lib1.js" type="text/javascript"></script>\n<script src="/elsewhere/blub/lib2.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>), javascript_include_tag(:defaults) - end - - def test_custom_javascript_expansions - ActionView::Helpers::AssetTagHelper::register_javascript_expansion :monkey => ["head", "body", "tail"] - assert_dom_equal %(<script src="/javascripts/first.js" type="text/javascript"></script>\n<script src="/javascripts/head.js" type="text/javascript"></script>\n<script src="/javascripts/body.js" type="text/javascript"></script>\n<script src="/javascripts/tail.js" type="text/javascript"></script>\n<script src="/javascripts/last.js" type="text/javascript"></script>), javascript_include_tag('first', :monkey, 'last') - end - - def test_custom_javascript_expansions_and_defaults_puts_application_js_at_the_end - ENV["RAILS_ASSET_ID"] = "" - ActionView::Helpers::AssetTagHelper::register_javascript_expansion :monkey => ["head", "body", "tail"] - assert_dom_equal %(<script src="/javascripts/first.js" type="text/javascript"></script>\n<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/head.js" type="text/javascript"></script>\n<script src="/javascripts/body.js" type="text/javascript"></script>\n<script src="/javascripts/tail.js" type="text/javascript"></script>\n<script src="/javascripts/last.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>), javascript_include_tag('first', :defaults, :monkey, 'last') - end - - def test_custom_javascript_expansions_with_undefined_symbol - ActionView::Helpers::AssetTagHelper::register_javascript_expansion :monkey => nil - assert_raise(ArgumentError) { javascript_include_tag('first', :monkey, 'last') } - end - - def test_stylesheet_path - StylePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_path_to_stylesheet_alias_for_stylesheet_path - PathToStyleToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_stylesheet_link_tag - ENV["RAILS_ASSET_ID"] = "" - StyleLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_custom_stylesheet_expansions - ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :monkey => ["head", "body", "tail"] - assert_dom_equal %(<link href="/stylesheets/first.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/head.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/body.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/tail.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/last.css" media="screen" rel="stylesheet" type="text/css" />), stylesheet_link_tag('first', :monkey, 'last') - end - - def test_custom_stylesheet_expansions_with_undefined_symbol - ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :monkey => nil - assert_raise(ArgumentError) { stylesheet_link_tag('first', :monkey, 'last') } - end - - def test_image_path - ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_path_to_image_alias_for_image_path - PathToImageToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_image_tag - ImageLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - end - - def test_image_tag_windows_behaviour - old_asset_id, ENV["RAILS_ASSET_ID"] = ENV["RAILS_ASSET_ID"], "1" - # This simulates the behaviour of File#exist? on windows when testing a file ending in "." - # If the file "rails.png" exists, windows will return true when asked if "rails.png." exists (notice trailing ".") - # OS X, linux etc will return false in this case. - File.stubs(:exist?).with('template/../fixtures/public/images/rails.png.').returns(true) - assert_equal '<img alt="Rails" src="/images/rails.png?1" />', image_tag('rails.png') - ensure - if old_asset_id - ENV["RAILS_ASSET_ID"] = old_asset_id - else - ENV.delete("RAILS_ASSET_ID") - end - end - - def test_timebased_asset_id - expected_time = File.stat(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).mtime.to_i.to_s - assert_equal %(<img alt="Rails" src="/images/rails.png?#{expected_time}" />), image_tag("rails.png") - end - - def test_timebased_asset_id_with_relative_url_root - ActionController::Base.relative_url_root = "/collaboration/hieraki" - expected_time = File.stat(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).mtime.to_i.to_s - assert_equal %(<img alt="Rails" src="#{ActionController::Base.relative_url_root}/images/rails.png?#{expected_time}" />), image_tag("rails.png") - ensure - ActionController::Base.relative_url_root = "" - end - - def test_should_skip_asset_id_on_complete_url - assert_equal %(<img alt="Rails" src="http://www.example.com/rails.png" />), image_tag("http://www.example.com/rails.png") - end - - def test_should_use_preset_asset_id - ENV["RAILS_ASSET_ID"] = "4500" - assert_equal %(<img alt="Rails" src="/images/rails.png?4500" />), image_tag("rails.png") - end - - def test_preset_empty_asset_id - ENV["RAILS_ASSET_ID"] = "" - assert_equal %(<img alt="Rails" src="/images/rails.png" />), image_tag("rails.png") - end - - def test_should_not_modify_source_string - source = '/images/rails.png' - copy = source.dup - image_tag(source) - assert_equal copy, source - end - - def test_caching_image_path_with_caching_and_proc_asset_host_using_request - ENV['RAILS_ASSET_ID'] = '' - ActionController::Base.asset_host = Proc.new do |source, request| - if request.ssl? - "#{request.protocol}#{request.host_with_port}" - else - "#{request.protocol}assets#{source.length}.example.com" - end - end - - ActionController::Base.perform_caching = true - - - @controller.request.stubs(:ssl?).returns(false) - assert_equal "http://assets15.example.com/images/xml.png", image_path("xml.png") - - @controller.request.stubs(:ssl?).returns(true) - assert_equal "http://localhost/images/xml.png", image_path("xml.png") - end - - def test_caching_javascript_include_tag_when_caching_on - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.asset_host = 'http://a0.example.com' - ActionController::Base.perform_caching = true - - assert_dom_equal( - %(<script src="http://a0.example.com/javascripts/all.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => true) - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) - - assert_dom_equal( - %(<script src="http://a0.example.com/javascripts/money.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => "money") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) - - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) - end - - def test_caching_javascript_include_tag_when_caching_on_with_proc_asset_host - ENV['RAILS_ASSET_ID'] = '' - ActionController::Base.asset_host = Proc.new { |source| "http://a#{source.length}.example.com" } - ActionController::Base.perform_caching = true - - assert_equal '/javascripts/scripts.js'.length, 23 - assert_dom_equal( - %(<script src="http://a23.example.com/javascripts/scripts.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => 'scripts') - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'scripts.js')) - - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'scripts.js')) - end - - def test_caching_javascript_include_tag_when_caching_on_with_2_argument_proc_asset_host - ENV['RAILS_ASSET_ID'] = '' - ActionController::Base.asset_host = Proc.new { |source, request| - if request.ssl? - "#{request.protocol}#{request.host_with_port}" - else - "#{request.protocol}assets#{source.length}.example.com" - end - } - ActionController::Base.perform_caching = true - - assert_equal '/javascripts/vanilla.js'.length, 23 - assert_dom_equal( - %(<script src="http://assets23.example.com/javascripts/vanilla.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => 'vanilla') - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'vanilla.js')) - - class << @controller.request - def protocol() 'https://' end - def ssl?() true end - end - - assert_equal '/javascripts/secure.js'.length, 22 - assert_dom_equal( - %(<script src="https://localhost/javascripts/secure.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => 'secure') - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'secure.js')) - - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'vanilla.js')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'secure.js')) - end - - def test_caching_javascript_include_tag_when_caching_on_with_2_argument_object_asset_host - ENV['RAILS_ASSET_ID'] = '' - ActionController::Base.asset_host = Class.new do - def call(source, request) - if request.ssl? - "#{request.protocol}#{request.host_with_port}" - else - "#{request.protocol}assets#{source.length}.example.com" - end - end - end.new - - ActionController::Base.perform_caching = true - - assert_equal '/javascripts/vanilla.js'.length, 23 - assert_dom_equal( - %(<script src="http://assets23.example.com/javascripts/vanilla.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => 'vanilla') - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'vanilla.js')) - - class << @controller.request - def protocol() 'https://' end - def ssl?() true end - end - - assert_equal '/javascripts/secure.js'.length, 22 - assert_dom_equal( - %(<script src="https://localhost/javascripts/secure.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => 'secure') - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'secure.js')) - - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'vanilla.js')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'secure.js')) - end - - def test_caching_javascript_include_tag_when_caching_on_and_using_subdirectory - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.asset_host = 'http://a%d.example.com' - ActionController::Base.perform_caching = true - - hash = '/javascripts/cache/money.js'.hash % 4 - assert_dom_equal( - %(<script src="http://a#{hash}.example.com/javascripts/cache/money.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => "cache/money") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js')) - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js')) - end - - def test_caching_javascript_include_tag_with_all_and_recursive_puts_defaults_at_the_start_of_the_file - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.asset_host = 'http://a0.example.com' - ActionController::Base.perform_caching = true - - assert_dom_equal( - %(<script src="http://a0.example.com/javascripts/combined.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => "combined", :recursive => true) - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'combined.js')) - - assert_equal( - %(// prototype js\n\n// effects js\n\n// dragdrop js\n\n// controls js\n\n// application js\n\n// bank js\n\n// robber js\n\n// subdir js\n\n\n// version.1.0 js), - IO.read(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'combined.js')) - ) - - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'combined.js')) - end - - def test_caching_javascript_include_tag_with_all_puts_defaults_at_the_start_of_the_file - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.asset_host = 'http://a0.example.com' - ActionController::Base.perform_caching = true - - assert_dom_equal( - %(<script src="http://a0.example.com/javascripts/combined.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => "combined") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'combined.js')) - - assert_equal( - %(// prototype js\n\n// effects js\n\n// dragdrop js\n\n// controls js\n\n// application js\n\n// bank js\n\n// robber js\n\n// version.1.0 js), - IO.read(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'combined.js')) - ) - - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'combined.js')) - end - - def test_caching_javascript_include_tag_with_relative_url_root - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.relative_url_root = "/collaboration/hieraki" - ActionController::Base.perform_caching = true - - assert_dom_equal( - %(<script src="/collaboration/hieraki/javascripts/all.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => true) - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) - - assert_dom_equal( - %(<script src="/collaboration/hieraki/javascripts/money.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => "money") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) - - ensure - ActionController::Base.relative_url_root = nil - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) - end - - def test_caching_javascript_include_tag_when_caching_off - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.perform_caching = false - - assert_dom_equal( - %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>\n<script src="/javascripts/version.1.0.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => true) - ) - - assert_dom_equal( - %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>\n<script src="/javascripts/subdir/subdir.js" type="text/javascript"></script>\n<script src="/javascripts/version.1.0.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => true, :recursive => true) - ) - - assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) - - assert_dom_equal( - %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>\n<script src="/javascripts/version.1.0.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => "money") - ) - - assert_dom_equal( - %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>\n<script src="/javascripts/subdir/subdir.js" type="text/javascript"></script>\n<script src="/javascripts/version.1.0.js" type="text/javascript"></script>), - javascript_include_tag(:all, :cache => "money", :recursive => true) - ) - - assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) - end - - def test_caching_stylesheet_link_tag_when_caching_on - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.asset_host = 'http://a0.example.com' - ActionController::Base.perform_caching = true - - assert_dom_equal( - %(<link href="http://a0.example.com/stylesheets/all.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => true) - ) - - expected = Dir["#{ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR}/*.css"].map { |p| File.mtime(p) }.max - assert_equal expected, File.mtime(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) - - assert_dom_equal( - %(<link href="http://a0.example.com/stylesheets/money.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => "money") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) - end - - def test_caching_stylesheet_link_tag_when_caching_on_with_proc_asset_host - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.asset_host = Proc.new { |source| "http://a#{source.length}.example.com" } - ActionController::Base.perform_caching = true - - assert_equal '/stylesheets/styles.css'.length, 23 - assert_dom_equal( - %(<link href="http://a23.example.com/stylesheets/styles.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => 'styles') - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'styles.css')) - - ensure - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'styles.css')) - end - - def test_caching_stylesheet_link_tag_with_relative_url_root - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.relative_url_root = "/collaboration/hieraki" - ActionController::Base.perform_caching = true - - assert_dom_equal( - %(<link href="/collaboration/hieraki/stylesheets/all.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => true) - ) - - expected = Dir["#{ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR}/*.css"].map { |p| File.mtime(p) }.max - assert_equal expected, File.mtime(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) - - assert_dom_equal( - %(<link href="/collaboration/hieraki/stylesheets/money.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => "money") - ) - - assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) - ensure - ActionController::Base.relative_url_root = nil - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) - FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) - end - - def test_caching_stylesheet_include_tag_when_caching_off - ENV["RAILS_ASSET_ID"] = "" - ActionController::Base.perform_caching = false - - assert_dom_equal( - %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/version.1.0.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => true) - ) - - assert_dom_equal( - %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/subdir/subdir.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/version.1.0.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => true, :recursive => true) - ) - - assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) - - assert_dom_equal( - %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/version.1.0.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => "money") - ) - - assert_dom_equal( - %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/subdir/subdir.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/version.1.0.css" media="screen" rel="stylesheet" type="text/css" />), - stylesheet_link_tag(:all, :cache => "money", :recursive => true) - ) - - assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) - end -end - -class AssetTagHelperNonVhostTest < ActionView::TestCase - tests ActionView::Helpers::AssetTagHelper - - def setup - ActionController::Base.relative_url_root = "/collaboration/hieraki" - - @controller = Class.new do - attr_accessor :request - - def url_for(options) - "http://www.example.com/collaboration/hieraki" - end - end.new - - @request = Class.new do - def protocol - 'gopher://' - end - end.new - - @controller.request = @request - - ActionView::Helpers::AssetTagHelper::reset_javascript_include_default - end - - def teardown - ActionController::Base.relative_url_root = nil - end - - def test_should_compute_proper_path - assert_dom_equal(%(<link href="http://www.example.com/collaboration/hieraki" rel="alternate" title="RSS" type="application/rss+xml" />), auto_discovery_link_tag) - assert_dom_equal(%(/collaboration/hieraki/javascripts/xmlhr.js), javascript_path("xmlhr")) - assert_dom_equal(%(/collaboration/hieraki/stylesheets/style.css), stylesheet_path("style")) - assert_dom_equal(%(/collaboration/hieraki/images/xml.png), image_path("xml.png")) - assert_dom_equal(%(<img alt="Mouse" onmouseover="this.src='/collaboration/hieraki/images/mouse_over.png'" onmouseout="this.src='/collaboration/hieraki/images/mouse.png'" src="/collaboration/hieraki/images/mouse.png" />), image_tag("mouse.png", :mouseover => "/images/mouse_over.png")) - assert_dom_equal(%(<img alt="Mouse2" onmouseover="this.src='/collaboration/hieraki/images/mouse_over2.png'" onmouseout="this.src='/collaboration/hieraki/images/mouse2.png'" src="/collaboration/hieraki/images/mouse2.png" />), image_tag("mouse2.png", :mouseover => image_path("mouse_over2.png"))) - end - - def test_should_ignore_relative_root_path_on_complete_url - assert_dom_equal(%(http://www.example.com/images/xml.png), image_path("http://www.example.com/images/xml.png")) - end - - def test_should_compute_proper_path_with_asset_host - ActionController::Base.asset_host = "http://assets.example.com" - assert_dom_equal(%(<link href="http://www.example.com/collaboration/hieraki" rel="alternate" title="RSS" type="application/rss+xml" />), auto_discovery_link_tag) - assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/javascripts/xmlhr.js), javascript_path("xmlhr")) - assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/stylesheets/style.css), stylesheet_path("style")) - assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/images/xml.png), image_path("xml.png")) - assert_dom_equal(%(<img alt="Mouse" onmouseover="this.src='http://assets.example.com/collaboration/hieraki/images/mouse_over.png'" onmouseout="this.src='http://assets.example.com/collaboration/hieraki/images/mouse.png'" src="http://assets.example.com/collaboration/hieraki/images/mouse.png" />), image_tag("mouse.png", :mouseover => "/images/mouse_over.png")) - assert_dom_equal(%(<img alt="Mouse2" onmouseover="this.src='http://assets.example.com/collaboration/hieraki/images/mouse_over2.png'" onmouseout="this.src='http://assets.example.com/collaboration/hieraki/images/mouse2.png'" src="http://assets.example.com/collaboration/hieraki/images/mouse2.png" />), image_tag("mouse2.png", :mouseover => image_path("mouse_over2.png"))) - ensure - ActionController::Base.asset_host = "" - end - - def test_should_ignore_asset_host_on_complete_url - ActionController::Base.asset_host = "http://assets.example.com" - assert_dom_equal(%(<link href="http://bar.example.com/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />), stylesheet_link_tag("http://bar.example.com/stylesheets/style.css")) - ensure - ActionController::Base.asset_host = "" - end - - def test_should_wildcard_asset_host_between_zero_and_four - ActionController::Base.asset_host = 'http://a%d.example.com' - assert_match %r(http://a[0123].example.com/collaboration/hieraki/images/xml.png), image_path('xml.png') - ensure - ActionController::Base.asset_host = nil - end - - def test_asset_host_without_protocol_should_use_request_protocol - ActionController::Base.asset_host = 'a.example.com' - assert_equal 'gopher://a.example.com/collaboration/hieraki/images/xml.png', image_path('xml.png') - ensure - ActionController::Base.asset_host = nil - end - - def test_asset_host_without_protocol_should_use_request_protocol_even_if_path_present - ActionController::Base.asset_host = 'a.example.com/files/go/here' - assert_equal 'gopher://a.example.com/files/go/here/collaboration/hieraki/images/xml.png', image_path('xml.png') - ensure - ActionController::Base.asset_host = nil - end - - def test_assert_css_and_js_of_the_same_name_return_correct_extension - assert_dom_equal(%(/collaboration/hieraki/javascripts/foo.js), javascript_path("foo")) - assert_dom_equal(%(/collaboration/hieraki/stylesheets/foo.css), stylesheet_path("foo")) - - end -end diff --git a/vendor/rails/actionpack/test/template/atom_feed_helper_test.rb b/vendor/rails/actionpack/test/template/atom_feed_helper_test.rb deleted file mode 100644 index 8a00a39..0000000 --- a/vendor/rails/actionpack/test/template/atom_feed_helper_test.rb +++ /dev/null @@ -1,286 +0,0 @@ -require 'abstract_unit' - -Scroll = Struct.new(:id, :to_param, :title, :body, :updated_at, :created_at) - -class ScrollsController < ActionController::Base - FEEDS = {} - FEEDS["defaults"] = <<-EOT - atom_feed(:schema_date => '2008') do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - for scroll in @scrolls - feed.entry(scroll) do |entry| - entry.title(scroll.title) - entry.content(scroll.body, :type => 'html') - - entry.author do |author| - author.name("DHH") - end - end - end - end - EOT - FEEDS["entry_options"] = <<-EOT - atom_feed do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - for scroll in @scrolls - feed.entry(scroll, :url => "/otherstuff/" + scroll.to_param, :updated => Time.utc(2007, 1, scroll.id)) do |entry| - entry.title(scroll.title) - entry.content(scroll.body, :type => 'html') - - entry.author do |author| - author.name("DHH") - end - end - end - end - EOT - FEEDS["xml_block"] = <<-EOT - atom_feed do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - feed.author do |author| - author.name("DHH") - end - - for scroll in @scrolls - feed.entry(scroll, :url => "/otherstuff/" + scroll.to_param, :updated => Time.utc(2007, 1, scroll.id)) do |entry| - entry.title(scroll.title) - entry.content(scroll.body, :type => 'html') - end - end - end - EOT - FEEDS["feed_with_atomPub_namespace"] = <<-EOT - atom_feed({'xmlns:app' => 'http://www.w3.org/2007/app', - 'xmlns:openSearch' => 'http://a9.com/-/spec/opensearch/1.1/'}) do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - for scroll in @scrolls - feed.entry(scroll) do |entry| - entry.title(scroll.title) - entry.content(scroll.body, :type => 'html') - entry.tag!('app:edited', Time.now) - - entry.author do |author| - author.name("DHH") - end - end - end - end - EOT - FEEDS["feed_with_overridden_ids"] = <<-EOT - atom_feed({:id => 'tag:test.rubyonrails.org,2008:test/'}) do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - for scroll in @scrolls - feed.entry(scroll, :id => "tag:test.rubyonrails.org,2008:"+scroll.id.to_s) do |entry| - entry.title(scroll.title) - entry.content(scroll.body, :type => 'html') - entry.tag!('app:edited', Time.now) - - entry.author do |author| - author.name("DHH") - end - end - end - end - EOT - FEEDS["feed_with_xml_processing_instructions"] = <<-EOT - atom_feed(:schema_date => '2008', - :instruct => {'xml-stylesheet' => { :href=> 't.css', :type => 'text/css' }}) do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - for scroll in @scrolls - feed.entry(scroll) do |entry| - entry.title(scroll.title) - entry.content(scroll.body, :type => 'html') - - entry.author do |author| - author.name("DHH") - end - end - end - end - EOT - FEEDS["feed_with_xml_processing_instructions_duplicate_targets"] = <<-EOT - atom_feed(:schema_date => '2008', - :instruct => {'target1' => [{ :a => '1', :b => '2' }, { :c => '3', :d => '4' }]}) do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - for scroll in @scrolls - feed.entry(scroll) do |entry| - entry.title(scroll.title) - entry.content(scroll.body, :type => 'html') - - entry.author do |author| - author.name("DHH") - end - end - end - end - EOT - FEEDS["feed_with_xhtml_content"] = <<-'EOT' - atom_feed do |feed| - feed.title("My great blog!") - feed.updated((@scrolls.first.created_at)) - - for scroll in @scrolls - feed.entry(scroll) do |entry| - entry.title(scroll.title) - entry.summary(:type => 'xhtml') do |xhtml| - xhtml.p "before #{scroll.id}" - xhtml.p {xhtml << scroll.body} - xhtml.p "after #{scroll.id}" - end - entry.tag!('app:edited', Time.now) - - entry.author do |author| - author.name("DHH") - end - end - end - end - EOT - def index - @scrolls = [ - Scroll.new(1, "1", "Hello One", "Something <i>COOL!</i>", Time.utc(2007, 12, 12, 15), Time.utc(2007, 12, 12, 15)), - Scroll.new(2, "2", "Hello Two", "Something Boring", Time.utc(2007, 12, 12, 15)), - ] - - render :inline => FEEDS[params[:id]], :type => :builder - end - - protected - - def rescue_action(e) - raise(e) - end -end - -class AtomFeedTest < ActionController::TestCase - tests ScrollsController - - def setup - @request.host = "www.nextangle.com" - end - - def test_feed_should_use_default_language_if_none_is_given - with_restful_routing(:scrolls) do - get :index, :id => "defaults" - assert_match %r{xml:lang="en-US"}, @response.body - end - end - - def test_feed_should_include_two_entries - with_restful_routing(:scrolls) do - get :index, :id => "defaults" - assert_select "entry", 2 - end - end - - def test_entry_should_only_use_published_if_created_at_is_present - with_restful_routing(:scrolls) do - get :index, :id => "defaults" - assert_select "published", 1 - end - end - - def test_entry_with_prefilled_options_should_use_those_instead_of_querying_the_record - with_restful_routing(:scrolls) do - get :index, :id => "entry_options" - - assert_select "updated", Time.utc(2007, 1, 1).xmlschema - assert_select "updated", Time.utc(2007, 1, 2).xmlschema - end - end - - def test_self_url_should_default_to_current_request_url - with_restful_routing(:scrolls) do - get :index, :id => "defaults" - assert_select "link[rel=self][href=http://www.nextangle.com/scrolls?id=defaults]" - end - end - - def test_feed_id_should_be_a_valid_tag - with_restful_routing(:scrolls) do - get :index, :id => "defaults" - assert_select "id", :text => "tag:www.nextangle.com,2008:/scrolls?id=defaults" - end - end - - def test_entry_id_should_be_a_valid_tag - with_restful_routing(:scrolls) do - get :index, :id => "defaults" - assert_select "entry id", :text => "tag:www.nextangle.com,2008:Scroll/1" - assert_select "entry id", :text => "tag:www.nextangle.com,2008:Scroll/2" - end - end - - def test_feed_should_allow_nested_xml_blocks - with_restful_routing(:scrolls) do - get :index, :id => "xml_block" - assert_select "author name", :text => "DHH" - end - end - - def test_feed_should_include_atomPub_namespace - with_restful_routing(:scrolls) do - get :index, :id => "feed_with_atomPub_namespace" - assert_match %r{xml:lang="en-US"}, @response.body - assert_match %r{xmlns="http://www.w3.org/2005/Atom"}, @response.body - assert_match %r{xmlns:app="http://www.w3.org/2007/app"}, @response.body - end - end - - def test_feed_should_allow_overriding_ids - with_restful_routing(:scrolls) do - get :index, :id => "feed_with_overridden_ids" - assert_select "id", :text => "tag:test.rubyonrails.org,2008:test/" - assert_select "entry id", :text => "tag:test.rubyonrails.org,2008:1" - assert_select "entry id", :text => "tag:test.rubyonrails.org,2008:2" - end - end - - def test_feed_xml_processing_instructions - with_restful_routing(:scrolls) do - get :index, :id => 'feed_with_xml_processing_instructions' - assert_match %r{<\?xml-stylesheet [^\?]*type="text/css"}, @response.body - assert_match %r{<\?xml-stylesheet [^\?]*href="t.css"}, @response.body - end - end - - def test_feed_xml_processing_instructions_duplicate_targets - with_restful_routing(:scrolls) do - get :index, :id => 'feed_with_xml_processing_instructions_duplicate_targets' - assert_match %r{<\?target1 (a="1" b="2"|b="2" a="1")\?>}, @response.body - assert_match %r{<\?target1 (c="3" d="4"|d="4" c="3")\?>}, @response.body - end - end - - def test_feed_xhtml - with_restful_routing(:scrolls) do - get :index, :id => "feed_with_xhtml_content" - assert_match %r{xmlns="http://www.w3.org/1999/xhtml"}, @response.body - assert_select "summary div p", :text => "Something Boring" - assert_select "summary div p", :text => "after 2" - end - end -private - def with_restful_routing(resources) - with_routing do |set| - set.draw do |map| - map.resources(resources) - end - yield - end - end -end diff --git a/vendor/rails/actionpack/test/template/benchmark_helper_test.rb b/vendor/rails/actionpack/test/template/benchmark_helper_test.rb deleted file mode 100644 index 5d2af7c..0000000 --- a/vendor/rails/actionpack/test/template/benchmark_helper_test.rb +++ /dev/null @@ -1,86 +0,0 @@ -require 'abstract_unit' -require 'action_view/helpers/benchmark_helper' - -class BenchmarkHelperTest < ActionView::TestCase - tests ActionView::Helpers::BenchmarkHelper - - def teardown - controller.logger.send(:clear_buffer) - end - - def controller - logger = ActiveSupport::BufferedLogger.new(StringIO.new) - logger.auto_flushing = false - @controller ||= Struct.new(:logger).new(logger) - end - - def test_without_block - assert_raise(LocalJumpError) { benchmark } - assert buffer.empty? - end - - def test_defaults - i_was_run = false - benchmark { i_was_run = true } - assert i_was_run - assert_last_logged - end - - def test_with_message - i_was_run = false - benchmark('test_run') { i_was_run = true } - assert i_was_run - assert_last_logged 'test_run' - end - - def test_with_message_and_deprecated_level - i_was_run = false - - assert_deprecated do - benchmark('debug_run', :debug) { i_was_run = true } - end - - assert i_was_run - assert_last_logged 'debug_run' - end - - def test_within_level - controller.logger.level = ActiveSupport::BufferedLogger::DEBUG - benchmark('included_debug_run', :level => :debug) { } - assert_last_logged 'included_debug_run' - end - - def test_outside_level - controller.logger.level = ActiveSupport::BufferedLogger::ERROR - benchmark('skipped_debug_run', :level => :debug) { } - assert_no_match(/skipped_debug_run/, buffer.last) - ensure - controller.logger.level = ActiveSupport::BufferedLogger::DEBUG - end - - def test_without_silencing - benchmark('debug_run', :silence => false) do - controller.logger.info "not silenced!" - end - - assert_equal 2, buffer.size - end - - def test_with_silencing - benchmark('debug_run', :silence => true) do - controller.logger.info "silenced!" - end - - assert_equal 1, buffer.size - end - - - private - def buffer - controller.logger.send(:buffer) - end - - def assert_last_logged(message = 'Benchmarking') - assert_match(/^#{message} \(.*\)$/, buffer.last) - end -end diff --git a/vendor/rails/actionpack/test/template/compiled_templates_test.rb b/vendor/rails/actionpack/test/template/compiled_templates_test.rb deleted file mode 100644 index 7d1d763..0000000 --- a/vendor/rails/actionpack/test/template/compiled_templates_test.rb +++ /dev/null @@ -1,203 +0,0 @@ -require 'abstract_unit' -require 'controller/fake_models' - -class CompiledTemplatesTest < Test::Unit::TestCase - - def setup - @compiled_templates = ActionView::Base::CompiledTemplates - @compiled_templates.instance_methods.each do |m| - @compiled_templates.send(:remove_method, m) if m =~ /^_run_/ - end - end - - def test_template_gets_compiled - with_caching(true) do - assert_equal 0, @compiled_templates.instance_methods.size - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - assert_equal 1, @compiled_templates.instance_methods.size - end - end - - def test_template_gets_recompiled_when_using_different_keys_in_local_assigns - with_caching(true) do - assert_equal 0, @compiled_templates.instance_methods.size - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - assert_equal "Hello world!", render(:file => "test/hello_world.erb", :locals => {:foo => "bar"}) - assert_equal 2, @compiled_templates.instance_methods.size - end - end - - def test_compiled_template_will_not_be_recompiled_when_rendered_with_identical_local_assigns - with_caching(true) do - assert_equal 0, @compiled_templates.instance_methods.size - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - ActionView::Template.any_instance.expects(:compile!).never - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - end - end - - def test_template_changes_are_not_reflected_with_cached_template_loading - with_caching(true) do - with_reloading(false) do - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - modify_template "test/hello_world.erb", "Goodbye world!" do - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - end - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - end - end - end - - def test_template_changes_are_reflected_without_cached_template_loading - with_caching(true) do - with_reloading(true) do - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - modify_template "test/hello_world.erb", "Goodbye world!" do - assert_equal "Goodbye world!", render(:file => "test/hello_world.erb") - end - assert_equal "Hello world!", render(:file => "test/hello_world.erb") - end - end - end - - def test_template_becomes_missing_if_deleted_without_cached_template_loading - with_reloading(true) do - assert_equal 'Hello world!', render(:file => 'test/hello_world.erb') - delete_template 'test/hello_world.erb' do - assert_raise(ActionView::MissingTemplate) { render(:file => 'test/hello_world.erb') } - end - assert_equal 'Hello world!', render(:file => 'test/hello_world.erb') - end - end - - def test_swapping_template_handler_is_working_without_cached_template_loading - with_reloading(true) do - assert_equal 'Hello world!', render(:file => 'test/hello_world') - delete_template 'test/hello_world.erb' do - rename_template 'test/hello_world_from_rxml.builder', 'test/hello_world.builder' do - assert_equal "<html>\n <p>Hello</p>\n</html>\n", render(:file => 'test/hello_world') - end - end - assert_equal 'Hello world!', render(:file => 'test/hello_world') - end - end - - def test_adding_localized_template_will_take_precedence_without_cached_template_loading - with_reloading(true) do - assert_equal 'Hello world!', render(:file => 'test/hello_world') - rename_template 'test/hello_world.da.html.erb', 'test/hello_world.en.html.erb' do - assert_equal 'Hey verden', render(:file => 'test/hello_world') - end - end - end - - def test_deleting_localized_template_will_fall_back_to_non_localized_template_without_cached_template_loading - with_reloading(true) do - rename_template 'test/hello_world.da.html.erb', 'test/hello_world.en.html.erb' do - assert_equal 'Hey verden', render(:file => 'test/hello_world') - delete_template 'test/hello_world.en.html.erb' do - assert_equal 'Hello world!', render(:file => 'test/hello_world') - end - assert_equal 'Hey verden', render(:file => 'test/hello_world') - end - end - end - - def test_parallel_reloadable_view_paths_are_working - with_reloading(true) do - view_paths_copy = new_reloadable_view_paths - assert_equal 'Hello world!', render(:file => 'test/hello_world') - with_view_paths(view_paths_copy, new_reloadable_view_paths) do - assert_equal 'Hello world!', render(:file => 'test/hello_world') - end - modify_template 'test/hello_world.erb', 'Goodbye world!' do - assert_equal 'Goodbye world!', render(:file => 'test/hello_world') - modify_template 'test/hello_world.erb', 'So long, world!' do - with_view_paths(view_paths_copy, new_reloadable_view_paths) do - assert_equal 'So long, world!', render(:file => 'test/hello_world') - end - assert_equal 'So long, world!', render(:file => 'test/hello_world') - end - end - end - end - - private - def render(*args) - view_paths = @explicit_view_paths || ActionController::Base.view_paths - ActionView::Base.new(view_paths, {}).render(*args) - end - - def with_view_paths(*args) - args.each do |view_paths| - begin - @explicit_view_paths = view_paths - yield - ensure - @explicit_view_paths = nil - end - end - end - - def reset_mtime_of(template_name, view_paths_to_use) - view_paths_to_use.find_template(template_name).previously_last_modified = 10.seconds.ago unless ActionView::Base.cache_template_loading? - end - - def modify_template(template, content, view_paths_to_use = ActionController::Base.view_paths) - filename = filename_for(template) - old_content = File.read(filename) - begin - File.open(filename, "wb+") { |f| f.write(content) } - reset_mtime_of(template, view_paths_to_use) - yield - ensure - File.open(filename, "wb+") { |f| f.write(old_content) } - reset_mtime_of(template, view_paths_to_use) - end - end - - def filename_for(template) - File.join(FIXTURE_LOAD_PATH, template) - end - - def rename_template(old_name, new_name) - File.rename(filename_for(old_name), filename_for(new_name)) - yield - ensure - File.rename(filename_for(new_name), filename_for(old_name)) - end - - def delete_template(template, &block) - rename_template(template, File.join(File.dirname(template), "__#{File.basename(template)}"), &block) - end - - def with_caching(perform_caching) - old_perform_caching = ActionController::Base.perform_caching - begin - ActionController::Base.perform_caching = perform_caching - yield - ensure - ActionController::Base.perform_caching = old_perform_caching - end - end - - def with_reloading(reload_templates, view_paths_owner = ActionController::Base) - old_view_paths, old_cache_templates = view_paths_owner.view_paths, ActionView::Base.cache_template_loading - begin - ActionView::Base.cache_template_loading = !reload_templates - view_paths_owner.view_paths = view_paths_for(reload_templates) - yield - ensure - view_paths_owner.view_paths, ActionView::Base.cache_template_loading = old_view_paths, old_cache_templates - end - end - - def new_reloadable_view_paths - ActionView::PathSet.new(CACHED_VIEW_PATHS.map(&:to_s)) - end - - def view_paths_for(reload_templates) - # reloadable paths are cheap to create - reload_templates ? new_reloadable_view_paths : CACHED_VIEW_PATHS - end -end diff --git a/vendor/rails/actionpack/test/template/date_helper_i18n_test.rb b/vendor/rails/actionpack/test/template/date_helper_i18n_test.rb deleted file mode 100644 index bc011f5..0000000 --- a/vendor/rails/actionpack/test/template/date_helper_i18n_test.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'abstract_unit' - -class DateHelperDistanceOfTimeInWordsI18nTests < Test::Unit::TestCase - include ActionView::Helpers::DateHelper - attr_reader :request - - def setup - @from = Time.mktime(2004, 6, 6, 21, 45, 0) - end - - # distance_of_time_in_words - - def test_distance_of_time_in_words_calls_i18n - { # with include_seconds - [2.seconds, true] => [:'less_than_x_seconds', 5], - [9.seconds, true] => [:'less_than_x_seconds', 10], - [19.seconds, true] => [:'less_than_x_seconds', 20], - [30.seconds, true] => [:'half_a_minute', nil], - [59.seconds, true] => [:'less_than_x_minutes', 1], - [60.seconds, true] => [:'x_minutes', 1], - - # without include_seconds - [29.seconds, false] => [:'less_than_x_minutes', 1], - [60.seconds, false] => [:'x_minutes', 1], - [44.minutes, false] => [:'x_minutes', 44], - [61.minutes, false] => [:'about_x_hours', 1], - [24.hours, false] => [:'x_days', 1], - [30.days, false] => [:'about_x_months', 1], - [60.days, false] => [:'x_months', 2], - [1.year, false] => [:'about_x_years', 1], - [3.years, false] => [:'over_x_years', 3] - - }.each do |passed, expected| - assert_distance_of_time_in_words_translates_key passed, expected - end - end - - def assert_distance_of_time_in_words_translates_key(passed, expected) - diff, include_seconds = *passed - key, count = *expected - to = @from + diff - - options = {:locale => 'en', :scope => :'datetime.distance_in_words'} - options[:count] = count if count - - I18n.expects(:t).with(key, options) - distance_of_time_in_words(@from, to, include_seconds, :locale => 'en') - end - - def test_distance_of_time_pluralizations - { [:'less_than_x_seconds', 1] => 'less than 1 second', - [:'less_than_x_seconds', 2] => 'less than 2 seconds', - [:'less_than_x_minutes', 1] => 'less than a minute', - [:'less_than_x_minutes', 2] => 'less than 2 minutes', - [:'x_minutes', 1] => '1 minute', - [:'x_minutes', 2] => '2 minutes', - [:'about_x_hours', 1] => 'about 1 hour', - [:'about_x_hours', 2] => 'about 2 hours', - [:'x_days', 1] => '1 day', - [:'x_days', 2] => '2 days', - [:'about_x_years', 1] => 'about 1 year', - [:'about_x_years', 2] => 'about 2 years', - [:'over_x_years', 1] => 'over 1 year', - [:'over_x_years', 2] => 'over 2 years' - - }.each do |args, expected| - key, count = *args - assert_equal expected, I18n.t(key, :count => count, :scope => 'datetime.distance_in_words') - end - end -end - -class DateHelperSelectTagsI18nTests < Test::Unit::TestCase - include ActionView::Helpers::DateHelper - attr_reader :request - - def setup - @prompt_defaults = {:year => 'Year', :month => 'Month', :day => 'Day', :hour => 'Hour', :minute => 'Minute', :second => 'Seconds'} - - I18n.stubs(:translate).with(:'date.month_names', :locale => 'en').returns Date::MONTHNAMES - end - - # select_month - - def test_select_month_given_use_month_names_option_does_not_translate_monthnames - I18n.expects(:translate).never - select_month(8, :locale => 'en', :use_month_names => Date::MONTHNAMES) - end - - def test_select_month_translates_monthnames - I18n.expects(:translate).with(:'date.month_names', :locale => 'en').returns Date::MONTHNAMES - select_month(8, :locale => 'en') - end - - def test_select_month_given_use_short_month_option_translates_abbr_monthnames - I18n.expects(:translate).with(:'date.abbr_month_names', :locale => 'en').returns Date::ABBR_MONTHNAMES - select_month(8, :locale => 'en', :use_short_month => true) - end - - def test_date_or_time_select_translates_prompts - @prompt_defaults.each do |key, prompt| - I18n.expects(:translate).with(('datetime.prompts.' + key.to_s).to_sym, :locale => 'en').returns prompt - end - - I18n.expects(:translate).with(:'date.order', :locale => 'en').returns [:year, :month, :day] - datetime_select('post', 'updated_at', :locale => 'en', :include_seconds => true, :prompt => true) - end - - # date_or_time_select - - def test_date_or_time_select_given_an_order_options_does_not_translate_order - I18n.expects(:translate).never - datetime_select('post', 'updated_at', :order => [:year, :month, :day], :locale => 'en') - end - - def test_date_or_time_select_given_no_order_options_translates_order - I18n.expects(:translate).with(:'date.order', :locale => 'en').returns [:year, :month, :day] - datetime_select('post', 'updated_at', :locale => 'en') - end -end diff --git a/vendor/rails/actionpack/test/template/date_helper_test.rb b/vendor/rails/actionpack/test/template/date_helper_test.rb deleted file mode 100644 index 2e4763f..0000000 --- a/vendor/rails/actionpack/test/template/date_helper_test.rb +++ /dev/null @@ -1,2469 +0,0 @@ -require 'abstract_unit' - -class DateHelperTest < ActionView::TestCase - tests ActionView::Helpers::DateHelper - - silence_warnings do - Post = Struct.new("Post", :id, :written_on, :updated_at) - Post.class_eval do - def id - 123 - end - def id_before_type_cast - 123 - end - def to_param - '123' - end - end - end - - def assert_distance_of_time_in_words(from, to=nil) - to ||= from - - # 0..1 with include_seconds - assert_equal "less than 5 seconds", distance_of_time_in_words(from, to + 0.seconds, true) - assert_equal "less than 5 seconds", distance_of_time_in_words(from, to + 4.seconds, true) - assert_equal "less than 10 seconds", distance_of_time_in_words(from, to + 5.seconds, true) - assert_equal "less than 10 seconds", distance_of_time_in_words(from, to + 9.seconds, true) - assert_equal "less than 20 seconds", distance_of_time_in_words(from, to + 10.seconds, true) - assert_equal "less than 20 seconds", distance_of_time_in_words(from, to + 19.seconds, true) - assert_equal "half a minute", distance_of_time_in_words(from, to + 20.seconds, true) - assert_equal "half a minute", distance_of_time_in_words(from, to + 39.seconds, true) - assert_equal "less than a minute", distance_of_time_in_words(from, to + 40.seconds, true) - assert_equal "less than a minute", distance_of_time_in_words(from, to + 59.seconds, true) - assert_equal "1 minute", distance_of_time_in_words(from, to + 60.seconds, true) - assert_equal "1 minute", distance_of_time_in_words(from, to + 89.seconds, true) - - # First case 0..1 - assert_equal "less than a minute", distance_of_time_in_words(from, to + 0.seconds) - assert_equal "less than a minute", distance_of_time_in_words(from, to + 29.seconds) - assert_equal "1 minute", distance_of_time_in_words(from, to + 30.seconds) - assert_equal "1 minute", distance_of_time_in_words(from, to + 1.minutes + 29.seconds) - - # 2..44 - assert_equal "2 minutes", distance_of_time_in_words(from, to + 1.minutes + 30.seconds) - assert_equal "44 minutes", distance_of_time_in_words(from, to + 44.minutes + 29.seconds) - - # 45..89 - assert_equal "about 1 hour", distance_of_time_in_words(from, to + 44.minutes + 30.seconds) - assert_equal "about 1 hour", distance_of_time_in_words(from, to + 89.minutes + 29.seconds) - - # 90..1439 - assert_equal "about 2 hours", distance_of_time_in_words(from, to + 89.minutes + 30.seconds) - assert_equal "about 24 hours", distance_of_time_in_words(from, to + 23.hours + 59.minutes + 29.seconds) - - # 1440..2879 - assert_equal "1 day", distance_of_time_in_words(from, to + 23.hours + 59.minutes + 30.seconds) - assert_equal "1 day", distance_of_time_in_words(from, to + 47.hours + 59.minutes + 29.seconds) - - # 2880..43199 - assert_equal "2 days", distance_of_time_in_words(from, to + 47.hours + 59.minutes + 30.seconds) - assert_equal "29 days", distance_of_time_in_words(from, to + 29.days + 23.hours + 59.minutes + 29.seconds) - - # 43200..86399 - assert_equal "about 1 month", distance_of_time_in_words(from, to + 29.days + 23.hours + 59.minutes + 30.seconds) - assert_equal "about 1 month", distance_of_time_in_words(from, to + 59.days + 23.hours + 59.minutes + 29.seconds) - - # 86400..525599 - assert_equal "2 months", distance_of_time_in_words(from, to + 59.days + 23.hours + 59.minutes + 30.seconds) - assert_equal "12 months", distance_of_time_in_words(from, to + 1.years - 31.seconds) - - # 525600..1051199 - assert_equal "about 1 year", distance_of_time_in_words(from, to + 1.years - 30.seconds) - assert_equal "about 1 year", distance_of_time_in_words(from, to + 2.years - 31.seconds) - - # > 1051199 - assert_equal "over 2 years", distance_of_time_in_words(from, to + 2.years + 30.seconds) - assert_equal "over 10 years", distance_of_time_in_words(from, to + 10.years) - - # test to < from - assert_equal "about 4 hours", distance_of_time_in_words(from + 4.hours, to) - assert_equal "less than 20 seconds", distance_of_time_in_words(from + 19.seconds, to, true) - end - - def test_distance_in_words - from = Time.mktime(2004, 6, 6, 21, 45, 0) - assert_distance_of_time_in_words(from) - end - - def test_distance_in_words_with_time_zones - from = Time.mktime(2004, 6, 6, 21, 45, 0) - assert_distance_of_time_in_words(from.in_time_zone('Alaska')) - assert_distance_of_time_in_words(from.in_time_zone('Hawaii')) - end - - def test_distance_in_words_with_different_time_zones - from = Time.mktime(2004, 6, 6, 21, 45, 0) - assert_distance_of_time_in_words( - from.in_time_zone('Alaska'), - from.in_time_zone('Hawaii') - ) - end - - def test_distance_in_words_with_dates - start_date = Date.new 1975, 1, 31 - end_date = Date.new 1977, 1, 31 - assert_equal("over 2 years", distance_of_time_in_words(start_date, end_date)) - end - - def test_distance_in_words_with_integers - assert_equal "less than a minute", distance_of_time_in_words(59) - assert_equal "about 1 hour", distance_of_time_in_words(60*60) - assert_equal "less than a minute", distance_of_time_in_words(0, 59) - assert_equal "about 1 hour", distance_of_time_in_words(60*60, 0) - end - - def test_time_ago_in_words - assert_equal "about 1 year", time_ago_in_words(1.year.ago - 1.day) - end - - def test_select_day - expected = %(<select id="date_day" name="date[day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_day(Time.mktime(2003, 8, 16)) - assert_dom_equal expected, select_day(16) - end - - def test_select_day_with_blank - expected = %(<select id="date_day" name="date[day]">\n) - expected << %(<option value=""></option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_day(Time.mktime(2003, 8, 16), :include_blank => true) - assert_dom_equal expected, select_day(16, :include_blank => true) - end - - def test_select_day_nil_with_blank - expected = %(<select id="date_day" name="date[day]">\n) - expected << %(<option value=""></option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_day(nil, :include_blank => true) - end - - def test_select_day_with_html_options - expected = %(<select id="date_day" name="date[day]" class="selector">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_day(Time.mktime(2003, 8, 16), {}, :class => 'selector') - assert_dom_equal expected, select_day(16, {}, :class => 'selector') - end - - def test_select_day_with_default_prompt - expected = %(<select id="date_day" name="date[day]">\n) - expected << %(<option value="">Day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_day(16, :prompt => true) - end - - def test_select_day_with_custom_prompt - expected = %(<select id="date_day" name="date[day]">\n) - expected << %(<option value="">Choose day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_day(16, :prompt => 'Choose day') - end - - def test_select_month - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16)) - assert_dom_equal expected, select_month(8) - end - - def test_select_month_with_disabled - expected = %(<select id="date_month" name="date[month]" disabled="disabled">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :disabled => true) - assert_dom_equal expected, select_month(8, :disabled => true) - end - - def test_select_month_with_field_name_override - expected = %(<select id="date_mois" name="date[mois]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :field_name => 'mois') - assert_dom_equal expected, select_month(8, :field_name => 'mois') - end - - def test_select_month_with_blank - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value=""></option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :include_blank => true) - assert_dom_equal expected, select_month(8, :include_blank => true) - end - - def test_select_month_nil_with_blank - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value=""></option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(nil, :include_blank => true) - end - - def test_select_month_with_numbers - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8" selected="selected">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_numbers => true) - assert_dom_equal expected, select_month(8, :use_month_numbers => true) - end - - def test_select_month_with_numbers_and_names - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value="1">1 - January</option>\n<option value="2">2 - February</option>\n<option value="3">3 - March</option>\n<option value="4">4 - April</option>\n<option value="5">5 - May</option>\n<option value="6">6 - June</option>\n<option value="7">7 - July</option>\n<option value="8" selected="selected">8 - August</option>\n<option value="9">9 - September</option>\n<option value="10">10 - October</option>\n<option value="11">11 - November</option>\n<option value="12">12 - December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :add_month_numbers => true) - assert_dom_equal expected, select_month(8, :add_month_numbers => true) - end - - def test_select_month_with_numbers_and_names_with_abbv - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value="1">1 - Jan</option>\n<option value="2">2 - Feb</option>\n<option value="3">3 - Mar</option>\n<option value="4">4 - Apr</option>\n<option value="5">5 - May</option>\n<option value="6">6 - Jun</option>\n<option value="7">7 - Jul</option>\n<option value="8" selected="selected">8 - Aug</option>\n<option value="9">9 - Sep</option>\n<option value="10">10 - Oct</option>\n<option value="11">11 - Nov</option>\n<option value="12">12 - Dec</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :add_month_numbers => true, :use_short_month => true) - assert_dom_equal expected, select_month(8, :add_month_numbers => true, :use_short_month => true) - end - - def test_select_month_with_abbv - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value="1">Jan</option>\n<option value="2">Feb</option>\n<option value="3">Mar</option>\n<option value="4">Apr</option>\n<option value="5">May</option>\n<option value="6">Jun</option>\n<option value="7">Jul</option>\n<option value="8" selected="selected">Aug</option>\n<option value="9">Sep</option>\n<option value="10">Oct</option>\n<option value="11">Nov</option>\n<option value="12">Dec</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_short_month => true) - assert_dom_equal expected, select_month(8, :use_short_month => true) - end - - def test_select_month_with_custom_names - month_names = %w(nil Januar Februar Marts April Maj Juni Juli August September Oktober November December) - - expected = %(<select id="date_month" name="date[month]">\n) - 1.upto(12) { |month| expected << %(<option value="#{month}"#{' selected="selected"' if month == 8}>#{month_names[month]}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_names => month_names) - assert_dom_equal expected, select_month(8, :use_month_names => month_names) - end - - def test_select_month_with_zero_indexed_custom_names - month_names = %w(Januar Februar Marts April Maj Juni Juli August September Oktober November December) - - expected = %(<select id="date_month" name="date[month]">\n) - 1.upto(12) { |month| expected << %(<option value="#{month}"#{' selected="selected"' if month == 8}>#{month_names[month-1]}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_names => month_names) - assert_dom_equal expected, select_month(8, :use_month_names => month_names) - end - - def test_select_month_with_hidden - assert_dom_equal "<input type=\"hidden\" id=\"date_month\" name=\"date[month]\" value=\"8\" />\n", select_month(8, :use_hidden => true) - end - - def test_select_month_with_hidden_and_field_name - assert_dom_equal "<input type=\"hidden\" id=\"date_mois\" name=\"date[mois]\" value=\"8\" />\n", select_month(8, :use_hidden => true, :field_name => 'mois') - end - - def test_select_month_with_html_options - expected = %(<select id="date_month" name="date[month]" class="selector" accesskey="M">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), {}, :class => 'selector', :accesskey => 'M') - #result = select_month(Time.mktime(2003, 8, 16), {}, :class => 'selector', :accesskey => 'M') - #assert result.include?('<select id="date_month" name="date[month]"') - #assert result.include?('class="selector"') - #assert result.include?('accesskey="M"') - #assert result.include?('<option value="1">January') - end - - def test_select_month_with_default_prompt - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value="">Month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(8, :prompt => true) - end - - def test_select_month_with_custom_prompt - expected = %(<select id="date_month" name="date[month]">\n) - expected << %(<option value="">Choose month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_month(8, :prompt => 'Choose month') - end - - def test_select_year - expected = %(<select id="date_year" name="date[year]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005) - assert_dom_equal expected, select_year(2003, :start_year => 2003, :end_year => 2005) - end - - def test_select_year_with_disabled - expected = %(<select id="date_year" name="date[year]" disabled="disabled">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year(Time.mktime(2003, 8, 16), :disabled => true, :start_year => 2003, :end_year => 2005) - assert_dom_equal expected, select_year(2003, :disabled => true, :start_year => 2003, :end_year => 2005) - end - - def test_select_year_with_field_name_override - expected = %(<select id="date_annee" name="date[annee]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :field_name => 'annee') - assert_dom_equal expected, select_year(2003, :start_year => 2003, :end_year => 2005, :field_name => 'annee') - end - - def test_select_year_with_type_discarding - expected = %(<select id="date_year" name="date_year">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year( - Time.mktime(2003, 8, 16), :prefix => "date_year", :discard_type => true, :start_year => 2003, :end_year => 2005) - assert_dom_equal expected, select_year( - 2003, :prefix => "date_year", :discard_type => true, :start_year => 2003, :end_year => 2005) - end - - def test_select_year_descending - expected = %(<select id="date_year" name="date[year]">\n) - expected << %(<option value="2005" selected="selected">2005</option>\n<option value="2004">2004</option>\n<option value="2003">2003</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year(Time.mktime(2005, 8, 16), :start_year => 2005, :end_year => 2003) - assert_dom_equal expected, select_year(2005, :start_year => 2005, :end_year => 2003) - end - - def test_select_year_with_hidden - assert_dom_equal "<input type=\"hidden\" id=\"date_year\" name=\"date[year]\" value=\"2007\" />\n", select_year(2007, :use_hidden => true) - end - - def test_select_year_with_hidden_and_field_name - assert_dom_equal "<input type=\"hidden\" id=\"date_anno\" name=\"date[anno]\" value=\"2007\" />\n", select_year(2007, :use_hidden => true, :field_name => 'anno') - end - - def test_select_year_with_html_options - expected = %(<select id="date_year" name="date[year]" class="selector" accesskey="M">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year(Time.mktime(2003, 8, 16), {:start_year => 2003, :end_year => 2005}, :class => 'selector', :accesskey => 'M') - #result = select_year(Time.mktime(2003, 8, 16), {:start_year => 2003, :end_year => 2005}, :class => 'selector', :accesskey => 'M') - #assert result.include?('<select id="date_year" name="date[year]"') - #assert result.include?('class="selector"') - #assert result.include?('accesskey="M"') - #assert result.include?('<option value="2003"') - end - - def test_select_year_with_default_prompt - expected = %(<select id="date_year" name="date[year]">\n) - expected << %(<option value="">Year</option>\n<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year(nil, :start_year => 2003, :end_year => 2005, :prompt => true) - end - - def test_select_year_with_custom_prompt - expected = %(<select id="date_year" name="date[year]">\n) - expected << %(<option value="">Choose year</option>\n<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_year(nil, :start_year => 2003, :end_year => 2005, :prompt => 'Choose year') - end - - def test_select_hour - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18)) - end - - def test_select_hour_with_disabled - expected = %(<select id="date_hour" name="date[hour]" disabled="disabled">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true) - end - - def test_select_hour_with_field_name_override - expected = %(<select id="date_heure" name="date[heure]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :field_name => 'heure') - end - - def test_select_hour_with_blank - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true) - end - - def test_select_hour_nil_with_blank - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(nil, :include_blank => true) - end - - def test_select_hour_with_html_options - expected = %(<select id="date_hour" name="date[hour]" class="selector" accesskey="M">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M') - end - - def test_select_hour_with_default_prompt - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="">Hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true) - end - - def test_select_hour_with_custom_prompt - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="">Choose hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => 'Choose hour') - end - - def test_select_minute - expected = %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18)) - end - - def test_select_minute_with_disabled - expected = %(<select id="date_minute" name="date[minute]" disabled="disabled">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true) - end - - def test_select_minute_with_field_name_override - expected = %(<select id="date_minuto" name="date[minuto]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :field_name => 'minuto') - end - - def test_select_minute_with_blank - expected = %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true) - end - - def test_select_minute_with_blank_and_step - expected = %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="15">15</option>\n<option value="30">30</option>\n<option value="45">45</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), { :include_blank => true , :minute_step => 15 }) - end - - def test_select_minute_nil_with_blank - expected = %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(nil, :include_blank => true) - end - - def test_select_minute_nil_with_blank_and_step - expected = %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="15">15</option>\n<option value="30">30</option>\n<option value="45">45</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(nil, { :include_blank => true , :minute_step => 15 }) - end - - def test_select_minute_with_hidden - assert_dom_equal "<input type=\"hidden\" id=\"date_minute\" name=\"date[minute]\" value=\"8\" />\n", select_minute(8, :use_hidden => true) - end - - def test_select_minute_with_hidden_and_field_name - assert_dom_equal "<input type=\"hidden\" id=\"date_minuto\" name=\"date[minuto]\" value=\"8\" />\n", select_minute(8, :use_hidden => true, :field_name => 'minuto') - end - - def test_select_minute_with_html_options - expected = expected = %(<select id="date_minute" name="date[minute]" class="selector" accesskey="M">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M') - - #result = select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M') - #assert result.include?('<select id="date_minute" name="date[minute]"') - #assert result.include?('class="selector"') - #assert result.include?('accesskey="M"') - #assert result.include?('<option value="00">00') - end - - def test_select_minute_with_default_prompt - expected = %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="">Minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true) - end - - def test_select_minute_with_custom_prompt - expected = %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="">Choose minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => 'Choose minute') - end - - def test_select_second - expected = %(<select id="date_second" name="date[second]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18)) - end - - def test_select_second_with_disabled - expected = %(<select id="date_second" name="date[second]" disabled="disabled">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true) - end - - def test_select_second_with_field_name_override - expected = %(<select id="date_segundo" name="date[segundo]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :field_name => 'segundo') - end - - def test_select_second_with_blank - expected = %(<select id="date_second" name="date[second]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true) - end - - def test_select_second_nil_with_blank - expected = %(<select id="date_second" name="date[second]">\n) - expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(nil, :include_blank => true) - end - - def test_select_second_with_html_options - expected = %(<select id="date_second" name="date[second]" class="selector" accesskey="M">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M') - - #result = select_second(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M') - #assert result.include?('<select id="date_second" name="date[second]"') - #assert result.include?('class="selector"') - #assert result.include?('accesskey="M"') - #assert result.include?('<option value="00">00') - end - - def test_select_second_with_default_prompt - expected = %(<select id="date_second" name="date[second]">\n) - expected << %(<option value="">Seconds</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true) - end - - def test_select_second_with_custom_prompt - expected = %(<select id="date_second" name="date[second]">\n) - expected << %(<option value="">Choose seconds</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => 'Choose seconds') - end - - def test_select_date - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]") - end - - def test_select_date_with_order - expected = %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :order => [:month, :day, :year]) - end - - def test_select_date_with_incomplete_order - # NOTE: modified this test because of minimal API change - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :order => [:day]) - end - - def test_select_date_with_disabled - expected = %(<select id="date_first_year" name="date[first][year]" disabled="disabled">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]" disabled="disabled">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]" disabled="disabled">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :disabled => true) - end - - def test_select_date_with_no_start_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+1) do |y| - if y == Date.today.year - expected << %(<option value="#{y}" selected="selected">#{y}</option>\n) - else - expected << %(<option value="#{y}">#{y}</option>\n) - end - end - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date( - Time.mktime(Date.today.year, 8, 16), :end_year => Date.today.year+1, :prefix => "date[first]" - ) - end - - def test_select_date_with_no_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - 2003.upto(2008) do |y| - if y == 2003 - expected << %(<option value="#{y}" selected="selected">#{y}</option>\n) - else - expected << %(<option value="#{y}">#{y}</option>\n) - end - end - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date( - Time.mktime(2003, 8, 16), :start_year => 2003, :prefix => "date[first]" - ) - end - - def test_select_date_with_no_start_or_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+5) do |y| - if y == Date.today.year - expected << %(<option value="#{y}" selected="selected">#{y}</option>\n) - else - expected << %(<option value="#{y}">#{y}</option>\n) - end - end - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date( - Time.mktime(Date.today.year, 8, 16), :prefix => "date[first]" - ) - end - - def test_select_date_with_zero_value - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(0, :start_year => 2003, :end_year => 2005, :prefix => "date[first]") - end - - def test_select_date_with_zero_value_and_no_start_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+1) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(0, :end_year => Date.today.year+1, :prefix => "date[first]") - end - - def test_select_date_with_zero_value_and_no_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - last_year = Time.now.year + 5 - 2003.upto(last_year) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(0, :start_year => 2003, :prefix => "date[first]") - end - - def test_select_date_with_zero_value_and_no_start_and_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(0, :prefix => "date[first]") - end - - def test_select_date_with_nil_value_and_no_start_and_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(nil, :prefix => "date[first]") - end - - def test_select_date_with_html_options - expected = %(<select id="date_first_year" name="date[first][year]" class="selector">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]" class="selector">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]" class="selector">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), {:start_year => 2003, :end_year => 2005, :prefix => "date[first]"}, :class => "selector") - end - - def test_select_date_with_separator - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << " / " - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << " / " - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), { :date_separator => " / ", :start_year => 2003, :end_year => 2005, :prefix => "date[first]"}) - end - - def test_select_datetime - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_hour" name="date[first][hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_minute" name="date[first][minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, :prefix => "date[first]") - end - - def test_select_datetime_with_separators - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << " &mdash; " - - expected << %(<select id="date_first_hour" name="date[first][hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << " : " - - expected << %(<select id="date_first_minute" name="date[first][minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :datetime_separator => ' &mdash; ', :time_separator => ' : ') - end - - def test_select_datetime_with_nil_value_and_no_start_and_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_hour" name="date[first][hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_minute" name="date[first][minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(nil, :prefix => "date[first]") - end - - def test_select_datetime_with_html_options - expected = %(<select id="date_first_year" name="date[first][year]" class="selector">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]" class="selector">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]" class="selector">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_hour" name="date[first][hour]" class="selector">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_minute" name="date[first][minute]" class="selector">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), {:start_year => 2003, :end_year => 2005, :prefix => "date[first]"}, :class => 'selector') - end - - def test_select_datetime_with_all_separators - expected = %(<select id="date_first_year" name="date[first][year]" class="selector">\n) - expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << "/" - - expected << %(<select id="date_first_month" name="date[first][month]" class="selector">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << "/" - - expected << %(<select id="date_first_day" name="date[first][day]" class="selector">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << "&mdash;" - - expected << %(<select id="date_first_hour" name="date[first][hour]" class="selector">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << ":" - - expected << %(<select id="date_first_minute" name="date[first][minute]" class="selector">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), { :datetime_separator => "&mdash;", :date_separator => "/", :time_separator => ":", :start_year => 2003, :end_year => 2005, :prefix => "date[first]"}, :class => 'selector') - end - - def test_select_datetime_should_work_with_date - assert_nothing_raised { select_datetime(Date.today) } - end - - def test_select_datetime_with_default_prompt - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="">Year</option>\n<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="">Month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="">Day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_hour" name="date[first][hour]">\n) - expected << %(<option value="">Hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_minute" name="date[first][minute]">\n) - expected << %(<option value="">Minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, - :prefix => "date[first]", :prompt => true) - end - - def test_select_datetime_with_custom_prompt - - expected = %(<select id="date_first_year" name="date[first][year]">\n) - expected << %(<option value="">Choose year</option>\n<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="">Choose month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="">Choose day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_hour" name="date[first][hour]">\n) - expected << %(<option value="">Choose hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_minute" name="date[first][minute]">\n) - expected << %(<option value="">Choose minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", - :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year', :hour => 'Choose hour', :minute => 'Choose minute'}) - end - - def test_select_time - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18)) - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => false) - end - - def test_select_time_with_separator - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << " : " - - expected << %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :time_separator => ' : ') - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :time_separator => ' : ', :include_seconds => false) - end - - def test_select_time_with_seconds - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_second" name="date[second]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => true) - end - - def test_select_time_with_seconds_and_separator - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << " : " - - expected << %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - expected << " : " - - expected << %(<select id="date_second" name="date[second]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => true, :time_separator => ' : ') - end - - def test_select_time_with_html_options - expected = %(<select id="date_hour" name="date[hour]" class="selector">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_minute" name="date[minute]" class="selector">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector') - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), {:include_seconds => false}, :class => 'selector') - end - - def test_select_time_should_work_with_date - assert_nothing_raised { select_time(Date.today) } - end - - def test_select_time_with_default_prompt - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="">Hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="">Minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_second" name="date[second]">\n) - expected << %(<option value="">Seconds</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => true, :prompt => true) - end - - def test_select_time_with_custom_prompt - - expected = %(<select id="date_hour" name="date[hour]">\n) - expected << %(<option value="">Choose hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_minute" name="date[minute]">\n) - expected << %(<option value="">Choose minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_second" name="date[second]">\n) - expected << %(<option value="">Choose seconds</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true, :include_seconds => true, - :prompt => {:hour => 'Choose hour', :minute => 'Choose minute', :second => 'Choose seconds'}) - end - - def test_date_select - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on") - end - - def test_date_select_without_day - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = "<input type=\"hidden\" id=\"post_written_on_3i\" name=\"post[written_on(3i)]\" value=\"1\" />\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :order => [ :month, :year ]) - end - - def test_date_select_within_fields_for - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - fields_for :post, @post do |f| - concat f.date_select(:written_on) - end - - expected = "<select id='post_written_on_1i' name='post[written_on(1i)]'>\n<option value='1999'>1999</option>\n<option value='2000'>2000</option>\n<option value='2001'>2001</option>\n<option value='2002'>2002</option>\n<option value='2003'>2003</option>\n<option selected='selected' value='2004'>2004</option>\n<option value='2005'>2005</option>\n<option value='2006'>2006</option>\n<option value='2007'>2007</option>\n<option value='2008'>2008</option>\n<option value='2009'>2009</option>\n</select>\n" - expected << "<select id='post_written_on_2i' name='post[written_on(2i)]'>\n<option value='1'>January</option>\n<option value='2'>February</option>\n<option value='3'>March</option>\n<option value='4'>April</option>\n<option value='5'>May</option>\n<option selected='selected' value='6'>June</option>\n<option value='7'>July</option>\n<option value='8'>August</option>\n<option value='9'>September</option>\n<option value='10'>October</option>\n<option value='11'>November</option>\n<option value='12'>December</option>\n</select>\n" - expected << "<select id='post_written_on_3i' name='post[written_on(3i)]'>\n<option value='1'>1</option>\n<option value='2'>2</option>\n<option value='3'>3</option>\n<option value='4'>4</option>\n<option value='5'>5</option>\n<option value='6'>6</option>\n<option value='7'>7</option>\n<option value='8'>8</option>\n<option value='9'>9</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option selected='selected' value='15'>15</option>\n<option value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n<option value='24'>24</option>\n<option value='25'>25</option>\n<option value='26'>26</option>\n<option value='27'>27</option>\n<option value='28'>28</option>\n<option value='29'>29</option>\n<option value='30'>30</option>\n<option value='31'>31</option>\n</select>\n" - - assert_dom_equal(expected, output_buffer) - end - - def test_date_select_within_fields_for_with_index - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - id = 27 - - fields_for :post, @post, :index => id do |f| - concat f.date_select(:written_on) - end - - expected = "<select id='post_#{id}_written_on_1i' name='post[#{id}][written_on(1i)]'>\n<option value='1999'>1999</option>\n<option value='2000'>2000</option>\n<option value='2001'>2001</option>\n<option value='2002'>2002</option>\n<option value='2003'>2003</option>\n<option selected='selected' value='2004'>2004</option>\n<option value='2005'>2005</option>\n<option value='2006'>2006</option>\n<option value='2007'>2007</option>\n<option value='2008'>2008</option>\n<option value='2009'>2009</option>\n</select>\n" - expected << "<select id='post_#{id}_written_on_2i' name='post[#{id}][written_on(2i)]'>\n<option value='1'>January</option>\n<option value='2'>February</option>\n<option value='3'>March</option>\n<option value='4'>April</option>\n<option value='5'>May</option>\n<option selected='selected' value='6'>June</option>\n<option value='7'>July</option>\n<option value='8'>August</option>\n<option value='9'>September</option>\n<option value='10'>October</option>\n<option value='11'>November</option>\n<option value='12'>December</option>\n</select>\n" - expected << "<select id='post_#{id}_written_on_3i' name='post[#{id}][written_on(3i)]'>\n<option value='1'>1</option>\n<option value='2'>2</option>\n<option value='3'>3</option>\n<option value='4'>4</option>\n<option value='5'>5</option>\n<option value='6'>6</option>\n<option value='7'>7</option>\n<option value='8'>8</option>\n<option value='9'>9</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option selected='selected' value='15'>15</option>\n<option value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n<option value='24'>24</option>\n<option value='25'>25</option>\n<option value='26'>26</option>\n<option value='27'>27</option>\n<option value='28'>28</option>\n<option value='29'>29</option>\n<option value='30'>30</option>\n<option value='31'>31</option>\n</select>\n" - - assert_dom_equal(expected, output_buffer) - end - - def test_date_select_within_fields_for_with_blank_index - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - id = nil - - fields_for :post, @post, :index => id do |f| - concat f.date_select(:written_on) - end - - expected = "<select id='post_#{id}_written_on_1i' name='post[#{id}][written_on(1i)]'>\n<option value='1999'>1999</option>\n<option value='2000'>2000</option>\n<option value='2001'>2001</option>\n<option value='2002'>2002</option>\n<option value='2003'>2003</option>\n<option selected='selected' value='2004'>2004</option>\n<option value='2005'>2005</option>\n<option value='2006'>2006</option>\n<option value='2007'>2007</option>\n<option value='2008'>2008</option>\n<option value='2009'>2009</option>\n</select>\n" - expected << "<select id='post_#{id}_written_on_2i' name='post[#{id}][written_on(2i)]'>\n<option value='1'>January</option>\n<option value='2'>February</option>\n<option value='3'>March</option>\n<option value='4'>April</option>\n<option value='5'>May</option>\n<option selected='selected' value='6'>June</option>\n<option value='7'>July</option>\n<option value='8'>August</option>\n<option value='9'>September</option>\n<option value='10'>October</option>\n<option value='11'>November</option>\n<option value='12'>December</option>\n</select>\n" - expected << "<select id='post_#{id}_written_on_3i' name='post[#{id}][written_on(3i)]'>\n<option value='1'>1</option>\n<option value='2'>2</option>\n<option value='3'>3</option>\n<option value='4'>4</option>\n<option value='5'>5</option>\n<option value='6'>6</option>\n<option value='7'>7</option>\n<option value='8'>8</option>\n<option value='9'>9</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option selected='selected' value='15'>15</option>\n<option value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n<option value='24'>24</option>\n<option value='25'>25</option>\n<option value='26'>26</option>\n<option value='27'>27</option>\n<option value='28'>28</option>\n<option value='29'>29</option>\n<option value='30'>30</option>\n<option value='31'>31</option>\n</select>\n" - - assert_dom_equal(expected, output_buffer) - end - - def test_date_select_with_index - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - id = 456 - - expected = %{<select id="post_456_written_on_1i" name="post[#{id}][written_on(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_456_written_on_2i" name="post[#{id}][written_on(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_456_written_on_3i" name="post[#{id}][written_on(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :index => id) - end - - def test_date_select_with_auto_index - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - id = 123 - - expected = %{<select id="post_123_written_on_1i" name="post[#{id}][written_on(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_123_written_on_2i" name="post[#{id}][written_on(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_123_written_on_3i" name="post[#{id}][written_on(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, date_select("post[]", "written_on") - end - - def test_date_select_with_different_order - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - 1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :order => [:day, :month, :year]) - end - - def test_date_select_with_nil - @post = Post.new - - start_year = Time.now.year-5 - end_year = Time.now.year+5 - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - start_year.upto(end_year) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == Time.now.year}>#{i}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == Time.now.month}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == Time.now.day}>#{i}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on") - end - - def test_date_select_with_nil_and_blank - @post = Post.new - - start_year = Time.now.year-5 - end_year = Time.now.year+5 - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << "<option value=\"\"></option>\n" - start_year.upto(end_year) { |i| expected << %(<option value="#{i}">#{i}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << "<option value=\"\"></option>\n" - 1.upto(12) { |i| expected << %(<option value="#{i}">#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - expected << "<option value=\"\"></option>\n" - 1.upto(31) { |i| expected << %(<option value="#{i}">#{i}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :include_blank => true) - end - - def test_date_select_with_nil_and_blank_and_order - @post = Post.new - - start_year = Time.now.year-5 - end_year = Time.now.year+5 - - expected = '<input name="post[written_on(3i)]" type="hidden" id="post_written_on_3i"/>' + "\n" - expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << "<option value=\"\"></option>\n" - start_year.upto(end_year) { |i| expected << %(<option value="#{i}">#{i}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << "<option value=\"\"></option>\n" - 1.upto(12) { |i| expected << %(<option value="#{i}">#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :order=>[:year, :month], :include_blank=>true) - end - - def test_date_select_with_nil_and_blank_and_order - @post = Post.new - - start_year = Time.now.year-5 - end_year = Time.now.year+5 - - expected = '<input name="post[written_on(3i)]" type="hidden" id="post_written_on_3i"/>' + "\n" - expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << "<option value=\"\"></option>\n" - start_year.upto(end_year) { |i| expected << %(<option value="#{i}">#{i}</option>\n) } - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << "<option value=\"\"></option>\n" - 1.upto(12) { |i| expected << %(<option value="#{i}">#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :order=>[:year, :month], :include_blank=>true) - end - - def test_date_select_cant_override_discard_hour - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :discard_hour => false) - end - - def test_date_select_with_html_options - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]" class="selector">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]" class="selector">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]" class="selector">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", {}, :class => 'selector') - end - - def test_date_select_with_html_options_within_fields_for - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - fields_for :post, @post do |f| - concat f.date_select(:written_on, {}, :class => 'selector') - end - - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]" class="selector">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]" class="selector">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]" class="selector">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - - expected << "</select>\n" - - assert_dom_equal expected, output_buffer - end - - def test_date_select_with_separator - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << " / " - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << " / " - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", { :date_separator => " / " }) - end - - def test_date_select_with_default_prompt - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << %{<option value="">Year</option>\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << %{<option value="">Month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - expected << %{<option value="">Day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :prompt => true) - end - - def test_date_select_with_custom_prompt - @post = Post.new - @post.written_on = Date.new(2004, 6, 15) - - expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n} - expected << %{<option value="">Choose year</option>\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n} - expected << %{<option value="">Choose month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n} - expected << %{<option value="">Choose day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "written_on", :prompt => {:year => 'Choose year', :month => 'Choose month', :day => 'Choose day'}) - end - - def test_time_select - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n} - - expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, time_select("post", "written_on") - end - - def test_time_select_without_date_hidden_fields - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, time_select("post", "written_on", :ignore_date => true) - end - - def test_time_select_with_seconds - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n} - - expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_6i" name="post[written_on(6i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 35}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, time_select("post", "written_on", :include_seconds => true) - end - - def test_time_select_with_html_options - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n} - - expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]" class="selector">\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]" class="selector">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, time_select("post", "written_on", {}, :class => 'selector') - end - - def test_time_select_with_html_options_within_fields_for - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - fields_for :post, @post do |f| - concat f.time_select(:written_on, {}, :class => 'selector') - end - - expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n} - - expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]" class="selector">\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]" class="selector">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, output_buffer - end - - def test_time_select_with_separator - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n} - - expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - expected << " - " - - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - expected << " - " - - expected << %(<select id="post_written_on_6i" name="post[written_on(6i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 35}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, time_select("post", "written_on", { :time_separator => " - ", :include_seconds => true }) - end - - def test_time_select_with_default_prompt - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n} - - expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n) - expected << %(<option value="">Hour</option>\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n) - expected << %(<option value="">Minute</option>\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, time_select("post", "written_on", :prompt => true) - end - - def test_time_select_with_custom_prompt - @post = Post.new - @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n} - - expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n) - expected << %(<option value="">Choose hour</option>\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n) - expected << %(<option value="">Choose minute</option>\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, time_select("post", "written_on", :prompt => {:hour => 'Choose hour', :minute => 'Choose minute'}) - end - - def test_datetime_select - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 16, 35) - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at") - end - - def test_datetime_select_defaults_to_time_zone_now_when_config_time_zone_is_set - time = stub(:year => 2004, :month => 6, :day => 15, :hour => 16, :min => 35, :sec => 0) - time_zone = mock() - time_zone.expects(:now).returns time - Time.zone_default = time_zone - @post = Post.new - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at") - ensure - Time.zone_default = nil - end - - def test_datetime_select_with_html_options_within_fields_for - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 16, 35) - - fields_for :post, @post do |f| - concat f.datetime_select(:updated_at, {}, :class => 'selector') - end - - expected = "<select id='post_updated_at_1i' name='post[updated_at(1i)]' class='selector'>\n<option value='1999'>1999</option>\n<option value='2000'>2000</option>\n<option value='2001'>2001</option>\n<option value='2002'>2002</option>\n<option value='2003'>2003</option>\n<option selected='selected' value='2004'>2004</option>\n<option value='2005'>2005</option>\n<option value='2006'>2006</option>\n<option value='2007'>2007</option>\n<option value='2008'>2008</option>\n<option value='2009'>2009</option>\n</select>\n" - expected << "<select id='post_updated_at_2i' name='post[updated_at(2i)]' class='selector'>\n<option value='1'>January</option>\n<option value='2'>February</option>\n<option value='3'>March</option>\n<option value='4'>April</option>\n<option value='5'>May</option>\n<option selected='selected' value='6'>June</option>\n<option value='7'>July</option>\n<option value='8'>August</option>\n<option value='9'>September</option>\n<option value='10'>October</option>\n<option value='11'>November</option>\n<option value='12'>December</option>\n</select>\n" - expected << "<select id='post_updated_at_3i' name='post[updated_at(3i)]' class='selector'>\n<option value='1'>1</option>\n<option value='2'>2</option>\n<option value='3'>3</option>\n<option value='4'>4</option>\n<option value='5'>5</option>\n<option value='6'>6</option>\n<option value='7'>7</option>\n<option value='8'>8</option>\n<option value='9'>9</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option selected='selected' value='15'>15</option>\n<option value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n<option value='24'>24</option>\n<option value='25'>25</option>\n<option value='26'>26</option>\n<option value='27'>27</option>\n<option value='28'>28</option>\n<option value='29'>29</option>\n<option value='30'>30</option>\n<option value='31'>31</option>\n</select>\n" - expected << " &mdash; <select id='post_updated_at_4i' name='post[updated_at(4i)]' class='selector'>\n<option value='00'>00</option>\n<option value='01'>01</option>\n<option value='02'>02</option>\n<option value='03'>03</option>\n<option value='04'>04</option>\n<option value='05'>05</option>\n<option value='06'>06</option>\n<option value='07'>07</option>\n<option value='08'>08</option>\n<option value='09'>09</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option value='15'>15</option>\n<option selected='selected' value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n</select>\n" - expected << " : <select id='post_updated_at_5i' name='post[updated_at(5i)]' class='selector'>\n<option value='00'>00</option>\n<option value='01'>01</option>\n<option value='02'>02</option>\n<option value='03'>03</option>\n<option value='04'>04</option>\n<option value='05'>05</option>\n<option value='06'>06</option>\n<option value='07'>07</option>\n<option value='08'>08</option>\n<option value='09'>09</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option value='15'>15</option>\n<option value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n<option value='24'>24</option>\n<option value='25'>25</option>\n<option value='26'>26</option>\n<option value='27'>27</option>\n<option value='28'>28</option>\n<option value='29'>29</option>\n<option value='30'>30</option>\n<option value='31'>31</option>\n<option value='32'>32</option>\n<option value='33'>33</option>\n<option value='34'>34</option>\n<option selected='selected' value='35'>35</option>\n<option value='36'>36</option>\n<option value='37'>37</option>\n<option value='38'>38</option>\n<option value='39'>39</option>\n<option value='40'>40</option>\n<option value='41'>41</option>\n<option value='42'>42</option>\n<option value='43'>43</option>\n<option value='44'>44</option>\n<option value='45'>45</option>\n<option value='46'>46</option>\n<option value='47'>47</option>\n<option value='48'>48</option>\n<option value='49'>49</option>\n<option value='50'>50</option>\n<option value='51'>51</option>\n<option value='52'>52</option>\n<option value='53'>53</option>\n<option value='54'>54</option>\n<option value='55'>55</option>\n<option value='56'>56</option>\n<option value='57'>57</option>\n<option value='58'>58</option>\n<option value='59'>59</option>\n</select>\n" - - assert_dom_equal expected, output_buffer - end - - def test_datetime_select_with_separators - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << " / " - - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << " / " - - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " , " - - expected << %(<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n) - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - expected << " - " - - expected << %(<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - expected << " - " - - expected << %(<select id="post_updated_at_6i" name="post[updated_at(6i)]">\n) - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 35}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", { :date_separator => " / ", :datetime_separator => " , ", :time_separator => " - ", :include_seconds => true }) - end - - def test_datetime_select_with_default_prompt - @post = Post.new - @post.updated_at = nil - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - expected << %{<option value="">Year</option>\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - expected << %{<option value="">Month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - expected << %{<option value="">Day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - expected << %{<option value="">Hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - expected << %{<option value="">Minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :start_year=>1999, :end_year=>2009, :prompt => true) - end - - def test_datetime_select_with_custom_prompt - @post = Post.new - @post.updated_at = nil - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - expected << %{<option value="">Choose year</option>\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - expected << %{<option value="">Choose month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - expected << %{<option value="">Choose day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - expected << %{<option value="">Choose hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - expected << %{<option value="">Choose minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :start_year=>1999, :end_year=>2009, :prompt => {:year => 'Choose year', :month => 'Choose month', :day => 'Choose day', :hour => 'Choose hour', :minute => 'Choose minute'}) - end - - def test_date_select_with_zero_value_and_no_start_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+1) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(0, :end_year => Date.today.year+1, :prefix => "date[first]") - end - - def test_date_select_with_zero_value_and_no_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - last_year = Time.now.year + 5 - 2003.upto(last_year) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(0, :start_year => 2003, :prefix => "date[first]") - end - - def test_date_select_with_zero_value_and_no_start_and_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(0, :prefix => "date[first]") - end - - def test_date_select_with_nil_value_and_no_start_and_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_date(nil, :prefix => "date[first]") - end - - def test_datetime_select_with_nil_value_and_no_start_and_end_year - expected = %(<select id="date_first_year" name="date[first][year]">\n) - (Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) } - expected << "</select>\n" - - expected << %(<select id="date_first_month" name="date[first][month]">\n) - expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_day" name="date[first][day]">\n) - expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_hour" name="date[first][hour]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n) - expected << "</select>\n" - - expected << %(<select id="date_first_minute" name="date[first][minute]">\n) - expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n) - expected << "</select>\n" - - assert_dom_equal expected, select_datetime(nil, :prefix => "date[first]") - end - - def test_datetime_select_with_options_index - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 16, 35) - id = 456 - - expected = %{<select id="post_456_updated_at_1i" name="post[#{id}][updated_at(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_456_updated_at_2i" name="post[#{id}][updated_at(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_456_updated_at_3i" name="post[#{id}][updated_at(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_456_updated_at_4i" name="post[#{id}][updated_at(4i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_456_updated_at_5i" name="post[#{id}][updated_at(5i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :index => id) - end - - def test_datetime_select_within_fields_for_with_options_index - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 16, 35) - id = 456 - - fields_for :post, @post, :index => id do |f| - concat f.datetime_select(:updated_at) - end - - expected = %{<select id="post_456_updated_at_1i" name="post[#{id}][updated_at(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_456_updated_at_2i" name="post[#{id}][updated_at(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_456_updated_at_3i" name="post[#{id}][updated_at(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_456_updated_at_4i" name="post[#{id}][updated_at(4i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_456_updated_at_5i" name="post[#{id}][updated_at(5i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, output_buffer - end - - def test_datetime_select_with_auto_index - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 16, 35) - id = @post.id - - expected = %{<select id="post_123_updated_at_1i" name="post[#{id}][updated_at(1i)]">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_123_updated_at_2i" name="post[#{id}][updated_at(2i)]">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_123_updated_at_3i" name="post[#{id}][updated_at(3i)]">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_123_updated_at_4i" name="post[#{id}][updated_at(4i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_123_updated_at_5i" name="post[#{id}][updated_at(5i)]">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post[]", "updated_at") - end - - def test_datetime_select_with_seconds - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - 1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) } - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_6i" name="post[updated_at(6i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 35}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :include_seconds => true) - end - - def test_datetime_select_discard_year - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_updated_at_1i" name="post[updated_at(1i)]" value="2004" />\n} - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) } - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :discard_year => true) - end - - def test_datetime_select_discard_month - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - 1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) } - expected << "</select>\n" - expected << %{<input type="hidden" id="post_updated_at_2i" name="post[updated_at(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_updated_at_3i" name="post[updated_at(3i)]" value="15" />\n} - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :discard_month => true) - end - - def test_datetime_select_discard_year_and_month - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_updated_at_1i" name="post[updated_at(1i)]" value="2004" />\n} - expected << %{<input type="hidden" id="post_updated_at_2i" name="post[updated_at(2i)]" value="6" />\n} - expected << %{<input type="hidden" id="post_updated_at_3i" name="post[updated_at(3i)]" value="15" />\n} - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :discard_year => true, :discard_month => true) - end - - def test_datetime_select_invalid_order - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - 1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) } - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :order => [:minute, :day, :hour, :month, :year, :second]) - end - - def test_datetime_select_discard_with_order - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - - expected = %{<input type="hidden" id="post_updated_at_1i" name="post[updated_at(1i)]" value="2004" />\n} - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :order => [:day, :month]) - end - - def test_datetime_select_with_default_value_as_time - @post = Post.new - @post.updated_at = nil - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - 2001.upto(2011) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2006}>#{i}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 9}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 19}>#{i}</option>\n) } - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :default => Time.local(2006, 9, 19, 15, 16, 35)) - end - - def test_include_blank_overrides_default_option - @post = Post.new - @post.updated_at = nil - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - expected << %(<option value=""></option>\n) - (Time.now.year - 5).upto(Time.now.year + 5) { |i| expected << %(<option value="#{i}">#{i}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - expected << %(<option value=""></option>\n) - 1.upto(12) { |i| expected << %(<option value="#{i}">#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - expected << %(<option value=""></option>\n) - 1.upto(31) { |i| expected << %(<option value="#{i}">#{i}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, date_select("post", "updated_at", :default => Time.local(2006, 9, 19, 15, 16, 35), :include_blank => true) - end - - def test_datetime_select_with_default_value_as_hash - @post = Post.new - @post.updated_at = nil - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n} - (Time.now.year - 5).upto(Time.now.year + 5) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == Time.now.year}>#{i}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n} - 1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 10}>#{Date::MONTHNAMES[i]}</option>\n) } - expected << "</select>\n" - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n} - 1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == Time.now.day}>#{i}</option>\n) } - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n} - 0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 9}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n} - 0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 42}>#{sprintf("%02d", i)}</option>\n) } - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", :default => { :month => 10, :minute => 42, :hour => 9 }) - end - - def test_datetime_select_with_html_options - @post = Post.new - @post.updated_at = Time.local(2004, 6, 15, 16, 35) - - expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]" class="selector">\n} - expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]" class="selector">\n} - expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n} - expected << "</select>\n" - - expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]" class="selector">\n} - expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n} - expected << "</select>\n" - - expected << " &mdash; " - - expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]" class="selector">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n} - expected << "</select>\n" - expected << " : " - expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]" class="selector">\n} - expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n} - expected << "</select>\n" - - assert_dom_equal expected, datetime_select("post", "updated_at", {}, :class => 'selector') - end - - def test_date_select_should_not_change_passed_options_hash - @post = Post.new - @post.updated_at = Time.local(2008, 7, 16, 23, 30) - - options = { - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - } - date_select(@post, :updated_at, options) - - # note: the literal hash is intentional to show that the actual options hash isn't modified - # don't change this! - assert_equal({ - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - }, options) - end - - def test_datetime_select_should_not_change_passed_options_hash - @post = Post.new - @post.updated_at = Time.local(2008, 7, 16, 23, 30) - - options = { - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - } - datetime_select(@post, :updated_at, options) - - # note: the literal hash is intentional to show that the actual options hash isn't modified - # don't change this! - assert_equal({ - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - }, options) - end - - def test_time_select_should_not_change_passed_options_hash - @post = Post.new - @post.updated_at = Time.local(2008, 7, 16, 23, 30) - - options = { - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - } - time_select(@post, :updated_at, options) - - # note: the literal hash is intentional to show that the actual options hash isn't modified - # don't change this! - assert_equal({ - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - }, options) - end - - def test_select_date_should_not_change_passed_options_hash - options = { - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - } - select_date(Date.today, options) - - # note: the literal hash is intentional to show that the actual options hash isn't modified - # don't change this! - assert_equal({ - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - }, options) - end - - def test_select_datetime_should_not_change_passed_options_hash - options = { - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - } - select_datetime(Time.now, options) - - # note: the literal hash is intentional to show that the actual options hash isn't modified - # don't change this! - assert_equal({ - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - }, options) - end - - def test_select_time_should_not_change_passed_options_hash - options = { - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - } - select_time(Time.now, options) - - # note: the literal hash is intentional to show that the actual options hash isn't modified - # don't change this! - assert_equal({ - :order => [ :year, :month, :day ], - :default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 }, - :discard_type => false, - :include_blank => false, - :ignore_date => false, - :include_seconds => true - }, options) - end - - protected - def with_env_tz(new_tz = 'US/Eastern') - old_tz, ENV['TZ'] = ENV['TZ'], new_tz - yield - ensure - old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ') - end -end diff --git a/vendor/rails/actionpack/test/template/erb_util_test.rb b/vendor/rails/actionpack/test/template/erb_util_test.rb deleted file mode 100644 index c8c986f..0000000 --- a/vendor/rails/actionpack/test/template/erb_util_test.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'abstract_unit' - -class ErbUtilTest < Test::Unit::TestCase - include ERB::Util - - ERB::Util::HTML_ESCAPE.each do |given, expected| - define_method "test_html_escape_#{expected.gsub /\W/, ''}" do - assert_equal expected, html_escape(given) - end - - unless given == '"' - define_method "test_json_escape_#{expected.gsub /\W/, ''}" do - assert_equal ERB::Util::JSON_ESCAPE[given], json_escape(given) - end - end - end - - def test_rest_in_ascii - (0..127).to_a.map(&:chr).each do |chr| - next if %w(& " < >).include?(chr) - assert_equal chr, html_escape(chr) - end - end -end diff --git a/vendor/rails/actionpack/test/template/form_helper_test.rb b/vendor/rails/actionpack/test/template/form_helper_test.rb deleted file mode 100644 index 654eee4..0000000 --- a/vendor/rails/actionpack/test/template/form_helper_test.rb +++ /dev/null @@ -1,1176 +0,0 @@ -require 'abstract_unit' - -silence_warnings do - Post = Struct.new(:title, :author_name, :body, :secret, :written_on, :cost) - Post.class_eval do - alias_method :title_before_type_cast, :title unless respond_to?(:title_before_type_cast) - alias_method :body_before_type_cast, :body unless respond_to?(:body_before_type_cast) - alias_method :author_name_before_type_cast, :author_name unless respond_to?(:author_name_before_type_cast) - alias_method :secret?, :secret - - def new_record=(boolean) - @new_record = boolean - end - - def new_record? - @new_record - end - - attr_accessor :author - def author_attributes=(attributes); end - - attr_accessor :comments - def comments_attributes=(attributes); end - end - - class Comment - attr_reader :id - attr_reader :post_id - def initialize(id = nil, post_id = nil); @id, @post_id = id, post_id end - def save; @id = 1; @post_id = 1 end - def new_record?; @id.nil? end - def to_param; @id; end - def name - @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}" - end - end - - class Author < Comment - attr_accessor :post - def post_attributes=(attributes); end - end -end - -class FormHelperTest < ActionView::TestCase - tests ActionView::Helpers::FormHelper - - def setup - @post = Post.new - @comment = Comment.new - def @post.errors() - Class.new{ - def on(field); "can't be empty" if field == "author_name"; end - def empty?() false end - def count() 1 end - def full_messages() [ "Author name can't be empty" ] end - }.new - end - def @post.id; 123; end - def @post.id_before_type_cast; 123; end - def @post.to_param; '123'; end - - @post.title = "Hello World" - @post.author_name = "" - @post.body = "Back to the hill and over it again!" - @post.secret = 1 - @post.written_on = Date.new(2004, 6, 15) - - @controller = Class.new do - attr_reader :url_for_options - def url_for(options) - @url_for_options = options - "http://www.example.com" - end - end - @controller = @controller.new - end - - def test_label - assert_dom_equal('<label for="post_title">Title</label>', label("post", "title")) - assert_dom_equal('<label for="post_title">The title goes here</label>', label("post", "title", "The title goes here")) - assert_dom_equal( - '<label class="title_label" for="post_title">Title</label>', - label("post", "title", nil, :class => 'title_label') - ) - assert_dom_equal('<label for="post_secret">Secret?</label>', label("post", "secret?")) - end - - def test_label_with_symbols - assert_dom_equal('<label for="post_title">Title</label>', label(:post, :title)) - assert_dom_equal('<label for="post_secret">Secret?</label>', label(:post, :secret?)) - end - - def test_label_with_for_attribute_as_symbol - assert_dom_equal('<label for="my_for">Title</label>', label(:post, :title, nil, :for => "my_for")) - end - - def test_label_with_for_attribute_as_string - assert_dom_equal('<label for="my_for">Title</label>', label(:post, :title, nil, "for" => "my_for")) - end - - def test_text_field - assert_dom_equal( - '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />', text_field("post", "title") - ) - assert_dom_equal( - '<input id="post_title" name="post[title]" size="30" type="password" value="Hello World" />', password_field("post", "title") - ) - assert_dom_equal( - '<input id="person_name" name="person[name]" size="30" type="password" />', password_field("person", "name") - ) - end - - def test_text_field_with_escapes - @post.title = "<b>Hello World</b>" - assert_dom_equal( - '<input id="post_title" name="post[title]" size="30" type="text" value="&lt;b&gt;Hello World&lt;/b&gt;" />', text_field("post", "title") - ) - end - - def test_text_field_with_html_entities - @post.title = "The HTML Entity for & is &amp;" - assert_dom_equal( - '<input id="post_title" name="post[title]" size="30" type="text" value="The HTML Entity for &amp; is &amp;amp;" />', - text_field("post", "title") - ) - end - - def test_text_field_with_options - expected = '<input id="post_title" name="post[title]" size="35" type="text" value="Hello World" />' - assert_dom_equal expected, text_field("post", "title", "size" => 35) - assert_dom_equal expected, text_field("post", "title", :size => 35) - end - - def test_text_field_assuming_size - expected = '<input id="post_title" maxlength="35" name="post[title]" size="35" type="text" value="Hello World" />' - assert_dom_equal expected, text_field("post", "title", "maxlength" => 35) - assert_dom_equal expected, text_field("post", "title", :maxlength => 35) - end - - def test_text_field_removing_size - expected = '<input id="post_title" maxlength="35" name="post[title]" type="text" value="Hello World" />' - assert_dom_equal expected, text_field("post", "title", "maxlength" => 35, "size" => nil) - assert_dom_equal expected, text_field("post", "title", :maxlength => 35, :size => nil) - end - - def test_text_field_doesnt_change_param_values - object_name = 'post[]' - expected = '<input id="post_123_title" name="post[123][title]" size="30" type="text" value="Hello World" />' - assert_equal expected, text_field(object_name, "title") - assert_equal object_name, "post[]" - end - - def test_hidden_field - assert_dom_equal '<input id="post_title" name="post[title]" type="hidden" value="Hello World" />', - hidden_field("post", "title") - assert_dom_equal '<input id="post_secret" name="post[secret]" type="hidden" value="1" />', - hidden_field("post", "secret?") - end - - def test_hidden_field_with_escapes - @post.title = "<b>Hello World</b>" - assert_dom_equal '<input id="post_title" name="post[title]" type="hidden" value="&lt;b&gt;Hello World&lt;/b&gt;" />', - hidden_field("post", "title") - end - - def test_text_field_with_options - assert_dom_equal '<input id="post_title" name="post[title]" type="hidden" value="Something Else" />', - hidden_field("post", "title", :value => "Something Else") - end - - def test_check_box - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret") - ) - @post.secret = 0 - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret") - ) - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret" ,{"checked"=>"checked"}) - ) - @post.secret = true - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret") - ) - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret?") - ) - - @post.secret = ['0'] - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret") - ) - @post.secret = ['1'] - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret") - ) - end - - def test_check_box_with_explicit_checked_and_unchecked_values - @post.secret = "on" - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="off" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="on" />', - check_box("post", "secret", {}, "on", "off") - ) - end - - def test_checkbox_disabled_still_submits_checked_value - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="1" /><input checked="checked" disabled="disabled" id="post_secret" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret", { :disabled => :true }) - ) - end - - def test_radio_button - assert_dom_equal('<input checked="checked" id="post_title_hello_world" name="post[title]" type="radio" value="Hello World" />', - radio_button("post", "title", "Hello World") - ) - assert_dom_equal('<input id="post_title_goodbye_world" name="post[title]" type="radio" value="Goodbye World" />', - radio_button("post", "title", "Goodbye World") - ) - assert_dom_equal('<input id="item_subobject_title_inside_world" name="item[subobject][title]" type="radio" value="inside world"/>', - radio_button("item[subobject]", "title", "inside world") - ) - end - - def test_radio_button_is_checked_with_integers - assert_dom_equal('<input checked="checked" id="post_secret_1" name="post[secret]" type="radio" value="1" />', - radio_button("post", "secret", "1") - ) - end - - def test_radio_button_respects_passed_in_id - assert_dom_equal('<input checked="checked" id="foo" name="post[secret]" type="radio" value="1" />', - radio_button("post", "secret", "1", :id=>"foo") - ) - end - - def test_text_area - assert_dom_equal( - '<textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea>', - text_area("post", "body") - ) - end - - def test_text_area_with_escapes - @post.body = "Back to <i>the</i> hill and over it again!" - assert_dom_equal( - '<textarea cols="40" id="post_body" name="post[body]" rows="20">Back to &lt;i&gt;the&lt;/i&gt; hill and over it again!</textarea>', - text_area("post", "body") - ) - end - - def test_text_area_with_alternate_value - assert_dom_equal( - '<textarea cols="40" id="post_body" name="post[body]" rows="20">Testing alternate values.</textarea>', - text_area("post", "body", :value => 'Testing alternate values.') - ) - end - - def test_text_area_with_html_entities - @post.body = "The HTML Entity for & is &amp;" - assert_dom_equal( - '<textarea cols="40" id="post_body" name="post[body]" rows="20">The HTML Entity for &amp; is &amp;amp;</textarea>', - text_area("post", "body") - ) - end - - def test_text_area_with_size_option - assert_dom_equal( - '<textarea cols="183" id="post_body" name="post[body]" rows="820">Back to the hill and over it again!</textarea>', - text_area("post", "body", :size => "183x820") - ) - end - - def test_explicit_name - assert_dom_equal( - '<input id="post_title" name="dont guess" size="30" type="text" value="Hello World" />', text_field("post", "title", "name" => "dont guess") - ) - assert_dom_equal( - '<textarea cols="40" id="post_body" name="really!" rows="20">Back to the hill and over it again!</textarea>', - text_area("post", "body", "name" => "really!") - ) - assert_dom_equal( - '<input name="i mean it" type="hidden" value="0" /><input checked="checked" id="post_secret" name="i mean it" type="checkbox" value="1" />', - check_box("post", "secret", "name" => "i mean it") - ) - assert_dom_equal text_field("post", "title", "name" => "dont guess"), - text_field("post", "title", :name => "dont guess") - assert_dom_equal text_area("post", "body", "name" => "really!"), - text_area("post", "body", :name => "really!") - assert_dom_equal check_box("post", "secret", "name" => "i mean it"), - check_box("post", "secret", :name => "i mean it") - end - - def test_explicit_id - assert_dom_equal( - '<input id="dont guess" name="post[title]" size="30" type="text" value="Hello World" />', text_field("post", "title", "id" => "dont guess") - ) - assert_dom_equal( - '<textarea cols="40" id="really!" name="post[body]" rows="20">Back to the hill and over it again!</textarea>', - text_area("post", "body", "id" => "really!") - ) - assert_dom_equal( - '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="i mean it" name="post[secret]" type="checkbox" value="1" />', - check_box("post", "secret", "id" => "i mean it") - ) - assert_dom_equal text_field("post", "title", "id" => "dont guess"), - text_field("post", "title", :id => "dont guess") - assert_dom_equal text_area("post", "body", "id" => "really!"), - text_area("post", "body", :id => "really!") - assert_dom_equal check_box("post", "secret", "id" => "i mean it"), - check_box("post", "secret", :id => "i mean it") - end - - def test_auto_index - pid = @post.id - assert_dom_equal( - "<label for=\"post_#{pid}_title\">Title</label>", - label("post[]", "title") - ) - assert_dom_equal( - "<input id=\"post_#{pid}_title\" name=\"post[#{pid}][title]\" size=\"30\" type=\"text\" value=\"Hello World\" />", text_field("post[]","title") - ) - assert_dom_equal( - "<textarea cols=\"40\" id=\"post_#{pid}_body\" name=\"post[#{pid}][body]\" rows=\"20\">Back to the hill and over it again!</textarea>", - text_area("post[]", "body") - ) - assert_dom_equal( - "<input name=\"post[#{pid}][secret]\" type=\"hidden\" value=\"0\" /><input checked=\"checked\" id=\"post_#{pid}_secret\" name=\"post[#{pid}][secret]\" type=\"checkbox\" value=\"1\" />", - check_box("post[]", "secret") - ) - assert_dom_equal( -"<input checked=\"checked\" id=\"post_#{pid}_title_hello_world\" name=\"post[#{pid}][title]\" type=\"radio\" value=\"Hello World\" />", - radio_button("post[]", "title", "Hello World") - ) - assert_dom_equal("<input id=\"post_#{pid}_title_goodbye_world\" name=\"post[#{pid}][title]\" type=\"radio\" value=\"Goodbye World\" />", - radio_button("post[]", "title", "Goodbye World") - ) - end - - def test_form_for - form_for(:post, @post, :html => { :id => 'create-post' }) do |f| - concat f.label(:title) - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - concat f.submit('Create post') - end - - expected = - "<form action='http://www.example.com' id='create-post' method='post'>" + - "<label for='post_title'>Title</label>" + - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[secret]' type='hidden' value='0' />" + - "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" + - "<input name='commit' id='post_submit' type='submit' value='Create post' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_method - form_for(:post, @post, :html => { :id => 'create-post', :method => :put }) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<form action='http://www.example.com' id='create-post' method='post'>" + - "<div style='margin:0;padding:0'><input name='_method' type='hidden' value='put' /></div>" + - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[secret]' type='hidden' value='0' />" + - "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_without_object - form_for(:post, :html => { :id => 'create-post' }) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<form action='http://www.example.com' id='create-post' method='post'>" + - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[secret]' type='hidden' value='0' />" + - "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_index - form_for("post[]", @post) do |f| - concat f.label(:title) - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<form action='http://www.example.com' method='post'>" + - "<label for=\"post_123_title\">Title</label>" + - "<input name='post[123][title]' size='30' type='text' id='post_123_title' value='Hello World' />" + - "<textarea name='post[123][body]' id='post_123_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[123][secret]' type='hidden' value='0' />" + - "<input name='post[123][secret]' checked='checked' type='checkbox' id='post_123_secret' value='1' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_nil_index_option_override - form_for("post[]", @post, :index => nil) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<form action='http://www.example.com' method='post'>" + - "<input name='post[][title]' size='30' type='text' id='post__title' value='Hello World' />" + - "<textarea name='post[][body]' id='post__body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[][secret]' type='hidden' value='0' />" + - "<input name='post[][secret]' checked='checked' type='checkbox' id='post__secret' value='1' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for - form_for(:post, @post) do |f| - f.fields_for(:comment, @post) do |c| - concat c.text_field(:title) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[comment][title]' size='30' type='text' id='post_comment_title' value='Hello World' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_nested_collections - form_for('post[]', @post) do |f| - concat f.text_field(:title) - f.fields_for('comment[]', @comment) do |c| - concat c.text_field(:name) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[123][title]' size='30' type='text' id='post_123_title' value='Hello World' />" + - "<input name='post[123][comment][][name]' size='30' type='text' id='post_123_comment__name' value='new comment' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_index_and_parent_fields - form_for('post', @post, :index => 1) do |c| - concat c.text_field(:title) - c.fields_for('comment', @comment, :index => 1) do |r| - concat r.text_field(:name) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[1][title]' size='30' type='text' id='post_1_title' value='Hello World' />" + - "<input name='post[1][comment][1][name]' size='30' type='text' id='post_1_comment_1_name' value='new comment' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_index_and_nested_fields_for - form_for(:post, @post, :index => 1) do |f| - f.fields_for(:comment, @post) do |c| - concat c.text_field(:title) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[1][comment][title]' size='30' type='text' id='post_1_comment_title' value='Hello World' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_index_on_both - form_for(:post, @post, :index => 1) do |f| - f.fields_for(:comment, @post, :index => 5) do |c| - concat c.text_field(:title) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[1][comment][5][title]' size='30' type='text' id='post_1_comment_5_title' value='Hello World' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_auto_index - form_for("post[]", @post) do |f| - f.fields_for(:comment, @post) do |c| - concat c.text_field(:title) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[123][comment][title]' size='30' type='text' id='post_123_comment_title' value='Hello World' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_auto_index_on_both - form_for("post[]", @post) do |f| - f.fields_for("comment[]", @post) do |c| - concat c.text_field(:title) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[123][comment][123][title]' size='30' type='text' id='post_123_comment_123_title' value='Hello World' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_index_and_auto_index - form_for("post[]", @post) do |f| - f.fields_for(:comment, @post, :index => 5) do |c| - concat c.text_field(:title) - end - end - - form_for(:post, @post, :index => 1) do |f| - f.fields_for("comment[]", @post) do |c| - concat c.text_field(:title) - end - end - - expected = "<form action='http://www.example.com' method='post'>" + - "<input name='post[123][comment][5][title]' size='30' type='text' id='post_123_comment_5_title' value='Hello World' />" + - "</form>" + - "<form action='http://www.example.com' method='post'>" + - "<input name='post[1][comment][123][title]' size='30' type='text' id='post_1_comment_123_title' value='Hello World' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_a_new_record_on_a_nested_attributes_one_to_one_association - @post.author = Author.new - - form_for(:post, @post) do |f| - concat f.text_field(:title) - f.fields_for(:author) do |af| - concat af.text_field(:name) - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="new author" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_explicitly_passed_object_on_a_nested_attributes_one_to_one_association - form_for(:post, @post) do |f| - f.fields_for(:author, Author.new(123)) do |af| - assert_not_nil af.object - assert_equal 123, af.object.id - end - end - end - - def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to_one_association - @post.author = Author.new(321) - - form_for(:post, @post) do |f| - concat f.text_field(:title) - f.fields_for(:author) do |af| - concat af.text_field(:name) - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' + - '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association - @post.comments = Array.new(2) { |id| Comment.new(id + 1) } - - form_for(:post, @post) do |f| - concat f.text_field(:title) - @post.comments.each do |comment| - f.fields_for(:comments, comment) do |cf| - concat cf.text_field(:name) - end - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' + - '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' + - '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />' + - '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="comment #2" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_new_records_on_a_nested_attributes_collection_association - @post.comments = [Comment.new, Comment.new] - - form_for(:post, @post) do |f| - concat f.text_field(:title) - @post.comments.each do |comment| - f.fields_for(:comments, comment) do |cf| - concat cf.text_field(:name) - end - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="new comment" />' + - '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="new comment" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_with_existing_and_new_records_on_a_nested_attributes_collection_association - @post.comments = [Comment.new(321), Comment.new] - - form_for(:post, @post) do |f| - concat f.text_field(:title) - @post.comments.each do |comment| - f.fields_for(:comments, comment) do |cf| - concat cf.text_field(:name) - end - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' + - '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #321" />' + - '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="new comment" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_nested_fields_for_on_a_nested_attributes_collection_association_yields_only_builder - @post.comments = [Comment.new(321), Comment.new] - yielded_comments = [] - - form_for(:post, @post) do |f| - concat f.text_field(:title) - f.fields_for(:comments) do |cf| - concat cf.text_field(:name) - yielded_comments << cf.object - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' + - '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' + - '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #321" />' + - '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="new comment" />' + - '</form>' - - assert_dom_equal expected, output_buffer - assert_equal yielded_comments, @post.comments - end - - def test_nested_fields_for_with_child_index_option_override_on_a_nested_attributes_collection_association - @post.comments = [] - - form_for(:post, @post) do |f| - f.fields_for(:comments, Comment.new(321), :child_index => 'abc') do |cf| - concat cf.text_field(:name) - end - end - - expected = '<form action="http://www.example.com" method="post">' + - '<input id="post_comments_attributes_abc_id" name="post[comments_attributes][abc][id]" type="hidden" value="321" />' + - '<input id="post_comments_attributes_abc_name" name="post[comments_attributes][abc][name]" size="30" type="text" value="comment #321" />' + - '</form>' - - assert_dom_equal expected, output_buffer - end - - def test_fields_for - fields_for(:post, @post) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[secret]' type='hidden' value='0' />" + - "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" - - assert_dom_equal expected, output_buffer - end - - def test_fields_for_with_index - fields_for("post[]", @post) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<input name='post[123][title]' size='30' type='text' id='post_123_title' value='Hello World' />" + - "<textarea name='post[123][body]' id='post_123_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[123][secret]' type='hidden' value='0' />" + - "<input name='post[123][secret]' checked='checked' type='checkbox' id='post_123_secret' value='1' />" - - assert_dom_equal expected, output_buffer - end - - def test_fields_for_with_nil_index_option_override - fields_for("post[]", @post, :index => nil) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<input name='post[][title]' size='30' type='text' id='post__title' value='Hello World' />" + - "<textarea name='post[][body]' id='post__body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[][secret]' type='hidden' value='0' />" + - "<input name='post[][secret]' checked='checked' type='checkbox' id='post__secret' value='1' />" - - assert_dom_equal expected, output_buffer - end - - def test_fields_for_with_index_option_override - fields_for("post[]", @post, :index => "abc") do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<input name='post[abc][title]' size='30' type='text' id='post_abc_title' value='Hello World' />" + - "<textarea name='post[abc][body]' id='post_abc_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[abc][secret]' type='hidden' value='0' />" + - "<input name='post[abc][secret]' checked='checked' type='checkbox' id='post_abc_secret' value='1' />" - - assert_dom_equal expected, output_buffer - end - - def test_fields_for_without_object - fields_for(:post) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[secret]' type='hidden' value='0' />" + - "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" - - assert_dom_equal expected, output_buffer - end - - def test_fields_for_with_only_object - fields_for(@post) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[secret]' type='hidden' value='0' />" + - "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" - - assert_dom_equal expected, output_buffer - end - - def test_fields_for_object_with_bracketed_name - fields_for("author[post]", @post) do |f| - concat f.label(:title) - concat f.text_field(:title) - end - - assert_dom_equal "<label for=\"author_post_title\">Title</label>" + - "<input name='author[post][title]' size='30' type='text' id='author_post_title' value='Hello World' />", - output_buffer - end - - def test_fields_for_object_with_bracketed_name_and_index - fields_for("author[post]", @post, :index => 1) do |f| - concat f.label(:title) - concat f.text_field(:title) - end - - assert_dom_equal "<label for=\"author_post_1_title\">Title</label>" + - "<input name='author[post][1][title]' size='30' type='text' id='author_post_1_title' value='Hello World' />", - output_buffer - end - - def test_form_builder_does_not_have_form_for_method - assert ! ActionView::Helpers::FormBuilder.instance_methods.include?('form_for') - end - - def test_form_for_and_fields_for - form_for(:post, @post, :html => { :id => 'create-post' }) do |post_form| - concat post_form.text_field(:title) - concat post_form.text_area(:body) - - fields_for(:parent_post, @post) do |parent_fields| - concat parent_fields.check_box(:secret) - end - end - - expected = - "<form action='http://www.example.com' id='create-post' method='post'>" + - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='parent_post[secret]' type='hidden' value='0' />" + - "<input name='parent_post[secret]' checked='checked' type='checkbox' id='parent_post_secret' value='1' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_and_fields_for_with_object - form_for(:post, @post, :html => { :id => 'create-post' }) do |post_form| - concat post_form.text_field(:title) - concat post_form.text_area(:body) - - post_form.fields_for(@comment) do |comment_fields| - concat comment_fields.text_field(:name) - end - end - - expected = - "<form action='http://www.example.com' id='create-post' method='post'>" + - "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + - "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + - "<input name='post[comment][name]' type='text' id='post_comment_name' value='new comment' size='30' />" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - class LabelledFormBuilder < ActionView::Helpers::FormBuilder - (field_helpers - %w(hidden_field)).each do |selector| - src = <<-END_SRC - def #{selector}(field, *args, &proc) - "<label for='\#{field}'>\#{field.to_s.humanize}:</label> " + super + "<br/>" - end - END_SRC - class_eval src, __FILE__, __LINE__ - end - end - - def test_form_for_with_labelled_builder - form_for(:post, @post, :builder => LabelledFormBuilder) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<form action='http://www.example.com' method='post'>" + - "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" + - "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" + - "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_default_form_builder - old_default_form_builder, ActionView::Base.default_form_builder = - ActionView::Base.default_form_builder, LabelledFormBuilder - - form_for(:post, @post) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<form action='http://www.example.com' method='post'>" + - "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" + - "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" + - "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>" + - "</form>" - - assert_dom_equal expected, output_buffer - ensure - ActionView::Base.default_form_builder = old_default_form_builder - end - - def test_default_form_builder_with_active_record_helpers - form_for(:post, @post) do |f| - concat f.error_message_on('author_name') - concat f.error_messages - end - - expected = %(<form action='http://www.example.com' method='post'>) + - %(<div class='formError'>can't be empty</div>) + - %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>) + - %(</form>) - - assert_dom_equal expected, output_buffer - - end - - def test_default_form_builder_no_instance_variable - post = @post - @post = nil - - form_for(:post, post) do |f| - concat f.error_message_on('author_name') - concat f.error_messages - end - - expected = %(<form action='http://www.example.com' method='post'>) + - %(<div class='formError'>can't be empty</div>) + - %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>) + - %(</form>) - - assert_dom_equal expected, output_buffer - - end - - # Perhaps this test should be moved to prototype helper tests. - def test_remote_form_for_with_labelled_builder - self.extend ActionView::Helpers::PrototypeHelper - - remote_form_for(:post, @post, :builder => LabelledFormBuilder) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - %(<form action="http://www.example.com" onsubmit="new Ajax.Request('http://www.example.com', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" method="post">) + - "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" + - "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" + - "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>" + - "</form>" - - assert_dom_equal expected, output_buffer - end - - def test_fields_for_with_labelled_builder - fields_for(:post, @post, :builder => LabelledFormBuilder) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end - - expected = - "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" + - "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" + - "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_labelled_builder_with_nested_fields_for_without_options_hash - klass = nil - - form_for(:post, @post, :builder => LabelledFormBuilder) do |f| - f.fields_for(:comments, Comment.new) do |nested_fields| - klass = nested_fields.class - '' - end - end - - assert_equal LabelledFormBuilder, klass - end - - def test_form_for_with_labelled_builder_with_nested_fields_for_with_options_hash - klass = nil - - form_for(:post, @post, :builder => LabelledFormBuilder) do |f| - f.fields_for(:comments, Comment.new, :index => 'foo') do |nested_fields| - klass = nested_fields.class - '' - end - end - - assert_equal LabelledFormBuilder, klass - end - - class LabelledFormBuilderSubclass < LabelledFormBuilder; end - - def test_form_for_with_labelled_builder_with_nested_fields_for_with_custom_builder - klass = nil - - form_for(:post, @post, :builder => LabelledFormBuilder) do |f| - f.fields_for(:comments, Comment.new, :builder => LabelledFormBuilderSubclass) do |nested_fields| - klass = nested_fields.class - '' - end - end - - assert_equal LabelledFormBuilderSubclass, klass - end - - def test_form_for_with_html_options_adds_options_to_form_tag - form_for(:post, @post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end - expected = "<form action=\"http://www.example.com\" class=\"some_class\" id=\"some_form\" method=\"post\"></form>" - - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_string_url_option - form_for(:post, @post, :url => 'http://www.otherdomain.com') do |f| end - - assert_equal '<form action="http://www.otherdomain.com" method="post"></form>', output_buffer - end - - def test_form_for_with_hash_url_option - form_for(:post, @post, :url => {:controller => 'controller', :action => 'action'}) do |f| end - - assert_equal 'controller', @controller.url_for_options[:controller] - assert_equal 'action', @controller.url_for_options[:action] - end - - def test_form_for_with_record_url_option - form_for(:post, @post, :url => @post) do |f| end - - expected = "<form action=\"/posts/123\" method=\"post\"></form>" - assert_equal expected, output_buffer - end - - def test_form_for_with_existing_object - form_for(@post) do |f| end - - expected = "<form action=\"/posts/123\" class=\"edit_post\" id=\"edit_post_123\" method=\"post\"><div style=\"margin:0;padding:0\"><input name=\"_method\" type=\"hidden\" value=\"put\" /></div></form>" - assert_equal expected, output_buffer - end - - def test_form_for_with_new_object - post = Post.new - post.new_record = true - def post.id() nil end - - form_for(post) do |f| end - - expected = "<form action=\"/posts\" class=\"new_post\" id=\"new_post\" method=\"post\"></form>" - assert_equal expected, output_buffer - end - - def test_form_for_with_existing_object_in_list - @post.new_record = false - @comment.save - - form_for([@post, @comment]) {} - - expected = %(<form action="#{comment_path(@post, @comment)}" class="edit_comment" id="edit_comment_1" method="post"><div style="margin:0;padding:0"><input name="_method" type="hidden" value="put" /></div></form>) - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_new_object_in_list - @post.new_record = false - - form_for([@post, @comment]) {} - - expected = %(<form action="#{comments_path(@post)}" class="new_comment" id="new_comment" method="post"></form>) - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_existing_object_and_namespace_in_list - @post.new_record = false - @comment.save - - form_for([:admin, @post, @comment]) {} - - expected = %(<form action="#{admin_comment_path(@post, @comment)}" class="edit_comment" id="edit_comment_1" method="post"><div style="margin:0;padding:0"><input name="_method" type="hidden" value="put" /></div></form>) - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_new_object_and_namespace_in_list - @post.new_record = false - - form_for([:admin, @post, @comment]) {} - - expected = %(<form action="#{admin_comments_path(@post)}" class="new_comment" id="new_comment" method="post"></form>) - assert_dom_equal expected, output_buffer - end - - def test_form_for_with_existing_object_and_custom_url - form_for(@post, :url => "/super_posts") do |f| end - - expected = "<form action=\"/super_posts\" class=\"edit_post\" id=\"edit_post_123\" method=\"post\"><div style=\"margin:0;padding:0\"><input name=\"_method\" type=\"hidden\" value=\"put\" /></div></form>" - assert_equal expected, output_buffer - end - - def test_remote_form_for_with_html_options_adds_options_to_form_tag - self.extend ActionView::Helpers::PrototypeHelper - - remote_form_for(:post, @post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end - expected = "<form action=\"http://www.example.com\" class=\"some_class\" id=\"some_form\" method=\"post\" onsubmit=\"new Ajax.Request('http://www.example.com', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\"></form>" - - assert_dom_equal expected, output_buffer - end - - protected - def comments_path(post) - "/posts/#{post.id}/comments" - end - alias_method :post_comments_path, :comments_path - - def comment_path(post, comment) - "/posts/#{post.id}/comments/#{comment.id}" - end - alias_method :post_comment_path, :comment_path - - def admin_comments_path(post) - "/admin/posts/#{post.id}/comments" - end - alias_method :admin_post_comments_path, :admin_comments_path - - def admin_comment_path(post, comment) - "/admin/posts/#{post.id}/comments/#{comment.id}" - end - alias_method :admin_post_comment_path, :admin_comment_path - - def posts_path - "/posts" - end - - def post_path(post) - "/posts/#{post.id}" - end - - def protect_against_forgery? - false - end -end \ No newline at end of file diff --git a/vendor/rails/actionpack/test/template/form_options_helper_test.rb b/vendor/rails/actionpack/test/template/form_options_helper_test.rb deleted file mode 100644 index 78db879..0000000 --- a/vendor/rails/actionpack/test/template/form_options_helper_test.rb +++ /dev/null @@ -1,751 +0,0 @@ -require 'abstract_unit' -require 'tzinfo' - -TZInfo::Timezone.cattr_reader :loaded_zones - -class FormOptionsHelperTest < ActionView::TestCase - tests ActionView::Helpers::FormOptionsHelper - - silence_warnings do - Post = Struct.new('Post', :title, :author_name, :body, :secret, :written_on, :category, :origin) - Continent = Struct.new('Continent', :continent_name, :countries) - Country = Struct.new('Country', :country_id, :country_name) - Firm = Struct.new('Firm', :time_zone) - Album = Struct.new('Album', :id, :title, :genre) - end - - def setup - @fake_timezones = %w(A B C D E).inject([]) do |zones, id| - tz = TZInfo::Timezone.loaded_zones[id] = stub(:name => id, :to_s => id) - ActiveSupport::TimeZone.stubs(:[]).with(id).returns(tz) - zones << tz - end - ActiveSupport::TimeZone.stubs(:all).returns(@fake_timezones) - end - - def test_collection_options - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\">Babe went home</option>\n<option value=\"Cabe\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title") - ) - end - - - def test_collection_options_with_preselected_value - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" selected=\"selected\">Babe went home</option>\n<option value=\"Cabe\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title", "Babe") - ) - end - - def test_collection_options_with_preselected_value_array - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" selected=\"selected\">Babe went home</option>\n<option value=\"Cabe\" selected=\"selected\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title", [ "Babe", "Cabe" ]) - ) - end - - def test_collection_options_with_proc_for_selected - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" selected=\"selected\">Babe went home</option>\n<option value=\"Cabe\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title", lambda{|p| p.author_name == 'Babe' }) - ) - end - - def test_collection_options_with_disabled_value - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" disabled=\"disabled\">Babe went home</option>\n<option value=\"Cabe\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title", :disabled => "Babe") - ) - end - - def test_collection_options_with_disabled_array - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" disabled=\"disabled\">Babe went home</option>\n<option value=\"Cabe\" disabled=\"disabled\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title", :disabled => [ "Babe", "Cabe" ]) - ) - end - - def test_collection_options_with_preselected_and_disabled_value - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" disabled=\"disabled\">Babe went home</option>\n<option value=\"Cabe\" selected=\"selected\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title", :selected => "Cabe", :disabled => "Babe") - ) - end - - def test_collection_options_with_proc_for_disabled - assert_dom_equal( - "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" disabled=\"disabled\">Babe went home</option>\n<option value=\"Cabe\" disabled=\"disabled\">Cabe went home</option>", - options_from_collection_for_select(dummy_posts, "author_name", "title", :disabled => lambda{|p| %w(Babe Cabe).include? p.author_name }) - ) - end - - def test_array_options_for_select - assert_dom_equal( - "<option value=\"&lt;Denmark&gt;\">&lt;Denmark&gt;</option>\n<option value=\"USA\">USA</option>\n<option value=\"Sweden\">Sweden</option>", - options_for_select([ "<Denmark>", "USA", "Sweden" ]) - ) - end - - def test_array_options_for_select_with_selection - assert_dom_equal( - "<option value=\"Denmark\">Denmark</option>\n<option value=\"&lt;USA&gt;\" selected=\"selected\">&lt;USA&gt;</option>\n<option value=\"Sweden\">Sweden</option>", - options_for_select([ "Denmark", "<USA>", "Sweden" ], "<USA>") - ) - end - - def test_array_options_for_select_with_selection_array - assert_dom_equal( - "<option value=\"Denmark\">Denmark</option>\n<option value=\"&lt;USA&gt;\" selected=\"selected\">&lt;USA&gt;</option>\n<option value=\"Sweden\" selected=\"selected\">Sweden</option>", - options_for_select([ "Denmark", "<USA>", "Sweden" ], [ "<USA>", "Sweden" ]) - ) - end - - def test_array_options_for_select_with_disabled_value - assert_dom_equal( - "<option value=\"Denmark\">Denmark</option>\n<option value=\"&lt;USA&gt;\" disabled=\"disabled\">&lt;USA&gt;</option>\n<option value=\"Sweden\">Sweden</option>", - options_for_select([ "Denmark", "<USA>", "Sweden" ], :disabled => "<USA>") - ) - end - - def test_array_options_for_select_with_disabled_array - assert_dom_equal( - "<option value=\"Denmark\">Denmark</option>\n<option value=\"&lt;USA&gt;\" disabled=\"disabled\">&lt;USA&gt;</option>\n<option value=\"Sweden\" disabled=\"disabled\">Sweden</option>", - options_for_select([ "Denmark", "<USA>", "Sweden" ], :disabled => ["<USA>", "Sweden"]) - ) - end - - def test_array_options_for_select_with_selection_and_disabled_value - assert_dom_equal( - "<option value=\"Denmark\" selected=\"selected\">Denmark</option>\n<option value=\"&lt;USA&gt;\" disabled=\"disabled\">&lt;USA&gt;</option>\n<option value=\"Sweden\">Sweden</option>", - options_for_select([ "Denmark", "<USA>", "Sweden" ], :selected => "Denmark", :disabled => "<USA>") - ) - end - - def test_array_options_for_string_include_in_other_string_bug_fix - assert_dom_equal( - "<option value=\"ruby\">ruby</option>\n<option value=\"rubyonrails\" selected=\"selected\">rubyonrails</option>", - options_for_select([ "ruby", "rubyonrails" ], "rubyonrails") - ) - assert_dom_equal( - "<option value=\"ruby\" selected=\"selected\">ruby</option>\n<option value=\"rubyonrails\">rubyonrails</option>", - options_for_select([ "ruby", "rubyonrails" ], "ruby") - ) - assert_dom_equal( - %(<option value="ruby" selected="selected">ruby</option>\n<option value="rubyonrails">rubyonrails</option>\n<option value=""></option>), - options_for_select([ "ruby", "rubyonrails", nil ], "ruby") - ) - end - - def test_hash_options_for_select - assert_dom_equal( - "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\">$</option>", - options_for_select("$" => "Dollar", "<DKR>" => "<Kroner>").split("\n").sort.join("\n") - ) - assert_dom_equal( - "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>", - options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, "Dollar").split("\n").sort.join("\n") - ) - assert_dom_equal( - "<option value=\"&lt;Kroner&gt;\" selected=\"selected\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>", - options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, [ "Dollar", "<Kroner>" ]).split("\n").sort.join("\n") - ) - end - - def test_ducktyped_options_for_select - quack = Struct.new(:first, :last) - assert_dom_equal( - "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\">$</option>", - options_for_select([quack.new("<DKR>", "<Kroner>"), quack.new("$", "Dollar")]) - ) - assert_dom_equal( - "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>", - options_for_select([quack.new("<DKR>", "<Kroner>"), quack.new("$", "Dollar")], "Dollar") - ) - assert_dom_equal( - "<option value=\"&lt;Kroner&gt;\" selected=\"selected\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>", - options_for_select([quack.new("<DKR>", "<Kroner>"), quack.new("$", "Dollar")], ["Dollar", "<Kroner>"]) - ) - end - - def test_option_groups_from_collection_for_select - @continents = [ - Continent.new("<Africa>", [Country.new("<sa>", "<South Africa>"), Country.new("so", "Somalia")] ), - Continent.new("Europe", [Country.new("dk", "Denmark"), Country.new("ie", "Ireland")] ) - ] - - assert_dom_equal( - "<optgroup label=\"&lt;Africa&gt;\"><option value=\"&lt;sa&gt;\">&lt;South Africa&gt;</option>\n<option value=\"so\">Somalia</option></optgroup><optgroup label=\"Europe\"><option value=\"dk\" selected=\"selected\">Denmark</option>\n<option value=\"ie\">Ireland</option></optgroup>", - option_groups_from_collection_for_select(@continents, "countries", "continent_name", "country_id", "country_name", "dk") - ) - end - - def test_grouped_options_for_select_with_array - assert_dom_equal( - "<optgroup label=\"North America\"><option value=\"US\">United States</option>\n<option value=\"Canada\">Canada</option></optgroup><optgroup label=\"Europe\"><option value=\"GB\">Great Britain</option>\n<option value=\"Germany\">Germany</option></optgroup>", - grouped_options_for_select([ - ["North America", - [['United States','US'],"Canada"]], - ["Europe", - [["Great Britain","GB"], "Germany"]] - ]) - ) - end - - def test_grouped_options_for_select_with_selected_and_prompt - assert_dom_equal( - "<option value=\"\">Choose a product...</option><optgroup label=\"Hats\"><option value=\"Baseball Cap\">Baseball Cap</option>\n<option selected=\"selected\" value=\"Cowboy Hat\">Cowboy Hat</option></optgroup>", - grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]], "Cowboy Hat", "Choose a product...") - ) - end - - def test_optgroups_with_with_options_with_hash - assert_dom_equal( - "<optgroup label=\"Europe\"><option value=\"Denmark\">Denmark</option>\n<option value=\"Germany\">Germany</option></optgroup><optgroup label=\"North America\"><option value=\"United States\">United States</option>\n<option value=\"Canada\">Canada</option></optgroup>", - grouped_options_for_select({'North America' => ['United States','Canada'], 'Europe' => ['Denmark','Germany']}) - ) - end - - def test_time_zone_options_no_parms - opts = time_zone_options_for_select - assert_dom_equal "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\">D</option>\n" + - "<option value=\"E\">E</option>", - opts - end - - def test_time_zone_options_with_selected - opts = time_zone_options_for_select( "D" ) - assert_dom_equal "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>", - opts - end - - def test_time_zone_options_with_unknown_selected - opts = time_zone_options_for_select( "K" ) - assert_dom_equal "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\">D</option>\n" + - "<option value=\"E\">E</option>", - opts - end - - def test_time_zone_options_with_priority_zones - zones = [ ActiveSupport::TimeZone.new( "B" ), ActiveSupport::TimeZone.new( "E" ) ] - opts = time_zone_options_for_select( nil, zones ) - assert_dom_equal "<option value=\"B\">B</option>\n" + - "<option value=\"E\">E</option>" + - "<option value=\"\" disabled=\"disabled\">-------------</option>\n" + - "<option value=\"A\">A</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\">D</option>", - opts - end - - def test_time_zone_options_with_selected_priority_zones - zones = [ ActiveSupport::TimeZone.new( "B" ), ActiveSupport::TimeZone.new( "E" ) ] - opts = time_zone_options_for_select( "E", zones ) - assert_dom_equal "<option value=\"B\">B</option>\n" + - "<option value=\"E\" selected=\"selected\">E</option>" + - "<option value=\"\" disabled=\"disabled\">-------------</option>\n" + - "<option value=\"A\">A</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\">D</option>", - opts - end - - def test_time_zone_options_with_unselected_priority_zones - zones = [ ActiveSupport::TimeZone.new( "B" ), ActiveSupport::TimeZone.new( "E" ) ] - opts = time_zone_options_for_select( "C", zones ) - assert_dom_equal "<option value=\"B\">B</option>\n" + - "<option value=\"E\">E</option>" + - "<option value=\"\" disabled=\"disabled\">-------------</option>\n" + - "<option value=\"A\">A</option>\n" + - "<option value=\"C\" selected=\"selected\">C</option>\n" + - "<option value=\"D\">D</option>", - opts - end - - def test_select - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest)) - ) - end - - def test_select_under_fields_for - @post = Post.new - @post.category = "<mus>" - - fields_for :post, @post do |f| - concat f.select(:category, %w( abe <mus> hest)) - end - - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - output_buffer - ) - end - - def test_select_under_fields_for_with_index - @post = Post.new - @post.category = "<mus>" - - fields_for :post, @post, :index => 108 do |f| - concat f.select(:category, %w( abe <mus> hest)) - end - - assert_dom_equal( - "<select id=\"post_108_category\" name=\"post[108][category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - output_buffer - ) - end - - def test_select_under_fields_for_with_auto_index - @post = Post.new - @post.category = "<mus>" - def @post.to_param; 108; end - - fields_for "post[]", @post do |f| - concat f.select(:category, %w( abe <mus> hest)) - end - - assert_dom_equal( - "<select id=\"post_108_category\" name=\"post[108][category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - output_buffer - ) - end - - def test_select_with_blank - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"\"></option>\n<option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest), :include_blank => true) - ) - end - - def test_select_with_blank_as_string - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"\">None</option>\n<option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest), :include_blank => 'None') - ) - end - - def test_select_with_default_prompt - @post = Post.new - @post.category = "" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"\">Please select</option>\n<option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest), :prompt => true) - ) - end - - def test_select_no_prompt_when_select_has_value - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest), :prompt => true) - ) - end - - def test_select_with_given_prompt - @post = Post.new - @post.category = "" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"\">The prompt</option>\n<option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest), :prompt => 'The prompt') - ) - end - - def test_select_with_prompt_and_blank - @post = Post.new - @post.category = "" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"\">Please select</option>\n<option value=\"\"></option>\n<option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest), :prompt => true, :include_blank => true) - ) - end - - def test_select_with_selected_value - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\" selected=\"selected\">abe</option>\n<option value=\"&lt;mus&gt;\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest ), :selected => 'abe') - ) - end - - def test_select_with_index_option - @album = Album.new - @album.id = 1 - - expected = "<select id=\"album__genre\" name=\"album[][genre]\"><option value=\"rap\">rap</option>\n<option value=\"rock\">rock</option>\n<option value=\"country\">country</option></select>" - - assert_dom_equal( - expected, - select("album[]", "genre", %w[rap rock country], {}, { :index => nil }) - ) - end - - def test_select_with_selected_nil - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>", - select("post", "category", %w( abe <mus> hest ), :selected => nil) - ) - end - - def test_select_with_disabled_value - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\" disabled=\"disabled\">hest</option></select>", - select("post", "category", %w( abe <mus> hest ), :disabled => 'hest') - ) - end - - def test_select_with_disabled_array - @post = Post.new - @post.category = "<mus>" - assert_dom_equal( - "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\" disabled=\"disabled\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\" disabled=\"disabled\">hest</option></select>", - select("post", "category", %w( abe <mus> hest ), :disabled => ['hest', 'abe']) - ) - end - - def test_collection_select - @post = Post.new - @post.author_name = "Babe" - - assert_dom_equal( - "<select id=\"post_author_name\" name=\"post[author_name]\"><option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>", - collection_select("post", "author_name", dummy_posts, "author_name", "author_name") - ) - end - - def test_collection_select_under_fields_for - @post = Post.new - @post.author_name = "Babe" - - fields_for :post, @post do |f| - concat f.collection_select(:author_name, dummy_posts, :author_name, :author_name) - end - - assert_dom_equal( - "<select id=\"post_author_name\" name=\"post[author_name]\"><option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>", - output_buffer - ) - end - - def test_collection_select_under_fields_for_with_index - @post = Post.new - @post.author_name = "Babe" - - fields_for :post, @post, :index => 815 do |f| - concat f.collection_select(:author_name, dummy_posts, :author_name, :author_name) - end - - assert_dom_equal( - "<select id=\"post_815_author_name\" name=\"post[815][author_name]\"><option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>", - output_buffer - ) - end - - def test_collection_select_under_fields_for_with_auto_index - @post = Post.new - @post.author_name = "Babe" - def @post.to_param; 815; end - - fields_for "post[]", @post do |f| - concat f.collection_select(:author_name, dummy_posts, :author_name, :author_name) - end - - assert_dom_equal( - "<select id=\"post_815_author_name\" name=\"post[815][author_name]\"><option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>", - output_buffer - ) - end - - def test_collection_select_with_blank_and_style - @post = Post.new - @post.author_name = "Babe" - - assert_dom_equal( - "<select id=\"post_author_name\" name=\"post[author_name]\" style=\"width: 200px\"><option value=\"\"></option>\n<option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>", - collection_select("post", "author_name", dummy_posts, "author_name", "author_name", { :include_blank => true }, "style" => "width: 200px") - ) - end - - def test_collection_select_with_blank_as_string_and_style - @post = Post.new - @post.author_name = "Babe" - - assert_dom_equal( - "<select id=\"post_author_name\" name=\"post[author_name]\" style=\"width: 200px\"><option value=\"\">No Selection</option>\n<option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>", - collection_select("post", "author_name", dummy_posts, "author_name", "author_name", { :include_blank => 'No Selection' }, "style" => "width: 200px") - ) - end - - def test_collection_select_with_multiple_option_appends_array_brackets - @post = Post.new - @post.author_name = "Babe" - - expected = "<select id=\"post_author_name\" name=\"post[author_name][]\" multiple=\"multiple\"><option value=\"\"></option>\n<option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>" - - # Should suffix default name with []. - assert_dom_equal expected, collection_select("post", "author_name", dummy_posts, "author_name", "author_name", { :include_blank => true }, :multiple => true) - - # Shouldn't suffix custom name with []. - assert_dom_equal expected, collection_select("post", "author_name", dummy_posts, "author_name", "author_name", { :include_blank => true, :name => 'post[author_name][]' }, :multiple => true) - end - - def test_collection_select_with_blank_and_selected - @post = Post.new - @post.author_name = "Babe" - - assert_dom_equal( - %{<select id="post_author_name" name="post[author_name]"><option value=""></option>\n<option value="&lt;Abe&gt;" selected="selected">&lt;Abe&gt;</option>\n<option value="Babe">Babe</option>\n<option value="Cabe">Cabe</option></select>}, - collection_select("post", "author_name", dummy_posts, "author_name", "author_name", {:include_blank => true, :selected => "<Abe>"}) - ) - end - - def test_collection_select_with_disabled - @post = Post.new - @post.author_name = "Babe" - - assert_dom_equal( - "<select id=\"post_author_name\" name=\"post[author_name]\"><option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\" disabled=\"disabled\">Cabe</option></select>", - collection_select("post", "author_name", dummy_posts, "author_name", "author_name", :disabled => 'Cabe') - ) - end - - def test_time_zone_select - @firm = Firm.new("D") - html = time_zone_select( "firm", "time_zone" ) - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - end - - def test_time_zone_select_under_fields_for - @firm = Firm.new("D") - - fields_for :firm, @firm do |f| - concat f.time_zone_select(:time_zone) - end - - assert_dom_equal( - "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - output_buffer - ) - end - - def test_time_zone_select_under_fields_for_with_index - @firm = Firm.new("D") - - fields_for :firm, @firm, :index => 305 do |f| - concat f.time_zone_select(:time_zone) - end - - assert_dom_equal( - "<select id=\"firm_305_time_zone\" name=\"firm[305][time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - output_buffer - ) - end - - def test_time_zone_select_under_fields_for_with_auto_index - @firm = Firm.new("D") - def @firm.to_param; 305; end - - fields_for "firm[]", @firm do |f| - concat f.time_zone_select(:time_zone) - end - - assert_dom_equal( - "<select id=\"firm_305_time_zone\" name=\"firm[305][time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - output_buffer - ) - end - - def test_time_zone_select_with_blank - @firm = Firm.new("D") - html = time_zone_select("firm", "time_zone", nil, :include_blank => true) - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"\"></option>\n" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - end - - def test_time_zone_select_with_blank_as_string - @firm = Firm.new("D") - html = time_zone_select("firm", "time_zone", nil, :include_blank => 'No Zone') - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"\">No Zone</option>\n" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - end - - def test_time_zone_select_with_style - @firm = Firm.new("D") - html = time_zone_select("firm", "time_zone", nil, {}, - "style" => "color: red") - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\" style=\"color: red\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - assert_dom_equal html, time_zone_select("firm", "time_zone", nil, {}, - :style => "color: red") - end - - def test_time_zone_select_with_blank_and_style - @firm = Firm.new("D") - html = time_zone_select("firm", "time_zone", nil, - { :include_blank => true }, "style" => "color: red") - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\" style=\"color: red\">" + - "<option value=\"\"></option>\n" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - assert_dom_equal html, time_zone_select("firm", "time_zone", nil, - { :include_blank => true }, :style => "color: red") - end - - def test_time_zone_select_with_blank_as_string_and_style - @firm = Firm.new("D") - html = time_zone_select("firm", "time_zone", nil, - { :include_blank => 'No Zone' }, "style" => "color: red") - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\" style=\"color: red\">" + - "<option value=\"\">No Zone</option>\n" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - assert_dom_equal html, time_zone_select("firm", "time_zone", nil, - { :include_blank => 'No Zone' }, :style => "color: red") - end - - def test_time_zone_select_with_priority_zones - @firm = Firm.new("D") - zones = [ ActiveSupport::TimeZone.new("A"), ActiveSupport::TimeZone.new("D") ] - html = time_zone_select("firm", "time_zone", zones ) - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>" + - "<option value=\"\" disabled=\"disabled\">-------------</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - end - - def test_time_zone_select_with_priority_zones_as_regexp - @firm = Firm.new("D") - @fake_timezones.each_with_index do |tz, i| - tz.stubs(:=~).returns(i.zero? || i == 3) - end - - html = time_zone_select("firm", "time_zone", /A|D/) - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>" + - "<option value=\"\" disabled=\"disabled\">-------------</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - end - - def test_time_zone_select_with_default_time_zone_and_nil_value - @firm = Firm.new() - @firm.time_zone = nil - html = time_zone_select( "firm", "time_zone", nil, :default => 'B' ) - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\" selected=\"selected\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - end - - def test_time_zone_select_with_default_time_zone_and_value - @firm = Firm.new('D') - html = time_zone_select( "firm", "time_zone", nil, :default => 'B' ) - assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" + - "<option value=\"A\">A</option>\n" + - "<option value=\"B\">B</option>\n" + - "<option value=\"C\">C</option>\n" + - "<option value=\"D\" selected=\"selected\">D</option>\n" + - "<option value=\"E\">E</option>" + - "</select>", - html - end - - private - - def dummy_posts - [ Post.new("<Abe> went home", "<Abe>", "To a little house", "shh!"), - Post.new("Babe went home", "Babe", "To a little house", "shh!"), - Post.new("Cabe went home", "Cabe", "To a little house", "shh!") ] - end -end diff --git a/vendor/rails/actionpack/test/template/form_tag_helper_test.rb b/vendor/rails/actionpack/test/template/form_tag_helper_test.rb deleted file mode 100644 index c713b8d..0000000 --- a/vendor/rails/actionpack/test/template/form_tag_helper_test.rb +++ /dev/null @@ -1,327 +0,0 @@ -require 'abstract_unit' - -class FormTagHelperTest < ActionView::TestCase - tests ActionView::Helpers::FormTagHelper - - def setup - @controller = Class.new do - def url_for(options) - "http://www.example.com" - end - end - @controller = @controller.new - end - - VALID_HTML_ID = /^[A-Za-z][-_:.A-Za-z0-9]*$/ # see http://www.w3.org/TR/html4/types.html#type-name - - def test_check_box_tag - actual = check_box_tag "admin" - expected = %(<input id="admin" name="admin" type="checkbox" value="1" />) - assert_dom_equal expected, actual - end - - def test_check_box_tag_id_sanitized - label_elem = root_elem(check_box_tag("project[2][admin]")) - assert_match VALID_HTML_ID, label_elem['id'] - end - - def test_form_tag - actual = form_tag - expected = %(<form action="http://www.example.com" method="post">) - assert_dom_equal expected, actual - end - - def test_form_tag_multipart - actual = form_tag({}, { 'multipart' => true }) - expected = %(<form action="http://www.example.com" enctype="multipart/form-data" method="post">) - assert_dom_equal expected, actual - end - - def test_form_tag_with_method_put - actual = form_tag({}, { :method => :put }) - expected = %(<form action="http://www.example.com" method="post"><div style='margin:0;padding:0'><input type="hidden" name="_method" value="put" /></div>) - assert_dom_equal expected, actual - end - - def test_form_tag_with_method_delete - actual = form_tag({}, { :method => :delete }) - expected = %(<form action="http://www.example.com" method="post"><div style='margin:0;padding:0'><input type="hidden" name="_method" value="delete" /></div>) - assert_dom_equal expected, actual - end - - def test_form_tag_with_block_in_erb - __in_erb_template = '' - form_tag("http://example.com") { concat "Hello world!" } - - expected = %(<form action="http://example.com" method="post">Hello world!</form>) - assert_dom_equal expected, output_buffer - end - - def test_form_tag_with_block_and_method_in_erb - __in_erb_template = '' - form_tag("http://example.com", :method => :put) { concat "Hello world!" } - - expected = %(<form action="http://example.com" method="post"><div style='margin:0;padding:0'><input type="hidden" name="_method" value="put" /></div>Hello world!</form>) - assert_dom_equal expected, output_buffer - end - - def test_hidden_field_tag - actual = hidden_field_tag "id", 3 - expected = %(<input id="id" name="id" type="hidden" value="3" />) - assert_dom_equal expected, actual - end - - def test_hidden_field_tag_id_sanitized - input_elem = root_elem(hidden_field_tag("item[][title]")) - assert_match VALID_HTML_ID, input_elem['id'] - end - - def test_file_field_tag - assert_dom_equal "<input name=\"picsplz\" type=\"file\" id=\"picsplz\" />", file_field_tag("picsplz") - end - - def test_file_field_tag_with_options - assert_dom_equal "<input name=\"picsplz\" type=\"file\" id=\"picsplz\" class=\"pix\"/>", file_field_tag("picsplz", :class => "pix") - end - - def test_password_field_tag - actual = password_field_tag - expected = %(<input id="password" name="password" type="password" />) - assert_dom_equal expected, actual - end - - def test_radio_button_tag - actual = radio_button_tag "people", "david" - expected = %(<input id="people_david" name="people" type="radio" value="david" />) - assert_dom_equal expected, actual - - actual = radio_button_tag("num_people", 5) - expected = %(<input id="num_people_5" name="num_people" type="radio" value="5" />) - assert_dom_equal expected, actual - - actual = radio_button_tag("gender", "m") + radio_button_tag("gender", "f") - expected = %(<input id="gender_m" name="gender" type="radio" value="m" /><input id="gender_f" name="gender" type="radio" value="f" />) - assert_dom_equal expected, actual - - actual = radio_button_tag("opinion", "-1") + radio_button_tag("opinion", "1") - expected = %(<input id="opinion_-1" name="opinion" type="radio" value="-1" /><input id="opinion_1" name="opinion" type="radio" value="1" />) - assert_dom_equal expected, actual - - actual = radio_button_tag("person[gender]", "m") - expected = %(<input id="person_gender_m" name="person[gender]" type="radio" value="m" />) - assert_dom_equal expected, actual - end - - def test_select_tag - actual = select_tag "people", "<option>david</option>" - expected = %(<select id="people" name="people"><option>david</option></select>) - assert_dom_equal expected, actual - end - - def test_select_tag_with_multiple - actual = select_tag "colors", "<option>Red</option><option>Blue</option><option>Green</option>", :multiple => :true - expected = %(<select id="colors" multiple="multiple" name="colors"><option>Red</option><option>Blue</option><option>Green</option></select>) - assert_dom_equal expected, actual - end - - def test_select_tag_disabled - actual = select_tag "places", "<option>Home</option><option>Work</option><option>Pub</option>", :disabled => :true - expected = %(<select id="places" disabled="disabled" name="places"><option>Home</option><option>Work</option><option>Pub</option></select>) - assert_dom_equal expected, actual - end - - def test_select_tag_id_sanitized - input_elem = root_elem(select_tag("project[1]people", "<option>david</option>")) - assert_match VALID_HTML_ID, input_elem['id'] - end - - def test_text_area_tag_size_string - actual = text_area_tag "body", "hello world", "size" => "20x40" - expected = %(<textarea cols="20" id="body" name="body" rows="40">hello world</textarea>) - assert_dom_equal expected, actual - end - - def test_text_area_tag_size_symbol - actual = text_area_tag "body", "hello world", :size => "20x40" - expected = %(<textarea cols="20" id="body" name="body" rows="40">hello world</textarea>) - assert_dom_equal expected, actual - end - - def test_text_area_tag_should_disregard_size_if_its_given_as_an_integer - actual = text_area_tag "body", "hello world", :size => 20 - expected = %(<textarea id="body" name="body">hello world</textarea>) - assert_dom_equal expected, actual - end - - def test_text_field_tag - actual = text_field_tag "title", "Hello!" - expected = %(<input id="title" name="title" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_tag_class_string - actual = text_field_tag "title", "Hello!", "class" => "admin" - expected = %(<input class="admin" id="title" name="title" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_tag_size_symbol - actual = text_field_tag "title", "Hello!", :size => 75 - expected = %(<input id="title" name="title" size="75" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_tag_size_string - actual = text_field_tag "title", "Hello!", "size" => "75" - expected = %(<input id="title" name="title" size="75" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_tag_maxlength_symbol - actual = text_field_tag "title", "Hello!", :maxlength => 75 - expected = %(<input id="title" name="title" maxlength="75" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_tag_maxlength_string - actual = text_field_tag "title", "Hello!", "maxlength" => "75" - expected = %(<input id="title" name="title" maxlength="75" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_disabled - actual = text_field_tag "title", "Hello!", :disabled => :true - expected = %(<input id="title" name="title" disabled="disabled" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_tag_with_multiple_options - actual = text_field_tag "title", "Hello!", :size => 70, :maxlength => 80 - expected = %(<input id="title" name="title" size="70" maxlength="80" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_text_field_tag_id_sanitized - input_elem = root_elem(text_field_tag("item[][title]")) - assert_match VALID_HTML_ID, input_elem['id'] - end - - def test_label_tag_without_text - actual = label_tag "title" - expected = %(<label for="title">Title</label>) - assert_dom_equal expected, actual - end - - def test_label_tag_with_symbol - actual = label_tag :title - expected = %(<label for="title">Title</label>) - assert_dom_equal expected, actual - end - - def test_label_tag_with_text - actual = label_tag "title", "My Title" - expected = %(<label for="title">My Title</label>) - assert_dom_equal expected, actual - end - - def test_label_tag_class_string - actual = label_tag "title", "My Title", "class" => "small_label" - expected = %(<label for="title" class="small_label">My Title</label>) - assert_dom_equal expected, actual - end - - def test_label_tag_id_sanitized - label_elem = root_elem(label_tag("item[title]")) - assert_match VALID_HTML_ID, label_elem['for'] - end - - def test_boolean_options - assert_dom_equal %(<input checked="checked" disabled="disabled" id="admin" name="admin" readonly="readonly" type="checkbox" value="1" />), check_box_tag("admin", 1, true, 'disabled' => true, :readonly => "yes") - assert_dom_equal %(<input checked="checked" id="admin" name="admin" type="checkbox" value="1" />), check_box_tag("admin", 1, true, :disabled => false, :readonly => nil) - assert_dom_equal %(<input type="checkbox" />), tag(:input, :type => "checkbox", :checked => false) - assert_dom_equal %(<select id="people" multiple="multiple" name="people[]"><option>david</option></select>), select_tag("people", "<option>david</option>", :multiple => true) - assert_dom_equal %(<select id="people_" multiple="multiple" name="people[]"><option>david</option></select>), select_tag("people[]", "<option>david</option>", :multiple => true) - assert_dom_equal %(<select id="people" name="people"><option>david</option></select>), select_tag("people", "<option>david</option>", :multiple => nil) - end - - def test_stringify_symbol_keys - actual = text_field_tag "title", "Hello!", :id => "admin" - expected = %(<input id="admin" name="title" type="text" value="Hello!" />) - assert_dom_equal expected, actual - end - - def test_submit_tag - assert_dom_equal( - %(<input name='commit' type='submit' value='Save' onclick="if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }else { hiddenCommit = this.cloneNode(false);hiddenCommit.setAttribute('type', 'hidden');this.form.appendChild(hiddenCommit); }this.setAttribute('originalValue', this.value);this.disabled = true;this.value='Saving...';alert('hello!');result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.value = this.getAttribute('originalValue');this.disabled = false; }return result;" />), - submit_tag("Save", :disable_with => "Saving...", :onclick => "alert('hello!')") - ) - end - - def test_submit_tag_with_no_onclick_options - assert_dom_equal( - %(<input name='commit' type='submit' value='Save' onclick="if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }else { hiddenCommit = this.cloneNode(false);hiddenCommit.setAttribute('type', 'hidden');this.form.appendChild(hiddenCommit); }this.setAttribute('originalValue', this.value);this.disabled = true;this.value='Saving...';result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.value = this.getAttribute('originalValue');this.disabled = false; }return result;" />), - submit_tag("Save", :disable_with => "Saving...") - ) - end - - def test_submit_tag_with_confirmation - assert_dom_equal( - %(<input name='commit' type='submit' value='Save' onclick="if (!confirm('Are you sure?')) return false; return true;"/>), - submit_tag("Save", :confirm => "Are you sure?") - ) - end - - def test_submit_tag_with_confirmation_and_with_disable_with - assert_dom_equal( - %(<input name="commit" type="submit" value="Save" onclick="if (!confirm('Are you sure?')) return false; if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }else { hiddenCommit = this.cloneNode(false);hiddenCommit.setAttribute('type', 'hidden');this.form.appendChild(hiddenCommit); }this.setAttribute('originalValue', this.value);this.disabled = true;this.value='Saving...';result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.value = this.getAttribute('originalValue');this.disabled = false; }return result;" />), - submit_tag("Save", :disable_with => "Saving...", :confirm => "Are you sure?") - ) - end - - def test_image_submit_tag_with_confirmation - assert_dom_equal( - %(<input type="image" src="/images/save.gif" onclick="return confirm('Are you sure?');"/>), - image_submit_tag("save.gif", :confirm => "Are you sure?") - ) - end - - def test_pass - assert_equal 1, 1 - end - - def test_field_set_tag_in_erb - __in_erb_template = '' - field_set_tag("Your details") { concat "Hello world!" } - - expected = %(<fieldset><legend>Your details</legend>Hello world!</fieldset>) - assert_dom_equal expected, output_buffer - - self.output_buffer = '' - field_set_tag { concat "Hello world!" } - - expected = %(<fieldset>Hello world!</fieldset>) - assert_dom_equal expected, output_buffer - - self.output_buffer = '' - field_set_tag('') { concat "Hello world!" } - - expected = %(<fieldset>Hello world!</fieldset>) - assert_dom_equal expected, output_buffer - - self.output_buffer = '' - field_set_tag('', :class => 'format') { concat "Hello world!" } - - expected = %(<fieldset class="format">Hello world!</fieldset>) - assert_dom_equal expected, output_buffer - end - - def protect_against_forgery? - false - end - - private - - def root_elem(rendered_content) - HTML::Document.new(rendered_content).root.children[0] - end -end diff --git a/vendor/rails/actionpack/test/template/javascript_helper_test.rb b/vendor/rails/actionpack/test/template/javascript_helper_test.rb deleted file mode 100644 index d2fb24e..0000000 --- a/vendor/rails/actionpack/test/template/javascript_helper_test.rb +++ /dev/null @@ -1,106 +0,0 @@ -require 'abstract_unit' - -class JavaScriptHelperTest < ActionView::TestCase - tests ActionView::Helpers::JavaScriptHelper - - attr_accessor :template_format, :output_buffer - - def setup - @template = self - end - - def test_escape_javascript - assert_equal '', escape_javascript(nil) - assert_equal %(This \\"thing\\" is really\\n netos\\'), escape_javascript(%(This "thing" is really\n netos')) - assert_equal %(backslash\\\\test), escape_javascript( %(backslash\\test) ) - assert_equal %(dont <\\/close> tags), escape_javascript(%(dont </close> tags)) - end - - def test_link_to_function - assert_dom_equal %(<a href="#" onclick="alert('Hello world!'); return false;">Greeting</a>), - link_to_function("Greeting", "alert('Hello world!')") - end - - def test_link_to_function_with_existing_onclick - assert_dom_equal %(<a href="#" onclick="confirm('Sanity!'); alert('Hello world!'); return false;">Greeting</a>), - link_to_function("Greeting", "alert('Hello world!')", :onclick => "confirm('Sanity!')") - end - - def test_link_to_function_with_rjs_block - html = link_to_function( "Greet me!" ) do |page| - page.replace_html 'header', "<h1>Greetings</h1>" - end - assert_dom_equal %(<a href="#" onclick="Element.update(&quot;header&quot;, &quot;\\u003Ch1\\u003EGreetings\\u003C/h1\\u003E&quot;);; return false;">Greet me!</a>), html - end - - def test_link_to_function_with_rjs_block_and_options - html = link_to_function( "Greet me!", :class => "updater" ) do |page| - page.replace_html 'header', "<h1>Greetings</h1>" - end - assert_dom_equal %(<a href="#" class="updater" onclick="Element.update(&quot;header&quot;, &quot;\\u003Ch1\\u003EGreetings\\u003C/h1\\u003E&quot;);; return false;">Greet me!</a>), html - end - - def test_link_to_function_with_href - assert_dom_equal %(<a href="http://example.com/" onclick="alert('Hello world!'); return false;">Greeting</a>), - link_to_function("Greeting", "alert('Hello world!')", :href => 'http://example.com/') - end - - def test_button_to_function - assert_dom_equal %(<input type="button" onclick="alert('Hello world!');" value="Greeting" />), - button_to_function("Greeting", "alert('Hello world!')") - end - - def test_button_to_function_with_rjs_block - html = button_to_function( "Greet me!" ) do |page| - page.replace_html 'header', "<h1>Greetings</h1>" - end - assert_dom_equal %(<input type="button" onclick="Element.update(&quot;header&quot;, &quot;\\u003Ch1\\u003EGreetings\\u003C/h1\\u003E&quot;);;" value="Greet me!" />), html - end - - def test_button_to_function_with_rjs_block_and_options - html = button_to_function( "Greet me!", :class => "greeter" ) do |page| - page.replace_html 'header', "<h1>Greetings</h1>" - end - assert_dom_equal %(<input type="button" class="greeter" onclick="Element.update(&quot;header&quot;, &quot;\\u003Ch1\\u003EGreetings\\u003C\/h1\\u003E&quot;);;" value="Greet me!" />), html - end - - def test_button_to_function_with_onclick - assert_dom_equal "<input onclick=\"alert('Goodbye World :('); alert('Hello world!');\" type=\"button\" value=\"Greeting\" />", - button_to_function("Greeting", "alert('Hello world!')", :onclick => "alert('Goodbye World :(')") - end - - def test_button_to_function_without_function - assert_dom_equal "<input onclick=\";\" type=\"button\" value=\"Greeting\" />", - button_to_function("Greeting") - end - - def test_javascript_tag - self.output_buffer = 'foo' - - assert_dom_equal "<script type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>", - javascript_tag("alert('hello')") - - assert_equal 'foo', output_buffer, 'javascript_tag without a block should not concat to output_buffer' - end - - def test_javascript_tag_with_options - assert_dom_equal "<script id=\"the_js_tag\" type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>", - javascript_tag("alert('hello')", :id => "the_js_tag") - end - - def test_javascript_tag_with_block_in_erb - __in_erb_template = '' - javascript_tag { concat "alert('hello')" } - assert_dom_equal "<script type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>", output_buffer - end - - def test_javascript_tag_with_block_and_options_in_erb - __in_erb_template = '' - javascript_tag(:id => "the_js_tag") { concat "alert('hello')" } - assert_dom_equal "<script id=\"the_js_tag\" type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>", output_buffer - end - - def test_javascript_cdata_section - assert_dom_equal "\n//<![CDATA[\nalert('hello')\n//]]>\n", javascript_cdata_section("alert('hello')") - end -end diff --git a/vendor/rails/actionpack/test/template/number_helper_i18n_test.rb b/vendor/rails/actionpack/test/template/number_helper_i18n_test.rb deleted file mode 100644 index bf5b812..0000000 --- a/vendor/rails/actionpack/test/template/number_helper_i18n_test.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'abstract_unit' - -class NumberHelperI18nTests < Test::Unit::TestCase - include ActionView::Helpers::NumberHelper - - attr_reader :request - - def setup - @number_defaults = { :precision => 3, :delimiter => ',', :separator => '.' } - @currency_defaults = { :unit => '$', :format => '%u%n', :precision => 2 } - @human_defaults = { :precision => 1 } - @human_storage_units_format_default = "%n %u" - @human_storage_units_units_byte_other = "Bytes" - @human_storage_units_units_kb_other = "KB" - @percentage_defaults = { :delimiter => '' } - @precision_defaults = { :delimiter => '' } - - I18n.backend.store_translations 'en', :number => { :format => @number_defaults, - :currency => { :format => @currency_defaults }, :human => @human_defaults } - end - - def test_number_to_currency_translates_currency_formats - I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults) - I18n.expects(:translate).with(:'number.currency.format', :locale => 'en', - :raise => true).returns(@currency_defaults) - number_to_currency(1, :locale => 'en') - end - - def test_number_with_precision_translates_number_formats - I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults) - I18n.expects(:translate).with(:'number.precision.format', :locale => 'en', - :raise => true).returns(@precision_defaults) - number_with_precision(1, :locale => 'en') - end - - def test_number_with_delimiter_translates_number_formats - I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults) - number_with_delimiter(1, :locale => 'en') - end - - def test_number_to_percentage_translates_number_formats - I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults) - I18n.expects(:translate).with(:'number.percentage.format', :locale => 'en', - :raise => true).returns(@percentage_defaults) - number_to_percentage(1, :locale => 'en') - end - - def test_number_to_human_size_translates_human_formats - I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults) - I18n.expects(:translate).with(:'number.human.format', :locale => 'en', - :raise => true).returns(@human_defaults) - I18n.expects(:translate).with(:'number.human.storage_units.format', :locale => 'en', - :raise => true).returns(@human_storage_units_format_default) - I18n.expects(:translate).with(:'number.human.storage_units.units.kb', :locale => 'en', :count => 2, - :raise => true).returns(@human_storage_units_units_kb_other) - # 2KB - number_to_human_size(2048, :locale => 'en') - - I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults) - I18n.expects(:translate).with(:'number.human.format', :locale => 'en', - :raise => true).returns(@human_defaults) - I18n.expects(:translate).with(:'number.human.storage_units.format', :locale => 'en', - :raise => true).returns(@human_storage_units_format_default) - I18n.expects(:translate).with(:'number.human.storage_units.units.byte', :locale => 'en', :count => 42, - :raise => true).returns(@human_storage_units_units_byte_other) - # 42 Bytes - number_to_human_size(42, :locale => 'en') - end -end diff --git a/vendor/rails/actionpack/test/template/number_helper_test.rb b/vendor/rails/actionpack/test/template/number_helper_test.rb deleted file mode 100644 index 29cb60f..0000000 --- a/vendor/rails/actionpack/test/template/number_helper_test.rb +++ /dev/null @@ -1,128 +0,0 @@ -require 'abstract_unit' - -class NumberHelperTest < ActionView::TestCase - tests ActionView::Helpers::NumberHelper - - def test_number_to_phone - assert_equal("555-1234", number_to_phone(5551234)) - assert_equal("800-555-1212", number_to_phone(8005551212)) - assert_equal("(800) 555-1212", number_to_phone(8005551212, {:area_code => true})) - assert_equal("800 555 1212", number_to_phone(8005551212, {:delimiter => " "})) - assert_equal("(800) 555-1212 x 123", number_to_phone(8005551212, {:area_code => true, :extension => 123})) - assert_equal("800-555-1212", number_to_phone(8005551212, :extension => " ")) - assert_equal("800-555-1212", number_to_phone("8005551212")) - assert_equal("+1-800-555-1212", number_to_phone(8005551212, :country_code => 1)) - assert_equal("+18005551212", number_to_phone(8005551212, :country_code => 1, :delimiter => '')) - assert_equal("22-555-1212", number_to_phone(225551212)) - assert_equal("+45-22-555-1212", number_to_phone(225551212, :country_code => 45)) - assert_equal("x", number_to_phone("x")) - assert_nil number_to_phone(nil) - end - - def test_number_to_currency - assert_equal("$1,234,567,890.50", number_to_currency(1234567890.50)) - assert_equal("$1,234,567,890.51", number_to_currency(1234567890.506)) - assert_equal("$1,234,567,892", number_to_currency(1234567891.50, {:precision => 0})) - assert_equal("$1,234,567,890.5", number_to_currency(1234567890.50, {:precision => 1})) - assert_equal("&pound;1234567890,50", number_to_currency(1234567890.50, {:unit => "&pound;", :separator => ",", :delimiter => ""})) - assert_equal("$1,234,567,890.50", number_to_currency("1234567890.50")) - assert_equal("1,234,567,890.50 K&#269;", number_to_currency("1234567890.50", {:unit => "K&#269;", :format => "%n %u"})) - #assert_equal("$x.", number_to_currency("x")) # fails due to API consolidation - assert_equal("$x", number_to_currency("x")) - assert_nil number_to_currency(nil) - end - - def test_number_to_percentage - assert_equal("100.000%", number_to_percentage(100)) - assert_equal("100%", number_to_percentage(100, {:precision => 0})) - assert_equal("302.06%", number_to_percentage(302.0574, {:precision => 2})) - assert_equal("100.000%", number_to_percentage("100")) - assert_equal("1000.000%", number_to_percentage("1000")) - assert_equal("x%", number_to_percentage("x")) - assert_equal("1.000,000%", number_to_percentage(1000, :delimiter => '.', :separator => ',')) - assert_nil number_to_percentage(nil) - end - - def test_number_with_delimiter - assert_equal("12,345,678", number_with_delimiter(12345678)) - assert_equal("0", number_with_delimiter(0)) - assert_equal("123", number_with_delimiter(123)) - assert_equal("123,456", number_with_delimiter(123456)) - assert_equal("123,456.78", number_with_delimiter(123456.78)) - assert_equal("123,456.789", number_with_delimiter(123456.789)) - assert_equal("123,456.78901", number_with_delimiter(123456.78901)) - assert_equal("123,456,789.78901", number_with_delimiter(123456789.78901)) - assert_equal("0.78901", number_with_delimiter(0.78901)) - assert_equal("123,456.78", number_with_delimiter("123456.78")) - assert_equal("x", number_with_delimiter("x")) - assert_nil number_with_delimiter(nil) - end - - def test_number_with_delimiter_with_options_hash - assert_equal '12 345 678', number_with_delimiter(12345678, :delimiter => ' ') - assert_equal '12,345,678-05', number_with_delimiter(12345678.05, :separator => '-') - assert_equal '12.345.678,05', number_with_delimiter(12345678.05, :separator => ',', :delimiter => '.') - assert_equal '12.345.678,05', number_with_delimiter(12345678.05, :delimiter => '.', :separator => ',') - end - - def test_number_with_precision - assert_equal("111.235", number_with_precision(111.2346)) - assert_equal("31.83", number_with_precision(31.825, :precision => 2)) - assert_equal("111.23", number_with_precision(111.2346, :precision => 2)) - assert_equal("111.00", number_with_precision(111, :precision => 2)) - assert_equal("111.235", number_with_precision("111.2346")) - assert_equal("31.83", number_with_precision("31.825", :precision => 2)) - assert_equal("112", number_with_precision(111.50, :precision => 0)) - assert_equal("1234567892", number_with_precision(1234567891.50, :precision => 0)) - - # Return non-numeric params unchanged. - assert_equal("x", number_with_precision("x")) - assert_nil number_with_precision(nil) - end - - def test_number_with_precision_with_custom_delimiter_and_separator - assert_equal '31,83', number_with_precision(31.825, :precision => 2, :separator => ',') - assert_equal '1.231,83', number_with_precision(1231.825, :precision => 2, :separator => ',', :delimiter => '.') - end - - def test_number_to_human_size - assert_equal '0 Bytes', number_to_human_size(0) - assert_equal '1 Byte', number_to_human_size(1) - assert_equal '3 Bytes', number_to_human_size(3.14159265) - assert_equal '123 Bytes', number_to_human_size(123.0) - assert_equal '123 Bytes', number_to_human_size(123) - assert_equal '1.2 KB', number_to_human_size(1234) - assert_equal '12.1 KB', number_to_human_size(12345) - assert_equal '1.2 MB', number_to_human_size(1234567) - assert_equal '1.1 GB', number_to_human_size(1234567890) - assert_equal '1.1 TB', number_to_human_size(1234567890123) - assert_equal '1025 TB', number_to_human_size(1025.terabytes) - assert_equal '444 KB', number_to_human_size(444.kilobytes) - assert_equal '1023 MB', number_to_human_size(1023.megabytes) - assert_equal '3 TB', number_to_human_size(3.terabytes) - assert_equal '1.18 MB', number_to_human_size(1234567, :precision => 2) - assert_equal '3 Bytes', number_to_human_size(3.14159265, :precision => 4) - assert_equal("123 Bytes", number_to_human_size("123")) - assert_equal '1.01 KB', number_to_human_size(1.0123.kilobytes, :precision => 2) - assert_equal '1.01 KB', number_to_human_size(1.0100.kilobytes, :precision => 4) - assert_equal '10 KB', number_to_human_size(10.000.kilobytes, :precision => 4) - assert_equal '1 Byte', number_to_human_size(1.1) - assert_equal '10 Bytes', number_to_human_size(10) - #assert_nil number_to_human_size('x') # fails due to API consolidation - assert_nil number_to_human_size(nil) - end - - def test_number_to_human_size_with_options_hash - assert_equal '1.18 MB', number_to_human_size(1234567, :precision => 2) - assert_equal '3 Bytes', number_to_human_size(3.14159265, :precision => 4) - assert_equal '1.01 KB', number_to_human_size(1.0123.kilobytes, :precision => 2) - assert_equal '1.01 KB', number_to_human_size(1.0100.kilobytes, :precision => 4) - assert_equal '10 KB', number_to_human_size(10.000.kilobytes, :precision => 4) - end - - def test_number_to_human_size_with_custom_delimiter_and_separator - assert_equal '1,01 KB', number_to_human_size(1.0123.kilobytes, :precision => 2, :separator => ',') - assert_equal '1,01 KB', number_to_human_size(1.0100.kilobytes, :precision => 4, :separator => ',') - assert_equal '1.000,1 TB', number_to_human_size(1000.1.terabytes, :delimiter => '.', :separator => ',') - end -end diff --git a/vendor/rails/actionpack/test/template/prototype_helper_test.rb b/vendor/rails/actionpack/test/template/prototype_helper_test.rb deleted file mode 100644 index d6b86a3..0000000 --- a/vendor/rails/actionpack/test/template/prototype_helper_test.rb +++ /dev/null @@ -1,639 +0,0 @@ -require 'abstract_unit' - -Bunny = Struct.new(:Bunny, :id) - -class Author - attr_reader :id - def save; @id = 1 end - def new_record?; @id.nil? end - def name - @id.nil? ? 'new author' : "author ##{@id}" - end -end - -class Article - attr_reader :id - attr_reader :author_id - def save; @id = 1; @author_id = 1 end - def new_record?; @id.nil? end - def name - @id.nil? ? 'new article' : "article ##{@id}" - end -end - -class Author::Nested < Author; end - - -class PrototypeHelperBaseTest < ActionView::TestCase - attr_accessor :template_format, :output_buffer - - def setup - @template = self - @controller = Class.new do - def url_for(options) - if options.is_a?(String) - options - else - url = "http://www.example.com/" - url << options[:action].to_s if options and options[:action] - url << "?a=#{options[:a]}" if options && options[:a] - url << "&b=#{options[:b]}" if options && options[:a] && options[:b] - url - end - end - end.new - end - - protected - def request_forgery_protection_token - nil - end - - def protect_against_forgery? - false - end - - def create_generator - block = Proc.new { |*args| yield *args if block_given? } - JavaScriptGenerator.new self, &block - end -end - -class PrototypeHelperTest < PrototypeHelperBaseTest - def setup - @record = @author = Author.new - @article = Article.new - super - end - - def test_link_to_remote - assert_dom_equal %(<a class=\"fine\" href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }}, { :class => "fine" }) - assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onComplete:function(request){alert(request.responseText)}}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", :complete => "alert(request.responseText)", :url => { :action => "whatnot" }) - assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onSuccess:function(request){alert(request.responseText)}}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", :success => "alert(request.responseText)", :url => { :action => "whatnot" }) - assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onFailure:function(request){alert(request.responseText)}}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", :failure => "alert(request.responseText)", :url => { :action => "whatnot" }) - assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot?a=10&amp;b=20', {asynchronous:true, evalScripts:true, onFailure:function(request){alert(request.responseText)}}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", :failure => "alert(request.responseText)", :url => { :action => "whatnot", :a => '10', :b => '20' }) - assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:false, evalScripts:true}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", :url => { :action => "whatnot" }, :type => :synchronous) - assert_dom_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, insertion:'bottom'}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", :url => { :action => "whatnot" }, :position => :bottom) - end - - def test_link_to_remote_html_options - assert_dom_equal %(<a class=\"fine\" href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true}); return false;\">Remote outauthor</a>), - link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }, :html => { :class => "fine" } }) - end - - def test_link_to_remote_url_quote_escaping - assert_dom_equal %(<a href="#" onclick="new Ajax.Request('http://www.example.com/whatnot\\\'s', {asynchronous:true, evalScripts:true}); return false;">Remote</a>), - link_to_remote("Remote", { :url => { :action => "whatnot's" } }) - end - - def test_button_to_remote - assert_dom_equal %(<input class=\"fine\" type=\"button\" value=\"Remote outpost\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true});\" />), - button_to_remote("Remote outpost", { :url => { :action => "whatnot" }}, { :class => "fine" }) - assert_dom_equal %(<input type=\"button\" value=\"Remote outpost\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onComplete:function(request){alert(request.reponseText)}});\" />), - button_to_remote("Remote outpost", :complete => "alert(request.reponseText)", :url => { :action => "whatnot" }) - assert_dom_equal %(<input type=\"button\" value=\"Remote outpost\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onSuccess:function(request){alert(request.reponseText)}});\" />), - button_to_remote("Remote outpost", :success => "alert(request.reponseText)", :url => { :action => "whatnot" }) - assert_dom_equal %(<input type=\"button\" value=\"Remote outpost\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onFailure:function(request){alert(request.reponseText)}});\" />), - button_to_remote("Remote outpost", :failure => "alert(request.reponseText)", :url => { :action => "whatnot" }) - assert_dom_equal %(<input type=\"button\" value=\"Remote outpost\" onclick=\"new Ajax.Request('http://www.example.com/whatnot?a=10&amp;b=20', {asynchronous:true, evalScripts:true, onFailure:function(request){alert(request.reponseText)}});\" />), - button_to_remote("Remote outpost", :failure => "alert(request.reponseText)", :url => { :action => "whatnot", :a => '10', :b => '20' }) - end - - def test_periodically_call_remote - assert_dom_equal %(<script type="text/javascript">\n//<![CDATA[\nnew PeriodicalExecuter(function() {new Ajax.Updater('schremser_bier', 'http://www.example.com/mehr_bier', {asynchronous:true, evalScripts:true})}, 10)\n//]]>\n</script>), - periodically_call_remote(:update => "schremser_bier", :url => { :action => "mehr_bier" }) - end - - def test_periodically_call_remote_with_frequency - assert_dom_equal( - "<script type=\"text/javascript\">\n//<![CDATA[\nnew PeriodicalExecuter(function() {new Ajax.Request('http://www.example.com/', {asynchronous:true, evalScripts:true})}, 2)\n//]]>\n</script>", - periodically_call_remote(:frequency => 2) - ) - end - - def test_form_remote_tag - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }) - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({success:'glass_of_beer'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">), - form_remote_tag(:update => { :success => "glass_of_beer" }, :url => { :action => :fast }) - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({failure:'glass_of_water'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">), - form_remote_tag(:update => { :failure => "glass_of_water" }, :url => { :action => :fast }) - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({success:'glass_of_beer',failure:'glass_of_water'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">), - form_remote_tag(:update => { :success => 'glass_of_beer', :failure => "glass_of_water" }, :url => { :action => :fast }) - end - - def test_form_remote_tag_with_method - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\"><div style='margin:0;padding:0'><input name='_method' type='hidden' value='put' /></div>), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, :html => { :method => :put }) - end - - def test_form_remote_tag_with_block_in_erb - __in_erb_template = '' - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }) { concat "Hello world!" } - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">Hello world!</form>), output_buffer - end - - def test_remote_form_for_with_record_identification_with_new_record - remote_form_for(@record, {:html => { :id => 'create-author' }}) {} - - expected = %(<form action='#{authors_path}' onsubmit="new Ajax.Request('#{authors_path}', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" class='new_author' id='create-author' method='post'></form>) - assert_dom_equal expected, output_buffer - end - - def test_remote_form_for_with_record_identification_without_html_options - remote_form_for(@record) {} - - expected = %(<form action='#{authors_path}' onsubmit="new Ajax.Request('#{authors_path}', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" class='new_author' method='post' id='new_author'></form>) - assert_dom_equal expected, output_buffer - end - - def test_remote_form_for_with_record_identification_with_existing_record - @record.save - remote_form_for(@record) {} - - expected = %(<form action='#{author_path(@record)}' id='edit_author_1' method='post' onsubmit="new Ajax.Request('#{author_path(@record)}', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" class='edit_author'><div style='margin:0;padding:0'><input name='_method' type='hidden' value='put' /></div></form>) - assert_dom_equal expected, output_buffer - end - - def test_remote_form_for_with_new_object_in_list - remote_form_for([@author, @article]) {} - - expected = %(<form action='#{author_articles_path(@author)}' onsubmit="new Ajax.Request('#{author_articles_path(@author)}', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" class='new_article' method='post' id='new_article'></form>) - assert_dom_equal expected, output_buffer - end - - def test_remote_form_for_with_existing_object_in_list - @author.save - @article.save - remote_form_for([@author, @article]) {} - - expected = %(<form action='#{author_article_path(@author, @article)}' id='edit_article_1' method='post' onsubmit="new Ajax.Request('#{author_article_path(@author, @article)}', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" class='edit_article'><div style='margin:0;padding:0'><input name='_method' type='hidden' value='put' /></div></form>) - assert_dom_equal expected, output_buffer - end - - def test_on_callbacks - callbacks = [:uninitialized, :loading, :loaded, :interactive, :complete, :success, :failure] - callbacks.each do |callback| - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, on#{callback.to_s.capitalize}:function(request){monkeys();}, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, callback=>"monkeys();") - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({success:'glass_of_beer'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, on#{callback.to_s.capitalize}:function(request){monkeys();}, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => { :success => "glass_of_beer" }, :url => { :action => :fast }, callback=>"monkeys();") - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({failure:'glass_of_beer'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, on#{callback.to_s.capitalize}:function(request){monkeys();}, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => { :failure => "glass_of_beer" }, :url => { :action => :fast }, callback=>"monkeys();") - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({success:'glass_of_beer',failure:'glass_of_water'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, on#{callback.to_s.capitalize}:function(request){monkeys();}, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => { :success => "glass_of_beer", :failure => "glass_of_water" }, :url => { :action => :fast }, callback=>"monkeys();") - end - - #HTTP status codes 200 up to 599 have callbacks - #these should work - 100.upto(599) do |callback| - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, on#{callback.to_s.capitalize}:function(request){monkeys();}, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, callback=>"monkeys();") - end - - #test 200 and 404 - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, on200:function(request){monkeys();}, on404:function(request){bananas();}, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, 200=>"monkeys();", 404=>"bananas();") - - #these shouldn't - 1.upto(99) do |callback| - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, callback=>"monkeys();") - end - 600.upto(999) do |callback| - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;">), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, callback=>"monkeys();") - end - - #test ultimate combo - assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, on200:function(request){monkeys();}, on404:function(request){bananas();}, onComplete:function(request){c();}, onFailure:function(request){f();}, onLoading:function(request){c1()}, onSuccess:function(request){s()}, parameters:Form.serialize(this)}); return false;\">), - form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, :loading => "c1()", :success => "s()", :failure => "f();", :complete => "c();", 200=>"monkeys();", 404=>"bananas();") - - end - - def test_submit_to_remote - assert_dom_equal %(<input name=\"More beer!\" onclick=\"new Ajax.Updater('empty_bottle', 'http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)});\" type=\"button\" value=\"1000000\" />), - submit_to_remote("More beer!", 1_000_000, :update => "empty_bottle") - end - - def test_observe_field - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/reorder_if_empty', {asynchronous:true, evalScripts:true, parameters:value})})\n//]]>\n</script>), - observe_field("glass", :frequency => 5.minutes, :url => { :action => "reorder_if_empty" }) - end - - def test_observe_field_using_with_option - expected = %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/check_value', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(value)})})\n//]]>\n</script>) - assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => 'id') - assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => "'id=' + encodeURIComponent(value)") - end - - def test_observe_field_using_json_in_with_option - expected = %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/check_value', {asynchronous:true, evalScripts:true, parameters:{'id':value}})})\n//]]>\n</script>) - assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => "{'id':value}") - end - - def test_observe_field_using_function_for_callback - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {alert('Element changed')})\n//]]>\n</script>), - observe_field("glass", :frequency => 5.minutes, :function => "alert('Element changed')") - end - - def test_observe_form - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Observer('cart', 2, function(element, value) {new Ajax.Request('http://www.example.com/cart_changed', {asynchronous:true, evalScripts:true, parameters:value})})\n//]]>\n</script>), - observe_form("cart", :frequency => 2, :url => { :action => "cart_changed" }) - end - - def test_observe_form_using_function_for_callback - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Observer('cart', 2, function(element, value) {alert('Form changed')})\n//]]>\n</script>), - observe_form("cart", :frequency => 2, :function => "alert('Form changed')") - end - - def test_observe_field_without_frequency - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.EventObserver('glass', function(element, value) {new Ajax.Request('http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:value})})\n//]]>\n</script>), - observe_field("glass") - end - - def test_update_page - old_output_buffer = output_buffer - - block = Proc.new { |page| page.replace_html('foo', 'bar') } - assert_equal create_generator(&block).to_s, update_page(&block) - - assert_equal old_output_buffer, output_buffer - end - - def test_update_page_tag - block = Proc.new { |page| page.replace_html('foo', 'bar') } - assert_equal javascript_tag(create_generator(&block).to_s), update_page_tag(&block) - end - - def test_update_page_tag_with_html_options - block = Proc.new { |page| page.replace_html('foo', 'bar') } - assert_equal javascript_tag(create_generator(&block).to_s, {:defer => 'true'}), update_page_tag({:defer => 'true'}, &block) - end - - - protected - def author_path(record) - "/authors/#{record.id}" - end - - def authors_path - "/authors" - end - - def author_articles_path(author) - "/authors/#{author.id}/articles" - end - - def author_article_path(author, article) - "/authors/#{author.id}/articles/#{article.id}" - end -end - -class JavaScriptGeneratorTest < PrototypeHelperBaseTest - def setup - super - @generator = create_generator - end - - def test_insert_html_with_string - assert_equal 'Element.insert("element", { top: "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E" });', - @generator.insert_html(:top, 'element', '<p>This is a test</p>') - assert_equal 'Element.insert("element", { bottom: "\\u003Cp\u003EThis is a test\\u003C/p\u003E" });', - @generator.insert_html(:bottom, 'element', '<p>This is a test</p>') - assert_equal 'Element.insert("element", { before: "\\u003Cp\u003EThis is a test\\u003C/p\u003E" });', - @generator.insert_html(:before, 'element', '<p>This is a test</p>') - assert_equal 'Element.insert("element", { after: "\\u003Cp\u003EThis is a test\\u003C/p\u003E" });', - @generator.insert_html(:after, 'element', '<p>This is a test</p>') - end - - def test_replace_html_with_string - assert_equal 'Element.update("element", "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E");', - @generator.replace_html('element', '<p>This is a test</p>') - end - - def test_replace_element_with_string - assert_equal 'Element.replace("element", "\\u003Cdiv id=\"element\"\\u003E\\u003Cp\\u003EThis is a test\\u003C/p\\u003E\\u003C/div\\u003E");', - @generator.replace('element', '<div id="element"><p>This is a test</p></div>') - end - - def test_remove - assert_equal 'Element.remove("foo");', - @generator.remove('foo') - assert_equal '["foo", "bar", "baz"].each(Element.remove);', - @generator.remove('foo', 'bar', 'baz') - end - - def test_show - assert_equal 'Element.show("foo");', - @generator.show('foo') - assert_equal '["foo", "bar", "baz"].each(Element.show);', - @generator.show('foo', 'bar', 'baz') - end - - def test_hide - assert_equal 'Element.hide("foo");', - @generator.hide('foo') - assert_equal '["foo", "bar", "baz"].each(Element.hide);', - @generator.hide('foo', 'bar', 'baz') - end - - def test_toggle - assert_equal 'Element.toggle("foo");', - @generator.toggle('foo') - assert_equal '["foo", "bar", "baz"].each(Element.toggle);', - @generator.toggle('foo', 'bar', 'baz') - end - - def test_alert - assert_equal 'alert("hello");', @generator.alert('hello') - end - - def test_redirect_to - assert_equal 'window.location.href = "http://www.example.com/welcome";', - @generator.redirect_to(:action => 'welcome') - assert_equal 'window.location.href = "http://www.example.com/welcome?a=b&c=d";', - @generator.redirect_to("http://www.example.com/welcome?a=b&c=d") - end - - def test_reload - assert_equal 'window.location.reload();', - @generator.reload - end - - def test_delay - @generator.delay(20) do - @generator.hide('foo') - end - - assert_equal "setTimeout(function() {\n;\nElement.hide(\"foo\");\n}, 20000);", @generator.to_s - end - - def test_to_s - @generator.insert_html(:top, 'element', '<p>This is a test</p>') - @generator.insert_html(:bottom, 'element', '<p>This is a test</p>') - @generator.remove('foo', 'bar') - @generator.replace_html('baz', '<p>This is a test</p>') - - assert_equal <<-EOS.chomp, @generator.to_s -Element.insert("element", { top: "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E" }); -Element.insert("element", { bottom: "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E" }); -["foo", "bar"].each(Element.remove); -Element.update("baz", "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E"); - EOS - end - - def test_element_access - assert_equal %($("hello");), @generator['hello'] - end - - def test_element_access_on_records - assert_equal %($("bunny_5");), @generator[Bunny.new(:id => 5)] - assert_equal %($("new_bunny");), @generator[Bunny.new] - end - - def test_element_proxy_one_deep - @generator['hello'].hide - assert_equal %($("hello").hide();), @generator.to_s - end - - def test_element_proxy_variable_access - @generator['hello']['style'] - assert_equal %($("hello").style;), @generator.to_s - end - - def test_element_proxy_variable_access_with_assignment - @generator['hello']['style']['color'] = 'red' - assert_equal %($("hello").style.color = "red";), @generator.to_s - end - - def test_element_proxy_assignment - @generator['hello'].width = 400 - assert_equal %($("hello").width = 400;), @generator.to_s - end - - def test_element_proxy_two_deep - @generator['hello'].hide("first").clean_whitespace - assert_equal %($("hello").hide("first").cleanWhitespace();), @generator.to_s - end - - def test_select_access - assert_equal %($$("div.hello");), @generator.select('div.hello') - end - - def test_select_proxy_one_deep - @generator.select('p.welcome b').first.hide - assert_equal %($$("p.welcome b").first().hide();), @generator.to_s - end - - def test_visual_effect - assert_equal %(new Effect.Puff("blah",{});), - @generator.visual_effect(:puff,'blah') - end - - def test_visual_effect_toggle - assert_equal %(Effect.toggle("blah",'appear',{});), - @generator.visual_effect(:toggle_appear,'blah') - end - - def test_sortable - assert_equal %(Sortable.create("blah", {onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize("blah")})}});), - @generator.sortable('blah', :url => { :action => "order" }) - assert_equal %(Sortable.create("blah", {onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:false, evalScripts:true, parameters:Sortable.serialize("blah")})}});), - @generator.sortable('blah', :url => { :action => "order" }, :type => :synchronous) - end - - def test_draggable - assert_equal %(new Draggable("blah", {});), - @generator.draggable('blah') - end - - def test_drop_receiving - assert_equal %(Droppables.add("blah", {onDrop:function(element){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}});), - @generator.drop_receiving('blah', :url => { :action => "order" }) - assert_equal %(Droppables.add("blah", {onDrop:function(element){new Ajax.Request('http://www.example.com/order', {asynchronous:false, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}});), - @generator.drop_receiving('blah', :url => { :action => "order" }, :type => :synchronous) - end - - def test_collection_first_and_last - @generator.select('p.welcome b').first.hide() - @generator.select('p.welcome b').last.show() - assert_equal <<-EOS.strip, @generator.to_s -$$("p.welcome b").first().hide(); -$$("p.welcome b").last().show(); - EOS - end - - def test_collection_proxy_with_each - @generator.select('p.welcome b').each do |value| - value.remove_class_name 'selected' - end - @generator.select('p.welcome b').each do |value, index| - @generator.visual_effect :highlight, value - end - assert_equal <<-EOS.strip, @generator.to_s -$$("p.welcome b").each(function(value, index) { -value.removeClassName("selected"); -}); -$$("p.welcome b").each(function(value, index) { -new Effect.Highlight(value,{}); -}); - EOS - end - - def test_collection_proxy_on_collect - @generator.select('p').collect('a') { |para| para.show } - @generator.select('p').collect { |para| para.hide } - assert_equal <<-EOS.strip, @generator.to_s -var a = $$("p").collect(function(value, index) { -return value.show(); -}); -$$("p").collect(function(value, index) { -return value.hide(); -}); - EOS - @generator = create_generator - end - - def test_collection_proxy_with_grep - @generator.select('p').grep 'a', /^a/ do |value| - @generator << '(value.className == "welcome")' - end - @generator.select('p').grep 'b', /b$/ do |value, index| - @generator.call 'alert', value - @generator << '(value.className == "welcome")' - end - - assert_equal <<-EOS.strip, @generator.to_s -var a = $$("p").grep(/^a/, function(value, index) { -return (value.className == "welcome"); -}); -var b = $$("p").grep(/b$/, function(value, index) { -alert(value); -return (value.className == "welcome"); -}); - EOS - end - - def test_collection_proxy_with_inject - @generator.select('p').inject 'a', [] do |memo, value| - @generator << '(value.className == "welcome")' - end - @generator.select('p').inject 'b', nil do |memo, value, index| - @generator.call 'alert', memo - @generator << '(value.className == "welcome")' - end - - assert_equal <<-EOS.strip, @generator.to_s -var a = $$("p").inject([], function(memo, value, index) { -return (value.className == "welcome"); -}); -var b = $$("p").inject(null, function(memo, value, index) { -alert(memo); -return (value.className == "welcome"); -}); - EOS - end - - def test_collection_proxy_with_pluck - @generator.select('p').pluck('a', 'className') - assert_equal %(var a = $$("p").pluck("className");), @generator.to_s - end - - def test_collection_proxy_with_zip - ActionView::Helpers::JavaScriptCollectionProxy.new(@generator, '[1, 2, 3]').zip('a', [4, 5, 6], [7, 8, 9]) - ActionView::Helpers::JavaScriptCollectionProxy.new(@generator, '[1, 2, 3]').zip('b', [4, 5, 6], [7, 8, 9]) do |array| - @generator.call 'array.reverse' - end - - assert_equal <<-EOS.strip, @generator.to_s -var a = [1, 2, 3].zip([4, 5, 6], [7, 8, 9]); -var b = [1, 2, 3].zip([4, 5, 6], [7, 8, 9], function(array) { -return array.reverse(); -}); - EOS - end - - def test_collection_proxy_with_find_all - @generator.select('p').find_all 'a' do |value, index| - @generator << '(value.className == "welcome")' - end - - assert_equal <<-EOS.strip, @generator.to_s -var a = $$("p").findAll(function(value, index) { -return (value.className == "welcome"); -}); - EOS - end - - def test_collection_proxy_with_in_groups_of - @generator.select('p').in_groups_of('a', 3) - @generator.select('p').in_groups_of('a', 3, 'x') - assert_equal <<-EOS.strip, @generator.to_s -var a = $$("p").inGroupsOf(3); -var a = $$("p").inGroupsOf(3, "x"); - EOS - end - - def test_collection_proxy_with_each_slice - @generator.select('p').each_slice('a', 3) - @generator.select('p').each_slice('a', 3) do |group, index| - group.reverse - end - - assert_equal <<-EOS.strip, @generator.to_s -var a = $$("p").eachSlice(3); -var a = $$("p").eachSlice(3, function(value, index) { -return value.reverse(); -}); - EOS - end - - def test_debug_rjs - ActionView::Base.debug_rjs = true - @generator['welcome'].replace_html 'Welcome' - assert_equal "try {\n$(\"welcome\").update(\"Welcome\");\n} catch (e) { alert('RJS error:\\n\\n' + e.toString()); alert('$(\\\"welcome\\\").update(\\\"Welcome\\\");'); throw e }", @generator.to_s - ensure - ActionView::Base.debug_rjs = false - end - - def test_literal - literal = @generator.literal("function() {}") - assert_equal "function() {}", literal.to_json - assert_equal "", @generator.to_s - end - - def test_class_proxy - @generator.form.focus('my_field') - assert_equal "Form.focus(\"my_field\");", @generator.to_s - end - - def test_call_with_block - @generator.call(:before) - @generator.call(:my_method) do |p| - p[:one].show - p[:two].hide - end - @generator.call(:in_between) - @generator.call(:my_method_with_arguments, true, "hello") do |p| - p[:three].visual_effect(:highlight) - end - assert_equal "before();\nmy_method(function() { $(\"one\").show();\n$(\"two\").hide(); });\nin_between();\nmy_method_with_arguments(true, \"hello\", function() { $(\"three\").visualEffect(\"highlight\"); });", @generator.to_s - end - - def test_class_proxy_call_with_block - @generator.my_object.my_method do |p| - p[:one].show - p[:two].hide - end - assert_equal "MyObject.myMethod(function() { $(\"one\").show();\n$(\"two\").hide(); });", @generator.to_s - end -end - diff --git a/vendor/rails/actionpack/test/template/record_tag_helper_test.rb b/vendor/rails/actionpack/test/template/record_tag_helper_test.rb deleted file mode 100644 index 67aa047..0000000 --- a/vendor/rails/actionpack/test/template/record_tag_helper_test.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'abstract_unit' - -class Post - def id - 45 - end - def body - "What a wonderful world!" - end -end - -class RecordTagHelperTest < ActionView::TestCase - tests ActionView::Helpers::RecordTagHelper - - def setup - @post = Post.new - end - - def test_content_tag_for - expected = %(<li class="post bar" id="post_45"></li>) - actual = content_tag_for(:li, @post, :class => 'bar') { } - assert_dom_equal expected, actual - end - - def test_content_tag_for_prefix - expected = %(<ul class="post" id="archived_post_45"></ul>) - actual = content_tag_for(:ul, @post, :archived) { } - assert_dom_equal expected, actual - end - - def test_content_tag_for_with_extra_html_tags - expected = %(<tr class="post bar" id="post_45" style='background-color: #f0f0f0'></tr>) - actual = content_tag_for(:tr, @post, {:class => "bar", :style => "background-color: #f0f0f0"}) { } - assert_dom_equal expected, actual - end - - def test_block_not_in_erb_multiple_calls - expected = %(<div class="post bar" id="post_45">#{@post.body}</div>) - actual = div_for(@post, :class => "bar") { @post.body } - assert_dom_equal expected, actual - actual = div_for(@post, :class => "bar") { @post.body } - assert_dom_equal expected, actual - end - - def test_block_works_with_content_tag_for_in_erb - __in_erb_template = '' - expected = %(<tr class="post" id="post_45">#{@post.body}</tr>) - actual = content_tag_for(:tr, @post) { concat @post.body } - assert_dom_equal expected, actual - end - - def test_div_for_in_erb - __in_erb_template = '' - expected = %(<div class="post bar" id="post_45">#{@post.body}</div>) - actual = div_for(@post, :class => "bar") { concat @post.body } - assert_dom_equal expected, actual - end -end diff --git a/vendor/rails/actionpack/test/template/render_test.rb b/vendor/rails/actionpack/test/template/render_test.rb deleted file mode 100644 index 9adf053..0000000 --- a/vendor/rails/actionpack/test/template/render_test.rb +++ /dev/null @@ -1,290 +0,0 @@ -# encoding: utf-8 -require 'abstract_unit' -require 'controller/fake_models' - -module RenderTestCases - def setup_view(paths) - @assigns = { :secret => 'in the sauce' } - @view = ActionView::Base.new(paths, @assigns) - - # Reload and register danish language for testing - I18n.reload! - I18n.backend.store_translations 'da', {} - I18n.backend.store_translations 'pt-BR', {} - - # Ensure original are still the same since we are reindexing view paths - assert_equal ORIGINAL_LOCALES, I18n.available_locales.map(&:to_s).sort - end - - def test_render_file - assert_equal "Hello world!", @view.render(:file => "test/hello_world.erb") - end - - def test_render_file_not_using_full_path - assert_equal "Hello world!", @view.render(:file => "test/hello_world.erb") - end - - def test_render_file_without_specific_extension - assert_equal "Hello world!", @view.render(:file => "test/hello_world") - end - - def test_render_file_with_localization - old_locale = I18n.locale - I18n.locale = :da - assert_equal "Hey verden", @view.render(:file => "test/hello_world") - ensure - I18n.locale = old_locale - end - - def test_render_file_with_dashed_locale - old_locale = I18n.locale - I18n.locale = :"pt-BR" - assert_equal "Ola mundo", @view.render(:file => "test/hello_world") - ensure - I18n.locale = old_locale - end - - def test_render_implicit_html_template_from_xhr_request - old_format = @view.template_format - @view.template_format = :js - assert_equal "Hello HTML!", @view.render(:file => "test/render_implicit_html_template_from_xhr_request") - ensure - @view.template_format = old_format - end - - def test_render_implicit_html_template_from_xhr_request_with_localization - old_locale = I18n.locale - old_format = @view.template_format - I18n.locale = :da - @view.template_format = :js - assert_equal "Hey HTML!\n", @view.render(:file => "test/render_implicit_html_template_from_xhr_request") - ensure - I18n.locale = old_locale - @view.template_format = old_format - end - - def test_render_file_at_top_level - assert_equal 'Elastica', @view.render(:file => '/shared') - end - - def test_render_file_with_full_path - template_path = File.join(File.dirname(__FILE__), '../fixtures/test/hello_world.erb') - assert_equal "Hello world!", @view.render(:file => template_path) - end - - def test_render_file_with_instance_variables - assert_equal "The secret is in the sauce\n", @view.render(:file => "test/render_file_with_ivar.erb") - end - - def test_render_file_with_locals - locals = { :secret => 'in the sauce' } - assert_equal "The secret is in the sauce\n", @view.render(:file => "test/render_file_with_locals.erb", :locals => locals) - end - - def test_render_file_not_using_full_path_with_dot_in_path - assert_equal "The secret is in the sauce\n", @view.render(:file => "test/dot.directory/render_file_with_ivar") - end - - def test_render_has_access_current_template - assert_equal "test/template.erb", @view.render(:file => "test/template.erb") - end - - def test_render_update - # TODO: You should not have to stub out template because template is self! - @view.instance_variable_set(:@template, @view) - assert_equal 'alert("Hello, World!");', @view.render(:update) { |page| page.alert('Hello, World!') } - end - - def test_render_partial_from_default - assert_equal "only partial", @view.render("test/partial_only") - end - - def test_render_partial - assert_equal "only partial", @view.render(:partial => "test/partial_only") - end - - def test_render_partial_with_format - assert_equal 'partial html', @view.render(:partial => 'test/partial') - end - - def test_render_partial_at_top_level - # file fixtures/_top_level_partial_only.erb (not fixtures/test) - assert_equal 'top level partial', @view.render(:partial => '/top_level_partial_only') - end - - def test_render_partial_with_format_at_top_level - # file fixtures/_top_level_partial.html.erb (not fixtures/test, with format extension) - assert_equal 'top level partial html', @view.render(:partial => '/top_level_partial') - end - - def test_render_partial_with_locals - assert_equal "5", @view.render(:partial => "test/counter", :locals => { :counter_counter => 5 }) - end - - def test_render_partial_with_locals_from_default - assert_equal "only partial", @view.render("test/partial_only", :counter_counter => 5) - end - - def test_render_partial_with_errors - @view.render(:partial => "test/raise") - flunk "Render did not raise TemplateError" - rescue ActionView::TemplateError => e - assert_match "undefined local variable or method `doesnt_exist'", e.message - assert_equal "", e.sub_template_message - assert_equal "1", e.line_number - assert_equal File.expand_path("#{FIXTURE_LOAD_PATH}/test/_raise.html.erb"), e.file_name - end - - def test_render_sub_template_with_errors - @view.render(:file => "test/sub_template_raise") - flunk "Render did not raise TemplateError" - rescue ActionView::TemplateError => e - assert_match "undefined local variable or method `doesnt_exist'", e.message - assert_equal "Trace of template inclusion: #{File.expand_path("#{FIXTURE_LOAD_PATH}/test/sub_template_raise.html.erb")}", e.sub_template_message - assert_equal "1", e.line_number - assert_equal File.expand_path("#{FIXTURE_LOAD_PATH}/test/_raise.html.erb"), e.file_name - end - - def test_render_object - assert_equal "Hello: david", @view.render(:partial => "test/customer", :object => Customer.new("david")) - end - - def test_render_partial_collection - assert_equal "Hello: davidHello: mary", @view.render(:partial => "test/customer", :collection => [ Customer.new("david"), Customer.new("mary") ]) - end - - def test_render_partial_collection_as - assert_equal "david david davidmary mary mary", - @view.render(:partial => "test/customer_with_var", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => :customer) - end - - def test_render_partial_collection_without_as - assert_equal "local_inspector,local_inspector_counter,object", - @view.render(:partial => "test/local_inspector", :collection => [ Customer.new("mary") ]) - end - - def test_render_partial_with_empty_collection_should_return_nil - assert_nil @view.render(:partial => "test/customer", :collection => []) - end - - def test_render_partial_with_nil_collection_should_return_nil - assert_nil @view.render(:partial => "test/customer", :collection => nil) - end - - def test_render_partial_with_nil_values_in_collection - assert_equal "Hello: davidHello: Anonymous", @view.render(:partial => "test/customer", :collection => [ Customer.new("david"), nil ]) - end - - def test_render_partial_with_empty_array_should_return_nil - assert_nil @view.render(:partial => []) - end - - # TODO: The reason for this test is unclear, improve documentation - def test_render_partial_and_fallback_to_layout - assert_equal "Before (Josh)\n\nAfter", @view.render(:partial => "test/layout_for_partial", :locals => { :name => "Josh" }) - end - - # TODO: The reason for this test is unclear, improve documentation - def test_render_missing_xml_partial_and_raise_missing_template - @view.template_format = :xml - assert_raise(ActionView::MissingTemplate) { @view.render(:partial => "test/layout_for_partial") } - end - - def test_render_inline - assert_equal "Hello, World!", @view.render(:inline => "Hello, World!") - end - - def test_render_inline_with_locals - assert_equal "Hello, Josh!", @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }) - end - - def test_render_fallbacks_to_erb_for_unknown_types - assert_equal "Hello, World!", @view.render(:inline => "Hello, World!", :type => :bar) - end - - CustomHandler = lambda do |template| - "@output_buffer = ''\n" + - "@output_buffer << 'source: #{template.source.inspect}'\n" - end - - def test_render_inline_with_compilable_custom_type - ActionView::Template.register_template_handler :foo, CustomHandler - assert_equal 'source: "Hello, World!"', @view.render(:inline => "Hello, World!", :type => :foo) - end - - def test_render_inline_with_locals_and_compilable_custom_type - ActionView::Template.register_template_handler :foo, CustomHandler - assert_equal 'source: "Hello, <%= name %>!"', @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }, :type => :foo) - end - - class LegacyHandler < ActionView::TemplateHandler - def render(template, local_assigns) - "source: #{template.source}; locals: #{local_assigns.inspect}" - end - end - - def test_render_legacy_handler_with_custom_type - ActionView::Template.register_template_handler :foo, LegacyHandler - assert_equal 'source: Hello, <%= name %>!; locals: {:name=>"Josh"}', @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }, :type => :foo) - end - - def test_render_ignores_templates_with_malformed_template_handlers - %w(malformed malformed.erb malformed.html.erb malformed.en.html.erb).each do |name| - assert_raise(ActionView::MissingTemplate) { @view.render(:file => "test/malformed/#{name}") } - end - end - - def test_template_with_malformed_template_handler_is_reachable_through_its_exact_filename - assert_equal "Don't render me!", @view.render(:file => 'test/malformed/malformed.html.erb~') - end - - def test_render_with_layout - assert_equal %(<title></title>\nHello world!\n), - @view.render(:file => "test/hello_world.erb", :layout => "layouts/yield") - end - - def test_render_with_nested_layout - assert_equal %(<title>title</title>\n<div id="column">column</div>\n<div id="content">content</div>\n), - @view.render(:file => "test/nested_layout.erb", :layout => "layouts/yield") - end - - if '1.9'.respond_to?(:force_encoding) - def test_render_utf8_template - result = @view.render(:file => "test/utf8.html.erb", :layouts => "layouts/yield") - assert_equal "Русский текст\n日本語のテキスト", result - assert_equal Encoding::UTF_8, result.encoding - end - end -end - -module TemplatesSetupTeardown - def setup_view_paths_for(new_cache_template_loading) - @previous_cache_template_loading, ActionView::Base.cache_template_loading = ActionView::Base.cache_template_loading, new_cache_template_loading - view_paths = new_cache_template_loading ? CACHED_VIEW_PATHS : ActionView::Base.process_view_paths(CACHED_VIEW_PATHS.map(&:to_s)) - assert_equal(new_cache_template_loading ? ActionView::Template::EagerPath : ActionView::ReloadableTemplate::ReloadablePath, view_paths.first.class) - setup_view(view_paths) - end - - def teardown - ActionView::Base.cache_template_loading = @previous_cache_template_loading - end -end - -class CachedRenderTest < Test::Unit::TestCase - include TemplatesSetupTeardown - include RenderTestCases - - def setup - setup_view_paths_for(cache_templates = true) - end -end - -class ReloadableRenderTest < Test::Unit::TestCase - include TemplatesSetupTeardown - include RenderTestCases - - def setup - setup_view_paths_for(cache_templates = false) - end -end - diff --git a/vendor/rails/actionpack/test/template/sanitize_helper_test.rb b/vendor/rails/actionpack/test/template/sanitize_helper_test.rb deleted file mode 100644 index f715071..0000000 --- a/vendor/rails/actionpack/test/template/sanitize_helper_test.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'abstract_unit' -require 'testing_sandbox' - -# The exhaustive tests are in test/controller/html/sanitizer_test.rb. -# This tests the that the helpers hook up correctly to the sanitizer classes. -class SanitizeHelperTest < ActionView::TestCase - tests ActionView::Helpers::SanitizeHelper - include TestingSandbox - - def test_strip_links - assert_equal "Dont touch me", strip_links("Dont touch me") - assert_equal "<a<a", strip_links("<a<a") - assert_equal "on my mind\nall day long", strip_links("<a href='almost'>on my mind</a>\n<A href='almost'>all day long</A>") - assert_equal "0wn3d", strip_links("<a href='http://www.rubyonrails.com/'><a href='http://www.rubyonrails.com/' onlclick='steal()'>0wn3d</a></a>") - assert_equal "Magic", strip_links("<a href='http://www.rubyonrails.com/'>Mag<a href='http://www.ruby-lang.org/'>ic") - assert_equal "FrrFox", strip_links("<href onlclick='steal()'>FrrFox</a></href>") - assert_equal "My mind\nall <b>day</b> long", strip_links("<a href='almost'>My mind</a>\n<A href='almost'>all <b>day</b> long</A>") - assert_equal "all <b>day</b> long", strip_links("<<a>a href='hello'>all <b>day</b> long<</A>/a>") - end - - def test_sanitize_form - assert_sanitized "<form action=\"/foo/bar\" method=\"post\"><input></form>", '' - end - - def test_should_sanitize_illegal_style_properties - raw = %(display:block; position:absolute; left:0; top:0; width:100%; height:100%; z-index:1; background-color:black; background-image:url(http://www.ragingplatypus.com/i/cam-full.jpg); background-x:center; background-y:center; background-repeat:repeat;) - expected = %(display: block; width: 100%; height: 100%; background-color: black; background-image: ; background-x: center; background-y: center;) - assert_equal expected, sanitize_css(raw) - end - - def test_strip_tags - assert_equal("<<<bad html", strip_tags("<<<bad html")) - assert_equal("<<", strip_tags("<<<bad html>")) - assert_equal("Dont touch me", strip_tags("Dont touch me")) - assert_equal("This is a test.", strip_tags("<p>This <u>is<u> a <a href='test.html'><strong>test</strong></a>.</p>")) - assert_equal("Weirdos", strip_tags("Wei<<a>a onclick='alert(document.cookie);'</a>/>rdos")) - assert_equal("This is a test.", strip_tags("This is a test.")) - assert_equal( - %{This is a test.\n\n\nIt no longer contains any HTML.\n}, strip_tags( - %{<title>This is <b>a <a href="" target="_blank">test</a></b>.</title>\n\n<!-- it has a comment -->\n\n<p>It no <b>longer <strong>contains <em>any <strike>HTML</strike></em>.</strong></b></p>\n})) - assert_equal "This has a here.", strip_tags("This has a <!-- comment --> here.") - [nil, '', ' '].each { |blank| assert_equal blank, strip_tags(blank) } - end - - def assert_sanitized(text, expected = nil) - assert_equal((expected || text), sanitize(text)) - end -end diff --git a/vendor/rails/actionpack/test/template/scriptaculous_helper_test.rb b/vendor/rails/actionpack/test/template/scriptaculous_helper_test.rb deleted file mode 100644 index 690a775..0000000 --- a/vendor/rails/actionpack/test/template/scriptaculous_helper_test.rb +++ /dev/null @@ -1,90 +0,0 @@ -require 'abstract_unit' - -class ScriptaculousHelperTest < ActionView::TestCase - tests ActionView::Helpers::ScriptaculousHelper - - def setup - @controller = Class.new do - def url_for(options) - url = "http://www.example.com/" - url << options[:action].to_s if options and options[:action] - url - end - end.new - end - - def test_effect - assert_equal "new Effect.Highlight(\"posts\",{});", visual_effect(:highlight, "posts") - assert_equal "new Effect.Highlight(\"posts\",{});", visual_effect("highlight", :posts) - assert_equal "new Effect.Highlight(\"posts\",{});", visual_effect(:highlight, :posts) - assert_equal "new Effect.Fade(\"fademe\",{duration:4.0});", visual_effect(:fade, "fademe", :duration => 4.0) - assert_equal "new Effect.Shake(element,{});", visual_effect(:shake) - assert_equal "new Effect.DropOut(\"dropme\",{queue:'end'});", visual_effect(:drop_out, 'dropme', :queue => :end) - assert_equal "new Effect.Highlight(\"status\",{endcolor:'#EEEEEE'});", visual_effect(:highlight, 'status', :endcolor => '#EEEEEE') - assert_equal "new Effect.Highlight(\"status\",{restorecolor:'#500000', startcolor:'#FEFEFE'});", visual_effect(:highlight, 'status', :restorecolor => '#500000', :startcolor => '#FEFEFE') - - # chop the queue params into a comma separated list - beginning, ending = 'new Effect.DropOut("dropme",{queue:{', '}});' - ve = [ - visual_effect(:drop_out, 'dropme', :queue => {:position => "end", :scope => "test", :limit => 2}), - visual_effect(:drop_out, 'dropme', :queue => {:scope => :list, :limit => 2}), - visual_effect(:drop_out, 'dropme', :queue => {:position => :end, :scope => :test, :limit => 2}) - ].collect { |v| v[beginning.length..-ending.length-1].split(',') } - - assert ve[0].include?("limit:2") - assert ve[0].include?("scope:'test'") - assert ve[0].include?("position:'end'") - - assert ve[1].include?("limit:2") - assert ve[1].include?("scope:'list'") - - assert ve[2].include?("limit:2") - assert ve[2].include?("scope:'test'") - assert ve[2].include?("position:'end'") - end - - def test_toggle_effects - assert_equal "Effect.toggle(\"posts\",'appear',{});", visual_effect(:toggle_appear, "posts") - assert_equal "Effect.toggle(\"posts\",'slide',{});", visual_effect(:toggle_slide, "posts") - assert_equal "Effect.toggle(\"posts\",'blind',{});", visual_effect(:toggle_blind, "posts") - assert_equal "Effect.toggle(\"posts\",'appear',{});", visual_effect("toggle_appear", "posts") - assert_equal "Effect.toggle(\"posts\",'slide',{});", visual_effect("toggle_slide", "posts") - assert_equal "Effect.toggle(\"posts\",'blind',{});", visual_effect("toggle_blind", "posts") - end - - - def test_sortable_element - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nSortable.create(\"mylist\", {onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(\"mylist\")})}})\n//]]>\n</script>), - sortable_element("mylist", :url => { :action => "order" }) - assert_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nSortable.create(\"mylist\", {constraint:'horizontal', onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(\"mylist\")})}, tag:'div'})\n//]]>\n</script>), - sortable_element("mylist", :tag => "div", :constraint => "horizontal", :url => { :action => "order" }) - assert_dom_equal %|<script type=\"text/javascript\">\n//<![CDATA[\nSortable.create(\"mylist\", {constraint:'horizontal', containment:['list1','list2'], onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(\"mylist\")})}})\n//]]>\n</script>|, - sortable_element("mylist", :containment => ['list1','list2'], :constraint => "horizontal", :url => { :action => "order" }) - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nSortable.create(\"mylist\", {constraint:'horizontal', containment:'list1', onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(\"mylist\")})}})\n//]]>\n</script>), - sortable_element("mylist", :containment => 'list1', :constraint => "horizontal", :url => { :action => "order" }) - end - - def test_draggable_element - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Draggable(\"product_13\", {})\n//]]>\n</script>), - draggable_element("product_13") - assert_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Draggable(\"product_13\", {revert:true})\n//]]>\n</script>), - draggable_element("product_13", :revert => true) - end - - def test_drop_receiving_element - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nDroppables.add(\"droptarget1\", {onDrop:function(element){new Ajax.Request('http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}})\n//]]>\n</script>), - drop_receiving_element("droptarget1") - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nDroppables.add(\"droptarget1\", {accept:'products', onDrop:function(element){new Ajax.Request('http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}})\n//]]>\n</script>), - drop_receiving_element("droptarget1", :accept => 'products') - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nDroppables.add(\"droptarget1\", {accept:'products', onDrop:function(element){new Ajax.Updater('infobox', 'http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}})\n//]]>\n</script>), - drop_receiving_element("droptarget1", :accept => 'products', :update => 'infobox') - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nDroppables.add(\"droptarget1\", {accept:['tshirts','mugs'], onDrop:function(element){new Ajax.Updater('infobox', 'http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}})\n//]]>\n</script>), - drop_receiving_element("droptarget1", :accept => ['tshirts','mugs'], :update => 'infobox') - assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nDroppables.add("droptarget1", {hoverclass:'dropready', onDrop:function(element){if (confirm('Are you sure?')) { new Ajax.Request('http://www.example.com/update_drop', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)}); }}})\n//]]>\n</script>), - drop_receiving_element('droptarget1', :hoverclass=>'dropready', :url=>{:action=>'update_drop'}, :confirm => 'Are you sure?') - - end - def protect_against_forgery? - false - end -end diff --git a/vendor/rails/actionpack/test/template/tag_helper_test.rb b/vendor/rails/actionpack/test/template/tag_helper_test.rb deleted file mode 100644 index ef88cae..0000000 --- a/vendor/rails/actionpack/test/template/tag_helper_test.rb +++ /dev/null @@ -1,97 +0,0 @@ -require 'abstract_unit' - -class TagHelperTest < ActionView::TestCase - tests ActionView::Helpers::TagHelper - - def test_tag - assert_equal "<br />", tag("br") - assert_equal "<br clear=\"left\" />", tag(:br, :clear => "left") - assert_equal "<br>", tag("br", nil, true) - end - - def test_tag_options - str = tag("p", "class" => "show", :class => "elsewhere") - assert_match /class="show"/, str - assert_match /class="elsewhere"/, str - end - - def test_tag_options_rejects_nil_option - assert_equal "<p />", tag("p", :ignored => nil) - end - - def test_tag_options_accepts_false_option - assert_equal "<p value=\"false\" />", tag("p", :value => false) - end - - def test_tag_options_accepts_blank_option - assert_equal "<p included=\"\" />", tag("p", :included => '') - end - - def test_tag_options_converts_boolean_option - assert_equal '<p disabled="disabled" multiple="multiple" readonly="readonly" />', - tag("p", :disabled => true, :multiple => true, :readonly => true) - end - - def test_content_tag - assert_equal "<a href=\"create\">Create</a>", content_tag("a", "Create", "href" => "create") - assert_equal content_tag("a", "Create", "href" => "create"), - content_tag("a", "Create", :href => "create") - end - - def test_content_tag_with_block_in_erb - __in_erb_template = '' - content_tag(:div) { concat "Hello world!" } - assert_dom_equal "<div>Hello world!</div>", output_buffer - end - - def test_content_tag_with_block_and_options_in_erb - __in_erb_template = '' - content_tag(:div, :class => "green") { concat "Hello world!" } - assert_dom_equal %(<div class="green">Hello world!</div>), output_buffer - end - - def test_content_tag_with_block_and_options_out_of_erb - assert_dom_equal %(<div class="green">Hello world!</div>), content_tag(:div, :class => "green") { "Hello world!" } - end - - def test_content_tag_with_block_and_options_outside_out_of_erb - assert_equal content_tag("a", "Create", :href => "create"), - content_tag("a", "href" => "create") { "Create" } - end - - def test_content_tag_nested_in_content_tag_out_of_erb - assert_equal content_tag("p", content_tag("b", "Hello")), - content_tag("p") { content_tag("b", "Hello") }, - output_buffer - end - - def test_content_tag_nested_in_content_tag_in_erb - __in_erb_template = true - content_tag("p") { concat content_tag("b", "Hello") } - assert_equal '<p><b>Hello</b></p>', output_buffer - end - - def test_cdata_section - assert_equal "<![CDATA[<hello world>]]>", cdata_section("<hello world>") - end - - def test_escape_once - assert_equal '1 &lt; 2 &amp; 3', escape_once('1 < 2 &amp; 3') - end - - def test_double_escaping_attributes - ['1&amp;2', '1 &lt; 2', '&#8220;test&#8220;'].each do |escaped| - assert_equal %(<a href="#{escaped}" />), tag('a', :href => escaped) - end - end - - def test_skip_invalid_escaped_attributes - ['&1;', '&#1dfa3;', '& #123;'].each do |escaped| - assert_equal %(<a href="#{escaped.gsub /&/, '&amp;'}" />), tag('a', :href => escaped) - end - end - - def test_disable_escaping - assert_equal '<a href="&amp;" />', tag('a', { :href => '&amp;' }, false, false) - end -end diff --git a/vendor/rails/actionpack/test/template/test_test.rb b/vendor/rails/actionpack/test/template/test_test.rb deleted file mode 100644 index ccd299f..0000000 --- a/vendor/rails/actionpack/test/template/test_test.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'abstract_unit' - -module PeopleHelper - def title(text) - content_tag(:h1, text) - end - - def homepage_path - people_path - end - - def homepage_url - people_url - end - - def link_to_person(person) - link_to person.name, person - end -end - -class PeopleHelperTest < ActionView::TestCase - def setup - ActionController::Routing::Routes.draw do |map| - map.people 'people', :controller => 'people', :action => 'index' - map.connect ':controller/:action/:id' - end - end - - def test_title - assert_equal "<h1>Ruby on Rails</h1>", title("Ruby on Rails") - end - - def test_homepage_path - assert_equal "/people", homepage_path - end - - def test_homepage_url - assert_equal "http://test.host/people", homepage_url - end - - def test_link_to_person - person = mock(:name => "David") - expects(:mocha_mock_path).with(person).returns("/people/1") - assert_equal '<a href="/people/1">David</a>', link_to_person(person) - end -end - -class CrazyHelperTest < ActionView::TestCase - tests PeopleHelper - - def test_helper_class_can_be_set_manually_not_just_inferred - assert_equal PeopleHelper, self.class.helper_class - end -end diff --git a/vendor/rails/actionpack/test/template/text_helper_test.rb b/vendor/rails/actionpack/test/template/text_helper_test.rb deleted file mode 100644 index a370f14..0000000 --- a/vendor/rails/actionpack/test/template/text_helper_test.rb +++ /dev/null @@ -1,520 +0,0 @@ -require 'abstract_unit' -require 'testing_sandbox' - -class TextHelperTest < ActionView::TestCase - tests ActionView::Helpers::TextHelper - include TestingSandbox - - def setup - # This simulates the fact that instance variables are reset every time - # a view is rendered. The cycle helper depends on this behavior. - @_cycles = nil if (defined? @_cycles) - end - - def test_concat - self.output_buffer = 'foo' - assert_equal 'foobar', concat('bar') - assert_equal 'foobar', output_buffer - end - - def test_simple_format - assert_equal "<p></p>", simple_format(nil) - - assert_equal "<p>crazy\n<br /> cross\n<br /> platform linebreaks</p>", simple_format("crazy\r\n cross\r platform linebreaks") - assert_equal "<p>A paragraph</p>\n\n<p>and another one!</p>", simple_format("A paragraph\n\nand another one!") - assert_equal "<p>A paragraph\n<br /> With a newline</p>", simple_format("A paragraph\n With a newline") - - text = "A\nB\nC\nD".freeze - assert_equal "<p>A\n<br />B\n<br />C\n<br />D</p>", simple_format(text) - - text = "A\r\n \nB\n\n\r\n\t\nC\nD".freeze - assert_equal "<p>A\n<br /> \n<br />B</p>\n\n<p>\t\n<br />C\n<br />D</p>", simple_format(text) - - assert_equal %q(<p class="test">This is a classy test</p>), simple_format("This is a classy test", :class => 'test') - assert_equal %Q(<p class="test">para 1</p>\n\n<p class="test">para 2</p>), simple_format("para 1\n\npara 2", :class => 'test') - end - - def test_truncate - assert_equal "Hello World!", truncate("Hello World!", :length => 12) - assert_equal "Hello Wor...", truncate("Hello World!!", :length => 12) - end - - def test_truncate_should_use_default_length_of_30 - str = "This is a string that will go longer then the default truncate length of 30" - assert_equal str[0...27] + "...", truncate(str) - end - - def test_truncate_with_options_hash - assert_equal "This is a string that wil[...]", truncate("This is a string that will go longer then the default truncate length of 30", :omission => "[...]") - assert_equal "Hello W...", truncate("Hello World!", :length => 10) - assert_equal "Hello[...]", truncate("Hello World!", :omission => "[...]", :length => 10) - end - - if RUBY_VERSION < '1.9.0' - def test_truncate_multibyte - with_kcode 'none' do - assert_equal "\354\225\210\353\205\225\355...", truncate("\354\225\210\353\205\225\355\225\230\354\204\270\354\232\224", :length => 10) - end - with_kcode 'u' do - assert_equal "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 ...", - truncate("\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 \354\225\204\353\235\274\353\246\254\354\230\244", :length => 10) - end - end - else - def test_truncate_multibyte - assert_equal "\354\225\210\353\205\225\355...", - truncate("\354\225\210\353\205\225\355\225\230\354\204\270\354\232\224", :length => 10) - - assert_equal "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 ...".force_encoding('UTF-8'), - truncate("\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 \354\225\204\353\235\274\353\246\254\354\230\244".force_encoding('UTF-8'), :length => 10) - end - end - - def test_highlighter - assert_equal( - "This is a <strong class=\"highlight\">beautiful</strong> morning", - highlight("This is a beautiful morning", "beautiful") - ) - - assert_equal( - "This is a <strong class=\"highlight\">beautiful</strong> morning, but also a <strong class=\"highlight\">beautiful</strong> day", - highlight("This is a beautiful morning, but also a beautiful day", "beautiful") - ) - - assert_equal( - "This is a <b>beautiful</b> morning, but also a <b>beautiful</b> day", - highlight("This is a beautiful morning, but also a beautiful day", "beautiful", '<b>\1</b>') - ) - - assert_equal( - "This text is not changed because we supplied an empty phrase", - highlight("This text is not changed because we supplied an empty phrase", nil) - ) - - assert_equal ' ', highlight(' ', 'blank text is returned verbatim') - end - - def test_highlight_with_regexp - assert_equal( - "This is a <strong class=\"highlight\">beautiful!</strong> morning", - highlight("This is a beautiful! morning", "beautiful!") - ) - - assert_equal( - "This is a <strong class=\"highlight\">beautiful! morning</strong>", - highlight("This is a beautiful! morning", "beautiful! morning") - ) - - assert_equal( - "This is a <strong class=\"highlight\">beautiful? morning</strong>", - highlight("This is a beautiful? morning", "beautiful? morning") - ) - end - - def test_highlight_with_multiple_phrases_in_one_pass - assert_equal %(<em>wow</em> <em>em</em>), highlight('wow em', %w(wow em), '<em>\1</em>') - end - - def test_highlight_with_options_hash - assert_equal( - "This is a <b>beautiful</b> morning, but also a <b>beautiful</b> day", - highlight("This is a beautiful morning, but also a beautiful day", "beautiful", :highlighter => '<b>\1</b>') - ) - end - - def test_highlight_with_html - assert_equal( - "<p>This is a <strong class=\"highlight\">beautiful</strong> morning, but also a <strong class=\"highlight\">beautiful</strong> day</p>", - highlight("<p>This is a beautiful morning, but also a beautiful day</p>", "beautiful") - ) - assert_equal( - "<p>This is a <em><strong class=\"highlight\">beautiful</strong></em> morning, but also a <strong class=\"highlight\">beautiful</strong> day</p>", - highlight("<p>This is a <em>beautiful</em> morning, but also a beautiful day</p>", "beautiful") - ) - assert_equal( - "<p>This is a <em class=\"error\"><strong class=\"highlight\">beautiful</strong></em> morning, but also a <strong class=\"highlight\">beautiful</strong> <span class=\"last\">day</span></p>", - highlight("<p>This is a <em class=\"error\">beautiful</em> morning, but also a beautiful <span class=\"last\">day</span></p>", "beautiful") - ) - assert_equal( - "<p class=\"beautiful\">This is a <strong class=\"highlight\">beautiful</strong> morning, but also a <strong class=\"highlight\">beautiful</strong> day</p>", - highlight("<p class=\"beautiful\">This is a beautiful morning, but also a beautiful day</p>", "beautiful") - ) - assert_equal( - "<p>This is a <strong class=\"highlight\">beautiful</strong> <a href=\"http://example.com/beautiful\#top?what=beautiful%20morning&when=now+then\">morning</a>, but also a <strong class=\"highlight\">beautiful</strong> day</p>", - highlight("<p>This is a beautiful <a href=\"http://example.com/beautiful\#top?what=beautiful%20morning&when=now+then\">morning</a>, but also a beautiful day</p>", "beautiful") - ) - end - - def test_excerpt - assert_equal("...is a beautiful morn...", excerpt("This is a beautiful morning", "beautiful", 5)) - assert_equal("This is a...", excerpt("This is a beautiful morning", "this", 5)) - assert_equal("...iful morning", excerpt("This is a beautiful morning", "morning", 5)) - assert_nil excerpt("This is a beautiful morning", "day") - end - - def test_excerpt_in_borderline_cases - assert_equal("", excerpt("", "", 0)) - assert_equal("a", excerpt("a", "a", 0)) - assert_equal("...b...", excerpt("abc", "b", 0)) - assert_equal("abc", excerpt("abc", "b", 1)) - assert_equal("abc...", excerpt("abcd", "b", 1)) - assert_equal("...abc", excerpt("zabc", "b", 1)) - assert_equal("...abc...", excerpt("zabcd", "b", 1)) - assert_equal("zabcd", excerpt("zabcd", "b", 2)) - - # excerpt strips the resulting string before ap-/prepending excerpt_string. - # whether this behavior is meaningful when excerpt_string is not to be - # appended is questionable. - assert_equal("zabcd", excerpt(" zabcd ", "b", 4)) - assert_equal("...abc...", excerpt("z abc d", "b", 1)) - end - - def test_excerpt_with_regex - assert_equal('...is a beautiful! mor...', excerpt('This is a beautiful! morning', 'beautiful', 5)) - assert_equal('...is a beautiful? mor...', excerpt('This is a beautiful? morning', 'beautiful', 5)) - end - - def test_excerpt_with_options_hash - assert_equal("...is a beautiful morn...", excerpt("This is a beautiful morning", "beautiful", :radius => 5)) - assert_equal("[...]is a beautiful morn[...]", excerpt("This is a beautiful morning", "beautiful", :omission => "[...]",:radius => 5)) - assert_equal( - "This is the ultimate supercalifragilisticexpialidoceous very looooooooooooooooooong looooooooooooong beautiful morning with amazing sunshine and awesome tempera[...]", - excerpt("This is the ultimate supercalifragilisticexpialidoceous very looooooooooooooooooong looooooooooooong beautiful morning with amazing sunshine and awesome temperatures. So what are you gonna do about it?", "very", - :omission => "[...]") - ) - end - - if RUBY_VERSION < '1.9' - def test_excerpt_with_utf8 - with_kcode('u') do - assert_equal("...\357\254\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', 8)) - end - with_kcode('none') do - assert_equal("...\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', 8)) - end - end - else - def test_excerpt_with_utf8 - assert_equal("...\357\254\203ciency could not be...".force_encoding('UTF-8'), excerpt("That's why e\357\254\203ciency could not be helped".force_encoding('UTF-8'), 'could', 8)) - assert_equal("...\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', 8)) - end - end - - def test_word_wrap - assert_equal("my very very\nvery long\nstring", word_wrap("my very very very long string", 15)) - end - - def test_word_wrap_with_extra_newlines - assert_equal("my very very\nvery long\nstring\n\nwith another\nline", word_wrap("my very very very long string\n\nwith another line", 15)) - end - - def test_word_wrap_with_options_hash - assert_equal("my very very\nvery long\nstring", word_wrap("my very very very long string", :line_width => 15)) - end - - def test_pluralization - assert_equal("1 count", pluralize(1, "count")) - assert_equal("2 counts", pluralize(2, "count")) - assert_equal("1 count", pluralize('1', "count")) - assert_equal("2 counts", pluralize('2', "count")) - assert_equal("1,066 counts", pluralize('1,066', "count")) - assert_equal("1.25 counts", pluralize('1.25', "count")) - assert_equal("2 counters", pluralize(2, "count", "counters")) - assert_equal("0 counters", pluralize(nil, "count", "counters")) - assert_equal("2 people", pluralize(2, "person")) - assert_equal("10 buffaloes", pluralize(10, "buffalo")) - assert_equal("1 berry", pluralize(1, "berry")) - assert_equal("12 berries", pluralize(12, "berry")) - end - - def test_auto_link_parsing - urls = %w( - http://www.rubyonrails.com - http://www.rubyonrails.com:80 - http://www.rubyonrails.com/~minam - https://www.rubyonrails.com/~minam - http://www.rubyonrails.com/~minam/url%20with%20spaces - http://www.rubyonrails.com/foo.cgi?something=here - http://www.rubyonrails.com/foo.cgi?something=here&and=here - http://www.rubyonrails.com/contact;new - http://www.rubyonrails.com/contact;new%20with%20spaces - http://www.rubyonrails.com/contact;new?with=query&string=params - http://www.rubyonrails.com/~minam/contact;new?with=query&string=params - http://en.wikipedia.org/wiki/Wikipedia:Today%27s_featured_picture_%28animation%29/January_20%2C_2007 - http://www.mail-archive.com/rails@lists.rubyonrails.org/ - http://www.amazon.com/Testing-Equal-Sign-In-Path/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1198861734&sr=8-1 - http://en.wikipedia.org/wiki/Texas_hold'em - https://www.google.com/doku.php?id=gps:resource:scs:start - http://connect.oraclecorp.com/search?search[q]=green+france&search[type]=Group - http://of.openfoundry.org/projects/492/download#4th.Release.3 - http://maps.google.co.uk/maps?f=q&q=the+london+eye&ie=UTF8&ll=51.503373,-0.11939&spn=0.007052,0.012767&z=16&iwloc=A - ) - - urls.each do |url| - assert_equal generate_result(url), auto_link(url) - end - end - - def generate_result(link_text, href = nil) - href ||= link_text - %{<a href="#{CGI::escapeHTML href}">#{CGI::escapeHTML link_text}</a>} - end - - def test_auto_linking - email_raw = 'david@loudthinking.com' - email_result = %{<a href="mailto:#{email_raw}">#{email_raw}</a>} - link_raw = 'http://www.rubyonrails.com' - link_result = generate_result(link_raw) - link_result_with_options = %{<a href="#{link_raw}" target="_blank">#{link_raw}</a>} - - assert_equal '', auto_link(nil) - assert_equal '', auto_link('') - assert_equal "#{link_result} #{link_result} #{link_result}", auto_link("#{link_raw} #{link_raw} #{link_raw}") - - assert_equal %(hello #{email_result}), auto_link("hello #{email_raw}", :email_addresses) - assert_equal %(Go to #{link_result}), auto_link("Go to #{link_raw}", :urls) - assert_equal %(Go to #{link_raw}), auto_link("Go to #{link_raw}", :email_addresses) - assert_equal %(Go to #{link_result} and say hello to #{email_result}), auto_link("Go to #{link_raw} and say hello to #{email_raw}") - assert_equal %(<p>Link #{link_result}</p>), auto_link("<p>Link #{link_raw}</p>") - assert_equal %(<p>#{link_result} Link</p>), auto_link("<p>#{link_raw} Link</p>") - assert_equal %(<p>Link #{link_result_with_options}</p>), auto_link("<p>Link #{link_raw}</p>", :all, {:target => "_blank"}) - assert_equal %(Go to #{link_result}.), auto_link(%(Go to #{link_raw}.)) - assert_equal %(<p>Go to #{link_result}, then say hello to #{email_result}.</p>), auto_link(%(<p>Go to #{link_raw}, then say hello to #{email_raw}.</p>)) - - email2_raw = '+david@loudthinking.com' - email2_result = %{<a href="mailto:#{email2_raw}">#{email2_raw}</a>} - assert_equal email2_result, auto_link(email2_raw) - - email3_raw = '+david@loudthinking.com' - email3_result = %{<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;+%64%61%76%69%64@%6c%6f%75%64%74%68%69%6e%6b%69%6e%67.%63%6f%6d">#{email3_raw}</a>} - assert_equal email3_result, auto_link(email3_raw, :all, :encode => :hex) - assert_equal email3_result, auto_link(email3_raw, :email_addresses, :encode => :hex) - - link2_raw = 'www.rubyonrails.com' - link2_result = generate_result(link2_raw, "http://#{link2_raw}") - assert_equal %(Go to #{link2_result}), auto_link("Go to #{link2_raw}", :urls) - assert_equal %(Go to #{link2_raw}), auto_link("Go to #{link2_raw}", :email_addresses) - assert_equal %(<p>Link #{link2_result}</p>), auto_link("<p>Link #{link2_raw}</p>") - assert_equal %(<p>#{link2_result} Link</p>), auto_link("<p>#{link2_raw} Link</p>") - assert_equal %(Go to #{link2_result}.), auto_link(%(Go to #{link2_raw}.)) - assert_equal %(<p>Say hello to #{email_result}, then go to #{link2_result}.</p>), auto_link(%(<p>Say hello to #{email_raw}, then go to #{link2_raw}.</p>)) - - link3_raw = 'http://manuals.ruby-on-rails.com/read/chapter.need_a-period/103#page281' - link3_result = generate_result(link3_raw) - assert_equal %(Go to #{link3_result}), auto_link("Go to #{link3_raw}", :urls) - assert_equal %(Go to #{link3_raw}), auto_link("Go to #{link3_raw}", :email_addresses) - assert_equal %(<p>Link #{link3_result}</p>), auto_link("<p>Link #{link3_raw}</p>") - assert_equal %(<p>#{link3_result} Link</p>), auto_link("<p>#{link3_raw} Link</p>") - assert_equal %(Go to #{link3_result}.), auto_link(%(Go to #{link3_raw}.)) - assert_equal %(<p>Go to #{link3_result}. Seriously, #{link3_result}? I think I'll say hello to #{email_result}. Instead.</p>), - auto_link(%(<p>Go to #{link3_raw}. Seriously, #{link3_raw}? I think I'll say hello to #{email_raw}. Instead.</p>)) - - link4_raw = 'http://foo.example.com/controller/action?parm=value&p2=v2#anchor123' - link4_result = generate_result(link4_raw) - assert_equal %(<p>Link #{link4_result}</p>), auto_link("<p>Link #{link4_raw}</p>") - assert_equal %(<p>#{link4_result} Link</p>), auto_link("<p>#{link4_raw} Link</p>") - - link5_raw = 'http://foo.example.com:3000/controller/action' - link5_result = generate_result(link5_raw) - assert_equal %(<p>#{link5_result} Link</p>), auto_link("<p>#{link5_raw} Link</p>") - - link6_raw = 'http://foo.example.com:3000/controller/action+pack' - link6_result = generate_result(link6_raw) - assert_equal %(<p>#{link6_result} Link</p>), auto_link("<p>#{link6_raw} Link</p>") - - link7_raw = 'http://foo.example.com/controller/action?parm=value&p2=v2#anchor-123' - link7_result = generate_result(link7_raw) - assert_equal %(<p>#{link7_result} Link</p>), auto_link("<p>#{link7_raw} Link</p>") - - link8_raw = 'http://foo.example.com:3000/controller/action.html' - link8_result = generate_result(link8_raw) - assert_equal %(Go to #{link8_result}), auto_link("Go to #{link8_raw}", :urls) - assert_equal %(Go to #{link8_raw}), auto_link("Go to #{link8_raw}", :email_addresses) - assert_equal %(<p>Link #{link8_result}</p>), auto_link("<p>Link #{link8_raw}</p>") - assert_equal %(<p>#{link8_result} Link</p>), auto_link("<p>#{link8_raw} Link</p>") - assert_equal %(Go to #{link8_result}.), auto_link(%(Go to #{link8_raw}.)) - assert_equal %(<p>Go to #{link8_result}. Seriously, #{link8_result}? I think I'll say hello to #{email_result}. Instead.</p>), - auto_link(%(<p>Go to #{link8_raw}. Seriously, #{link8_raw}? I think I'll say hello to #{email_raw}. Instead.</p>)) - - link9_raw = 'http://business.timesonline.co.uk/article/0,,9065-2473189,00.html' - link9_result = generate_result(link9_raw) - assert_equal %(Go to #{link9_result}), auto_link("Go to #{link9_raw}", :urls) - assert_equal %(Go to #{link9_raw}), auto_link("Go to #{link9_raw}", :email_addresses) - assert_equal %(<p>Link #{link9_result}</p>), auto_link("<p>Link #{link9_raw}</p>") - assert_equal %(<p>#{link9_result} Link</p>), auto_link("<p>#{link9_raw} Link</p>") - assert_equal %(Go to #{link9_result}.), auto_link(%(Go to #{link9_raw}.)) - assert_equal %(<p>Go to #{link9_result}. Seriously, #{link9_result}? I think I'll say hello to #{email_result}. Instead.</p>), - auto_link(%(<p>Go to #{link9_raw}. Seriously, #{link9_raw}? I think I'll say hello to #{email_raw}. Instead.</p>)) - - link10_raw = 'http://www.mail-archive.com/ruby-talk@ruby-lang.org/' - link10_result = generate_result(link10_raw) - assert_equal %(<p>#{link10_result} Link</p>), auto_link("<p>#{link10_raw} Link</p>") - end - - def test_auto_link_already_linked - linked1 = generate_result('Ruby On Rails', 'http://www.rubyonrails.com') - linked2 = generate_result('www.rubyonrails.com', 'http://www.rubyonrails.com') - assert_equal linked1, auto_link(linked1) - assert_equal linked2, auto_link(linked2) - end - - def test_auto_link_with_brackets - link1_raw = 'http://en.wikipedia.org/wiki/Sprite_(computer_graphics)' - link1_result = generate_result(link1_raw) - assert_equal link1_result, auto_link(link1_raw) - assert_equal "(link: #{link1_result})", auto_link("(link: #{link1_raw})") - - link2_raw = 'http://en.wikipedia.org/wiki/Sprite_[computer_graphics]' - link2_result = generate_result(link2_raw) - assert_equal link2_result, auto_link(link2_raw) - assert_equal "[link: #{link2_result}]", auto_link("[link: #{link2_raw}]") - - link3_raw = 'http://en.wikipedia.org/wiki/Sprite_{computer_graphics}' - link3_result = generate_result(link3_raw) - assert_equal link3_result, auto_link(link3_raw) - assert_equal "{link: #{link3_result}}", auto_link("{link: #{link3_raw}}") - end - - def test_auto_link_in_tags - link_raw = 'http://www.rubyonrails.org/images/rails.png' - link_result = %Q(<img src="#{link_raw}" />) - assert_equal link_result, auto_link(link_result) - end - - def test_auto_link_at_eol - url1 = "http://api.rubyonrails.com/Foo.html" - url2 = "http://www.ruby-doc.org/core/Bar.html" - - assert_equal %(<p><a href="#{url1}">#{url1}</a><br /><a href="#{url2}">#{url2}</a><br /></p>), auto_link("<p>#{url1}<br />#{url2}<br /></p>") - end - - def test_auto_link_with_block - url = "http://api.rubyonrails.com/Foo.html" - email = "fantabulous@shiznadel.ic" - - assert_equal %(<p><a href="#{url}">#{url[0...7]}...</a><br /><a href="mailto:#{email}">#{email[0...7]}...</a><br /></p>), auto_link("<p>#{url}<br />#{email}<br /></p>") { |url| truncate(url, :length => 10) } - end - - def test_auto_link_with_options_hash - assert_dom_equal 'Welcome to my new blog at <a href="http://www.myblog.com/" class="menu" target="_blank">http://www.myblog.com/</a>. Please e-mail me at <a href="mailto:me@email.com" class="menu" target="_blank">me@email.com</a>.', - auto_link("Welcome to my new blog at http://www.myblog.com/. Please e-mail me at me@email.com.", - :link => :all, :html => { :class => "menu", :target => "_blank" }) - end - - def test_cycle_class - value = Cycle.new("one", 2, "3") - assert_equal("one", value.to_s) - assert_equal("2", value.to_s) - assert_equal("3", value.to_s) - assert_equal("one", value.to_s) - value.reset - assert_equal("one", value.to_s) - assert_equal("2", value.to_s) - assert_equal("3", value.to_s) - end - - def test_cycle_class_with_no_arguments - assert_raise(ArgumentError) { value = Cycle.new() } - end - - def test_cycle - assert_equal("one", cycle("one", 2, "3")) - assert_equal("2", cycle("one", 2, "3")) - assert_equal("3", cycle("one", 2, "3")) - assert_equal("one", cycle("one", 2, "3")) - assert_equal("2", cycle("one", 2, "3")) - assert_equal("3", cycle("one", 2, "3")) - end - - def test_cycle_with_no_arguments - assert_raise(ArgumentError) { value = cycle() } - end - - def test_cycle_resets_with_new_values - assert_equal("even", cycle("even", "odd")) - assert_equal("odd", cycle("even", "odd")) - assert_equal("even", cycle("even", "odd")) - assert_equal("1", cycle(1, 2, 3)) - assert_equal("2", cycle(1, 2, 3)) - assert_equal("3", cycle(1, 2, 3)) - assert_equal("1", cycle(1, 2, 3)) - end - - def test_named_cycles - assert_equal("1", cycle(1, 2, 3, :name => "numbers")) - assert_equal("red", cycle("red", "blue", :name => "colors")) - assert_equal("2", cycle(1, 2, 3, :name => "numbers")) - assert_equal("blue", cycle("red", "blue", :name => "colors")) - assert_equal("3", cycle(1, 2, 3, :name => "numbers")) - assert_equal("red", cycle("red", "blue", :name => "colors")) - end - - def test_current_cycle_with_default_name - cycle("even","odd") - assert_equal "even", current_cycle - cycle("even","odd") - assert_equal "odd", current_cycle - cycle("even","odd") - assert_equal "even", current_cycle - end - - def test_current_cycle_with_named_cycles - cycle("red", "blue", :name => "colors") - assert_equal "red", current_cycle("colors") - cycle("red", "blue", :name => "colors") - assert_equal "blue", current_cycle("colors") - cycle("red", "blue", :name => "colors") - assert_equal "red", current_cycle("colors") - end - - def test_current_cycle_safe_call - assert_nothing_raised { current_cycle } - assert_nothing_raised { current_cycle("colors") } - end - - def test_current_cycle_with_more_than_two_names - cycle(1,2,3) - assert_equal "1", current_cycle - cycle(1,2,3) - assert_equal "2", current_cycle - cycle(1,2,3) - assert_equal "3", current_cycle - cycle(1,2,3) - assert_equal "1", current_cycle - end - - def test_default_named_cycle - assert_equal("1", cycle(1, 2, 3)) - assert_equal("2", cycle(1, 2, 3, :name => "default")) - assert_equal("3", cycle(1, 2, 3)) - end - - def test_reset_cycle - assert_equal("1", cycle(1, 2, 3)) - assert_equal("2", cycle(1, 2, 3)) - reset_cycle - assert_equal("1", cycle(1, 2, 3)) - end - - def test_reset_unknown_cycle - reset_cycle("colors") - end - - def test_recet_named_cycle - assert_equal("1", cycle(1, 2, 3, :name => "numbers")) - assert_equal("red", cycle("red", "blue", :name => "colors")) - reset_cycle("numbers") - assert_equal("1", cycle(1, 2, 3, :name => "numbers")) - assert_equal("blue", cycle("red", "blue", :name => "colors")) - assert_equal("2", cycle(1, 2, 3, :name => "numbers")) - assert_equal("red", cycle("red", "blue", :name => "colors")) - end - - def test_cycle_no_instance_variable_clashes - @cycles = %w{Specialized Fuji Giant} - assert_equal("red", cycle("red", "blue")) - assert_equal("blue", cycle("red", "blue")) - assert_equal("red", cycle("red", "blue")) - assert_equal(%w{Specialized Fuji Giant}, @cycles) - end -end diff --git a/vendor/rails/actionpack/test/template/translation_helper_test.rb b/vendor/rails/actionpack/test/template/translation_helper_test.rb deleted file mode 100644 index a20f3c3..0000000 --- a/vendor/rails/actionpack/test/template/translation_helper_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'abstract_unit' - -class TranslationHelperTest < Test::Unit::TestCase - include ActionView::Helpers::TagHelper - include ActionView::Helpers::TranslationHelper - - attr_reader :request - def setup - end - - def test_delegates_to_i18n_setting_the_raise_option - I18n.expects(:translate).with(:foo, :locale => 'en', :raise => true) - translate :foo, :locale => 'en' - end - - def test_returns_missing_translation_message_wrapped_into_span - expected = '<span class="translation_missing">en, foo</span>' - assert_equal expected, translate(:foo) - end - - def test_delegates_localize_to_i18n - @time = Time.utc(2008, 7, 8, 12, 18, 38) - I18n.expects(:localize).with(@time) - localize @time - end - - def test_scoping_by_partial - expects(:template).returns(stub(:path_without_format_and_extension => "people/index")) - I18n.expects(:translate).with("people.index.foo", :locale => 'en', :raise => true) - translate ".foo", :locale => 'en' - end -end diff --git a/vendor/rails/actionpack/test/template/url_helper_test.rb b/vendor/rails/actionpack/test/template/url_helper_test.rb deleted file mode 100644 index 5900709..0000000 --- a/vendor/rails/actionpack/test/template/url_helper_test.rb +++ /dev/null @@ -1,614 +0,0 @@ -# encoding: utf-8 -require 'abstract_unit' - -RequestMock = Struct.new("Request", :request_uri, :protocol, :host_with_port, :env) - -class UrlHelperTest < ActionView::TestCase - tests ActionView::Helpers::UrlHelper - - def setup - @controller = Class.new do - attr_accessor :url, :request - def url_for(options) - url - end - end - @controller = @controller.new - @controller.url = "http://www.example.com" - end - - def test_url_for_escapes_urls - @controller.url = "http://www.example.com?a=b&c=d" - assert_equal "http://www.example.com?a=b&amp;c=d", url_for(:a => 'b', :c => 'd') - assert_equal "http://www.example.com?a=b&amp;c=d", url_for(:a => 'b', :c => 'd', :escape => true) - assert_equal "http://www.example.com?a=b&c=d", url_for(:a => 'b', :c => 'd', :escape => false) - end - - def test_url_for_escapes_url_once - @controller.url = "http://www.example.com?a=b&amp;c=d" - assert_equal "http://www.example.com?a=b&amp;c=d", url_for("http://www.example.com?a=b&amp;c=d") - end - - def test_url_for_with_back - @controller.request = RequestMock.new("http://www.example.com/weblog/show", nil, nil, {'HTTP_REFERER' => 'http://www.example.com/referer'}) - assert_equal 'http://www.example.com/referer', url_for(:back) - end - - def test_url_for_with_back_and_no_referer - @controller.request = RequestMock.new("http://www.example.com/weblog/show", nil, nil, {}) - assert_equal 'javascript:history.back()', url_for(:back) - end - - # todo: missing test cases - def test_button_to_with_straight_url - assert_dom_equal "<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", button_to("Hello", "http://www.example.com") - end - - def test_button_to_with_query - assert_dom_equal "<form method=\"post\" action=\"http://www.example.com/q1=v1&amp;q2=v2\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", button_to("Hello", "http://www.example.com/q1=v1&q2=v2") - end - - def test_button_to_with_escaped_query - assert_dom_equal "<form method=\"post\" action=\"http://www.example.com/q1=v1&amp;q2=v2\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", button_to("Hello", "http://www.example.com/q1=v1&amp;q2=v2") - end - - def test_button_to_with_query_and_no_name - assert_dom_equal "<form method=\"post\" action=\"http://www.example.com?q1=v1&amp;q2=v2\" class=\"button-to\"><div><input type=\"submit\" value=\"http://www.example.com?q1=v1&amp;q2=v2\" /></div></form>", button_to(nil, "http://www.example.com?q1=v1&q2=v2") - end - - def test_button_to_with_javascript_confirm - assert_dom_equal( - "<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input onclick=\"return confirm('Are you sure?');\" type=\"submit\" value=\"Hello\" /></div></form>", - button_to("Hello", "http://www.example.com", :confirm => "Are you sure?") - ) - end - - def test_button_to_enabled_disabled - assert_dom_equal( - "<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", - button_to("Hello", "http://www.example.com", :disabled => false) - ) - assert_dom_equal( - "<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input disabled=\"disabled\" type=\"submit\" value=\"Hello\" /></div></form>", - button_to("Hello", "http://www.example.com", :disabled => true) - ) - end - - def test_button_to_with_method_delete - assert_dom_equal( - "<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input type=\"hidden\" name=\"_method\" value=\"delete\" /><input type=\"submit\" value=\"Hello\" /></div></form>", - button_to("Hello", "http://www.example.com", :method => :delete) - ) - end - - def test_button_to_with_method_get - assert_dom_equal( - "<form method=\"get\" action=\"http://www.example.com\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", - button_to("Hello", "http://www.example.com", :method => :get) - ) - end - - def test_link_tag_with_straight_url - assert_dom_equal "<a href=\"http://www.example.com\">Hello</a>", link_to("Hello", "http://www.example.com") - end - - def test_link_tag_without_host_option - ActionController::Base.class_eval { attr_accessor :url } - url = {:controller => 'weblog', :action => 'show'} - @controller = ActionController::Base.new - @controller.request = ActionController::TestRequest.new - @controller.url = ActionController::UrlRewriter.new(@controller.request, url) - assert_dom_equal(%q{<a href="/weblog/show">Test Link</a>}, link_to('Test Link', url)) - end - - def test_link_tag_with_host_option - ActionController::Base.class_eval { attr_accessor :url } - url = {:controller => 'weblog', :action => 'show', :host => 'www.example.com'} - @controller = ActionController::Base.new - @controller.request = ActionController::TestRequest.new - @controller.url = ActionController::UrlRewriter.new(@controller.request, url) - assert_dom_equal(%q{<a href="http://www.example.com/weblog/show">Test Link</a>}, link_to('Test Link', url)) - end - - def test_link_tag_with_query - assert_dom_equal "<a href=\"http://www.example.com?q1=v1&amp;q2=v2\">Hello</a>", link_to("Hello", "http://www.example.com?q1=v1&amp;q2=v2") - end - - def test_link_tag_with_query_and_no_name - assert_dom_equal "<a href=\"http://www.example.com?q1=v1&amp;q2=v2\">http://www.example.com?q1=v1&amp;q2=v2</a>", link_to(nil, "http://www.example.com?q1=v1&amp;q2=v2") - end - - def test_link_tag_with_back - @controller.request = RequestMock.new("http://www.example.com/weblog/show", nil, nil, {'HTTP_REFERER' => 'http://www.example.com/referer'}) - assert_dom_equal "<a href=\"http://www.example.com/referer\">go back</a>", link_to('go back', :back) - end - - def test_link_tag_with_back_and_no_referer - @controller.request = RequestMock.new("http://www.example.com/weblog/show", nil, nil, {}) - assert_dom_equal "<a href=\"javascript:history.back()\">go back</a>", link_to('go back', :back) - end - - def test_link_tag_with_back - @controller.request = RequestMock.new("http://www.example.com/weblog/show", nil, nil, {'HTTP_REFERER' => 'http://www.example.com/referer'}) - assert_dom_equal "<a href=\"http://www.example.com/referer\">go back</a>", link_to('go back', :back) - end - - def test_link_tag_with_back_and_no_referer - @controller.request = RequestMock.new("http://www.example.com/weblog/show", nil, nil, {}) - assert_dom_equal "<a href=\"javascript:history.back()\">go back</a>", link_to('go back', :back) - end - - def test_link_tag_with_img - assert_dom_equal "<a href=\"http://www.example.com\"><img src='/favicon.jpg' /></a>", link_to("<img src='/favicon.jpg' />", "http://www.example.com") - end - - def test_link_with_nil_html_options - assert_dom_equal "<a href=\"http://www.example.com\">Hello</a>", link_to("Hello", {:action => 'myaction'}, nil) - end - - def test_link_tag_with_custom_onclick - assert_dom_equal "<a href=\"http://www.example.com\" onclick=\"alert('yay!')\">Hello</a>", link_to("Hello", "http://www.example.com", :onclick => "alert('yay!')") - end - - def test_link_tag_with_javascript_confirm - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"return confirm('Are you sure?');\">Hello</a>", - link_to("Hello", "http://www.example.com", :confirm => "Are you sure?") - ) - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"return confirm('You can\\'t possibly be sure, can you?');\">Hello</a>", - link_to("Hello", "http://www.example.com", :confirm => "You can't possibly be sure, can you?") - ) - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"return confirm('You can\\'t possibly be sure,\\n can you?');\">Hello</a>", - link_to("Hello", "http://www.example.com", :confirm => "You can't possibly be sure,\n can you?") - ) - end - - def test_link_tag_with_popup - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"window.open(this.href);return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", :popup => true) - ) - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"window.open(this.href);return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", :popup => 'true') - ) - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"window.open(this.href,'window_name','width=300,height=300');return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", :popup => ['window_name', 'width=300,height=300']) - ) - end - - def test_link_tag_with_popup_and_javascript_confirm - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"if (confirm('Fo\\' sho\\'?')) { window.open(this.href); };return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", { :popup => true, :confirm => "Fo' sho'?" }) - ) - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"if (confirm('Are you serious?')) { window.open(this.href,'window_name','width=300,height=300'); };return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", { :popup => ['window_name', 'width=300,height=300'], :confirm => "Are you serious?" }) - ) - end - - def test_link_tag_using_post_javascript - assert_dom_equal( - "<a href='http://www.example.com' onclick=\"var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;f.submit();return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", :method => :post) - ) - end - - def test_link_tag_using_delete_javascript - assert_dom_equal( - "<a href='http://www.example.com' onclick=\"var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);f.submit();return false;\">Destroy</a>", - link_to("Destroy", "http://www.example.com", :method => :delete) - ) - end - - def test_link_tag_using_delete_javascript_and_href - assert_dom_equal( - "<a href='\#' onclick=\"var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = 'http://www.example.com';var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);f.submit();return false;\">Destroy</a>", - link_to("Destroy", "http://www.example.com", :method => :delete, :href => '#') - ) - end - - def test_link_tag_using_post_javascript_and_confirm - assert_dom_equal( - "<a href=\"http://www.example.com\" onclick=\"if (confirm('Are you serious?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;f.submit(); };return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", :method => :post, :confirm => "Are you serious?") - ) - end - - def test_link_tag_using_post_javascript_and_popup - assert_raise(ActionView::ActionViewError) { link_to("Hello", "http://www.example.com", :popup => true, :method => :post, :confirm => "Are you serious?") } - end - - def test_link_tag_using_block_in_erb - __in_erb_template = '' - - link_to("http://example.com") { concat("Example site") } - - assert_equal '<a href="http://example.com">Example site</a>', output_buffer - end - - def test_link_to_unless - assert_equal "Showing", link_to_unless(true, "Showing", :action => "show", :controller => "weblog") - assert_dom_equal "<a href=\"http://www.example.com\">Listing</a>", link_to_unless(false, "Listing", :action => "list", :controller => "weblog") - assert_equal "Showing", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) - assert_equal "<strong>Showing</strong>", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) { |name, options, html_options| - "<strong>#{name}</strong>" - } - assert_equal "<strong>Showing</strong>", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) { |name| - "<strong>#{name}</strong>" - } - assert_equal "test", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) { - "test" - } - end - - def test_link_to_if - assert_equal "Showing", link_to_if(false, "Showing", :action => "show", :controller => "weblog") - assert_dom_equal "<a href=\"http://www.example.com\">Listing</a>", link_to_if(true, "Listing", :action => "list", :controller => "weblog") - assert_equal "Showing", link_to_if(false, "Showing", :action => "show", :controller => "weblog", :id => 1) - end - - def test_current_page_with_simple_url - @controller.request = RequestMock.new("http://www.example.com/weblog/show") - @controller.url = "http://www.example.com/weblog/show" - assert current_page?({ :action => "show", :controller => "weblog" }) - assert current_page?("http://www.example.com/weblog/show") - end - - def test_current_page_ignoring_params - @controller.request = RequestMock.new("http://www.example.com/weblog/show?order=desc&page=1") - @controller.url = "http://www.example.com/weblog/show?order=desc&page=1" - assert current_page?({ :action => "show", :controller => "weblog" }) - assert current_page?("http://www.example.com/weblog/show") - end - - def test_current_page_with_params_that_match - @controller.request = RequestMock.new("http://www.example.com/weblog/show?order=desc&page=1") - @controller.url = "http://www.example.com/weblog/show?order=desc&page=1" - assert current_page?({ :action => "show", :controller => "weblog", :order => "desc", :page => "1" }) - assert current_page?("http://www.example.com/weblog/show?order=desc&amp;page=1") - end - - def test_link_unless_current - @controller.request = RequestMock.new("http://www.example.com/weblog/show") - @controller.url = "http://www.example.com/weblog/show" - assert_equal "Showing", link_to_unless_current("Showing", { :action => "show", :controller => "weblog" }) - assert_equal "Showing", link_to_unless_current("Showing", "http://www.example.com/weblog/show") - - @controller.request = RequestMock.new("http://www.example.com/weblog/show?order=desc") - @controller.url = "http://www.example.com/weblog/show" - assert_equal "Showing", link_to_unless_current("Showing", { :action => "show", :controller => "weblog" }) - assert_equal "Showing", link_to_unless_current("Showing", "http://www.example.com/weblog/show") - - @controller.request = RequestMock.new("http://www.example.com/weblog/show?order=desc&page=1") - @controller.url = "http://www.example.com/weblog/show?order=desc&page=1" - assert_equal "Showing", link_to_unless_current("Showing", { :action => "show", :controller => "weblog", :order=>'desc', :page=>'1' }) - assert_equal "Showing", link_to_unless_current("Showing", "http://www.example.com/weblog/show?order=desc&amp;page=1") - assert_equal "Showing", link_to_unless_current("Showing", "http://www.example.com/weblog/show?order=desc&page=1") - - @controller.request = RequestMock.new("http://www.example.com/weblog/show?order=desc") - @controller.url = "http://www.example.com/weblog/show?order=asc" - assert_equal "<a href=\"http://www.example.com/weblog/show?order=asc\">Showing</a>", link_to_unless_current("Showing", { :action => "show", :controller => "weblog" }) - assert_equal "<a href=\"http://www.example.com/weblog/show?order=asc\">Showing</a>", link_to_unless_current("Showing", "http://www.example.com/weblog/show?order=asc") - - @controller.request = RequestMock.new("http://www.example.com/weblog/show?order=desc&page=1") - @controller.url = "http://www.example.com/weblog/show?order=desc&page=2" - assert_equal "<a href=\"http://www.example.com/weblog/show?order=desc&amp;page=2\">Showing</a>", link_to_unless_current("Showing", { :action => "show", :controller => "weblog" }) - assert_equal "<a href=\"http://www.example.com/weblog/show?order=desc&amp;page=2\">Showing</a>", link_to_unless_current("Showing", "http://www.example.com/weblog/show?order=desc&page=2") - - - @controller.request = RequestMock.new("http://www.example.com/weblog/show") - @controller.url = "http://www.example.com/weblog/list" - assert_equal "<a href=\"http://www.example.com/weblog/list\">Listing</a>", - link_to_unless_current("Listing", :action => "list", :controller => "weblog") - assert_equal "<a href=\"http://www.example.com/weblog/list\">Listing</a>", - link_to_unless_current("Listing", "http://www.example.com/weblog/list") - end - - def test_mail_to - assert_dom_equal "<a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>", mail_to("david@loudthinking.com") - assert_dom_equal "<a href=\"mailto:david@loudthinking.com\">David Heinemeier Hansson</a>", mail_to("david@loudthinking.com", "David Heinemeier Hansson") - assert_dom_equal( - "<a class=\"admin\" href=\"mailto:david@loudthinking.com\">David Heinemeier Hansson</a>", - mail_to("david@loudthinking.com", "David Heinemeier Hansson", "class" => "admin") - ) - assert_equal mail_to("david@loudthinking.com", "David Heinemeier Hansson", "class" => "admin"), - mail_to("david@loudthinking.com", "David Heinemeier Hansson", :class => "admin") - end - - def test_mail_to_with_javascript - assert_dom_equal "<script type=\"text/javascript\">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", "My email", :encode => "javascript") - end - - def test_mail_to_with_javascript_unicode - assert_dom_equal "<script type=\"text/javascript\">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%75%6e%69%63%6f%64%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%22%3e%c3%ba%6e%69%63%6f%64%65%3c%2f%61%3e%27%29%3b'))</script>", mail_to("unicode@example.com", "únicode", :encode => "javascript") - end - - def test_mail_with_options - assert_dom_equal( - %(<a href="mailto:me@example.com?cc=ccaddress%40example.com&amp;bcc=bccaddress%40example.com&amp;body=This%20is%20the%20body%20of%20the%20message.&amp;subject=This%20is%20an%20example%20email">My email</a>), - mail_to("me@example.com", "My email", :cc => "ccaddress@example.com", :bcc => "bccaddress@example.com", :subject => "This is an example email", :body => "This is the body of the message.") - ) - end - - def test_mail_to_with_img - assert_dom_equal %(<a href="mailto:feedback@example.com"><img src="/feedback.png" /></a>), mail_to('feedback@example.com', '<img src="/feedback.png" />') - end - - def test_mail_to_with_hex - assert_dom_equal "<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">My email</a>", mail_to("me@domain.com", "My email", :encode => "hex") - assert_dom_equal "<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">&#109;&#101;&#64;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;</a>", mail_to("me@domain.com", nil, :encode => "hex") - end - - def test_mail_to_with_replace_options - assert_dom_equal "<a href=\"mailto:wolfgang@stufenlos.net\">wolfgang(at)stufenlos(dot)net</a>", mail_to("wolfgang@stufenlos.net", nil, :replace_at => "(at)", :replace_dot => "(dot)") - assert_dom_equal "<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">&#109;&#101;&#40;&#97;&#116;&#41;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;</a>", mail_to("me@domain.com", nil, :encode => "hex", :replace_at => "(at)") - assert_dom_equal "<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">My email</a>", mail_to("me@domain.com", "My email", :encode => "hex", :replace_at => "(at)") - assert_dom_equal "<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">&#109;&#101;&#40;&#97;&#116;&#41;&#100;&#111;&#109;&#97;&#105;&#110;&#40;&#100;&#111;&#116;&#41;&#99;&#111;&#109;</a>", mail_to("me@domain.com", nil, :encode => "hex", :replace_at => "(at)", :replace_dot => "(dot)") - assert_dom_equal "<script type=\"text/javascript\">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", "My email", :encode => "javascript", :replace_at => "(at)", :replace_dot => "(dot)") - assert_dom_equal "<script type=\"text/javascript\">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%6d%65%28%61%74%29%64%6f%6d%61%69%6e%28%64%6f%74%29%63%6f%6d%3c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", nil, :encode => "javascript", :replace_at => "(at)", :replace_dot => "(dot)") - end - - def protect_against_forgery? - false - end -end - -class UrlHelperWithControllerTest < ActionView::TestCase - class UrlHelperController < ActionController::Base - def self.controller_path; 'url_helper_with_controller' end - - def show_url_for - render :inline => "<%= url_for :controller => 'url_helper_with_controller', :action => 'show_url_for' %>" - end - - def show_named_route - render :inline => "<%= show_named_route_#{params[:kind]} %>" - end - - def nil_url_for - render :inline => '<%= url_for(nil) %>' - end - - def rescue_action(e) raise e end - end - - tests ActionView::Helpers::UrlHelper - - def setup - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @controller = UrlHelperController.new - end - - def test_url_for_shows_only_path - get :show_url_for - assert_equal '/url_helper_with_controller/show_url_for', @response.body - end - - def test_named_route_url_shows_host_and_path - with_url_helper_routing do - get :show_named_route, :kind => 'url' - assert_equal 'http://test.host/url_helper_with_controller/show_named_route', @response.body - end - end - - def test_named_route_path_shows_only_path - with_url_helper_routing do - get :show_named_route, :kind => 'path' - assert_equal '/url_helper_with_controller/show_named_route', @response.body - end - end - - def test_url_for_nil_returns_current_path - get :nil_url_for - assert_equal '/url_helper_with_controller/nil_url_for', @response.body - end - - def test_named_route_should_show_host_and_path_using_controller_default_url_options - class << @controller - def default_url_options(options = nil) - {:host => 'testtwo.host'} - end - end - - with_url_helper_routing do - get :show_named_route, :kind => 'url' - assert_equal 'http://testtwo.host/url_helper_with_controller/show_named_route', @response.body - end - end - - protected - def with_url_helper_routing - with_routing do |set| - set.draw do |map| - map.show_named_route 'url_helper_with_controller/show_named_route', :controller => 'url_helper_with_controller', :action => 'show_named_route' - end - yield - end - end -end - -class LinkToUnlessCurrentWithControllerTest < ActionView::TestCase - class TasksController < ActionController::Base - def self.controller_path; 'tasks' end - - def index - render_default - end - - def show - render_default - end - - def rescue_action(e) raise e end - - protected - def render_default - render :inline => - "<%= link_to_unless_current(\"tasks\", tasks_path) %>\n" + - "<%= link_to_unless_current(\"tasks\", tasks_url) %>" - end - end - - tests ActionView::Helpers::UrlHelper - - def setup - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @controller = TasksController.new - end - - def test_link_to_unless_current_to_current - with_restful_routing do - get :index - assert_equal "tasks\ntasks", @response.body - end - end - - def test_link_to_unless_current_shows_link - with_restful_routing do - get :show, :id => 1 - assert_equal "<a href=\"/tasks\">tasks</a>\n" + - "<a href=\"#{@request.protocol}#{@request.host_with_port}/tasks\">tasks</a>", - @response.body - end - end - - protected - def with_restful_routing - with_routing do |set| - set.draw do |map| - map.resources :tasks - end - yield - end - end -end - -class Workshop - attr_accessor :id, :new_record - - def initialize(id, new_record) - @id, @new_record = id, new_record - end - - def new_record? - @new_record - end - - def to_s - id.to_s - end -end - -class Session - attr_accessor :id, :workshop_id, :new_record - - def initialize(id, new_record) - @id, @new_record = id, new_record - end - - def new_record? - @new_record - end - - def to_s - id.to_s - end -end - -class PolymorphicControllerTest < ActionView::TestCase - class WorkshopsController < ActionController::Base - def self.controller_path; 'workshops' end - - def index - @workshop = Workshop.new(1, true) - render :inline => "<%= url_for(@workshop) %>\n<%= link_to('Workshop', @workshop) %>" - end - - def show - @workshop = Workshop.new(params[:id], false) - render :inline => "<%= url_for(@workshop) %>\n<%= link_to('Workshop', @workshop) %>" - end - - def rescue_action(e) raise e end - end - - class SessionsController < ActionController::Base - def self.controller_path; 'sessions' end - - def index - @workshop = Workshop.new(params[:workshop_id], false) - @session = Session.new(1, true) - render :inline => "<%= url_for([@workshop, @session]) %>\n<%= link_to('Session', [@workshop, @session]) %>" - end - - def show - @workshop = Workshop.new(params[:workshop_id], false) - @session = Session.new(params[:id], false) - render :inline => "<%= url_for([@workshop, @session]) %>\n<%= link_to('Session', [@workshop, @session]) %>" - end - - def rescue_action(e) raise e end - end - - tests ActionView::Helpers::UrlHelper - - def setup - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def test_new_resource - @controller = WorkshopsController.new - - with_restful_routing do - get :index - assert_equal "/workshops\n<a href=\"/workshops\">Workshop</a>", @response.body - end - end - - def test_existing_resource - @controller = WorkshopsController.new - - with_restful_routing do - get :show, :id => 1 - assert_equal "/workshops/1\n<a href=\"/workshops/1\">Workshop</a>", @response.body - end - end - - def test_new_nested_resource - @controller = SessionsController.new - - with_restful_routing do - get :index, :workshop_id => 1 - assert_equal "/workshops/1/sessions\n<a href=\"/workshops/1/sessions\">Session</a>", @response.body - end - end - - def test_existing_nested_resource - @controller = SessionsController.new - - with_restful_routing do - get :show, :workshop_id => 1, :id => 1 - assert_equal "/workshops/1/sessions/1\n<a href=\"/workshops/1/sessions/1\">Session</a>", @response.body - end - end - - protected - def with_restful_routing - with_routing do |set| - set.draw do |map| - map.resources :workshops do |w| - w.resources :sessions - end - end - yield - end - end -end diff --git a/vendor/rails/actionpack/test/testing_sandbox.rb b/vendor/rails/actionpack/test/testing_sandbox.rb deleted file mode 100644 index c365851..0000000 --- a/vendor/rails/actionpack/test/testing_sandbox.rb +++ /dev/null @@ -1,15 +0,0 @@ -module TestingSandbox - # Temporarily replaces KCODE for the block - def with_kcode(kcode) - if RUBY_VERSION < '1.9' - old_kcode, $KCODE = $KCODE, kcode - begin - yield - ensure - $KCODE = old_kcode - end - else - yield - end - end -end diff --git a/vendor/rails/actionpack/test/view/test_case_test.rb b/vendor/rails/actionpack/test/view/test_case_test.rb deleted file mode 100644 index 9124198..0000000 --- a/vendor/rails/actionpack/test/view/test_case_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'abstract_unit' - -class TestCaseTest < ActionView::TestCase - def test_should_have_current_url - controller = TestController.new - assert_nothing_raised(NoMethodError){ controller.url_for({:controller => "foo", :action => "index"}) } - end -end diff --git a/vendor/rails/activerecord/CHANGELOG b/vendor/rails/activerecord/CHANGELOG deleted file mode 100644 index c73ac46..0000000 --- a/vendor/rails/activerecord/CHANGELOG +++ /dev/null @@ -1,5832 +0,0 @@ -*2.3.2 [Final] (March 15, 2009)* - -* Added ActiveRecord::Base.find_each and ActiveRecord::Base.find_in_batches for batch processing [DHH/Jamis Buck] - -* Added that ActiveRecord::Base.exists? can be called with no arguments #1817 [Scott Taylor] - -* Add Support for updating deeply nested models from a single form. #1202 [Eloy Duran] - - class Book < ActiveRecord::Base - has_one :author - has_many :pages - - accepts_nested_attributes_for :author, :pages - end - -* Make after_save callbacks fire only if the record was successfully saved. #1735 [Michael Lovitt] - - Previously the callbacks would fire if a before_save cancelled saving. - -* Support nested transactions using database savepoints. #383 [Jonathan Viney, Hongli Lai] - -* Added dynamic scopes ala dynamic finders #1648 [Yaroslav Markin] - -* Fixed that ActiveRecord::Base#new_record? should return false (not nil) for existing records #1219 [Yaroslav Markin] - -* I18n the word separator for error messages. Introduces the activerecord.errors.format.separator translation key. #1294 [Akira Matsuda] - -* Add :having as a key to find and the relevant associations. [Emilio Tagua] - -* Added default_scope to Base #1381 [Paweł Kondzior]. Example: - - class Person < ActiveRecord::Base - default_scope :order => 'last_name, first_name' - end - - class Company < ActiveRecord::Base - has_many :people - end - - Person.all # => Person.find(:all, :order => 'last_name, first_name') - Company.find(1).people # => Person.find(:all, :order => 'last_name, first_name', :conditions => { :company_id => 1 }) - - -*2.2.1 [RC2] (November 14th, 2008)* - -* Ensure indices don't flip order in schema.rb #1266 [Jordi Bunster] - -* Fixed that serialized strings should never be type-casted (i.e. turning "Yes" to a boolean) #857 [Andreas Korth] - - -*2.2.0 [RC1] (October 24th, 2008)* - -* Skip collection ids reader optimization if using :finder_sql [Jeremy Kemper] - -* Add Model#delete instance method, similar to Model.delete class method. #1086 [Hongli Lai (Phusion)] - -* MySQL: cope with quirky default values for not-null text columns. #1043 [Frederick Cheung] - -* Multiparameter attributes skip time zone conversion for time-only columns [#1030 state:resolved] [Geoff Buesing] - -* Base.skip_time_zone_conversion_for_attributes uses class_inheritable_accessor, so that subclasses don't overwrite Base [#346 state:resolved] [Emilio Tagua] - -* Added find_last_by dynamic finder #762 [Emilio Tagua] - -* Internal API: configurable association options and build_association method for reflections so plugins may extend and override. #985 [Hongli Lai (Phusion)] - -* Changed benchmarks to be reported in milliseconds [David Heinemeier Hansson] - -* Connection pooling. #936 [Nick Sieger] - -* Merge scoped :joins together instead of overwriting them. May expose scoping bugs in your code! #501 [Andrew White] - -* before_save, before_validation and before_destroy callbacks that return false will now ROLLBACK the transaction. Previously this would have been committed before the processing was aborted. #891 [Xavier Noria] - -* Transactional migrations for databases which support them. #834 [divoxx, Adam Wiggins, Tarmo Tänav] - -* Set config.active_record.timestamped_migrations = false to have migrations with numeric prefix instead of UTC timestamp. #446. [Andrew Stone, Nik Wakelin] - -* change_column_default preserves the not-null constraint. #617 [Tarmo Tänav] - -* Fixed that create database statements would always include "DEFAULT NULL" (Nick Sieger) [#334] - -* Add :tokenizer option to validates_length_of to specify how to split up the attribute string. #507. [David Lowenfels] Example : - - # Ensure essay contains at least 100 words. - validates_length_of :essay, :minimum => 100, :too_short => "Your essay must be at least %d words."), :tokenizer => lambda {|str| str.scan(/\w+/) } - -* Allow conditions on multiple tables to be specified using hash. [Pratik Naik]. Example: - - User.all :joins => :items, :conditions => { :age => 10, :items => { :color => 'black' } } - Item.first :conditions => { :items => { :color => 'red' } } - -* Always treat integer :limit as byte length. #420 [Tarmo Tänav] - -* Partial updates don't update lock_version if nothing changed. #426 [Daniel Morrison] - -* Fix column collision with named_scope and :joins. #46 [Duncan Beevers, Mark Catley] - -* db:migrate:down and :up update schema_migrations. #369 [Michael Raidel, RaceCondition] - -* PostgreSQL: support :conditions => [':foo::integer', { :foo => 1 }] without treating the ::integer typecast as a bind variable. [Tarmo Tänav] - -* MySQL: rename_column preserves column defaults. #466 [Diego Algorta] - -* Add :from option to calculations. #397 [Ben Munat] - -* Add :validate option to associations to enable/disable the automatic validation of associated models. Resolves #301. [Jan De Poorter] - -* PostgreSQL: use 'INSERT ... RETURNING id' for 8.2 and later. [Jeremy Kemper] - -* Added SQL escaping for :limit and :offset in MySQL [Jonathan Wiess] - - -*2.1.0 (May 31st, 2008)* - -* Add ActiveRecord::Base.sti_name that checks ActiveRecord::Base#store_full_sti_class? and returns either the full or demodulized name. [Rick Olson] - -* Add first/last methods to associations/named_scope. Resolved #226. [Ryan Bates] - -* Added SQL escaping for :limit and :offset #288 [Aaron Bedra, Steven Bristol, Jonathan Wiess] - -* Added first/last methods to associations/named_scope. Resolved #226. [Ryan Bates] - -* Ensure hm:t preloading honours reflection options. Resolves #137. [Frederick Cheung] - -* Added protection against duplicate migration names (Aslak Hellesøy) [#112] - -* Base#instantiate_time_object: eliminate check for Time.zone, since we can assume this is set if time_zone_aware_attributes is set to true [Geoff Buesing] - -* Time zone aware attribute methods use Time.zone.parse instead of #to_time for String arguments, so that offset information in String is respected. Resolves #105. [Scott Fleckenstein, Geoff Buesing] - -* Added change_table for migrations (Jeff Dean) [#71]. Example: - - change_table :videos do |t| - t.timestamps # adds created_at, updated_at - t.belongs_to :goat # adds goat_id integer - t.string :name, :email, :limit => 20 # adds name and email both with a 20 char limit - t.remove :name, :email # removes the name and email columns - end - -* Fixed has_many :through .create with no parameters caused a "can't dup NilClass" error (Steven Soroka) [#85] - -* Added block-setting of attributes for Base.create like Base.new already has (Adam Meehan) [#39] - -* Fixed that pessimistic locking you reference the quoted table name (Josh Susser) [#67] - -* Fixed that change_column should be able to use :null => true on a field that formerly had false [Nate Wiger] [#26] - -* Added that the MySQL adapter should map integer to either smallint, int, or bigint depending on the :limit just like PostgreSQL [David Heinemeier Hansson] - -* Change validates_uniqueness_of :case_sensitive option default back to true (from [9160]). Love your database columns, don't LOWER them. [Rick Olson] - -* Add support for interleaving migrations by storing which migrations have run in the new schema_migrations table. Closes #11493 [Jordi Bunster] - -* ActiveRecord::Base#sum defaults to 0 if no rows are returned. Closes #11550 [Kamal Fariz Mahyuddin] - -* Ensure that respond_to? considers dynamic finder methods. Closes #11538. [James Mead] - -* Ensure that save on parent object fails for invalid has_one association. Closes #10518. [Pratik Naik] - -* Remove duplicate code from associations. [Pratik Naik] - -* Refactor HasManyThroughAssociation to inherit from HasManyAssociation. Association callbacks and <association>_ids= now work with hm:t. #11516 [Ruy Asan] - -* Ensure HABTM#create and HABTM#build do not load entire association. [Pratik Naik] - -* Improve documentation. [Xavier Noria, Jack Danger Canty, leethal] - -* Tweak ActiveRecord::Base#to_json to include a root value in the returned hash: {"post": {"title": ...}} [Rick Olson] - - Post.find(1).to_json # => {"title": ...} - config.active_record.include_root_in_json = true - Post.find(1).to_json # => {"post": {"title": ...}} - -* Add efficient #include? to AssociationCollection (for has_many/has_many :through/habtm). [stopdropandrew] - -* PostgreSQL: create_ and drop_database support. #9042 [ez, pedz, Nick Sieger] - -* Ensure that validates_uniqueness_of works with with_scope. Closes #9235. [Nik Wakelin, cavalle] - -* Partial updates include only unsaved attributes. Off by default; set YourClass.partial_updates = true to enable. [Jeremy Kemper] - -* Removing unnecessary uses_tzinfo helper from tests, given that TZInfo is now bundled [Geoff Buesing] - -* Fixed that validates_size_of :within works in associations #11295, #10019 [cavalle] - -* Track changes to unsaved attributes. [Jeremy Kemper] - -* Switched to UTC-timebased version numbers for migrations and the schema. This will as good as eliminate the problem of multiple migrations getting the same version assigned in different branches. Also added rake db:migrate:up/down to apply individual migrations that may need to be run when you merge branches #11458 [John Barnette] - -* Fixed that has_many :through would ignore the hash conditions #11447 [Emilio Tagua] - -* Fix issue where the :uniq option of a has_many :through association is ignored when find(:all) is called. Closes #9407 [cavalle] - -* Fix duplicate table alias error when including an association with a has_many :through association on the same join table. Closes #7310 [cavalle] - -* More efficient association preloading code that compacts a through_records array in a central location. Closes #11427 [Jack Danger Canty] - -* Improve documentation. [Ryan Bigg, Jan De Poorter, Cheah Chu Yeow, Xavier Shay, Jack Danger Canty, Emilio Tagua, Xavier Noria, Sunny Ripert] - -* Fixed that ActiveRecord#Base.find_or_create/initialize would not honor attr_protected/accessible when used with a hash #11422 [Emilio Tagua] - -* Added ActiveRecord#Base.all/first/last as aliases for find(:all/:first/:last) #11413 [nkallen, Chris O'Sullivan] - -* Merge the has_finder gem, renamed as 'named_scope'. #11404 [nkallen] - - class Article < ActiveRecord::Base - named_scope :published, :conditions => {:published => true} - named_scope :popular, :conditions => ... - end - - Article.published.paginate(:page => 1) - Article.published.popular.count - Article.popular.find(:first) - Article.popular.find(:all, :conditions => {...}) - - See http://pivots.pivotallabs.com/users/nick/blog/articles/284-hasfinder-it-s-now-easier-than-ever-to-create-complex-re-usable-sql-queries - -* Add has_one :through support. #4756 [Chris O'Sullivan] - -* Migrations: create_table supports primary_key_prefix_type. #10314 [student, Chris O'Sullivan] - -* Added logging for dependency load errors with fixtures #11056 [stuthulhu] - -* Time zone aware attributes use Time#in_time_zone [Geoff Buesing] - -* Fixed that scoped joins would not always be respected #6821 [Theory/Jack Danger Canty] - -* Ensure that ActiveRecord::Calculations disambiguates field names with the table name. #11027 [cavalle] - -* Added add/remove_timestamps to the schema statements for adding the created_at/updated_at columns on existing tables #11129 [jramirez] - -* Added ActiveRecord::Base.find(:last) #11338 [Emilio Tagua] - -* test_native_types expects DateTime.local_offset instead of DateTime.now.offset; fixes test breakage due to dst transition [Geoff Buesing] - -* Add :readonly option to HasManyThrough associations. #11156 [Emilio Tagua] - -* Improve performance on :include/:conditions/:limit queries by selectively joining in the pre-query. #9560 [dasil003] - -* Perf fix: Avoid the use of named block arguments. Closes #11109 [adymo] - -* PostgreSQL: support server versions 7.4 through 8.0 and the ruby-pg driver. #11127 [jdavis] - -* Ensure association preloading doesn't break when an association returns nil. ##11145 [GMFlash] - -* Make dynamic finders respect the :include on HasManyThrough associations. #10998. [cpytel] - -* Base#instantiate_time_object only uses Time.zone when Base.time_zone_aware_attributes is true; leverages Time#time_with_datetime_fallback for readability [Geoff Buesing] - -* Refactor ConnectionAdapters::Column.new_time: leverage DateTime failover behavior of Time#time_with_datetime_fallback [Geoff Buesing] - -* Improve associations performance by using symbol callbacks instead of string callbacks. #11108 [adymo] - -* Optimise the BigDecimal conversion code. #11110 [adymo] - -* Introduce the :readonly option to all associations. Records from the association cannot be saved. #11084 [Emilio Tagua] - -* Multiparameter attributes for time columns fail over to DateTime when out of range of Time [Geoff Buesing] - -* Base#instantiate_time_object uses Time.zone.local() [Geoff Buesing] - -* Add timezone-aware attribute readers and writers. #10982 [Geoff Buesing] - -* Instantiating time objects in multiparameter attributes uses Time.zone if available. #10982 [Rick Olson] - -* Add note about how ActiveRecord::Observer classes are initialized in a Rails app. #10980 [Xavier Noria] - -* MySQL: omit text/blob defaults from the schema instead of using an empty string. #10963 [mdeiters] - -* belongs_to supports :dependent => :destroy and :delete. #10592 [Jonathan Viney] - -* Introduce preload query strategy for eager :includes. #9640 [Frederick Cheung, Aliaksey Kandratsenka, codafoo] - -* Support aggregations in finder conditions. #10572 [Ryan Kinderman] - -* Organize and clean up the Active Record test suite. #10742 [John Barnette] - -* Ensure that modifying has_and_belongs_to_many actions clear the query cache. Closes #10840 [john.andrews] - -* Fix issue where Table#references doesn't pass a :null option to a *_type attribute for polymorphic associations. Closes #10753 [railsjitsu] - -* Fixtures: removed support for the ancient pre-YAML file format. #10736 [John Barnette] - -* More thoroughly quote table names. #10698 [dimdenis, lotswholetime, Jeremy Kemper] - -* update_all ignores scoped :order and :limit, so post.comments.update_all doesn't try to include the comment order in the update statement. #10686 [Brendan Ribera] - -* Added ActiveRecord::Base.cache_key to make it easier to cache Active Records in combination with the new ActiveSupport::Cache::* libraries [David Heinemeier Hansson] - -* Make sure CSV fixtures are compatible with ruby 1.9's new csv implementation. [JEG2] - -* Added by parameter to increment, decrement, and their bang varieties so you can do player1.increment!(:points, 5) #10542 [Sam] - -* Optimize ActiveRecord::Base#exists? to use #select_all instead of #find. Closes #10605 [jamesh, Frederick Cheung, protocool] - -* Don't unnecessarily load has_many associations in after_update callbacks. Closes #6822 [stopdropandrew, canadaduane] - -* Eager belongs_to :include infers the foreign key from the association name rather than the class name. #10517 [Jonathan Viney] - -* SQLite: fix rename_ and remove_column for columns with unique indexes. #10576 [Brandon Keepers] - -* Ruby 1.9 compatibility. #10655 [Jeremy Kemper, Dirkjan Bussink] - - -*2.0.2* (December 16th, 2007) - -* Ensure optimistic locking handles nil #lock_version values properly. Closes #10510 [Rick Olson] - -* Make the Fixtures Test::Unit enhancements more supporting for double-loaded test cases. Closes #10379 [brynary] - -* Fix that validates_acceptance_of still works for non-existent tables (useful for bootstrapping new databases). Closes #10474 [Josh Susser] - -* Ensure that the :uniq option for has_many :through associations retains the order. #10463 [remvee] - -* Base.exists? doesn't rescue exceptions to avoid hiding SQL errors. #10458 [Michael Klishin] - -* Documentation: Active Record exceptions, destroy_all and delete_all. #10444, #10447 [Michael Klishin] - - -*2.0.1* (December 7th, 2007) - -* Removed query cache rescue as it could cause code to be run twice (closes #10408) [David Heinemeier Hansson] - - -*2.0.0* (December 6th, 2007) - -* Anchor DateTimeTest to fixed DateTime instead of a variable value based on Time.now#advance#to_datetime, so that this test passes on 64-bit platforms running Ruby 1.8.6+ [Geoff Buesing] - -* Fixed that the Query Cache should just be ignored if the database is misconfigured (so that the "About your applications environment" works even before the database has been created) [David Heinemeier Hansson] - -* Fixed that the truncation of strings longer than 50 chars should use inspect -so newlines etc are escaped #10385 [Norbert Crombach] - -* Fixed that habtm associations should be able to set :select as part of their definition and have that honored [David Heinemeier Hansson] - -* Document how the :include option can be used in Calculations::calculate. Closes #7446 [adamwiggins, ultimoamore] - -* Fix typo in documentation for polymorphic associations w/STI. Closes #7461 [johnjosephbachir] - -* Reveal that the type option in migrations can be any supported column type for your database but also include caveat about agnosticism. Closes #7531 [adamwiggins, mikong] - -* More complete documentation for find_by_sql. Closes #7912 [fearoffish] - -* Added ActiveRecord::Base#becomes to turn a record into one of another class (mostly relevant for STIs) [David Heinemeier Hansson]. Example: - - render :partial => @client.becomes(Company) # renders companies/company instead of clients/client - -* Fixed that to_xml should not automatically pass :procs to associations included with :include #10162 [Cheah Chu Yeow] - -* Fix documentation typo introduced in [8250]. Closes #10339 [Henrik N] - -* Foxy fixtures: support single-table inheritance. #10234 [tom] - -* Foxy fixtures: allow mixed usage to make migration easier and more attractive. #10004 [lotswholetime] - -* Make the record_timestamps class-inheritable so it can be set per model. #10004 [tmacedo] - -* Allow validates_acceptance_of to use a real attribute instead of only virtual (so you can record that the acceptance occured) #7457 [ambethia] - -* DateTimes use Ruby's default calendar reform setting. #10201 [Geoff Buesing] - -* Dynamic finders on association collections respect association :order and :limit. #10211, #10227 [Patrick Joyce, Rick Olson, Jack Danger Canty] - -* Add 'foxy' support for fixtures of polymorphic associations. #10183 [John Barnette, David Lowenfels] - -* validates_inclusion_of and validates_exclusion_of allow formatted :message strings. #8132 [devrieda, Mike Naberezny] - -* attr_readonly behaves well with optimistic locking. #10188 [Nick Bugajski] - -* Base#to_xml supports the nil="true" attribute like Hash#to_xml. #8268 [Jonathan del Strother] - -* Change plings to the more conventional quotes in the documentation. Closes #10104 [Jack Danger Canty] - -* Fix HasManyThrough Association so it uses :conditions on the HasMany Association. Closes #9729 [Jack Danger Canty] - -* Ensure that column names are quoted. Closes #10134 [wesley.moxam] - -* Smattering of grammatical fixes to documentation. Closes #10083 [Bob Silva] - -* Enhance explanation with more examples for attr_accessible macro. Closes #8095 [fearoffish, Marcel Molina Jr.] - -* Update association/method mapping table to refected latest collection methods for has_many :through. Closes #8772 [Pratik Naik] - -* Explain semantics of having several different AR instances in a transaction block. Closes #9036 [jacobat, Marcel Molina Jr.] - -* Update Schema documentation to use updated sexy migration notation. Closes #10086 [Sam Granieri] - -* Make fixtures work with the new test subclasses. [Tarmo Tänav, Michael Koziarski] - -* Introduce finder :joins with associations. Same :include syntax but with inner rather than outer joins. #10012 [RubyRedRick] - # Find users with an avatar - User.find(:all, :joins => :avatar) - - # Find posts with a high-rated comment. - Post.find(:all, :joins => :comments, :conditions => 'comments.rating > 3') - -* Associations: speedup duplicate record check. #10011 [Pratik Naik] - -* Make sure that << works on has_many associations on unsaved records. Closes #9989 [Josh Susser] - -* Allow association redefinition in subclasses. #9346 [wildchild] - -* Fix has_many :through delete with custom foreign keys. #6466 [naffis] - -* Foxy fixtures, from rathole (http://svn.geeksomnia.com/rathole/trunk/README) - - stable, autogenerated IDs - - specify associations (belongs_to, has_one, has_many) by label, not ID - - specify HABTM associations as inline lists - - autofill timestamp columns - - support YAML defaults - - fixture label interpolation - Enabled for fixtures that correspond to a model class and don't specify a primary key value. #9981 [John Barnette] - -* Add docs explaining how to protect all attributes using attr_accessible with no arguments. Closes #9631 [boone, rmm5t] - -* Update add_index documentation to use new options api. Closes #9787 [Kamal Fariz Mahyuddin] - -* Allow find on a has_many association defined with :finder_sql to accept id arguments as strings like regular find does. Closes #9916 [krishna] - -* Use VALID_FIND_OPTIONS when resolving :find scoping rather than hard coding the list of valid find options. Closes #9443 [sur] - -* Limited eager loading no longer ignores scoped :order. Closes #9561 [Jack Danger Canty, Josh Peek] - -* Assigning an instance of a foreign class to a composed_of aggregate calls an optional conversion block. Refactor and simplify composed_of implementation. #6322 [brandon, Chris Cruft] - -* Assigning nil to a composed_of aggregate also sets its immediate value to nil. #9843 [Chris Cruft] - -* Ensure that mysql quotes table names with database names correctly. Closes #9911 [crayz] - - "foo.bar" => "`foo`.`bar`" - -* Complete the assimilation of Sexy Migrations from ErrFree [Chris Wanstrath, PJ Hyett] - http://errtheblog.com/post/2381 - -* Qualified column names work in hash conditions, like :conditions => { 'comments.created_at' => ... }. #9733 [Jack Danger Canty] - -* Fix regression where the association would not construct new finder SQL on save causing bogus queries for "WHERE owner_id = NULL" even after owner was saved. #8713 [Bryan Helmkamp] - -* Refactor association create and build so before & after callbacks behave consistently. #8854 [Pratik Naik, mortent] - -* Quote table names. Defaults to column quoting. #4593 [Justin Lynn, gwcoffey, eadz, Dmitry V. Sabanin, Jeremy Kemper] - -* Alias association #build to #new so it behaves predictably. #8787 [Pratik Naik] - -* Add notes to documentation regarding attr_readonly behavior with counter caches and polymorphic associations. Closes #9835 [saimonmoore, Rick Olson] - -* Observers can observe model names as symbols properly now. Closes #9869 [queso] - -* find_and_(initialize|create)_by methods can now properly initialize protected attributes [Tobias Lütke] - -* belongs_to infers the foreign key from the association name instead of from the class name. [Jeremy Kemper] - -* PostgreSQL: support multiline default values. #7533 [Carl Lerche, aguynamedryan, Rein Henrichs, Tarmo Tänav] - -* MySQL: fix change_column on not-null columns that don't accept dfeault values of ''. #6663 [Jonathan Viney, Tarmo Tänav] - -* validates_uniqueness_of behaves well with abstract superclasses and -single-table inheritance. #3833, #9886 [Gabriel Gironda, rramdas, François Beausoleil, Josh Peek, Tarmo Tänav, pat] - -* Warn about protected attribute assigments in development and test environments when mass-assigning to an attr_protected attribute. #9802 [Henrik N] - -* Speedup database date/time parsing. [Jeremy Kemper, Tarmo Tänav] - -* Fix calling .clear on a has_many :dependent=>:delete_all association. [Tarmo Tänav] - -* Allow change_column to set NOT NULL in the PostgreSQL adapter [Tarmo Tänav] - -* Fix that ActiveRecord would create attribute methods and override custom attribute getters if the method is also defined in Kernel.methods. [Rick Olson] - -* Don't call attr_readonly on polymorphic belongs_to associations, in case it matches the name of some other non-ActiveRecord class/module. [Rick Olson] - -* Try loading activerecord-<adaptername>-adapter gem before trying a plain require so you can use custom gems for the bundled adapters. Also stops gems from requiring an adapter from an old Active Record gem. [Jeremy Kemper, Derrick Spell] - - -*2.0.0 [Preview Release]* (September 29th, 2007) [Includes duplicates of changes from 1.14.2 - 1.15.3] - -* Add attr_readonly to specify columns that are skipped during a normal ActiveRecord #save operation. Closes #6896 [Dan Manges] - - class Comment < ActiveRecord::Base - # Automatically sets Article#comments_count as readonly. - belongs_to :article, :counter_cache => :comments_count - end - - class Article < ActiveRecord::Base - attr_readonly :approved_comments_count - end - -* Make size for has_many :through use counter cache if it exists. Closes #9734 [Xavier Shay] - -* Remove DB2 adapter since IBM chooses to maintain their own adapter instead. [Jeremy Kemper] - -* Extract Oracle, SQLServer, and Sybase adapters into gems. [Jeremy Kemper] - -* Added fixture caching that'll speed up a normal fixture-powered test suite between 50% and 100% #9682 [Frederick Cheung] - -* Correctly quote id list for limited eager loading. #7482 [tmacedo] - -* Fixed that using version-targetted migrates would fail on loggers other than the default one #7430 [valeksenko] - -* Fixed rename_column for SQLite when using symbols for the column names #8616 [drodriguez] - -* Added the possibility of using symbols in addition to concrete classes with ActiveRecord::Observer#observe. #3998 [Robby Russell, Tarmo Tänav] - -* Added ActiveRecord::Base#to_json/from_json [David Heinemeier Hansson, Cheah Chu Yeow] - -* Added ActiveRecord::Base#from_xml [David Heinemeier Hansson]. Example: - - xml = "<person><name>David</name></person>" - Person.new.from_xml(xml).name # => "David" - -* Define dynamic finders as real methods after first usage. [bscofield] - -* Deprecation: remove deprecated threaded_connections methods. Use allow_concurrency instead. [Jeremy Kemper] - -* Associations macros accept extension blocks alongside modules. #9346 [Josh Peek] - -* Speed up and simplify query caching. [Jeremy Kemper] - -* connection.select_rows 'sql' returns an array (rows) of arrays (field values). #2329 [Michael Schuerig] - -* Eager loading respects explicit :joins. #9496 [dasil003] - -* Extract Firebird, FrontBase, and OpenBase adapters into gems. #9508, #9509, #9510 [Jeremy Kemper] - -* RubyGem database adapters: expects a gem named activerecord-<database>-adapter with active_record/connection_adapters/<database>_adapter.rb in its load path. [Jeremy Kemper] - -* Fixed that altering join tables in migrations would fail w/ sqlite3 #7453 [TimoMihaljov/brandon] - -* Fix association writer with :dependent => :nullify. #7314 [Jonathan Viney] - -* OpenBase: update for new lib and latest Rails. Support migrations. #8748 [dcsesq] - -* Moved acts_as_tree into a plugin of the same name on the official Rails svn. #9514 [Pratik Naik] - -* Moved acts_as_nested_set into a plugin of the same name on the official Rails svn. #9516 [Josh Peek] - -* Moved acts_as_list into a plugin of the same name on the official Rails svn. [Josh Peek] - -* Explicitly require active_record/query_cache before using it. [Jeremy Kemper] - -* Fix bug where unserializing an attribute attempts to modify a frozen @attributes hash for a deleted record. [Rick Olson, marclove] - -* Performance: absorb instantiate and initialize_with_callbacks into the Base methods. [Jeremy Kemper] - -* Fixed that eager loading queries and with_scope should respect the :group option [David Heinemeier Hansson] - -* Improve performance and functionality of the postgresql adapter. Closes #8049 [roderickvd] - - For more information see: http://dev.rubyonrails.org/ticket/8049 - -* Don't clobber includes passed to has_many.count [Jack Danger Canty] - -* Make sure has_many uses :include when counting [Jack Danger Canty] - -* Change the implementation of ActiveRecord's attribute reader and writer methods [Michael Koziarski] - - Generate Reader and Writer methods which cache attribute values in hashes. This is to avoid repeatedly parsing the same date or integer columns. - - Change exception raised when users use find with :select then try to access a skipped column. Plugins could override missing_attribute() to lazily load the columns. - - Move method definition to the class, instead of the instance - - Always generate the readers, writers and predicate methods. - -* Perform a deep #dup on query cache results so that modifying activerecord attributes does not modify the cached attributes. [Rick Olson] - -# Ensure that has_many :through associations use a count query instead of loading the target when #size is called. Closes #8800 [Pratik Naik] - -* Added :unless clause to validations #8003 [monki]. Example: - - def using_open_id? - !identity_url.blank? - end - - validates_presence_of :identity_url, :if => using_open_id? - validates_presence_of :username, :unless => using_open_id? - validates_presence_of :password, :unless => using_open_id? - -* Fix #count on a has_many :through association so that it recognizes the :uniq option. Closes #8801 [Pratik Naik] - -* Fix and properly document/test count(column_name) usage. Closes #8999 [Pratik Naik] - -* Remove deprecated count(conditions=nil, joins=nil) usage. Closes #8993 [Pratik Naik] - -* Change belongs_to so that the foreign_key assumption is taken from the association name, not the class name. Closes #8992 [Josh Susser] - - OLD - belongs_to :visitor, :class_name => 'User' # => inferred foreign_key is user_id - - NEW - belongs_to :visitor, :class_name => 'User' # => inferred foreign_key is visitor_id - -* Remove spurious tests from deprecated_associations_test, most of these aren't deprecated, and are duplicated in associations_test. Closes #8987 [Pratik Naik] - -* Make create! on a has_many :through association return the association object. Not the collection. Closes #8786 [Pratik Naik] - -* Move from select * to select tablename.* to avoid clobbering IDs. Closes #8889 [dasil003] - -* Don't call unsupported methods on associated objects when using :include, :method with to_xml #7307, [Manfred Stienstra, jwilger] - -* Define collection singular ids method for has_many :through associations. #8763 [Pratik Naik] - -* Array attribute conditions work with proxied association collections. #8318 [Kamal Fariz Mahyuddin, theamazingrando] - -* Fix polymorphic has_one associations declared in an abstract class. #8638 [Pratik Naik, Dax Huiberts] - -* Fixed validates_associated should not stop on the first error. #4276 [mrj, Manfred Stienstra, Josh Peek] - -* Rollback if commit raises an exception. #8642 [kik, Jeremy Kemper] - -* Update tests' use of fixtures for the new collections api. #8726 [Kamal Fariz Mahyuddin] - -* Save associated records only if the association is already loaded. #8713 [Blaine] - -* MySQL: fix show_variable. #8448 [matt, Jeremy Kemper] - -* Fixtures: correctly delete and insert fixtures in a single transaction. #8553 [Michael Schuerig] - -* Fixtures: people(:technomancy, :josh) returns both fixtures. #7880 [technomancy, Josh Peek] - -* Calculations support non-numeric foreign keys. #8154 [Kamal Fariz Mahyuddin] - -* with_scope is protected. #8524 [Josh Peek] - -* Quickref for association methods. #7723 [marclove, Mindsweeper] - -* Calculations: return nil average instead of 0 when there are no rows to average. #8298 [davidw] - -* acts_as_nested_set: direct_children is sorted correctly. #4761 [Josh Peek, rails@33lc0.net] - -* Raise an exception if both attr_protected and attr_accessible are declared. #8507 [stellsmi] - -* SQLite, MySQL, PostgreSQL, Oracle: quote column names in column migration SQL statements. #8466 [marclove, lorenjohnson] - -* Allow nil serialized attributes with a set class constraint. #7293 [sandofsky] - -* Oracle: support binary fixtures. #7987 [Michael Schoen] - -* Fixtures: pull fixture insertion into the database adapters. #7987 [Michael Schoen] - -* Announce migration versions as they're performed. [Jeremy Kemper] - -* find gracefully copes with blank :conditions. #7599 [Dan Manges, johnnyb] - -* validates_numericality_of takes :greater_than, :greater_than_or_equal_to, :equal_to, :less_than, :less_than_or_equal_to, :odd, and :even options. #3952 [Bob Silva, Dan Kubb, Josh Peek] - -* MySQL: create_database takes :charset and :collation options. Charset defaults to utf8. #8448 [matt] - -* Find with a list of ids supports limit/offset. #8437 [hrudududu] - -* Optimistic locking: revert the lock version when an update fails. #7840 [plang] - -* Migrations: add_column supports custom column types. #7742 [jsgarvin, Theory] - -* Load database adapters on demand. Eliminates config.connection_adapters and RAILS_CONNECTION_ADAPTERS. Add your lib directory to the $LOAD_PATH and put your custom adapter in lib/active_record/connection_adapters/adaptername_adapter.rb. This way you can provide custom adapters as plugins or gems without modifying Rails. [Jeremy Kemper] - -* Ensure that associations with :dependent => :delete_all respect :conditions option. Closes #8034 [Jack Danger Canty, Josh Peek, Rick Olson] - -* belongs_to assignment creates a new proxy rather than modifying its target in-place. #8412 [mmangino@elevatedrails.com] - -* Fix column type detection while loading fixtures. Closes #7987 [roderickvd] - -* Document deep eager includes. #6267 [Josh Susser, Dan Manges] - -* Document warning that associations names shouldn't be reserved words. #4378 [murphy@cYcnus.de, Josh Susser] - -* Sanitize Base#inspect. #8392, #8623 [Nik Wakelin, jnoon] - -* Replace the transaction {|transaction|..} semantics with a new Exception ActiveRecord::Rollback. [Michael Koziarski] - -* Oracle: extract column length for CHAR also. #7866 [ymendel] - -* Document :allow_nil option for validates_acceptance_of since it defaults to true. [tzaharia] - -* Update documentation for :dependent declaration so that it explicitly uses the non-deprecated API. [Jack Danger Canty] - -* Add documentation caveat about when to use count_by_sql. [fearoffish] - -* Enhance documentation for increment_counter and decrement_counter. [fearoffish] - -* Provide brief introduction to what optimistic locking is. [fearoffish] - -* Add documentation for :encoding option to mysql adapter. [marclove] - -* Added short-hand declaration style to migrations (inspiration from Sexy Migrations, http://errtheblog.com/post/2381) [David Heinemeier Hansson]. Example: - - create_table "products" do |t| - t.column "shop_id", :integer - t.column "creator_id", :integer - t.column "name", :string, :default => "Untitled" - t.column "value", :string, :default => "Untitled" - t.column "created_at", :datetime - t.column "updated_at", :datetime - end - - ...can now be written as: - - create_table :products do |t| - t.integer :shop_id, :creator_id - t.string :name, :value, :default => "Untitled" - t.timestamps - end - -* Use association name for the wrapper element when using .to_xml. Previous behavior lead to non-deterministic situations with STI and polymorphic associations. [Michael Koziarski, jstrachan] - -* Improve performance of calling .create on has_many :through associations. [evan] - -* Improved cloning performance by relying less on exception raising #8159 [Blaine] - -* Added ActiveRecord::Base.inspect to return a column-view like #<Post id:integer, title:string, body:text> [David Heinemeier Hansson] - -* Added yielding of Builder instance for ActiveRecord::Base#to_xml calls [David Heinemeier Hansson] - -* Small additions and fixes for ActiveRecord documentation. Closes #7342 [Jeremy McAnally] - -* Add helpful debugging info to the ActiveRecord::StatementInvalid exception in ActiveRecord::ConnectionAdapters::SqliteAdapter#table_structure. Closes #7925. [court3nay] - -* SQLite: binary escaping works with $KCODE='u'. #7862 [tsuka] - -* Base#to_xml supports serialized attributes. #7502 [jonathan] - -* Base.update_all :order and :limit options. Useful for MySQL updates that must be ordered to avoid violating unique constraints. [Jeremy Kemper] - -* Remove deprecated object transactions. People relying on this functionality should install the object_transactions plugin at http://code.bitsweat.net/svn/object_transactions. Closes #5637 [Michael Koziarski, Jeremy Kemper] - -* PostgreSQL: remove DateTime -> Time downcast. Warning: do not enable translate_results for the C bindings if you have timestamps outside Time's domain. [Jeremy Kemper] - -* find_or_create_by_* takes a hash so you can create with more attributes than are in the method name. For example, Person.find_or_create_by_name(:name => 'Henry', :comments => 'Hi new user!') is equivalent to Person.find_by_name('Henry') || Person.create(:name => 'Henry', :comments => 'Hi new user!'). #7368 [Josh Susser] - -* Make sure with_scope takes both :select and :joins into account when setting :readonly. Allows you to save records you retrieve using method_missing on a has_many :through associations. [Michael Koziarski] - -* Allow a polymorphic :source for has_many :through associations. Closes #7143 [protocool] - -* Consistent public/protected/private visibility for chained methods. #7813 [Dan Manges] - -* Oracle: fix quoted primary keys and datetime overflow. #7798 [Michael Schoen] - -* Consistently quote primary key column names. #7763 [toolmantim] - -* Fixtures: fix YAML ordered map support. #2665 [Manuel Holtgrewe, nfbuckley] - -* DateTimes assume the default timezone. #7764 [Geoff Buesing] - -* Sybase: hide timestamp columns since they're inherently read-only. #7716 [Mike Joyce] - -* Oracle: overflow Time to DateTime. #7718 [Michael Schoen] - -* PostgreSQL: don't use async_exec and async_query with postgres-pr. #7727, #7762 [flowdelic, toolmantim] - -* Fix has_many :through << with custom foreign keys. #6466, #7153 [naffis, Rich Collins] - -* Test DateTime native type in migrations, including an edge case with dates -during calendar reform. #7649, #7724 [fedot, Geoff Buesing] - -* SQLServer: correctly schema-dump tables with no indexes or descending indexes. #7333, #7703 [Jakob Skjerning, Tom Ward] - -* SQLServer: recognize real column type as Ruby float. #7057 [sethladd, Tom Ward] - -* Added fixtures :all as a way of loading all fixtures in the fixture directory at once #7214 [Manfred Stienstra] - -* Added database connection as a yield parameter to ActiveRecord::Base.transaction so you can manually rollback [David Heinemeier Hansson]. Example: - - transaction do |transaction| - david.withdrawal(100) - mary.deposit(100) - transaction.rollback! # rolls back the transaction that was otherwise going to be successful - end - -* Made increment_counter/decrement_counter play nicely with optimistic locking, and added a more general update_counters method [Jamis Buck] - -* Reworked David's query cache to be available as Model.cache {...}. For the duration of the block no select query should be run more then once. Any inserts/deletes/executes will flush the whole cache however [Tobias Lütke] - Task.cache { Task.find(1); Task.find(1) } #=> 1 query - -* When dealing with SQLite3, use the table_info pragma helper, so that the bindings can do some translation for when sqlite3 breaks incompatibly between point releases. [Jamis Buck] - -* Oracle: fix lob and text default handling. #7344 [gfriedrich, Michael Schoen] - -* SQLServer: don't choke on strings containing 'null'. #7083 [Jakob Skjerning] - -* MySQL: blob and text columns may not have defaults in 5.x. Update fixtures schema for strict mode. #6695 [Dan Kubb] - -* update_all can take a Hash argument. sanitize_sql splits into two methods for conditions and assignment since NULL values and delimiters are handled differently. #6583, #7365 [sandofsky, Assaf] - -* MySQL: SET SQL_AUTO_IS_NULL=0 so 'where id is null' doesn't select the last inserted id. #6778 [Jonathan Viney, timc] - -* Use Date#to_s(:db) for quoted dates. #7411 [Michael Schoen] - -* Don't create instance writer methods for class attributes. Closes #7401 [Rick Olson] - -* Docs: validations examples. #7343 [zackchandler] - -* Add missing tests ensuring callbacks work with class inheritance. Closes #7339 [sandofsky] - -* Fixtures use the table name and connection from set_fixture_class. #7330 [Anthony Eden] - -* Remove useless code in #attribute_present? since 0 != blank?. Closes #7249 [Josh Susser] - -* Fix minor doc typos. Closes #7157 [Josh Susser] - -* Fix incorrect usage of #classify when creating the eager loading join statement. Closes #7044 [Josh Susser] - -* SQLServer: quote table name in indexes query. #2928 [keithm@infused.org] - -* Subclasses of an abstract class work with single-table inheritance. #5704, #7284 [BertG, nick+rails@ag.arizona.edu] - -* Make sure sqlite3 driver closes open connections on disconnect [Rob Rasmussen] - -* [DOC] clear up some ambiguity with the way has_and_belongs_to_many creates the default join table name. #7072 [Jeremy McAnally] - -* change_column accepts :default => nil. Skip column options for primary keys. #6956, #7048 [Dan Manges, Jeremy Kemper] - -* MySQL, PostgreSQL: change_column_default quotes the default value and doesn't lose column type information. #3987, #6664 [Jonathan Viney, Manfred Stienstra, altano@bigfoot.com] - -* Oracle: create_table takes a :sequence_name option to override the 'tablename_seq' default. #7000 [Michael Schoen] - -* MySQL: retain SSL settings on reconnect. #6976 [randyv2] - -* Apply scoping during initialize instead of create. Fixes setting of foreign key when using find_or_initialize_by with scoping. [Cody Fauser] - -* SQLServer: handle [quoted] table names. #6635 [rrich] - -* acts_as_nested_set works with single-table inheritance. #6030 [Josh Susser] - -* PostgreSQL, Oracle: correctly perform eager finds with :limit and :order. #4668, #7021 [eventualbuddha, Michael Schoen] - -* Pass a range in :conditions to use the SQL BETWEEN operator. #6974 [Dan Manges] - Student.find(:all, :conditions => { :grade => 9..12 }) - -* Fix the Oracle adapter for serialized attributes stored in CLOBs. Closes #6825 [mschoen, tdfowler] - -* [DOCS] Apply more documentation for ActiveRecord Reflection. Closes #4055 [Robby Russell] - -* [DOCS] Document :allow_nil option of #validate_uniqueness_of. Closes #3143 [Caio Chassot] - -* Bring the sybase adapter up to scratch for 1.2 release. [jsheets] - -* Rollback new_record? and id when an exception is raised in a save callback. #6910 [Ben Curren, outerim] - -* Pushing a record on an association collection doesn't unnecessarily load all the associated records. [Obie Fernandez, Jeremy Kemper] - -* Oracle: fix connection reset failure. #6846 [leonlleslie] - -* Subclass instantiation doesn't try to explicitly require the corresponding subclass. #6840 [leei, Jeremy Kemper] - -* fix faulty inheritance tests and that eager loading grabs the wrong inheritance column when the class of your association is an STI subclass. Closes #6859 [protocool] - -* Consolidated different create and create! versions to call through to the base class with scope. This fixes inconsistencies, especially related to protected attribtues. Closes #5847 [Alexander Dymo, Tobias Lütke] - -* find supports :lock with :include. Check whether your database allows SELECT ... FOR UPDATE with outer joins before using. #6764 [vitaly, Jeremy Kemper] - -* Add AssociationCollection#create! to be consistent with AssociationCollection#create when dealing with a foreign key that is a protected attribute [Cody Fauser] - -* Added counter optimization for AssociationCollection#any? so person.friends.any? won't actually load the full association if we have the count in a cheaper form [David Heinemeier Hansson] - -* Change fixture_path to a class inheritable accessor allowing test cases to have their own custom set of fixtures. #6672 [Zach Dennis] - -* Quote ActiveSupport::Multibyte::Chars. #6653 [Julian Tarkhanov] - -* Simplify query_attribute by typecasting the attribute value and checking whether it's nil, false, zero or blank. #6659 [Jonathan Viney] - -* validates_numericality_of uses \A \Z to ensure the entire string matches rather than ^ $ which may match one valid line of a multiline string. #5716 [Andreas Schwarz] - -* Run validations in the order they were declared. #6657 [obrie] - -* MySQL: detect when a NOT NULL column without a default value is misreported as default ''. Can't detect for string, text, and binary columns since '' is a legitimate default. #6156 [simon@redhillconsulting.com.au, obrie, Jonathan Viney, Jeremy Kemper] - -* Simplify association proxy implementation by factoring construct_scope out of method_missing. #6643 [martin] - -* Oracle: automatically detect the primary key. #6594 [vesaria, Michael Schoen] - -* Oracle: to increase performance, prefetch 100 rows and enable similar cursor sharing. Both are configurable in database.yml. #6607 [philbogle@gmail.com, ray.fortna@jobster.com, Michael Schoen] - -* Don't inspect unloaded associations. #2905 [lmarlow] - -* SQLite: use AUTOINCREMENT primary key in >= 3.1.0. #6588, #6616 [careo, lukfugl] - -* Cache inheritance_column. #6592 [Stefan Kaes] - -* Firebird: decimal/numeric support. #6408 [macrnic] - -* make add_order a tad faster. #6567 [Stefan Kaes] - -* Find with :include respects scoped :order. #5850 - -* Support nil and Array in :conditions => { attr => value } hashes. #6548 [Assaf, Jeremy Kemper] - find(:all, :conditions => { :topic_id => [1, 2, 3], :last_read => nil } - -* Consistently use LOWER() for uniqueness validations (rather than mixing with UPPER()) so the database can always use a functional index on the lowercased column. #6495 [Si] - -* SQLite: fix calculations workaround, remove count(distinct) query rewrite, cleanup test connection scripts. [Jeremy Kemper] - -* SQLite: count(distinct) queries supported in >= 3.2.6. #6544 [Bob Silva] - -* Dynamically generate reader methods for serialized attributes. #6362 [Stefan Kaes] - -* Deprecation: object transactions warning. [Jeremy Kemper] - -* has_one :dependent => :nullify ignores nil associates. #4848, #6528 [bellis@deepthought.org, janovetz, Jeremy Kemper] - -* Oracle: resolve test failures, use prefetched primary key for inserts, check for null defaults, fix limited id selection for eager loading. Factor out some common methods from all adapters. #6515 [Michael Schoen] - -* Make add_column use the options hash with the Sqlite Adapter. Closes #6464 [obrie] - -* Document other options available to migration's add_column. #6419 [grg] - -* MySQL: all_hashes compatibility with old MysqlRes class. #6429, #6601 [Jeremy Kemper] - -* Fix has_many :through to add the appropriate conditions when going through an association using STI. Closes #5783. [Jonathan Viney] - -* fix select_limited_ids_list issues in postgresql, retain current behavior in other adapters [Rick Olson] - -* Restore eager condition interpolation, document it's differences [Rick Olson] - -* Don't rollback in teardown unless a transaction was started. Don't start a transaction in create_fixtures if a transaction is started. #6282 [Jacob Fugal, Jeremy Kemper] - -* Add #delete support to has_many :through associations. Closes #6049 [Martin Landers] - -* Reverted old select_limited_ids_list postgresql fix that caused issues in mysql. Closes #5851 [Rick Olson] - -* Removes the ability for eager loaded conditions to be interpolated, since there is no model instance to use as a context for interpolation. #5553 [turnip@turnipspatch.com] - -* Added timeout option to SQLite3 configurations to deal more gracefully with SQLite3::BusyException, now the connection can instead retry for x seconds to see if the db clears up before throwing that exception #6126 [wreese@gmail.com] - -* Added update_attributes! which uses save! to raise an exception if a validation error prevents saving #6192 [jonathan] - -* Deprecated add_on_boundary_breaking (use validates_length_of instead) #6292 [Bob Silva] - -* The has_many create method works with polymorphic associations. #6361 [Dan Peterson] - -* MySQL: introduce Mysql::Result#all_hashes to support further optimization. #5581 [Stefan Kaes] - -* save! shouldn't validate twice. #6324 [maiha, Bob Silva] - -* Association collections have an _ids reader method to match the existing writer for collection_select convenience (e.g. employee.task_ids). The writer method skips blank ids so you can safely do @employee.task_ids = params[:tasks] without checking every time for an empty list or blank values. #1887, #5780 [Michael Schuerig] - -* Add an attribute reader method for ActiveRecord::Base.observers [Rick Olson] - -* Deprecation: count class method should be called with an options hash rather than two args for conditions and joins. #6287 [Bob Silva] - -* has_one associations with a nil target may be safely marshaled. #6279 [norbauer, Jeremy Kemper] - -* Duplicate the hash provided to AR::Base#to_xml to prevent unexpected side effects [Michael Koziarski] - -* Add a :namespace option to AR::Base#to_xml [Michael Koziarski] - -* Deprecation tests. Remove warnings for dynamic finders and for the foo_count method if it's also an attribute. [Jeremy Kemper] - -* Mock Time.now for more accurate Touch mixin tests. #6213 [Dan Peterson] - -* Improve yaml fixtures error reporting. #6205 [Bruce Williams] - -* Rename AR::Base#quote so people can use that name in their models. #3628 [Michael Koziarski] - -* Add deprecation warning for inferred foreign key. #6029 [Josh Susser] - -* Fixed the Ruby/MySQL adapter we ship with Active Record to work with the new authentication handshake that was introduced in MySQL 4.1, along with the other protocol changes made at that time #5723 [jimw@mysql.com] - -* Deprecation: use :dependent => :delete_all rather than :exclusively_dependent => true. #6024 [Josh Susser] - -* Document validates_presences_of behavior with booleans: you probably want validates_inclusion_of :attr, :in => [true, false]. #2253 [Bob Silva] - -* Optimistic locking: gracefully handle nil versions, treat as zero. #5908 [Tom Ward] - -* to_xml: the :methods option works on arrays of records. #5845 [Josh Starcher] - -* Deprecation: update docs. #5998 [Jakob Skjerning, Kevin Clark] - -* Add some XmlSerialization tests for ActiveRecord [Rick Olson] - -* has_many :through conditions are sanitized by the associating class. #5971 [martin.emde@gmail.com] - -* Tighten rescue clauses. #5985 [james@grayproductions.net] - -* Fix spurious newlines and spaces in AR::Base#to_xml output [Jamis Buck] - -* has_one supports the :dependent => :delete option which skips the typical callback chain and deletes the associated object directly from the database. #5927 [Chris Mear, Jonathan Viney] - -* Nested subclasses are not prefixed with the parent class' table_name since they should always use the base class' table_name. #5911 [Jonathan Viney] - -* SQLServer: work around bug where some unambiguous date formats are not correctly identified if the session language is set to german. #5894 [Tom Ward, kruth@bfpi] - -* SQLServer: fix eager association test. #5901 [Tom Ward] - -* Clashing type columns due to a sloppy join shouldn't wreck single-table inheritance. #5838 [Kevin Clark] - -* Fixtures: correct escaping of \n and \r. #5859 [evgeny.zislis@gmail.com] - -* Migrations: gracefully handle missing migration files. #5857 [eli.gordon@gmail.com] - -* MySQL: update test schema for MySQL 5 strict mode. #5861 [Tom Ward] - -* to_xml: correct naming of included associations. #5831 [Josh Starcher] - -* Pushing a record onto a has_many :through sets the association's foreign key to the associate's primary key and adds it to the correct association. #5815, #5829 [Josh Susser] - -* Add records to has_many :through using <<, push, and concat by creating the association record. Raise if base or associate are new records since both ids are required to create the association. #build raises since you can't associate an unsaved record. #create! takes an attributes hash and creates the associated record and its association in a transaction. [Jeremy Kemper] - - # Create a tagging to associate the post and tag. - post.tags << Tag.find_by_name('old') - post.tags.create! :name => 'general' - - # Would have been: - post.taggings.create!(:tag => Tag.find_by_name('finally') - transaction do - post.taggings.create!(:tag => Tag.create!(:name => 'general')) - end - -* Cache nil results for :included has_one associations also. #5787 [Michael Schoen] - -* Fixed a bug which would cause .save to fail after trying to access a empty has_one association on a unsaved record. [Tobias Lütke] - -* Nested classes are given table names prefixed by the singular form of the parent's table name. [Jeremy Kemper] - Example: Invoice::Lineitem is given table name invoice_lineitems - -* Migrations: uniquely name multicolumn indexes so you don't have to. [Jeremy Kemper] - # people_active_last_name_index, people_active_deactivated_at_index - add_index :people, [:active, :last_name] - add_index :people, [:active, :deactivated_at] - remove_index :people, [:active, :last_name] - remove_index :people, [:active, :deactivated_at] - - WARNING: backward-incompatibility. Multicolumn indexes created before this - revision were named using the first column name only. Now they're uniquely - named using all indexed columns. - - To remove an old multicolumn index, remove_index :table_name, :first_column - -* Fix for deep includes on the same association. [richcollins@gmail.com] - -* Tweak fixtures so they don't try to use a non-ActiveRecord class. [Kevin Clark] - -* Remove ActiveRecord::Base.reset since Dispatcher doesn't use it anymore. [Rick Olson] - -* Document find's :from option. Closes #5762. [andrew@redlinesoftware.com] - -* PostgreSQL: autodetected sequences work correctly with multiple schemas. Rely on the schema search_path instead of explicitly qualifying the sequence name with its schema. #5280 [guy.naor@famundo.com] - -* Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar] - -* Cache nil results for has_one associations so multiple calls don't call the database. Closes #5757. [Michael Schoen] - -* Add documentation for how to disable timestamps on a per model basis. Closes #5684. [matt@mattmargolis.net Marcel Molina Jr.] - -* Don't save has_one associations unnecessarily. #5735 [Jonathan Viney] - -* Refactor ActiveRecord::Base.reset_subclasses to #reset, and add global observer resetting. [Rick Olson] - -* Formally deprecate the deprecated finders. [Michael Koziarski] - -* Formally deprecate rich associations. [Michael Koziarski] - -* Fixed that default timezones for new / initialize should uphold utc setting #5709 [daniluk@yahoo.com] - -* Fix announcement of very long migration names. #5722 [blake@near-time.com] - -* The exists? class method should treat a string argument as an id rather than as conditions. #5698 [jeremy@planetargon.com] - -* Fixed to_xml with :include misbehaviors when invoked on array of model instances #5690 [alexkwolfe@gmail.com] - -* Added support for conditions on Base.exists? #5689 [Josh Peek]. Examples: - - assert (Topic.exists?(:author_name => "David")) - assert (Topic.exists?(:author_name => "Mary", :approved => true)) - assert (Topic.exists?(["parent_id = ?", 1])) - -* Schema dumper quotes date :default values. [Dave Thomas] - -* Calculate sum with SQL, not Enumerable on HasManyThrough Associations. [Dan Peterson] - -* Factor the attribute#{suffix} methods out of method_missing for easier extension. [Jeremy Kemper] - -* Patch sql injection vulnerability when using integer or float columns. [Jamis Buck] - -* Allow #count through a has_many association to accept :include. [Dan Peterson] - -* create_table rdoc: suggest :id => false for habtm join tables. [Zed Shaw] - -* PostgreSQL: return array fields as strings. #4664 [Robby Russell] - -* SQLServer: added tests to ensure all database statements are closed, refactored identity_insert management code to use blocks, removed update/delete rowcount code out of execute and into update/delete, changed insert to go through execute method, removed unused quoting methods, disabled pessimistic locking tests as feature is currently unsupported, fixed RakeFile to load sqlserver specific tests whether running in ado or odbc mode, fixed support for recently added decimal types, added support for limits on integer types. #5670 [Tom Ward] - -* SQLServer: fix db:schema:dump case-sensitivity. #4684 [Will Rogers] - -* Oracle: BigDecimal support. #5667 [Michael Schoen] - -* Numeric and decimal columns map to BigDecimal instead of Float. Those with scale 0 map to Integer. #5454 [robbat2@gentoo.org, work@ashleymoran.me.uk] - -* Firebird migrations support. #5337 [Ken Kunz <kennethkunz@gmail.com>] - -* PostgreSQL: create/drop as postgres user. #4790 [mail@matthewpainter.co.uk, mlaster@metavillage.com] - -* Update callbacks documentation. #3970 [Robby Russell <robby@planetargon.com>] - -* PostgreSQL: correctly quote the ' in pk_and_sequence_for. #5462 [tietew@tietew.net] - -* PostgreSQL: correctly quote microseconds in timestamps. #5641 [rick@rickbradley.com] - -* Clearer has_one/belongs_to model names (account has_one :user). #5632 [matt@mattmargolis.net] - -* Oracle: use nonblocking queries if allow_concurrency is set, fix pessimistic locking, don't guess date vs. time by default (set OracleAdapter.emulate_dates = true for the old behavior), adapter cleanup. #5635 [Michael Schoen] - -* Fixed a few Oracle issues: Allows Oracle's odd date handling to still work consistently within #to_xml, Passes test that hardcode insert statement by dropping the :id column, Updated RUNNING_UNIT_TESTS with Oracle instructions, Corrects method signature for #exec #5294 [Michael Schoen] - -* Added :group to available options for finds done on associations #5516 [mike@michaeldewey.org] - -* Minor tweak to improve performance of ActiveRecord::Base#to_param. - -* Observers also watch subclasses created after they are declared. #5535 [daniels@pronto.com.au] - -* Removed deprecated timestamps_gmt class methods. [Jeremy Kemper] - -* rake build_mysql_database grants permissions to rails@localhost. #5501 [brianegge@yahoo.com] - -* PostgreSQL: support microsecond time resolution. #5492 [alex@msgpad.com] - -* Add AssociationCollection#sum since the method_missing invokation has been shadowed by Enumerable#sum. - -* Added find_or_initialize_by_X which works like find_or_create_by_X but doesn't save the newly instantiated record. [Sam Stephenson] - -* Row locking. Provide a locking clause with the :lock finder option or true for the default "FOR UPDATE". Use the #lock! method to obtain a row lock on a single record (reloads the record with :lock => true). [Shugo Maeda] - # Obtain an exclusive lock on person 1 so we can safely increment visits. - Person.transaction do - # select * from people where id=1 for update - person = Person.find(1, :lock => true) - person.visits += 1 - person.save! - end - -* PostgreSQL: introduce allow_concurrency option which determines whether to use blocking or asynchronous #execute. Adapters with blocking #execute will deadlock Ruby threads. The default value is ActiveRecord::Base.allow_concurrency. [Jeremy Kemper] - -* Use a per-thread (rather than global) transaction mutex so you may execute concurrent transactions on separate connections. [Jeremy Kemper] - -* Change AR::Base#to_param to return a String instead of a Fixnum. Closes #5320. [Nicholas Seckar] - -* Use explicit delegation instead of method aliasing for AR::Base.to_param -> AR::Base.id. #5299 (skaes@web.de) - -* Refactored ActiveRecord::Base.to_xml to become a delegate for XmlSerializer, which restores sanity to the mega method. This refactoring also reinstates the opinions that type="string" is redundant and ugly and nil-differentiation is not a concern of serialization [David Heinemeier Hansson] - -* Added simple hash conditions to find that'll just convert hash to an AND-based condition string #5143 [Hampton Catlin]. Example: - - Person.find(:all, :conditions => { :last_name => "Catlin", :status => 1 }, :limit => 2) - -...is the same as: - - Person.find(:all, :conditions => [ "last_name = ? and status = ?", "Catlin", 1 ], :limit => 2) - - This makes it easier to pass in the options from a form or otherwise outside. - - -* Fixed issues with BLOB limits, charsets, and booleans for Firebird #5194, #5191, #5189 [kennethkunz@gmail.com] - -* Fixed usage of :limit and with_scope when the association in scope is a 1:m #5208 [alex@purefiction.net] - -* Fixed migration trouble with SQLite when NOT NULL is used in the new definition #5215 [greg@lapcominc.com] - -* Fixed problems with eager loading and counting on SQL Server #5212 [kajism@yahoo.com] - -* Fixed that count distinct should use the selected column even when using :include #5251 [anna@wota.jp] - -* Fixed that :includes merged from with_scope won't cause the same association to be loaded more than once if repetition occurs in the clauses #5253 [alex@purefiction.net] - -* Allow models to override to_xml. #4989 [Blair Zajac <blair@orcaware.com>] - -* PostgreSQL: don't ignore port when host is nil since it's often used to label the domain socket. #5247 [shimbo@is.naist.jp] - -* Records and arrays of records are bound as quoted ids. [Jeremy Kemper] - Foo.find(:all, :conditions => ['bar_id IN (?)', bars]) - Foo.find(:first, :conditions => ['bar_id = ?', bar]) - -* Fixed that Base.find :all, :conditions => [ "id IN (?)", collection ] would fail if collection was empty [David Heinemeier Hansson] - -* Add a list of regexes assert_queries skips in the ActiveRecord test suite. [Rick Olson] - -* Fix the has_and_belongs_to_many #create doesn't populate the join for new records. Closes #3692 [Josh Susser] - -* Provide Association Extensions access to the instance that the association is being accessed from. - Closes #4433 [Josh Susser] - -* Update OpenBase adaterp's maintainer's email address. Closes #5176. [Derrick Spell] - -* Add a quick note about :select and eagerly included associations. [Rick Olson] - -* Add docs for the :as option in has_one associations. Closes #5144 [cdcarter@gmail.com] - -* Fixed that has_many collections shouldn't load the entire association to do build or create [David Heinemeier Hansson] - -* Added :allow_nil option for aggregations #5091 [Ian White] - -* Fix Oracle boolean support and tests. Closes #5139. [Michael Schoen] - -* create! no longer blows up when no attributes are passed and a :create scope is in effect (e.g. foo.bars.create! failed whereas foo.bars.create!({}) didn't.) [Jeremy Kemper] - -* Call Inflector#demodulize on the class name when eagerly including an STI model. Closes #5077 [info@loobmedia.com] - -* Preserve MySQL boolean column defaults when changing a column in a migration. Closes #5015. [pdcawley@bofh.org.uk] - -* PostgreSQL: migrations support :limit with :integer columns by mapping limit < 4 to smallint, > 4 to bigint, and anything else to integer. #2900 [keegan@thebasement.org] - -* Dates and times interpret empty strings as nil rather than 2000-01-01. #4830 [kajism@yahoo.com] - -* Allow :uniq => true with has_many :through associations. [Jeremy Kemper] - -* Ensure that StringIO is always available for the Schema dumper. [Marcel Molina Jr.] - -* Allow AR::Base#to_xml to include methods too. Closes #4921. [johan@textdrive.com] - -* Replace superfluous name_to_class_name variant with camelize. [Marcel Molina Jr.] - -* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.] - -* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.] - -* Remove duplicate fixture entry in comments.yml. Closes #4923. [Blair Zajac <blair@orcaware.com>] - -* Update FrontBase adapter to check binding version. Closes #4920. [mlaster@metavillage.com] - -* New Frontbase connections don't start in auto-commit mode. Closes #4922. [mlaster@metavillage.com] - -* When grouping, use the appropriate option key. [Marcel Molina Jr.] - -* Only modify the sequence name in the FrontBase adapter if the FrontBase adapter is actually being used. [Marcel Molina Jr.] - -* Add support for FrontBase (http://www.frontbase.com/) with a new adapter thanks to the hard work of one Mike Laster. Closes #4093. [mlaster@metavillage.com] - -* Add warning about the proper way to validate the presence of a foreign key. Closes #4147. [Francois Beausoleil <francois.beausoleil@gmail.com>] - -* Fix syntax error in documentation. Closes #4679. [Mislav Marohnić] - -* Add Oracle support for CLOB inserts. Closes #4748. [schoenm@earthlink.net sandra.metz@duke.edu] - -* Various fixes for sqlserver_adapter (odbc statement finishing, ado schema dumper, drop index). Closes #4831. [kajism@yahoo.com] - -* Add support for :order option to with_scope. Closes #3887. [eric.daspet@survol.net] - -* Prettify output of schema_dumper by making things line up. Closes #4241 [Caio Chassot <caio@v2studio.com>] - -* Make build_postgresql_databases task make databases owned by the postgres user. Closes #4790. [mlaster@metavillage.com] - -* Sybase Adapter type conversion cleanup. Closes #4736. [dev@metacasa.net] - -* Fix bug where calculations with long alias names return null. [Rick Olson] - -* Raise error when trying to add to a has_many :through association. Use the Join Model instead. [Rick Olson] - - @post.tags << @tag # BAD - @post.taggings.create(:tag => @tag) # GOOD - -* Allow all calculations to take the :include option, not just COUNT (closes #4840) [Rick Olson] - -* Update inconsistent migrations documentation. #4683 [machomagna@gmail.com] - -* Add ActiveRecord::Errors#to_xml [Jamis Buck] - -* Properly quote index names in migrations (closes #4764) [John Long] - -* Fix the HasManyAssociation#count method so it uses the new ActiveRecord::Base#count syntax, while maintaining backwards compatibility. [Rick Olson] - -* Ensure that Associations#include_eager_conditions? checks both scoped and explicit conditions [Rick Olson] - -* Associations#select_limited_ids_list adds the ORDER BY columns to the SELECT DISTINCT List for postgresql. [Rick Olson] - -* DRY up association collection reader method generation. [Marcel Molina Jr.] - -* DRY up and tweak style of the validation error object. [Marcel Molina Jr.] - -* Add :case_sensitive option to validates_uniqueness_of (closes #3090) [Rick Olson] - - class Account < ActiveRecord::Base - validates_uniqueness_of :email, :case_sensitive => false - end - -* Allow multiple association extensions with :extend option (closes #4666) [Josh Susser] - - class Account < ActiveRecord::Base - has_many :people, :extend => [FindOrCreateByNameExtension, FindRecentExtension] - end - - *1.15.3* (March 12th, 2007) - - * Allow a polymorphic :source for has_many :through associations. Closes #7143 [protocool] - - * Consistently quote primary key column names. #7763 [toolmantim] - - * Fixtures: fix YAML ordered map support. #2665 [Manuel Holtgrewe, nfbuckley] - - * Fix has_many :through << with custom foreign keys. #6466, #7153 [naffis, Rich Collins] - - -*1.15.2* (February 5th, 2007) - -* Pass a range in :conditions to use the SQL BETWEEN operator. #6974 [Dan Manges] - Student.find(:all, :conditions => { :grade => 9..12 }) - -* Don't create instance writer methods for class attributes. [Rick Olson] - -* When dealing with SQLite3, use the table_info pragma helper, so that the bindings can do some translation for when sqlite3 breaks incompatibly between point releases. [Jamis Buck] - -* SQLServer: don't choke on strings containing 'null'. #7083 [Jakob Skjerning] - -* Consistently use LOWER() for uniqueness validations (rather than mixing with UPPER()) so the database can always use a functional index on the lowercased column. #6495 [Si] - -* MySQL: SET SQL_AUTO_IS_NULL=0 so 'where id is null' doesn't select the last inserted id. #6778 [Jonathan Viney, timc] - -* Fixtures use the table name and connection from set_fixture_class. #7330 [Anthony Eden] - -* SQLServer: quote table name in indexes query. #2928 [keithm@infused.org] - - -*1.15.1* (January 17th, 2007) - -* Fix nodoc breaking of adapters - - -*1.15.0* (January 16th, 2007) - -* [DOC] clear up some ambiguity with the way has_and_belongs_to_many creates the default join table name. #7072 [Jeremy McAnally] - -* change_column accepts :default => nil. Skip column options for primary keys. #6956, #7048 [Dan Manges, Jeremy Kemper] - -* MySQL, PostgreSQL: change_column_default quotes the default value and doesn't lose column type information. #3987, #6664 [Jonathan Viney, Manfred Stienstra, altano@bigfoot.com] - -* Oracle: create_table takes a :sequence_name option to override the 'tablename_seq' default. #7000 [Michael Schoen] - -* MySQL: retain SSL settings on reconnect. #6976 [randyv2] - -* SQLServer: handle [quoted] table names. #6635 [rrich] - -* acts_as_nested_set works with single-table inheritance. #6030 [Josh Susser] - -* PostgreSQL, Oracle: correctly perform eager finds with :limit and :order. #4668, #7021 [eventualbuddha, Michael Schoen] - -* Fix the Oracle adapter for serialized attributes stored in CLOBs. Closes #6825 [mschoen, tdfowler] - -* [DOCS] Apply more documentation for ActiveRecord Reflection. Closes #4055 [Robby Russell] - -* [DOCS] Document :allow_nil option of #validate_uniqueness_of. Closes #3143 [Caio Chassot] - -* Bring the sybase adapter up to scratch for 1.2 release. [jsheets] - -* Oracle: fix connection reset failure. #6846 [leonlleslie] - -* Subclass instantiation doesn't try to explicitly require the corresponding subclass. #6840 [leei, Jeremy Kemper] - -* fix faulty inheritance tests and that eager loading grabs the wrong inheritance column when the class of your association is an STI subclass. Closes #6859 [protocool] - -* find supports :lock with :include. Check whether your database allows SELECT ... FOR UPDATE with outer joins before using. #6764 [vitaly, Jeremy Kemper] - -* Support nil and Array in :conditions => { attr => value } hashes. #6548 [Assaf, Jeremy Kemper] - find(:all, :conditions => { :topic_id => [1, 2, 3], :last_read => nil } - -* Quote ActiveSupport::Multibyte::Chars. #6653 [Julian Tarkhanov] - -* MySQL: detect when a NOT NULL column without a default value is misreported as default ''. Can't detect for string, text, and binary columns since '' is a legitimate default. #6156 [simon@redhillconsulting.com.au, obrie, Jonathan Viney, Jeremy Kemper] - -* validates_numericality_of uses \A \Z to ensure the entire string matches rather than ^ $ which may match one valid line of a multiline string. #5716 [Andreas Schwarz] - -* Oracle: automatically detect the primary key. #6594 [vesaria, Michael Schoen] - -* Oracle: to increase performance, prefetch 100 rows and enable similar cursor sharing. Both are configurable in database.yml. #6607 [philbogle@gmail.com, ray.fortna@jobster.com, Michael Schoen] - -* Firebird: decimal/numeric support. #6408 [macrnic] - -* Find with :include respects scoped :order. #5850 - -* Dynamically generate reader methods for serialized attributes. #6362 [Stefan Kaes] - -* Deprecation: object transactions warning. [Jeremy Kemper] - -* has_one :dependent => :nullify ignores nil associates. #6528 [janovetz, Jeremy Kemper] - -* Oracle: resolve test failures, use prefetched primary key for inserts, check for null defaults, fix limited id selection for eager loading. Factor out some common methods from all adapters. #6515 [Michael Schoen] - -* Make add_column use the options hash with the Sqlite Adapter. Closes #6464 [obrie] - -* Document other options available to migration's add_column. #6419 [grg] - -* MySQL: all_hashes compatibility with old MysqlRes class. #6429, #6601 [Jeremy Kemper] - -* Fix has_many :through to add the appropriate conditions when going through an association using STI. Closes #5783. [Jonathan Viney] - -* fix select_limited_ids_list issues in postgresql, retain current behavior in other adapters [Rick Olson] - -* Restore eager condition interpolation, document it's differences [Rick Olson] - -* Don't rollback in teardown unless a transaction was started. Don't start a transaction in create_fixtures if a transaction is started. #6282 [Jacob Fugal, Jeremy Kemper] - -* Add #delete support to has_many :through associations. Closes #6049 [Martin Landers] - -* Reverted old select_limited_ids_list postgresql fix that caused issues in mysql. Closes #5851 [Rick Olson] - -* Removes the ability for eager loaded conditions to be interpolated, since there is no model instance to use as a context for interpolation. #5553 [turnip@turnipspatch.com] - -* Added timeout option to SQLite3 configurations to deal more gracefully with SQLite3::BusyException, now the connection can instead retry for x seconds to see if the db clears up before throwing that exception #6126 [wreese@gmail.com] - -* Added update_attributes! which uses save! to raise an exception if a validation error prevents saving #6192 [jonathan] - -* Deprecated add_on_boundary_breaking (use validates_length_of instead) #6292 [Bob Silva] - -* The has_many create method works with polymorphic associations. #6361 [Dan Peterson] - -* MySQL: introduce Mysql::Result#all_hashes to support further optimization. #5581 [Stefan Kaes] - -* save! shouldn't validate twice. #6324 [maiha, Bob Silva] - -* Association collections have an _ids reader method to match the existing writer for collection_select convenience (e.g. employee.task_ids). The writer method skips blank ids so you can safely do @employee.task_ids = params[:tasks] without checking every time for an empty list or blank values. #1887, #5780 [Michael Schuerig] - -* Add an attribute reader method for ActiveRecord::Base.observers [Rick Olson] - -* Deprecation: count class method should be called with an options hash rather than two args for conditions and joins. #6287 [Bob Silva] - -* has_one associations with a nil target may be safely marshaled. #6279 [norbauer, Jeremy Kemper] - -* Duplicate the hash provided to AR::Base#to_xml to prevent unexpected side effects [Michael Koziarski] - -* Add a :namespace option to AR::Base#to_xml [Michael Koziarski] - -* Deprecation tests. Remove warnings for dynamic finders and for the foo_count method if it's also an attribute. [Jeremy Kemper] - -* Mock Time.now for more accurate Touch mixin tests. #6213 [Dan Peterson] - -* Improve yaml fixtures error reporting. #6205 [Bruce Williams] - -* Rename AR::Base#quote so people can use that name in their models. #3628 [Michael Koziarski] - -* Add deprecation warning for inferred foreign key. #6029 [Josh Susser] - -* Fixed the Ruby/MySQL adapter we ship with Active Record to work with the new authentication handshake that was introduced in MySQL 4.1, along with the other protocol changes made at that time #5723 [jimw@mysql.com] - -* Deprecation: use :dependent => :delete_all rather than :exclusively_dependent => true. #6024 [Josh Susser] - -* Optimistic locking: gracefully handle nil versions, treat as zero. #5908 [Tom Ward] - -* to_xml: the :methods option works on arrays of records. #5845 [Josh Starcher] - -* has_many :through conditions are sanitized by the associating class. #5971 [martin.emde@gmail.com] - -* Fix spurious newlines and spaces in AR::Base#to_xml output [Jamis Buck] - -* has_one supports the :dependent => :delete option which skips the typical callback chain and deletes the associated object directly from the database. #5927 [Chris Mear, Jonathan Viney] - -* Nested subclasses are not prefixed with the parent class' table_name since they should always use the base class' table_name. #5911 [Jonathan Viney] - -* SQLServer: work around bug where some unambiguous date formats are not correctly identified if the session language is set to german. #5894 [Tom Ward, kruth@bfpi] - -* Clashing type columns due to a sloppy join shouldn't wreck single-table inheritance. #5838 [Kevin Clark] - -* Fixtures: correct escaping of \n and \r. #5859 [evgeny.zislis@gmail.com] - -* Migrations: gracefully handle missing migration files. #5857 [eli.gordon@gmail.com] - -* MySQL: update test schema for MySQL 5 strict mode. #5861 [Tom Ward] - -* to_xml: correct naming of included associations. #5831 [Josh Starcher] - -* Pushing a record onto a has_many :through sets the association's foreign key to the associate's primary key and adds it to the correct association. #5815, #5829 [Josh Susser] - -* Add records to has_many :through using <<, push, and concat by creating the association record. Raise if base or associate are new records since both ids are required to create the association. #build raises since you can't associate an unsaved record. #create! takes an attributes hash and creates the associated record and its association in a transaction. [Jeremy Kemper] - - # Create a tagging to associate the post and tag. - post.tags << Tag.find_by_name('old') - post.tags.create! :name => 'general' - - # Would have been: - post.taggings.create!(:tag => Tag.find_by_name('finally') - transaction do - post.taggings.create!(:tag => Tag.create!(:name => 'general')) - end - -* Cache nil results for :included has_one associations also. #5787 [Michael Schoen] - -* Fixed a bug which would cause .save to fail after trying to access a empty has_one association on a unsaved record. [Tobias Lütke] - -* Nested classes are given table names prefixed by the singular form of the parent's table name. [Jeremy Kemper] - Example: Invoice::Lineitem is given table name invoice_lineitems - -* Migrations: uniquely name multicolumn indexes so you don't have to. [Jeremy Kemper] - # people_active_last_name_index, people_active_deactivated_at_index - add_index :people, [:active, :last_name] - add_index :people, [:active, :deactivated_at] - remove_index :people, [:active, :last_name] - remove_index :people, [:active, :deactivated_at] - - WARNING: backward-incompatibility. Multicolumn indexes created before this - revision were named using the first column name only. Now they're uniquely - named using all indexed columns. - - To remove an old multicolumn index, remove_index :table_name, :first_column - -* Fix for deep includes on the same association. [richcollins@gmail.com] - -* Tweak fixtures so they don't try to use a non-ActiveRecord class. [Kevin Clark] - -* Remove ActiveRecord::Base.reset since Dispatcher doesn't use it anymore. [Rick Olson] - -* PostgreSQL: autodetected sequences work correctly with multiple schemas. Rely on the schema search_path instead of explicitly qualifying the sequence name with its schema. #5280 [guy.naor@famundo.com] - -* Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar] - -* Cache nil results for has_one associations so multiple calls don't call the database. Closes #5757. [Michael Schoen] - -* Don't save has_one associations unnecessarily. #5735 [Jonathan Viney] - -* Refactor ActiveRecord::Base.reset_subclasses to #reset, and add global observer resetting. [Rick Olson] - -* Formally deprecate the deprecated finders. [Michael Koziarski] - -* Formally deprecate rich associations. [Michael Koziarski] - -* Fixed that default timezones for new / initialize should uphold utc setting #5709 [daniluk@yahoo.com] - -* Fix announcement of very long migration names. #5722 [blake@near-time.com] - -* The exists? class method should treat a string argument as an id rather than as conditions. #5698 [jeremy@planetargon.com] - -* Fixed to_xml with :include misbehaviors when invoked on array of model instances #5690 [alexkwolfe@gmail.com] - -* Added support for conditions on Base.exists? #5689 [Josh Peek]. Examples: - - assert (Topic.exists?(:author_name => "David")) - assert (Topic.exists?(:author_name => "Mary", :approved => true)) - assert (Topic.exists?(["parent_id = ?", 1])) - -* Schema dumper quotes date :default values. [Dave Thomas] - -* Calculate sum with SQL, not Enumerable on HasManyThrough Associations. [Dan Peterson] - -* Factor the attribute#{suffix} methods out of method_missing for easier extension. [Jeremy Kemper] - -* Patch sql injection vulnerability when using integer or float columns. [Jamis Buck] - -* Allow #count through a has_many association to accept :include. [Dan Peterson] - -* create_table rdoc: suggest :id => false for habtm join tables. [Zed Shaw] - -* PostgreSQL: return array fields as strings. #4664 [Robby Russell] - -* SQLServer: added tests to ensure all database statements are closed, refactored identity_insert management code to use blocks, removed update/delete rowcount code out of execute and into update/delete, changed insert to go through execute method, removed unused quoting methods, disabled pessimistic locking tests as feature is currently unsupported, fixed RakeFile to load sqlserver specific tests whether running in ado or odbc mode, fixed support for recently added decimal types, added support for limits on integer types. #5670 [Tom Ward] - -* SQLServer: fix db:schema:dump case-sensitivity. #4684 [Will Rogers] - -* Oracle: BigDecimal support. #5667 [Michael Schoen] - -* Numeric and decimal columns map to BigDecimal instead of Float. Those with scale 0 map to Integer. #5454 [robbat2@gentoo.org, work@ashleymoran.me.uk] - -* Firebird migrations support. #5337 [Ken Kunz <kennethkunz@gmail.com>] - -* PostgreSQL: create/drop as postgres user. #4790 [mail@matthewpainter.co.uk, mlaster@metavillage.com] - -* PostgreSQL: correctly quote the ' in pk_and_sequence_for. #5462 [tietew@tietew.net] - -* PostgreSQL: correctly quote microseconds in timestamps. #5641 [rick@rickbradley.com] - -* Clearer has_one/belongs_to model names (account has_one :user). #5632 [matt@mattmargolis.net] - -* Oracle: use nonblocking queries if allow_concurrency is set, fix pessimistic locking, don't guess date vs. time by default (set OracleAdapter.emulate_dates = true for the old behavior), adapter cleanup. #5635 [Michael Schoen] - -* Fixed a few Oracle issues: Allows Oracle's odd date handling to still work consistently within #to_xml, Passes test that hardcode insert statement by dropping the :id column, Updated RUNNING_UNIT_TESTS with Oracle instructions, Corrects method signature for #exec #5294 [Michael Schoen] - -* Added :group to available options for finds done on associations #5516 [mike@michaeldewey.org] - -* Observers also watch subclasses created after they are declared. #5535 [daniels@pronto.com.au] - -* Removed deprecated timestamps_gmt class methods. [Jeremy Kemper] - -* rake build_mysql_database grants permissions to rails@localhost. #5501 [brianegge@yahoo.com] - -* PostgreSQL: support microsecond time resolution. #5492 [alex@msgpad.com] - -* Add AssociationCollection#sum since the method_missing invokation has been shadowed by Enumerable#sum. - -* Added find_or_initialize_by_X which works like find_or_create_by_X but doesn't save the newly instantiated record. [Sam Stephenson] - -* Row locking. Provide a locking clause with the :lock finder option or true for the default "FOR UPDATE". Use the #lock! method to obtain a row lock on a single record (reloads the record with :lock => true). [Shugo Maeda] - # Obtain an exclusive lock on person 1 so we can safely increment visits. - Person.transaction do - # select * from people where id=1 for update - person = Person.find(1, :lock => true) - person.visits += 1 - person.save! - end - -* PostgreSQL: introduce allow_concurrency option which determines whether to use blocking or asynchronous #execute. Adapters with blocking #execute will deadlock Ruby threads. The default value is ActiveRecord::Base.allow_concurrency. [Jeremy Kemper] - -* Use a per-thread (rather than global) transaction mutex so you may execute concurrent transactions on separate connections. [Jeremy Kemper] - -* Change AR::Base#to_param to return a String instead of a Fixnum. Closes #5320. [Nicholas Seckar] - -* Use explicit delegation instead of method aliasing for AR::Base.to_param -> AR::Base.id. #5299 (skaes@web.de) - -* Refactored ActiveRecord::Base.to_xml to become a delegate for XmlSerializer, which restores sanity to the mega method. This refactoring also reinstates the opinions that type="string" is redundant and ugly and nil-differentiation is not a concern of serialization [David Heinemeier Hansson] - -* Added simple hash conditions to find that'll just convert hash to an AND-based condition string #5143 [Hampton Catlin]. Example: - - Person.find(:all, :conditions => { :last_name => "Catlin", :status => 1 }, :limit => 2) - -...is the same as: - - Person.find(:all, :conditions => [ "last_name = ? and status = ?", "Catlin", 1 ], :limit => 2) - - This makes it easier to pass in the options from a form or otherwise outside. - - -* Fixed issues with BLOB limits, charsets, and booleans for Firebird #5194, #5191, #5189 [kennethkunz@gmail.com] - -* Fixed usage of :limit and with_scope when the association in scope is a 1:m #5208 [alex@purefiction.net] - -* Fixed migration trouble with SQLite when NOT NULL is used in the new definition #5215 [greg@lapcominc.com] - -* Fixed problems with eager loading and counting on SQL Server #5212 [kajism@yahoo.com] - -* Fixed that count distinct should use the selected column even when using :include #5251 [anna@wota.jp] - -* Fixed that :includes merged from with_scope won't cause the same association to be loaded more than once if repetition occurs in the clauses #5253 [alex@purefiction.net] - -* Allow models to override to_xml. #4989 [Blair Zajac <blair@orcaware.com>] - -* PostgreSQL: don't ignore port when host is nil since it's often used to label the domain socket. #5247 [shimbo@is.naist.jp] - -* Records and arrays of records are bound as quoted ids. [Jeremy Kemper] - Foo.find(:all, :conditions => ['bar_id IN (?)', bars]) - Foo.find(:first, :conditions => ['bar_id = ?', bar]) - -* Fixed that Base.find :all, :conditions => [ "id IN (?)", collection ] would fail if collection was empty [David Heinemeier Hansson] - -* Add a list of regexes assert_queries skips in the ActiveRecord test suite. [Rick Olson] - -* Fix the has_and_belongs_to_many #create doesn't populate the join for new records. Closes #3692 [Josh Susser] - -* Provide Association Extensions access to the instance that the association is being accessed from. - Closes #4433 [Josh Susser] - -* Update OpenBase adaterp's maintainer's email address. Closes #5176. [Derrick Spell] - -* Add a quick note about :select and eagerly included associations. [Rick Olson] - -* Add docs for the :as option in has_one associations. Closes #5144 [cdcarter@gmail.com] - -* Fixed that has_many collections shouldn't load the entire association to do build or create [David Heinemeier Hansson] - -* Added :allow_nil option for aggregations #5091 [Ian White] - -* Fix Oracle boolean support and tests. Closes #5139. [Michael Schoen] - -* create! no longer blows up when no attributes are passed and a :create scope is in effect (e.g. foo.bars.create! failed whereas foo.bars.create!({}) didn't.) [Jeremy Kemper] - -* Call Inflector#demodulize on the class name when eagerly including an STI model. Closes #5077 [info@loobmedia.com] - -* Preserve MySQL boolean column defaults when changing a column in a migration. Closes #5015. [pdcawley@bofh.org.uk] - -* PostgreSQL: migrations support :limit with :integer columns by mapping limit < 4 to smallint, > 4 to bigint, and anything else to integer. #2900 [keegan@thebasement.org] - -* Dates and times interpret empty strings as nil rather than 2000-01-01. #4830 [kajism@yahoo.com] - -* Allow :uniq => true with has_many :through associations. [Jeremy Kemper] - -* Ensure that StringIO is always available for the Schema dumper. [Marcel Molina Jr.] - -* Allow AR::Base#to_xml to include methods too. Closes #4921. [johan@textdrive.com] - -* Remove duplicate fixture entry in comments.yml. Closes #4923. [Blair Zajac <blair@orcaware.com>] - -* When grouping, use the appropriate option key. [Marcel Molina Jr.] - -* Add support for FrontBase (http://www.frontbase.com/) with a new adapter thanks to the hard work of one Mike Laster. Closes #4093. [mlaster@metavillage.com] - -* Add warning about the proper way to validate the presence of a foreign key. Closes #4147. [Francois Beausoleil <francois.beausoleil@gmail.com>] - -* Fix syntax error in documentation. Closes #4679. [Mislav Marohnić] - -* Add Oracle support for CLOB inserts. Closes #4748. [schoenm@earthlink.net sandra.metz@duke.edu] - -* Various fixes for sqlserver_adapter (odbc statement finishing, ado schema dumper, drop index). Closes #4831. [kajism@yahoo.com] - -* Add support for :order option to with_scope. Closes #3887. [eric.daspet@survol.net] - -* Prettify output of schema_dumper by making things line up. Closes #4241 [Caio Chassot <caio@v2studio.com>] - -* Make build_postgresql_databases task make databases owned by the postgres user. Closes #4790. [mlaster@metavillage.com] - -* Sybase Adapter type conversion cleanup. Closes #4736. [dev@metacasa.net] - -* Fix bug where calculations with long alias names return null. [Rick Olson] - -* Raise error when trying to add to a has_many :through association. Use the Join Model instead. [Rick Olson] - - @post.tags << @tag # BAD - @post.taggings.create(:tag => @tag) # GOOD - -* Allow all calculations to take the :include option, not just COUNT (closes #4840) [Rick Olson] - -* Add ActiveRecord::Errors#to_xml [Jamis Buck] - -* Properly quote index names in migrations (closes #4764) [John Long] - -* Fix the HasManyAssociation#count method so it uses the new ActiveRecord::Base#count syntax, while maintaining backwards compatibility. [Rick Olson] - -* Ensure that Associations#include_eager_conditions? checks both scoped and explicit conditions [Rick Olson] - -* Associations#select_limited_ids_list adds the ORDER BY columns to the SELECT DISTINCT List for postgresql. [Rick Olson] - -* Add :case_sensitive option to validates_uniqueness_of (closes #3090) [Rick Olson] - - class Account < ActiveRecord::Base - validates_uniqueness_of :email, :case_sensitive => false - end - -* Allow multiple association extensions with :extend option (closes #4666) [Josh Susser] - - class Account < ActiveRecord::Base - has_many :people, :extend => [FindOrCreateByNameExtension, FindRecentExtension] - end - - -*1.14.4* (August 8th, 2006) - -* Add warning about the proper way to validate the presence of a foreign key. #4147 [Francois Beausoleil <francois.beausoleil@gmail.com>] - -* Fix syntax error in documentation. #4679 [Mislav Marohnić] - -* Update inconsistent migrations documentation. #4683 [machomagna@gmail.com] - - -*1.14.3* (June 27th, 2006) - -* Fix announcement of very long migration names. #5722 [blake@near-time.com] - -* Update callbacks documentation. #3970 [Robby Russell <robby@planetargon.com>] - -* Properly quote index names in migrations (closes #4764) [John Long] - -* Ensure that Associations#include_eager_conditions? checks both scoped and explicit conditions [Rick Olson] - -* Associations#select_limited_ids_list adds the ORDER BY columns to the SELECT DISTINCT List for postgresql. [Rick Olson] - - -*1.14.2* (April 9th, 2006) - -* Fixed calculations for the Oracle Adapter (closes #4626) [Michael Schoen] - - -*1.14.1* (April 6th, 2006) - -* Fix type_name_with_module to handle type names that begin with '::'. Closes #4614. [Nicholas Seckar] - -* Fixed that that multiparameter assignment doesn't work with aggregations (closes #4620) [Lars Pind] - -* Enable Limit/Offset in Calculations (closes #4558) [lmarlow] - -* Fixed that loading including associations returns all results if Load IDs For Limited Eager Loading returns none (closes #4528) [Rick Olson] - -* Fixed HasManyAssociation#find bugs when :finder_sql is set #4600 [lagroue@free.fr] - -* Allow AR::Base#respond_to? to behave when @attributes is nil [Ryan Davis] - -* Support eager includes when going through a polymorphic has_many association. [Rick Olson] - -* Added support for eagerly including polymorphic has_one associations. (closes #4525) [Rick Olson] - - class Post < ActiveRecord::Base - has_one :tagging, :as => :taggable - end - - Post.find :all, :include => :tagging - -* Added descriptive error messages for invalid has_many :through associations: going through :has_one or :has_and_belongs_to_many [Rick Olson] - -* Added support for going through a polymorphic has_many association: (closes #4401) [Rick Olson] - - class PhotoCollection < ActiveRecord::Base - has_many :photos, :as => :photographic - belongs_to :firm - end - - class Firm < ActiveRecord::Base - has_many :photo_collections - has_many :photos, :through => :photo_collections - end - -* Multiple fixes and optimizations in PostgreSQL adapter, allowing ruby-postgres gem to work properly. [ruben.nine@gmail.com] - -* Fixed that AssociationCollection#delete_all should work even if the records of the association are not loaded yet. [Florian Weber] - -* Changed those private ActiveRecord methods to take optional third argument :auto instead of nil for performance optimizations. (closes #4456) [Stefan] - -* Private ActiveRecord methods add_limit!, add_joins!, and add_conditions! take an OPTIONAL third argument 'scope' (closes #4456) [Rick Olson] - -* DEPRECATED: Using additional attributes on has_and_belongs_to_many associations. Instead upgrade your association to be a real join model [David Heinemeier Hansson] - -* Fixed that records returned from has_and_belongs_to_many associations with additional attributes should be marked as read only (fixes #4512) [David Heinemeier Hansson] - -* Do not implicitly mark recordss of has_many :through as readonly but do mark habtm records as readonly (eventually only on join tables without rich attributes). [Marcel Mollina Jr.] - -* Fixed broken OCIAdapter #4457 [Michael Schoen] - - -*1.14.0* (March 27th, 2006) - -* Replace 'rescue Object' with a finer grained rescue. Closes #4431. [Nicholas Seckar] - -* Fixed eager loading so that an aliased table cannot clash with a has_and_belongs_to_many join table [Rick Olson] - -* Add support for :include to with_scope [andrew@redlinesoftware.com] - -* Support the use of public synonyms with the Oracle adapter; required ruby-oci8 v0.1.14 #4390 [Michael Schoen] - -* Change periods (.) in table aliases to _'s. Closes #4251 [jeff@ministrycentered.com] - -* Changed has_and_belongs_to_many join to INNER JOIN for Mysql 3.23.x. Closes #4348 [Rick Olson] - -* Fixed issue that kept :select options from being scoped [Rick Olson] - -* Fixed db_schema_import when binary types are present #3101 [David Heinemeier Hansson] - -* Fixed that MySQL enums should always be returned as strings #3501 [David Heinemeier Hansson] - -* Change has_many :through to use the :source option to specify the source association. :class_name is now ignored. [Rick Olson] - - class Connection < ActiveRecord::Base - belongs_to :user - belongs_to :channel - end - - class Channel < ActiveRecord::Base - has_many :connections - has_many :contacts, :through => :connections, :class_name => 'User' # OLD - has_many :contacts, :through => :connections, :source => :user # NEW - end - -* Fixed DB2 adapter so nullable columns will be determines correctly now and quotes from column default values will be removed #4350 [contact@maik-schmidt.de] - -* Allow overriding of find parameters in scoped has_many :through calls [Rick Olson] - - In this example, :include => false disables the default eager association from loading. :select changes the standard - select clause. :joins specifies a join that is added to the end of the has_many :through query. - - class Post < ActiveRecord::Base - has_many :tags, :through => :taggings, :include => :tagging do - def add_joins_and_select - find :all, :select => 'tags.*, authors.id as author_id', :include => false, - :joins => 'left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id' - end - end - end - -* Fixed that schema changes while the database was open would break any connections to a SQLite database (now we reconnect if that error is throw) [David Heinemeier Hansson] - -* Don't classify the has_one class when eager loading, it is already singular. Add tests. (closes #4117) [Jonathan Viney] - -* Quit ignoring default :include options in has_many :through calls [Mark James] - -* Allow has_many :through associations to find the source association by setting a custom class (closes #4307) [Jonathan Viney] - -* Eager Loading support added for has_many :through => :has_many associations (see below). [Rick Olson] - -* Allow has_many :through to work on has_many associations (closes #3864) [sco@scottraymond.net] Example: - - class Firm < ActiveRecord::Base - has_many :clients - has_many :invoices, :through => :clients - end - - class Client < ActiveRecord::Base - belongs_to :firm - has_many :invoices - end - - class Invoice < ActiveRecord::Base - belongs_to :client - end - -* Raise error when trying to select many polymorphic objects with has_many :through or :include (closes #4226) [Josh Susser] - -* Fixed has_many :through to include :conditions set on the :through association. closes #4020 [Jonathan Viney] - -* Fix that has_many :through honors the foreign key set by the belongs_to association in the join model (closes #4259) [andylien@gmail.com / Rick Olson] - -* SQL Server adapter gets some love #4298 [Ryan Tomayko] - -* Added OpenBase database adapter that builds on top of the http://www.spice-of-life.net/ruby-openbase/ driver. All functionality except LIMIT/OFFSET is supported #3528 [derrickspell@cdmplus.com] - -* Rework table aliasing to account for truncated table aliases. Add smarter table aliasing when doing eager loading of STI associations. This allows you to use the association name in the order/where clause. [Jonathan Viney / Rick Olson] #4108 Example (SpecialComment is using STI): - - Author.find(:all, :include => { :posts => :special_comments }, :order => 'special_comments.body') - -* Add AbstractAdapter#table_alias_for to create table aliases according to the rules of the current adapter. [Rick Olson] - -* Provide access to the underlying database connection through Adapter#raw_connection. Enables the use of db-specific methods without complicating the adapters. #2090 [Michael Koziarski] - -* Remove broken attempts at handling columns with a default of 'now()' in the postgresql adapter. #2257 [Michael Koziarski] - -* Added connection#current_database that'll return of the current database (only works in MySQL, SQL Server, and Oracle so far -- please help implement for the rest of the adapters) #3663 [Tom Ward] - -* Fixed that Migration#execute would have the table name prefix appended to its query #4110 [mark.imbriaco@pobox.com] - -* Make all tinyint(1) variants act like boolean in mysql (tinyint(1) unsigned, etc.) [Jamis Buck] - -* Use association's :conditions when eager loading. [Jeremy Evans] #4144 - -* Alias the has_and_belongs_to_many join table on eager includes. #4106 [Jeremy Evans] - - This statement would normally error because the projects_developers table is joined twice, and therefore joined_on would be ambiguous. - - Developer.find(:all, :include => {:projects => :developers}, :conditions => 'join_project_developers.joined_on IS NOT NULL') - -* Oracle adapter gets some love #4230 [Michael Schoen] - - * Changes :text to CLOB rather than BLOB [Moses Hohman] - * Fixes an issue with nil numeric length/scales (several) - * Implements support for XMLTYPE columns [wilig / Kubo Takehiro] - * Tweaks a unit test to get it all green again - * Adds support for #current_database - -* Added Base.abstract_class? that marks which classes are not part of the Active Record hierarchy #3704 [Rick Olson] - - class CachedModel < ActiveRecord::Base - self.abstract_class = true - end - - class Post < CachedModel - end - - CachedModel.abstract_class? - => true - - Post.abstract_class? - => false - - Post.base_class - => Post - - Post.table_name - => 'posts' - -* Allow :dependent options to be used with polymorphic joins. #3820 [Rick Olson] - - class Foo < ActiveRecord::Base - has_many :attachments, :as => :attachable, :dependent => :delete_all - end - -* Nicer error message on has_many :through when :through reflection can not be found. #4042 [court3nay] - -* Upgrade to Transaction::Simple 1.3 [Jamis Buck] - -* Catch FixtureClassNotFound when using instantiated fixtures on a fixture that has no ActiveRecord model [Rick Olson] - -* Allow ordering of calculated results and/or grouped fields in calculations [solo@gatelys.com] - -* Make ActiveRecord::Base#save! return true instead of nil on success. #4173 [johan@johansorensen.com] - -* Dynamically set allow_concurrency. #4044 [Stefan Kaes] - -* Added Base#to_xml that'll turn the current record into a XML representation [David Heinemeier Hansson]. Example: - - topic.to_xml - - ...returns: - - <?xml version="1.0" encoding="UTF-8"?> - <topic> - <title>The First Topic</title> - <author-name>David</author-name> - <id type="integer">1</id> - <approved type="boolean">false</approved> - <replies-count type="integer">0</replies-count> - <bonus-time type="datetime">2000-01-01 08:28:00</bonus-time> - <written-on type="datetime">2003-07-16 09:28:00</written-on> - <content>Have a nice day</content> - <author-email-address>david@loudthinking.com</author-email-address> - <parent-id></parent-id> - <last-read type="date">2004-04-15</last-read> - </topic> - - ...and you can configure with: - - topic.to_xml(:skip_instruct => true, :except => [ :id, bonus_time, :written_on, replies_count ]) - - ...that'll return: - - <topic> - <title>The First Topic</title> - <author-name>David</author-name> - <approved type="boolean">false</approved> - <content>Have a nice day</content> - <author-email-address>david@loudthinking.com</author-email-address> - <parent-id></parent-id> - <last-read type="date">2004-04-15</last-read> - </topic> - - You can even do load first-level associations as part of the document: - - firm.to_xml :include => [ :account, :clients ] - - ...that'll return something like: - - <?xml version="1.0" encoding="UTF-8"?> - <firm> - <id type="integer">1</id> - <rating type="integer">1</rating> - <name>37signals</name> - <clients> - <client> - <rating type="integer">1</rating> - <name>Summit</name> - </client> - <client> - <rating type="integer">1</rating> - <name>Microsoft</name> - </client> - </clients> - <account> - <id type="integer">1</id> - <credit-limit type="integer">50</credit-limit> - </account> - </firm> - -* Allow :counter_cache to take a column name for custom counter cache columns [Jamis Buck] - -* Documentation fixes for :dependent [robby@planetargon.com] - -* Stop the MySQL adapter crashing when views are present. #3782 [Jonathan Viney] - -* Don't classify the belongs_to class, it is already singular #4117 [keithm@infused.org] - -* Allow set_fixture_class to take Classes instead of strings for a class in a module. Raise FixtureClassNotFound if a fixture can't load. [Rick Olson] - -* Fix quoting of inheritance column for STI eager loading #4098 [Jonathan Viney <jonathan@bluewire.net.nz>] - -* Added smarter table aliasing for eager associations for multiple self joins #3580 [Rick Olson] - - * The first time a table is referenced in a join, no alias is used. - * After that, the parent class name and the reflection name are used. - - Tree.find(:all, :include => :children) # LEFT OUTER JOIN trees AS tree_children ... - - * Any additional join references get a numerical suffix like '_2', '_3', etc. - -* Fixed eager loading problems with single-table inheritance #3580 [Rick Olson]. Post.find(:all, :include => :special_comments) now returns all posts, and any special comments that the posts may have. And made STI work with has_many :through and polymorphic belongs_to. - -* Added cascading eager loading that allows for queries like Author.find(:all, :include=> { :posts=> :comments }), which will fetch all authors, their posts, and the comments belonging to those posts in a single query (using LEFT OUTER JOIN) #3913 [anna@wota.jp]. Examples: - - # cascaded in two levels - >> Author.find(:all, :include=>{:posts=>:comments}) - => authors - +- posts - +- comments - - # cascaded in two levels and normal association - >> Author.find(:all, :include=>[{:posts=>:comments}, :categorizations]) - => authors - +- posts - +- comments - +- categorizations - - # cascaded in two levels with two has_many associations - >> Author.find(:all, :include=>{:posts=>[:comments, :categorizations]}) - => authors - +- posts - +- comments - +- categorizations - - # cascaded in three levels - >> Company.find(:all, :include=>{:groups=>{:members=>{:favorites}}}) - => companies - +- groups - +- members - +- favorites - -* Make counter cache work when replacing an association #3245 [eugenol@gmail.com] - -* Make migrations verbose [Jamis Buck] - -* Make counter_cache work with polymorphic belongs_to [Jamis Buck] - -* Fixed that calling HasOneProxy#build_model repeatedly would cause saving to happen #4058 [anna@wota.jp] - -* Added Sybase database adapter that relies on the Sybase Open Client bindings (see http://raa.ruby-lang.org/project/sybase-ctlib) #3765 [John Sheets]. It's almost completely Active Record compliant (including migrations), but has the following caveats: - - * Does not support DATE SQL column types; use DATETIME instead. - * Date columns on HABTM join tables are returned as String, not Time. - * Insertions are potentially broken for :polymorphic join tables - * BLOB column access not yet fully supported - -* Clear stale, cached connections left behind by defunct threads. [Jeremy Kemper] - -* CHANGED DEFAULT: set ActiveRecord::Base.allow_concurrency to false. Most AR usage is in single-threaded applications. [Jeremy Kemper] - -* Renamed the "oci" adapter to "oracle", but kept the old name as an alias #4017 [Michael Schoen] - -* Fixed that Base.save should always return false if the save didn't succeed, including if it has halted by before_save's #1861, #2477 [David Heinemeier Hansson] - -* Speed up class -> connection caching and stale connection verification. #3979 [Stefan Kaes] - -* Add set_fixture_class to allow the use of table name accessors with models which use set_table_name. [Kevin Clark] - -* Added that fixtures to placed in subdirectories of the main fixture files are also loaded #3937 [dblack@wobblini.net] - -* Define attribute query methods to avoid method_missing calls. #3677 [Jonathan Viney] - -* ActiveRecord::Base.remove_connection explicitly closes database connections and doesn't corrupt the connection cache. Introducing the disconnect! instance method for the PostgreSQL, MySQL, and SQL Server adapters; implementations for the others are welcome. #3591 [Simon Stapleton, Tom Ward] - -* Added support for nested scopes #3407 [anna@wota.jp]. Examples: - - Developer.with_scope(:find => { :conditions => "salary > 10000", :limit => 10 }) do - Developer.find(:all) # => SELECT * FROM developers WHERE (salary > 10000) LIMIT 10 - - # inner rule is used. (all previous parameters are ignored) - Developer.with_exclusive_scope(:find => { :conditions => "name = 'Jamis'" }) do - Developer.find(:all) # => SELECT * FROM developers WHERE (name = 'Jamis') - end - - # parameters are merged - Developer.with_scope(:find => { :conditions => "name = 'Jamis'" }) do - Developer.find(:all) # => SELECT * FROM developers WHERE (( salary > 10000 ) AND ( name = 'Jamis' )) LIMIT 10 - end - end - -* Fixed db2 connection with empty user_name and auth options #3622 [phurley@gmail.com] - -* Fixed validates_length_of to work on UTF-8 strings by using characters instead of bytes #3699 [Masao Mutoh] - -* Fixed that reflections would bleed across class boundaries in single-table inheritance setups #3796 [Lars Pind] - -* Added calculations: Base.count, Base.average, Base.sum, Base.minimum, Base.maxmium, and the generic Base.calculate. All can be used with :group and :having. Calculations and statitics need no longer require custom SQL. #3958 [Rick Olson]. Examples: - - Person.average :age - Person.minimum :age - Person.maximum :age - Person.sum :salary, :group => :last_name - -* Renamed Errors#count to Errors#size but kept an alias for the old name (and included an alias for length too) #3920 [Luke Redpath] - -* Reflections don't attempt to resolve module nesting of association classes. Simplify type computation. [Jeremy Kemper] - -* Improved the Oracle OCI Adapter with better performance for column reflection (from #3210), fixes to migrations (from #3476 and #3742), tweaks to unit tests (from #3610), and improved documentation (from #2446) #3879 [Aggregated by schoenm@earthlink.net] - -* Fixed that the schema_info table used by ActiveRecord::Schema.define should respect table pre- and suffixes #3834 [rubyonrails@atyp.de] - -* Added :select option to Base.count that'll allow you to select something else than * to be counted on. Especially important for count queries using DISTINCT #3839 [Stefan Kaes] - -* Correct syntax error in mysql DDL, and make AAACreateTablesTest run first [Bob Silva] - -* Allow :include to be used with has_many :through associations #3611 [Michael Schoen] - -* PostgreSQL: smarter schema dumps using pk_and_sequence_for(table). #2920 [Blair Zajac] - -* SQLServer: more compatible limit/offset emulation. #3779 [Tom Ward] - -* Polymorphic join support for has_one associations (has_one :foo, :as => :bar) #3785 [Rick Olson] - -* PostgreSQL: correctly parse negative integer column defaults. #3776 [bellis@deepthought.org] - -* Fix problems with count when used with :include [Jeremy Hopple and Kevin Clark] - -* ActiveRecord::RecordInvalid now states which validations failed in its default error message [Tobias Lütke] - -* Using AssociationCollection#build with arrays of hashes should call build, not create [David Heinemeier Hansson] - -* Remove definition of reloadable? from ActiveRecord::Base to make way for new Reloadable code. [Nicholas Seckar] - -* Fixed schema handling for DB2 adapter that didn't work: an initial schema could be set, but it wasn't used when getting tables and indexes #3678 [Maik Schmidt] - -* Support the :column option for remove_index with the PostgreSQL adapter. #3661 [Shugo Maeda] - -* Add documentation for add_index and remove_index. #3600 [Manfred Stienstra <m.stienstra@fngtps.com>] - -* If the OCI library is not available, raise an exception indicating as much. #3593 [Michael Schoen] - -* Add explicit :order in finder tests as postgresql orders results differently by default. #3577. [Rick Olson] - -* Make dynamic finders honor additional passed in :conditions. #3569 [Oleg Pudeyev <pudeyo@rpi.edu>, Marcel Molina Jr.] - -* Show a meaningful error when the DB2 adapter cannot be loaded due to missing dependencies. [Nicholas Seckar] - -* Make .count work for has_many associations with multi line finder sql [Michael Schoen] - -* Add AR::Base.base_class for querying the ancestor AR::Base subclass [Jamis Buck] - -* Allow configuration of the column used for optimistic locking [wilsonb@gmail.com] - -* Don't hardcode 'id' in acts as list. [ror@philippeapril.com] - -* Fix date errors for SQLServer in association tests. #3406 [Kevin Clark] - -* Escape database name in MySQL adapter when creating and dropping databases. #3409 [anna@wota.jp] - -* Disambiguate table names for columns in validates_uniquness_of's WHERE clause. #3423 [alex.borovsky@gmail.com] - -* .with_scope imposed create parameters now bypass attr_protected [Tobias Lütke] - -* Don't raise an exception when there are more keys than there are named bind variables when sanitizing conditions. [Marcel Molina Jr.] - -* Multiple enhancements and adjustments to DB2 adaptor. #3377 [contact@maik-schmidt.de] - -* Sanitize scoped conditions. [Marcel Molina Jr.] - -* Added option to Base.reflection_of_all_associations to specify a specific association to scope the call. For example Base.reflection_of_all_associations(:has_many) [David Heinemeier Hansson] - -* Added ActiveRecord::SchemaDumper.ignore_tables which tells SchemaDumper which tables to ignore. Useful for tables with funky column like the ones required for tsearch2. [Tobias Lütke] - -* SchemaDumper now doesn't fail anymore when there are unknown column types in the schema. Instead the table is ignored and a Comment is left in the schema.rb. [Tobias Lütke] - -* Fixed that saving a model with multiple habtm associations would only save the first one. #3244 [yanowitz-rubyonrails@quantumfoam.org, Florian Weber] - -* Fix change_column to work with PostgreSQL 7.x and 8.x. #3141 [wejn@box.cz, Rick Olson, Scott Barron] - -* removed :piggyback in favor of just allowing :select on :through associations. [Tobias Lütke] - -* made method missing delegation to class methods on relation target work on :through associations. [Tobias Lütke] - -* made .find() work on :through relations. [Tobias Lütke] - -* Fix typo in association docs. #3296. [Blair Zajac] - -* Fixed :through relations when using STI inherited classes would use the inherited class's name as foreign key on the join model [Tobias Lütke] - -*1.13.2* (December 13th, 2005) - -* Become part of Rails 1.0 - -* MySQL: allow encoding option for mysql.rb driver. [Jeremy Kemper] - -* Added option inheritance for find calls on has_and_belongs_to_many and has_many assosociations [David Heinemeier Hansson]. Example: - - class Post - has_many :recent_comments, :class_name => "Comment", :limit => 10, :include => :author - end - - post.recent_comments.find(:all) # Uses LIMIT 10 and includes authors - post.recent_comments.find(:all, :limit => nil) # Uses no limit but include authors - post.recent_comments.find(:all, :limit => nil, :include => nil) # Uses no limit and doesn't include authors - -* Added option to specify :group, :limit, :offset, and :select options from find on has_and_belongs_to_many and has_many assosociations [David Heinemeier Hansson] - -* MySQL: fixes for the bundled mysql.rb driver. #3160 [Justin Forder] - -* SQLServer: fix obscure optimistic locking bug. #3068 [kajism@yahoo.com] - -* SQLServer: support uniqueidentifier columns. #2930 [keithm@infused.org] - -* SQLServer: cope with tables names qualified by owner. #3067 [jeff@ministrycentered.com] - -* SQLServer: cope with columns with "desc" in the name. #1950 [Ron Lusk, Ryan Tomayko] - -* SQLServer: cope with primary keys with "select" in the name. #3057 [rdifrango@captechventures.com] - -* Oracle: active? performs a select instead of a commit. #3133 [Michael Schoen] - -* MySQL: more robust test for nullified result hashes. #3124 [Stefan Kaes] - -* Reloading an instance refreshes its aggregations as well as its associations. #3024 [François Beausoleil] - -* Fixed that using :include together with :conditions array in Base.find would cause NoMethodError #2887 [Paul Hammmond] - -* PostgreSQL: more robust sequence name discovery. #3087 [Rick Olson] - -* Oracle: use syntax compatible with Oracle 8. #3131 [Michael Schoen] - -* MySQL: work around ruby-mysql/mysql-ruby inconsistency with mysql.stat. Eliminate usage of mysql.ping because it doesn't guarantee reconnect. Explicitly close and reopen the connection instead. [Jeremy Kemper] - -* Added preliminary support for polymorphic associations [David Heinemeier Hansson] - -* Added preliminary support for join models [David Heinemeier Hansson] - -* Allow validate_uniqueness_of to be scoped by more than just one column. #1559. [jeremy@jthopple.com, Marcel Molina Jr.] - -* Firebird: active? and reconnect! methods for handling stale connections. #428 [Ken Kunz <kennethkunz@gmail.com>] - -* Firebird: updated for FireRuby 0.4.0. #3009 [Ken Kunz <kennethkunz@gmail.com>] - -* MySQL and PostgreSQL: active? compatibility with the pure-Ruby driver. #428 [Jeremy Kemper] - -* Oracle: active? check pings the database rather than testing the last command status. #428 [Michael Schoen] - -* SQLServer: resolve column aliasing/quoting collision when using limit or offset in an eager find. #2974 [kajism@yahoo.com] - -* Reloading a model doesn't lose track of its connection. #2996 [junk@miriamtech.com, Jeremy Kemper] - -* Fixed bug where using update_attribute after pushing a record to a habtm association of the object caused duplicate rows in the join table. #2888 [colman@rominato.com, Florian Weber, Michael Schoen] - -* MySQL, PostgreSQL: reconnect! also reconfigures the connection. Otherwise, the connection 'loses' its settings if it times out and is reconnected. #2978 [Shugo Maeda] - -* has_and_belongs_to_many: use JOIN instead of LEFT JOIN. [Jeremy Kemper] - -* MySQL: introduce :encoding option to specify the character set for client, connection, and results. Only available for MySQL 4.1 and later with the mysql-ruby driver. Do SHOW CHARACTER SET in mysql client to see available encodings. #2975 [Shugo Maeda] - -* Add tasks to create, drop and rebuild the MySQL and PostgreSQL test databases. [Marcel Molina Jr.] - -* Correct boolean handling in generated reader methods. #2945 [Don Park, Stefan Kaes] - -* Don't generate read methods for columns whose names are not valid ruby method names. #2946 [Stefan Kaes] - -* Document :force option to create_table. #2921 [Blair Zajac <blair@orcaware.com>] - -* Don't add the same conditions twice in has_one finder sql. #2916 [Jeremy Evans] - -* Rename Version constant to VERSION. #2802 [Marcel Molina Jr.] - -* Introducing the Firebird adapter. Quote columns and use attribute_condition more consistently. Setup guide: http://wiki.rubyonrails.com/rails/pages/Firebird+Adapter #1874 [Ken Kunz <kennethkunz@gmail.com>] - -* SQLServer: active? and reconnect! methods for handling stale connections. #428 [kajism@yahoo.com, Tom Ward <tom@popdog.net>] - -* Associations handle case-equality more consistently: item.parts.is_a?(Array) and item.parts === Array. #1345 [MarkusQ@reality.com] - -* SQLServer: insert uses given primary key value if not nil rather than SELECT @@IDENTITY. #2866 [kajism@yahoo.com, Tom Ward <tom@popdog.net>] - -* Oracle: active? and reconnect! methods for handling stale connections. Optionally retry queries after reconnect. #428 [Michael Schoen <schoenm@earthlink.net>] - -* Correct documentation for Base.delete_all. #1568 [Newhydra] - -* Oracle: test case for column default parsing. #2788 [Michael Schoen <schoenm@earthlink.net>] - -* Update documentation for Migrations. #2861 [Tom Werner <tom@cube6media.com>] - -* When AbstractAdapter#log rescues an exception, attempt to detect and reconnect to an inactive database connection. Connection adapter must respond to the active? and reconnect! instance methods. Initial support for PostgreSQL, MySQL, and SQLite. Make certain that all statements which may need reconnection are performed within a logged block: for example, this means no avoiding log(sql, name) { } if @logger.nil? #428 [Jeremy Kemper] - -* Oracle: Much faster column reflection. #2848 [Michael Schoen <schoenm@earthlink.net>] - -* Base.reset_sequence_name analogous to reset_table_name (mostly useful for testing). Base.define_attr_method allows nil values. [Jeremy Kemper] - -* PostgreSQL: smarter sequence name defaults, stricter last_insert_id, warn on pk without sequence. [Jeremy Kemper] - -* PostgreSQL: correctly discover custom primary key sequences. #2594 [Blair Zajac <blair@orcaware.com>, meadow.nnick@gmail.com, Jeremy Kemper] - -* SQLServer: don't report limits for unsupported field types. #2835 [Ryan Tomayko] - -* Include the Enumerable module in ActiveRecord::Errors. [Rick Bradley <rick@rickbradley.com>] - -* Add :group option, correspond to GROUP BY, to the find method and to the has_many association. #2818 [rubyonrails@atyp.de] - -* Don't cast nil or empty strings to a dummy date. #2789 [Rick Bradley <rick@rickbradley.com>] - -* acts_as_list plays nicely with inheritance by remembering the class which declared it. #2811 [rephorm@rephorm.com] - -* Fix sqlite adaptor's detection of missing dbfile or database declaration. [Nicholas Seckar] - -* Fixed acts_as_list for definitions without an explicit :order #2803 [Jonathan Viney] - -* Upgrade bundled ruby-mysql 0.2.4 with mysql411 shim (see #440) to ruby-mysql 0.2.6 with a patchset for 4.1 protocol support. Local change [301] is now a part of the main driver; reapplied local change [2182]. Removed GC.start from Result.free. [tommy@tmtm.org, akuroda@gmail.com, Doug Fales <doug.fales@gmail.com>, Jeremy Kemper] - -* Correct handling of complex order clauses with SQL Server limit emulation. #2770 [Tom Ward <tom@popdog.net>, Matt B.] - -* Correct whitespace problem in Oracle default column value parsing. #2788 [rick@rickbradley.com] - -* Destroy associated has_and_belongs_to_many records after all before_destroy callbacks but before destroy. This allows you to act on the habtm association as you please while preserving referential integrity. #2065 [larrywilliams1@gmail.com, sam.kirchmeier@gmail.com, elliot@townx.org, Jeremy Kemper] - -* Deprecate the old, confusing :exclusively_dependent option in favor of :dependent => :delete_all. [Jeremy Kemper] - -* More compatible Oracle column reflection. #2771 [Ryan Davis <ryand-ruby@zenspider.com>, Michael Schoen <schoenm@earthlink.net>] - - -*1.13.0* (November 7th, 2005) - -* Fixed faulty regex in get_table_name method (SQLServerAdapter) #2639 [Ryan Tomayko] - -* Added :include as an option for association declarations [David Heinemeier Hansson]. Example: - - has_many :posts, :include => [ :author, :comments ] - -* Rename Base.constrain to Base.with_scope so it doesn't conflict with existing concept of database constraints. Make scoping more robust: uniform method => parameters, validated method names and supported finder parameters, raise exception on nested scopes. [Jeremy Kemper] Example: - - Comment.with_scope(:find => { :conditions => 'active=true' }, :create => { :post_id => 5 }) do - # Find where name = ? and active=true - Comment.find :all, :conditions => ['name = ?', name] - # Create comment associated with :post_id - Comment.create :body => "Hello world" - end - -* Fixed that SQL Server should ignore :size declarations on anything but integer and string in the agnostic schema representation #2756 [Ryan Tomayko] - -* Added constrain scoping for creates using a hash of attributes bound to the :creation key [David Heinemeier Hansson]. Example: - - Comment.constrain(:creation => { :post_id => 5 }) do - # Associated with :post_id - Comment.create :body => "Hello world" - end - - This is rarely used directly, but allows for find_or_create on associations. So you can do: - - # If the tag doesn't exist, a new one is created that's associated with the person - person.tags.find_or_create_by_name("Summer") - -* Added find_or_create_by_X as a second type of dynamic finder that'll create the record if it doesn't already exist [David Heinemeier Hansson]. Example: - - # No 'Summer' tag exists - Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer") - - # Now the 'Summer' tag does exist - Tag.find_or_create_by_name("Summer") # equal to Tag.find_by_name("Summer") - -* Added extension capabilities to has_many and has_and_belongs_to_many proxies [David Heinemeier Hansson]. Example: - - class Account < ActiveRecord::Base - has_many :people do - def find_or_create_by_name(name) - first_name, *last_name = name.split - last_name = last_name.join " " - - find_or_create_by_first_name_and_last_name(first_name, last_name) - end - end - end - - person = Account.find(:first).people.find_or_create_by_name("David Heinemeier Hansson") - person.first_name # => "David" - person.last_name # => "Heinemeier Hansson" - - Note that the anoymous module must be declared using brackets, not do/end (due to order of evaluation). - -* Omit internal dtproperties table from SQLServer table list. #2729 [Ryan Tomayko] - -* Quote column names in generated SQL. #2728 [Ryan Tomayko] - -* Correct the pure-Ruby MySQL 4.1.1 shim's version test. #2718 [Jeremy Kemper] - -* Add Model.create! to match existing model.save! method. When save! raises RecordInvalid, you can catch the exception, retrieve the invalid record (invalid_exception.record), and see its errors (invalid_exception.record.errors). [Jeremy Kemper] - -* Correct fixture behavior when table name pluralization is off. #2719 [Rick Bradley <rick@rickbradley.com>] - -* Changed :dbfile to :database for SQLite adapter for consistency (old key still works as an alias) #2644 [Dan Peterson] - -* Added migration support for Oracle #2647 [Michael Schoen] - -* Worked around that connection can't be reset if allow_concurrency is off. #2648 [Michael Schoen <schoenm@earthlink.net>] - -* Fixed SQL Server adapter to pass even more tests and do even better #2634 [Ryan Tomayko] - -* Fixed SQL Server adapter so it honors options[:conditions] when applying :limits #1978 [Tom Ward] - -* Added migration support to SQL Server adapter (please someone do the same for Oracle and DB2) #2625 [Tom Ward] - -* Use AR::Base.silence rather than AR::Base.logger.silence in fixtures to preserve Log4r compatibility. #2618 [dansketcher@gmail.com] - -* Constraints are cloned so they can't be inadvertently modified while they're -in effect. Added :readonly finder constraint. Calling an association collection's class method (Part.foobar via item.parts.foobar) constrains :readonly => false since the collection's :joins constraint would otherwise force it to true. [Jeremy Kemper <rails@bitsweat.net>] - -* Added :offset and :limit to the kinds of options that Base.constrain can use #2466 [duane.johnson@gmail.com] - -* Fixed handling of nil number columns on Oracle and cleaned up tests for Oracle in general #2555 [Michael Schoen] - -* Added quoted_true and quoted_false methods and tables to db2_adapter and cleaned up tests for DB2 #2493, #2624 [maik schmidt] - - -*1.12.2* (October 26th, 2005) - -* Allow symbols to rename columns when using SQLite adapter. #2531 [Kevin Clark] - -* Map Active Record time to SQL TIME. #2575, #2576 [Robby Russell <robby@planetargon.com>] - -* Clarify semantics of ActiveRecord::Base#respond_to? #2560 [Stefan Kaes] - -* Fixed Association#clear for associations which have not yet been accessed. #2524 [Patrick Lenz <patrick@lenz.sh>] - -* HABTM finders shouldn't return readonly records. #2525 [Patrick Lenz <patrick@lenz.sh>] - -* Make all tests runnable on their own. #2521. [Blair Zajac <blair@orcaware.com>] - - -*1.12.1* (October 19th, 2005) - -* Always parenthesize :conditions options so they may be safely combined with STI and constraints. - -* Correct PostgreSQL primary key sequence detection. #2507 [tmornini@infomania.com] - -* Added support for using limits in eager loads that involve has_many and has_and_belongs_to_many associations - - -*1.12.0* (October 16th, 2005) - -* Update/clean up documentation (rdoc) - -* PostgreSQL sequence support. Use set_sequence_name in your model class to specify its primary key sequence. #2292 [Rick Olson <technoweenie@gmail.com>, Robby Russell <robby@planetargon.com>] - -* Change default logging colors to work on both white and black backgrounds. [Sam Stephenson] - -* YAML fixtures support ordered hashes for fixtures with foreign key dependencies in the same table. #1896 [purestorm@ggnore.net] - -* :dependent now accepts :nullify option. Sets the foreign key of the related objects to NULL instead of deleting them. #2015 [Robby Russell <robby@planetargon.com>] - -* Introduce read-only records. If you call object.readonly! then it will mark the object as read-only and raise ReadOnlyRecord if you call object.save. object.readonly? reports whether the object is read-only. Passing :readonly => true to any finder method will mark returned records as read-only. The :joins option now implies :readonly, so if you use this option, saving the same record will now fail. Use find_by_sql to work around. - -* Avoid memleak in dev mode when using fcgi - -* Simplified .clear on active record associations by using the existing delete_records method. #1906 [Caleb <me@cpb.ca>] - -* Delegate access to a customized primary key to the conventional id method. #2444. [Blair Zajac <blair@orcaware.com>] - -* Fix errors caused by assigning a has-one or belongs-to property to itself - -* Add ActiveRecord::Base.schema_format setting which specifies how databases should be dumped [Sam Stephenson] - -* Update DB2 adapter. #2206. [contact@maik-schmidt.de] - -* Corrections to SQLServer native data types. #2267. [rails.20.clarry@spamgourmet.com] - -* Deprecated ActiveRecord::Base.threaded_connection in favor of ActiveRecord::Base.allow_concurrency. - -* Protect id attribute from mass assigment even when the primary key is set to something else. #2438. [Blair Zajac <blair@orcaware.com>] - -* Misc doc fixes (typos/grammar/etc.). #2430. [coffee2code] - -* Add test coverage for content_columns. #2432. [coffee2code] - -* Speed up for unthreaded environments. #2431. [Stefan Kaes] - -* Optimization for Mysql selects using mysql-ruby extension greater than 2.6.3. #2426. [Stefan Kaes] - -* Speed up the setting of table_name. #2428. [Stefan Kaes] - -* Optimize instantiation of STI subclass records. In partial fullfilment of #1236. [Stefan Kaes] - -* Fix typo of 'constrains' to 'contraints'. #2069. [Michael Schuerig <michael@schuerig.de>] - -* Optimization refactoring for add_limit_offset!. In partial fullfilment of #1236. [Stefan Kaes] - -* Add ability to get all siblings, including the current child, with acts_as_tree. Recloses #2140. [Michael Schuerig <michael@schuerig.de>] - -* Add geometric type for postgresql adapter. #2233 [Andrew Kaspick] - -* Add option (true by default) to generate reader methods for each attribute of a record to avoid the overhead of calling method missing. In partial fullfilment of #1236. [Stefan Kaes] - -* Add convenience predicate methods on Column class. In partial fullfilment of #1236. [Stefan Kaes] - -* Raise errors when invalid hash keys are passed to ActiveRecord::Base.find. #2363 [Chad Fowler <chad@chadfowler.com>, Nicholas Seckar] - -* Added :force option to create_table that'll try to drop the table if it already exists before creating - -* Fix transactions so that calling return while inside a transaction will not leave an open transaction on the connection. [Nicholas Seckar] - -* Use foreign_key inflection uniformly. #2156 [Blair Zajac <blair@orcaware.com>] - -* model.association.clear should destroy associated objects if :dependent => true instead of nullifying their foreign keys. #2221 [joergd@pobox.com, ObieFernandez <obiefernandez@gmail.com>] - -* Returning false from before_destroy should cancel the action. #1829 [Jeremy Huffman] - -* Recognize PostgreSQL NOW() default as equivalent to CURRENT_TIMESTAMP or CURRENT_DATE, depending on the column's type. #2256 [mat <mat@absolight.fr>] - -* Extensive documentation for the abstract database adapter. #2250 [François Beausoleil <fbeausoleil@ftml.net>] - -* Clean up Fixtures.reset_sequences for PostgreSQL. Handle tables with no rows and models with custom primary keys. #2174, #2183 [jay@jay.fm, Blair Zajac <blair@orcaware.com>] - -* Improve error message when nil is assigned to an attr which validates_size_of within a range. #2022 [Manuel Holtgrewe <purestorm@ggnore.net>] - -* Make update_attribute use the same writer method that update_attributes uses. - #2237 [trevor@protocool.com] - -* Make migrations honor table name prefixes and suffixes. #2298 [Jakob Skjerning, Marcel Molina Jr.] - -* Correct and optimize PostgreSQL bytea escaping. #1745, #1837 [dave@cherryville.org, ken@miriamtech.com, bellis@deepthought.org] - -* Fixtures should only reset a PostgreSQL sequence if it corresponds to an integer primary key named id. #1749 [chris@chrisbrinker.com] - -* Standardize the interpretation of boolean columns in the Mysql and Sqlite adapters. (Use MysqlAdapter.emulate_booleans = false to disable this behavior) - -* Added new symbol-driven approach to activating observers with Base#observers= [David Heinemeier Hansson]. Example: - - ActiveRecord::Base.observers = :cacher, :garbage_collector - -* Added AbstractAdapter#select_value and AbstractAdapter#select_values as convenience methods for selecting single values, instead of hashes, of the first column in a SELECT #2283 [solo@gatelys.com] - -* Wrap :conditions in parentheses to prevent problems with OR's #1871 [Jamis Buck] - -* Allow the postgresql adapter to work with the SchemaDumper. [Jamis Buck] - -* Add ActiveRecord::SchemaDumper for dumping a DB schema to a pure-ruby file, making it easier to consolidate large migration lists and port database schemas between databases. [Jamis Buck] - -* Fixed migrations for Windows when using more than 10 [David Naseby] - -* Fixed that the create_x method from belongs_to wouldn't save the association properly #2042 [Florian Weber] - -* Fixed saving a record with two unsaved belongs_to associations pointing to the same object #2023 [Tobias Lütke] - -* Improved migrations' behavior when the schema_info table is empty. [Nicholas Seckar] - -* Fixed that Observers didn't observe sub-classes #627 [Florian Weber] - -* Fix eager loading error messages, allow :include to specify tables using strings or symbols. Closes #2222 [Marcel Molina Jr.] - -* Added check for RAILS_CONNECTION_ADAPTERS on startup and only load the connection adapters specified within if its present (available in Rails through config.connection_adapters using the new config) #1958 [skae] - -* Fixed various problems with has_and_belongs_to_many when using customer finder_sql #2094 [Florian Weber] - -* Added better exception error when unknown column types are used with migrations #1814 [François Beausoleil] - -* Fixed "connection lost" issue with the bundled Ruby/MySQL driver (would kill the app after 8 hours of inactivity) #2163, #428 [kajism@yahoo.com] - -* Fixed comparison of Active Record objects so two new objects are not equal #2099 [deberg] - -* Fixed that the SQL Server adapter would sometimes return DBI::Timestamp objects instead of Time #2127 [Tom Ward] - -* Added the instance methods #root and #ancestors on acts_as_tree and fixed siblings to not include the current node #2142, #2140 [coffee2code] - -* Fixed that Active Record would call SHOW FIELDS twice (or more) for the same model when the cached results were available #1947 [sd@notso.net] - -* Added log_level and use_silence parameter to ActiveRecord::Base.benchmark. The first controls at what level the benchmark statement will be logged (now as debug, instead of info) and the second that can be passed false to include all logging statements during the benchmark block/ - -* Make sure the schema_info table is created before querying the current version #1903 - -* Fixtures ignore table name prefix and suffix #1987 [Jakob Skjerning] - -* Add documentation for index_type argument to add_index method for migrations #2005 [Blaine] - -* Modify read_attribute to allow a symbol argument #2024 [Ken Kunz] - -* Make destroy return self #1913 [Sebastian Kanthak] - -* Fix typo in validations documentation #1938 [court3nay] - -* Make acts_as_list work for insert_at(1) #1966 [hensleyl@papermountain.org] - -* Fix typo in count_by_sql documentation #1969 [Alexey Verkhovsky] - -* Allow add_column and create_table to specify NOT NULL #1712 [emptysands@gmail.com] - -* Fix create_table so that id column is implicitly added [Rick Olson] - -* Default sequence names for Oracle changed to #{table_name}_seq, which is the most commonly used standard. In addition, a new method ActiveRecord::Base#set_sequence_name allows the developer to set the sequence name per model. This is a non-backwards-compatible change -- anyone using the old-style "rails_sequence" will need to either create new sequences, or set: ActiveRecord::Base.set_sequence_name = "rails_sequence" #1798 - -* OCIAdapter now properly handles synonyms, which are commonly used to separate out the schema owner from the application user #1798 - -* Fixed the handling of camelCase columns names in Oracle #1798 - -* Implemented for OCI the Rakefile tasks of :clone_structure_to_test, :db_structure_dump, and :purge_test_database, which enable Oracle folks to enjoy all the agile goodness of Rails for testing. Note that the current implementation is fairly limited -- only tables and sequences are cloned, not constraints or indexes. A full clone in Oracle generally requires some manual effort, and is version-specific. Post 9i, Oracle recommends the use of the DBMS_METADATA package, though that approach requires editing of the physical characteristics generated #1798 - -* Fixed the handling of multiple blob columns in Oracle if one or more of them are null #1798 - -* Added support for calling constrained class methods on has_many and has_and_belongs_to_many collections #1764 [Tobias Lütke] - - class Comment < AR:B - def self.search(q) - find(:all, :conditions => ["body = ?", q]) - end - end - - class Post < AR:B - has_many :comments - end - - Post.find(1).comments.search('hi') # => SELECT * from comments WHERE post_id = 1 AND body = 'hi' - - NOTICE: This patch changes the underlying SQL generated by has_and_belongs_to_many queries. If your relying on that, such as - by explicitly referencing the old t and j aliases, you'll need to update your code. Of course, you _shouldn't_ be relying on - details like that no less than you should be diving in to touch private variables. But just in case you do, consider yourself - noticed :) - -* Added migration support for SQLite (using temporary tables to simulate ALTER TABLE) #1771 [Sam Stephenson] - -* Remove extra definition of supports_migrations? from abstract_adaptor.rb [Nicholas Seckar] - -* Fix acts_as_list so that moving next-to-last item to the bottom does not result in duplicate item positions - -* Fixed incompatibility in DB2 adapter with the new limit/offset approach #1718 [Maik Schmidt] - -* Added :select option to find which can specify a different value than the default *, like find(:all, :select => "first_name, last_name"), if you either only want to select part of the columns or exclude columns otherwise included from a join #1338 [Stefan Kaes] - - -*1.11.1* (11 July, 2005) - -* Added support for limit and offset with eager loading of has_one and belongs_to associations. Using the options with has_many and has_and_belongs_to_many associations will now raise an ActiveRecord::ConfigurationError #1692 [Rick Olson] - -* Fixed that assume_bottom_position (in acts_as_list) could be called on items already last in the list and they would move one position away from the list #1648 [tyler@kianta.com] - -* Added ActiveRecord::Base.threaded_connections flag to turn off 1-connection per thread (required for thread safety). By default it's on, but WEBrick in Rails need it off #1685 [Sam Stephenson] - -* Correct reflected table name for singular associations. #1688 [court3nay] - -* Fixed optimistic locking with SQL Server #1660 [tom@popdog.net] - -* Added ActiveRecord::Migrator.migrate that can figure out whether to go up or down based on the target version and the current - -* Added better error message for "packets out of order" #1630 [court3nay] - -* Fixed first run of "rake migrate" on PostgreSQL by not expecting a return value on the id #1640 - - -*1.11.0* (6 July, 2005) - -* Fixed that Yaml error message in fixtures hid the real error #1623 [Nicholas Seckar] - -* Changed logging of SQL statements to use the DEBUG level instead of INFO - -* Added new Migrations framework for describing schema transformations in a way that can be easily applied across multiple databases #1604 [Tobias Lütke] See documentation under ActiveRecord::Migration and the additional support in the Rails rakefile/generator. - -* Added callback hooks to association collections #1549 [Florian Weber]. Example: - - class Project - has_and_belongs_to_many :developers, :before_add => :evaluate_velocity - - def evaluate_velocity(developer) - ... - end - end - - ..raising an exception will cause the object not to be added (or removed, with before_remove). - - -* Fixed Base.content_columns call for SQL Server adapter #1450 [DeLynn Berry] - -* Fixed Base#write_attribute to work with both symbols and strings #1190 [Paul Legato] - -* Fixed that has_and_belongs_to_many didn't respect single table inheritance types #1081 [Florian Weber] - -* Speed up ActiveRecord#method_missing for the common case (read_attribute). - -* Only notify observers on after_find and after_initialize if these methods are defined on the model. #1235 [Stefan Kaes] - -* Fixed that single-table inheritance sub-classes couldn't be used to limit the result set with eager loading #1215 [Chris McGrath] - -* Fixed validates_numericality_of to work with overrided getter-method when :allow_nil is on #1316 [raidel@onemail.at] - -* Added roots, root, and siblings to the batch of methods added by acts_as_tree #1541 [Michael Schuerig] - -* Added support for limit/offset with the MS SQL Server driver so that pagination will now work #1569 [DeLynn Berry] - -* Added support for ODBC connections to MS SQL Server so you can connect from a non-Windows machine #1569 [Mark Imbriaco/DeLynn Berry] - -* Fixed that multiparameter posts ignored attr_protected #1532 [alec+rails@veryclever.net] - -* Fixed problem with eager loading when using a has_and_belongs_to_many association using :association_foreign_key #1504 [flash@vanklinkenbergsoftware.nl] - -* Fixed Base#find to honor the documentation on how :joins work and make them consistent with Base#count #1405 [pritchie@gmail.com]. What used to be: - - Developer.find :all, :joins => 'developers_projects', :conditions => 'id=developer_id AND project_id=1' - - ...should instead be: - - Developer.find( - :all, - :joins => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id', - :conditions => 'project_id=1' - ) - -* Fixed that validations didn't respecting custom setting for too_short, too_long messages #1437 [Marcel Molina Jr.] - -* Fixed that clear_association_cache doesn't delete new associations on new records (so you can safely place new records in the session with Action Pack without having new associations wiped) #1494 [cluon] - -* Fixed that calling Model.find([]) returns [] and doesn't throw an exception #1379 - -* Fixed that adding a record to a has_and_belongs_to collection would always save it -- now it only saves if its a new record #1203 [Alisdair McDiarmid] - -* Fixed saving of in-memory association structures to happen as a after_create/after_update callback instead of after_save -- that way you can add new associations in after_create/after_update callbacks without getting them saved twice - -* Allow any Enumerable, not just Array, to work as bind variables #1344 [Jeremy Kemper] - -* Added actual database-changing behavior to collection assigment for has_many and has_and_belongs_to_many #1425 [Sebastian Kanthak]. - Example: - - david.projects = [Project.find(1), Project.new("name" => "ActionWebSearch")] - david.save - - If david.projects already contain the project with ID 1, this is left unchanged. Any other projects are dropped. And the new - project is saved when david.save is called. - - Also included is a way to do assignments through IDs, which is perfect for checkbox updating, so you get to do: - - david.project_ids = [1, 5, 7] - -* Corrected typo in find SQL for has_and_belongs_to_many. #1312 [ben@bensinclair.com] - -* Fixed sanitized conditions for has_many finder method. #1281 [jackc@hylesanderson.com, pragdave, Tobias Lütke] - -* Comprehensive PostgreSQL schema support. Use the optional schema_search_path directive in database.yml to give a comma-separated list of schemas to search for your tables. This allows you, for example, to have tables in a shared schema without having to use a custom table name. See http://www.postgresql.org/docs/8.0/interactive/ddl-schemas.html to learn more. #827 [dave@cherryville.org] - -* Corrected @@configurations typo #1410 [david@ruppconsulting.com] - -* Return PostgreSQL columns in the order they were declared #1374 [perlguy@gmail.com] - -* Allow before/after update hooks to work on models using optimistic locking - -* Eager loading of dependent has_one associations won't delete the association #1212 - -* Added a second parameter to the build and create method for has_one that controls whether the existing association should be replaced (which means nullifying its foreign key as well). By default this is true, but false can be passed to prevent it. - -* Using transactional fixtures now causes the data to be loaded only once. - -* Added fixture accessor methods that can be used when instantiated fixtures are disabled. - - fixtures :web_sites - - def test_something - assert_equal "Ruby on Rails", web_sites(:rubyonrails).name - end - -* Added DoubleRenderError exception that'll be raised if render* is called twice #518 [Nicholas Seckar] - -* Fixed exceptions occuring after render has been called #1096 [Nicholas Seckar] - -* CHANGED: validates_presence_of now uses Errors#add_on_blank, which will make " " fail the validation where it didn't before #1309 - -* Added Errors#add_on_blank which works like Errors#add_on_empty, but uses Object#blank? instead - -* Added the :if option to all validations that can either use a block or a method pointer to determine whether the validation should be run or not. #1324 [Duane Johnson/jhosteny]. Examples: - - Conditional validations such as the following are made possible: - validates_numericality_of :income, :if => :employed? - - Conditional validations can also solve the salted login generator problem: - validates_confirmation_of :password, :if => :new_password? - - Using blocks: - validates_presence_of :username, :if => Proc.new { |user| user.signup_step > 1 } - -* Fixed use of construct_finder_sql when using :join #1288 [dwlt@dwlt.net] - -* Fixed that :delete_sql in has_and_belongs_to_many associations couldn't access record properties #1299 [Rick Olson] - -* Fixed that clone would break when an aggregate had the same name as one of its attributes #1307 [Jeremy Kemper] - -* Changed that destroying an object will only freeze the attributes hash, which keeps the object from having attributes changed (as that wouldn't make sense), but allows for the querying of associations after it has been destroyed. - -* Changed the callbacks such that observers are notified before the in-object callbacks are triggered. Without this change, it wasn't possible to act on the whole object in something like a before_destroy observer without having the objects own callbacks (like deleting associations) called first. - -* Added option for passing an array to the find_all version of the dynamic finders and have it evaluated as an IN fragment. Example: - - # SELECT * FROM topics WHERE title IN ('First', 'Second') - Topic.find_all_by_title(["First", "Second"]) - -* Added compatibility with camelCase column names for dynamic finders #533 [Dee Zsombor] - -* Fixed extraneous comma in count() function that made it not work with joins #1156 [Jarkko Laine/Dee Zsombor] - -* Fixed incompatibility with Base#find with an array of ids that would fail when using eager loading #1186 [Alisdair McDiarmid] - -* Fixed that validate_length_of lost :on option when :within was specified #1195 [jhosteny@mac.com] - -* Added encoding and min_messages options for PostgreSQL #1205 [Shugo Maeda]. Configuration example: - - development: - adapter: postgresql - database: rails_development - host: localhost - username: postgres - password: - encoding: UTF8 - min_messages: ERROR - -* Fixed acts_as_list where deleting an item that was removed from the list would ruin the positioning of other list items #1197 [Jamis Buck] - -* Added validates_exclusion_of as a negative of validates_inclusion_of - -* Optimized counting of has_many associations by setting the association to empty if the count is 0 so repeated calls doesn't trigger database calls - - -*1.10.1* (20th April, 2005) - -* Fixed frivilous database queries being triggered with eager loading on empty associations and other things - -* Fixed order of loading in eager associations - -* Fixed stray comma when using eager loading and ordering together from has_many associations #1143 - - -*1.10.0* (19th April, 2005) - -* Added eager loading of associations as a way to solve the N+1 problem more gracefully without piggy-back queries. Example: - - for post in Post.find(:all, :limit => 100) - puts "Post: " + post.title - puts "Written by: " + post.author.name - puts "Last comment on: " + post.comments.first.created_on - end - - This used to generate 301 database queries if all 100 posts had both author and comments. It can now be written as: - - for post in Post.find(:all, :limit => 100, :include => [ :author, :comments ]) - - ...and the number of database queries needed is now 1. - -* Added new unified Base.find API and deprecated the use of find_first and find_all. See the documentation for Base.find. Examples: - - Person.find(1, :conditions => "administrator = 1", :order => "created_on DESC") - Person.find(1, 5, 6, :conditions => "administrator = 1", :order => "created_on DESC") - Person.find(:first, :order => "created_on DESC", :offset => 5) - Person.find(:all, :conditions => [ "category IN (?)", categories], :limit => 50) - Person.find(:all, :offset => 10, :limit => 10) - -* Added acts_as_nested_set #1000 [wschenk]. Introduction: - - This acts provides Nested Set functionality. Nested Set is similiar to Tree, but with - the added feature that you can select the children and all of it's descendants with - a single query. A good use case for this is a threaded post system, where you want - to display every reply to a comment without multiple selects. - -* Added Base.save! that attempts to save the record just like Base.save but will raise a RecordInvalid exception instead of returning false if the record is not valid [Dave Thomas] - -* Fixed PostgreSQL usage of fixtures with regards to public schemas and table names with dots #962 [gnuman1@gmail.com] - -* Fixed that fixtures were being deleted in the same order as inserts causing FK errors #890 [andrew.john.peters@gmail.com] - -* Fixed loading of fixtures in to be in the right order (or PostgreSQL would bark) #1047 [stephenh@chase3000.com] - -* Fixed page caching for non-vhost applications living underneath the root #1004 [Ben Schumacher] - -* Fixes a problem with the SQL Adapter which was resulting in IDENTITY_INSERT not being set to ON when it should be #1104 [adelle] - -* Added the option to specify the acceptance string in validates_acceptance_of #1106 [caleb@aei-tech.com] - -* Added insert_at(position) to acts_as_list #1083 [DeLynnB] - -* Removed the default order by id on has_and_belongs_to_many queries as it could kill performance on large sets (you can still specify by hand with :order) - -* Fixed that Base.silence should restore the old logger level when done, not just set it to DEBUG #1084 [yon@milliped.com] - -* Fixed boolean saving on Oracle #1093 [mparrish@pearware.org] - -* Moved build_association and create_association for has_one and belongs_to out of deprecation as they work when the association is nil unlike association.build and association.create, which require the association to be already in place #864 - -* Added rollbacks of transactions if they're active as the dispatcher is killed gracefully (TERM signal) #1054 [Leon Bredt] - -* Added quoting of column names for fixtures #997 [jcfischer@gmail.com] - -* Fixed counter_sql when no records exist in database for PostgreSQL (would give error, not 0) #1039 [Caleb Tennis] - -* Fixed that benchmarking times for rendering included db runtimes #987 [Stefan Kaes] - -* Fixed boolean queries for t/f fields in PostgreSQL #995 [dave@cherryville.org] - -* Added that model.items.delete(child) will delete the child, not just set the foreign key to nil, if the child is dependent on the model #978 [Jeremy Kemper] - -* Fixed auto-stamping of dates (created_on/updated_on) for PostgreSQL #985 [dave@cherryville.org] - -* Fixed Base.silence/benchmark to only log if a logger has been configured #986 [Stefan Kaes] - -* Added a join parameter as the third argument to Base.find_first and as the second to Base.count #426, #988 [Stefan Kaes] - -* Fixed bug in Base#hash method that would treat records with the same string-based id as different [Dave Thomas] - -* Renamed DateHelper#distance_of_time_in_words_to_now to DateHelper#time_ago_in_words (old method name is still available as a deprecated alias) - - -*1.9.1* (27th March, 2005) - -* Fixed that Active Record objects with float attribute could not be cloned #808 - -* Fixed that MissingSourceFile's wasn't properly detected in production mode #925 [Nicholas Seckar] - -* Fixed that :counter_cache option would look for a line_items_count column for a LineItem object instead of lineitems_count - -* Fixed that AR exists?() would explode on postgresql if the passed id did not match the PK type #900 [Scott Barron] - -* Fixed the MS SQL adapter to work with the new limit/offset approach and with binary data (still suffering from 7KB limit, though) #901 [delynnb] - - -*1.9.0* (22th March, 2005) - -* Added adapter independent limit clause as a two-element array with the first being the limit, the second being the offset #795 [Sam Stephenson]. Example: - - Developer.find_all nil, 'id ASC', 5 # return the first five developers - Developer.find_all nil, 'id ASC', [3, 8] # return three developers, starting from #8 and forward - - This doesn't yet work with the DB2 or MS SQL adapters. Patches to make that happen are encouraged. - -* Added alias_method :to_param, :id to Base, such that Active Record objects to be used as URL parameters in Action Pack automatically #812 [Nicholas Seckar/Sam Stephenson] - -* Improved the performance of the OCI8 adapter for Oracle #723 [pilx/gjenkins] - -* Added type conversion before saving a record, so string-based values like "10.0" aren't left for the database to convert #820 [dave@cherryville.org] - -* Added with additional settings for working with transactional fixtures and pre-loaded test databases #865 [mindel] - -* Fixed acts_as_list to trigger remove_from_list on destroy after the fact, not before, so a unique position can be maintained #871 [Alisdair McDiarmid] - -* Added the possibility of specifying fixtures in multiple calls #816 [kim@tinker.com] - -* Added Base.exists?(id) that'll return true if an object of the class with the given id exists #854 [stian@grytoyr.net] - -* Added optionally allow for nil or empty strings with validates_numericality_of #801 [Sebastian Kanthak] - -* Fixed problem with using slashes in validates_format_of regular expressions #801 [Sebastian Kanthak] - -* Fixed that SQLite3 exceptions are caught and reported properly #823 [yerejm] - -* Added that all types of after_find/after_initialized callbacks are triggered if the explicit implementation is present, not only the explicit implementation itself - -* Fixed that symbols can be used on attribute assignment, like page.emails.create(:subject => data.subject, :body => data.body) - - -*1.8.0* (7th March, 2005) - -* Added ActiveRecord::Base.colorize_logging to control whether to use colors in logs or not (on by default) - -* Added support for timestamp with time zone in PostgreSQL #560 [Scott Barron] - -* Added MultiparameterAssignmentErrors and AttributeAssignmentError exceptions #777 [demetrius]. Documentation: - - * +MultiparameterAssignmentErrors+ -- collection of errors that occurred during a mass assignment using the - +attributes=+ method. The +errors+ property of this exception contains an array of +AttributeAssignmentError+ - objects that should be inspected to determine which attributes triggered the errors. - * +AttributeAssignmentError+ -- an error occurred while doing a mass assignment through the +attributes=+ method. - You can inspect the +attribute+ property of the exception object to determine which attribute triggered the error. - -* Fixed that postgresql adapter would fails when reading bytea fields with null value #771 [rodrigo k] - -* Added transactional fixtures that uses rollback to undo changes to fixtures instead of DELETE/INSERT -- it's much faster. See documentation under Fixtures #760 [Jeremy Kemper] - -* Added destruction of dependent objects in has_one associations when a new assignment happens #742 [mindel]. Example: - - class Account < ActiveRecord::Base - has_one :credit_card, :dependent => true - end - class CreditCard < ActiveRecord::Base - belongs_to :account - end - - account.credit_card # => returns existing credit card, lets say id = 12 - account.credit_card = CreditCard.create("number" => "123") - account.save # => CC with id = 12 is destroyed - - -* Added validates_numericality_of #716 [Sebastian Kanthak/Chris McGrath]. Docuemntation: - - Validates whether the value of the specified attribute is numeric by trying to convert it to - a float with Kernel.Float (if <tt>integer</tt> is false) or applying it to the regular expression - <tt>/^[\+\-]?\d+$/</tt> (if <tt>integer</tt> is set to true). - - class Person < ActiveRecord::Base - validates_numericality_of :value, :on => :create - end - - Configuration options: - * <tt>message</tt> - A custom error message (default is: "is not a number") - * <tt>on</tt> Specifies when this validation is active (default is :save, other options :create, :update) - * <tt>only_integer</tt> Specifies whether the value has to be an integer, e.g. an integral value (default is false) - - -* Fixed that HasManyAssociation#count was using :finder_sql rather than :counter_sql if it was available #445 [Scott Barron] - -* Added better defaults for composed_of, so statements like composed_of :time_zone, :mapping => %w( time_zone time_zone ) can be written without the mapping part (it's now assumed) - -* Added MacroReflection#macro which will return a symbol describing the macro used (like :composed_of or :has_many) #718, #248 [james@slashetc.com] - - -*1.7.0* (24th February, 2005) - -* Changed the auto-timestamping feature to use ActiveRecord::Base.default_timezone instead of entertaining the parallel ActiveRecord::Base.timestamps_gmt method. The latter is now deprecated and will throw a warning on use (but still work) #710 [Jamis Buck] - -* Added a OCI8-based Oracle adapter that has been verified to work with Oracle 8 and 9 #629 [Graham Jenkins]. Usage notes: - - 1. Key generation uses a sequence "rails_sequence" for all tables. (I couldn't find a simple - and safe way of passing table-specific sequence information to the adapter.) - 2. Oracle uses DATE or TIMESTAMP datatypes for both dates and times. Consequently I have had to - resort to some hacks to get data converted to Date or Time in Ruby. - If the column_name ends in _at (like created_at, updated_at) it's created as a Ruby Time. Else if the - hours/minutes/seconds are 0, I make it a Ruby Date. Else it's a Ruby Time. - This is nasty - but if you use Duck Typing you'll probably not care very much. - In 9i it's tempting to map DATE to Date and TIMESTAMP to Time but I don't think that is - valid - too many databases use DATE for both. - Timezones and sub-second precision on timestamps are not supported. - 3. Default values that are functions (such as "SYSDATE") are not supported. This is a - restriction of the way active record supports default values. - 4. Referential integrity constraints are not fully supported. Under at least - some circumstances, active record appears to delete parent and child records out of - sequence and out of transaction scope. (Or this may just be a problem of test setup.) - - The OCI8 driver can be retrieved from http://rubyforge.org/projects/ruby-oci8/ - -* Added option :schema_order to the PostgreSQL adapter to support the use of multiple schemas per database #697 [YuriSchimke] - -* Optimized the SQL used to generate has_and_belongs_to_many queries by listing the join table first #693 [yerejm] - -* Fixed that when using validation macros with a custom message, if you happened to use single quotes in the message string you would get a parsing error #657 [tonka] - -* Fixed that Active Record would throw Broken Pipe errors with FCGI when the MySQL connection timed out instead of reconnecting #428 [Nicholas Seckar] - -* Added options to specify an SSL connection for MySQL. Define the following attributes in the connection config (config/database.yml in Rails) to use it: sslkey, sslcert, sslca, sslcapath, sslcipher. To use SSL with no client certs, just set :sslca = '/dev/null'. http://dev.mysql.com/doc/mysql/en/secure-connections.html #604 [daniel@nightrunner.com] - -* Added automatic dropping/creating of test tables for running the unit tests on all databases #587 [adelle@bullet.net.au] - -* Fixed that find_by_* would fail when column names had numbers #670 [demetrius] - -* Fixed the SQL Server adapter on a bunch of issues #667 [DeLynn] - - 1. Created a new columns method that is much cleaner. - 2. Corrected a problem with the select and select_all methods - that didn't account for the LIMIT clause being passed into raw SQL statements. - 3. Implemented the string_to_time method in order to create proper instances of the time class. - 4. Added logic to the simplified_type method that allows the database to specify the scale of float data. - 5. Adjusted the quote_column_name to account for the fact that MS SQL is bothered by a forward slash in the data string. - -* Fixed that the dynamic finder like find_all_by_something_boolean(false) didn't work #649 [lmarlow] - -* Added validates_each that validates each specified attribute against a block #610 [Jeremy Kemper]. Example: - - class Person < ActiveRecord::Base - validates_each :first_name, :last_name do |record, attr| - record.errors.add attr, 'starts with z.' if attr[0] == ?z - end - end - -* Added :allow_nil as an explicit option for validates_length_of, so unless that's set to true having the attribute as nil will also return an error if a range is specified as :within #610 [Jeremy Kemper] - -* Added that validates_* now accept blocks to perform validations #618 [Tim Bates]. Example: - - class Person < ActiveRecord::Base - validate { |person| person.errors.add("title", "will never be valid") if SHOULD_NEVER_BE_VALID } - end - -* Addded validation for validate all the associated objects before declaring failure with validates_associated #618 [Tim Bates] - -* Added keyword-style approach to defining the custom relational bindings #545 [Jamis Buck]. Example: - - class Project < ActiveRecord::Base - primary_key "sysid" - table_name "XYZ_PROJECT" - inheritance_column { original_inheritance_column + "_id" } - end - -* Fixed Base#clone for use with PostgreSQL #565 [hanson@surgery.wisc.edu] - - -*1.6.0* (January 25th, 2005) - -* Added that has_many association build and create methods can take arrays of record data like Base#create and Base#build to build/create multiple records at once. - -* Added that Base#delete and Base#destroy both can take an array of ids to delete/destroy #336 - -* Added the option of supplying an array of attributes to Base#create, so that multiple records can be created at once. - -* Added the option of supplying an array of ids and attributes to Base#update, so that multiple records can be updated at once (inspired by #526/Duane Johnson). Example - - people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy"} } - Person.update(people.keys, people.values) - -* Added ActiveRecord::Base.timestamps_gmt that can be set to true to make the automated timestamping use GMT instead of local time #520 [Scott Baron] - -* Added that update_all calls sanitize_sql on its updates argument, so stuff like MyRecord.update_all(['time = ?', Time.now]) works #519 [notahat] - -* Fixed that the dynamic finders didn't treat nil as a "IS NULL" but rather "= NULL" case #515 [Demetrius] - -* Added bind-named arrays for interpolating a group of ids or strings in conditions #528 [Jeremy Kemper] - -* Added that has_and_belongs_to_many associations with additional attributes also can be created between unsaved objects and only committed to the database when Base#save is called on the associator #524 [Eric Anderson] - -* Fixed that records fetched with piggy-back attributes or through rich has_and_belongs_to_many associations couldn't be saved due to the extra attributes not part of the table #522 [Eric Anderson] - -* Added mass-assignment protection for the inheritance column -- regardless of a custom column is used or not - -* Fixed that association proxies would fail === tests like PremiumSubscription === @account.subscription - -* Fixed that column aliases didn't work as expected with the new MySql411 driver #507 [Demetrius] - -* Fixed that find_all would produce invalid sql when called sequentialy #490 [Scott Baron] - - -*1.5.1* (January 18th, 2005) - -* Fixed that the belongs_to and has_one proxy would fail a test like 'if project.manager' -- this unfortunately also means that you can't call methods like project.manager.build unless there already is a manager on the project #492 [Tim Bates] - -* Fixed that the Ruby/MySQL adapter wouldn't connect if the password was empty #503 [Pelle] - - -*1.5.0* (January 17th, 2005) - -* Fixed that unit tests for MySQL are now run as the "rails" user instead of root #455 [Eric Hodel] - -* Added validates_associated that enables validation of objects in an unsaved association #398 [Tim Bates]. Example: - - class Book < ActiveRecord::Base - has_many :pages - belongs_to :library - - validates_associated :pages, :library - end - -* Added support for associating unsaved objects #402 [Tim Bates]. Rules that govern this addition: - - == Unsaved objects and associations - - You can manipulate objects and associations before they are saved to the database, but there is some special behaviour you should be - aware of, mostly involving the saving of associated objects. - - === One-to-one associations - - * Assigning an object to a has_one association automatically saves that object, and the object being replaced (if there is one), in - order to update their primary keys - except if the parent object is unsaved (new_record? == true). - * If either of these saves fail (due to one of the objects being invalid) the assignment statement returns false and the assignment - is cancelled. - * If you wish to assign an object to a has_one association without saving it, use the #association.build method (documented below). - * Assigning an object to a belongs_to association does not save the object, since the foreign key field belongs on the parent. It does - not save the parent either. - - === Collections - - * Adding an object to a collection (has_many or has_and_belongs_to_many) automatically saves that object, except if the parent object - (the owner of the collection) is not yet stored in the database. - * If saving any of the objects being added to a collection (via #push or similar) fails, then #push returns false. - * You can add an object to a collection without automatically saving it by using the #collection.build method (documented below). - * All unsaved (new_record? == true) members of the collection are automatically saved when the parent is saved. - -* Added replace to associations, so you can do project.manager.replace(new_manager) or project.milestones.replace(new_milestones) #402 [Tim Bates] - -* Added build and create methods to has_one and belongs_to associations, so you can now do project.manager.build(attributes) #402 [Tim Bates] - -* Added that if a before_* callback returns false, all the later callbacks and the associated action are cancelled. If an after_* callback returns false, all the later callbacks are cancelled. Callbacks are generally run in the order they are defined, with the exception of callbacks defined as methods on the model, which are called last. #402 [Tim Bates] - -* Fixed that Base#== wouldn't work for multiple references to the same unsaved object #402 [Tim Bates] - -* Fixed binary support for PostgreSQL #444 [alex@byzantine.no] - -* Added a differenciation between AssociationCollection#size and -length. Now AssociationCollection#size returns the size of the - collection by executing a SELECT COUNT(*) query if the collection hasn't been loaded and calling collection.size if it has. If - it's more likely than not that the collection does have a size larger than zero and you need to fetch that collection afterwards, - it'll take one less SELECT query if you use length. - -* Added Base#attributes that returns a hash of all the attributes with their names as keys and clones of their objects as values #433 [atyp.de] - -* Fixed that foreign keys named the same as the association would cause stack overflow #437 [Eric Anderson] - -* Fixed default scope of acts_as_list from "1" to "1 = 1", so it'll work in PostgreSQL (among other places) #427 [Alexey] - -* Added Base#reload that reloads the attributes of an object from the database #422 [Andreas Schwarz] - -* Added SQLite3 compatibility through the sqlite3-ruby adapter by Jamis Buck #381 [Jeremy Kemper] - -* Added support for the new protocol spoken by MySQL 4.1.1+ servers for the Ruby/MySQL adapter that ships with Rails #440 [Matt Mower] - -* Added that Observers can use the observes class method instead of overwriting self.observed_class(). - - Before: - class ListSweeper < ActiveRecord::Base - def self.observed_class() [ List, Item ] - end - - After: - class ListSweeper < ActiveRecord::Base - observes List, Item - end - -* Fixed that conditions in has_many and has_and_belongs_to_many should be interpolated just like the finder_sql is - -* Fixed Base#update_attribute to be indifferent to whether a string or symbol is used to describe the name - -* Added Base#toggle(attribute) and Base#toggle!(attribute) that makes it easier to flip a switch or flag. - - Before: topic.update_attribute(:approved, !approved?) - After : topic.toggle!(:approved) - -* Added Base#increment!(attribute) and Base#decrement!(attribute) that also saves the records. Example: - - page.views # => 1 - page.increment!(:views) # executes an UPDATE statement - page.views # => 2 - - page.increment(:views).increment!(:views) - page.views # => 4 - -* Added Base#increment(attribute) and Base#decrement(attribute) that encapsulates the += 1 and -= 1 patterns. - - - - -*1.14.2* (April 9th, 2005) - -* Fixed calculations for the Oracle Adapter (closes #4626) [Michael Schoen] - - -*1.14.1* (April 6th, 2006) - -* Fix type_name_with_module to handle type names that begin with '::'. Closes #4614. [Nicholas Seckar] - -* Fixed that that multiparameter assignment doesn't work with aggregations (closes #4620) [Lars Pind] - -* Enable Limit/Offset in Calculations (closes #4558) [lmarlow] - -* Fixed that loading including associations returns all results if Load IDs For Limited Eager Loading returns none (closes #4528) [Rick Olson] - -* Fixed HasManyAssociation#find bugs when :finder_sql is set #4600 [lagroue@free.fr] - -* Allow AR::Base#respond_to? to behave when @attributes is nil [Ryan Davis] - -* Support eager includes when going through a polymorphic has_many association. [Rick Olson] - -* Added support for eagerly including polymorphic has_one associations. (closes #4525) [Rick Olson] - - class Post < ActiveRecord::Base - has_one :tagging, :as => :taggable - end - - Post.find :all, :include => :tagging - -* Added descriptive error messages for invalid has_many :through associations: going through :has_one or :has_and_belongs_to_many [Rick Olson] - -* Added support for going through a polymorphic has_many association: (closes #4401) [Rick Olson] - - class PhotoCollection < ActiveRecord::Base - has_many :photos, :as => :photographic - belongs_to :firm - end - - class Firm < ActiveRecord::Base - has_many :photo_collections - has_many :photos, :through => :photo_collections - end - -* Multiple fixes and optimizations in PostgreSQL adapter, allowing ruby-postgres gem to work properly. [ruben.nine@gmail.com] - -* Fixed that AssociationCollection#delete_all should work even if the records of the association are not loaded yet. [Florian Weber] - -* Changed those private ActiveRecord methods to take optional third argument :auto instead of nil for performance optimizations. (closes #4456) [Stefan] - -* Private ActiveRecord methods add_limit!, add_joins!, and add_conditions! take an OPTIONAL third argument 'scope' (closes #4456) [Rick Olson] - -* DEPRECATED: Using additional attributes on has_and_belongs_to_many associations. Instead upgrade your association to be a real join model [David Heinemeier Hansson] - -* Fixed that records returned from has_and_belongs_to_many associations with additional attributes should be marked as read only (fixes #4512) [David Heinemeier Hansson] - -* Do not implicitly mark recordss of has_many :through as readonly but do mark habtm records as readonly (eventually only on join tables without rich attributes). [Marcel Mollina Jr.] - -* Fixed broken OCIAdapter #4457 [Michael Schoen] - - -*1.14.0* (March 27th, 2006) - -* Replace 'rescue Object' with a finer grained rescue. Closes #4431. [Nicholas Seckar] - -* Fixed eager loading so that an aliased table cannot clash with a has_and_belongs_to_many join table [Rick Olson] - -* Add support for :include to with_scope [andrew@redlinesoftware.com] - -* Support the use of public synonyms with the Oracle adapter; required ruby-oci8 v0.1.14 #4390 [Michael Schoen] - -* Change periods (.) in table aliases to _'s. Closes #4251 [jeff@ministrycentered.com] - -* Changed has_and_belongs_to_many join to INNER JOIN for Mysql 3.23.x. Closes #4348 [Rick Olson] - -* Fixed issue that kept :select options from being scoped [Rick Olson] - -* Fixed db_schema_import when binary types are present #3101 [David Heinemeier Hansson] - -* Fixed that MySQL enums should always be returned as strings #3501 [David Heinemeier Hansson] - -* Change has_many :through to use the :source option to specify the source association. :class_name is now ignored. [Rick Olson] - - class Connection < ActiveRecord::Base - belongs_to :user - belongs_to :channel - end - - class Channel < ActiveRecord::Base - has_many :connections - has_many :contacts, :through => :connections, :class_name => 'User' # OLD - has_many :contacts, :through => :connections, :source => :user # NEW - end - -* Fixed DB2 adapter so nullable columns will be determines correctly now and quotes from column default values will be removed #4350 [contact@maik-schmidt.de] - -* Allow overriding of find parameters in scoped has_many :through calls [Rick Olson] - - In this example, :include => false disables the default eager association from loading. :select changes the standard - select clause. :joins specifies a join that is added to the end of the has_many :through query. - - class Post < ActiveRecord::Base - has_many :tags, :through => :taggings, :include => :tagging do - def add_joins_and_select - find :all, :select => 'tags.*, authors.id as author_id', :include => false, - :joins => 'left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id' - end - end - end - -* Fixed that schema changes while the database was open would break any connections to a SQLite database (now we reconnect if that error is throw) [David Heinemeier Hansson] - -* Don't classify the has_one class when eager loading, it is already singular. Add tests. (closes #4117) [Jonathan Viney] - -* Quit ignoring default :include options in has_many :through calls [Mark James] - -* Allow has_many :through associations to find the source association by setting a custom class (closes #4307) [Jonathan Viney] - -* Eager Loading support added for has_many :through => :has_many associations (see below). [Rick Olson] - -* Allow has_many :through to work on has_many associations (closes #3864) [sco@scottraymond.net] Example: - - class Firm < ActiveRecord::Base - has_many :clients - has_many :invoices, :through => :clients - end - - class Client < ActiveRecord::Base - belongs_to :firm - has_many :invoices - end - - class Invoice < ActiveRecord::Base - belongs_to :client - end - -* Raise error when trying to select many polymorphic objects with has_many :through or :include (closes #4226) [Josh Susser] - -* Fixed has_many :through to include :conditions set on the :through association. closes #4020 [Jonathan Viney] - -* Fix that has_many :through honors the foreign key set by the belongs_to association in the join model (closes #4259) [andylien@gmail.com / Rick Olson] - -* SQL Server adapter gets some love #4298 [Ryan Tomayko] - -* Added OpenBase database adapter that builds on top of the http://www.spice-of-life.net/ruby-openbase/ driver. All functionality except LIMIT/OFFSET is supported #3528 [derrickspell@cdmplus.com] - -* Rework table aliasing to account for truncated table aliases. Add smarter table aliasing when doing eager loading of STI associations. This allows you to use the association name in the order/where clause. [Jonathan Viney / Rick Olson] #4108 Example (SpecialComment is using STI): - - Author.find(:all, :include => { :posts => :special_comments }, :order => 'special_comments.body') - -* Add AbstractAdapter#table_alias_for to create table aliases according to the rules of the current adapter. [Rick Olson] - -* Provide access to the underlying database connection through Adapter#raw_connection. Enables the use of db-specific methods without complicating the adapters. #2090 [Michael Koziarski] - -* Remove broken attempts at handling columns with a default of 'now()' in the postgresql adapter. #2257 [Michael Koziarski] - -* Added connection#current_database that'll return of the current database (only works in MySQL, SQL Server, and Oracle so far -- please help implement for the rest of the adapters) #3663 [Tom Ward] - -* Fixed that Migration#execute would have the table name prefix appended to its query #4110 [mark.imbriaco@pobox.com] - -* Make all tinyint(1) variants act like boolean in mysql (tinyint(1) unsigned, etc.) [Jamis Buck] - -* Use association's :conditions when eager loading. [Jeremy Evans] #4144 - -* Alias the has_and_belongs_to_many join table on eager includes. #4106 [Jeremy Evans] - - This statement would normally error because the projects_developers table is joined twice, and therefore joined_on would be ambiguous. - - Developer.find(:all, :include => {:projects => :developers}, :conditions => 'join_project_developers.joined_on IS NOT NULL') - -* Oracle adapter gets some love #4230 [Michael Schoen] - - * Changes :text to CLOB rather than BLOB [Moses Hohman] - * Fixes an issue with nil numeric length/scales (several) - * Implements support for XMLTYPE columns [wilig / Kubo Takehiro] - * Tweaks a unit test to get it all green again - * Adds support for #current_database - -* Added Base.abstract_class? that marks which classes are not part of the Active Record hierarchy #3704 [Rick Olson] - - class CachedModel < ActiveRecord::Base - self.abstract_class = true - end - - class Post < CachedModel - end - - CachedModel.abstract_class? - => true - - Post.abstract_class? - => false - - Post.base_class - => Post - - Post.table_name - => 'posts' - -* Allow :dependent options to be used with polymorphic joins. #3820 [Rick Olson] - - class Foo < ActiveRecord::Base - has_many :attachments, :as => :attachable, :dependent => :delete_all - end - -* Nicer error message on has_many :through when :through reflection can not be found. #4042 [court3nay] - -* Upgrade to Transaction::Simple 1.3 [Jamis Buck] - -* Catch FixtureClassNotFound when using instantiated fixtures on a fixture that has no ActiveRecord model [Rick Olson] - -* Allow ordering of calculated results and/or grouped fields in calculations [solo@gatelys.com] - -* Make ActiveRecord::Base#save! return true instead of nil on success. #4173 [johan@johansorensen.com] - -* Dynamically set allow_concurrency. #4044 [Stefan Kaes] - -* Added Base#to_xml that'll turn the current record into a XML representation [David Heinemeier Hansson]. Example: - - topic.to_xml - - ...returns: - - <?xml version="1.0" encoding="UTF-8"?> - <topic> - <title>The First Topic</title> - <author-name>David</author-name> - <id type="integer">1</id> - <approved type="boolean">false</approved> - <replies-count type="integer">0</replies-count> - <bonus-time type="datetime">2000-01-01 08:28:00</bonus-time> - <written-on type="datetime">2003-07-16 09:28:00</written-on> - <content>Have a nice day</content> - <author-email-address>david@loudthinking.com</author-email-address> - <parent-id></parent-id> - <last-read type="date">2004-04-15</last-read> - </topic> - - ...and you can configure with: - - topic.to_xml(:skip_instruct => true, :except => [ :id, bonus_time, :written_on, replies_count ]) - - ...that'll return: - - <topic> - <title>The First Topic</title> - <author-name>David</author-name> - <approved type="boolean">false</approved> - <content>Have a nice day</content> - <author-email-address>david@loudthinking.com</author-email-address> - <parent-id></parent-id> - <last-read type="date">2004-04-15</last-read> - </topic> - - You can even do load first-level associations as part of the document: - - firm.to_xml :include => [ :account, :clients ] - - ...that'll return something like: - - <?xml version="1.0" encoding="UTF-8"?> - <firm> - <id type="integer">1</id> - <rating type="integer">1</rating> - <name>37signals</name> - <clients> - <client> - <rating type="integer">1</rating> - <name>Summit</name> - </client> - <client> - <rating type="integer">1</rating> - <name>Microsoft</name> - </client> - </clients> - <account> - <id type="integer">1</id> - <credit-limit type="integer">50</credit-limit> - </account> - </firm> - -* Allow :counter_cache to take a column name for custom counter cache columns [Jamis Buck] - -* Documentation fixes for :dependent [robby@planetargon.com] - -* Stop the MySQL adapter crashing when views are present. #3782 [Jonathan Viney] - -* Don't classify the belongs_to class, it is already singular #4117 [keithm@infused.org] - -* Allow set_fixture_class to take Classes instead of strings for a class in a module. Raise FixtureClassNotFound if a fixture can't load. [Rick Olson] - -* Fix quoting of inheritance column for STI eager loading #4098 [Jonathan Viney <jonathan@bluewire.net.nz>] - -* Added smarter table aliasing for eager associations for multiple self joins #3580 [Rick Olson] - - * The first time a table is referenced in a join, no alias is used. - * After that, the parent class name and the reflection name are used. - - Tree.find(:all, :include => :children) # LEFT OUTER JOIN trees AS tree_children ... - - * Any additional join references get a numerical suffix like '_2', '_3', etc. - -* Fixed eager loading problems with single-table inheritance #3580 [Rick Olson]. Post.find(:all, :include => :special_comments) now returns all posts, and any special comments that the posts may have. And made STI work with has_many :through and polymorphic belongs_to. - -* Added cascading eager loading that allows for queries like Author.find(:all, :include=> { :posts=> :comments }), which will fetch all authors, their posts, and the comments belonging to those posts in a single query (using LEFT OUTER JOIN) #3913 [anna@wota.jp]. Examples: - - # cascaded in two levels - >> Author.find(:all, :include=>{:posts=>:comments}) - => authors - +- posts - +- comments - - # cascaded in two levels and normal association - >> Author.find(:all, :include=>[{:posts=>:comments}, :categorizations]) - => authors - +- posts - +- comments - +- categorizations - - # cascaded in two levels with two has_many associations - >> Author.find(:all, :include=>{:posts=>[:comments, :categorizations]}) - => authors - +- posts - +- comments - +- categorizations - - # cascaded in three levels - >> Company.find(:all, :include=>{:groups=>{:members=>{:favorites}}}) - => companies - +- groups - +- members - +- favorites - -* Make counter cache work when replacing an association #3245 [eugenol@gmail.com] - -* Make migrations verbose [Jamis Buck] - -* Make counter_cache work with polymorphic belongs_to [Jamis Buck] - -* Fixed that calling HasOneProxy#build_model repeatedly would cause saving to happen #4058 [anna@wota.jp] - -* Added Sybase database adapter that relies on the Sybase Open Client bindings (see http://raa.ruby-lang.org/project/sybase-ctlib) #3765 [John Sheets]. It's almost completely Active Record compliant (including migrations), but has the following caveats: - - * Does not support DATE SQL column types; use DATETIME instead. - * Date columns on HABTM join tables are returned as String, not Time. - * Insertions are potentially broken for :polymorphic join tables - * BLOB column access not yet fully supported - -* Clear stale, cached connections left behind by defunct threads. [Jeremy Kemper] - -* CHANGED DEFAULT: set ActiveRecord::Base.allow_concurrency to false. Most AR usage is in single-threaded applications. [Jeremy Kemper] - -* Renamed the "oci" adapter to "oracle", but kept the old name as an alias #4017 [Michael Schoen] - -* Fixed that Base.save should always return false if the save didn't succeed, including if it has halted by before_save's #1861, #2477 [David Heinemeier Hansson] - -* Speed up class -> connection caching and stale connection verification. #3979 [Stefan Kaes] - -* Add set_fixture_class to allow the use of table name accessors with models which use set_table_name. [Kevin Clark] - -* Added that fixtures to placed in subdirectories of the main fixture files are also loaded #3937 [dblack@wobblini.net] - -* Define attribute query methods to avoid method_missing calls. #3677 [Jonathan Viney] - -* ActiveRecord::Base.remove_connection explicitly closes database connections and doesn't corrupt the connection cache. Introducing the disconnect! instance method for the PostgreSQL, MySQL, and SQL Server adapters; implementations for the others are welcome. #3591 [Simon Stapleton, Tom Ward] - -* Added support for nested scopes #3407 [anna@wota.jp]. Examples: - - Developer.with_scope(:find => { :conditions => "salary > 10000", :limit => 10 }) do - Developer.find(:all) # => SELECT * FROM developers WHERE (salary > 10000) LIMIT 10 - - # inner rule is used. (all previous parameters are ignored) - Developer.with_exclusive_scope(:find => { :conditions => "name = 'Jamis'" }) do - Developer.find(:all) # => SELECT * FROM developers WHERE (name = 'Jamis') - end - - # parameters are merged - Developer.with_scope(:find => { :conditions => "name = 'Jamis'" }) do - Developer.find(:all) # => SELECT * FROM developers WHERE (( salary > 10000 ) AND ( name = 'Jamis' )) LIMIT 10 - end - end - -* Fixed db2 connection with empty user_name and auth options #3622 [phurley@gmail.com] - -* Fixed validates_length_of to work on UTF-8 strings by using characters instead of bytes #3699 [Masao Mutoh] - -* Fixed that reflections would bleed across class boundaries in single-table inheritance setups #3796 [Lars Pind] - -* Added calculations: Base.count, Base.average, Base.sum, Base.minimum, Base.maxmium, and the generic Base.calculate. All can be used with :group and :having. Calculations and statitics need no longer require custom SQL. #3958 [Rick Olson]. Examples: - - Person.average :age - Person.minimum :age - Person.maximum :age - Person.sum :salary, :group => :last_name - -* Renamed Errors#count to Errors#size but kept an alias for the old name (and included an alias for length too) #3920 [Luke Redpath] - -* Reflections don't attempt to resolve module nesting of association classes. Simplify type computation. [Jeremy Kemper] - -* Improved the Oracle OCI Adapter with better performance for column reflection (from #3210), fixes to migrations (from #3476 and #3742), tweaks to unit tests (from #3610), and improved documentation (from #2446) #3879 [Aggregated by schoenm@earthlink.net] - -* Fixed that the schema_info table used by ActiveRecord::Schema.define should respect table pre- and suffixes #3834 [rubyonrails@atyp.de] - -* Added :select option to Base.count that'll allow you to select something else than * to be counted on. Especially important for count queries using DISTINCT #3839 [Stefan Kaes] - -* Correct syntax error in mysql DDL, and make AAACreateTablesTest run first [Bob Silva] - -* Allow :include to be used with has_many :through associations #3611 [Michael Schoen] - -* PostgreSQL: smarter schema dumps using pk_and_sequence_for(table). #2920 [Blair Zajac] - -* SQLServer: more compatible limit/offset emulation. #3779 [Tom Ward] - -* Polymorphic join support for has_one associations (has_one :foo, :as => :bar) #3785 [Rick Olson] - -* PostgreSQL: correctly parse negative integer column defaults. #3776 [bellis@deepthought.org] - -* Fix problems with count when used with :include [Jeremy Hopple and Kevin Clark] - -* ActiveRecord::RecordInvalid now states which validations failed in its default error message [Tobias Lütke] - -* Using AssociationCollection#build with arrays of hashes should call build, not create [David Heinemeier Hansson] - -* Remove definition of reloadable? from ActiveRecord::Base to make way for new Reloadable code. [Nicholas Seckar] - -* Fixed schema handling for DB2 adapter that didn't work: an initial schema could be set, but it wasn't used when getting tables and indexes #3678 [Maik Schmidt] - -* Support the :column option for remove_index with the PostgreSQL adapter. #3661 [Shugo Maeda] - -* Add documentation for add_index and remove_index. #3600 [Manfred Stienstra <m.stienstra@fngtps.com>] - -* If the OCI library is not available, raise an exception indicating as much. #3593 [Michael Schoen] - -* Add explicit :order in finder tests as postgresql orders results differently by default. #3577. [Rick Olson] - -* Make dynamic finders honor additional passed in :conditions. #3569 [Oleg Pudeyev <pudeyo@rpi.edu>, Marcel Molina Jr.] - -* Show a meaningful error when the DB2 adapter cannot be loaded due to missing dependencies. [Nicholas Seckar] - -* Make .count work for has_many associations with multi line finder sql [Michael Schoen] - -* Add AR::Base.base_class for querying the ancestor AR::Base subclass [Jamis Buck] - -* Allow configuration of the column used for optimistic locking [wilsonb@gmail.com] - -* Don't hardcode 'id' in acts as list. [ror@philippeapril.com] - -* Fix date errors for SQLServer in association tests. #3406 [Kevin Clark] - -* Escape database name in MySQL adapter when creating and dropping databases. #3409 [anna@wota.jp] - -* Disambiguate table names for columns in validates_uniquness_of's WHERE clause. #3423 [alex.borovsky@gmail.com] - -* .with_scope imposed create parameters now bypass attr_protected [Tobias Lütke] - -* Don't raise an exception when there are more keys than there are named bind variables when sanitizing conditions. [Marcel Molina Jr.] - -* Multiple enhancements and adjustments to DB2 adaptor. #3377 [contact@maik-schmidt.de] - -* Sanitize scoped conditions. [Marcel Molina Jr.] - -* Added option to Base.reflection_of_all_associations to specify a specific association to scope the call. For example Base.reflection_of_all_associations(:has_many) [David Heinemeier Hansson] - -* Added ActiveRecord::SchemaDumper.ignore_tables which tells SchemaDumper which tables to ignore. Useful for tables with funky column like the ones required for tsearch2. [Tobias Lütke] - -* SchemaDumper now doesn't fail anymore when there are unknown column types in the schema. Instead the table is ignored and a Comment is left in the schema.rb. [Tobias Lütke] - -* Fixed that saving a model with multiple habtm associations would only save the first one. #3244 [yanowitz-rubyonrails@quantumfoam.org, Florian Weber] - -* Fix change_column to work with PostgreSQL 7.x and 8.x. #3141 [wejn@box.cz, Rick Olson, Scott Barron] - -* removed :piggyback in favor of just allowing :select on :through associations. [Tobias Lütke] - -* made method missing delegation to class methods on relation target work on :through associations. [Tobias Lütke] - -* made .find() work on :through relations. [Tobias Lütke] - -* Fix typo in association docs. #3296. [Blair Zajac] - -* Fixed :through relations when using STI inherited classes would use the inherited class's name as foreign key on the join model [Tobias Lütke] - -*1.13.2* (December 13th, 2005) - -* Become part of Rails 1.0 - -* MySQL: allow encoding option for mysql.rb driver. [Jeremy Kemper] - -* Added option inheritance for find calls on has_and_belongs_to_many and has_many assosociations [David Heinemeier Hansson]. Example: - - class Post - has_many :recent_comments, :class_name => "Comment", :limit => 10, :include => :author - end - - post.recent_comments.find(:all) # Uses LIMIT 10 and includes authors - post.recent_comments.find(:all, :limit => nil) # Uses no limit but include authors - post.recent_comments.find(:all, :limit => nil, :include => nil) # Uses no limit and doesn't include authors - -* Added option to specify :group, :limit, :offset, and :select options from find on has_and_belongs_to_many and has_many assosociations [David Heinemeier Hansson] - -* MySQL: fixes for the bundled mysql.rb driver. #3160 [Justin Forder] - -* SQLServer: fix obscure optimistic locking bug. #3068 [kajism@yahoo.com] - -* SQLServer: support uniqueidentifier columns. #2930 [keithm@infused.org] - -* SQLServer: cope with tables names qualified by owner. #3067 [jeff@ministrycentered.com] - -* SQLServer: cope with columns with "desc" in the name. #1950 [Ron Lusk, Ryan Tomayko] - -* SQLServer: cope with primary keys with "select" in the name. #3057 [rdifrango@captechventures.com] - -* Oracle: active? performs a select instead of a commit. #3133 [Michael Schoen] - -* MySQL: more robust test for nullified result hashes. #3124 [Stefan Kaes] - -* Reloading an instance refreshes its aggregations as well as its associations. #3024 [François Beausoleil] - -* Fixed that using :include together with :conditions array in Base.find would cause NoMethodError #2887 [Paul Hammmond] - -* PostgreSQL: more robust sequence name discovery. #3087 [Rick Olson] - -* Oracle: use syntax compatible with Oracle 8. #3131 [Michael Schoen] - -* MySQL: work around ruby-mysql/mysql-ruby inconsistency with mysql.stat. Eliminate usage of mysql.ping because it doesn't guarantee reconnect. Explicitly close and reopen the connection instead. [Jeremy Kemper] - -* Added preliminary support for polymorphic associations [David Heinemeier Hansson] - -* Added preliminary support for join models [David Heinemeier Hansson] - -* Allow validate_uniqueness_of to be scoped by more than just one column. #1559. [jeremy@jthopple.com, Marcel Molina Jr.] - -* Firebird: active? and reconnect! methods for handling stale connections. #428 [Ken Kunz <kennethkunz@gmail.com>] - -* Firebird: updated for FireRuby 0.4.0. #3009 [Ken Kunz <kennethkunz@gmail.com>] - -* MySQL and PostgreSQL: active? compatibility with the pure-Ruby driver. #428 [Jeremy Kemper] - -* Oracle: active? check pings the database rather than testing the last command status. #428 [Michael Schoen] - -* SQLServer: resolve column aliasing/quoting collision when using limit or offset in an eager find. #2974 [kajism@yahoo.com] - -* Reloading a model doesn't lose track of its connection. #2996 [junk@miriamtech.com, Jeremy Kemper] - -* Fixed bug where using update_attribute after pushing a record to a habtm association of the object caused duplicate rows in the join table. #2888 [colman@rominato.com, Florian Weber, Michael Schoen] - -* MySQL, PostgreSQL: reconnect! also reconfigures the connection. Otherwise, the connection 'loses' its settings if it times out and is reconnected. #2978 [Shugo Maeda] - -* has_and_belongs_to_many: use JOIN instead of LEFT JOIN. [Jeremy Kemper] - -* MySQL: introduce :encoding option to specify the character set for client, connection, and results. Only available for MySQL 4.1 and later with the mysql-ruby driver. Do SHOW CHARACTER SET in mysql client to see available encodings. #2975 [Shugo Maeda] - -* Add tasks to create, drop and rebuild the MySQL and PostgreSQL test databases. [Marcel Molina Jr.] - -* Correct boolean handling in generated reader methods. #2945 [Don Park, Stefan Kaes] - -* Don't generate read methods for columns whose names are not valid ruby method names. #2946 [Stefan Kaes] - -* Document :force option to create_table. #2921 [Blair Zajac <blair@orcaware.com>] - -* Don't add the same conditions twice in has_one finder sql. #2916 [Jeremy Evans] - -* Rename Version constant to VERSION. #2802 [Marcel Molina Jr.] - -* Introducing the Firebird adapter. Quote columns and use attribute_condition more consistently. Setup guide: http://wiki.rubyonrails.com/rails/pages/Firebird+Adapter #1874 [Ken Kunz <kennethkunz@gmail.com>] - -* SQLServer: active? and reconnect! methods for handling stale connections. #428 [kajism@yahoo.com, Tom Ward <tom@popdog.net>] - -* Associations handle case-equality more consistently: item.parts.is_a?(Array) and item.parts === Array. #1345 [MarkusQ@reality.com] - -* SQLServer: insert uses given primary key value if not nil rather than SELECT @@IDENTITY. #2866 [kajism@yahoo.com, Tom Ward <tom@popdog.net>] - -* Oracle: active? and reconnect! methods for handling stale connections. Optionally retry queries after reconnect. #428 [Michael Schoen <schoenm@earthlink.net>] - -* Correct documentation for Base.delete_all. #1568 [Newhydra] - -* Oracle: test case for column default parsing. #2788 [Michael Schoen <schoenm@earthlink.net>] - -* Update documentation for Migrations. #2861 [Tom Werner <tom@cube6media.com>] - -* When AbstractAdapter#log rescues an exception, attempt to detect and reconnect to an inactive database connection. Connection adapter must respond to the active? and reconnect! instance methods. Initial support for PostgreSQL, MySQL, and SQLite. Make certain that all statements which may need reconnection are performed within a logged block: for example, this means no avoiding log(sql, name) { } if @logger.nil? #428 [Jeremy Kemper] - -* Oracle: Much faster column reflection. #2848 [Michael Schoen <schoenm@earthlink.net>] - -* Base.reset_sequence_name analogous to reset_table_name (mostly useful for testing). Base.define_attr_method allows nil values. [Jeremy Kemper] - -* PostgreSQL: smarter sequence name defaults, stricter last_insert_id, warn on pk without sequence. [Jeremy Kemper] - -* PostgreSQL: correctly discover custom primary key sequences. #2594 [Blair Zajac <blair@orcaware.com>, meadow.nnick@gmail.com, Jeremy Kemper] - -* SQLServer: don't report limits for unsupported field types. #2835 [Ryan Tomayko] - -* Include the Enumerable module in ActiveRecord::Errors. [Rick Bradley <rick@rickbradley.com>] - -* Add :group option, correspond to GROUP BY, to the find method and to the has_many association. #2818 [rubyonrails@atyp.de] - -* Don't cast nil or empty strings to a dummy date. #2789 [Rick Bradley <rick@rickbradley.com>] - -* acts_as_list plays nicely with inheritance by remembering the class which declared it. #2811 [rephorm@rephorm.com] - -* Fix sqlite adaptor's detection of missing dbfile or database declaration. [Nicholas Seckar] - -* Fixed acts_as_list for definitions without an explicit :order #2803 [Jonathan Viney] - -* Upgrade bundled ruby-mysql 0.2.4 with mysql411 shim (see #440) to ruby-mysql 0.2.6 with a patchset for 4.1 protocol support. Local change [301] is now a part of the main driver; reapplied local change [2182]. Removed GC.start from Result.free. [tommy@tmtm.org, akuroda@gmail.com, Doug Fales <doug.fales@gmail.com>, Jeremy Kemper] - -* Correct handling of complex order clauses with SQL Server limit emulation. #2770 [Tom Ward <tom@popdog.net>, Matt B.] - -* Correct whitespace problem in Oracle default column value parsing. #2788 [rick@rickbradley.com] - -* Destroy associated has_and_belongs_to_many records after all before_destroy callbacks but before destroy. This allows you to act on the habtm association as you please while preserving referential integrity. #2065 [larrywilliams1@gmail.com, sam.kirchmeier@gmail.com, elliot@townx.org, Jeremy Kemper] - -* Deprecate the old, confusing :exclusively_dependent option in favor of :dependent => :delete_all. [Jeremy Kemper] - -* More compatible Oracle column reflection. #2771 [Ryan Davis <ryand-ruby@zenspider.com>, Michael Schoen <schoenm@earthlink.net>] - - -*1.13.0* (November 7th, 2005) - -* Fixed faulty regex in get_table_name method (SQLServerAdapter) #2639 [Ryan Tomayko] - -* Added :include as an option for association declarations [David Heinemeier Hansson]. Example: - - has_many :posts, :include => [ :author, :comments ] - -* Rename Base.constrain to Base.with_scope so it doesn't conflict with existing concept of database constraints. Make scoping more robust: uniform method => parameters, validated method names and supported finder parameters, raise exception on nested scopes. [Jeremy Kemper] Example: - - Comment.with_scope(:find => { :conditions => 'active=true' }, :create => { :post_id => 5 }) do - # Find where name = ? and active=true - Comment.find :all, :conditions => ['name = ?', name] - # Create comment associated with :post_id - Comment.create :body => "Hello world" - end - -* Fixed that SQL Server should ignore :size declarations on anything but integer and string in the agnostic schema representation #2756 [Ryan Tomayko] - -* Added constrain scoping for creates using a hash of attributes bound to the :creation key [David Heinemeier Hansson]. Example: - - Comment.constrain(:creation => { :post_id => 5 }) do - # Associated with :post_id - Comment.create :body => "Hello world" - end - - This is rarely used directly, but allows for find_or_create on associations. So you can do: - - # If the tag doesn't exist, a new one is created that's associated with the person - person.tags.find_or_create_by_name("Summer") - -* Added find_or_create_by_X as a second type of dynamic finder that'll create the record if it doesn't already exist [David Heinemeier Hansson]. Example: - - # No 'Summer' tag exists - Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer") - - # Now the 'Summer' tag does exist - Tag.find_or_create_by_name("Summer") # equal to Tag.find_by_name("Summer") - -* Added extension capabilities to has_many and has_and_belongs_to_many proxies [David Heinemeier Hansson]. Example: - - class Account < ActiveRecord::Base - has_many :people do - def find_or_create_by_name(name) - first_name, *last_name = name.split - last_name = last_name.join " " - - find_or_create_by_first_name_and_last_name(first_name, last_name) - end - end - end - - person = Account.find(:first).people.find_or_create_by_name("David Heinemeier Hansson") - person.first_name # => "David" - person.last_name # => "Heinemeier Hansson" - - Note that the anoymous module must be declared using brackets, not do/end (due to order of evaluation). - -* Omit internal dtproperties table from SQLServer table list. #2729 [Ryan Tomayko] - -* Quote column names in generated SQL. #2728 [Ryan Tomayko] - -* Correct the pure-Ruby MySQL 4.1.1 shim's version test. #2718 [Jeremy Kemper] - -* Add Model.create! to match existing model.save! method. When save! raises RecordInvalid, you can catch the exception, retrieve the invalid record (invalid_exception.record), and see its errors (invalid_exception.record.errors). [Jeremy Kemper] - -* Correct fixture behavior when table name pluralization is off. #2719 [Rick Bradley <rick@rickbradley.com>] - -* Changed :dbfile to :database for SQLite adapter for consistency (old key still works as an alias) #2644 [Dan Peterson] - -* Added migration support for Oracle #2647 [Michael Schoen] - -* Worked around that connection can't be reset if allow_concurrency is off. #2648 [Michael Schoen <schoenm@earthlink.net>] - -* Fixed SQL Server adapter to pass even more tests and do even better #2634 [Ryan Tomayko] - -* Fixed SQL Server adapter so it honors options[:conditions] when applying :limits #1978 [Tom Ward] - -* Added migration support to SQL Server adapter (please someone do the same for Oracle and DB2) #2625 [Tom Ward] - -* Use AR::Base.silence rather than AR::Base.logger.silence in fixtures to preserve Log4r compatibility. #2618 [dansketcher@gmail.com] - -* Constraints are cloned so they can't be inadvertently modified while they're -in effect. Added :readonly finder constraint. Calling an association collection's class method (Part.foobar via item.parts.foobar) constrains :readonly => false since the collection's :joins constraint would otherwise force it to true. [Jeremy Kemper <rails@bitsweat.net>] - -* Added :offset and :limit to the kinds of options that Base.constrain can use #2466 [duane.johnson@gmail.com] - -* Fixed handling of nil number columns on Oracle and cleaned up tests for Oracle in general #2555 [Michael Schoen] - -* Added quoted_true and quoted_false methods and tables to db2_adapter and cleaned up tests for DB2 #2493, #2624 [maik schmidt] - - -*1.12.2* (October 26th, 2005) - -* Allow symbols to rename columns when using SQLite adapter. #2531 [Kevin Clark] - -* Map Active Record time to SQL TIME. #2575, #2576 [Robby Russell <robby@planetargon.com>] - -* Clarify semantics of ActiveRecord::Base#respond_to? #2560 [Stefan Kaes] - -* Fixed Association#clear for associations which have not yet been accessed. #2524 [Patrick Lenz <patrick@lenz.sh>] - -* HABTM finders shouldn't return readonly records. #2525 [Patrick Lenz <patrick@lenz.sh>] - -* Make all tests runnable on their own. #2521. [Blair Zajac <blair@orcaware.com>] - - -*1.12.1* (October 19th, 2005) - -* Always parenthesize :conditions options so they may be safely combined with STI and constraints. - -* Correct PostgreSQL primary key sequence detection. #2507 [tmornini@infomania.com] - -* Added support for using limits in eager loads that involve has_many and has_and_belongs_to_many associations - - -*1.12.0* (October 16th, 2005) - -* Update/clean up documentation (rdoc) - -* PostgreSQL sequence support. Use set_sequence_name in your model class to specify its primary key sequence. #2292 [Rick Olson <technoweenie@gmail.com>, Robby Russell <robby@planetargon.com>] - -* Change default logging colors to work on both white and black backgrounds. [Sam Stephenson] - -* YAML fixtures support ordered hashes for fixtures with foreign key dependencies in the same table. #1896 [purestorm@ggnore.net] - -* :dependent now accepts :nullify option. Sets the foreign key of the related objects to NULL instead of deleting them. #2015 [Robby Russell <robby@planetargon.com>] - -* Introduce read-only records. If you call object.readonly! then it will mark the object as read-only and raise ReadOnlyRecord if you call object.save. object.readonly? reports whether the object is read-only. Passing :readonly => true to any finder method will mark returned records as read-only. The :joins option now implies :readonly, so if you use this option, saving the same record will now fail. Use find_by_sql to work around. - -* Avoid memleak in dev mode when using fcgi - -* Simplified .clear on active record associations by using the existing delete_records method. #1906 [Caleb <me@cpb.ca>] - -* Delegate access to a customized primary key to the conventional id method. #2444. [Blair Zajac <blair@orcaware.com>] - -* Fix errors caused by assigning a has-one or belongs-to property to itself - -* Add ActiveRecord::Base.schema_format setting which specifies how databases should be dumped [Sam Stephenson] - -* Update DB2 adapter. #2206. [contact@maik-schmidt.de] - -* Corrections to SQLServer native data types. #2267. [rails.20.clarry@spamgourmet.com] - -* Deprecated ActiveRecord::Base.threaded_connection in favor of ActiveRecord::Base.allow_concurrency. - -* Protect id attribute from mass assigment even when the primary key is set to something else. #2438. [Blair Zajac <blair@orcaware.com>] - -* Misc doc fixes (typos/grammar/etc.). #2430. [coffee2code] - -* Add test coverage for content_columns. #2432. [coffee2code] - -* Speed up for unthreaded environments. #2431. [Stefan Kaes] - -* Optimization for Mysql selects using mysql-ruby extension greater than 2.6.3. #2426. [Stefan Kaes] - -* Speed up the setting of table_name. #2428. [Stefan Kaes] - -* Optimize instantiation of STI subclass records. In partial fullfilment of #1236. [Stefan Kaes] - -* Fix typo of 'constrains' to 'contraints'. #2069. [Michael Schuerig <michael@schuerig.de>] - -* Optimization refactoring for add_limit_offset!. In partial fullfilment of #1236. [Stefan Kaes] - -* Add ability to get all siblings, including the current child, with acts_as_tree. Recloses #2140. [Michael Schuerig <michael@schuerig.de>] - -* Add geometric type for postgresql adapter. #2233 [Andrew Kaspick] - -* Add option (true by default) to generate reader methods for each attribute of a record to avoid the overhead of calling method missing. In partial fullfilment of #1236. [Stefan Kaes] - -* Add convenience predicate methods on Column class. In partial fullfilment of #1236. [Stefan Kaes] - -* Raise errors when invalid hash keys are passed to ActiveRecord::Base.find. #2363 [Chad Fowler <chad@chadfowler.com>, Nicholas Seckar] - -* Added :force option to create_table that'll try to drop the table if it already exists before creating - -* Fix transactions so that calling return while inside a transaction will not leave an open transaction on the connection. [Nicholas Seckar] - -* Use foreign_key inflection uniformly. #2156 [Blair Zajac <blair@orcaware.com>] - -* model.association.clear should destroy associated objects if :dependent => true instead of nullifying their foreign keys. #2221 [joergd@pobox.com, ObieFernandez <obiefernandez@gmail.com>] - -* Returning false from before_destroy should cancel the action. #1829 [Jeremy Huffman] - -* Recognize PostgreSQL NOW() default as equivalent to CURRENT_TIMESTAMP or CURRENT_DATE, depending on the column's type. #2256 [mat <mat@absolight.fr>] - -* Extensive documentation for the abstract database adapter. #2250 [François Beausoleil <fbeausoleil@ftml.net>] - -* Clean up Fixtures.reset_sequences for PostgreSQL. Handle tables with no rows and models with custom primary keys. #2174, #2183 [jay@jay.fm, Blair Zajac <blair@orcaware.com>] - -* Improve error message when nil is assigned to an attr which validates_size_of within a range. #2022 [Manuel Holtgrewe <purestorm@ggnore.net>] - -* Make update_attribute use the same writer method that update_attributes uses. - #2237 [trevor@protocool.com] - -* Make migrations honor table name prefixes and suffixes. #2298 [Jakob Skjerning, Marcel Molina Jr.] - -* Correct and optimize PostgreSQL bytea escaping. #1745, #1837 [dave@cherryville.org, ken@miriamtech.com, bellis@deepthought.org] - -* Fixtures should only reset a PostgreSQL sequence if it corresponds to an integer primary key named id. #1749 [chris@chrisbrinker.com] - -* Standardize the interpretation of boolean columns in the Mysql and Sqlite adapters. (Use MysqlAdapter.emulate_booleans = false to disable this behavior) - -* Added new symbol-driven approach to activating observers with Base#observers= [David Heinemeier Hansson]. Example: - - ActiveRecord::Base.observers = :cacher, :garbage_collector - -* Added AbstractAdapter#select_value and AbstractAdapter#select_values as convenience methods for selecting single values, instead of hashes, of the first column in a SELECT #2283 [solo@gatelys.com] - -* Wrap :conditions in parentheses to prevent problems with OR's #1871 [Jamis Buck] - -* Allow the postgresql adapter to work with the SchemaDumper. [Jamis Buck] - -* Add ActiveRecord::SchemaDumper for dumping a DB schema to a pure-ruby file, making it easier to consolidate large migration lists and port database schemas between databases. [Jamis Buck] - -* Fixed migrations for Windows when using more than 10 [David Naseby] - -* Fixed that the create_x method from belongs_to wouldn't save the association properly #2042 [Florian Weber] - -* Fixed saving a record with two unsaved belongs_to associations pointing to the same object #2023 [Tobias Lütke] - -* Improved migrations' behavior when the schema_info table is empty. [Nicholas Seckar] - -* Fixed that Observers didn't observe sub-classes #627 [Florian Weber] - -* Fix eager loading error messages, allow :include to specify tables using strings or symbols. Closes #2222 [Marcel Molina Jr.] - -* Added check for RAILS_CONNECTION_ADAPTERS on startup and only load the connection adapters specified within if its present (available in Rails through config.connection_adapters using the new config) #1958 [skae] - -* Fixed various problems with has_and_belongs_to_many when using customer finder_sql #2094 [Florian Weber] - -* Added better exception error when unknown column types are used with migrations #1814 [François Beausoleil] - -* Fixed "connection lost" issue with the bundled Ruby/MySQL driver (would kill the app after 8 hours of inactivity) #2163, #428 [kajism@yahoo.com] - -* Fixed comparison of Active Record objects so two new objects are not equal #2099 [deberg] - -* Fixed that the SQL Server adapter would sometimes return DBI::Timestamp objects instead of Time #2127 [Tom Ward] - -* Added the instance methods #root and #ancestors on acts_as_tree and fixed siblings to not include the current node #2142, #2140 [coffee2code] - -* Fixed that Active Record would call SHOW FIELDS twice (or more) for the same model when the cached results were available #1947 [sd@notso.net] - -* Added log_level and use_silence parameter to ActiveRecord::Base.benchmark. The first controls at what level the benchmark statement will be logged (now as debug, instead of info) and the second that can be passed false to include all logging statements during the benchmark block/ - -* Make sure the schema_info table is created before querying the current version #1903 - -* Fixtures ignore table name prefix and suffix #1987 [Jakob Skjerning] - -* Add documentation for index_type argument to add_index method for migrations #2005 [Blaine] - -* Modify read_attribute to allow a symbol argument #2024 [Ken Kunz] - -* Make destroy return self #1913 [Sebastian Kanthak] - -* Fix typo in validations documentation #1938 [court3nay] - -* Make acts_as_list work for insert_at(1) #1966 [hensleyl@papermountain.org] - -* Fix typo in count_by_sql documentation #1969 [Alexey Verkhovsky] - -* Allow add_column and create_table to specify NOT NULL #1712 [emptysands@gmail.com] - -* Fix create_table so that id column is implicitly added [Rick Olson] - -* Default sequence names for Oracle changed to #{table_name}_seq, which is the most commonly used standard. In addition, a new method ActiveRecord::Base#set_sequence_name allows the developer to set the sequence name per model. This is a non-backwards-compatible change -- anyone using the old-style "rails_sequence" will need to either create new sequences, or set: ActiveRecord::Base.set_sequence_name = "rails_sequence" #1798 - -* OCIAdapter now properly handles synonyms, which are commonly used to separate out the schema owner from the application user #1798 - -* Fixed the handling of camelCase columns names in Oracle #1798 - -* Implemented for OCI the Rakefile tasks of :clone_structure_to_test, :db_structure_dump, and :purge_test_database, which enable Oracle folks to enjoy all the agile goodness of Rails for testing. Note that the current implementation is fairly limited -- only tables and sequences are cloned, not constraints or indexes. A full clone in Oracle generally requires some manual effort, and is version-specific. Post 9i, Oracle recommends the use of the DBMS_METADATA package, though that approach requires editing of the physical characteristics generated #1798 - -* Fixed the handling of multiple blob columns in Oracle if one or more of them are null #1798 - -* Added support for calling constrained class methods on has_many and has_and_belongs_to_many collections #1764 [Tobias Lütke] - - class Comment < AR:B - def self.search(q) - find(:all, :conditions => ["body = ?", q]) - end - end - - class Post < AR:B - has_many :comments - end - - Post.find(1).comments.search('hi') # => SELECT * from comments WHERE post_id = 1 AND body = 'hi' - - NOTICE: This patch changes the underlying SQL generated by has_and_belongs_to_many queries. If your relying on that, such as - by explicitly referencing the old t and j aliases, you'll need to update your code. Of course, you _shouldn't_ be relying on - details like that no less than you should be diving in to touch private variables. But just in case you do, consider yourself - noticed :) - -* Added migration support for SQLite (using temporary tables to simulate ALTER TABLE) #1771 [Sam Stephenson] - -* Remove extra definition of supports_migrations? from abstract_adaptor.rb [Nicholas Seckar] - -* Fix acts_as_list so that moving next-to-last item to the bottom does not result in duplicate item positions - -* Fixed incompatibility in DB2 adapter with the new limit/offset approach #1718 [Maik Schmidt] - -* Added :select option to find which can specify a different value than the default *, like find(:all, :select => "first_name, last_name"), if you either only want to select part of the columns or exclude columns otherwise included from a join #1338 [Stefan Kaes] - - -*1.11.1* (11 July, 2005) - -* Added support for limit and offset with eager loading of has_one and belongs_to associations. Using the options with has_many and has_and_belongs_to_many associations will now raise an ActiveRecord::ConfigurationError #1692 [Rick Olson] - -* Fixed that assume_bottom_position (in acts_as_list) could be called on items already last in the list and they would move one position away from the list #1648 [tyler@kianta.com] - -* Added ActiveRecord::Base.threaded_connections flag to turn off 1-connection per thread (required for thread safety). By default it's on, but WEBrick in Rails need it off #1685 [Sam Stephenson] - -* Correct reflected table name for singular associations. #1688 [court3nay] - -* Fixed optimistic locking with SQL Server #1660 [tom@popdog.net] - -* Added ActiveRecord::Migrator.migrate that can figure out whether to go up or down based on the target version and the current - -* Added better error message for "packets out of order" #1630 [court3nay] - -* Fixed first run of "rake migrate" on PostgreSQL by not expecting a return value on the id #1640 - - -*1.11.0* (6 July, 2005) - -* Fixed that Yaml error message in fixtures hid the real error #1623 [Nicholas Seckar] - -* Changed logging of SQL statements to use the DEBUG level instead of INFO - -* Added new Migrations framework for describing schema transformations in a way that can be easily applied across multiple databases #1604 [Tobias Lütke] See documentation under ActiveRecord::Migration and the additional support in the Rails rakefile/generator. - -* Added callback hooks to association collections #1549 [Florian Weber]. Example: - - class Project - has_and_belongs_to_many :developers, :before_add => :evaluate_velocity - - def evaluate_velocity(developer) - ... - end - end - - ..raising an exception will cause the object not to be added (or removed, with before_remove). - - -* Fixed Base.content_columns call for SQL Server adapter #1450 [DeLynn Berry] - -* Fixed Base#write_attribute to work with both symbols and strings #1190 [Paul Legato] - -* Fixed that has_and_belongs_to_many didn't respect single table inheritance types #1081 [Florian Weber] - -* Speed up ActiveRecord#method_missing for the common case (read_attribute). - -* Only notify observers on after_find and after_initialize if these methods are defined on the model. #1235 [Stefan Kaes] - -* Fixed that single-table inheritance sub-classes couldn't be used to limit the result set with eager loading #1215 [Chris McGrath] - -* Fixed validates_numericality_of to work with overrided getter-method when :allow_nil is on #1316 [raidel@onemail.at] - -* Added roots, root, and siblings to the batch of methods added by acts_as_tree #1541 [Michael Schuerig] - -* Added support for limit/offset with the MS SQL Server driver so that pagination will now work #1569 [DeLynn Berry] - -* Added support for ODBC connections to MS SQL Server so you can connect from a non-Windows machine #1569 [Mark Imbriaco/DeLynn Berry] - -* Fixed that multiparameter posts ignored attr_protected #1532 [alec+rails@veryclever.net] - -* Fixed problem with eager loading when using a has_and_belongs_to_many association using :association_foreign_key #1504 [flash@vanklinkenbergsoftware.nl] - -* Fixed Base#find to honor the documentation on how :joins work and make them consistent with Base#count #1405 [pritchie@gmail.com]. What used to be: - - Developer.find :all, :joins => 'developers_projects', :conditions => 'id=developer_id AND project_id=1' - - ...should instead be: - - Developer.find( - :all, - :joins => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id', - :conditions => 'project_id=1' - ) - -* Fixed that validations didn't respecting custom setting for too_short, too_long messages #1437 [Marcel Molina Jr.] - -* Fixed that clear_association_cache doesn't delete new associations on new records (so you can safely place new records in the session with Action Pack without having new associations wiped) #1494 [cluon] - -* Fixed that calling Model.find([]) returns [] and doesn't throw an exception #1379 - -* Fixed that adding a record to a has_and_belongs_to collection would always save it -- now it only saves if its a new record #1203 [Alisdair McDiarmid] - -* Fixed saving of in-memory association structures to happen as a after_create/after_update callback instead of after_save -- that way you can add new associations in after_create/after_update callbacks without getting them saved twice - -* Allow any Enumerable, not just Array, to work as bind variables #1344 [Jeremy Kemper] - -* Added actual database-changing behavior to collection assigment for has_many and has_and_belongs_to_many #1425 [Sebastian Kanthak]. - Example: - - david.projects = [Project.find(1), Project.new("name" => "ActionWebSearch")] - david.save - - If david.projects already contain the project with ID 1, this is left unchanged. Any other projects are dropped. And the new - project is saved when david.save is called. - - Also included is a way to do assignments through IDs, which is perfect for checkbox updating, so you get to do: - - david.project_ids = [1, 5, 7] - -* Corrected typo in find SQL for has_and_belongs_to_many. #1312 [ben@bensinclair.com] - -* Fixed sanitized conditions for has_many finder method. #1281 [jackc@hylesanderson.com, pragdave, Tobias Lütke] - -* Comprehensive PostgreSQL schema support. Use the optional schema_search_path directive in database.yml to give a comma-separated list of schemas to search for your tables. This allows you, for example, to have tables in a shared schema without having to use a custom table name. See http://www.postgresql.org/docs/8.0/interactive/ddl-schemas.html to learn more. #827 [dave@cherryville.org] - -* Corrected @@configurations typo #1410 [david@ruppconsulting.com] - -* Return PostgreSQL columns in the order they were declared #1374 [perlguy@gmail.com] - -* Allow before/after update hooks to work on models using optimistic locking - -* Eager loading of dependent has_one associations won't delete the association #1212 - -* Added a second parameter to the build and create method for has_one that controls whether the existing association should be replaced (which means nullifying its foreign key as well). By default this is true, but false can be passed to prevent it. - -* Using transactional fixtures now causes the data to be loaded only once. - -* Added fixture accessor methods that can be used when instantiated fixtures are disabled. - - fixtures :web_sites - - def test_something - assert_equal "Ruby on Rails", web_sites(:rubyonrails).name - end - -* Added DoubleRenderError exception that'll be raised if render* is called twice #518 [Nicholas Seckar] - -* Fixed exceptions occuring after render has been called #1096 [Nicholas Seckar] - -* CHANGED: validates_presence_of now uses Errors#add_on_blank, which will make " " fail the validation where it didn't before #1309 - -* Added Errors#add_on_blank which works like Errors#add_on_empty, but uses Object#blank? instead - -* Added the :if option to all validations that can either use a block or a method pointer to determine whether the validation should be run or not. #1324 [Duane Johnson/jhosteny]. Examples: - - Conditional validations such as the following are made possible: - validates_numericality_of :income, :if => :employed? - - Conditional validations can also solve the salted login generator problem: - validates_confirmation_of :password, :if => :new_password? - - Using blocks: - validates_presence_of :username, :if => Proc.new { |user| user.signup_step > 1 } - -* Fixed use of construct_finder_sql when using :join #1288 [dwlt@dwlt.net] - -* Fixed that :delete_sql in has_and_belongs_to_many associations couldn't access record properties #1299 [Rick Olson] - -* Fixed that clone would break when an aggregate had the same name as one of its attributes #1307 [Jeremy Kemper] - -* Changed that destroying an object will only freeze the attributes hash, which keeps the object from having attributes changed (as that wouldn't make sense), but allows for the querying of associations after it has been destroyed. - -* Changed the callbacks such that observers are notified before the in-object callbacks are triggered. Without this change, it wasn't possible to act on the whole object in something like a before_destroy observer without having the objects own callbacks (like deleting associations) called first. - -* Added option for passing an array to the find_all version of the dynamic finders and have it evaluated as an IN fragment. Example: - - # SELECT * FROM topics WHERE title IN ('First', 'Second') - Topic.find_all_by_title(["First", "Second"]) - -* Added compatibility with camelCase column names for dynamic finders #533 [Dee Zsombor] - -* Fixed extraneous comma in count() function that made it not work with joins #1156 [Jarkko Laine/Dee Zsombor] - -* Fixed incompatibility with Base#find with an array of ids that would fail when using eager loading #1186 [Alisdair McDiarmid] - -* Fixed that validate_length_of lost :on option when :within was specified #1195 [jhosteny@mac.com] - -* Added encoding and min_messages options for PostgreSQL #1205 [Shugo Maeda]. Configuration example: - - development: - adapter: postgresql - database: rails_development - host: localhost - username: postgres - password: - encoding: UTF8 - min_messages: ERROR - -* Fixed acts_as_list where deleting an item that was removed from the list would ruin the positioning of other list items #1197 [Jamis Buck] - -* Added validates_exclusion_of as a negative of validates_inclusion_of - -* Optimized counting of has_many associations by setting the association to empty if the count is 0 so repeated calls doesn't trigger database calls - - -*1.10.1* (20th April, 2005) - -* Fixed frivilous database queries being triggered with eager loading on empty associations and other things - -* Fixed order of loading in eager associations - -* Fixed stray comma when using eager loading and ordering together from has_many associations #1143 - - -*1.10.0* (19th April, 2005) - -* Added eager loading of associations as a way to solve the N+1 problem more gracefully without piggy-back queries. Example: - - for post in Post.find(:all, :limit => 100) - puts "Post: " + post.title - puts "Written by: " + post.author.name - puts "Last comment on: " + post.comments.first.created_on - end - - This used to generate 301 database queries if all 100 posts had both author and comments. It can now be written as: - - for post in Post.find(:all, :limit => 100, :include => [ :author, :comments ]) - - ...and the number of database queries needed is now 1. - -* Added new unified Base.find API and deprecated the use of find_first and find_all. See the documentation for Base.find. Examples: - - Person.find(1, :conditions => "administrator = 1", :order => "created_on DESC") - Person.find(1, 5, 6, :conditions => "administrator = 1", :order => "created_on DESC") - Person.find(:first, :order => "created_on DESC", :offset => 5) - Person.find(:all, :conditions => [ "category IN (?)", categories], :limit => 50) - Person.find(:all, :offset => 10, :limit => 10) - -* Added acts_as_nested_set #1000 [wschenk]. Introduction: - - This acts provides Nested Set functionality. Nested Set is similiar to Tree, but with - the added feature that you can select the children and all of it's descendants with - a single query. A good use case for this is a threaded post system, where you want - to display every reply to a comment without multiple selects. - -* Added Base.save! that attempts to save the record just like Base.save but will raise a RecordInvalid exception instead of returning false if the record is not valid [Dave Thomas] - -* Fixed PostgreSQL usage of fixtures with regards to public schemas and table names with dots #962 [gnuman1@gmail.com] - -* Fixed that fixtures were being deleted in the same order as inserts causing FK errors #890 [andrew.john.peters@gmail.com] - -* Fixed loading of fixtures in to be in the right order (or PostgreSQL would bark) #1047 [stephenh@chase3000.com] - -* Fixed page caching for non-vhost applications living underneath the root #1004 [Ben Schumacher] - -* Fixes a problem with the SQL Adapter which was resulting in IDENTITY_INSERT not being set to ON when it should be #1104 [adelle] - -* Added the option to specify the acceptance string in validates_acceptance_of #1106 [caleb@aei-tech.com] - -* Added insert_at(position) to acts_as_list #1083 [DeLynnB] - -* Removed the default order by id on has_and_belongs_to_many queries as it could kill performance on large sets (you can still specify by hand with :order) - -* Fixed that Base.silence should restore the old logger level when done, not just set it to DEBUG #1084 [yon@milliped.com] - -* Fixed boolean saving on Oracle #1093 [mparrish@pearware.org] - -* Moved build_association and create_association for has_one and belongs_to out of deprecation as they work when the association is nil unlike association.build and association.create, which require the association to be already in place #864 - -* Added rollbacks of transactions if they're active as the dispatcher is killed gracefully (TERM signal) #1054 [Leon Bredt] - -* Added quoting of column names for fixtures #997 [jcfischer@gmail.com] - -* Fixed counter_sql when no records exist in database for PostgreSQL (would give error, not 0) #1039 [Caleb Tennis] - -* Fixed that benchmarking times for rendering included db runtimes #987 [Stefan Kaes] - -* Fixed boolean queries for t/f fields in PostgreSQL #995 [dave@cherryville.org] - -* Added that model.items.delete(child) will delete the child, not just set the foreign key to nil, if the child is dependent on the model #978 [Jeremy Kemper] - -* Fixed auto-stamping of dates (created_on/updated_on) for PostgreSQL #985 [dave@cherryville.org] - -* Fixed Base.silence/benchmark to only log if a logger has been configured #986 [Stefan Kaes] - -* Added a join parameter as the third argument to Base.find_first and as the second to Base.count #426, #988 [Stefan Kaes] - -* Fixed bug in Base#hash method that would treat records with the same string-based id as different [Dave Thomas] - -* Renamed DateHelper#distance_of_time_in_words_to_now to DateHelper#time_ago_in_words (old method name is still available as a deprecated alias) - - -*1.9.1* (27th March, 2005) - -* Fixed that Active Record objects with float attribute could not be cloned #808 - -* Fixed that MissingSourceFile's wasn't properly detected in production mode #925 [Nicholas Seckar] - -* Fixed that :counter_cache option would look for a line_items_count column for a LineItem object instead of lineitems_count - -* Fixed that AR exists?() would explode on postgresql if the passed id did not match the PK type #900 [Scott Barron] - -* Fixed the MS SQL adapter to work with the new limit/offset approach and with binary data (still suffering from 7KB limit, though) #901 [delynnb] - - -*1.9.0* (22th March, 2005) - -* Added adapter independent limit clause as a two-element array with the first being the limit, the second being the offset #795 [Sam Stephenson]. Example: - - Developer.find_all nil, 'id ASC', 5 # return the first five developers - Developer.find_all nil, 'id ASC', [3, 8] # return three developers, starting from #8 and forward - - This doesn't yet work with the DB2 or MS SQL adapters. Patches to make that happen are encouraged. - -* Added alias_method :to_param, :id to Base, such that Active Record objects to be used as URL parameters in Action Pack automatically #812 [Nicholas Seckar/Sam Stephenson] - -* Improved the performance of the OCI8 adapter for Oracle #723 [pilx/gjenkins] - -* Added type conversion before saving a record, so string-based values like "10.0" aren't left for the database to convert #820 [dave@cherryville.org] - -* Added with additional settings for working with transactional fixtures and pre-loaded test databases #865 [mindel] - -* Fixed acts_as_list to trigger remove_from_list on destroy after the fact, not before, so a unique position can be maintained #871 [Alisdair McDiarmid] - -* Added the possibility of specifying fixtures in multiple calls #816 [kim@tinker.com] - -* Added Base.exists?(id) that'll return true if an object of the class with the given id exists #854 [stian@grytoyr.net] - -* Added optionally allow for nil or empty strings with validates_numericality_of #801 [Sebastian Kanthak] - -* Fixed problem with using slashes in validates_format_of regular expressions #801 [Sebastian Kanthak] - -* Fixed that SQLite3 exceptions are caught and reported properly #823 [yerejm] - -* Added that all types of after_find/after_initialized callbacks are triggered if the explicit implementation is present, not only the explicit implementation itself - -* Fixed that symbols can be used on attribute assignment, like page.emails.create(:subject => data.subject, :body => data.body) - - -*1.8.0* (7th March, 2005) - -* Added ActiveRecord::Base.colorize_logging to control whether to use colors in logs or not (on by default) - -* Added support for timestamp with time zone in PostgreSQL #560 [Scott Barron] - -* Added MultiparameterAssignmentErrors and AttributeAssignmentError exceptions #777 [demetrius]. Documentation: - - * +MultiparameterAssignmentErrors+ -- collection of errors that occurred during a mass assignment using the - +attributes=+ method. The +errors+ property of this exception contains an array of +AttributeAssignmentError+ - objects that should be inspected to determine which attributes triggered the errors. - * +AttributeAssignmentError+ -- an error occurred while doing a mass assignment through the +attributes=+ method. - You can inspect the +attribute+ property of the exception object to determine which attribute triggered the error. - -* Fixed that postgresql adapter would fails when reading bytea fields with null value #771 [rodrigo k] - -* Added transactional fixtures that uses rollback to undo changes to fixtures instead of DELETE/INSERT -- it's much faster. See documentation under Fixtures #760 [Jeremy Kemper] - -* Added destruction of dependent objects in has_one associations when a new assignment happens #742 [mindel]. Example: - - class Account < ActiveRecord::Base - has_one :credit_card, :dependent => true - end - class CreditCard < ActiveRecord::Base - belongs_to :account - end - - account.credit_card # => returns existing credit card, lets say id = 12 - account.credit_card = CreditCard.create("number" => "123") - account.save # => CC with id = 12 is destroyed - - -* Added validates_numericality_of #716 [Sebastian Kanthak/Chris McGrath]. Docuemntation: - - Validates whether the value of the specified attribute is numeric by trying to convert it to - a float with Kernel.Float (if <tt>integer</tt> is false) or applying it to the regular expression - <tt>/^[\+\-]?\d+$/</tt> (if <tt>integer</tt> is set to true). - - class Person < ActiveRecord::Base - validates_numericality_of :value, :on => :create - end - - Configuration options: - * <tt>message</tt> - A custom error message (default is: "is not a number") - * <tt>on</tt> Specifies when this validation is active (default is :save, other options :create, :update) - * <tt>only_integer</tt> Specifies whether the value has to be an integer, e.g. an integral value (default is false) - - -* Fixed that HasManyAssociation#count was using :finder_sql rather than :counter_sql if it was available #445 [Scott Barron] - -* Added better defaults for composed_of, so statements like composed_of :time_zone, :mapping => %w( time_zone time_zone ) can be written without the mapping part (it's now assumed) - -* Added MacroReflection#macro which will return a symbol describing the macro used (like :composed_of or :has_many) #718, #248 [james@slashetc.com] - - -*1.7.0* (24th February, 2005) - -* Changed the auto-timestamping feature to use ActiveRecord::Base.default_timezone instead of entertaining the parallel ActiveRecord::Base.timestamps_gmt method. The latter is now deprecated and will throw a warning on use (but still work) #710 [Jamis Buck] - -* Added a OCI8-based Oracle adapter that has been verified to work with Oracle 8 and 9 #629 [Graham Jenkins]. Usage notes: - - 1. Key generation uses a sequence "rails_sequence" for all tables. (I couldn't find a simple - and safe way of passing table-specific sequence information to the adapter.) - 2. Oracle uses DATE or TIMESTAMP datatypes for both dates and times. Consequently I have had to - resort to some hacks to get data converted to Date or Time in Ruby. - If the column_name ends in _at (like created_at, updated_at) it's created as a Ruby Time. Else if the - hours/minutes/seconds are 0, I make it a Ruby Date. Else it's a Ruby Time. - This is nasty - but if you use Duck Typing you'll probably not care very much. - In 9i it's tempting to map DATE to Date and TIMESTAMP to Time but I don't think that is - valid - too many databases use DATE for both. - Timezones and sub-second precision on timestamps are not supported. - 3. Default values that are functions (such as "SYSDATE") are not supported. This is a - restriction of the way active record supports default values. - 4. Referential integrity constraints are not fully supported. Under at least - some circumstances, active record appears to delete parent and child records out of - sequence and out of transaction scope. (Or this may just be a problem of test setup.) - - The OCI8 driver can be retrieved from http://rubyforge.org/projects/ruby-oci8/ - -* Added option :schema_order to the PostgreSQL adapter to support the use of multiple schemas per database #697 [YuriSchimke] - -* Optimized the SQL used to generate has_and_belongs_to_many queries by listing the join table first #693 [yerejm] - -* Fixed that when using validation macros with a custom message, if you happened to use single quotes in the message string you would get a parsing error #657 [tonka] - -* Fixed that Active Record would throw Broken Pipe errors with FCGI when the MySQL connection timed out instead of reconnecting #428 [Nicholas Seckar] - -* Added options to specify an SSL connection for MySQL. Define the following attributes in the connection config (config/database.yml in Rails) to use it: sslkey, sslcert, sslca, sslcapath, sslcipher. To use SSL with no client certs, just set :sslca = '/dev/null'. http://dev.mysql.com/doc/mysql/en/secure-connections.html #604 [daniel@nightrunner.com] - -* Added automatic dropping/creating of test tables for running the unit tests on all databases #587 [adelle@bullet.net.au] - -* Fixed that find_by_* would fail when column names had numbers #670 [demetrius] - -* Fixed the SQL Server adapter on a bunch of issues #667 [DeLynn] - - 1. Created a new columns method that is much cleaner. - 2. Corrected a problem with the select and select_all methods - that didn't account for the LIMIT clause being passed into raw SQL statements. - 3. Implemented the string_to_time method in order to create proper instances of the time class. - 4. Added logic to the simplified_type method that allows the database to specify the scale of float data. - 5. Adjusted the quote_column_name to account for the fact that MS SQL is bothered by a forward slash in the data string. - -* Fixed that the dynamic finder like find_all_by_something_boolean(false) didn't work #649 [lmarlow] - -* Added validates_each that validates each specified attribute against a block #610 [Jeremy Kemper]. Example: - - class Person < ActiveRecord::Base - validates_each :first_name, :last_name do |record, attr| - record.errors.add attr, 'starts with z.' if attr[0] == ?z - end - end - -* Added :allow_nil as an explicit option for validates_length_of, so unless that's set to true having the attribute as nil will also return an error if a range is specified as :within #610 [Jeremy Kemper] - -* Added that validates_* now accept blocks to perform validations #618 [Tim Bates]. Example: - - class Person < ActiveRecord::Base - validate { |person| person.errors.add("title", "will never be valid") if SHOULD_NEVER_BE_VALID } - end - -* Addded validation for validate all the associated objects before declaring failure with validates_associated #618 [Tim Bates] - -* Added keyword-style approach to defining the custom relational bindings #545 [Jamis Buck]. Example: - - class Project < ActiveRecord::Base - primary_key "sysid" - table_name "XYZ_PROJECT" - inheritance_column { original_inheritance_column + "_id" } - end - -* Fixed Base#clone for use with PostgreSQL #565 [hanson@surgery.wisc.edu] - - -*1.6.0* (January 25th, 2005) - -* Added that has_many association build and create methods can take arrays of record data like Base#create and Base#build to build/create multiple records at once. - -* Added that Base#delete and Base#destroy both can take an array of ids to delete/destroy #336 - -* Added the option of supplying an array of attributes to Base#create, so that multiple records can be created at once. - -* Added the option of supplying an array of ids and attributes to Base#update, so that multiple records can be updated at once (inspired by #526/Duane Johnson). Example - - people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy"} } - Person.update(people.keys, people.values) - -* Added ActiveRecord::Base.timestamps_gmt that can be set to true to make the automated timestamping use GMT instead of local time #520 [Scott Baron] - -* Added that update_all calls sanitize_sql on its updates argument, so stuff like MyRecord.update_all(['time = ?', Time.now]) works #519 [notahat] - -* Fixed that the dynamic finders didn't treat nil as a "IS NULL" but rather "= NULL" case #515 [Demetrius] - -* Added bind-named arrays for interpolating a group of ids or strings in conditions #528 [Jeremy Kemper] - -* Added that has_and_belongs_to_many associations with additional attributes also can be created between unsaved objects and only committed to the database when Base#save is called on the associator #524 [Eric Anderson] - -* Fixed that records fetched with piggy-back attributes or through rich has_and_belongs_to_many associations couldn't be saved due to the extra attributes not part of the table #522 [Eric Anderson] - -* Added mass-assignment protection for the inheritance column -- regardless of a custom column is used or not - -* Fixed that association proxies would fail === tests like PremiumSubscription === @account.subscription - -* Fixed that column aliases didn't work as expected with the new MySql411 driver #507 [Demetrius] - -* Fixed that find_all would produce invalid sql when called sequentialy #490 [Scott Baron] - - -*1.5.1* (January 18th, 2005) - -* Fixed that the belongs_to and has_one proxy would fail a test like 'if project.manager' -- this unfortunately also means that you can't call methods like project.manager.build unless there already is a manager on the project #492 [Tim Bates] - -* Fixed that the Ruby/MySQL adapter wouldn't connect if the password was empty #503 [Pelle] - - -*1.5.0* (January 17th, 2005) - -* Fixed that unit tests for MySQL are now run as the "rails" user instead of root #455 [Eric Hodel] - -* Added validates_associated that enables validation of objects in an unsaved association #398 [Tim Bates]. Example: - - class Book < ActiveRecord::Base - has_many :pages - belongs_to :library - - validates_associated :pages, :library - end - -* Added support for associating unsaved objects #402 [Tim Bates]. Rules that govern this addition: - - == Unsaved objects and associations - - You can manipulate objects and associations before they are saved to the database, but there is some special behaviour you should be - aware of, mostly involving the saving of associated objects. - - === One-to-one associations - - * Assigning an object to a has_one association automatically saves that object, and the object being replaced (if there is one), in - order to update their primary keys - except if the parent object is unsaved (new_record? == true). - * If either of these saves fail (due to one of the objects being invalid) the assignment statement returns false and the assignment - is cancelled. - * If you wish to assign an object to a has_one association without saving it, use the #association.build method (documented below). - * Assigning an object to a belongs_to association does not save the object, since the foreign key field belongs on the parent. It does - not save the parent either. - - === Collections - - * Adding an object to a collection (has_many or has_and_belongs_to_many) automatically saves that object, except if the parent object - (the owner of the collection) is not yet stored in the database. - * If saving any of the objects being added to a collection (via #push or similar) fails, then #push returns false. - * You can add an object to a collection without automatically saving it by using the #collection.build method (documented below). - * All unsaved (new_record? == true) members of the collection are automatically saved when the parent is saved. - -* Added replace to associations, so you can do project.manager.replace(new_manager) or project.milestones.replace(new_milestones) #402 [Tim Bates] - -* Added build and create methods to has_one and belongs_to associations, so you can now do project.manager.build(attributes) #402 [Tim Bates] - -* Added that if a before_* callback returns false, all the later callbacks and the associated action are cancelled. If an after_* callback returns false, all the later callbacks are cancelled. Callbacks are generally run in the order they are defined, with the exception of callbacks defined as methods on the model, which are called last. #402 [Tim Bates] - -* Fixed that Base#== wouldn't work for multiple references to the same unsaved object #402 [Tim Bates] - -* Fixed binary support for PostgreSQL #444 [alex@byzantine.no] - -* Added a differenciation between AssociationCollection#size and -length. Now AssociationCollection#size returns the size of the - collection by executing a SELECT COUNT(*) query if the collection hasn't been loaded and calling collection.size if it has. If - it's more likely than not that the collection does have a size larger than zero and you need to fetch that collection afterwards, - it'll take one less SELECT query if you use length. - -* Added Base#attributes that returns a hash of all the attributes with their names as keys and clones of their objects as values #433 [atyp.de] - -* Fixed that foreign keys named the same as the association would cause stack overflow #437 [Eric Anderson] - -* Fixed default scope of acts_as_list from "1" to "1 = 1", so it'll work in PostgreSQL (among other places) #427 [Alexey] - -* Added Base#reload that reloads the attributes of an object from the database #422 [Andreas Schwarz] - -* Added SQLite3 compatibility through the sqlite3-ruby adapter by Jamis Buck #381 [Jeremy Kemper] - -* Added support for the new protocol spoken by MySQL 4.1.1+ servers for the Ruby/MySQL adapter that ships with Rails #440 [Matt Mower] - -* Added that Observers can use the observes class method instead of overwriting self.observed_class(). - - Before: - class ListSweeper < ActiveRecord::Base - def self.observed_class() [ List, Item ] - end - - After: - class ListSweeper < ActiveRecord::Base - observes List, Item - end - -* Fixed that conditions in has_many and has_and_belongs_to_many should be interpolated just like the finder_sql is - -* Fixed Base#update_attribute to be indifferent to whether a string or symbol is used to describe the name - -* Added Base#toggle(attribute) and Base#toggle!(attribute) that makes it easier to flip a switch or flag. - - Before: topic.update_attribute(:approved, !approved?) - After : topic.toggle!(:approved) - -* Added Base#increment!(attribute) and Base#decrement!(attribute) that also saves the records. Example: - - page.views # => 1 - page.increment!(:views) # executes an UPDATE statement - page.views # => 2 - - page.increment(:views).increment!(:views) - page.views # => 4 - -* Added Base#increment(attribute) and Base#decrement(attribute) that encapsulates the += 1 and -= 1 patterns. - - -*1.4.0* (January 4th, 2005) - -* Added automated optimistic locking if the field <tt>lock_version</tt> is present. Each update to the - record increments the lock_version column and the locking facilities ensure that records instantiated twice - will let the last one saved raise a StaleObjectError if the first was also updated. Example: - - p1 = Person.find(1) - p2 = Person.find(1) - - p1.first_name = "Michael" - p1.save - - p2.first_name = "should fail" - p2.save # Raises a ActiveRecord::StaleObjectError - - You're then responsible for dealing with the conflict by rescuing the exception and either rolling back, merging, - or otherwise apply the business logic needed to resolve the conflict. - - #384 [Michael Koziarski] - -* Added dynamic attribute-based finders as a cleaner way of getting objects by simple queries without turning to SQL. - They work by appending the name of an attribute to <tt>find_by_</tt>, so you get finders like <tt>Person.find_by_user_name, - Payment.find_by_transaction_id</tt>. So instead of writing <tt>Person.find_first(["user_name = ?", user_name])</tt>, you just do - <tt>Person.find_by_user_name(user_name)</tt>. - - It's also possible to use multiple attributes in the same find by separating them with "_and_", so you get finders like - <tt>Person.find_by_user_name_and_password</tt> or even <tt>Payment.find_by_purchaser_and_state_and_country</tt>. So instead of writing - <tt>Person.find_first(["user_name = ? AND password = ?", user_name, password])</tt>, you just do - <tt>Person.find_by_user_name_and_password(user_name, password)</tt>. - - While primarily a construct for easier find_firsts, it can also be used as a construct for find_all by using calls like - <tt>Payment.find_all_by_amount(50)</tt> that is turned into <tt>Payment.find_all(["amount = ?", 50])</tt>. This is something not as equally useful, - though, as it's not possible to specify the order in which the objects are returned. - -* Added block-style for callbacks #332 [Jeremy Kemper]. - - Before: - before_destroy(Proc.new{ |record| Person.destroy_all "firm_id = #{record.id}" }) - - After: - before_destroy { |record| Person.destroy_all "firm_id = #{record.id}" } - -* Added :counter_cache option to acts_as_tree that works just like the one you can define on belongs_to #371 [Josh Peek] - -* Added Base.default_timezone accessor that determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates - and times from the database. This is set to :local by default. - -* Added the possibility for adapters to overwrite add_limit! to implement a different limiting scheme than "LIMIT X" used by MySQL, PostgreSQL, and SQLite. - -* Added the possibility of having objects with acts_as_list created before their scope is available or... - -* Added a db2 adapter that only depends on the Ruby/DB2 bindings (http://raa.ruby-lang.org/project/ruby-db2/) #386 [Maik Schmidt] - -* Added the final touches to the Microsoft SQL Server adapter by Joey Gibson that makes it suitable for actual use #394 [DeLynn Barry] - -* Added that Base#find takes an optional options hash, including :conditions. Base#find_on_conditions deprecated in favor of #find with :conditions #407 [Jeremy Kemper] - -* Added HasManyAssociation#count that works like Base#count #413 [intinig] - -* Fixed handling of binary content in blobs and similar fields for Ruby/MySQL and SQLite #409 [xal] - -* Fixed a bug in the Ruby/MySQL that caused binary content to be escaped badly and come back mangled #405 [Tobias Lütke] - -* Fixed that the const_missing autoload assumes the requested constant is set by require_association and calls const_get to retrieve it. - If require_association did not set the constant then const_get will call const_missing, resulting in an infinite loop #380 [Jeremy Kemper] - -* Fixed broken transactions that were actually only running object-level and not db level transactions [andreas] - -* Fixed that validates_uniqueness_of used 'id' instead of defined primary key #406 - -* Fixed that the overwritten respond_to? method didn't take two parameters like the original #391 - -* Fixed quoting in validates_format_of that would allow some rules to pass regardless of input #390 [Dmitry V. Sabanin] - - -*1.3.0* (December 23, 2004) - -* Added a require_association hook on const_missing that makes it possible to use any model class without requiring it first. This makes STI look like: - - before: - require_association 'person' - class Employee < Person - end - - after: - class Employee < Person - end - - This also reduces the usefulness of Controller.model in Action Pack to currently only being for documentation purposes. - -* Added that Base.update_all and Base.delete_all return an integer of the number of affected rows #341 - -* Added scope option to validation_uniqueness #349 [Kent Sibilev] - -* Added respondence to *_before_type_cast for all attributes to return their string-state before they were type casted by the column type. - This is helpful for getting "100,000" back on a integer-based validation where the value would normally be "100". - -* Added allow_nil options to validates_inclusion_of so that validation is only triggered if the attribute is not nil [what-a-day] - -* Added work-around for PostgreSQL and the problem of getting fixtures to be created from id 1 on each test case. - This only works for auto-incrementing primary keys called "id" for now #359 [Scott Baron] - -* Added Base#clear_association_cache to empty all the cached associations #347 [Tobias Lütke] - -* Added more informative exceptions in establish_connection #356 [Jeremy Kemper] - -* Added Base#update_attributes that'll accept a hash of attributes and save the record (returning true if it passed validation, false otherwise). - - Before: - person.attributes = @params["person"] - person.save - - Now: - person.update_attributes(@params["person"]) - -* Added Base.destroy and Base.delete to remove records without holding a reference to them first. - -* Added that query benchmarking will only happen if its going to be logged anyway #344 - -* Added higher_item and lower_item as public methods for acts_as_list #342 [Tobias Lütke] - -* Fixed that options[:counter_sql] was overwritten with interpolated sql rather than original sql #355 [Jeremy Kemper] - -* Fixed that overriding an attribute's accessor would be disregarded by add_on_empty and add_on_boundary_breaking because they simply used - the attributes[] hash instead of checking for @base.respond_to?(attr.to_s). [Marten] - -* Fixed that Base.table_name would expect a parameter when used in has_and_belongs_to_many joins [Anna Lissa Cruz] - -* Fixed that nested transactions now work by letting the outer most transaction have the responsibilty of starting and rolling back the transaction. - If any of the inner transactions swallow the exception raised, though, the transaction will not be rolled back. So always let the transaction - bubble up even when you've dealt with local issues. Closes #231 and #340. - -* Fixed validates_{confirmation,acceptance}_of to only happen when the virtual attributes are not nil #348 [dpiddy@gmail.com] - -* Changed the interface on AbstractAdapter to require that adapters return the number of affected rows on delete and update operations. - -* Fixed the automated timestamping feature when running under Rails' development environment that resets the inheritable attributes on each request. - - - -*1.2.0* - -* Added Base.validates_inclusion_of that validates whether the value of the specified attribute is available in a particular enumerable - object. [what-a-day] - - class Person < ActiveRecord::Base - validates_inclusion_of :gender, :in=>%w( m f ), :message=>"woah! what are you then!??!!" - validates_inclusion_of :age, :in=>0..99 - end - -* Added acts_as_list that can decorates an existing class with methods like move_higher/lower, move_to_top/bottom. [Tobias Lütke] Example: - - class TodoItem < ActiveRecord::Base - acts_as_list :scope => :todo_list_id - belongs_to :todo_list - end - -* Added acts_as_tree that can decorates an existing class with a many to many relationship with itself. Perfect for categories in - categories and the likes. [Tobias Lütke] - -* Added that Active Records will automatically record creation and/or update timestamps of database objects if fields of the names - created_at/created_on or updated_at/updated_on are present. [Tobias Lütke] - -* Added Base.default_error_messages as a hash of all the error messages used in the validates_*_of so they can be changed in one place [Tobias Lütke] - -* Added automatic transaction block around AssociationCollection.<<, AssociationCollection.delete, and AssociationCollection.destroy_all - -* Fixed that Base#find will return an array if given an array -- regardless of the number of elements #270 [Marten] - -* Fixed that has_and_belongs_to_many would generate bad sql when naming conventions differed from using vanilla "id" everywhere [RedTerror] - -* Added a better exception for when a type column is used in a table without the intention of triggering single-table inheritance. Example: - - ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'bad_class!'. - This error is raised because the column 'type' is reserved for storing the class in case of inheritance. - Please rename this column if you didn't intend it to be used for storing the inheritance class or - overwrite Company.inheritance_column to use another column for that information. - -* Added that single-table inheritance will only kick in if the inheritance_column (by default "type") is present. Otherwise, inheritance won't - have any magic side effects. - -* Added the possibility of marking fields as being in error without adding a message (using nil) to it that'll get displayed wth full_messages #208 [mjobin] - -* Fixed Base.errors to be indifferent as to whether strings or symbols are used. Examples: - - Before: - errors.add(:name, "must be shorter") if name.size > 10 - errors.on(:name) # => "must be shorter" - errors.on("name") # => nil - - After: - errors.add(:name, "must be shorter") if name.size > 10 - errors.on(:name) # => "must be shorter" - errors.on("name") # => "must be shorter" - -* Added Base.validates_format_of that Validates whether the value of the specified attribute is of the correct form by matching - it against the regular expression provided. [Marcel Molina Jr.] - - class Person < ActiveRecord::Base - validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/, :on => :create - end - -* Added Base.validates_length_of that delegates to add_on_boundary_breaking #312 [Tobias Lütke]. Example: - - Validates that the specified attribute matches the length restrictions supplied in either: - - - configuration[:minimum] - - configuration[:maximum] - - configuration[:is] - - configuration[:within] (aka. configuration[:in]) - - Only one option can be used at a time. - - class Person < ActiveRecord::Base - validates_length_of :first_name, :maximum=>30 - validates_length_of :last_name, :maximum=>30, :message=>"less than %d if you don't mind" - validates_length_of :user_name, :within => 6..20, :too_long => "pick a shorter name", :too_short => "pick a longer name" - validates_length_of :fav_bra_size, :minimum=>1, :too_short=>"please enter at least %d character" - validates_length_of :smurf_leader, :is=>4, :message=>"papa is spelled with %d characters... don't play me." - end - -* Added Base.validate_presence as an alternative to implementing validate and doing errors.add_on_empty yourself. - -* Added Base.validates_uniqueness_of that alidates whether the value of the specified attributes are unique across the system. - Useful for making sure that only one user can be named "davidhh". - - class Person < ActiveRecord::Base - validates_uniqueness_of :user_name - end - - When the record is created, a check is performed to make sure that no record exist in the database with the given value for the specified - attribute (that maps to a column). When the record is updated, the same check is made but disregarding the record itself. - - -* Added Base.validates_confirmation_of that encapsulates the pattern of wanting to validate a password or email address field with a confirmation. Example: - - Model: - class Person < ActiveRecord::Base - validates_confirmation_of :password - end - - View: - <%= password_field "person", "password" %> - <%= password_field "person", "password_confirmation" %> - - The person has to already have a password attribute (a column in the people table), but the password_confirmation is virtual. - It exists only as an in-memory variable for validating the password. This check is performed both on create and update. - - -* Added Base.validates_acceptance_of that encapsulates the pattern of wanting to validate the acceptance of a terms of service check box (or similar agreement). Example: - - class Person < ActiveRecord::Base - validates_acceptance_of :terms_of_service - end - - The terms_of_service attribute is entirely virtual. No database column is needed. This check is performed both on create and update. - - NOTE: The agreement is considered valid if it's set to the string "1". This makes it easy to relate it to an HTML checkbox. - - -* Added validation macros to make the stackable just like the lifecycle callbacks. Examples: - - class Person < ActiveRecord::Base - validate { |record| record.errors.add("name", "too short") unless name.size > 10 } - validate { |record| record.errors.add("name", "too long") unless name.size < 20 } - validate_on_create :validate_password - - private - def validate_password - errors.add("password", "too short") unless password.size > 6 - end - end - -* Added the option for sanitizing find_by_sql and the offset parts in regular finds [Sam Stephenson]. Examples: - - Project.find_all ["category = ?", category_name], "created ASC", ["? OFFSET ?", 15, 20] - Post.find_by_sql ["SELECT * FROM posts WHERE author = ? AND created > ?", author_id, start_date] - -* Fixed value quoting in all generated SQL statements, so that integers are not surrounded in quotes and that all sanitation are happening - through the database's own quoting routine. This should hopefully make it lots easier for new adapters that doesn't accept '1' for integer - columns. - -* Fixed has_and_belongs_to_many guessing of foreign key so that keys are generated correctly for models like SomeVerySpecialClient - [Florian Weber] - -* Added counter_sql option for has_many associations [Jeremy Kemper]. Documentation: - - <tt>:counter_sql</tt> - specify a complete SQL statement to fetch the size of the association. If +:finder_sql+ is - specified but +:counter_sql+, +:counter_sql+ will be generated by replacing SELECT ... FROM with SELECT COUNT(*) FROM. - -* Fixed that methods wrapped in callbacks still return their original result #260 [Jeremy Kemper] - -* Fixed the Inflector to handle the movie/movies pair correctly #261 [Scott Baron] - -* Added named bind-style variable interpolation #281 [Michael Koziarski]. Example: - - Person.find(["id = :id and first_name = :first_name", { :id => 5, :first_name = "bob' or 1=1" }]) - -* Added bind-style variable interpolation for the condition arrays that uses the adapter's quote method [Michael Koziarski] - - Before: - find_first([ "user_name = '%s' AND password = '%s'", user_name, password ])] - find_first([ "firm_id = %s", firm_id ])] # unsafe! - - After: - find_first([ "user_name = ? AND password = ?", user_name, password ])] - find_first([ "firm_id = ?", firm_id ])] - -* Added CSV format for fixtures #272 [what-a-day]. (See the new and expanded documentation on fixtures for more information) - -* Fixed fixtures using primary key fields called something else than "id" [dave] - -* Added proper handling of time fields that are turned into Time objects with the dummy date of 2000/1/1 [HariSeldon] - -* Added reverse order of deleting fixtures, so referential keys can be maintained #247 [Tim Bates] - -* Added relative path search for sqlite dbfiles in database.yml (if RAILS_ROOT is defined) #233 [Jeremy Kemper] - -* Added option to establish_connection where you'll be able to leave out the parameter to have it use the RAILS_ENV environment variable - -* Fixed problems with primary keys and postgresql sequences (#230) [Tim Bates] - -* Added reloading for associations under cached environments like FastCGI and mod_ruby. This makes it possible to use those environments for development. - This is turned on by default, but can be turned off with ActiveRecord::Base.reload_dependencies = false in production environments. - - NOTE: This will only have an effect if you let the associations manage the requiring of model classes. All libraries loaded through - require will be "forever" cached. You can, however, use ActiveRecord::Base.load_or_require("library") to get this behavior outside of the - auto-loading associations. - -* Added ERB capabilities to the fixture files for dynamic fixture generation. You don't need to do anything, just include ERB blocks like: - - david: - id: 1 - name: David - - jamis: - id: 2 - name: Jamis - - <% for digit in 3..10 %> - dev_<%= digit %>: - id: <%= digit %> - name: fixture_<%= digit %> - <% end %> - -* Changed the yaml fixture searcher to look in the root of the fixtures directory, so when you before could have something like: - - fixtures/developers/fixtures.yaml - fixtures/accounts/fixtures.yaml - - ...you now need to do: - - fixtures/developers.yaml - fixtures/accounts.yaml - -* Changed the fixture format from: - - name: david - data: - id: 1 - name: David Heinemeier Hansson - birthday: 1979-10-15 - profession: Systems development - --- - name: steve - data: - id: 2 - name: Steve Ross Kellock - birthday: 1974-09-27 - profession: guy with keyboard - - ...to: - - david: - id: 1 - name: David Heinemeier Hansson - birthday: 1979-10-15 - profession: Systems development - - steve: - id: 2 - name: Steve Ross Kellock - birthday: 1974-09-27 - profession: guy with keyboard - - The change is NOT backwards compatible. Fixtures written in the old YAML style needs to be rewritten! - -* All associations will now attempt to require the classes that they associate to. Relieving the need for most explicit 'require' statements. - - -*1.1.0* (34) - -* Added automatic fixture setup and instance variable availability. Fixtures can also be automatically - instantiated in instance variables relating to their names using the following style: - - class FixturesTest < Test::Unit::TestCase - fixtures :developers # you can add more with comma separation - - def test_developers - assert_equal 3, @developers.size # the container for all the fixtures is automatically set - assert_kind_of Developer, @david # works like @developers["david"].find - assert_equal "David Heinemeier Hansson", @david.name - end - end - -* Added HasAndBelongsToManyAssociation#push_with_attributes(object, join_attributes) that can create associations in the join table with additional - attributes. This is really useful when you have information that's only relevant to the join itself, such as a "added_on" column for an association - between post and category. The added attributes will automatically be injected into objects retrieved through the association similar to the piggy-back - approach: - - post.categories.push_with_attributes(category, :added_on => Date.today) - post.categories.first.added_on # => Date.today - - NOTE: The categories table doesn't have a added_on column, it's the categories_post join table that does! - -* Fixed that :exclusively_dependent and :dependent can't be activated at the same time on has_many associations [Jeremy Kemper] - -* Fixed that database passwords couldn't be all numeric [Jeremy Kemper] - -* Fixed that calling id would create the instance variable for new_records preventing them from being saved correctly [Jeremy Kemper] - -* Added sanitization feature to HasManyAssociation#find_all so it works just like Base.find_all [Sam Stephenson/Jeremy Kemper] - -* Added that you can pass overlapping ids to find without getting duplicated records back [Jeremy Kemper] - -* Added that Base.benchmark returns the result of the block [Jeremy Kemper] - -* Fixed problem with unit tests on Windows with SQLite [paterno] - -* Fixed that quotes would break regular non-yaml fixtures [Dmitry Sabanin/daft] - -* Fixed fixtures on windows with line endings cause problems under unix / mac [Tobias Lütke] - -* Added HasAndBelongsToManyAssociation#find(id) that'll search inside the collection and find the object or record with that id - -* Added :conditions option to has_and_belongs_to_many that works just like the one on all the other associations - -* Added AssociationCollection#clear to remove all associations from has_many and has_and_belongs_to_many associations without destroying the records [geech] - -* Added type-checking and remove in 1-instead-of-N sql statements to AssociationCollection#delete [geech] - -* Added a return of self to AssociationCollection#<< so appending can be chained, like project << Milestone.create << Milestone.create [geech] - -* Added Base#hash and Base#eql? which means that all of the equality using features of array and other containers now works: - - [ Person.find(1), Person.find(2), Person.find(3) ] & [ Person.find(1), Person.find(4) ] # => [ Person.find(1) ] - -* Added :uniq as an option to has_and_belongs_to_many which will automatically ensure that AssociateCollection#uniq is called - before pulling records out of the association. This is especially useful for three-way (and above) has_and_belongs_to_many associations. - -* Added AssociateCollection#uniq which is especially useful for has_and_belongs_to_many associations that can include duplicates, - which is common on associations that also use metadata. Usage: post.categories.uniq - -* Fixed respond_to? to use a subclass specific hash instead of an Active Record-wide one - -* Fixed has_and_belongs_to_many to treat associations between classes in modules properly [Florian Weber] - -* Added a NoMethod exception to be raised when query and writer methods are called for attributes that doesn't exist [geech] - -* Added a more robust version of Fixtures that throws meaningful errors when on formatting issues [geech] - -* Added Base#transaction as a compliment to Base.transaction for prettier use in instance methods [geech] - -* Improved the speed of respond_to? by placing the dynamic methods lookup table in a hash [geech] - -* Added that any additional fields added to the join table in a has_and_belongs_to_many association - will be placed as attributes when pulling records out through has_and_belongs_to_many associations. - This is helpful when have information about the association itself that you want available on retrival. - -* Added better loading exception catching and RubyGems retries to the database adapters [alexeyv] - -* Fixed bug with per-model transactions [daniel] - -* Fixed Base#transaction so that it returns the result of the last expression in the transaction block [alexeyv] - -* Added Fixture#find to find the record corresponding to the fixture id. The record - class name is guessed by using Inflector#classify (also new) on the fixture directory name. - - Before: Document.find(@documents["first"]["id"]) - After : @documents["first"].find - -* Fixed that the table name part of column names ("TABLE.COLUMN") wasn't removed properly [Andreas Schwarz] - -* Fixed a bug with Base#size when a finder_sql was used that didn't capitalize SELECT and FROM [geech] - -* Fixed quoting problems on SQLite by adding quote_string to the AbstractAdapter that can be overwritten by the concrete - adapters for a call to the dbm. [Andreas Schwarz] - -* Removed RubyGems backup strategy for requiring SQLite-adapter -- if people want to use gems, they're already doing it with AR. - - -*1.0.0 (35)* - -* Added OO-style associations methods [Florian Weber]. Examples: - - Project#milestones_count => Project#milestones.size - Project#build_to_milestones => Project#milestones.build - Project#create_for_milestones => Project#milestones.create - Project#find_in_milestones => Project#milestones.find - Project#find_all_in_milestones => Project#milestones.find_all - -* Added serialize as a new class method to control when text attributes should be YAMLized or not. This means that automated - serialization of hashes, arrays, and so on WILL NO LONGER HAPPEN (#10). You need to do something like this: - - class User < ActiveRecord::Base - serialize :settings - end - - This will assume that settings is a text column and will now YAMLize any object put in that attribute. You can also specify - an optional :class_name option that'll raise an exception if a serialized object is retrieved as a descendant of a class not in - the hierarchy. Example: - - class User < ActiveRecord::Base - serialize :settings, :class_name => "Hash" - end - - user = User.create("settings" => %w( one two three )) - User.find(user.id).settings # => raises SerializationTypeMismatch - -* Added the option to connect to a different database for one model at a time. Just call establish_connection on the class - you want to have connected to another database than Base. This will automatically also connect decendents of that class - to the different database [Renald Buter]. - -* Added transactional protection for Base#save. Validations can now check for values knowing that it happens in a transaction and callbacks - can raise exceptions knowing that the save will be rolled back. [Suggested by Alexey Verkhovsky] - -* Added column name quoting so reserved words, such as "references", can be used as column names [Ryan Platte] - -* Added the possibility to chain the return of what happened inside a logged block [geech]: - - This now works: - log { ... }.map { ... } - - Instead of doing: - result = [] - log { result = ... } - result.map { ... } - -* Added "socket" option for the MySQL adapter, so you can change it to something else than "/tmp/mysql.sock" [Anna Lissa Cruz] - -* Added respond_to? answers for all the attribute methods. So if Person has a name attribute retrieved from the table schema, - person.respond_to? "name" will return true. - -* Added Base.benchmark which can be used to aggregate logging and benchmark, so you can measure and represent multiple statements in a single block. - Usage (hides all the SQL calls for the individual actions and calculates total runtime for them all): - - Project.benchmark("Creating project") do - project = Project.create("name" => "stuff") - project.create_manager("name" => "David") - project.milestones << Milestone.find_all - end - -* Added logging of invalid SQL statements [Daniel Von Fange] - -* Added alias Errors#[] for Errors#on, so you can now say person.errors["name"] to retrieve the errors for name [Andreas Schwarz] - -* Added RubyGems require attempt if sqlite-ruby is not available through regular methods. - -* Added compatibility with 2.x series of sqlite-ruby drivers. [Jamis Buck] - -* Added type safety for association assignments, so a ActiveRecord::AssociationTypeMismatch will be raised if you attempt to - assign an object that's not of the associated class. This cures the problem with nil giving id = 4 and fixnums giving id = 1 on - mistaken association assignments. [Reported by Andreas Schwarz] - -* Added the option to keep many fixtures in one single YAML document [what-a-day] - -* Added the class method "inheritance_column" that can be overwritten to return the name of an alternative column than "type" for storing - the type for inheritance hierarchies. [Dave Steinberg] - -* Added [] and []= as an alternative way to access attributes when the regular methods have been overwritten [Dave Steinberg] - -* Added the option to observer more than one class at the time by specifying observed_class as an array - -* Added auto-id propagation support for tables with arbitrary primary keys that have autogenerated sequences associated with them - on PostgreSQL. [Dave Steinberg] - -* Changed that integer and floats set to "" through attributes= remain as NULL. This was especially a problem for scaffolding and postgresql. (#49) - -* Changed the MySQL Adapter to rely on MySQL for its defaults for socket, host, and port [Andreas Schwarz] - -* Changed ActionControllerError to decent from StandardError instead of Exception. It can now be caught by a generic rescue. - -* Changed class inheritable attributes to not use eval [Caio Chassot] - -* Changed Errors#add to now use "invalid" as the default message instead of true, which means full_messages work with those [Marcel Molina Jr.] - -* Fixed spelling on Base#add_on_boundry_breaking to Base#add_on_boundary_breaking (old naming still works) [Marcel Molina Jr.] - -* Fixed that entries in the has_and_belongs_to_many join table didn't get removed when an associated object was destroyed. - -* Fixed unnecessary calls to SET AUTOCOMMIT=0/1 for MySQL adapter [Andreas Schwarz] - -* Fixed PostgreSQL defaults are now handled gracefully [Dave Steinberg] - -* Fixed increment/decrement_counter are now atomic updates [Andreas Schwarz] - -* Fixed the problems the Inflector had turning Attachment into attuchments and Cases into Casis [radsaq/Florian Gross] - -* Fixed that cloned records would point attribute references on the parent object [Andreas Schwarz] - -* Fixed SQL for type call on inheritance hierarchies [Caio Chassot] - -* Fixed bug with typed inheritance [Florian Weber] - -* Fixed a bug where has_many collection_count wouldn't use the conditions specified for that association - - -*0.9.5* - -* Expanded the table_name guessing rules immensely [Florian Green]. Documentation: - - Guesses the table name (in forced lower-case) based on the name of the class in the inheritance hierarchy descending - directly from ActiveRecord. So if the hierarchy looks like: Reply < Message < ActiveRecord, then Message is used - to guess the table name from even when called on Reply. The guessing rules are as follows: - * Class name ends in "x", "ch" or "ss": "es" is appended, so a Search class becomes a searches table. - * Class name ends in "y" preceded by a consonant or "qu": The "y" is replaced with "ies", - so a Category class becomes a categories table. - * Class name ends in "fe": The "fe" is replaced with "ves", so a Wife class becomes a wives table. - * Class name ends in "lf" or "rf": The "f" is replaced with "ves", so a Half class becomes a halves table. - * Class name ends in "person": The "person" is replaced with "people", so a Salesperson class becomes a salespeople table. - * Class name ends in "man": The "man" is replaced with "men", so a Spokesman class becomes a spokesmen table. - * Class name ends in "sis": The "i" is replaced with an "e", so a Basis class becomes a bases table. - * Class name ends in "tum" or "ium": The "um" is replaced with an "a", so a Datum class becomes a data table. - * Class name ends in "child": The "child" is replaced with "children", so a NodeChild class becomes a node_children table. - * Class name ends in an "s": No additional characters are added or removed. - * Class name doesn't end in "s": An "s" is appended, so a Comment class becomes a comments table. - * Class name with word compositions: Compositions are underscored, so CreditCard class becomes a credit_cards table. - Additionally, the class-level table_name_prefix is prepended to the table_name and the table_name_suffix is appended. - So if you have "myapp_" as a prefix, the table name guess for an Account class becomes "myapp_accounts". - - You can also overwrite this class method to allow for unguessable links, such as a Mouse class with a link to a - "mice" table. Example: - - class Mouse < ActiveRecord::Base - def self.table_name() "mice" end - end - - This conversion is now done through an external class called Inflector residing in lib/active_record/support/inflector.rb. - -* Added find_all_in_collection to has_many defined collections. Works like this: - - class Firm < ActiveRecord::Base - has_many :clients - end - - firm.id # => 1 - firm.find_all_in_clients "revenue > 1000" # SELECT * FROM clients WHERE firm_id = 1 AND revenue > 1000 - - [Requested by Dave Thomas] - -* Fixed finders for inheritance hierarchies deeper than one level [Florian Weber] - -* Added add_on_boundry_breaking to errors to accompany add_on_empty as a default validation method. It's used like this: - - class Person < ActiveRecord::Base - protected - def validation - errors.add_on_boundry_breaking "password", 3..20 - end - end - - This will add an error to the tune of "is too short (minimum is 3 characters)" or "is too long (minimum is 20 characters)" if - the password is outside the boundry. The messages can be changed by passing a third and forth parameter as message strings. - -* Implemented a clone method that works properly with AR. It returns a clone of the record that - hasn't been assigned an id yet and is treated as a new record. - -* Allow for domain sockets in PostgreSQL by not assuming localhost when no host is specified [Scott Barron] - -* Fixed that bignums are saved properly instead of attempted to be YAMLized [Andreas Schwartz] - -* Fixed a bug in the GEM where the rdoc options weren't being passed according to spec [Chad Fowler] - -* Fixed a bug with the exclusively_dependent option for has_many - - -*0.9.4* - -* Correctly guesses the primary key when the class is inside a module [Dave Steinberg]. - -* Added [] and []= as alternatives to read_attribute and write_attribute [Dave Steinberg] - -* has_and_belongs_to_many now accepts an :order key to determine in which order the collection is returned [radsaq]. - -* The ids passed to find and find_on_conditions are now automatically sanitized. - -* Added escaping of plings in YAML content. - -* Multi-parameter assigns where all the parameters are empty will now be set to nil instead of a new instance of their class. - -* Proper type within an inheritance hierarchy is now ensured already at object initialization (instead of first at create) - - -*0.9.3* - -* Fixed bug with using a different primary key name together with has_and_belongs_to_many [Investigation by Scott] - -* Added :exclusively_dependent option to the has_many association macro. The doc reads: - - If set to true all the associated object are deleted in one SQL statement without having their - before_destroy callback run. This should only be used on associations that depend solely on - this class and don't need to do any clean-up in before_destroy. The upside is that it's much - faster, especially if there's a counter_cache involved. - -* Added :port key to connection options, so the PostgreSQL and MySQL adapters can connect to a database server - running on another port than the default. - -* Converted the new natural singleton methods that prevented AR objects from being saved by PStore - (and hence be placed in a Rails session) to a module. [Florian Weber] - -* Fixed the use of floats (was broken since 0.9.0+) - -* Fixed PostgreSQL adapter so default values are displayed properly when used in conjunction with - Action Pack scaffolding. - -* Fixed booleans support for PostgreSQL (use real true/false on boolean fields instead of 0/1 on tinyints) [radsaq] - - -*0.9.2* - -* Added static method for instantly updating a record - -* Treat decimal and numeric as Ruby floats [Andreas Schwartz] - -* Treat chars as Ruby strings (fixes problem for Action Pack form helpers too) - -* Removed debugging output accidently left in (which would screw web applications) - - -*0.9.1* - -* Added MIT license - -* Added natural object-style assignment for has_and_belongs_to_many associations. Consider the following model: - - class Event < ActiveRecord::Base - has_one_and_belongs_to_many :sponsors - end - - class Sponsor < ActiveRecord::Base - has_one_and_belongs_to_many :sponsors - end - - Earlier, you'd have to use synthetic methods for creating associations between two objects of the above class: - - roskilde_festival.add_to_sponsors(carlsberg) - roskilde_festival.remove_from_sponsors(carlsberg) - - nike.add_to_events(world_cup) - nike.remove_from_events(world_cup) - - Now you can use regular array-styled methods: - - roskilde_festival.sponsors << carlsberg - roskilde_festival.sponsors.delete(carlsberg) - - nike.events << world_cup - nike.events.delete(world_cup) - -* Added delete method for has_many associations. Using this will nullify an association between the has_many and the belonging - object by setting the foreign key to null. Consider this model: - - class Post < ActiveRecord::Base - has_many :comments - end - - class Comment < ActiveRecord::Base - belongs_to :post - end - - You could do something like: - - funny_comment.has_post? # => true - announcement.comments.delete(funny_comment) - funny_comment.has_post? # => false - - -*0.9.0* - -* Active Record is now thread safe! (So you can use it with Cerise and WEBrick applications) - [Implementation idea by Michael Neumann, debugging assistance by Jamis Buck] - -* Improved performance by roughly 400% on a basic test case of pulling 100 records and querying one attribute. - This brings the tax for using Active Record instead of "riding on the metal" (using MySQL-ruby C-driver directly) down to ~50%. - Done by doing lazy type conversions and caching column information on the class-level. - -* Added callback objects and procs as options for implementing the target for callback macros. - -* Added "counter_cache" option to belongs_to that automates the usage of increment_counter and decrement_counter. Consider: - - class Post < ActiveRecord::Base - has_many :comments - end - - class Comment < ActiveRecord::Base - belongs_to :post - end - - Iterating over 100 posts like this: - - <% for post in @posts %> - <%= post.title %> has <%= post.comments_count %> comments - <% end %> - - Will generate 100 SQL count queries -- one for each call to post.comments_count. If you instead add a "comments_count" int column - to the posts table and rewrite the comments association macro with: - - class Comment < ActiveRecord::Base - belongs_to :post, :counter_cache => true - end - - Those 100 SQL count queries will be reduced to zero. Beware that counter caching is only appropriate for objects that begin life - with the object it's specified to belong with and is destroyed like that as well. Typically objects where you would also specify - :dependent => true. If your objects switch from one belonging to another (like a post that can be move from one category to another), - you'll have to manage the counter yourself. - -* Added natural object-style assignment for has_one and belongs_to associations. Consider the following model: - - class Project < ActiveRecord::Base - has_one :manager - end - - class Manager < ActiveRecord::Base - belongs_to :project - end - - Earlier, assignments would work like following regardless of which way the assignment told the best story: - - active_record.manager_id = david.id - - Now you can do it either from the belonging side: - - david.project = active_record - - ...or from the having side: - - active_record.manager = david - - If the assignment happens from the having side, the assigned object is automatically saved. So in the example above, the - project_id attribute on david would be set to the id of active_record, then david would be saved. - -* Added natural object-style assignment for has_many associations [Florian Weber]. Consider the following model: - - class Project < ActiveRecord::Base - has_many :milestones - end - - class Milestone < ActiveRecord::Base - belongs_to :project - end - - Earlier, assignments would work like following regardless of which way the assignment told the best story: - - deadline.project_id = active_record.id - - Now you can do it either from the belonging side: - - deadline.project = active_record - - ...or from the having side: - - active_record.milestones << deadline - - The milestone is automatically saved with the new foreign key. - -* API CHANGE: Attributes for text (or blob or similar) columns will now have unknown classes stored using YAML instead of using - to_s. (Known classes that won't be yamelized are: String, NilClass, TrueClass, FalseClass, Fixnum, Date, and Time). - Likewise, data pulled out of text-based attributes will be attempted converged using Yaml if they have the "--- " header. - This was primarily done to be enable the storage of hashes and arrays without wrapping them in aggregations, so now you can do: - - user = User.find(1) - user.preferences = { "background" => "black", "display" => large } - user.save - - User.find(1).preferences # => { "background" => "black", "display" => large } - - Please note that this method should only be used when you don't care about representing the object in proper columns in - the database. A money object consisting of an amount and a currency is still a much better fit for a value object done through - aggregations than this new option. - -* POSSIBLE CODE BREAKAGE: As a consequence of the lazy type conversions, it's a bad idea to reference the @attributes hash - directly (it always was, but now it's paramount that you don't). If you do, you won't get the type conversion. So to implement - new accessors for existing attributes, use read_attribute(attr_name) and write_attribute(attr_name, value) instead. Like this: - - class Song < ActiveRecord::Base - # Uses an integer of seconds to hold the length of the song - - def length=(minutes) - write_attribute("length", minutes * 60) - end - - def length - read_attribute("length") / 60 - end - end - - The clever kid will notice that this opens a door to sidestep the automated type conversion by using @attributes directly. - This is not recommended as read/write_attribute may be granted additional responsibilities in the future, but if you think - you know what you're doing and aren't afraid of future consequences, this is an option. - -* Applied a few minor bug fixes reported by Daniel Von Fange. - - -*0.8.4* - -_Reflection_ - -* Added ActiveRecord::Reflection with a bunch of methods and classes for reflecting in aggregations and associations. - -* Added Base.columns and Base.content_columns which returns arrays of column description (type, default, etc) objects. - -* Added Base#attribute_names which returns an array of names for the attributes available on the object. - -* Added Base#column_for_attribute(name) which returns the column description object for the named attribute. - - -_Misc_ - -* Added multi-parameter assignment: - - # Instantiate objects for all attribute classes that needs more than one constructor parameter. This is done - # by calling new on the column type or aggregation type (through composed_of) object with these parameters. - # So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate - # written_on (a date type) with Date.new("2004", "6", "24"). You can also specify a typecast character in the - # parenteses to have the parameters typecasted before they're used in the constructor. Use i for Fixnum, f for Float, - # s for String, and a for Array. - - This is incredibly useful for assigning dates from HTML drop-downs of month, year, and day. - -* Fixed bug with custom primary key column name and Base.find on multiple parameters. - -* Fixed bug with dependent option on has_one associations if there was no associated object. - - -*0.8.3* - -_Transactions_ - -* Added transactional protection for destroy (important for the new :dependent option) [Suggested by Carl Youngblood] - -* Fixed so transactions are ignored on MyISAM tables for MySQL (use InnoDB to get transactions) - -* Changed transactions so only exceptions will cause a rollback, not returned false. - - -_Mapping_ - -* Added support for non-integer primary keys [Aredridel/earlier work by Michael Neumann] - - User.find "jdoe" - Product.find "PDKEY-INT-12" - -* Added option to specify naming method for primary key column. ActiveRecord::Base.primary_key_prefix_type can either - be set to nil, :table_name, or :table_name_with_underscore. :table_name will assume that Product class has a primary key - of "productid" and :table_name_with_underscore will assume "product_id". The default nil will just give "id". - -* Added an overwriteable primary_key method that'll instruct AR to the name of the - id column [Aredridele/earlier work by Guan Yang] - - class Project < ActiveRecord::Base - def self.primary_key() "project_id" end - end - -* Fixed that Active Records can safely associate inside and out of modules. - - class MyApplication::Account < ActiveRecord::Base - has_many :clients # will look for MyApplication::Client - has_many :interests, :class_name => "Business::Interest" # will look for Business::Interest - end - -* Fixed that Active Records can safely live inside modules [Aredridel] - - class MyApplication::Account < ActiveRecord::Base - end - - -_Misc_ - -* Added freeze call to value object assignments to ensure they remain immutable [Spotted by Gavin Sinclair] - -* Changed interface for specifying observed class in observers. Was OBSERVED_CLASS constant, now is - observed_class() class method. This is more consistant with things like self.table_name(). Works like this: - - class AuditObserver < ActiveRecord::Observer - def self.observed_class() Account end - def after_update(account) - AuditTrail.new(account, "UPDATED") - end - end - - [Suggested by Gavin Sinclair] - -* Create new Active Record objects by setting the attributes through a block. Like this: - - person = Person.new do |p| - p.name = 'Freddy' - p.age = 19 - end - - [Suggested by Gavin Sinclair] - - -*0.8.2* - -* Added inheritable callback queues that can ensure that certain callback methods or inline fragments are - run throughout the entire inheritance hierarchy. Regardless of whether a descendant overwrites the callback - method: - - class Topic < ActiveRecord::Base - before_destroy :destroy_author, 'puts "I'm an inline fragment"' - end - - Learn more in link:classes/ActiveRecord/Callbacks.html - -* Added :dependent option to has_many and has_one, which will automatically destroy associated objects when - the holder is destroyed: - - class Album < ActiveRecord::Base - has_many :tracks, :dependent => true - end - - All the associated tracks are destroyed when the album is. - -* Added Base.create as a factory that'll create, save, and return a new object in one step. - -* Automatically convert strings in config hashes to symbols for the _connection methods. This allows you - to pass the argument hashes directly from yaml. (Luke) - -* Fixed the install.rb to include simple.rb [Spotted by Kevin Bullock] - -* Modified block syntax to better follow our code standards outlined in - http://www.rubyonrails.org/CodingStandards - - -*0.8.1* - -* Added object-level transactions [Austin Ziegler] - -* Changed adapter-specific connection methods to use centralized ActiveRecord::Base.establish_connection, - which is parametized through a config hash with symbol keys instead of a regular parameter list. - This will allow for database connections to be opened in a more generic fashion. (Luke) - - NOTE: This requires all *_connections to be updated! Read more in: - http://ar.rubyonrails.org/classes/ActiveRecord/Base.html#M000081 - -* Fixed SQLite adapter so objects fetched from has_and_belongs_to_many have proper attributes - (t.name is now name). [Spotted by Garrett Rooney] - -* Fixed SQLite adapter so dates are returned as Date objects, not Time objects [Spotted by Gavin Sinclair] - -* Fixed requirement of date class, so date conversions are succesful regardless of whether you - manually require date or not. - - -*0.8.0* - -* Added transactions - -* Changed Base.find to also accept either a list (1, 5, 6) or an array of ids ([5, 7]) - as parameter and then return an array of objects instead of just an object - -* Fixed method has_collection? for has_and_belongs_to_many macro to behave as a - collection, not an association - -* Fixed SQLite adapter so empty or nil values in columns of datetime, date, or time type - aren't treated as current time [Spotted by Gavin Sinclair] - - -*0.7.6* - -* Fixed the install.rb to create the lib/active_record/support directory [Spotted by Gavin Sinclair] -* Fixed that has_association? would always return true [Daniel Von Fange] diff --git a/vendor/rails/activerecord/README b/vendor/rails/activerecord/README deleted file mode 100644 index d68eb28..0000000 --- a/vendor/rails/activerecord/README +++ /dev/null @@ -1,351 +0,0 @@ -= Active Record -- Object-relation mapping put on rails - -Active Record connects business objects and database tables to create a persistable -domain model where logic and data are presented in one wrapping. It's an implementation -of the object-relational mapping (ORM) pattern[http://www.martinfowler.com/eaaCatalog/activeRecord.html] -by the same name as described by Martin Fowler: - - "An object that wraps a row in a database table or view, encapsulates - the database access, and adds domain logic on that data." - -Active Record's main contribution to the pattern is to relieve the original of two stunting problems: -lack of associations and inheritance. By adding a simple domain language-like set of macros to describe -the former and integrating the Single Table Inheritance pattern for the latter, Active Record narrows the -gap of functionality between the data mapper and active record approach. - -A short rundown of the major features: - -* Automated mapping between classes and tables, attributes and columns. - - class Product < ActiveRecord::Base; end - - ...is automatically mapped to the table named "products", such as: - - CREATE TABLE products ( - id int(11) NOT NULL auto_increment, - name varchar(255), - PRIMARY KEY (id) - ); - - ...which again gives Product#name and Product#name=(new_name) - - {Learn more}[link:classes/ActiveRecord/Base.html] - - -* Associations between objects controlled by simple meta-programming macros. - - class Firm < ActiveRecord::Base - has_many :clients - has_one :account - belongs_to :conglomorate - end - - {Learn more}[link:classes/ActiveRecord/Associations/ClassMethods.html] - - -* Aggregations of value objects controlled by simple meta-programming macros. - - class Account < ActiveRecord::Base - composed_of :balance, :class_name => "Money", - :mapping => %w(balance amount) - composed_of :address, - :mapping => [%w(address_street street), %w(address_city city)] - end - - {Learn more}[link:classes/ActiveRecord/Aggregations/ClassMethods.html] - - -* Validation rules that can differ for new or existing objects. - - class Account < ActiveRecord::Base - validates_presence_of :subdomain, :name, :email_address, :password - validates_uniqueness_of :subdomain - validates_acceptance_of :terms_of_service, :on => :create - validates_confirmation_of :password, :email_address, :on => :create - end - - {Learn more}[link:classes/ActiveRecord/Validations.html] - -* Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc). - - class Person < ActiveRecord::Base - def before_destroy # is called just before Person#destroy - CreditCard.find(credit_card_id).destroy - end - end - - class Account < ActiveRecord::Base - after_find :eager_load, 'self.class.announce(#{id})' - end - - {Learn more}[link:classes/ActiveRecord/Callbacks.html] - - -* Observers for the entire lifecycle - - class CommentObserver < ActiveRecord::Observer - def after_create(comment) # is called just after Comment#save - Notifications.deliver_new_comment("david@loudthinking.com", comment) - end - end - - {Learn more}[link:classes/ActiveRecord/Observer.html] - - -* Inheritance hierarchies - - class Company < ActiveRecord::Base; end - class Firm < Company; end - class Client < Company; end - class PriorityClient < Client; end - - {Learn more}[link:classes/ActiveRecord/Base.html] - - -* Transactions - - # Database transaction - Account.transaction do - david.withdrawal(100) - mary.deposit(100) - end - - {Learn more}[link:classes/ActiveRecord/Transactions/ClassMethods.html] - - -* Reflections on columns, associations, and aggregations - - reflection = Firm.reflect_on_association(:clients) - reflection.klass # => Client (class) - Firm.columns # Returns an array of column descriptors for the firms table - - {Learn more}[link:classes/ActiveRecord/Reflection/ClassMethods.html] - - -* Direct manipulation (instead of service invocation) - - So instead of (Hibernate[http://www.hibernate.org/] example): - - long pkId = 1234; - DomesticCat pk = (DomesticCat) sess.load( Cat.class, new Long(pkId) ); - // something interesting involving a cat... - sess.save(cat); - sess.flush(); // force the SQL INSERT - - Active Record lets you: - - pkId = 1234 - cat = Cat.find(pkId) - # something even more interesting involving the same cat... - cat.save - - {Learn more}[link:classes/ActiveRecord/Base.html] - - -* Database abstraction through simple adapters (~100 lines) with a shared connector - - ActiveRecord::Base.establish_connection(:adapter => "sqlite", :database => "dbfile") - - ActiveRecord::Base.establish_connection( - :adapter => "mysql", - :host => "localhost", - :username => "me", - :password => "secret", - :database => "activerecord" - ) - - {Learn more}[link:classes/ActiveRecord/Base.html#M000081] and read about the built-in support for - MySQL[link:classes/ActiveRecord/ConnectionAdapters/MysqlAdapter.html], PostgreSQL[link:classes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapter.html], SQLite[link:classes/ActiveRecord/ConnectionAdapters/SQLiteAdapter.html], Oracle[link:classes/ActiveRecord/ConnectionAdapters/OracleAdapter.html], SQLServer[link:classes/ActiveRecord/ConnectionAdapters/SQLServerAdapter.html], and DB2[link:classes/ActiveRecord/ConnectionAdapters/DB2Adapter.html]. - - -* Logging support for Log4r[http://log4r.sourceforge.net] and Logger[http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc] - - ActiveRecord::Base.logger = Logger.new(STDOUT) - ActiveRecord::Base.logger = Log4r::Logger.new("Application Log") - - -* Database agnostic schema management with Migrations - - class AddSystemSettings < ActiveRecord::Migration - def self.up - create_table :system_settings do |t| - t.string :name - t.string :label - t.text :value - t.string :type - t.integer :position - end - - SystemSetting.create :name => "notice", :label => "Use notice?", :value => 1 - end - - def self.down - drop_table :system_settings - end - end - - {Learn more}[link:classes/ActiveRecord/Migration.html] - -== Simple example (1/2): Defining tables and classes (using MySQL) - -Data definitions are specified only in the database. Active Record queries the database for -the column names (that then serves to determine which attributes are valid) on regular -object instantiation through the new constructor and relies on the column names in the rows -with the finders. - - # CREATE TABLE companies ( - # id int(11) unsigned NOT NULL auto_increment, - # client_of int(11), - # name varchar(255), - # type varchar(100), - # PRIMARY KEY (id) - # ) - -Active Record automatically links the "Company" object to the "companies" table - - class Company < ActiveRecord::Base - has_many :people, :class_name => "Person" - end - - class Firm < Company - has_many :clients - - def people_with_all_clients - clients.inject([]) { |people, client| people + client.people } - end - end - -The foreign_key is only necessary because we didn't use "firm_id" in the data definition - - class Client < Company - belongs_to :firm, :foreign_key => "client_of" - end - - # CREATE TABLE people ( - # id int(11) unsigned NOT NULL auto_increment, - # name text, - # company_id text, - # PRIMARY KEY (id) - # ) - -Active Record will also automatically link the "Person" object to the "people" table - - class Person < ActiveRecord::Base - belongs_to :company - end - -== Simple example (2/2): Using the domain - -Picking a database connection for all the Active Records - - ActiveRecord::Base.establish_connection( - :adapter => "mysql", - :host => "localhost", - :username => "me", - :password => "secret", - :database => "activerecord" - ) - -Create some fixtures - - firm = Firm.new("name" => "Next Angle") - # SQL: INSERT INTO companies (name, type) VALUES("Next Angle", "Firm") - firm.save - - client = Client.new("name" => "37signals", "client_of" => firm.id) - # SQL: INSERT INTO companies (name, client_of, type) VALUES("37signals", 1, "Firm") - client.save - -Lots of different finders - - # SQL: SELECT * FROM companies WHERE id = 1 - next_angle = Company.find(1) - - # SQL: SELECT * FROM companies WHERE id = 1 AND type = 'Firm' - next_angle = Firm.find(1) - - # SQL: SELECT * FROM companies WHERE id = 1 AND name = 'Next Angle' - next_angle = Company.find(:first, :conditions => "name = 'Next Angle'") - - next_angle = Firm.find_by_sql("SELECT * FROM companies WHERE id = 1").first - -The supertype, Company, will return subtype instances - - Firm === next_angle - -All the dynamic methods added by the has_many macro - - next_angle.clients.empty? # true - next_angle.clients.size # total number of clients - all_clients = next_angle.clients - -Constrained finds makes access security easier when ID comes from a web-app - - # SQL: SELECT * FROM companies WHERE client_of = 1 AND type = 'Client' AND id = 2 - thirty_seven_signals = next_angle.clients.find(2) - -Bi-directional associations thanks to the "belongs_to" macro - - thirty_seven_signals.firm.nil? # true - - -== Philosophy - -Active Record attempts to provide a coherent wrapper as a solution for the inconvenience that is -object-relational mapping. The prime directive for this mapping has been to minimize -the amount of code needed to build a real-world domain model. This is made possible -by relying on a number of conventions that make it easy for Active Record to infer -complex relations and structures from a minimal amount of explicit direction. - -Convention over Configuration: -* No XML-files! -* Lots of reflection and run-time extension -* Magic is not inherently a bad word - -Admit the Database: -* Lets you drop down to SQL for odd cases and performance -* Doesn't attempt to duplicate or replace data definitions - - -== Download - -The latest version of Active Record can be found at - -* http://rubyforge.org/project/showfiles.php?group_id=182 - -Documentation can be found at - -* http://ar.rubyonrails.com - - -== Installation - -The prefered method of installing Active Record is through its GEM file. You'll need to have -RubyGems[http://rubygems.rubyforge.org/wiki/wiki.pl] installed for that, though. If you have, -then use: - - % [sudo] gem install activerecord-1.10.0.gem - -You can also install Active Record the old-fashioned way with the following command: - - % [sudo] ruby install.rb - -from its distribution directory. - - -== License - -Active Record is released under the MIT license. - - -== Support - -The Active Record homepage is http://www.rubyonrails.com. You can find the Active Record -RubyForge page at http://rubyforge.org/projects/activerecord. And as Jim from Rake says: - - Feel free to submit commits or feature requests. If you send a patch, - remember to update the corresponding unit tests. If fact, I prefer - new feature to be submitted in the form of new unit tests. - -For other information, feel free to ask on the rubyonrails-talk -(http://groups.google.com/group/rubyonrails-talk) mailing list. diff --git a/vendor/rails/activerecord/RUNNING_UNIT_TESTS b/vendor/rails/activerecord/RUNNING_UNIT_TESTS deleted file mode 100644 index 39fc867..0000000 --- a/vendor/rails/activerecord/RUNNING_UNIT_TESTS +++ /dev/null @@ -1,36 +0,0 @@ -== Creating the test database - -The default names for the test databases are "activerecord_unittest" and -"activerecord_unittest2". If you want to use another database name then be sure -to update the connection adapter setups you want to test with in -test/connections/<your database>/connection.rb. -When you have the database online, you can import the fixture tables with -the test/schema/*.sql files. - -Make sure that you create database objects with the same user that you specified in -connection.rb otherwise (on Postgres, at least) tests for default values will fail. - -== Running with Rake - -The easiest way to run the unit tests is through Rake. The default task runs -the entire test suite for all the adapters. You can also run the suite on just -one adapter by using the tasks test_mysql, test_sqlite, test_postgresql or any -of the other test_ tasks. For more information, checkout the full array of rake -tasks with "rake -T" - -Rake can be found at http://rake.rubyforge.org - -== Running by hand - -Unit tests are located in test/cases directory. If you only want to run a single test suite, -you can do so with: - - rake test_mysql TEST=test/cases/base_test.rb - -That'll run the base suite using the MySQL-Ruby adapter. Some tests rely on the schema -being initialized - you can initialize the schema with: - - rake test_mysql TEST=test/cases/aaa_create_tables_test.rb - - - diff --git a/vendor/rails/activerecord/Rakefile b/vendor/rails/activerecord/Rakefile deleted file mode 100644 index b50008c..0000000 --- a/vendor/rails/activerecord/Rakefile +++ /dev/null @@ -1,253 +0,0 @@ -require 'rubygems' -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' -require 'rake/packagetask' -require 'rake/gempackagetask' -require 'rake/contrib/sshpublisher' - -require File.join(File.dirname(__FILE__), 'lib', 'active_record', 'version') -require File.expand_path(File.dirname(__FILE__)) + "/test/config" - -PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' -PKG_NAME = 'activerecord' -PKG_VERSION = ActiveRecord::VERSION::STRING + PKG_BUILD -PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" - -RELEASE_NAME = "REL #{PKG_VERSION}" - -RUBY_FORGE_PROJECT = "activerecord" -RUBY_FORGE_USER = "webster132" - -MYSQL_DB_USER = 'rails' - -PKG_FILES = FileList[ - "lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "[A-Z]*", "install.rb", "Rakefile" -].exclude(/\bCVS\b|~$/) - - -desc 'Run mysql, sqlite, and postgresql tests by default' -task :default => :test - -desc 'Run mysql, sqlite, and postgresql tests' -task :test => defined?(JRUBY_VERSION) ? - %w(test_jdbcmysql test_jdbcsqlite3 test_jdbcpostgresql) : - %w(test_mysql test_sqlite3 test_postgresql) - -for adapter in %w( mysql postgresql sqlite sqlite3 firebird db2 oracle sybase openbase frontbase jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb ) - Rake::TestTask.new("test_#{adapter}") { |t| - if adapter =~ /jdbc/ - t.libs << "test" << "test/connections/jdbc_#{adapter}" - else - t.libs << "test" << "test/connections/native_#{adapter}" - end - adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z]+/] - t.test_files=Dir.glob( "test/cases/**/*_test{,_#{adapter_short}}.rb" ).sort - t.verbose = true - } - - namespace adapter do - task :test => "test_#{adapter}" - end -end - -namespace :mysql do - desc 'Build the MySQL test databases' - task :build_databases do - %x( mysqladmin --user=#{MYSQL_DB_USER} create activerecord_unittest ) - %x( mysqladmin --user=#{MYSQL_DB_USER} create activerecord_unittest2 ) - end - - desc 'Drop the MySQL test databases' - task :drop_databases do - %x( mysqladmin --user=#{MYSQL_DB_USER} -f drop activerecord_unittest ) - %x( mysqladmin --user=#{MYSQL_DB_USER} -f drop activerecord_unittest2 ) - end - - desc 'Rebuild the MySQL test databases' - task :rebuild_databases => [:drop_databases, :build_databases] -end - -task :build_mysql_databases => 'mysql:build_databases' -task :drop_mysql_databases => 'mysql:drop_databases' -task :rebuild_mysql_databases => 'mysql:rebuild_databases' - - -namespace :postgresql do - desc 'Build the PostgreSQL test databases' - task :build_databases do - %x( createdb activerecord_unittest ) - %x( createdb activerecord_unittest2 ) - end - - desc 'Drop the PostgreSQL test databases' - task :drop_databases do - %x( dropdb activerecord_unittest ) - %x( dropdb activerecord_unittest2 ) - end - - desc 'Rebuild the PostgreSQL test databases' - task :rebuild_databases => [:drop_databases, :build_databases] -end - -task :build_postgresql_databases => 'postgresql:build_databases' -task :drop_postgresql_databases => 'postgresql:drop_databases' -task :rebuild_postgresql_databases => 'postgresql:rebuild_databases' - - -namespace :frontbase do - desc 'Build the FrontBase test databases' - task :build_databases => :rebuild_frontbase_databases - - desc 'Rebuild the FrontBase test databases' - task :rebuild_databases do - build_frontbase_database = Proc.new do |db_name, sql_definition_file| - %( - STOP DATABASE #{db_name}; - DELETE DATABASE #{db_name}; - CREATE DATABASE #{db_name}; - - CONNECT TO #{db_name} AS SESSION_NAME USER _SYSTEM; - SET COMMIT FALSE; - - CREATE USER RAILS; - CREATE SCHEMA RAILS AUTHORIZATION RAILS; - COMMIT; - - SET SESSION AUTHORIZATION RAILS; - SCRIPT '#{sql_definition_file}'; - - COMMIT; - - DISCONNECT ALL; - ) - end - create_activerecord_unittest = build_frontbase_database['activerecord_unittest', File.join(SCHEMA_ROOT, 'frontbase.sql')] - create_activerecord_unittest2 = build_frontbase_database['activerecord_unittest2', File.join(SCHEMA_ROOT, 'frontbase2.sql')] - execute_frontbase_sql = Proc.new do |sql| - system(<<-SHELL) - /Library/FrontBase/bin/sql92 <<-SQL - #{sql} - SQL - SHELL - end - execute_frontbase_sql[create_activerecord_unittest] - execute_frontbase_sql[create_activerecord_unittest2] - end -end - -task :build_frontbase_databases => 'frontbase:build_databases' -task :rebuild_frontbase_databases => 'frontbase:rebuild_databases' - - -# Generate the RDoc documentation - -Rake::RDocTask.new { |rdoc| - rdoc.rdoc_dir = 'doc' - rdoc.title = "Active Record -- Object-relation mapping put on rails" - rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object' - rdoc.options << '--charset' << 'utf-8' - rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo' - rdoc.rdoc_files.include('README', 'RUNNING_UNIT_TESTS', 'CHANGELOG') - rdoc.rdoc_files.include('lib/**/*.rb') - rdoc.rdoc_files.exclude('lib/active_record/vendor/*') - rdoc.rdoc_files.include('dev-utils/*.rb') -} - -# Enhance rdoc task to copy referenced images also -task :rdoc do - FileUtils.mkdir_p "doc/files/examples/" - FileUtils.copy "examples/associations.png", "doc/files/examples/associations.png" -end - - -# Create compressed packages - -dist_dirs = [ "lib", "test", "examples" ] - -spec = Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = PKG_NAME - s.version = PKG_VERSION - s.summary = "Implements the ActiveRecord pattern for ORM." - s.description = %q{Implements the ActiveRecord pattern (Fowler, PoEAA) for ORM. It ties database tables and classes together for business objects, like Customer or Subscription, that can find, save, and destroy themselves without resorting to manual SQL.} - - s.files = [ "Rakefile", "install.rb", "README", "RUNNING_UNIT_TESTS", "CHANGELOG" ] - dist_dirs.each do |dir| - s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) } - end - - s.add_dependency('activesupport', '= 2.3.2' + PKG_BUILD) - - s.files.delete FIXTURES_ROOT + "/fixture_database.sqlite" - s.files.delete FIXTURES_ROOT + "/fixture_database_2.sqlite" - s.files.delete FIXTURES_ROOT + "/fixture_database.sqlite3" - s.files.delete FIXTURES_ROOT + "/fixture_database_2.sqlite3" - s.require_path = 'lib' - s.autorequire = 'active_record' - - s.has_rdoc = true - s.extra_rdoc_files = %w( README ) - s.rdoc_options.concat ['--main', 'README'] - - s.author = "David Heinemeier Hansson" - s.email = "david@loudthinking.com" - s.homepage = "http://www.rubyonrails.org" - s.rubyforge_project = "activerecord" -end - -Rake::GemPackageTask.new(spec) do |p| - p.gem_spec = spec - p.need_tar = true - p.need_zip = true -end - -task :lines do - lines, codelines, total_lines, total_codelines = 0, 0, 0, 0 - - for file_name in FileList["lib/active_record/**/*.rb"] - next if file_name =~ /vendor/ - f = File.open(file_name) - - while line = f.gets - lines += 1 - next if line =~ /^\s*$/ - next if line =~ /^\s*#/ - codelines += 1 - end - puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}" - - total_lines += lines - total_codelines += codelines - - lines, codelines = 0, 0 - end - - puts "Total: Lines #{total_lines}, LOC #{total_codelines}" -end - - -# Publishing ------------------------------------------------------ - -desc "Publish the beta gem" -task :pgem => [:package] do - Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload - `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'` -end - -desc "Publish the API documentation" -task :pdoc => [:rdoc] do - Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ar", "doc").upload -end - -desc "Publish the release files to RubyForge." -task :release => [ :package ] do - require 'rubyforge' - require 'rake/contrib/rubyforgepublisher' - - packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" } - - rubyforge = RubyForge.new - rubyforge.login - rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages) -end diff --git a/vendor/rails/activerecord/examples/associations.png b/vendor/rails/activerecord/examples/associations.png deleted file mode 100644 index 661c7a8..0000000 Binary files a/vendor/rails/activerecord/examples/associations.png and /dev/null differ diff --git a/vendor/rails/activerecord/install.rb b/vendor/rails/activerecord/install.rb deleted file mode 100644 index c87398b..0000000 --- a/vendor/rails/activerecord/install.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'rbconfig' -require 'find' -require 'ftools' - -include Config - -# this was adapted from rdoc's install.rb by ways of Log4r - -$sitedir = CONFIG["sitelibdir"] -unless $sitedir - version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"] - $libdir = File.join(CONFIG["libdir"], "ruby", version) - $sitedir = $:.find {|x| x =~ /site_ruby/ } - if !$sitedir - $sitedir = File.join($libdir, "site_ruby") - elsif $sitedir !~ Regexp.quote(version) - $sitedir = File.join($sitedir, version) - end -end - -# the actual gruntwork -Dir.chdir("lib") - -Find.find("active_record", "active_record.rb") { |f| - if f[-3..-1] == ".rb" - File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true) - else - File::makedirs(File.join($sitedir, *f.split(/\//))) - end -} diff --git a/vendor/rails/activerecord/lib/active_record.rb b/vendor/rails/activerecord/lib/active_record.rb deleted file mode 100644 index 2f8c5c7..0000000 --- a/vendor/rails/activerecord/lib/active_record.rb +++ /dev/null @@ -1,84 +0,0 @@ -#-- -# Copyright (c) 2004-2009 David Heinemeier Hansson -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ - -begin - require 'active_support' -rescue LoadError - activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib" - if File.directory?(activesupport_path) - $:.unshift activesupport_path - require 'active_support' - end -end - -module ActiveRecord - # TODO: Review explicit loads to see if they will automatically be handled by the initilizer. - def self.load_all! - [Base, DynamicFinderMatch, ConnectionAdapters::AbstractAdapter] - end - - autoload :VERSION, 'active_record/version' - - autoload :ActiveRecordError, 'active_record/base' - autoload :ConnectionNotEstablished, 'active_record/base' - - autoload :Aggregations, 'active_record/aggregations' - autoload :AssociationPreload, 'active_record/association_preload' - autoload :Associations, 'active_record/associations' - autoload :AttributeMethods, 'active_record/attribute_methods' - autoload :AutosaveAssociation, 'active_record/autosave_association' - autoload :Base, 'active_record/base' - autoload :Batches, 'active_record/batches' - autoload :Calculations, 'active_record/calculations' - autoload :Callbacks, 'active_record/callbacks' - autoload :Dirty, 'active_record/dirty' - autoload :DynamicFinderMatch, 'active_record/dynamic_finder_match' - autoload :DynamicScopeMatch, 'active_record/dynamic_scope_match' - autoload :Migration, 'active_record/migration' - autoload :Migrator, 'active_record/migration' - autoload :NamedScope, 'active_record/named_scope' - autoload :NestedAttributes, 'active_record/nested_attributes' - autoload :Observing, 'active_record/observer' - autoload :QueryCache, 'active_record/query_cache' - autoload :Reflection, 'active_record/reflection' - autoload :Schema, 'active_record/schema' - autoload :SchemaDumper, 'active_record/schema_dumper' - autoload :Serialization, 'active_record/serialization' - autoload :SessionStore, 'active_record/session_store' - autoload :TestCase, 'active_record/test_case' - autoload :Timestamp, 'active_record/timestamp' - autoload :Transactions, 'active_record/transactions' - autoload :Validations, 'active_record/validations' - - module Locking - autoload :Optimistic, 'active_record/locking/optimistic' - autoload :Pessimistic, 'active_record/locking/pessimistic' - end - - module ConnectionAdapters - autoload :AbstractAdapter, 'active_record/connection_adapters/abstract_adapter' - end -end - -require 'active_record/i18n_interpolation_deprecation' -I18n.load_path << File.dirname(__FILE__) + '/active_record/locale/en.yml' diff --git a/vendor/rails/activerecord/lib/active_record/aggregations.rb b/vendor/rails/activerecord/lib/active_record/aggregations.rb deleted file mode 100644 index 1eefebb..0000000 --- a/vendor/rails/activerecord/lib/active_record/aggregations.rb +++ /dev/null @@ -1,261 +0,0 @@ -module ActiveRecord - module Aggregations # :nodoc: - def self.included(base) - base.extend(ClassMethods) - end - - def clear_aggregation_cache #:nodoc: - self.class.reflect_on_all_aggregations.to_a.each do |assoc| - instance_variable_set "@#{assoc.name}", nil - end unless self.new_record? - end - - # Active Record implements aggregation through a macro-like class method called +composed_of+ for representing attributes - # as value objects. It expresses relationships like "Account [is] composed of Money [among other things]" or "Person [is] - # composed of [an] address". Each call to the macro adds a description of how the value objects are created from the - # attributes of the entity object (when the entity is initialized either as a new object or from finding an existing object) - # and how it can be turned back into attributes (when the entity is saved to the database). Example: - # - # class Customer < ActiveRecord::Base - # composed_of :balance, :class_name => "Money", :mapping => %w(balance amount) - # composed_of :address, :mapping => [ %w(address_street street), %w(address_city city) ] - # end - # - # The customer class now has the following methods to manipulate the value objects: - # * <tt>Customer#balance, Customer#balance=(money)</tt> - # * <tt>Customer#address, Customer#address=(address)</tt> - # - # These methods will operate with value objects like the ones described below: - # - # class Money - # include Comparable - # attr_reader :amount, :currency - # EXCHANGE_RATES = { "USD_TO_DKK" => 6 } - # - # def initialize(amount, currency = "USD") - # @amount, @currency = amount, currency - # end - # - # def exchange_to(other_currency) - # exchanged_amount = (amount * EXCHANGE_RATES["#{currency}_TO_#{other_currency}"]).floor - # Money.new(exchanged_amount, other_currency) - # end - # - # def ==(other_money) - # amount == other_money.amount && currency == other_money.currency - # end - # - # def <=>(other_money) - # if currency == other_money.currency - # amount <=> amount - # else - # amount <=> other_money.exchange_to(currency).amount - # end - # end - # end - # - # class Address - # attr_reader :street, :city - # def initialize(street, city) - # @street, @city = street, city - # end - # - # def close_to?(other_address) - # city == other_address.city - # end - # - # def ==(other_address) - # city == other_address.city && street == other_address.street - # end - # end - # - # Now it's possible to access attributes from the database through the value objects instead. If you choose to name the - # composition the same as the attribute's name, it will be the only way to access that attribute. That's the case with our - # +balance+ attribute. You interact with the value objects just like you would any other attribute, though: - # - # customer.balance = Money.new(20) # sets the Money value object and the attribute - # customer.balance # => Money value object - # customer.balance.exchange_to("DKK") # => Money.new(120, "DKK") - # customer.balance > Money.new(10) # => true - # customer.balance == Money.new(20) # => true - # customer.balance < Money.new(5) # => false - # - # Value objects can also be composed of multiple attributes, such as the case of Address. The order of the mappings will - # determine the order of the parameters. Example: - # - # customer.address_street = "Hyancintvej" - # customer.address_city = "Copenhagen" - # customer.address # => Address.new("Hyancintvej", "Copenhagen") - # customer.address = Address.new("May Street", "Chicago") - # customer.address_street # => "May Street" - # customer.address_city # => "Chicago" - # - # == Writing value objects - # - # Value objects are immutable and interchangeable objects that represent a given value, such as a Money object representing - # $5. Two Money objects both representing $5 should be equal (through methods such as <tt>==</tt> and <tt><=></tt> from Comparable if ranking - # makes sense). This is unlike entity objects where equality is determined by identity. An entity class such as Customer can - # easily have two different objects that both have an address on Hyancintvej. Entity identity is determined by object or - # relational unique identifiers (such as primary keys). Normal ActiveRecord::Base classes are entity objects. - # - # It's also important to treat the value objects as immutable. Don't allow the Money object to have its amount changed after - # creation. Create a new Money object with the new value instead. This is exemplified by the Money#exchange_to method that - # returns a new value object instead of changing its own values. Active Record won't persist value objects that have been - # changed through means other than the writer method. - # - # The immutable requirement is enforced by Active Record by freezing any object assigned as a value object. Attempting to - # change it afterwards will result in a ActiveSupport::FrozenObjectError. - # - # Read more about value objects on http://c2.com/cgi/wiki?ValueObject and on the dangers of not keeping value objects - # immutable on http://c2.com/cgi/wiki?ValueObjectsShouldBeImmutable - # - # == Custom constructors and converters - # - # By default value objects are initialized by calling the <tt>new</tt> constructor of the value class passing each of the - # mapped attributes, in the order specified by the <tt>:mapping</tt> option, as arguments. If the value class doesn't support - # this convention then +composed_of+ allows a custom constructor to be specified. - # - # When a new value is assigned to the value object the default assumption is that the new value is an instance of the value - # class. Specifying a custom converter allows the new value to be automatically converted to an instance of value class if - # necessary. - # - # For example, the NetworkResource model has +network_address+ and +cidr_range+ attributes that should be aggregated using the - # NetAddr::CIDR value class (http://netaddr.rubyforge.org). The constructor for the value class is called +create+ and it - # expects a CIDR address string as a parameter. New values can be assigned to the value object using either another - # NetAddr::CIDR object, a string or an array. The <tt>:constructor</tt> and <tt>:converter</tt> options can be used to - # meet these requirements: - # - # class NetworkResource < ActiveRecord::Base - # composed_of :cidr, - # :class_name => 'NetAddr::CIDR', - # :mapping => [ %w(network_address network), %w(cidr_range bits) ], - # :allow_nil => true, - # :constructor => Proc.new { |network_address, cidr_range| NetAddr::CIDR.create("#{network_address}/#{cidr_range}") }, - # :converter => Proc.new { |value| NetAddr::CIDR.create(value.is_a?(Array) ? value.join('/') : value) } - # end - # - # # This calls the :constructor - # network_resource = NetworkResource.new(:network_address => '192.168.0.1', :cidr_range => 24) - # - # # These assignments will both use the :converter - # network_resource.cidr = [ '192.168.2.1', 8 ] - # network_resource.cidr = '192.168.0.1/24' - # - # # This assignment won't use the :converter as the value is already an instance of the value class - # network_resource.cidr = NetAddr::CIDR.create('192.168.2.1/8') - # - # # Saving and then reloading will use the :constructor on reload - # network_resource.save - # network_resource.reload - # - # == Finding records by a value object - # - # Once a +composed_of+ relationship is specified for a model, records can be loaded from the database by specifying an instance - # of the value object in the conditions hash. The following example finds all customers with +balance_amount+ equal to 20 and - # +balance_currency+ equal to "USD": - # - # Customer.find(:all, :conditions => {:balance => Money.new(20, "USD")}) - # - module ClassMethods - # Adds reader and writer methods for manipulating a value object: - # <tt>composed_of :address</tt> adds <tt>address</tt> and <tt>address=(new_address)</tt> methods. - # - # Options are: - # * <tt>:class_name</tt> - Specifies the class name of the association. Use it only if that name can't be inferred - # from the part id. So <tt>composed_of :address</tt> will by default be linked to the Address class, but - # if the real class name is CompanyAddress, you'll have to specify it with this option. - # * <tt>:mapping</tt> - Specifies the mapping of entity attributes to attributes of the value object. Each mapping - # is represented as an array where the first item is the name of the entity attribute and the second item is the - # name the attribute in the value object. The order in which mappings are defined determine the order in which - # attributes are sent to the value class constructor. - # * <tt>:allow_nil</tt> - Specifies that the value object will not be instantiated when all mapped - # attributes are +nil+. Setting the value object to +nil+ has the effect of writing +nil+ to all mapped attributes. - # This defaults to +false+. - # * <tt>:constructor</tt> - A symbol specifying the name of the constructor method or a Proc that is called to - # initialize the value object. The constructor is passed all of the mapped attributes, in the order that they - # are defined in the <tt>:mapping option</tt>, as arguments and uses them to instantiate a <tt>:class_name</tt> object. - # The default is <tt>:new</tt>. - # * <tt>:converter</tt> - A symbol specifying the name of a class method of <tt>:class_name</tt> or a Proc that is - # called when a new value is assigned to the value object. The converter is passed the single value that is used - # in the assignment and is only called if the new value is not an instance of <tt>:class_name</tt>. - # - # Option examples: - # composed_of :temperature, :mapping => %w(reading celsius) - # composed_of :balance, :class_name => "Money", :mapping => %w(balance amount), :converter => Proc.new { |balance| balance.to_money } - # composed_of :address, :mapping => [ %w(address_street street), %w(address_city city) ] - # composed_of :gps_location - # composed_of :gps_location, :allow_nil => true - # composed_of :ip_address, - # :class_name => 'IPAddr', - # :mapping => %w(ip to_i), - # :constructor => Proc.new { |ip| IPAddr.new(ip, Socket::AF_INET) }, - # :converter => Proc.new { |ip| ip.is_a?(Integer) ? IPAddr.new(ip, Socket::AF_INET) : IPAddr.new(ip.to_s) } - # - def composed_of(part_id, options = {}, &block) - options.assert_valid_keys(:class_name, :mapping, :allow_nil, :constructor, :converter) - - name = part_id.id2name - class_name = options[:class_name] || name.camelize - mapping = options[:mapping] || [ name, name ] - mapping = [ mapping ] unless mapping.first.is_a?(Array) - allow_nil = options[:allow_nil] || false - constructor = options[:constructor] || :new - converter = options[:converter] || block - - ActiveSupport::Deprecation.warn('The conversion block has been deprecated, use the :converter option instead.', caller) if block_given? - - reader_method(name, class_name, mapping, allow_nil, constructor) - writer_method(name, class_name, mapping, allow_nil, converter) - - create_reflection(:composed_of, part_id, options, self) - end - - private - def reader_method(name, class_name, mapping, allow_nil, constructor) - module_eval do - define_method(name) do |*args| - force_reload = args.first || false - if (instance_variable_get("@#{name}").nil? || force_reload) && (!allow_nil || mapping.any? {|pair| !read_attribute(pair.first).nil? }) - attrs = mapping.collect {|pair| read_attribute(pair.first)} - object = case constructor - when Symbol - class_name.constantize.send(constructor, *attrs) - when Proc, Method - constructor.call(*attrs) - else - raise ArgumentError, 'Constructor must be a symbol denoting the constructor method to call or a Proc to be invoked.' - end - instance_variable_set("@#{name}", object) - end - instance_variable_get("@#{name}") - end - end - - end - - def writer_method(name, class_name, mapping, allow_nil, converter) - module_eval do - define_method("#{name}=") do |part| - if part.nil? && allow_nil - mapping.each { |pair| self[pair.first] = nil } - instance_variable_set("@#{name}", nil) - else - unless part.is_a?(class_name.constantize) || converter.nil? - part = case converter - when Symbol - class_name.constantize.send(converter, part) - when Proc, Method - converter.call(part) - else - raise ArgumentError, 'Converter must be a symbol denoting the converter method to call or a Proc to be invoked.' - end - end - mapping.each { |pair| self[pair.first] = part.send(pair.last) } - instance_variable_set("@#{name}", part.freeze) - end - end - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/association_preload.rb b/vendor/rails/activerecord/lib/active_record/association_preload.rb deleted file mode 100644 index e4ab69a..0000000 --- a/vendor/rails/activerecord/lib/active_record/association_preload.rb +++ /dev/null @@ -1,389 +0,0 @@ -module ActiveRecord - # See ActiveRecord::AssociationPreload::ClassMethods for documentation. - module AssociationPreload #:nodoc: - def self.included(base) - base.extend(ClassMethods) - end - - # Implements the details of eager loading of ActiveRecord associations. - # Application developers should not use this module directly. - # - # ActiveRecord::Base is extended with this module. The source code in - # ActiveRecord::Base references methods defined in this module. - # - # Note that 'eager loading' and 'preloading' are actually the same thing. - # However, there are two different eager loading strategies. - # - # The first one is by using table joins. This was only strategy available - # prior to Rails 2.1. Suppose that you have an Author model with columns - # 'name' and 'age', and a Book model with columns 'name' and 'sales'. Using - # this strategy, ActiveRecord would try to retrieve all data for an author - # and all of its books via a single query: - # - # SELECT * FROM authors - # LEFT OUTER JOIN books ON authors.id = books.id - # WHERE authors.name = 'Ken Akamatsu' - # - # However, this could result in many rows that contain redundant data. After - # having received the first row, we already have enough data to instantiate - # the Author object. In all subsequent rows, only the data for the joined - # 'books' table is useful; the joined 'authors' data is just redundant, and - # processing this redundant data takes memory and CPU time. The problem - # quickly becomes worse and worse as the level of eager loading increases - # (i.e. if ActiveRecord is to eager load the associations' assocations as - # well). - # - # The second strategy is to use multiple database queries, one for each - # level of association. Since Rails 2.1, this is the default strategy. In - # situations where a table join is necessary (e.g. when the +:conditions+ - # option references an association's column), it will fallback to the table - # join strategy. - # - # See also ActiveRecord::Associations::ClassMethods, which explains eager - # loading in a more high-level (application developer-friendly) manner. - module ClassMethods - protected - - # Eager loads the named associations for the given ActiveRecord record(s). - # - # In this description, 'association name' shall refer to the name passed - # to an association creation method. For example, a model that specifies - # <tt>belongs_to :author</tt>, <tt>has_many :buyers</tt> has association - # names +:author+ and +:buyers+. - # - # == Parameters - # +records+ is an array of ActiveRecord::Base. This array needs not be flat, - # i.e. +records+ itself may also contain arrays of records. In any case, - # +preload_associations+ will preload the associations all records by - # flattening +records+. - # - # +associations+ specifies one or more associations that you want to - # preload. It may be: - # - a Symbol or a String which specifies a single association name. For - # example, specifiying +:books+ allows this method to preload all books - # for an Author. - # - an Array which specifies multiple association names. This array - # is processed recursively. For example, specifying <tt>[:avatar, :books]</tt> - # allows this method to preload an author's avatar as well as all of his - # books. - # - a Hash which specifies multiple association names, as well as - # association names for the to-be-preloaded association objects. For - # example, specifying <tt>{ :author => :avatar }</tt> will preload a - # book's author, as well as that author's avatar. - # - # +:associations+ has the same format as the +:include+ option for - # <tt>ActiveRecord::Base.find</tt>. So +associations+ could look like this: - # - # :books - # [ :books, :author ] - # { :author => :avatar } - # [ :books, { :author => :avatar } ] - # - # +preload_options+ contains options that will be passed to ActiveRecord#find - # (which is called under the hood for preloading records). But it is passed - # only one level deep in the +associations+ argument, i.e. it's not passed - # to the child associations when +associations+ is a Hash. - def preload_associations(records, associations, preload_options={}) - records = [records].flatten.compact.uniq - return if records.empty? - case associations - when Array then associations.each {|association| preload_associations(records, association, preload_options)} - when Symbol, String then preload_one_association(records, associations.to_sym, preload_options) - when Hash then - associations.each do |parent, child| - raise "parent must be an association name" unless parent.is_a?(String) || parent.is_a?(Symbol) - preload_associations(records, parent, preload_options) - reflection = reflections[parent] - parents = records.map {|record| record.send(reflection.name)}.flatten.compact - unless parents.empty? - parents.first.class.preload_associations(parents, child) - end - end - end - end - - private - - # Preloads a specific named association for the given records. This is - # called by +preload_associations+ as its base case. - def preload_one_association(records, association, preload_options={}) - class_to_reflection = {} - # Not all records have the same class, so group then preload - # group on the reflection itself so that if various subclass share the same association then we do not split them - # unnecessarily - records.group_by {|record| class_to_reflection[record.class] ||= record.class.reflections[association]}.each do |reflection, records| - raise ConfigurationError, "Association named '#{ association }' was not found; perhaps you misspelled it?" unless reflection - - # 'reflection.macro' can return 'belongs_to', 'has_many', etc. Thus, - # the following could call 'preload_belongs_to_association', - # 'preload_has_many_association', etc. - send("preload_#{reflection.macro}_association", records, reflection, preload_options) - end - end - - def add_preloaded_records_to_collection(parent_records, reflection_name, associated_record) - parent_records.each do |parent_record| - association_proxy = parent_record.send(reflection_name) - association_proxy.loaded - association_proxy.target.push(*[associated_record].flatten) - end - end - - def add_preloaded_record_to_collection(parent_records, reflection_name, associated_record) - parent_records.each do |parent_record| - parent_record.send("set_#{reflection_name}_target", associated_record) - end - end - - def set_association_collection_records(id_to_record_map, reflection_name, associated_records, key) - associated_records.each do |associated_record| - mapped_records = id_to_record_map[associated_record[key].to_s] - add_preloaded_records_to_collection(mapped_records, reflection_name, associated_record) - end - end - - def set_association_single_records(id_to_record_map, reflection_name, associated_records, key) - seen_keys = {} - associated_records.each do |associated_record| - #this is a has_one or belongs_to: there should only be one record. - #Unfortunately we can't (in portable way) ask the database for 'all records where foo_id in (x,y,z), but please - # only one row per distinct foo_id' so this where we enforce that - next if seen_keys[associated_record[key].to_s] - seen_keys[associated_record[key].to_s] = true - mapped_records = id_to_record_map[associated_record[key].to_s] - mapped_records.each do |mapped_record| - mapped_record.send("set_#{reflection_name}_target", associated_record) - end - end - end - - # Given a collection of ActiveRecord objects, constructs a Hash which maps - # the objects' IDs to the relevant objects. Returns a 2-tuple - # <tt>(id_to_record_map, ids)</tt> where +id_to_record_map+ is the Hash, - # and +ids+ is an Array of record IDs. - def construct_id_map(records, primary_key=nil) - id_to_record_map = {} - ids = [] - records.each do |record| - primary_key ||= record.class.primary_key - ids << record[primary_key] - mapped_records = (id_to_record_map[ids.last.to_s] ||= []) - mapped_records << record - end - ids.uniq! - return id_to_record_map, ids - end - - def preload_has_and_belongs_to_many_association(records, reflection, preload_options={}) - table_name = reflection.klass.quoted_table_name - id_to_record_map, ids = construct_id_map(records) - records.each {|record| record.send(reflection.name).loaded} - options = reflection.options - - conditions = "t0.#{reflection.primary_key_name} #{in_or_equals_for_ids(ids)}" - conditions << append_conditions(reflection, preload_options) - - associated_records = reflection.klass.with_exclusive_scope do - reflection.klass.find(:all, :conditions => [conditions, ids], - :include => options[:include], - :joins => "INNER JOIN #{connection.quote_table_name options[:join_table]} t0 ON #{reflection.klass.quoted_table_name}.#{reflection.klass.primary_key} = t0.#{reflection.association_foreign_key}", - :select => "#{options[:select] || table_name+'.*'}, t0.#{reflection.primary_key_name} as the_parent_record_id", - :order => options[:order]) - end - set_association_collection_records(id_to_record_map, reflection.name, associated_records, 'the_parent_record_id') - end - - def preload_has_one_association(records, reflection, preload_options={}) - return if records.first.send("loaded_#{reflection.name}?") - id_to_record_map, ids = construct_id_map(records, reflection.options[:primary_key]) - options = reflection.options - records.each {|record| record.send("set_#{reflection.name}_target", nil)} - if options[:through] - through_records = preload_through_records(records, reflection, options[:through]) - through_reflection = reflections[options[:through]] - through_primary_key = through_reflection.primary_key_name - unless through_records.empty? - source = reflection.source_reflection.name - through_records.first.class.preload_associations(through_records, source) - if through_reflection.macro == :belongs_to - rev_id_to_record_map, rev_ids = construct_id_map(records, through_primary_key) - rev_primary_key = through_reflection.klass.primary_key - through_records.each do |through_record| - add_preloaded_record_to_collection(rev_id_to_record_map[through_record[rev_primary_key].to_s], - reflection.name, through_record.send(source)) - end - else - through_records.each do |through_record| - add_preloaded_record_to_collection(id_to_record_map[through_record[through_primary_key].to_s], - reflection.name, through_record.send(source)) - end - end - end - else - set_association_single_records(id_to_record_map, reflection.name, find_associated_records(ids, reflection, preload_options), reflection.primary_key_name) - end - end - - def preload_has_many_association(records, reflection, preload_options={}) - return if records.first.send(reflection.name).loaded? - options = reflection.options - - primary_key_name = reflection.through_reflection_primary_key_name - id_to_record_map, ids = construct_id_map(records, primary_key_name || reflection.options[:primary_key]) - records.each {|record| record.send(reflection.name).loaded} - - if options[:through] - through_records = preload_through_records(records, reflection, options[:through]) - through_reflection = reflections[options[:through]] - unless through_records.empty? - source = reflection.source_reflection.name - through_records.first.class.preload_associations(through_records, source, options) - through_records.each do |through_record| - through_record_id = through_record[reflection.through_reflection_primary_key].to_s - add_preloaded_records_to_collection(id_to_record_map[through_record_id], reflection.name, through_record.send(source)) - end - end - - else - set_association_collection_records(id_to_record_map, reflection.name, find_associated_records(ids, reflection, preload_options), - reflection.primary_key_name) - end - end - - def preload_through_records(records, reflection, through_association) - through_reflection = reflections[through_association] - through_primary_key = through_reflection.primary_key_name - - if reflection.options[:source_type] - interface = reflection.source_reflection.options[:foreign_type] - preload_options = {:conditions => ["#{connection.quote_column_name interface} = ?", reflection.options[:source_type]]} - - records.compact! - records.first.class.preload_associations(records, through_association, preload_options) - - # Dont cache the association - we would only be caching a subset - through_records = [] - records.each do |record| - proxy = record.send(through_association) - - if proxy.respond_to?(:target) - through_records << proxy.target - proxy.reset - else # this is a has_one :through reflection - through_records << proxy if proxy - end - end - through_records.flatten! - else - records.first.class.preload_associations(records, through_association) - through_records = records.map {|record| record.send(through_association)}.flatten - end - through_records.compact! - through_records - end - - def preload_belongs_to_association(records, reflection, preload_options={}) - return if records.first.send("loaded_#{reflection.name}?") - options = reflection.options - primary_key_name = reflection.primary_key_name - - if options[:polymorphic] - polymorph_type = options[:foreign_type] - klasses_and_ids = {} - - # Construct a mapping from klass to a list of ids to load and a mapping of those ids back to their parent_records - records.each do |record| - if klass = record.send(polymorph_type) - klass_id = record.send(primary_key_name) - if klass_id - id_map = klasses_and_ids[klass] ||= {} - id_list_for_klass_id = (id_map[klass_id.to_s] ||= []) - id_list_for_klass_id << record - end - end - end - klasses_and_ids = klasses_and_ids.to_a - else - id_map = {} - records.each do |record| - key = record.send(primary_key_name) - if key - mapped_records = (id_map[key.to_s] ||= []) - mapped_records << record - end - end - klasses_and_ids = [[reflection.klass.name, id_map]] - end - - klasses_and_ids.each do |klass_and_id| - klass_name, id_map = *klass_and_id - next if id_map.empty? - klass = klass_name.constantize - - table_name = klass.quoted_table_name - primary_key = klass.primary_key - column_type = klass.columns.detect{|c| c.name == primary_key}.type - ids = id_map.keys.map do |id| - if column_type == :integer - id.to_i - elsif column_type == :float - id.to_f - else - id - end - end - conditions = "#{table_name}.#{connection.quote_column_name(primary_key)} #{in_or_equals_for_ids(ids)}" - conditions << append_conditions(reflection, preload_options) - associated_records = klass.with_exclusive_scope do - klass.find(:all, :conditions => [conditions, ids], - :include => options[:include], - :select => options[:select], - :joins => options[:joins], - :order => options[:order]) - end - set_association_single_records(id_map, reflection.name, associated_records, primary_key) - end - end - - def find_associated_records(ids, reflection, preload_options) - options = reflection.options - table_name = reflection.klass.quoted_table_name - - if interface = reflection.options[:as] - conditions = "#{reflection.klass.quoted_table_name}.#{connection.quote_column_name "#{interface}_id"} #{in_or_equals_for_ids(ids)} and #{reflection.klass.quoted_table_name}.#{connection.quote_column_name "#{interface}_type"} = '#{self.base_class.sti_name}'" - else - foreign_key = reflection.primary_key_name - conditions = "#{reflection.klass.quoted_table_name}.#{foreign_key} #{in_or_equals_for_ids(ids)}" - end - - conditions << append_conditions(reflection, preload_options) - - reflection.klass.with_exclusive_scope do - reflection.klass.find(:all, - :select => (preload_options[:select] || options[:select] || "#{table_name}.*"), - :include => preload_options[:include] || options[:include], - :conditions => [conditions, ids], - :joins => options[:joins], - :group => preload_options[:group] || options[:group], - :order => preload_options[:order] || options[:order]) - end - end - - - def interpolate_sql_for_preload(sql) - instance_eval("%@#{sql.gsub('@', '\@')}@") - end - - def append_conditions(reflection, preload_options) - sql = "" - sql << " AND (#{interpolate_sql_for_preload(reflection.sanitized_conditions)})" if reflection.sanitized_conditions - sql << " AND (#{sanitize_sql preload_options[:conditions]})" if preload_options[:conditions] - sql - end - - def in_or_equals_for_ids(ids) - ids.size > 1 ? "IN (?)" : "= ?" - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations.rb b/vendor/rails/activerecord/lib/active_record/associations.rb deleted file mode 100755 index 6d25b36..0000000 --- a/vendor/rails/activerecord/lib/active_record/associations.rb +++ /dev/null @@ -1,2169 +0,0 @@ -module ActiveRecord - class HasManyThroughAssociationNotFoundError < ActiveRecordError #:nodoc: - def initialize(owner_class_name, reflection) - super("Could not find the association #{reflection.options[:through].inspect} in model #{owner_class_name}") - end - end - - class HasManyThroughAssociationPolymorphicError < ActiveRecordError #:nodoc: - def initialize(owner_class_name, reflection, source_reflection) - super("Cannot have a has_many :through association '#{owner_class_name}##{reflection.name}' on the polymorphic object '#{source_reflection.class_name}##{source_reflection.name}'.") - end - end - - class HasManyThroughAssociationPointlessSourceTypeError < ActiveRecordError #:nodoc: - def initialize(owner_class_name, reflection, source_reflection) - super("Cannot have a has_many :through association '#{owner_class_name}##{reflection.name}' with a :source_type option if the '#{reflection.through_reflection.class_name}##{source_reflection.name}' is not polymorphic. Try removing :source_type on your association.") - end - end - - class HasManyThroughSourceAssociationNotFoundError < ActiveRecordError #:nodoc: - def initialize(reflection) - through_reflection = reflection.through_reflection - source_reflection_names = reflection.source_reflection_names - source_associations = reflection.through_reflection.klass.reflect_on_all_associations.collect { |a| a.name.inspect } - super("Could not find the source association(s) #{source_reflection_names.collect(&:inspect).to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)} in model #{through_reflection.klass}. Try 'has_many #{reflection.name.inspect}, :through => #{through_reflection.name.inspect}, :source => <name>'. Is it one of #{source_associations.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)}?") - end - end - - class HasManyThroughSourceAssociationMacroError < ActiveRecordError #:nodoc: - def initialize(reflection) - through_reflection = reflection.through_reflection - source_reflection = reflection.source_reflection - super("Invalid source reflection macro :#{source_reflection.macro}#{" :through" if source_reflection.options[:through]} for has_many #{reflection.name.inspect}, :through => #{through_reflection.name.inspect}. Use :source to specify the source reflection.") - end - end - - class HasManyThroughCantAssociateThroughHasManyReflection < ActiveRecordError #:nodoc: - def initialize(owner, reflection) - super("Cannot modify association '#{owner.class.name}##{reflection.name}' because the source reflection class '#{reflection.source_reflection.class_name}' is associated to '#{reflection.through_reflection.class_name}' via :#{reflection.source_reflection.macro}.") - end - end - class HasManyThroughCantAssociateNewRecords < ActiveRecordError #:nodoc: - def initialize(owner, reflection) - super("Cannot associate new records through '#{owner.class.name}##{reflection.name}' on '#{reflection.source_reflection.class_name rescue nil}##{reflection.source_reflection.name rescue nil}'. Both records must have an id in order to create the has_many :through record associating them.") - end - end - - class HasManyThroughCantDissociateNewRecords < ActiveRecordError #:nodoc: - def initialize(owner, reflection) - super("Cannot dissociate new records through '#{owner.class.name}##{reflection.name}' on '#{reflection.source_reflection.class_name rescue nil}##{reflection.source_reflection.name rescue nil}'. Both records must have an id in order to delete the has_many :through record associating them.") - end - end - - class HasAndBelongsToManyAssociationForeignKeyNeeded < ActiveRecordError #:nodoc: - def initialize(reflection) - super("Cannot create self referential has_and_belongs_to_many association on '#{reflection.class_name rescue nil}##{reflection.name rescue nil}'. :association_foreign_key cannot be the same as the :foreign_key.") - end - end - - class EagerLoadPolymorphicError < ActiveRecordError #:nodoc: - def initialize(reflection) - super("Can not eagerly load the polymorphic association #{reflection.name.inspect}") - end - end - - class ReadOnlyAssociation < ActiveRecordError #:nodoc: - def initialize(reflection) - super("Can not add to a has_many :through association. Try adding to #{reflection.through_reflection.name.inspect}.") - end - end - - # See ActiveRecord::Associations::ClassMethods for documentation. - module Associations # :nodoc: - # These classes will be loaded when associations are created. - # So there is no need to eager load them. - autoload :AssociationCollection, 'active_record/associations/association_collection' - autoload :AssociationProxy, 'active_record/associations/association_proxy' - autoload :BelongsToAssociation, 'active_record/associations/belongs_to_association' - autoload :BelongsToPolymorphicAssociation, 'active_record/associations/belongs_to_polymorphic_association' - autoload :HasAndBelongsToManyAssociation, 'active_record/associations/has_and_belongs_to_many_association' - autoload :HasManyAssociation, 'active_record/associations/has_many_association' - autoload :HasManyThroughAssociation, 'active_record/associations/has_many_through_association' - autoload :HasOneAssociation, 'active_record/associations/has_one_association' - autoload :HasOneThroughAssociation, 'active_record/associations/has_one_through_association' - - def self.included(base) - base.extend(ClassMethods) - end - - # Clears out the association cache - def clear_association_cache #:nodoc: - self.class.reflect_on_all_associations.to_a.each do |assoc| - instance_variable_set "@#{assoc.name}", nil - end unless self.new_record? - end - - private - # Gets the specified association instance if it responds to :loaded?, nil otherwise. - def association_instance_get(name) - association = instance_variable_get("@#{name}") - association if association.respond_to?(:loaded?) - end - - # Set the specified association instance. - def association_instance_set(name, association) - instance_variable_set("@#{name}", association) - end - - # Associations are a set of macro-like class methods for tying objects together through foreign keys. They express relationships like - # "Project has one Project Manager" or "Project belongs to a Portfolio". Each macro adds a number of methods to the class which are - # specialized according to the collection or association symbol and the options hash. It works much the same way as Ruby's own <tt>attr*</tt> - # methods. Example: - # - # class Project < ActiveRecord::Base - # belongs_to :portfolio - # has_one :project_manager - # has_many :milestones - # has_and_belongs_to_many :categories - # end - # - # The project class now has the following methods (and more) to ease the traversal and manipulation of its relationships: - # * <tt>Project#portfolio, Project#portfolio=(portfolio), Project#portfolio.nil?</tt> - # * <tt>Project#project_manager, Project#project_manager=(project_manager), Project#project_manager.nil?,</tt> - # * <tt>Project#milestones.empty?, Project#milestones.size, Project#milestones, Project#milestones<<(milestone),</tt> - # <tt>Project#milestones.delete(milestone), Project#milestones.find(milestone_id), Project#milestones.find(:all, options),</tt> - # <tt>Project#milestones.build, Project#milestones.create</tt> - # * <tt>Project#categories.empty?, Project#categories.size, Project#categories, Project#categories<<(category1),</tt> - # <tt>Project#categories.delete(category1)</tt> - # - # === A word of warning - # - # Don't create associations that have the same name as instance methods of ActiveRecord::Base. Since the association - # adds a method with that name to its model, it will override the inherited method and break things. - # For instance, +attributes+ and +connection+ would be bad choices for association names. - # - # == Auto-generated methods - # - # === Singular associations (one-to-one) - # | | belongs_to | - # generated methods | belongs_to | :polymorphic | has_one - # ----------------------------------+------------+--------------+--------- - # other | X | X | X - # other=(other) | X | X | X - # build_other(attributes={}) | X | | X - # create_other(attributes={}) | X | | X - # other.create!(attributes={}) | | | X - # - # ===Collection associations (one-to-many / many-to-many) - # | | | has_many - # generated methods | habtm | has_many | :through - # ----------------------------------+-------+----------+---------- - # others | X | X | X - # others=(other,other,...) | X | X | X - # other_ids | X | X | X - # other_ids=(id,id,...) | X | X | X - # others<< | X | X | X - # others.push | X | X | X - # others.concat | X | X | X - # others.build(attributes={}) | X | X | X - # others.create(attributes={}) | X | X | X - # others.create!(attributes={}) | X | X | X - # others.size | X | X | X - # others.length | X | X | X - # others.count | X | X | X - # others.sum(args*,&block) | X | X | X - # others.empty? | X | X | X - # others.clear | X | X | X - # others.delete(other,other,...) | X | X | X - # others.delete_all | X | X | - # others.destroy_all | X | X | X - # others.find(*args) | X | X | X - # others.find_first | X | | - # others.exists? | X | X | X - # others.uniq | X | X | X - # others.reset | X | X | X - # - # == Cardinality and associations - # - # Active Record associations can be used to describe one-to-one, one-to-many and many-to-many - # relationships between models. Each model uses an association to describe its role in - # the relation. The +belongs_to+ association is always used in the model that has - # the foreign key. - # - # === One-to-one - # - # Use +has_one+ in the base, and +belongs_to+ in the associated model. - # - # class Employee < ActiveRecord::Base - # has_one :office - # end - # class Office < ActiveRecord::Base - # belongs_to :employee # foreign key - employee_id - # end - # - # === One-to-many - # - # Use +has_many+ in the base, and +belongs_to+ in the associated model. - # - # class Manager < ActiveRecord::Base - # has_many :employees - # end - # class Employee < ActiveRecord::Base - # belongs_to :manager # foreign key - manager_id - # end - # - # === Many-to-many - # - # There are two ways to build a many-to-many relationship. - # - # The first way uses a +has_many+ association with the <tt>:through</tt> option and a join model, so - # there are two stages of associations. - # - # class Assignment < ActiveRecord::Base - # belongs_to :programmer # foreign key - programmer_id - # belongs_to :project # foreign key - project_id - # end - # class Programmer < ActiveRecord::Base - # has_many :assignments - # has_many :projects, :through => :assignments - # end - # class Project < ActiveRecord::Base - # has_many :assignments - # has_many :programmers, :through => :assignments - # end - # - # For the second way, use +has_and_belongs_to_many+ in both models. This requires a join table - # that has no corresponding model or primary key. - # - # class Programmer < ActiveRecord::Base - # has_and_belongs_to_many :projects # foreign keys in the join table - # end - # class Project < ActiveRecord::Base - # has_and_belongs_to_many :programmers # foreign keys in the join table - # end - # - # Choosing which way to build a many-to-many relationship is not always simple. - # If you need to work with the relationship model as its own entity, - # use <tt>has_many :through</tt>. Use +has_and_belongs_to_many+ when working with legacy schemas or when - # you never work directly with the relationship itself. - # - # == Is it a +belongs_to+ or +has_one+ association? - # - # Both express a 1-1 relationship. The difference is mostly where to place the foreign key, which goes on the table for the class - # declaring the +belongs_to+ relationship. Example: - # - # class User < ActiveRecord::Base - # # I reference an account. - # belongs_to :account - # end - # - # class Account < ActiveRecord::Base - # # One user references me. - # has_one :user - # end - # - # The tables for these classes could look something like: - # - # CREATE TABLE users ( - # id int(11) NOT NULL auto_increment, - # account_id int(11) default NULL, - # name varchar default NULL, - # PRIMARY KEY (id) - # ) - # - # CREATE TABLE accounts ( - # id int(11) NOT NULL auto_increment, - # name varchar default NULL, - # PRIMARY KEY (id) - # ) - # - # == Unsaved objects and associations - # - # You can manipulate objects and associations before they are saved to the database, but there is some special behavior you should be - # aware of, mostly involving the saving of associated objects. - # - # Unless you enable the :autosave option on a <tt>has_one</tt>, <tt>belongs_to</tt>, - # <tt>has_many</tt>, or <tt>has_and_belongs_to_many</tt> association, - # in which case the members are always saved. - # - # === One-to-one associations - # - # * Assigning an object to a +has_one+ association automatically saves that object and the object being replaced (if there is one), in - # order to update their primary keys - except if the parent object is unsaved (<tt>new_record? == true</tt>). - # * If either of these saves fail (due to one of the objects being invalid) the assignment statement returns +false+ and the assignment - # is cancelled. - # * If you wish to assign an object to a +has_one+ association without saving it, use the <tt>association.build</tt> method (documented below). - # * Assigning an object to a +belongs_to+ association does not save the object, since the foreign key field belongs on the parent. It - # does not save the parent either. - # - # === Collections - # - # * Adding an object to a collection (+has_many+ or +has_and_belongs_to_many+) automatically saves that object, except if the parent object - # (the owner of the collection) is not yet stored in the database. - # * If saving any of the objects being added to a collection (via <tt>push</tt> or similar) fails, then <tt>push</tt> returns +false+. - # * You can add an object to a collection without automatically saving it by using the <tt>collection.build</tt> method (documented below). - # * All unsaved (<tt>new_record? == true</tt>) members of the collection are automatically saved when the parent is saved. - # - # === Association callbacks - # - # Similar to the normal callbacks that hook into the lifecycle of an Active Record object, you can also define callbacks that get - # triggered when you add an object to or remove an object from an association collection. Example: - # - # class Project - # has_and_belongs_to_many :developers, :after_add => :evaluate_velocity - # - # def evaluate_velocity(developer) - # ... - # end - # end - # - # It's possible to stack callbacks by passing them as an array. Example: - # - # class Project - # has_and_belongs_to_many :developers, :after_add => [:evaluate_velocity, Proc.new { |p, d| p.shipping_date = Time.now}] - # end - # - # Possible callbacks are: +before_add+, +after_add+, +before_remove+ and +after_remove+. - # - # Should any of the +before_add+ callbacks throw an exception, the object does not get added to the collection. Same with - # the +before_remove+ callbacks; if an exception is thrown the object doesn't get removed. - # - # === Association extensions - # - # The proxy objects that control the access to associations can be extended through anonymous modules. This is especially - # beneficial for adding new finders, creators, and other factory-type methods that are only used as part of this association. - # Example: - # - # class Account < ActiveRecord::Base - # has_many :people do - # def find_or_create_by_name(name) - # first_name, last_name = name.split(" ", 2) - # find_or_create_by_first_name_and_last_name(first_name, last_name) - # end - # end - # end - # - # person = Account.find(:first).people.find_or_create_by_name("David Heinemeier Hansson") - # person.first_name # => "David" - # person.last_name # => "Heinemeier Hansson" - # - # If you need to share the same extensions between many associations, you can use a named extension module. Example: - # - # module FindOrCreateByNameExtension - # def find_or_create_by_name(name) - # first_name, last_name = name.split(" ", 2) - # find_or_create_by_first_name_and_last_name(first_name, last_name) - # end - # end - # - # class Account < ActiveRecord::Base - # has_many :people, :extend => FindOrCreateByNameExtension - # end - # - # class Company < ActiveRecord::Base - # has_many :people, :extend => FindOrCreateByNameExtension - # end - # - # If you need to use multiple named extension modules, you can specify an array of modules with the <tt>:extend</tt> option. - # In the case of name conflicts between methods in the modules, methods in modules later in the array supercede - # those earlier in the array. Example: - # - # class Account < ActiveRecord::Base - # has_many :people, :extend => [FindOrCreateByNameExtension, FindRecentExtension] - # end - # - # Some extensions can only be made to work with knowledge of the association proxy's internals. - # Extensions can access relevant state using accessors on the association proxy: - # - # * +proxy_owner+ - Returns the object the association is part of. - # * +proxy_reflection+ - Returns the reflection object that describes the association. - # * +proxy_target+ - Returns the associated object for +belongs_to+ and +has_one+, or the collection of associated objects for +has_many+ and +has_and_belongs_to_many+. - # - # === Association Join Models - # - # Has Many associations can be configured with the <tt>:through</tt> option to use an explicit join model to retrieve the data. This - # operates similarly to a +has_and_belongs_to_many+ association. The advantage is that you're able to add validations, - # callbacks, and extra attributes on the join model. Consider the following schema: - # - # class Author < ActiveRecord::Base - # has_many :authorships - # has_many :books, :through => :authorships - # end - # - # class Authorship < ActiveRecord::Base - # belongs_to :author - # belongs_to :book - # end - # - # @author = Author.find :first - # @author.authorships.collect { |a| a.book } # selects all books that the author's authorships belong to. - # @author.books # selects all books by using the Authorship join model - # - # You can also go through a +has_many+ association on the join model: - # - # class Firm < ActiveRecord::Base - # has_many :clients - # has_many :invoices, :through => :clients - # end - # - # class Client < ActiveRecord::Base - # belongs_to :firm - # has_many :invoices - # end - # - # class Invoice < ActiveRecord::Base - # belongs_to :client - # end - # - # @firm = Firm.find :first - # @firm.clients.collect { |c| c.invoices }.flatten # select all invoices for all clients of the firm - # @firm.invoices # selects all invoices by going through the Client join model. - # - # === Polymorphic Associations - # - # Polymorphic associations on models are not restricted on what types of models they can be associated with. Rather, they - # specify an interface that a +has_many+ association must adhere to. - # - # class Asset < ActiveRecord::Base - # belongs_to :attachable, :polymorphic => true - # end - # - # class Post < ActiveRecord::Base - # has_many :assets, :as => :attachable # The :as option specifies the polymorphic interface to use. - # end - # - # @asset.attachable = @post - # - # This works by using a type column in addition to a foreign key to specify the associated record. In the Asset example, you'd need - # an +attachable_id+ integer column and an +attachable_type+ string column. - # - # Using polymorphic associations in combination with single table inheritance (STI) is a little tricky. In order - # for the associations to work as expected, ensure that you store the base model for the STI models in the - # type column of the polymorphic association. To continue with the asset example above, suppose there are guest posts - # and member posts that use the posts table for STI. In this case, there must be a +type+ column in the posts table. - # - # class Asset < ActiveRecord::Base - # belongs_to :attachable, :polymorphic => true - # - # def attachable_type=(sType) - # super(sType.to_s.classify.constantize.base_class.to_s) - # end - # end - # - # class Post < ActiveRecord::Base - # # because we store "Post" in attachable_type now :dependent => :destroy will work - # has_many :assets, :as => :attachable, :dependent => :destroy - # end - # - # class GuestPost < Post - # end - # - # class MemberPost < Post - # end - # - # == Caching - # - # All of the methods are built on a simple caching principle that will keep the result of the last query around unless specifically - # instructed not to. The cache is even shared across methods to make it even cheaper to use the macro-added methods without - # worrying too much about performance at the first go. Example: - # - # project.milestones # fetches milestones from the database - # project.milestones.size # uses the milestone cache - # project.milestones.empty? # uses the milestone cache - # project.milestones(true).size # fetches milestones from the database - # project.milestones # uses the milestone cache - # - # == Eager loading of associations - # - # Eager loading is a way to find objects of a certain class and a number of named associations. This is - # one of the easiest ways of to prevent the dreaded 1+N problem in which fetching 100 posts that each need to display their author - # triggers 101 database queries. Through the use of eager loading, the 101 queries can be reduced to 2. Example: - # - # class Post < ActiveRecord::Base - # belongs_to :author - # has_many :comments - # end - # - # Consider the following loop using the class above: - # - # for post in Post.all - # puts "Post: " + post.title - # puts "Written by: " + post.author.name - # puts "Last comment on: " + post.comments.first.created_on - # end - # - # To iterate over these one hundred posts, we'll generate 201 database queries. Let's first just optimize it for retrieving the author: - # - # for post in Post.find(:all, :include => :author) - # - # This references the name of the +belongs_to+ association that also used the <tt>:author</tt> symbol. After loading the posts, find - # will collect the +author_id+ from each one and load all the referenced authors with one query. Doing so will cut down the number of queries from 201 to 102. - # - # We can improve upon the situation further by referencing both associations in the finder with: - # - # for post in Post.find(:all, :include => [ :author, :comments ]) - # - # This will load all comments with a single query. This reduces the total number of queries to 3. More generally the number of queries - # will be 1 plus the number of associations named (except if some of the associations are polymorphic +belongs_to+ - see below). - # - # To include a deep hierarchy of associations, use a hash: - # - # for post in Post.find(:all, :include => [ :author, { :comments => { :author => :gravatar } } ]) - # - # That'll grab not only all the comments but all their authors and gravatar pictures. You can mix and match - # symbols, arrays and hashes in any combination to describe the associations you want to load. - # - # All of this power shouldn't fool you into thinking that you can pull out huge amounts of data with no performance penalty just because you've reduced - # the number of queries. The database still needs to send all the data to Active Record and it still needs to be processed. So it's no - # catch-all for performance problems, but it's a great way to cut down on the number of queries in a situation as the one described above. - # - # Since only one table is loaded at a time, conditions or orders cannot reference tables other than the main one. If this is the case - # Active Record falls back to the previously used LEFT OUTER JOIN based strategy. For example - # - # Post.find(:all, :include => [ :author, :comments ], :conditions => ['comments.approved = ?', true]) - # - # will result in a single SQL query with joins along the lines of: <tt>LEFT OUTER JOIN comments ON comments.post_id = posts.id</tt> and - # <tt>LEFT OUTER JOIN authors ON authors.id = posts.author_id</tt>. Note that using conditions like this can have unintended consequences. - # In the above example posts with no approved comments are not returned at all, because the conditions apply to the SQL statement as a whole - # and not just to the association. You must disambiguate column references for this fallback to happen, for example - # <tt>:order => "author.name DESC"</tt> will work but <tt>:order => "name DESC"</tt> will not. - # - # If you do want eagerload only some members of an association it is usually more natural to <tt>:include</tt> an association - # which has conditions defined on it: - # - # class Post < ActiveRecord::Base - # has_many :approved_comments, :class_name => 'Comment', :conditions => ['approved = ?', true] - # end - # - # Post.find(:all, :include => :approved_comments) - # - # will load posts and eager load the +approved_comments+ association, which contains only those comments that have been approved. - # - # If you eager load an association with a specified <tt>:limit</tt> option, it will be ignored, returning all the associated objects: - # - # class Picture < ActiveRecord::Base - # has_many :most_recent_comments, :class_name => 'Comment', :order => 'id DESC', :limit => 10 - # end - # - # Picture.find(:first, :include => :most_recent_comments).most_recent_comments # => returns all associated comments. - # - # When eager loaded, conditions are interpolated in the context of the model class, not the model instance. Conditions are lazily interpolated - # before the actual model exists. - # - # Eager loading is supported with polymorphic associations. - # - # class Address < ActiveRecord::Base - # belongs_to :addressable, :polymorphic => true - # end - # - # A call that tries to eager load the addressable model - # - # Address.find(:all, :include => :addressable) - # - # will execute one query to load the addresses and load the addressables with one query per addressable type. - # For example if all the addressables are either of class Person or Company then a total of 3 queries will be executed. The list of - # addressable types to load is determined on the back of the addresses loaded. This is not supported if Active Record has to fallback - # to the previous implementation of eager loading and will raise ActiveRecord::EagerLoadPolymorphicError. The reason is that the parent - # model's type is a column value so its corresponding table name cannot be put in the +FROM+/+JOIN+ clauses of that query. - # - # == Table Aliasing - # - # Active Record uses table aliasing in the case that a table is referenced multiple times in a join. If a table is referenced only once, - # the standard table name is used. The second time, the table is aliased as <tt>#{reflection_name}_#{parent_table_name}</tt>. Indexes are appended - # for any more successive uses of the table name. - # - # Post.find :all, :joins => :comments - # # => SELECT ... FROM posts INNER JOIN comments ON ... - # Post.find :all, :joins => :special_comments # STI - # # => SELECT ... FROM posts INNER JOIN comments ON ... AND comments.type = 'SpecialComment' - # Post.find :all, :joins => [:comments, :special_comments] # special_comments is the reflection name, posts is the parent table name - # # => SELECT ... FROM posts INNER JOIN comments ON ... INNER JOIN comments special_comments_posts - # - # Acts as tree example: - # - # TreeMixin.find :all, :joins => :children - # # => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ... - # TreeMixin.find :all, :joins => {:children => :parent} - # # => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ... - # INNER JOIN parents_mixins ... - # TreeMixin.find :all, :joins => {:children => {:parent => :children}} - # # => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ... - # INNER JOIN parents_mixins ... - # INNER JOIN mixins childrens_mixins_2 - # - # Has and Belongs to Many join tables use the same idea, but add a <tt>_join</tt> suffix: - # - # Post.find :all, :joins => :categories - # # => SELECT ... FROM posts INNER JOIN categories_posts ... INNER JOIN categories ... - # Post.find :all, :joins => {:categories => :posts} - # # => SELECT ... FROM posts INNER JOIN categories_posts ... INNER JOIN categories ... - # INNER JOIN categories_posts posts_categories_join INNER JOIN posts posts_categories - # Post.find :all, :joins => {:categories => {:posts => :categories}} - # # => SELECT ... FROM posts INNER JOIN categories_posts ... INNER JOIN categories ... - # INNER JOIN categories_posts posts_categories_join INNER JOIN posts posts_categories - # INNER JOIN categories_posts categories_posts_join INNER JOIN categories categories_posts_2 - # - # If you wish to specify your own custom joins using a <tt>:joins</tt> option, those table names will take precedence over the eager associations: - # - # Post.find :all, :joins => :comments, :joins => "inner join comments ..." - # # => SELECT ... FROM posts INNER JOIN comments_posts ON ... INNER JOIN comments ... - # Post.find :all, :joins => [:comments, :special_comments], :joins => "inner join comments ..." - # # => SELECT ... FROM posts INNER JOIN comments comments_posts ON ... - # INNER JOIN comments special_comments_posts ... - # INNER JOIN comments ... - # - # Table aliases are automatically truncated according to the maximum length of table identifiers according to the specific database. - # - # == Modules - # - # By default, associations will look for objects within the current module scope. Consider: - # - # module MyApplication - # module Business - # class Firm < ActiveRecord::Base - # has_many :clients - # end - # - # class Client < ActiveRecord::Base; end - # end - # end - # - # When <tt>Firm#clients</tt> is called, it will in turn call <tt>MyApplication::Business::Client.find_all_by_firm_id(firm.id)</tt>. - # If you want to associate with a class in another module scope, this can be done by specifying the complete class name. - # Example: - # - # module MyApplication - # module Business - # class Firm < ActiveRecord::Base; end - # end - # - # module Billing - # class Account < ActiveRecord::Base - # belongs_to :firm, :class_name => "MyApplication::Business::Firm" - # end - # end - # end - # - # == Type safety with <tt>ActiveRecord::AssociationTypeMismatch</tt> - # - # If you attempt to assign an object to an association that doesn't match the inferred or specified <tt>:class_name</tt>, you'll - # get an <tt>ActiveRecord::AssociationTypeMismatch</tt>. - # - # == Options - # - # All of the association macros can be specialized through options. This makes cases more complex than the simple and guessable ones - # possible. - module ClassMethods - # Specifies a one-to-many association. The following methods for retrieval and query of - # collections of associated objects will be added: - # - # [collection(force_reload = false)] - # Returns an array of all the associated objects. - # An empty array is returned if none are found. - # [collection<<(object, ...)] - # Adds one or more objects to the collection by setting their foreign keys to the collection's primary key. - # [collection.delete(object, ...)] - # Removes one or more objects from the collection by setting their foreign keys to +NULL+. - # Objects will be in addition destroyed if they're associated with <tt>:dependent => :destroy</tt>, - # and deleted if they're associated with <tt>:dependent => :delete_all</tt>. - # [collection=objects] - # Replaces the collections content by deleting and adding objects as appropriate. - # [collection_singular_ids] - # Returns an array of the associated objects' ids - # [collection_singular_ids=ids] - # Replace the collection with the objects identified by the primary keys in +ids+ - # [collection.clear] - # Removes every object from the collection. This destroys the associated objects if they - # are associated with <tt>:dependent => :destroy</tt>, deletes them directly from the - # database if <tt>:dependent => :delete_all</tt>, otherwise sets their foreign keys to +NULL+. - # [collection.empty?] - # Returns +true+ if there are no associated objects. - # [collection.size] - # Returns the number of associated objects. - # [collection.find(...)] - # Finds an associated object according to the same rules as ActiveRecord::Base.find. - # [collection.exists?(...)] - # Checks whether an associated object with the given conditions exists. - # Uses the same rules as ActiveRecord::Base.exists?. - # [collection.build(attributes = {}, ...)] - # Returns one or more new objects of the collection type that have been instantiated - # with +attributes+ and linked to this object through a foreign key, but have not yet - # been saved. <b>Note:</b> This only works if an associated object already exists, not if - # it's +nil+! - # [collection.create(attributes = {})] - # Returns a new object of the collection type that has been instantiated - # with +attributes+, linked to this object through a foreign key, and that has already - # been saved (if it passed the validation). <b>Note:</b> This only works if an associated - # object already exists, not if it's +nil+! - # - # (*Note*: +collection+ is replaced with the symbol passed as the first argument, so - # <tt>has_many :clients</tt> would add among others <tt>clients.empty?</tt>.) - # - # === Example - # - # Example: A Firm class declares <tt>has_many :clients</tt>, which will add: - # * <tt>Firm#clients</tt> (similar to <tt>Clients.find :all, :conditions => ["firm_id = ?", id]</tt>) - # * <tt>Firm#clients<<</tt> - # * <tt>Firm#clients.delete</tt> - # * <tt>Firm#clients=</tt> - # * <tt>Firm#client_ids</tt> - # * <tt>Firm#client_ids=</tt> - # * <tt>Firm#clients.clear</tt> - # * <tt>Firm#clients.empty?</tt> (similar to <tt>firm.clients.size == 0</tt>) - # * <tt>Firm#clients.size</tt> (similar to <tt>Client.count "firm_id = #{id}"</tt>) - # * <tt>Firm#clients.find</tt> (similar to <tt>Client.find(id, :conditions => "firm_id = #{id}")</tt>) - # * <tt>Firm#clients.exists?(:name => 'ACME')</tt> (similar to <tt>Client.exists?(:name => 'ACME', :firm_id => firm.id)</tt>) - # * <tt>Firm#clients.build</tt> (similar to <tt>Client.new("firm_id" => id)</tt>) - # * <tt>Firm#clients.create</tt> (similar to <tt>c = Client.new("firm_id" => id); c.save; c</tt>) - # The declaration can also include an options hash to specialize the behavior of the association. - # - # === Supported options - # [:class_name] - # Specify the class name of the association. Use it only if that name can't be inferred - # from the association name. So <tt>has_many :products</tt> will by default be linked to the Product class, but - # if the real class name is SpecialProduct, you'll have to specify it with this option. - # [:conditions] - # Specify the conditions that the associated objects must meet in order to be included as a +WHERE+ - # SQL fragment, such as <tt>price > 5 AND name LIKE 'B%'</tt>. Record creations from the association are scoped if a hash - # is used. <tt>has_many :posts, :conditions => {:published => true}</tt> will create published posts with <tt>@blog.posts.create</tt> - # or <tt>@blog.posts.build</tt>. - # [:order] - # Specify the order in which the associated objects are returned as an <tt>ORDER BY</tt> SQL fragment, - # such as <tt>last_name, first_name DESC</tt>. - # [:foreign_key] - # Specify the foreign key used for the association. By default this is guessed to be the name - # of this class in lower-case and "_id" suffixed. So a Person class that makes a +has_many+ association will use "person_id" - # as the default <tt>:foreign_key</tt>. - # [:primary_key] - # Specify the method that returns the primary key used for the association. By default this is +id+. - # [:dependent] - # If set to <tt>:destroy</tt> all the associated objects are destroyed - # alongside this object by calling their +destroy+ method. If set to <tt>:delete_all</tt> all associated - # objects are deleted *without* calling their +destroy+ method. If set to <tt>:nullify</tt> all associated - # objects' foreign keys are set to +NULL+ *without* calling their +save+ callbacks. *Warning:* This option is ignored when also using - # the <tt>:through</tt> option. - # [:finder_sql] - # Specify a complete SQL statement to fetch the association. This is a good way to go for complex - # associations that depend on multiple tables. Note: When this option is used, +find_in_collection+ is _not_ added. - # [:counter_sql] - # Specify a complete SQL statement to fetch the size of the association. If <tt>:finder_sql</tt> is - # specified but not <tt>:counter_sql</tt>, <tt>:counter_sql</tt> will be generated by replacing <tt>SELECT ... FROM</tt> with <tt>SELECT COUNT(*) FROM</tt>. - # [:extend] - # Specify a named module for extending the proxy. See "Association extensions". - # [:include] - # Specify second-order associations that should be eager loaded when the collection is loaded. - # [:group] - # An attribute name by which the result should be grouped. Uses the <tt>GROUP BY</tt> SQL-clause. - # [:having] - # Combined with +:group+ this can be used to filter the records that a <tt>GROUP BY</tt> returns. Uses the <tt>HAVING</tt> SQL-clause. - # [:limit] - # An integer determining the limit on the number of rows that should be returned. - # [:offset] - # An integer determining the offset from where the rows should be fetched. So at 5, it would skip the first 4 rows. - # [:select] - # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed if you, for example, want to do a join - # but not include the joined columns. Do not forget to include the primary and foreign keys, otherwise it will raise an error. - # [:as] - # Specifies a polymorphic interface (See <tt>belongs_to</tt>). - # [:through] - # Specifies a Join Model through which to perform the query. Options for <tt>:class_name</tt> and <tt>:foreign_key</tt> - # are ignored, as the association uses the source reflection. You can only use a <tt>:through</tt> query through a <tt>belongs_to</tt> - # or <tt>has_many</tt> association on the join model. - # [:source] - # Specifies the source association name used by <tt>has_many :through</tt> queries. Only use it if the name cannot be - # inferred from the association. <tt>has_many :subscribers, :through => :subscriptions</tt> will look for either <tt>:subscribers</tt> or - # <tt>:subscriber</tt> on Subscription, unless a <tt>:source</tt> is given. - # [:source_type] - # Specifies type of the source association used by <tt>has_many :through</tt> queries where the source - # association is a polymorphic +belongs_to+. - # [:uniq] - # If true, duplicates will be omitted from the collection. Useful in conjunction with <tt>:through</tt>. - # [:readonly] - # If true, all the associated objects are readonly through the association. - # [:validate] - # If false, don't validate the associated objects when saving the parent object. true by default. - # [:autosave] - # If true, always save any loaded members and destroy members marked for destruction, when saving the parent object. Off by default. - # - # Option examples: - # has_many :comments, :order => "posted_on" - # has_many :comments, :include => :author - # has_many :people, :class_name => "Person", :conditions => "deleted = 0", :order => "name" - # has_many :tracks, :order => "position", :dependent => :destroy - # has_many :comments, :dependent => :nullify - # has_many :tags, :as => :taggable - # has_many :reports, :readonly => true - # has_many :subscribers, :through => :subscriptions, :source => :user - # has_many :subscribers, :class_name => "Person", :finder_sql => - # 'SELECT DISTINCT people.* ' + - # 'FROM people p, post_subscriptions ps ' + - # 'WHERE ps.post_id = #{id} AND ps.person_id = p.id ' + - # 'ORDER BY p.first_name' - def has_many(association_id, options = {}, &extension) - reflection = create_has_many_reflection(association_id, options, &extension) - configure_dependency_for_has_many(reflection) - add_association_callbacks(reflection.name, reflection.options) - - if options[:through] - collection_accessor_methods(reflection, HasManyThroughAssociation) - else - collection_accessor_methods(reflection, HasManyAssociation) - end - end - - # Specifies a one-to-one association with another class. This method should only be used - # if the other class contains the foreign key. If the current class contains the foreign key, - # then you should use +belongs_to+ instead. See also ActiveRecord::Associations::ClassMethods's overview - # on when to use has_one and when to use belongs_to. - # - # The following methods for retrieval and query of a single associated object will be added: - # - # [association(force_reload = false)] - # Returns the associated object. +nil+ is returned if none is found. - # [association=(associate)] - # Assigns the associate object, extracts the primary key, sets it as the foreign key, - # and saves the associate object. - # [build_association(attributes = {})] - # Returns a new object of the associated type that has been instantiated - # with +attributes+ and linked to this object through a foreign key, but has not - # yet been saved. <b>Note:</b> This ONLY works if an association already exists. - # It will NOT work if the association is +nil+. - # [create_association(attributes = {})] - # Returns a new object of the associated type that has been instantiated - # with +attributes+, linked to this object through a foreign key, and that - # has already been saved (if it passed the validation). - # - # (+association+ is replaced with the symbol passed as the first argument, so - # <tt>has_one :manager</tt> would add among others <tt>manager.nil?</tt>.) - # - # === Example - # - # An Account class declares <tt>has_one :beneficiary</tt>, which will add: - # * <tt>Account#beneficiary</tt> (similar to <tt>Beneficiary.find(:first, :conditions => "account_id = #{id}")</tt>) - # * <tt>Account#beneficiary=(beneficiary)</tt> (similar to <tt>beneficiary.account_id = account.id; beneficiary.save</tt>) - # * <tt>Account#build_beneficiary</tt> (similar to <tt>Beneficiary.new("account_id" => id)</tt>) - # * <tt>Account#create_beneficiary</tt> (similar to <tt>b = Beneficiary.new("account_id" => id); b.save; b</tt>) - # - # === Options - # - # The declaration can also include an options hash to specialize the behavior of the association. - # - # Options are: - # [:class_name] - # Specify the class name of the association. Use it only if that name can't be inferred - # from the association name. So <tt>has_one :manager</tt> will by default be linked to the Manager class, but - # if the real class name is Person, you'll have to specify it with this option. - # [:conditions] - # Specify the conditions that the associated object must meet in order to be included as a +WHERE+ - # SQL fragment, such as <tt>rank = 5</tt>. - # [:order] - # Specify the order in which the associated objects are returned as an <tt>ORDER BY</tt> SQL fragment, - # such as <tt>last_name, first_name DESC</tt>. - # [:dependent] - # If set to <tt>:destroy</tt>, the associated object is destroyed when this object is. If set to - # <tt>:delete</tt>, the associated object is deleted *without* calling its destroy method. If set to <tt>:nullify</tt>, the associated - # object's foreign key is set to +NULL+. Also, association is assigned. - # [:foreign_key] - # Specify the foreign key used for the association. By default this is guessed to be the name - # of this class in lower-case and "_id" suffixed. So a Person class that makes a +has_one+ association will use "person_id" - # as the default <tt>:foreign_key</tt>. - # [:primary_key] - # Specify the method that returns the primary key used for the association. By default this is +id+. - # [:include] - # Specify second-order associations that should be eager loaded when this object is loaded. - # [:as] - # Specifies a polymorphic interface (See <tt>belongs_to</tt>). - # [:select] - # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed if, for example, you want to do a join - # but not include the joined columns. Do not forget to include the primary and foreign keys, otherwise it will raise an error. - # [:through] - # Specifies a Join Model through which to perform the query. Options for <tt>:class_name</tt> and <tt>:foreign_key</tt> - # are ignored, as the association uses the source reflection. You can only use a <tt>:through</tt> query through a - # <tt>has_one</tt> or <tt>belongs_to</tt> association on the join model. - # [:source] - # Specifies the source association name used by <tt>has_one :through</tt> queries. Only use it if the name cannot be - # inferred from the association. <tt>has_one :favorite, :through => :favorites</tt> will look for a - # <tt>:favorite</tt> on Favorite, unless a <tt>:source</tt> is given. - # [:source_type] - # Specifies type of the source association used by <tt>has_one :through</tt> queries where the source - # association is a polymorphic +belongs_to+. - # [:readonly] - # If true, the associated object is readonly through the association. - # [:validate] - # If false, don't validate the associated object when saving the parent object. +false+ by default. - # [:autosave] - # If true, always save the associated object or destroy it if marked for destruction, when saving the parent object. Off by default. - # - # Option examples: - # has_one :credit_card, :dependent => :destroy # destroys the associated credit card - # has_one :credit_card, :dependent => :nullify # updates the associated records foreign key value to NULL rather than destroying it - # has_one :last_comment, :class_name => "Comment", :order => "posted_on" - # has_one :project_manager, :class_name => "Person", :conditions => "role = 'project_manager'" - # has_one :attachment, :as => :attachable - # has_one :boss, :readonly => :true - # has_one :club, :through => :membership - # has_one :primary_address, :through => :addressables, :conditions => ["addressable.primary = ?", true], :source => :addressable - def has_one(association_id, options = {}) - if options[:through] - reflection = create_has_one_through_reflection(association_id, options) - association_accessor_methods(reflection, ActiveRecord::Associations::HasOneThroughAssociation) - else - reflection = create_has_one_reflection(association_id, options) - association_accessor_methods(reflection, HasOneAssociation) - association_constructor_method(:build, reflection, HasOneAssociation) - association_constructor_method(:create, reflection, HasOneAssociation) - configure_dependency_for_has_one(reflection) - end - end - - # Specifies a one-to-one association with another class. This method should only be used - # if this class contains the foreign key. If the other class contains the foreign key, - # then you should use +has_one+ instead. See also ActiveRecord::Associations::ClassMethods's overview - # on when to use +has_one+ and when to use +belongs_to+. - # - # Methods will be added for retrieval and query for a single associated object, for which - # this object holds an id: - # - # [association(force_reload = false)] - # Returns the associated object. +nil+ is returned if none is found. - # [association=(associate)] - # Assigns the associate object, extracts the primary key, and sets it as the foreign key. - # [build_association(attributes = {})] - # Returns a new object of the associated type that has been instantiated - # with +attributes+ and linked to this object through a foreign key, but has not yet been saved. - # [create_association(attributes = {})] - # Returns a new object of the associated type that has been instantiated - # with +attributes+, linked to this object through a foreign key, and that - # has already been saved (if it passed the validation). - # - # (+association+ is replaced with the symbol passed as the first argument, so - # <tt>belongs_to :author</tt> would add among others <tt>author.nil?</tt>.) - # - # === Example - # - # A Post class declares <tt>belongs_to :author</tt>, which will add: - # * <tt>Post#author</tt> (similar to <tt>Author.find(author_id)</tt>) - # * <tt>Post#author=(author)</tt> (similar to <tt>post.author_id = author.id</tt>) - # * <tt>Post#author?</tt> (similar to <tt>post.author == some_author</tt>) - # * <tt>Post#build_author</tt> (similar to <tt>post.author = Author.new</tt>) - # * <tt>Post#create_author</tt> (similar to <tt>post.author = Author.new; post.author.save; post.author</tt>) - # The declaration can also include an options hash to specialize the behavior of the association. - # - # === Options - # - # [:class_name] - # Specify the class name of the association. Use it only if that name can't be inferred - # from the association name. So <tt>has_one :author</tt> will by default be linked to the Author class, but - # if the real class name is Person, you'll have to specify it with this option. - # [:conditions] - # Specify the conditions that the associated object must meet in order to be included as a +WHERE+ - # SQL fragment, such as <tt>authorized = 1</tt>. - # [:select] - # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed if, for example, you want to do a join - # but not include the joined columns. Do not forget to include the primary and foreign keys, otherwise it will raise an error. - # [:foreign_key] - # Specify the foreign key used for the association. By default this is guessed to be the name - # of the association with an "_id" suffix. So a class that defines a <tt>belongs_to :person</tt> association will use - # "person_id" as the default <tt>:foreign_key</tt>. Similarly, <tt>belongs_to :favorite_person, :class_name => "Person"</tt> - # will use a foreign key of "favorite_person_id". - # [:dependent] - # If set to <tt>:destroy</tt>, the associated object is destroyed when this object is. If set to - # <tt>:delete</tt>, the associated object is deleted *without* calling its destroy method. This option should not be specified when - # <tt>belongs_to</tt> is used in conjunction with a <tt>has_many</tt> relationship on another class because of the potential to leave - # orphaned records behind. - # [:counter_cache] - # Caches the number of belonging objects on the associate class through the use of +increment_counter+ - # and +decrement_counter+. The counter cache is incremented when an object of this class is created and decremented when it's - # destroyed. This requires that a column named <tt>#{table_name}_count</tt> (such as +comments_count+ for a belonging Comment class) - # is used on the associate class (such as a Post class). You can also specify a custom counter cache column by providing - # a column name instead of a +true+/+false+ value to this option (e.g., <tt>:counter_cache => :my_custom_counter</tt>.) - # Note: Specifying a counter cache will add it to that model's list of readonly attributes using +attr_readonly+. - # [:include] - # Specify second-order associations that should be eager loaded when this object is loaded. - # [:polymorphic] - # Specify this association is a polymorphic association by passing +true+. - # Note: If you've enabled the counter cache, then you may want to add the counter cache attribute - # to the +attr_readonly+ list in the associated classes (e.g. <tt>class Post; attr_readonly :comments_count; end</tt>). - # [:readonly] - # If true, the associated object is readonly through the association. - # [:validate] - # If false, don't validate the associated objects when saving the parent object. +false+ by default. - # [:autosave] - # If true, always save the associated object or destroy it if marked for destruction, when saving the parent object. Off by default. - # - # Option examples: - # belongs_to :firm, :foreign_key => "client_of" - # belongs_to :author, :class_name => "Person", :foreign_key => "author_id" - # belongs_to :valid_coupon, :class_name => "Coupon", :foreign_key => "coupon_id", - # :conditions => 'discounts > #{payments_count}' - # belongs_to :attachable, :polymorphic => true - # belongs_to :project, :readonly => true - # belongs_to :post, :counter_cache => true - def belongs_to(association_id, options = {}) - reflection = create_belongs_to_reflection(association_id, options) - - if reflection.options[:polymorphic] - association_accessor_methods(reflection, BelongsToPolymorphicAssociation) - else - association_accessor_methods(reflection, BelongsToAssociation) - association_constructor_method(:build, reflection, BelongsToAssociation) - association_constructor_method(:create, reflection, BelongsToAssociation) - end - - # Create the callbacks to update counter cache - if options[:counter_cache] - cache_column = reflection.counter_cache_column - - method_name = "belongs_to_counter_cache_after_create_for_#{reflection.name}".to_sym - define_method(method_name) do - association = send(reflection.name) - association.class.increment_counter(cache_column, send(reflection.primary_key_name)) unless association.nil? - end - after_create method_name - - method_name = "belongs_to_counter_cache_before_destroy_for_#{reflection.name}".to_sym - define_method(method_name) do - association = send(reflection.name) - association.class.decrement_counter(cache_column, send(reflection.primary_key_name)) unless association.nil? - end - before_destroy method_name - - module_eval( - "#{reflection.class_name}.send(:attr_readonly,\"#{cache_column}\".intern) if defined?(#{reflection.class_name}) && #{reflection.class_name}.respond_to?(:attr_readonly)" - ) - end - - configure_dependency_for_belongs_to(reflection) - end - - # Specifies a many-to-many relationship with another class. This associates two classes via an - # intermediate join table. Unless the join table is explicitly specified as an option, it is - # guessed using the lexical order of the class names. So a join between Developer and Project - # will give the default join table name of "developers_projects" because "D" outranks "P". Note that this precedence - # is calculated using the <tt><</tt> operator for String. This means that if the strings are of different lengths, - # and the strings are equal when compared up to the shortest length, then the longer string is considered of higher - # lexical precedence than the shorter one. For example, one would expect the tables "paper_boxes" and "papers" - # to generate a join table name of "papers_paper_boxes" because of the length of the name "paper_boxes", - # but it in fact generates a join table name of "paper_boxes_papers". Be aware of this caveat, and use the - # custom <tt>:join_table</tt> option if you need to. - # - # The join table should not have a primary key or a model associated with it. You must manually generate the - # join table with a migration such as this: - # - # class CreateDevelopersProjectsJoinTable < ActiveRecord::Migration - # def self.up - # create_table :developers_projects, :id => false do |t| - # t.integer :developer_id - # t.integer :project_id - # end - # end - # - # def self.down - # drop_table :developers_projects - # end - # end - # - # Deprecated: Any additional fields added to the join table will be placed as attributes when pulling records out through - # +has_and_belongs_to_many+ associations. Records returned from join tables with additional attributes will be marked as - # readonly (because we can't save changes to the additional attributes). It's strongly recommended that you upgrade any - # associations with attributes to a real join model (see introduction). - # - # Adds the following methods for retrieval and query: - # - # [collection(force_reload = false)] - # Returns an array of all the associated objects. - # An empty array is returned if none are found. - # [collection<<(object, ...)] - # Adds one or more objects to the collection by creating associations in the join table - # (<tt>collection.push</tt> and <tt>collection.concat</tt> are aliases to this method). - # [collection.delete(object, ...)] - # Removes one or more objects from the collection by removing their associations from the join table. - # This does not destroy the objects. - # [collection=objects] - # Replaces the collection's content by deleting and adding objects as appropriate. - # [collection_singular_ids] - # Returns an array of the associated objects' ids. - # [collection_singular_ids=ids] - # Replace the collection by the objects identified by the primary keys in +ids+. - # [collection.clear] - # Removes every object from the collection. This does not destroy the objects. - # [collection.empty?] - # Returns +true+ if there are no associated objects. - # [collection.size] - # Returns the number of associated objects. - # [collection.find(id)] - # Finds an associated object responding to the +id+ and that - # meets the condition that it has to be associated with this object. - # Uses the same rules as ActiveRecord::Base.find. - # [collection.exists?(...)] - # Checks whether an associated object with the given conditions exists. - # Uses the same rules as ActiveRecord::Base.exists?. - # [collection.build(attributes = {})] - # Returns a new object of the collection type that has been instantiated - # with +attributes+ and linked to this object through the join table, but has not yet been saved. - # [collection.create(attributes = {})] - # Returns a new object of the collection type that has been instantiated - # with +attributes+, linked to this object through the join table, and that has already been saved (if it passed the validation). - # - # (+collection+ is replaced with the symbol passed as the first argument, so - # <tt>has_and_belongs_to_many :categories</tt> would add among others <tt>categories.empty?</tt>.) - # - # === Example - # - # A Developer class declares <tt>has_and_belongs_to_many :projects</tt>, which will add: - # * <tt>Developer#projects</tt> - # * <tt>Developer#projects<<</tt> - # * <tt>Developer#projects.delete</tt> - # * <tt>Developer#projects=</tt> - # * <tt>Developer#project_ids</tt> - # * <tt>Developer#project_ids=</tt> - # * <tt>Developer#projects.clear</tt> - # * <tt>Developer#projects.empty?</tt> - # * <tt>Developer#projects.size</tt> - # * <tt>Developer#projects.find(id)</tt> - # * <tt>Developer#clients.exists?(...)</tt> - # * <tt>Developer#projects.build</tt> (similar to <tt>Project.new("project_id" => id)</tt>) - # * <tt>Developer#projects.create</tt> (similar to <tt>c = Project.new("project_id" => id); c.save; c</tt>) - # The declaration may include an options hash to specialize the behavior of the association. - # - # === Options - # - # [:class_name] - # Specify the class name of the association. Use it only if that name can't be inferred - # from the association name. So <tt>has_and_belongs_to_many :projects</tt> will by default be linked to the - # Project class, but if the real class name is SuperProject, you'll have to specify it with this option. - # [:join_table] - # Specify the name of the join table if the default based on lexical order isn't what you want. - # <b>WARNING:</b> If you're overwriting the table name of either class, the +table_name+ method - # MUST be declared underneath any +has_and_belongs_to_many+ declaration in order to work. - # [:foreign_key] - # Specify the foreign key used for the association. By default this is guessed to be the name - # of this class in lower-case and "_id" suffixed. So a Person class that makes a +has_and_belongs_to_many+ association - # to Project will use "person_id" as the default <tt>:foreign_key</tt>. - # [:association_foreign_key] - # Specify the foreign key used for the association on the receiving side of the association. - # By default this is guessed to be the name of the associated class in lower-case and "_id" suffixed. - # So if a Person class makes a +has_and_belongs_to_many+ association to Project, - # the association will use "project_id" as the default <tt>:association_foreign_key</tt>. - # [:conditions] - # Specify the conditions that the associated object must meet in order to be included as a +WHERE+ - # SQL fragment, such as <tt>authorized = 1</tt>. Record creations from the association are scoped if a hash is used. - # <tt>has_many :posts, :conditions => {:published => true}</tt> will create published posts with <tt>@blog.posts.create</tt> - # or <tt>@blog.posts.build</tt>. - # [:order] - # Specify the order in which the associated objects are returned as an <tt>ORDER BY</tt> SQL fragment, - # such as <tt>last_name, first_name DESC</tt> - # [:uniq] - # If true, duplicate associated objects will be ignored by accessors and query methods. - # [:finder_sql] - # Overwrite the default generated SQL statement used to fetch the association with a manual statement - # [:counter_sql] - # Specify a complete SQL statement to fetch the size of the association. If <tt>:finder_sql</tt> is - # specified but not <tt>:counter_sql</tt>, <tt>:counter_sql</tt> will be generated by replacing <tt>SELECT ... FROM</tt> with <tt>SELECT COUNT(*) FROM</tt>. - # [:delete_sql] - # Overwrite the default generated SQL statement used to remove links between the associated - # classes with a manual statement. - # [:insert_sql] - # Overwrite the default generated SQL statement used to add links between the associated classes - # with a manual statement. - # [:extend] - # Anonymous module for extending the proxy, see "Association extensions". - # [:include] - # Specify second-order associations that should be eager loaded when the collection is loaded. - # [:group] - # An attribute name by which the result should be grouped. Uses the <tt>GROUP BY</tt> SQL-clause. - # [:having] - # Combined with +:group+ this can be used to filter the records that a <tt>GROUP BY</tt> returns. Uses the <tt>HAVING</tt> SQL-clause. - # [:limit] - # An integer determining the limit on the number of rows that should be returned. - # [:offset] - # An integer determining the offset from where the rows should be fetched. So at 5, it would skip the first 4 rows. - # [:select] - # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed if, for example, you want to do a join - # but not include the joined columns. Do not forget to include the primary and foreign keys, otherwise it will raise an error. - # [:readonly] - # If true, all the associated objects are readonly through the association. - # [:validate] - # If false, don't validate the associated objects when saving the parent object. +true+ by default. - # [:autosave] - # If true, always save any loaded members and destroy members marked for destruction, when saving the parent object. Off by default. - # - # Option examples: - # has_and_belongs_to_many :projects - # has_and_belongs_to_many :projects, :include => [ :milestones, :manager ] - # has_and_belongs_to_many :nations, :class_name => "Country" - # has_and_belongs_to_many :categories, :join_table => "prods_cats" - # has_and_belongs_to_many :categories, :readonly => true - # has_and_belongs_to_many :active_projects, :join_table => 'developers_projects', :delete_sql => - # 'DELETE FROM developers_projects WHERE active=1 AND developer_id = #{id} AND project_id = #{record.id}' - def has_and_belongs_to_many(association_id, options = {}, &extension) - reflection = create_has_and_belongs_to_many_reflection(association_id, options, &extension) - collection_accessor_methods(reflection, HasAndBelongsToManyAssociation) - - # Don't use a before_destroy callback since users' before_destroy - # callbacks will be executed after the association is wiped out. - old_method = "destroy_without_habtm_shim_for_#{reflection.name}" - class_eval <<-end_eval unless method_defined?(old_method) - alias_method :#{old_method}, :destroy_without_callbacks # alias_method :destroy_without_habtm_shim_for_posts, :destroy_without_callbacks - def destroy_without_callbacks # def destroy_without_callbacks - #{reflection.name}.clear # posts.clear - #{old_method} # destroy_without_habtm_shim_for_posts - end # end - end_eval - - add_association_callbacks(reflection.name, options) - end - - private - # Generates a join table name from two provided table names. - # The names in the join table namesme end up in lexicographic order. - # - # join_table_name("members", "clubs") # => "clubs_members" - # join_table_name("members", "special_clubs") # => "members_special_clubs" - def join_table_name(first_table_name, second_table_name) - if first_table_name < second_table_name - join_table = "#{first_table_name}_#{second_table_name}" - else - join_table = "#{second_table_name}_#{first_table_name}" - end - - table_name_prefix + join_table + table_name_suffix - end - - def association_accessor_methods(reflection, association_proxy_class) - define_method(reflection.name) do |*params| - force_reload = params.first unless params.empty? - association = association_instance_get(reflection.name) - - if association.nil? || force_reload - association = association_proxy_class.new(self, reflection) - retval = association.reload - if retval.nil? and association_proxy_class == BelongsToAssociation - association_instance_set(reflection.name, nil) - return nil - end - association_instance_set(reflection.name, association) - end - - association.target.nil? ? nil : association - end - - define_method("loaded_#{reflection.name}?") do - association = association_instance_get(reflection.name) - association && association.loaded? - end - - define_method("#{reflection.name}=") do |new_value| - association = association_instance_get(reflection.name) - - if association.nil? || association.target != new_value - association = association_proxy_class.new(self, reflection) - end - - if association_proxy_class == HasOneThroughAssociation - association.create_through_record(new_value) - self.send(reflection.name, new_value) - else - association.replace(new_value) - association_instance_set(reflection.name, new_value.nil? ? nil : association) - end - end - - define_method("set_#{reflection.name}_target") do |target| - return if target.nil? and association_proxy_class == BelongsToAssociation - association = association_proxy_class.new(self, reflection) - association.target = target - association_instance_set(reflection.name, association) - end - end - - def collection_reader_method(reflection, association_proxy_class) - define_method(reflection.name) do |*params| - force_reload = params.first unless params.empty? - association = association_instance_get(reflection.name) - - unless association - association = association_proxy_class.new(self, reflection) - association_instance_set(reflection.name, association) - end - - association.reload if force_reload - - association - end - - define_method("#{reflection.name.to_s.singularize}_ids") do - if send(reflection.name).loaded? || reflection.options[:finder_sql] - send(reflection.name).map(&:id) - else - send(reflection.name).all(:select => "#{reflection.quoted_table_name}.#{reflection.klass.primary_key}").map(&:id) - end - end - end - - def collection_accessor_methods(reflection, association_proxy_class, writer = true) - collection_reader_method(reflection, association_proxy_class) - - if writer - define_method("#{reflection.name}=") do |new_value| - # Loads proxy class instance (defined in collection_reader_method) if not already loaded - association = send(reflection.name) - association.replace(new_value) - association - end - - define_method("#{reflection.name.to_s.singularize}_ids=") do |new_value| - ids = (new_value || []).reject { |nid| nid.blank? } - send("#{reflection.name}=", reflection.class_name.constantize.find(ids)) - end - end - end - - def association_constructor_method(constructor, reflection, association_proxy_class) - define_method("#{constructor}_#{reflection.name}") do |*params| - attributees = params.first unless params.empty? - replace_existing = params[1].nil? ? true : params[1] - association = association_instance_get(reflection.name) - - unless association - association = association_proxy_class.new(self, reflection) - association_instance_set(reflection.name, association) - end - - if association_proxy_class == HasOneAssociation - association.send(constructor, attributees, replace_existing) - else - association.send(constructor, attributees) - end - end - end - - def find_with_associations(options = {}) - catch :invalid_query do - join_dependency = JoinDependency.new(self, merge_includes(scope(:find, :include), options[:include]), options[:joins]) - rows = select_all_rows(options, join_dependency) - return join_dependency.instantiate(rows) - end - [] - end - - # Creates before_destroy callback methods that nullify, delete or destroy - # has_many associated objects, according to the defined :dependent rule. - # - # See HasManyAssociation#delete_records. Dependent associations - # delete children, otherwise foreign key is set to NULL. - # - # The +extra_conditions+ parameter, which is not used within the main - # Active Record codebase, is meant to allow plugins to define extra - # finder conditions. - def configure_dependency_for_has_many(reflection, extra_conditions = nil) - if reflection.options.include?(:dependent) - # Add polymorphic type if the :as option is present - dependent_conditions = [] - dependent_conditions << "#{reflection.primary_key_name} = \#{record.quoted_id}" - dependent_conditions << "#{reflection.options[:as]}_type = '#{base_class.name}'" if reflection.options[:as] - dependent_conditions << sanitize_sql(reflection.options[:conditions]) if reflection.options[:conditions] - dependent_conditions << extra_conditions if extra_conditions - dependent_conditions = dependent_conditions.collect {|where| "(#{where})" }.join(" AND ") - dependent_conditions = dependent_conditions.gsub('@', '\@') - case reflection.options[:dependent] - when :destroy - method_name = "has_many_dependent_destroy_for_#{reflection.name}".to_sym - define_method(method_name) do - send(reflection.name).each { |o| o.destroy } - end - before_destroy method_name - when :delete_all - module_eval %Q{ - before_destroy do |record| # before_destroy do |record| - delete_all_has_many_dependencies(record, # delete_all_has_many_dependencies(record, - "#{reflection.name}", # "posts", - #{reflection.class_name}, # Post, - %@#{dependent_conditions}@) # %@...@) # this is a string literal like %(...) - end # end - } - when :nullify - module_eval %Q{ - before_destroy do |record| # before_destroy do |record| - nullify_has_many_dependencies(record, # nullify_has_many_dependencies(record, - "#{reflection.name}", # "posts", - #{reflection.class_name}, # Post, - "#{reflection.primary_key_name}", # "user_id", - %@#{dependent_conditions}@) # %@...@) # this is a string literal like %(...) - end # end - } - else - raise ArgumentError, "The :dependent option expects either :destroy, :delete_all, or :nullify (#{reflection.options[:dependent].inspect})" - end - end - end - - # Creates before_destroy callback methods that nullify, delete or destroy - # has_one associated objects, according to the defined :dependent rule. - def configure_dependency_for_has_one(reflection) - if reflection.options.include?(:dependent) - case reflection.options[:dependent] - when :destroy - method_name = "has_one_dependent_destroy_for_#{reflection.name}".to_sym - define_method(method_name) do - association = send(reflection.name) - association.destroy unless association.nil? - end - before_destroy method_name - when :delete - method_name = "has_one_dependent_delete_for_#{reflection.name}".to_sym - define_method(method_name) do - # Retrieve the associated object and delete it. The retrieval - # is necessary because there may be multiple associated objects - # with foreign keys pointing to this object, and we only want - # to delete the correct one, not all of them. - association = send(reflection.name) - association.delete unless association.nil? - end - before_destroy method_name - when :nullify - method_name = "has_one_dependent_nullify_for_#{reflection.name}".to_sym - define_method(method_name) do - association = send(reflection.name) - association.update_attribute(reflection.primary_key_name, nil) unless association.nil? - end - before_destroy method_name - else - raise ArgumentError, "The :dependent option expects either :destroy, :delete or :nullify (#{reflection.options[:dependent].inspect})" - end - end - end - - def configure_dependency_for_belongs_to(reflection) - if reflection.options.include?(:dependent) - case reflection.options[:dependent] - when :destroy - method_name = "belongs_to_dependent_destroy_for_#{reflection.name}".to_sym - define_method(method_name) do - association = send(reflection.name) - association.destroy unless association.nil? - end - after_destroy method_name - when :delete - method_name = "belongs_to_dependent_delete_for_#{reflection.name}".to_sym - define_method(method_name) do - association = send(reflection.name) - association.delete unless association.nil? - end - after_destroy method_name - else - raise ArgumentError, "The :dependent option expects either :destroy or :delete (#{reflection.options[:dependent].inspect})" - end - end - end - - def delete_all_has_many_dependencies(record, reflection_name, association_class, dependent_conditions) - association_class.delete_all(dependent_conditions) - end - - def nullify_has_many_dependencies(record, reflection_name, association_class, primary_key_name, dependent_conditions) - association_class.update_all("#{primary_key_name} = NULL", dependent_conditions) - end - - mattr_accessor :valid_keys_for_has_many_association - @@valid_keys_for_has_many_association = [ - :class_name, :table_name, :foreign_key, :primary_key, - :dependent, - :select, :conditions, :include, :order, :group, :having, :limit, :offset, - :as, :through, :source, :source_type, - :uniq, - :finder_sql, :counter_sql, - :before_add, :after_add, :before_remove, :after_remove, - :extend, :readonly, - :validate - ] - - def create_has_many_reflection(association_id, options, &extension) - options.assert_valid_keys(valid_keys_for_has_many_association) - options[:extend] = create_extension_modules(association_id, extension, options[:extend]) - - create_reflection(:has_many, association_id, options, self) - end - - mattr_accessor :valid_keys_for_has_one_association - @@valid_keys_for_has_one_association = [ - :class_name, :foreign_key, :remote, :select, :conditions, :order, - :include, :dependent, :counter_cache, :extend, :as, :readonly, - :validate, :primary_key - ] - - def create_has_one_reflection(association_id, options) - options.assert_valid_keys(valid_keys_for_has_one_association) - create_reflection(:has_one, association_id, options, self) - end - - def create_has_one_through_reflection(association_id, options) - options.assert_valid_keys( - :class_name, :foreign_key, :remote, :select, :conditions, :order, :include, :dependent, :counter_cache, :extend, :as, :through, :source, :source_type, :validate - ) - create_reflection(:has_one, association_id, options, self) - end - - mattr_accessor :valid_keys_for_belongs_to_association - @@valid_keys_for_belongs_to_association = [ - :class_name, :foreign_key, :foreign_type, :remote, :select, :conditions, - :include, :dependent, :counter_cache, :extend, :polymorphic, :readonly, - :validate - ] - - def create_belongs_to_reflection(association_id, options) - options.assert_valid_keys(valid_keys_for_belongs_to_association) - reflection = create_reflection(:belongs_to, association_id, options, self) - - if options[:polymorphic] - reflection.options[:foreign_type] ||= reflection.class_name.underscore + "_type" - end - - reflection - end - - mattr_accessor :valid_keys_for_has_and_belongs_to_many_association - @@valid_keys_for_has_and_belongs_to_many_association = [ - :class_name, :table_name, :join_table, :foreign_key, :association_foreign_key, - :select, :conditions, :include, :order, :group, :having, :limit, :offset, - :uniq, - :finder_sql, :counter_sql, :delete_sql, :insert_sql, - :before_add, :after_add, :before_remove, :after_remove, - :extend, :readonly, - :validate - ] - - def create_has_and_belongs_to_many_reflection(association_id, options, &extension) - options.assert_valid_keys(valid_keys_for_has_and_belongs_to_many_association) - - options[:extend] = create_extension_modules(association_id, extension, options[:extend]) - - reflection = create_reflection(:has_and_belongs_to_many, association_id, options, self) - - if reflection.association_foreign_key == reflection.primary_key_name - raise HasAndBelongsToManyAssociationForeignKeyNeeded.new(reflection) - end - - reflection.options[:join_table] ||= join_table_name(undecorated_table_name(self.to_s), undecorated_table_name(reflection.class_name)) - - reflection - end - - def reflect_on_included_associations(associations) - [ associations ].flatten.collect { |association| reflect_on_association(association.to_s.intern) } - end - - def guard_against_unlimitable_reflections(reflections, options) - if (options[:offset] || options[:limit]) && !using_limitable_reflections?(reflections) - raise( - ConfigurationError, - "You can not use offset and limit together with has_many or has_and_belongs_to_many associations" - ) - end - end - - def select_all_rows(options, join_dependency) - connection.select_all( - construct_finder_sql_with_included_associations(options, join_dependency), - "#{name} Load Including Associations" - ) - end - - def construct_finder_sql_with_included_associations(options, join_dependency) - scope = scope(:find) - sql = "SELECT #{column_aliases(join_dependency)} FROM #{(scope && scope[:from]) || options[:from] || quoted_table_name} " - sql << join_dependency.join_associations.collect{|join| join.association_join }.join - - add_joins!(sql, options[:joins], scope) - add_conditions!(sql, options[:conditions], scope) - add_limited_ids_condition!(sql, options, join_dependency) if !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit]) - - add_group!(sql, options[:group], options[:having], scope) - add_order!(sql, options[:order], scope) - add_limit!(sql, options, scope) if using_limitable_reflections?(join_dependency.reflections) - add_lock!(sql, options, scope) - - return sanitize_sql(sql) - end - - def add_limited_ids_condition!(sql, options, join_dependency) - unless (id_list = select_limited_ids_list(options, join_dependency)).empty? - sql << "#{condition_word(sql)} #{connection.quote_table_name table_name}.#{primary_key} IN (#{id_list}) " - else - throw :invalid_query - end - end - - def select_limited_ids_list(options, join_dependency) - pk = columns_hash[primary_key] - - connection.select_all( - construct_finder_sql_for_association_limiting(options, join_dependency), - "#{name} Load IDs For Limited Eager Loading" - ).collect { |row| connection.quote(row[primary_key], pk) }.join(", ") - end - - def construct_finder_sql_for_association_limiting(options, join_dependency) - scope = scope(:find) - - # Only join tables referenced in order or conditions since this is particularly slow on the pre-query. - tables_from_conditions = conditions_tables(options) - tables_from_order = order_tables(options) - all_tables = tables_from_conditions + tables_from_order - distinct_join_associations = all_tables.uniq.map{|table| - join_dependency.joins_for_table_name(table) - }.flatten.compact.uniq - - order = options[:order] - if scoped_order = (scope && scope[:order]) - order = order ? "#{order}, #{scoped_order}" : scoped_order - end - - is_distinct = !options[:joins].blank? || include_eager_conditions?(options, tables_from_conditions) || include_eager_order?(options, tables_from_order) - sql = "SELECT " - if is_distinct - sql << connection.distinct("#{connection.quote_table_name table_name}.#{primary_key}", order) - else - sql << primary_key - end - sql << " FROM #{connection.quote_table_name table_name} " - - if is_distinct - sql << distinct_join_associations.collect { |assoc| assoc.association_join }.join - add_joins!(sql, options[:joins], scope) - end - - add_conditions!(sql, options[:conditions], scope) - add_group!(sql, options[:group], options[:having], scope) - - if order && is_distinct - connection.add_order_by_for_association_limiting!(sql, :order => order) - else - add_order!(sql, options[:order], scope) - end - - add_limit!(sql, options, scope) - - return sanitize_sql(sql) - end - - def tables_in_string(string) - return [] if string.blank? - string.scan(/([\.a-zA-Z_]+).?\./).flatten - end - - def conditions_tables(options) - # look in both sets of conditions - conditions = [scope(:find, :conditions), options[:conditions]].inject([]) do |all, cond| - case cond - when nil then all - when Array then all << cond.first - when Hash then all << cond.keys - else all << cond - end - end - tables_in_string(conditions.join(' ')) - end - - def order_tables(options) - order = [options[:order], scope(:find, :order) ].join(", ") - return [] unless order && order.is_a?(String) - tables_in_string(order) - end - - def selects_tables(options) - select = options[:select] - return [] unless select && select.is_a?(String) - tables_in_string(select) - end - - def joined_tables(options) - scope = scope(:find) - joins = options[:joins] - merged_joins = scope && scope[:joins] && joins ? merge_joins(scope[:joins], joins) : (joins || scope && scope[:joins]) - [table_name] + case merged_joins - when Symbol, Hash, Array - if array_of_strings?(merged_joins) - tables_in_string(merged_joins.join(' ')) - else - join_dependency = ActiveRecord::Associations::ClassMethods::InnerJoinDependency.new(self, merged_joins, nil) - join_dependency.join_associations.collect {|join_association| [join_association.aliased_join_table_name, join_association.aliased_table_name]}.flatten.compact - end - else - tables_in_string(merged_joins) - end - end - - # Checks if the conditions reference a table other than the current model table - def include_eager_conditions?(options, tables = nil, joined_tables = nil) - ((tables || conditions_tables(options)) - (joined_tables || joined_tables(options))).any? - end - - # Checks if the query order references a table other than the current model's table. - def include_eager_order?(options, tables = nil, joined_tables = nil) - ((tables || order_tables(options)) - (joined_tables || joined_tables(options))).any? - end - - def include_eager_select?(options, joined_tables = nil) - (selects_tables(options) - (joined_tables || joined_tables(options))).any? - end - - def references_eager_loaded_tables?(options) - joined_tables = joined_tables(options) - include_eager_order?(options, nil, joined_tables) || include_eager_conditions?(options, nil, joined_tables) || include_eager_select?(options, joined_tables) - end - - def using_limitable_reflections?(reflections) - reflections.reject { |r| [ :belongs_to, :has_one ].include?(r.macro) }.length.zero? - end - - def column_aliases(join_dependency) - join_dependency.joins.collect{|join| join.column_names_with_alias.collect{|column_name, aliased_name| - "#{connection.quote_table_name join.aliased_table_name}.#{connection.quote_column_name column_name} AS #{aliased_name}"}}.flatten.join(", ") - end - - def add_association_callbacks(association_name, options) - callbacks = %w(before_add after_add before_remove after_remove) - callbacks.each do |callback_name| - full_callback_name = "#{callback_name}_for_#{association_name}" - defined_callbacks = options[callback_name.to_sym] - if options.has_key?(callback_name.to_sym) - class_inheritable_reader full_callback_name.to_sym - write_inheritable_attribute(full_callback_name.to_sym, [defined_callbacks].flatten) - else - write_inheritable_attribute(full_callback_name.to_sym, []) - end - end - end - - def condition_word(sql) - sql =~ /where/i ? " AND " : "WHERE " - end - - def create_extension_modules(association_id, block_extension, extensions) - if block_extension - extension_module_name = "#{self.to_s.demodulize}#{association_id.to_s.camelize}AssociationExtension" - - silence_warnings do - self.parent.const_set(extension_module_name, Module.new(&block_extension)) - end - Array(extensions).push("#{self.parent}::#{extension_module_name}".constantize) - else - Array(extensions) - end - end - - class JoinDependency # :nodoc: - attr_reader :joins, :reflections, :table_aliases - - def initialize(base, associations, joins) - @joins = [JoinBase.new(base, joins)] - @associations = associations - @reflections = [] - @base_records_hash = {} - @base_records_in_order = [] - @table_aliases = Hash.new { |aliases, table| aliases[table] = 0 } - @table_aliases[base.table_name] = 1 - build(associations) - end - - def join_associations - @joins[1..-1].to_a - end - - def join_base - @joins[0] - end - - def instantiate(rows) - rows.each_with_index do |row, i| - primary_id = join_base.record_id(row) - unless @base_records_hash[primary_id] - @base_records_in_order << (@base_records_hash[primary_id] = join_base.instantiate(row)) - end - construct(@base_records_hash[primary_id], @associations, join_associations.dup, row) - end - remove_duplicate_results!(join_base.active_record, @base_records_in_order, @associations) - return @base_records_in_order - end - - def remove_duplicate_results!(base, records, associations) - case associations - when Symbol, String - reflection = base.reflections[associations] - if reflection && [:has_many, :has_and_belongs_to_many].include?(reflection.macro) - records.each { |record| record.send(reflection.name).target.uniq! } - end - when Array - associations.each do |association| - remove_duplicate_results!(base, records, association) - end - when Hash - associations.keys.each do |name| - reflection = base.reflections[name] - is_collection = [:has_many, :has_and_belongs_to_many].include?(reflection.macro) - - parent_records = records.map do |record| - descendant = record.send(reflection.name) - next unless descendant - descendant.target.uniq! if is_collection - descendant - end.flatten.compact - - remove_duplicate_results!(reflection.class_name.constantize, parent_records, associations[name]) unless parent_records.empty? - end - end - end - - def join_for_table_name(table_name) - join = (@joins.select{|j|j.aliased_table_name == table_name.gsub(/^\"(.*)\"$/){$1} }.first) rescue nil - return join unless join.nil? - @joins.select{|j|j.is_a?(JoinAssociation) && j.aliased_join_table_name == table_name.gsub(/^\"(.*)\"$/){$1} }.first rescue nil - end - - def joins_for_table_name(table_name) - join = join_for_table_name(table_name) - result = nil - if join && join.is_a?(JoinAssociation) - result = [join] - if join.parent && join.parent.is_a?(JoinAssociation) - result = joins_for_table_name(join.parent.aliased_table_name) + - result - end - end - result - end - - protected - def build(associations, parent = nil) - parent ||= @joins.last - case associations - when Symbol, String - reflection = parent.reflections[associations.to_s.intern] or - raise ConfigurationError, "Association named '#{ associations }' was not found; perhaps you misspelled it?" - @reflections << reflection - @joins << build_join_association(reflection, parent) - when Array - associations.each do |association| - build(association, parent) - end - when Hash - associations.keys.sort{|a,b|a.to_s<=>b.to_s}.each do |name| - build(name, parent) - build(associations[name]) - end - else - raise ConfigurationError, associations.inspect - end - end - - # overridden in InnerJoinDependency subclass - def build_join_association(reflection, parent) - JoinAssociation.new(reflection, self, parent) - end - - def construct(parent, associations, joins, row) - case associations - when Symbol, String - join = joins.detect{|j| j.reflection.name.to_s == associations.to_s && j.parent_table_name == parent.class.table_name } - raise(ConfigurationError, "No such association") if join.nil? - - joins.delete(join) - construct_association(parent, join, row) - when Array - associations.each do |association| - construct(parent, association, joins, row) - end - when Hash - associations.keys.sort{|a,b|a.to_s<=>b.to_s}.each do |name| - join = joins.detect{|j| j.reflection.name.to_s == name.to_s && j.parent_table_name == parent.class.table_name } - raise(ConfigurationError, "No such association") if join.nil? - - association = construct_association(parent, join, row) - joins.delete(join) - construct(association, associations[name], joins, row) if association - end - else - raise ConfigurationError, associations.inspect - end - end - - def construct_association(record, join, row) - case join.reflection.macro - when :has_many, :has_and_belongs_to_many - collection = record.send(join.reflection.name) - collection.loaded - - return nil if record.id.to_s != join.parent.record_id(row).to_s or row[join.aliased_primary_key].nil? - association = join.instantiate(row) - collection.target.push(association) - when :has_one - return if record.id.to_s != join.parent.record_id(row).to_s - return if record.instance_variable_defined?("@#{join.reflection.name}") - association = join.instantiate(row) unless row[join.aliased_primary_key].nil? - record.send("set_#{join.reflection.name}_target", association) - when :belongs_to - return if record.id.to_s != join.parent.record_id(row).to_s or row[join.aliased_primary_key].nil? - association = join.instantiate(row) - record.send("set_#{join.reflection.name}_target", association) - else - raise ConfigurationError, "unknown macro: #{join.reflection.macro}" - end - return association - end - - class JoinBase # :nodoc: - attr_reader :active_record, :table_joins - delegate :table_name, :column_names, :primary_key, :reflections, :sanitize_sql, :to => :active_record - - def initialize(active_record, joins = nil) - @active_record = active_record - @cached_record = {} - @table_joins = joins - end - - def aliased_prefix - "t0" - end - - def aliased_primary_key - "#{aliased_prefix}_r0" - end - - def aliased_table_name - active_record.table_name - end - - def column_names_with_alias - unless defined?(@column_names_with_alias) - @column_names_with_alias = [] - - ([primary_key] + (column_names - [primary_key])).each_with_index do |column_name, i| - @column_names_with_alias << [column_name, "#{aliased_prefix}_r#{i}"] - end - end - - @column_names_with_alias - end - - def extract_record(row) - column_names_with_alias.inject({}){|record, (cn, an)| record[cn] = row[an]; record} - end - - def record_id(row) - row[aliased_primary_key] - end - - def instantiate(row) - @cached_record[record_id(row)] ||= active_record.send(:instantiate, extract_record(row)) - end - end - - class JoinAssociation < JoinBase # :nodoc: - attr_reader :reflection, :parent, :aliased_table_name, :aliased_prefix, :aliased_join_table_name, :parent_table_name - delegate :options, :klass, :through_reflection, :source_reflection, :to => :reflection - - def initialize(reflection, join_dependency, parent = nil) - reflection.check_validity! - if reflection.options[:polymorphic] - raise EagerLoadPolymorphicError.new(reflection) - end - - super(reflection.klass) - @join_dependency = join_dependency - @parent = parent - @reflection = reflection - @aliased_prefix = "t#{ join_dependency.joins.size }" - @parent_table_name = parent.active_record.table_name - @aliased_table_name = aliased_table_name_for(table_name) - - if reflection.macro == :has_and_belongs_to_many - @aliased_join_table_name = aliased_table_name_for(reflection.options[:join_table], "_join") - end - - if [:has_many, :has_one].include?(reflection.macro) && reflection.options[:through] - @aliased_join_table_name = aliased_table_name_for(reflection.through_reflection.klass.table_name, "_join") - end - end - - def association_join - connection = reflection.active_record.connection - join = case reflection.macro - when :has_and_belongs_to_many - " #{join_type} %s ON %s.%s = %s.%s " % [ - table_alias_for(options[:join_table], aliased_join_table_name), - connection.quote_table_name(aliased_join_table_name), - options[:foreign_key] || reflection.active_record.to_s.foreign_key, - connection.quote_table_name(parent.aliased_table_name), - reflection.active_record.primary_key] + - " #{join_type} %s ON %s.%s = %s.%s " % [ - table_name_and_alias, - connection.quote_table_name(aliased_table_name), - klass.primary_key, - connection.quote_table_name(aliased_join_table_name), - options[:association_foreign_key] || klass.to_s.foreign_key - ] - when :has_many, :has_one - case - when reflection.options[:through] - through_conditions = through_reflection.options[:conditions] ? "AND #{interpolate_sql(sanitize_sql(through_reflection.options[:conditions]))}" : '' - - jt_foreign_key = jt_as_extra = jt_source_extra = jt_sti_extra = nil - first_key = second_key = as_extra = nil - - if through_reflection.options[:as] # has_many :through against a polymorphic join - jt_foreign_key = through_reflection.options[:as].to_s + '_id' - jt_as_extra = " AND %s.%s = %s" % [ - connection.quote_table_name(aliased_join_table_name), - connection.quote_column_name(through_reflection.options[:as].to_s + '_type'), - klass.quote_value(parent.active_record.base_class.name) - ] - else - jt_foreign_key = through_reflection.primary_key_name - end - - case source_reflection.macro - when :has_many - if source_reflection.options[:as] - first_key = "#{source_reflection.options[:as]}_id" - second_key = options[:foreign_key] || primary_key - as_extra = " AND %s.%s = %s" % [ - connection.quote_table_name(aliased_table_name), - connection.quote_column_name("#{source_reflection.options[:as]}_type"), - klass.quote_value(source_reflection.active_record.base_class.name) - ] - else - first_key = through_reflection.klass.base_class.to_s.foreign_key - second_key = options[:foreign_key] || primary_key - end - - unless through_reflection.klass.descends_from_active_record? - jt_sti_extra = " AND %s.%s = %s" % [ - connection.quote_table_name(aliased_join_table_name), - connection.quote_column_name(through_reflection.active_record.inheritance_column), - through_reflection.klass.quote_value(through_reflection.klass.sti_name)] - end - when :belongs_to - first_key = primary_key - if reflection.options[:source_type] - second_key = source_reflection.association_foreign_key - jt_source_extra = " AND %s.%s = %s" % [ - connection.quote_table_name(aliased_join_table_name), - connection.quote_column_name(reflection.source_reflection.options[:foreign_type]), - klass.quote_value(reflection.options[:source_type]) - ] - else - second_key = source_reflection.primary_key_name - end - end - - " #{join_type} %s ON (%s.%s = %s.%s%s%s%s) " % [ - table_alias_for(through_reflection.klass.table_name, aliased_join_table_name), - connection.quote_table_name(parent.aliased_table_name), - connection.quote_column_name(parent.primary_key), - connection.quote_table_name(aliased_join_table_name), - connection.quote_column_name(jt_foreign_key), - jt_as_extra, jt_source_extra, jt_sti_extra - ] + - " #{join_type} %s ON (%s.%s = %s.%s%s) " % [ - table_name_and_alias, - connection.quote_table_name(aliased_table_name), - connection.quote_column_name(first_key), - connection.quote_table_name(aliased_join_table_name), - connection.quote_column_name(second_key), - as_extra - ] - - when reflection.options[:as] && [:has_many, :has_one].include?(reflection.macro) - " #{join_type} %s ON %s.%s = %s.%s AND %s.%s = %s" % [ - table_name_and_alias, - connection.quote_table_name(aliased_table_name), - "#{reflection.options[:as]}_id", - connection.quote_table_name(parent.aliased_table_name), - parent.primary_key, - connection.quote_table_name(aliased_table_name), - "#{reflection.options[:as]}_type", - klass.quote_value(parent.active_record.base_class.name) - ] - else - foreign_key = options[:foreign_key] || reflection.active_record.name.foreign_key - " #{join_type} %s ON %s.%s = %s.%s " % [ - table_name_and_alias, - aliased_table_name, - foreign_key, - parent.aliased_table_name, - reflection.options[:primary_key] || parent.primary_key - ] - end - when :belongs_to - " #{join_type} %s ON %s.%s = %s.%s " % [ - table_name_and_alias, - connection.quote_table_name(aliased_table_name), - reflection.klass.primary_key, - connection.quote_table_name(parent.aliased_table_name), - options[:foreign_key] || reflection.primary_key_name - ] - else - "" - end || '' - join << %(AND %s) % [ - klass.send(:type_condition, aliased_table_name)] unless klass.descends_from_active_record? - - [through_reflection, reflection].each do |ref| - join << "AND #{interpolate_sql(sanitize_sql(ref.options[:conditions]))} " if ref && ref.options[:conditions] - end - - join - end - - protected - - def aliased_table_name_for(name, suffix = nil) - if !parent.table_joins.blank? && parent.table_joins.to_s.downcase =~ %r{join(\s+\w+)?\s+#{active_record.connection.quote_table_name name.downcase}\son} - @join_dependency.table_aliases[name] += 1 - end - - unless @join_dependency.table_aliases[name].zero? - # if the table name has been used, then use an alias - name = active_record.connection.table_alias_for "#{pluralize(reflection.name)}_#{parent_table_name}#{suffix}" - table_index = @join_dependency.table_aliases[name] - @join_dependency.table_aliases[name] += 1 - name = name[0..active_record.connection.table_alias_length-3] + "_#{table_index+1}" if table_index > 0 - else - @join_dependency.table_aliases[name] += 1 - end - - name - end - - def pluralize(table_name) - ActiveRecord::Base.pluralize_table_names ? table_name.to_s.pluralize : table_name - end - - def table_alias_for(table_name, table_alias) - "#{reflection.active_record.connection.quote_table_name(table_name)} #{table_alias if table_name != table_alias}".strip - end - - def table_name_and_alias - table_alias_for table_name, @aliased_table_name - end - - def interpolate_sql(sql) - instance_eval("%@#{sql.gsub('@', '\@')}@") - end - - private - def join_type - "LEFT OUTER JOIN" - end - end - end - - class InnerJoinDependency < JoinDependency # :nodoc: - protected - def build_join_association(reflection, parent) - InnerJoinAssociation.new(reflection, self, parent) - end - - class InnerJoinAssociation < JoinAssociation - private - def join_type - "INNER JOIN" - end - end - end - - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb b/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb deleted file mode 100644 index ad375be..0000000 --- a/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb +++ /dev/null @@ -1,470 +0,0 @@ -require 'set' - -module ActiveRecord - module Associations - # AssociationCollection is an abstract class that provides common stuff to - # ease the implementation of association proxies that represent - # collections. See the class hierarchy in AssociationProxy. - # - # You need to be careful with assumptions regarding the target: The proxy - # does not fetch records from the database until it needs them, but new - # ones created with +build+ are added to the target. So, the target may be - # non-empty and still lack children waiting to be read from the database. - # If you look directly to the database you cannot assume that's the entire - # collection because new records may have beed added to the target, etc. - # - # If you need to work on all current children, new and existing records, - # +load_target+ and the +loaded+ flag are your friends. - class AssociationCollection < AssociationProxy #:nodoc: - def initialize(owner, reflection) - super - construct_sql - end - - def find(*args) - options = args.extract_options! - - # If using a custom finder_sql, scan the entire collection. - if @reflection.options[:finder_sql] - expects_array = args.first.kind_of?(Array) - ids = args.flatten.compact.uniq.map { |arg| arg.to_i } - - if ids.size == 1 - id = ids.first - record = load_target.detect { |r| id == r.id } - expects_array ? [ record ] : record - else - load_target.select { |r| ids.include?(r.id) } - end - else - conditions = "#{@finder_sql}" - if sanitized_conditions = sanitize_sql(options[:conditions]) - conditions << " AND (#{sanitized_conditions})" - end - - options[:conditions] = conditions - - if options[:order] && @reflection.options[:order] - options[:order] = "#{options[:order]}, #{@reflection.options[:order]}" - elsif @reflection.options[:order] - options[:order] = @reflection.options[:order] - end - - # Build options specific to association - construct_find_options!(options) - - merge_options_from_reflection!(options) - - # Pass through args exactly as we received them. - args << options - @reflection.klass.find(*args) - end - end - - # Fetches the first one using SQL if possible. - def first(*args) - if fetch_first_or_last_using_find?(args) - find(:first, *args) - else - load_target unless loaded? - @target.first(*args) - end - end - - # Fetches the last one using SQL if possible. - def last(*args) - if fetch_first_or_last_using_find?(args) - find(:last, *args) - else - load_target unless loaded? - @target.last(*args) - end - end - - def to_ary - load_target - if @target.is_a?(Array) - @target.to_ary - else - Array(@target) - end - end - - def reset - reset_target! - @loaded = false - end - - def build(attributes = {}, &block) - if attributes.is_a?(Array) - attributes.collect { |attr| build(attr, &block) } - else - build_record(attributes) do |record| - block.call(record) if block_given? - set_belongs_to_association_for(record) - end - end - end - - # Add +records+ to this association. Returns +self+ so method calls may be chained. - # Since << flattens its argument list and inserts each record, +push+ and +concat+ behave identically. - def <<(*records) - result = true - load_target if @owner.new_record? - - transaction do - flatten_deeper(records).each do |record| - raise_on_type_mismatch(record) - add_record_to_target_with_callbacks(record) do |r| - result &&= insert_record(record) unless @owner.new_record? - end - end - end - - result && self - end - - alias_method :push, :<< - alias_method :concat, :<< - - # Starts a transaction in the association class's database connection. - # - # class Author < ActiveRecord::Base - # has_many :books - # end - # - # Author.find(:first).books.transaction do - # # same effect as calling Book.transaction - # end - def transaction(*args) - @reflection.klass.transaction(*args) do - yield - end - end - - # Remove all records from this association - def delete_all - load_target - delete(@target) - reset_target! - end - - # Calculate sum using SQL, not Enumerable - def sum(*args) - if block_given? - calculate(:sum, *args) { |*block_args| yield(*block_args) } - else - calculate(:sum, *args) - end - end - - # Count all records using SQL. If the +:counter_sql+ option is set for the association, it will - # be used for the query. If no +:counter_sql+ was supplied, but +:finder_sql+ was set, the - # descendant's +construct_sql+ method will have set :counter_sql automatically. - # Otherwise, construct options and pass them with scope to the target class's +count+. - def count(*args) - if @reflection.options[:counter_sql] - @reflection.klass.count_by_sql(@counter_sql) - else - column_name, options = @reflection.klass.send(:construct_count_options_from_args, *args) - if @reflection.options[:uniq] - # This is needed because 'SELECT count(DISTINCT *)..' is not valid SQL. - column_name = "#{@reflection.quoted_table_name}.#{@reflection.klass.primary_key}" if column_name == :all - options.merge!(:distinct => true) - end - - value = @reflection.klass.send(:with_scope, construct_scope) { @reflection.klass.count(column_name, options) } - - limit = @reflection.options[:limit] - offset = @reflection.options[:offset] - - if limit || offset - [ [value - offset.to_i, 0].max, limit.to_i ].min - else - value - end - end - end - - # Removes +records+ from this association calling +before_remove+ and - # +after_remove+ callbacks. - # - # This method is abstract in the sense that +delete_records+ has to be - # provided by descendants. Note this method does not imply the records - # are actually removed from the database, that depends precisely on - # +delete_records+. They are in any case removed from the collection. - def delete(*records) - remove_records(records) do |records, old_records| - delete_records(old_records) if old_records.any? - records.each { |record| @target.delete(record) } - end - end - - # Destroy +records+ and remove from this association calling +before_remove+ - # and +after_remove+ callbacks. - # - # Note this method will always remove records from database ignoring the - # +:dependent+ option. - def destroy(*records) - remove_records(records) do |records, old_records| - old_records.each { |record| record.destroy } - end - - load_target - end - - # Removes all records from this association. Returns +self+ so method calls may be chained. - def clear - return self if length.zero? # forces load_target if it hasn't happened already - - if @reflection.options[:dependent] && @reflection.options[:dependent] == :destroy - destroy_all - else - delete_all - end - - self - end - - # Destory all the records from this association - def destroy_all - load_target - destroy(@target) - reset_target! - end - - def create(attrs = {}) - if attrs.is_a?(Array) - attrs.collect { |attr| create(attr) } - else - create_record(attrs) do |record| - yield(record) if block_given? - record.save - end - end - end - - def create!(attrs = {}) - create_record(attrs) do |record| - yield(record) if block_given? - record.save! - end - end - - # Returns the size of the collection by executing a SELECT COUNT(*) - # query if the collection hasn't been loaded, and calling - # <tt>collection.size</tt> if it has. - # - # If the collection has been already loaded +size+ and +length+ are - # equivalent. If not and you are going to need the records anyway - # +length+ will take one less query. Otherwise +size+ is more efficient. - # - # This method is abstract in the sense that it relies on - # +count_records+, which is a method descendants have to provide. - def size - if @owner.new_record? || (loaded? && !@reflection.options[:uniq]) - @target.size - elsif !loaded? && @reflection.options[:group] - load_target.size - elsif !loaded? && !@reflection.options[:uniq] && @target.is_a?(Array) - unsaved_records = @target.select { |r| r.new_record? } - unsaved_records.size + count_records - else - count_records - end - end - - # Returns the size of the collection calling +size+ on the target. - # - # If the collection has been already loaded +length+ and +size+ are - # equivalent. If not and you are going to need the records anyway this - # method will take one less query. Otherwise +size+ is more efficient. - def length - load_target.size - end - - # Equivalent to <tt>collection.size.zero?</tt>. If the collection has - # not been already loaded and you are going to fetch the records anyway - # it is better to check <tt>collection.length.zero?</tt>. - def empty? - size.zero? - end - - def any? - if block_given? - method_missing(:any?) { |*block_args| yield(*block_args) } - else - !empty? - end - end - - def uniq(collection = self) - seen = Set.new - collection.inject([]) do |kept, record| - unless seen.include?(record.id) - kept << record - seen << record.id - end - kept - end - end - - # Replace this collection with +other_array+ - # This will perform a diff and delete/add only records that have changed. - def replace(other_array) - other_array.each { |val| raise_on_type_mismatch(val) } - - load_target - other = other_array.size < 100 ? other_array : other_array.to_set - current = @target.size < 100 ? @target : @target.to_set - - transaction do - delete(@target.select { |v| !other.include?(v) }) - concat(other_array.select { |v| !current.include?(v) }) - end - end - - def include?(record) - return false unless record.is_a?(@reflection.klass) - load_target if @reflection.options[:finder_sql] && !loaded? - return @target.include?(record) if loaded? - exists?(record) - end - - def proxy_respond_to?(method, include_private = false) - super || @reflection.klass.respond_to?(method, include_private) - end - - protected - def construct_find_options!(options) - end - - def load_target - if !@owner.new_record? || foreign_key_present - begin - if !loaded? - if @target.is_a?(Array) && @target.any? - @target = find_target + @target.find_all {|t| t.new_record? } - else - @target = find_target - end - end - rescue ActiveRecord::RecordNotFound - reset - end - end - - loaded if target - target - end - - def method_missing(method, *args) - if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method)) - if block_given? - super { |*block_args| yield(*block_args) } - else - super - end - elsif @reflection.klass.scopes.include?(method) - @reflection.klass.scopes[method].call(self, *args) - else - with_scope(construct_scope) do - if block_given? - @reflection.klass.send(method, *args) { |*block_args| yield(*block_args) } - else - @reflection.klass.send(method, *args) - end - end - end - end - - # overloaded in derived Association classes to provide useful scoping depending on association type. - def construct_scope - {} - end - - def reset_target! - @target = Array.new - end - - def find_target - records = - if @reflection.options[:finder_sql] - @reflection.klass.find_by_sql(@finder_sql) - else - find(:all) - end - - @reflection.options[:uniq] ? uniq(records) : records - end - - private - - def create_record(attrs) - attrs.update(@reflection.options[:conditions]) if @reflection.options[:conditions].is_a?(Hash) - ensure_owner_is_not_new - record = @reflection.klass.send(:with_scope, :create => construct_scope[:create]) do - @reflection.build_association(attrs) - end - if block_given? - add_record_to_target_with_callbacks(record) { |*block_args| yield(*block_args) } - else - add_record_to_target_with_callbacks(record) - end - end - - def build_record(attrs) - attrs.update(@reflection.options[:conditions]) if @reflection.options[:conditions].is_a?(Hash) - record = @reflection.build_association(attrs) - if block_given? - add_record_to_target_with_callbacks(record) { |*block_args| yield(*block_args) } - else - add_record_to_target_with_callbacks(record) - end - end - - def add_record_to_target_with_callbacks(record) - callback(:before_add, record) - yield(record) if block_given? - @target ||= [] unless loaded? - @target << record unless @reflection.options[:uniq] && @target.include?(record) - callback(:after_add, record) - record - end - - def remove_records(*records) - records = flatten_deeper(records) - records.each { |record| raise_on_type_mismatch(record) } - - transaction do - records.each { |record| callback(:before_remove, record) } - old_records = records.reject { |r| r.new_record? } - yield(records, old_records) - records.each { |record| callback(:after_remove, record) } - end - end - - def callback(method, record) - callbacks_for(method).each do |callback| - ActiveSupport::Callbacks::Callback.new(method, callback, record).call(@owner, record) - end - end - - def callbacks_for(callback_name) - full_callback_name = "#{callback_name}_for_#{@reflection.name}" - @owner.class.read_inheritable_attribute(full_callback_name.to_sym) || [] - end - - def ensure_owner_is_not_new - if @owner.new_record? - raise ActiveRecord::RecordNotSaved, "You cannot call create unless the parent is saved" - end - end - - def fetch_first_or_last_using_find?(args) - args.first.kind_of?(Hash) || !(loaded? || @owner.new_record? || @reflection.options[:finder_sql] || - @target.any? { |record| record.new_record? } || args.first.kind_of?(Integer)) - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb b/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb deleted file mode 100644 index 676c4ac..0000000 --- a/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb +++ /dev/null @@ -1,279 +0,0 @@ -module ActiveRecord - module Associations - # This is the root class of all association proxies: - # - # AssociationProxy - # BelongsToAssociation - # HasOneAssociation - # BelongsToPolymorphicAssociation - # AssociationCollection - # HasAndBelongsToManyAssociation - # HasManyAssociation - # HasManyThroughAssociation - # HasOneThroughAssociation - # - # Association proxies in Active Record are middlemen between the object that - # holds the association, known as the <tt>@owner</tt>, and the actual associated - # object, known as the <tt>@target</tt>. The kind of association any proxy is - # about is available in <tt>@reflection</tt>. That's an instance of the class - # ActiveRecord::Reflection::AssociationReflection. - # - # For example, given - # - # class Blog < ActiveRecord::Base - # has_many :posts - # end - # - # blog = Blog.find(:first) - # - # the association proxy in <tt>blog.posts</tt> has the object in +blog+ as - # <tt>@owner</tt>, the collection of its posts as <tt>@target</tt>, and - # the <tt>@reflection</tt> object represents a <tt>:has_many</tt> macro. - # - # This class has most of the basic instance methods removed, and delegates - # unknown methods to <tt>@target</tt> via <tt>method_missing</tt>. As a - # corner case, it even removes the +class+ method and that's why you get - # - # blog.posts.class # => Array - # - # though the object behind <tt>blog.posts</tt> is not an Array, but an - # ActiveRecord::Associations::HasManyAssociation. - # - # The <tt>@target</tt> object is not \loaded until needed. For example, - # - # blog.posts.count - # - # is computed directly through SQL and does not trigger by itself the - # instantiation of the actual post records. - class AssociationProxy #:nodoc: - alias_method :proxy_respond_to?, :respond_to? - alias_method :proxy_extend, :extend - delegate :to_param, :to => :proxy_target - instance_methods.each { |m| undef_method m unless m =~ /(^__|^nil\?$|^send$|proxy_|^object_id$)/ } - - def initialize(owner, reflection) - @owner, @reflection = owner, reflection - Array(reflection.options[:extend]).each { |ext| proxy_extend(ext) } - reset - end - - # Returns the owner of the proxy. - def proxy_owner - @owner - end - - # Returns the reflection object that represents the association handled - # by the proxy. - def proxy_reflection - @reflection - end - - # Returns the \target of the proxy, same as +target+. - def proxy_target - @target - end - - # Does the proxy or its \target respond to +symbol+? - def respond_to?(*args) - proxy_respond_to?(*args) || (load_target && @target.respond_to?(*args)) - end - - # Forwards <tt>===</tt> explicitly to the \target because the instance method - # removal above doesn't catch it. Loads the \target if needed. - def ===(other) - load_target - other === @target - end - - # Returns the name of the table of the related class: - # - # post.comments.aliased_table_name # => "comments" - # - def aliased_table_name - @reflection.klass.table_name - end - - # Returns the SQL string that corresponds to the <tt>:conditions</tt> - # option of the macro, if given, or +nil+ otherwise. - def conditions - @conditions ||= interpolate_sql(@reflection.sanitized_conditions) if @reflection.sanitized_conditions - end - alias :sql_conditions :conditions - - # Resets the \loaded flag to +false+ and sets the \target to +nil+. - def reset - @loaded = false - @target = nil - end - - # Reloads the \target and returns +self+ on success. - def reload - reset - load_target - self unless @target.nil? - end - - # Has the \target been already \loaded? - def loaded? - @loaded - end - - # Asserts the \target has been loaded setting the \loaded flag to +true+. - def loaded - @loaded = true - end - - # Returns the target of this proxy, same as +proxy_target+. - def target - @target - end - - # Sets the target of this proxy to <tt>\target</tt>, and the \loaded flag to +true+. - def target=(target) - @target = target - loaded - end - - # Forwards the call to the target. Loads the \target if needed. - def inspect - load_target - @target.inspect - end - - def send(method, *args) - if proxy_respond_to?(method) - super - else - load_target - @target.send(method, *args) - end - end - - protected - # Does the association have a <tt>:dependent</tt> option? - def dependent? - @reflection.options[:dependent] - end - - # Returns a string with the IDs of +records+ joined with a comma, quoted - # if needed. The result is ready to be inserted into a SQL IN clause. - # - # quoted_record_ids(records) # => "23,56,58,67" - # - def quoted_record_ids(records) - records.map { |record| record.quoted_id }.join(',') - end - - def interpolate_sql(sql, record = nil) - @owner.send(:interpolate_sql, sql, record) - end - - # Forwards the call to the reflection class. - def sanitize_sql(sql) - @reflection.klass.send(:sanitize_sql, sql) - end - - # Assigns the ID of the owner to the corresponding foreign key in +record+. - # If the association is polymorphic the type of the owner is also set. - def set_belongs_to_association_for(record) - if @reflection.options[:as] - record["#{@reflection.options[:as]}_id"] = @owner.id unless @owner.new_record? - record["#{@reflection.options[:as]}_type"] = @owner.class.base_class.name.to_s - else - unless @owner.new_record? - primary_key = @reflection.options[:primary_key] || :id - record[@reflection.primary_key_name] = @owner.send(primary_key) - end - end - end - - # Merges into +options+ the ones coming from the reflection. - def merge_options_from_reflection!(options) - options.reverse_merge!( - :group => @reflection.options[:group], - :having => @reflection.options[:having], - :limit => @reflection.options[:limit], - :offset => @reflection.options[:offset], - :joins => @reflection.options[:joins], - :include => @reflection.options[:include], - :select => @reflection.options[:select], - :readonly => @reflection.options[:readonly] - ) - end - - # Forwards +with_scope+ to the reflection. - def with_scope(*args, &block) - @reflection.klass.send :with_scope, *args, &block - end - - private - # Forwards any missing method call to the \target. - def method_missing(method, *args) - if load_target - unless @target.respond_to?(method) - message = "undefined method `#{method.to_s}' for \"#{@target}\":#{@target.class.to_s}" - raise NoMethodError, message - end - - if block_given? - @target.send(method, *args) { |*block_args| yield(*block_args) } - else - @target.send(method, *args) - end - end - end - - # Loads the \target if needed and returns it. - # - # This method is abstract in the sense that it relies on +find_target+, - # which is expected to be provided by descendants. - # - # If the \target is already \loaded it is just returned. Thus, you can call - # +load_target+ unconditionally to get the \target. - # - # ActiveRecord::RecordNotFound is rescued within the method, and it is - # not reraised. The proxy is \reset and +nil+ is the return value. - def load_target - return nil unless defined?(@loaded) - - if !loaded? and (!@owner.new_record? || foreign_key_present) - @target = find_target - end - - @loaded = true - @target - rescue ActiveRecord::RecordNotFound - reset - end - - # Can be overwritten by associations that might have the foreign key - # available for an association without having the object itself (and - # still being a new record). Currently, only +belongs_to+ presents - # this scenario (both vanilla and polymorphic). - def foreign_key_present - false - end - - # Raises ActiveRecord::AssociationTypeMismatch unless +record+ is of - # the kind of the class of the associated objects. Meant to be used as - # a sanity check when you are about to assign an associated record. - def raise_on_type_mismatch(record) - unless record.is_a?(@reflection.klass) || record.is_a?(@reflection.class_name.constantize) - message = "#{@reflection.class_name}(##{@reflection.klass.object_id}) expected, got #{record.class}(##{record.class.object_id})" - raise ActiveRecord::AssociationTypeMismatch, message - end - end - - # Array#flatten has problems with recursive arrays. Going one level - # deeper solves the majority of the problems. - def flatten_deeper(array) - array.collect { |element| (element.respond_to?(:flatten) && !element.is_a?(Hash)) ? element.flatten : element }.flatten - end - - # Returns the ID of the owner, quoted if needed. - def owner_quoted_id - @owner.quoted_id - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb b/vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb deleted file mode 100644 index f05c6be..0000000 --- a/vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb +++ /dev/null @@ -1,58 +0,0 @@ -module ActiveRecord - module Associations - class BelongsToAssociation < AssociationProxy #:nodoc: - def create(attributes = {}) - replace(@reflection.create_association(attributes)) - end - - def build(attributes = {}) - replace(@reflection.build_association(attributes)) - end - - def replace(record) - counter_cache_name = @reflection.counter_cache_column - - if record.nil? - if counter_cache_name && !@owner.new_record? - @reflection.klass.decrement_counter(counter_cache_name, @owner[@reflection.primary_key_name]) if @owner[@reflection.primary_key_name] - end - - @target = @owner[@reflection.primary_key_name] = nil - else - raise_on_type_mismatch(record) - - if counter_cache_name && !@owner.new_record? - @reflection.klass.increment_counter(counter_cache_name, record.id) - @reflection.klass.decrement_counter(counter_cache_name, @owner[@reflection.primary_key_name]) if @owner[@reflection.primary_key_name] - end - - @target = (AssociationProxy === record ? record.target : record) - @owner[@reflection.primary_key_name] = record.id unless record.new_record? - @updated = true - end - - loaded - record - end - - def updated? - @updated - end - - private - def find_target - @reflection.klass.find( - @owner[@reflection.primary_key_name], - :select => @reflection.options[:select], - :conditions => conditions, - :include => @reflection.options[:include], - :readonly => @reflection.options[:readonly] - ) - end - - def foreign_key_present - !@owner[@reflection.primary_key_name].nil? - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb b/vendor/rails/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb deleted file mode 100644 index d8146da..0000000 --- a/vendor/rails/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb +++ /dev/null @@ -1,49 +0,0 @@ -module ActiveRecord - module Associations - class BelongsToPolymorphicAssociation < AssociationProxy #:nodoc: - def replace(record) - if record.nil? - @target = @owner[@reflection.primary_key_name] = @owner[@reflection.options[:foreign_type]] = nil - else - @target = (AssociationProxy === record ? record.target : record) - - @owner[@reflection.primary_key_name] = record.id - @owner[@reflection.options[:foreign_type]] = record.class.base_class.name.to_s - - @updated = true - end - - loaded - record - end - - def updated? - @updated - end - - private - def find_target - return nil if association_class.nil? - - if @reflection.options[:conditions] - association_class.find( - @owner[@reflection.primary_key_name], - :select => @reflection.options[:select], - :conditions => conditions, - :include => @reflection.options[:include] - ) - else - association_class.find(@owner[@reflection.primary_key_name], :select => @reflection.options[:select], :include => @reflection.options[:include]) - end - end - - def foreign_key_present - !@owner[@reflection.primary_key_name].nil? - end - - def association_class - @owner[@reflection.options[:foreign_type]] ? @owner[@reflection.options[:foreign_type]].constantize : nil - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb deleted file mode 100644 index af9ce3d..0000000 --- a/vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +++ /dev/null @@ -1,127 +0,0 @@ -module ActiveRecord - module Associations - class HasAndBelongsToManyAssociation < AssociationCollection #:nodoc: - def create(attributes = {}) - create_record(attributes) { |record| insert_record(record) } - end - - def create!(attributes = {}) - create_record(attributes) { |record| insert_record(record, true) } - end - - def columns - @reflection.columns(@reflection.options[:join_table], "#{@reflection.options[:join_table]} Columns") - end - - def reset_column_information - @reflection.reset_column_information - end - - protected - def construct_find_options!(options) - options[:joins] = @join_sql - options[:readonly] = finding_with_ambiguous_select?(options[:select] || @reflection.options[:select]) - options[:select] ||= (@reflection.options[:select] || '*') - end - - def count_records - load_target.size - end - - def insert_record(record, force = true, validate = true) - if record.new_record? - if force - record.save! - else - return false unless record.save(validate) - end - end - - if @reflection.options[:insert_sql] - @owner.connection.insert(interpolate_sql(@reflection.options[:insert_sql], record)) - else - attributes = columns.inject({}) do |attrs, column| - case column.name.to_s - when @reflection.primary_key_name.to_s - attrs[column.name] = owner_quoted_id - when @reflection.association_foreign_key.to_s - attrs[column.name] = record.quoted_id - else - if record.has_attribute?(column.name) - value = @owner.send(:quote_value, record[column.name], column) - attrs[column.name] = value unless value.nil? - end - end - attrs - end - - sql = - "INSERT INTO #{@owner.connection.quote_table_name @reflection.options[:join_table]} (#{@owner.send(:quoted_column_names, attributes).join(', ')}) " + - "VALUES (#{attributes.values.join(', ')})" - - @owner.connection.insert(sql) - end - - return true - end - - def delete_records(records) - if sql = @reflection.options[:delete_sql] - records.each { |record| @owner.connection.delete(interpolate_sql(sql, record)) } - else - ids = quoted_record_ids(records) - sql = "DELETE FROM #{@owner.connection.quote_table_name @reflection.options[:join_table]} WHERE #{@reflection.primary_key_name} = #{owner_quoted_id} AND #{@reflection.association_foreign_key} IN (#{ids})" - @owner.connection.delete(sql) - end - end - - def construct_sql - if @reflection.options[:finder_sql] - @finder_sql = interpolate_sql(@reflection.options[:finder_sql]) - else - @finder_sql = "#{@owner.connection.quote_table_name @reflection.options[:join_table]}.#{@reflection.primary_key_name} = #{owner_quoted_id} " - @finder_sql << " AND (#{conditions})" if conditions - end - - @join_sql = "INNER JOIN #{@owner.connection.quote_table_name @reflection.options[:join_table]} ON #{@reflection.quoted_table_name}.#{@reflection.klass.primary_key} = #{@owner.connection.quote_table_name @reflection.options[:join_table]}.#{@reflection.association_foreign_key}" - - if @reflection.options[:counter_sql] - @counter_sql = interpolate_sql(@reflection.options[:counter_sql]) - elsif @reflection.options[:finder_sql] - # replace the SELECT clause with COUNT(*), preserving any hints within /* ... */ - @reflection.options[:counter_sql] = @reflection.options[:finder_sql].sub(/SELECT (\/\*.*?\*\/ )?(.*)\bFROM\b/im) { "SELECT #{$1}COUNT(*) FROM" } - @counter_sql = interpolate_sql(@reflection.options[:counter_sql]) - else - @counter_sql = @finder_sql - end - end - - def construct_scope - { :find => { :conditions => @finder_sql, - :joins => @join_sql, - :readonly => false, - :order => @reflection.options[:order], - :include => @reflection.options[:include], - :limit => @reflection.options[:limit] } } - end - - # Join tables with additional columns on top of the two foreign keys must be considered ambiguous unless a select - # clause has been explicitly defined. Otherwise you can get broken records back, if, for example, the join column also has - # an id column. This will then overwrite the id column of the records coming back. - def finding_with_ambiguous_select?(select_clause) - !select_clause && columns.size != 2 - end - - private - def create_record(attributes, &block) - # Can't use Base.create because the foreign key may be a protected attribute. - ensure_owner_is_not_new - if attributes.is_a?(Array) - attributes.collect { |attr| create(attr) } - else - build_record(attributes, &block) - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb b/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb deleted file mode 100644 index a2cbabf..0000000 --- a/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb +++ /dev/null @@ -1,121 +0,0 @@ -module ActiveRecord - module Associations - # This is the proxy that handles a has many association. - # - # If the association has a <tt>:through</tt> option further specialization - # is provided by its child HasManyThroughAssociation. - class HasManyAssociation < AssociationCollection #:nodoc: - protected - def owner_quoted_id - if @reflection.options[:primary_key] - quote_value(@owner.send(@reflection.options[:primary_key])) - else - @owner.quoted_id - end - end - - # Returns the number of records in this collection. - # - # If the association has a counter cache it gets that value. Otherwise - # it will attempt to do a count via SQL, bounded to <tt>:limit</tt> if - # there's one. Some configuration options like :group make it impossible - # to do a SQL count, in those cases the array count will be used. - # - # That does not depend on whether the collection has already been loaded - # or not. The +size+ method is the one that takes the loaded flag into - # account and delegates to +count_records+ if needed. - # - # If the collection is empty the target is set to an empty array and - # the loaded flag is set to true as well. - def count_records - count = if has_cached_counter? - @owner.send(:read_attribute, cached_counter_attribute_name) - elsif @reflection.options[:counter_sql] - @reflection.klass.count_by_sql(@counter_sql) - else - @reflection.klass.count(:conditions => @counter_sql, :include => @reflection.options[:include]) - end - - # If there's nothing in the database and @target has no new records - # we are certain the current target is an empty array. This is a - # documented side-effect of the method that may avoid an extra SELECT. - @target ||= [] and loaded if count == 0 - - if @reflection.options[:limit] - count = [ @reflection.options[:limit], count ].min - end - - return count - end - - def has_cached_counter? - @owner.attribute_present?(cached_counter_attribute_name) - end - - def cached_counter_attribute_name - "#{@reflection.name}_count" - end - - def insert_record(record, force = false, validate = true) - set_belongs_to_association_for(record) - force ? record.save! : record.save(validate) - end - - # Deletes the records according to the <tt>:dependent</tt> option. - def delete_records(records) - case @reflection.options[:dependent] - when :destroy - records.each { |r| r.destroy } - when :delete_all - @reflection.klass.delete(records.map { |record| record.id }) - else - ids = quoted_record_ids(records) - @reflection.klass.update_all( - "#{@reflection.primary_key_name} = NULL", - "#{@reflection.primary_key_name} = #{owner_quoted_id} AND #{@reflection.klass.primary_key} IN (#{ids})" - ) - end - end - - def target_obsolete? - false - end - - def construct_sql - case - when @reflection.options[:finder_sql] - @finder_sql = interpolate_sql(@reflection.options[:finder_sql]) - - when @reflection.options[:as] - @finder_sql = - "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " + - "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}" - @finder_sql << " AND (#{conditions})" if conditions - - else - @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}" - @finder_sql << " AND (#{conditions})" if conditions - end - - if @reflection.options[:counter_sql] - @counter_sql = interpolate_sql(@reflection.options[:counter_sql]) - elsif @reflection.options[:finder_sql] - # replace the SELECT clause with COUNT(*), preserving any hints within /* ... */ - @reflection.options[:counter_sql] = @reflection.options[:finder_sql].sub(/SELECT (\/\*.*?\*\/ )?(.*)\bFROM\b/im) { "SELECT #{$1}COUNT(*) FROM" } - @counter_sql = interpolate_sql(@reflection.options[:counter_sql]) - else - @counter_sql = @finder_sql - end - end - - def construct_scope - create_scoping = {} - set_belongs_to_association_for(create_scoping) - { - :find => { :conditions => @finder_sql, :readonly => false, :order => @reflection.options[:order], :limit => @reflection.options[:limit], :include => @reflection.options[:include]}, - :create => create_scoping - } - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb b/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb deleted file mode 100644 index 1c091e7..0000000 --- a/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb +++ /dev/null @@ -1,256 +0,0 @@ -module ActiveRecord - module Associations - class HasManyThroughAssociation < HasManyAssociation #:nodoc: - def initialize(owner, reflection) - reflection.check_validity! - super - end - - alias_method :new, :build - - def create!(attrs = nil) - transaction do - self << (object = attrs ? @reflection.klass.send(:with_scope, :create => attrs) { @reflection.create_association! } : @reflection.create_association!) - object - end - end - - def create(attrs = nil) - transaction do - self << (object = attrs ? @reflection.klass.send(:with_scope, :create => attrs) { @reflection.create_association } : @reflection.create_association) - object - end - end - - # Returns the size of the collection by executing a SELECT COUNT(*) query if the collection hasn't been loaded and - # calling collection.size if it has. If it's more likely than not that the collection does have a size larger than zero, - # and you need to fetch that collection afterwards, it'll take one fewer SELECT query if you use #length. - def size - return @owner.send(:read_attribute, cached_counter_attribute_name) if has_cached_counter? - return @target.size if loaded? - return count - end - - protected - def target_reflection_has_associated_record? - if @reflection.through_reflection.macro == :belongs_to && @owner[@reflection.through_reflection.primary_key_name].blank? - false - else - true - end - end - - def construct_find_options!(options) - options[:select] = construct_select(options[:select]) - options[:from] ||= construct_from - options[:joins] = construct_joins(options[:joins]) - options[:include] = @reflection.source_reflection.options[:include] if options[:include].nil? - end - - def insert_record(record, force = true, validate = true) - if record.new_record? - if force - record.save! - else - return false unless record.save(validate) - end - end - through_reflection = @reflection.through_reflection - klass = through_reflection.klass - @owner.send(@reflection.through_reflection.name).proxy_target << klass.send(:with_scope, :create => construct_join_attributes(record)) { through_reflection.create_association! } - end - - # TODO - add dependent option support - def delete_records(records) - klass = @reflection.through_reflection.klass - records.each do |associate| - klass.delete_all(construct_join_attributes(associate)) - end - end - - def find_target - return [] unless target_reflection_has_associated_record? - @reflection.klass.find(:all, - :select => construct_select, - :conditions => construct_conditions, - :from => construct_from, - :joins => construct_joins, - :order => @reflection.options[:order], - :limit => @reflection.options[:limit], - :group => @reflection.options[:group], - :readonly => @reflection.options[:readonly], - :include => @reflection.options[:include] || @reflection.source_reflection.options[:include] - ) - end - - # Construct attributes for associate pointing to owner. - def construct_owner_attributes(reflection) - if as = reflection.options[:as] - { "#{as}_id" => @owner.id, - "#{as}_type" => @owner.class.base_class.name.to_s } - else - { reflection.primary_key_name => @owner.id } - end - end - - # Construct attributes for :through pointing to owner and associate. - def construct_join_attributes(associate) - # TODO: revist this to allow it for deletion, supposing dependent option is supported - raise ActiveRecord::HasManyThroughCantAssociateThroughHasManyReflection.new(@owner, @reflection) if @reflection.source_reflection.macro == :has_many - join_attributes = construct_owner_attributes(@reflection.through_reflection).merge(@reflection.source_reflection.primary_key_name => associate.id) - if @reflection.options[:source_type] - join_attributes.merge!(@reflection.source_reflection.options[:foreign_type] => associate.class.base_class.name.to_s) - end - join_attributes - end - - # Associate attributes pointing to owner, quoted. - def construct_quoted_owner_attributes(reflection) - if as = reflection.options[:as] - { "#{as}_id" => owner_quoted_id, - "#{as}_type" => reflection.klass.quote_value( - @owner.class.base_class.name.to_s, - reflection.klass.columns_hash["#{as}_type"]) } - elsif reflection.macro == :belongs_to - { reflection.klass.primary_key => @owner[reflection.primary_key_name] } - else - { reflection.primary_key_name => owner_quoted_id } - end - end - - # Build SQL conditions from attributes, qualified by table name. - def construct_conditions - table_name = @reflection.through_reflection.quoted_table_name - conditions = construct_quoted_owner_attributes(@reflection.through_reflection).map do |attr, value| - "#{table_name}.#{attr} = #{value}" - end - conditions << sql_conditions if sql_conditions - "(" + conditions.join(') AND (') + ")" - end - - def construct_from - @reflection.quoted_table_name - end - - def construct_select(custom_select = nil) - distinct = "DISTINCT " if @reflection.options[:uniq] - selected = custom_select || @reflection.options[:select] || "#{distinct}#{@reflection.quoted_table_name}.*" - end - - def construct_joins(custom_joins = nil) - polymorphic_join = nil - if @reflection.source_reflection.macro == :belongs_to - reflection_primary_key = @reflection.klass.primary_key - source_primary_key = @reflection.source_reflection.primary_key_name - if @reflection.options[:source_type] - polymorphic_join = "AND %s.%s = %s" % [ - @reflection.through_reflection.quoted_table_name, "#{@reflection.source_reflection.options[:foreign_type]}", - @owner.class.quote_value(@reflection.options[:source_type]) - ] - end - else - reflection_primary_key = @reflection.source_reflection.primary_key_name - source_primary_key = @reflection.through_reflection.klass.primary_key - if @reflection.source_reflection.options[:as] - polymorphic_join = "AND %s.%s = %s" % [ - @reflection.quoted_table_name, "#{@reflection.source_reflection.options[:as]}_type", - @owner.class.quote_value(@reflection.through_reflection.klass.name) - ] - end - end - - "INNER JOIN %s ON %s.%s = %s.%s %s #{@reflection.options[:joins]} #{custom_joins}" % [ - @reflection.through_reflection.quoted_table_name, - @reflection.quoted_table_name, reflection_primary_key, - @reflection.through_reflection.quoted_table_name, source_primary_key, - polymorphic_join - ] - end - - def construct_scope - { :create => construct_owner_attributes(@reflection), - :find => { :from => construct_from, - :conditions => construct_conditions, - :joins => construct_joins, - :include => @reflection.options[:include], - :select => construct_select, - :order => @reflection.options[:order], - :limit => @reflection.options[:limit], - :readonly => @reflection.options[:readonly], - } } - end - - def construct_sql - case - when @reflection.options[:finder_sql] - @finder_sql = interpolate_sql(@reflection.options[:finder_sql]) - - @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}" - @finder_sql << " AND (#{conditions})" if conditions - else - @finder_sql = construct_conditions - end - - if @reflection.options[:counter_sql] - @counter_sql = interpolate_sql(@reflection.options[:counter_sql]) - elsif @reflection.options[:finder_sql] - # replace the SELECT clause with COUNT(*), preserving any hints within /* ... */ - @reflection.options[:counter_sql] = @reflection.options[:finder_sql].sub(/SELECT (\/\*.*?\*\/ )?(.*)\bFROM\b/im) { "SELECT #{$1}COUNT(*) FROM" } - @counter_sql = interpolate_sql(@reflection.options[:counter_sql]) - else - @counter_sql = @finder_sql - end - end - - def conditions - @conditions = build_conditions unless defined?(@conditions) - @conditions - end - - def build_conditions - association_conditions = @reflection.options[:conditions] - through_conditions = build_through_conditions - source_conditions = @reflection.source_reflection.options[:conditions] - uses_sti = !@reflection.through_reflection.klass.descends_from_active_record? - - if association_conditions || through_conditions || source_conditions || uses_sti - all = [] - - [association_conditions, source_conditions].each do |conditions| - all << interpolate_sql(sanitize_sql(conditions)) if conditions - end - - all << through_conditions if through_conditions - all << build_sti_condition if uses_sti - - all.map { |sql| "(#{sql})" } * ' AND ' - end - end - - def build_through_conditions - conditions = @reflection.through_reflection.options[:conditions] - if conditions.is_a?(Hash) - interpolate_sql(sanitize_sql(conditions)).gsub( - @reflection.quoted_table_name, - @reflection.through_reflection.quoted_table_name) - elsif conditions - interpolate_sql(sanitize_sql(conditions)) - end - end - - def build_sti_condition - @reflection.through_reflection.klass.send(:type_condition) - end - - alias_method :sql_conditions, :conditions - - def has_cached_counter? - @owner.attribute_present?(cached_counter_attribute_name) - end - - def cached_counter_attribute_name - "#{@reflection.name}_count" - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/has_one_association.rb b/vendor/rails/activerecord/lib/active_record/associations/has_one_association.rb deleted file mode 100644 index b92cbbd..0000000 --- a/vendor/rails/activerecord/lib/active_record/associations/has_one_association.rb +++ /dev/null @@ -1,124 +0,0 @@ -module ActiveRecord - module Associations - class HasOneAssociation < BelongsToAssociation #:nodoc: - def initialize(owner, reflection) - super - construct_sql - end - - def create(attrs = {}, replace_existing = true) - new_record(replace_existing) do |reflection| - reflection.create_association(attrs) - end - end - - def create!(attrs = {}, replace_existing = true) - new_record(replace_existing) do |reflection| - reflection.create_association!(attrs) - end - end - - def build(attrs = {}, replace_existing = true) - new_record(replace_existing) do |reflection| - reflection.build_association(attrs) - end - end - - def replace(obj, dont_save = false) - load_target - - unless @target.nil? || @target == obj - if dependent? && !dont_save - case @reflection.options[:dependent] - when :delete - @target.delete unless @target.new_record? - @owner.clear_association_cache - when :destroy - @target.destroy unless @target.new_record? - @owner.clear_association_cache - when :nullify - @target[@reflection.primary_key_name] = nil - @target.save unless @owner.new_record? || @target.new_record? - end - else - @target[@reflection.primary_key_name] = nil - @target.save unless @owner.new_record? || @target.new_record? - end - end - - if obj.nil? - @target = nil - else - raise_on_type_mismatch(obj) - set_belongs_to_association_for(obj) - @target = (AssociationProxy === obj ? obj.target : obj) - end - - @loaded = true - - unless @owner.new_record? or obj.nil? or dont_save - return (obj.save ? self : false) - else - return (obj.nil? ? nil : self) - end - end - - protected - def owner_quoted_id - if @reflection.options[:primary_key] - @owner.class.quote_value(@owner.send(@reflection.options[:primary_key])) - else - @owner.quoted_id - end - end - - private - def find_target - @reflection.klass.find(:first, - :conditions => @finder_sql, - :select => @reflection.options[:select], - :order => @reflection.options[:order], - :include => @reflection.options[:include], - :readonly => @reflection.options[:readonly] - ) - end - - def construct_sql - case - when @reflection.options[:as] - @finder_sql = - "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " + - "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}" - else - @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}" - end - @finder_sql << " AND (#{conditions})" if conditions - end - - def construct_scope - create_scoping = {} - set_belongs_to_association_for(create_scoping) - { :create => create_scoping } - end - - def new_record(replace_existing) - # Make sure we load the target first, if we plan on replacing the existing - # instance. Otherwise, if the target has not previously been loaded - # elsewhere, the instance we create will get orphaned. - load_target if replace_existing - record = @reflection.klass.send(:with_scope, :create => construct_scope[:create]) do - yield @reflection - end - - if replace_existing - replace(record, true) - else - record[@reflection.primary_key_name] = @owner.id unless @owner.new_record? - self.target = record - end - - record - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/associations/has_one_through_association.rb b/vendor/rails/activerecord/lib/active_record/associations/has_one_through_association.rb deleted file mode 100644 index 8073eba..0000000 --- a/vendor/rails/activerecord/lib/active_record/associations/has_one_through_association.rb +++ /dev/null @@ -1,31 +0,0 @@ -module ActiveRecord - module Associations - class HasOneThroughAssociation < HasManyThroughAssociation - - def create_through_record(new_value) #nodoc: - klass = @reflection.through_reflection.klass - - current_object = @owner.send(@reflection.through_reflection.name) - - if current_object - current_object.update_attributes(construct_join_attributes(new_value)) - else - @owner.send(@reflection.through_reflection.name, klass.send(:create, construct_join_attributes(new_value))) - end - end - - private - def find(*args) - super(args.merge(:limit => 1)) - end - - def find_target - super.first - end - - def reset_target! - @target = nil - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/attribute_methods.rb b/vendor/rails/activerecord/lib/active_record/attribute_methods.rb deleted file mode 100644 index 3ffc489..0000000 --- a/vendor/rails/activerecord/lib/active_record/attribute_methods.rb +++ /dev/null @@ -1,388 +0,0 @@ -module ActiveRecord - module AttributeMethods #:nodoc: - DEFAULT_SUFFIXES = %w(= ? _before_type_cast) - ATTRIBUTE_TYPES_CACHED_BY_DEFAULT = [:datetime, :timestamp, :time, :date] - - def self.included(base) - base.extend ClassMethods - base.attribute_method_suffix(*DEFAULT_SUFFIXES) - base.cattr_accessor :attribute_types_cached_by_default, :instance_writer => false - base.attribute_types_cached_by_default = ATTRIBUTE_TYPES_CACHED_BY_DEFAULT - base.cattr_accessor :time_zone_aware_attributes, :instance_writer => false - base.time_zone_aware_attributes = false - base.class_inheritable_accessor :skip_time_zone_conversion_for_attributes, :instance_writer => false - base.skip_time_zone_conversion_for_attributes = [] - end - - # Declare and check for suffixed attribute methods. - module ClassMethods - # Declares a method available for all attributes with the given suffix. - # Uses +method_missing+ and <tt>respond_to?</tt> to rewrite the method - # - # #{attr}#{suffix}(*args, &block) - # - # to - # - # attribute#{suffix}(#{attr}, *args, &block) - # - # An <tt>attribute#{suffix}</tt> instance method must exist and accept at least - # the +attr+ argument. - # - # For example: - # - # class Person < ActiveRecord::Base - # attribute_method_suffix '_changed?' - # - # private - # def attribute_changed?(attr) - # ... - # end - # end - # - # person = Person.find(1) - # person.name_changed? # => false - # person.name = 'Hubert' - # person.name_changed? # => true - def attribute_method_suffix(*suffixes) - attribute_method_suffixes.concat suffixes - rebuild_attribute_method_regexp - end - - # Returns MatchData if method_name is an attribute method. - def match_attribute_method?(method_name) - rebuild_attribute_method_regexp unless defined?(@@attribute_method_regexp) && @@attribute_method_regexp - @@attribute_method_regexp.match(method_name) - end - - - # Contains the names of the generated attribute methods. - def generated_methods #:nodoc: - @generated_methods ||= Set.new - end - - def generated_methods? - !generated_methods.empty? - end - - # Generates all the attribute related methods for columns in the database - # accessors, mutators and query methods. - def define_attribute_methods - return if generated_methods? - columns_hash.each do |name, column| - unless instance_method_already_implemented?(name) - if self.serialized_attributes[name] - define_read_method_for_serialized_attribute(name) - elsif create_time_zone_conversion_attribute?(name, column) - define_read_method_for_time_zone_conversion(name) - else - define_read_method(name.to_sym, name, column) - end - end - - unless instance_method_already_implemented?("#{name}=") - if create_time_zone_conversion_attribute?(name, column) - define_write_method_for_time_zone_conversion(name) - else - define_write_method(name.to_sym) - end - end - - unless instance_method_already_implemented?("#{name}?") - define_question_method(name) - end - end - end - - # Checks whether the method is defined in the model or any of its subclasses - # that also derive from Active Record. Raises DangerousAttributeError if the - # method is defined by Active Record though. - def instance_method_already_implemented?(method_name) - method_name = method_name.to_s - return true if method_name =~ /^id(=$|\?$|$)/ - @_defined_class_methods ||= ancestors.first(ancestors.index(ActiveRecord::Base)).sum([]) { |m| m.public_instance_methods(false) | m.private_instance_methods(false) | m.protected_instance_methods(false) }.map(&:to_s).to_set - @@_defined_activerecord_methods ||= (ActiveRecord::Base.public_instance_methods(false) | ActiveRecord::Base.private_instance_methods(false) | ActiveRecord::Base.protected_instance_methods(false)).map(&:to_s).to_set - raise DangerousAttributeError, "#{method_name} is defined by ActiveRecord" if @@_defined_activerecord_methods.include?(method_name) - @_defined_class_methods.include?(method_name) - end - - alias :define_read_methods :define_attribute_methods - - # +cache_attributes+ allows you to declare which converted attribute values should - # be cached. Usually caching only pays off for attributes with expensive conversion - # methods, like time related columns (e.g. +created_at+, +updated_at+). - def cache_attributes(*attribute_names) - attribute_names.each {|attr| cached_attributes << attr.to_s} - end - - # Returns the attributes which are cached. By default time related columns - # with datatype <tt>:datetime, :timestamp, :time, :date</tt> are cached. - def cached_attributes - @cached_attributes ||= - columns.select{|c| attribute_types_cached_by_default.include?(c.type)}.map(&:name).to_set - end - - # Returns +true+ if the provided attribute is being cached. - def cache_attribute?(attr_name) - cached_attributes.include?(attr_name) - end - - private - # Suffixes a, ?, c become regexp /(a|\?|c)$/ - def rebuild_attribute_method_regexp - suffixes = attribute_method_suffixes.map { |s| Regexp.escape(s) } - @@attribute_method_regexp = /(#{suffixes.join('|')})$/.freeze - end - - # Default to =, ?, _before_type_cast - def attribute_method_suffixes - @@attribute_method_suffixes ||= [] - end - - def create_time_zone_conversion_attribute?(name, column) - time_zone_aware_attributes && !skip_time_zone_conversion_for_attributes.include?(name.to_sym) && [:datetime, :timestamp].include?(column.type) - end - - # Define an attribute reader method. Cope with nil column. - def define_read_method(symbol, attr_name, column) - cast_code = column.type_cast_code('v') if column - access_code = cast_code ? "(v=@attributes['#{attr_name}']) && #{cast_code}" : "@attributes['#{attr_name}']" - - unless attr_name.to_s == self.primary_key.to_s - access_code = access_code.insert(0, "missing_attribute('#{attr_name}', caller) unless @attributes.has_key?('#{attr_name}'); ") - end - - if cache_attribute?(attr_name) - access_code = "@attributes_cache['#{attr_name}'] ||= (#{access_code})" - end - evaluate_attribute_method attr_name, "def #{symbol}; #{access_code}; end" - end - - # Define read method for serialized attribute. - def define_read_method_for_serialized_attribute(attr_name) - evaluate_attribute_method attr_name, "def #{attr_name}; unserialize_attribute('#{attr_name}'); end" - end - - # Defined for all +datetime+ and +timestamp+ attributes when +time_zone_aware_attributes+ are enabled. - # This enhanced read method automatically converts the UTC time stored in the database to the time zone stored in Time.zone. - def define_read_method_for_time_zone_conversion(attr_name) - method_body = <<-EOV - def #{attr_name}(reload = false) - cached = @attributes_cache['#{attr_name}'] - return cached if cached && !reload - time = read_attribute('#{attr_name}') - @attributes_cache['#{attr_name}'] = time.acts_like?(:time) ? time.in_time_zone : time - end - EOV - evaluate_attribute_method attr_name, method_body - end - - # Defines a predicate method <tt>attr_name?</tt>. - def define_question_method(attr_name) - evaluate_attribute_method attr_name, "def #{attr_name}?; query_attribute('#{attr_name}'); end", "#{attr_name}?" - end - - def define_write_method(attr_name) - evaluate_attribute_method attr_name, "def #{attr_name}=(new_value);write_attribute('#{attr_name}', new_value);end", "#{attr_name}=" - end - - # Defined for all +datetime+ and +timestamp+ attributes when +time_zone_aware_attributes+ are enabled. - # This enhanced write method will automatically convert the time passed to it to the zone stored in Time.zone. - def define_write_method_for_time_zone_conversion(attr_name) - method_body = <<-EOV - def #{attr_name}=(time) - unless time.acts_like?(:time) - time = time.is_a?(String) ? Time.zone.parse(time) : time.to_time rescue time - end - time = time.in_time_zone rescue nil if time - write_attribute(:#{attr_name}, time) - end - EOV - evaluate_attribute_method attr_name, method_body, "#{attr_name}=" - end - - # Evaluate the definition for an attribute related method - def evaluate_attribute_method(attr_name, method_definition, method_name=attr_name) - - unless method_name.to_s == primary_key.to_s - generated_methods << method_name - end - - begin - class_eval(method_definition, __FILE__, __LINE__) - rescue SyntaxError => err - generated_methods.delete(attr_name) - if logger - logger.warn "Exception occurred during reader method compilation." - logger.warn "Maybe #{attr_name} is not a valid Ruby identifier?" - logger.warn err.message - end - end - end - end # ClassMethods - - - # Allows access to the object attributes, which are held in the <tt>@attributes</tt> hash, as though they - # were first-class methods. So a Person class with a name attribute can use Person#name and - # Person#name= and never directly use the attributes hash -- except for multiple assigns with - # ActiveRecord#attributes=. A Milestone class can also ask Milestone#completed? to test that - # the completed attribute is not +nil+ or 0. - # - # It's also possible to instantiate related objects, so a Client class belonging to the clients - # table with a +master_id+ foreign key can instantiate master through Client#master. - def method_missing(method_id, *args, &block) - method_name = method_id.to_s - - if self.class.private_method_defined?(method_name) - raise NoMethodError.new("Attempt to call private method", method_name, args) - end - - # If we haven't generated any methods yet, generate them, then - # see if we've created the method we're looking for. - if !self.class.generated_methods? - self.class.define_attribute_methods - if self.class.generated_methods.include?(method_name) - return self.send(method_id, *args, &block) - end - end - - if self.class.primary_key.to_s == method_name - id - elsif md = self.class.match_attribute_method?(method_name) - attribute_name, method_type = md.pre_match, md.to_s - if @attributes.include?(attribute_name) - __send__("attribute#{method_type}", attribute_name, *args, &block) - else - super - end - elsif @attributes.include?(method_name) - read_attribute(method_name) - else - super - end - end - - # Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example, - # "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)). - def read_attribute(attr_name) - attr_name = attr_name.to_s - if !(value = @attributes[attr_name]).nil? - if column = column_for_attribute(attr_name) - if unserializable_attribute?(attr_name, column) - unserialize_attribute(attr_name) - else - column.type_cast(value) - end - else - value - end - else - nil - end - end - - def read_attribute_before_type_cast(attr_name) - @attributes[attr_name] - end - - # Returns true if the attribute is of a text column and marked for serialization. - def unserializable_attribute?(attr_name, column) - column.text? && self.class.serialized_attributes[attr_name] - end - - # Returns the unserialized object of the attribute. - def unserialize_attribute(attr_name) - unserialized_object = object_from_yaml(@attributes[attr_name]) - - if unserialized_object.is_a?(self.class.serialized_attributes[attr_name]) || unserialized_object.nil? - @attributes.frozen? ? unserialized_object : @attributes[attr_name] = unserialized_object - else - raise SerializationTypeMismatch, - "#{attr_name} was supposed to be a #{self.class.serialized_attributes[attr_name]}, but was a #{unserialized_object.class.to_s}" - end - end - - - # Updates the attribute identified by <tt>attr_name</tt> with the specified +value+. Empty strings for fixnum and float - # columns are turned into +nil+. - def write_attribute(attr_name, value) - attr_name = attr_name.to_s - @attributes_cache.delete(attr_name) - if (column = column_for_attribute(attr_name)) && column.number? - @attributes[attr_name] = convert_number_column_value(value) - else - @attributes[attr_name] = value - end - end - - - def query_attribute(attr_name) - unless value = read_attribute(attr_name) - false - else - column = self.class.columns_hash[attr_name] - if column.nil? - if Numeric === value || value !~ /[^0-9]/ - !value.to_i.zero? - else - return false if ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(value) - !value.blank? - end - elsif column.number? - !value.zero? - else - !value.blank? - end - end - end - - # A Person object with a name attribute can ask <tt>person.respond_to?(:name)</tt>, - # <tt>person.respond_to?(:name=)</tt>, and <tt>person.respond_to?(:name?)</tt> - # which will all return +true+. - alias :respond_to_without_attributes? :respond_to? - def respond_to?(method, include_private_methods = false) - method_name = method.to_s - if super - return true - elsif !include_private_methods && super(method, true) - # If we're here than we haven't found among non-private methods - # but found among all methods. Which means that given method is private. - return false - elsif !self.class.generated_methods? - self.class.define_attribute_methods - if self.class.generated_methods.include?(method_name) - return true - end - end - - if @attributes.nil? - return super - elsif @attributes.include?(method_name) - return true - elsif md = self.class.match_attribute_method?(method_name) - return true if @attributes.include?(md.pre_match) - end - super - end - - private - - def missing_attribute(attr_name, stack) - raise ActiveRecord::MissingAttributeError, "missing attribute: #{attr_name}", stack - end - - # Handle *? for method_missing. - def attribute?(attribute_name) - query_attribute(attribute_name) - end - - # Handle *= for method_missing. - def attribute=(attribute_name, value) - write_attribute(attribute_name, value) - end - - # Handle *_before_type_cast for method_missing. - def attribute_before_type_cast(attribute_name) - read_attribute_before_type_cast(attribute_name) - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/autosave_association.rb b/vendor/rails/activerecord/lib/active_record/autosave_association.rb deleted file mode 100644 index 741aa2a..0000000 --- a/vendor/rails/activerecord/lib/active_record/autosave_association.rb +++ /dev/null @@ -1,349 +0,0 @@ -module ActiveRecord - # AutosaveAssociation is a module that takes care of automatically saving - # your associations when the parent is saved. In addition to saving, it - # also destroys any associations that were marked for destruction. - # (See mark_for_destruction and marked_for_destruction?) - # - # Saving of the parent, its associations, and the destruction of marked - # associations, all happen inside 1 transaction. This should never leave the - # database in an inconsistent state after, for instance, mass assigning - # attributes and saving them. - # - # If validations for any of the associations fail, their error messages will - # be applied to the parent. - # - # Note that it also means that associations marked for destruction won't - # be destroyed directly. They will however still be marked for destruction. - # - # === One-to-one Example - # - # Consider a Post model with one Author: - # - # class Post - # has_one :author, :autosave => true - # end - # - # Saving changes to the parent and its associated model can now be performed - # automatically _and_ atomically: - # - # post = Post.find(1) - # post.title # => "The current global position of migrating ducks" - # post.author.name # => "alloy" - # - # post.title = "On the migration of ducks" - # post.author.name = "Eloy Duran" - # - # post.save - # post.reload - # post.title # => "On the migration of ducks" - # post.author.name # => "Eloy Duran" - # - # Destroying an associated model, as part of the parent's save action, is as - # simple as marking it for destruction: - # - # post.author.mark_for_destruction - # post.author.marked_for_destruction? # => true - # - # Note that the model is _not_ yet removed from the database: - # id = post.author.id - # Author.find_by_id(id).nil? # => false - # - # post.save - # post.reload.author # => nil - # - # Now it _is_ removed from the database: - # Author.find_by_id(id).nil? # => true - # - # === One-to-many Example - # - # Consider a Post model with many Comments: - # - # class Post - # has_many :comments, :autosave => true - # end - # - # Saving changes to the parent and its associated model can now be performed - # automatically _and_ atomically: - # - # post = Post.find(1) - # post.title # => "The current global position of migrating ducks" - # post.comments.first.body # => "Wow, awesome info thanks!" - # post.comments.last.body # => "Actually, your article should be named differently." - # - # post.title = "On the migration of ducks" - # post.comments.last.body = "Actually, your article should be named differently. [UPDATED]: You are right, thanks." - # - # post.save - # post.reload - # post.title # => "On the migration of ducks" - # post.comments.last.body # => "Actually, your article should be named differently. [UPDATED]: You are right, thanks." - # - # Destroying one of the associated models members, as part of the parent's - # save action, is as simple as marking it for destruction: - # - # post.comments.last.mark_for_destruction - # post.comments.last.marked_for_destruction? # => true - # post.comments.length # => 2 - # - # Note that the model is _not_ yet removed from the database: - # id = post.comments.last.id - # Comment.find_by_id(id).nil? # => false - # - # post.save - # post.reload.comments.length # => 1 - # - # Now it _is_ removed from the database: - # Comment.find_by_id(id).nil? # => true - # - # === Validation - # - # Validation is performed on the parent as usual, but also on all autosave - # enabled associations. If any of the associations fail validation, its - # error messages will be applied on the parents errors object and validation - # of the parent will fail. - # - # Consider a Post model with Author which validates the presence of its name - # attribute: - # - # class Post - # has_one :author, :autosave => true - # end - # - # class Author - # validates_presence_of :name - # end - # - # post = Post.find(1) - # post.author.name = '' - # post.save # => false - # post.errors # => #<ActiveRecord::Errors:0x174498c @errors={"author_name"=>["can't be blank"]}, @base=#<Post ...>> - # - # No validations will be performed on the associated models when validations - # are skipped for the parent: - # - # post = Post.find(1) - # post.author.name = '' - # post.save(false) # => true - module AutosaveAssociation - ASSOCIATION_TYPES = %w{ has_one belongs_to has_many has_and_belongs_to_many } - - def self.included(base) - base.class_eval do - base.extend(ClassMethods) - alias_method_chain :reload, :autosave_associations - - ASSOCIATION_TYPES.each do |type| - base.send("valid_keys_for_#{type}_association") << :autosave - end - end - end - - module ClassMethods - private - - # def belongs_to(name, options = {}) - # super - # add_autosave_association_callbacks(reflect_on_association(name)) - # end - ASSOCIATION_TYPES.each do |type| - module_eval %{ - def #{type}(name, options = {}) - super - add_autosave_association_callbacks(reflect_on_association(name)) - end - } - end - - # Adds a validate and save callback for the association as specified by - # the +reflection+. - def add_autosave_association_callbacks(reflection) - save_method = "autosave_associated_records_for_#{reflection.name}" - validation_method = "validate_associated_records_for_#{reflection.name}" - validate validation_method - - case reflection.macro - when :has_many, :has_and_belongs_to_many - before_save :before_save_collection_association - - define_method(save_method) { save_collection_association(reflection) } - # Doesn't use after_save as that would save associations added in after_create/after_update twice - after_create save_method - after_update save_method - - define_method(validation_method) { validate_collection_association(reflection) } - else - case reflection.macro - when :has_one - define_method(save_method) { save_has_one_association(reflection) } - after_save save_method - when :belongs_to - define_method(save_method) { save_belongs_to_association(reflection) } - before_save save_method - end - define_method(validation_method) { validate_single_association(reflection) } - end - end - end - - # Reloads the attributes of the object as usual and removes a mark for destruction. - def reload_with_autosave_associations(options = nil) - @marked_for_destruction = false - reload_without_autosave_associations(options) - end - - # Marks this record to be destroyed as part of the parents save transaction. - # This does _not_ actually destroy the record yet, rather it will be destroyed when <tt>parent.save</tt> is called. - # - # Only useful if the <tt>:autosave</tt> option on the parent is enabled for this associated model. - def mark_for_destruction - @marked_for_destruction = true - end - - # Returns whether or not this record will be destroyed as part of the parents save transaction. - # - # Only useful if the <tt>:autosave</tt> option on the parent is enabled for this associated model. - def marked_for_destruction? - @marked_for_destruction - end - - private - - # Returns the record for an association collection that should be validated - # or saved. If +autosave+ is +false+ only new records will be returned, - # unless the parent is/was a new record itself. - def associated_records_to_validate_or_save(association, new_record, autosave) - if new_record - association - elsif association.loaded? - autosave ? association : association.select { |record| record.new_record? } - else - autosave ? association.target : association.target.select { |record| record.new_record? } - end - end - - # Validate the association if <tt>:validate</tt> or <tt>:autosave</tt> is - # turned on for the association specified by +reflection+. - def validate_single_association(reflection) - if reflection.options[:validate] == true || reflection.options[:autosave] == true - if (association = association_instance_get(reflection.name)) && !association.target.nil? - association_valid?(reflection, association) - end - end - end - - # Validate the associated records if <tt>:validate</tt> or - # <tt>:autosave</tt> is turned on for the association specified by - # +reflection+. - def validate_collection_association(reflection) - if reflection.options[:validate] != false && association = association_instance_get(reflection.name) - if records = associated_records_to_validate_or_save(association, new_record?, reflection.options[:autosave]) - records.each { |record| association_valid?(reflection, record) } - end - end - end - - # Returns whether or not the association is valid and applies any errors to - # the parent, <tt>self</tt>, if it wasn't. Skips any <tt>:autosave</tt> - # enabled records if they're marked_for_destruction?. - def association_valid?(reflection, association) - unless valid = association.valid? - if reflection.options[:autosave] - unless association.marked_for_destruction? - association.errors.each do |attribute, message| - attribute = "#{reflection.name}_#{attribute}" - errors.add(attribute, message) unless errors.on(attribute) - end - end - else - errors.add(reflection.name) - end - end - valid - end - - # Is used as a before_save callback to check while saving a collection - # association whether or not the parent was a new record before saving. - def before_save_collection_association - @new_record_before_save = new_record? - true - end - - # Saves any new associated records, or all loaded autosave associations if - # <tt>:autosave</tt> is enabled on the association. - # - # In addition, it destroys all children that were marked for destruction - # with mark_for_destruction. - # - # This all happens inside a transaction, _if_ the Transactions module is included into - # ActiveRecord::Base after the AutosaveAssociation module, which it does by default. - def save_collection_association(reflection) - if association = association_instance_get(reflection.name) - autosave = reflection.options[:autosave] - - if records = associated_records_to_validate_or_save(association, @new_record_before_save, autosave) - records.each do |record| - if autosave && record.marked_for_destruction? - association.destroy(record) - elsif @new_record_before_save || record.new_record? - if autosave - association.send(:insert_record, record, false, false) - else - association.send(:insert_record, record) - end - elsif autosave - record.save(false) - end - end - end - - # reconstruct the SQL queries now that we know the owner's id - association.send(:construct_sql) if association.respond_to?(:construct_sql) - end - end - - # Saves the associated record if it's new or <tt>:autosave</tt> is enabled - # on the association. - # - # In addition, it will destroy the association if it was marked for - # destruction with mark_for_destruction. - # - # This all happens inside a transaction, _if_ the Transactions module is included into - # ActiveRecord::Base after the AutosaveAssociation module, which it does by default. - def save_has_one_association(reflection) - if (association = association_instance_get(reflection.name)) && !association.target.nil? - if reflection.options[:autosave] && association.marked_for_destruction? - association.destroy - elsif new_record? || association.new_record? || association[reflection.primary_key_name] != id || reflection.options[:autosave] - association[reflection.primary_key_name] = id - association.save(false) - end - end - end - - # Saves the associated record if it's new or <tt>:autosave</tt> is enabled - # on the association. - # - # In addition, it will destroy the association if it was marked for - # destruction with mark_for_destruction. - # - # This all happens inside a transaction, _if_ the Transactions module is included into - # ActiveRecord::Base after the AutosaveAssociation module, which it does by default. - def save_belongs_to_association(reflection) - if association = association_instance_get(reflection.name) - if reflection.options[:autosave] && association.marked_for_destruction? - association.destroy - else - association.save(false) if association.new_record? || reflection.options[:autosave] - - if association.updated? - self[reflection.primary_key_name] = association.id - # TODO: Removing this code doesn't seem to matter… - if reflection.options[:polymorphic] - self[reflection.options[:foreign_type]] = association.class.base_class.name.to_s - end - end - end - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/lib/active_record/base.rb b/vendor/rails/activerecord/lib/active_record/base.rb deleted file mode 100755 index 4ef3cc6..0000000 --- a/vendor/rails/activerecord/lib/active_record/base.rb +++ /dev/null @@ -1,3155 +0,0 @@ -require 'yaml' -require 'set' - -module ActiveRecord #:nodoc: - # Generic Active Record exception class. - class ActiveRecordError < StandardError - end - - # Raised when the single-table inheritance mechanism fails to locate the subclass - # (for example due to improper usage of column that +inheritance_column+ points to). - class SubclassNotFound < ActiveRecordError #:nodoc: - end - - # Raised when an object assigned to an association has an incorrect type. - # - # class Ticket < ActiveRecord::Base - # has_many :patches - # end - # - # class Patch < ActiveRecord::Base - # belongs_to :ticket - # end - # - # # Comments are not patches, this assignment raises AssociationTypeMismatch. - # @ticket.patches << Comment.new(:content => "Please attach tests to your patch.") - class AssociationTypeMismatch < ActiveRecordError - end - - # Raised when unserialized object's type mismatches one specified for serializable field. - class SerializationTypeMismatch < ActiveRecordError - end - - # Raised when adapter not specified on connection (or configuration file <tt>config/database.yml</tt> misses adapter field). - class AdapterNotSpecified < ActiveRecordError - end - - # Raised when Active Record cannot find database adapter specified in <tt>config/database.yml</tt> or programmatically. - class AdapterNotFound < ActiveRecordError - end - - # Raised when connection to the database could not been established (for example when <tt>connection=</tt> is given a nil object). - class ConnectionNotEstablished < ActiveRecordError - end - - # Raised when Active Record cannot find record by given id or set of ids. - class RecordNotFound < ActiveRecordError - end - - # Raised by ActiveRecord::Base.save! and ActiveRecord::Base.create! methods when record cannot be - # saved because record is invalid. - class RecordNotSaved < ActiveRecordError - end - - # Raised when SQL statement cannot be executed by the database (for example, it's often the case for MySQL when Ruby driver used is too old). - class StatementInvalid < ActiveRecordError - end - - # Raised when number of bind variables in statement given to <tt>:condition</tt> key (for example, when using +find+ method) - # does not match number of expected variables. - # - # For example, in - # - # Location.find :all, :conditions => ["lat = ? AND lng = ?", 53.7362] - # - # two placeholders are given but only one variable to fill them. - class PreparedStatementInvalid < ActiveRecordError - end - - # Raised on attempt to save stale record. Record is stale when it's being saved in another query after - # instantiation, for example, when two users edit the same wiki page and one starts editing and saves - # the page before the other. - # - # Read more about optimistic locking in ActiveRecord::Locking module RDoc. - class StaleObjectError < ActiveRecordError - end - - # Raised when association is being configured improperly or - # user tries to use offset and limit together with has_many or has_and_belongs_to_many associations. - class ConfigurationError < ActiveRecordError - end - - # Raised on attempt to update record that is instantiated as read only. - class ReadOnlyRecord < ActiveRecordError - end - - # ActiveRecord::Transactions::ClassMethods.transaction uses this exception - # to distinguish a deliberate rollback from other exceptional situations. - # Normally, raising an exception will cause the +transaction+ method to rollback - # the database transaction *and* pass on the exception. But if you raise an - # ActiveRecord::Rollback exception, then the database transaction will be rolled back, - # without passing on the exception. - # - # For example, you could do this in your controller to rollback a transaction: - # - # class BooksController < ActionController::Base - # def create - # Book.transaction do - # book = Book.new(params[:book]) - # book.save! - # if today_is_friday? - # # The system must fail on Friday so that our support department - # # won't be out of job. We silently rollback this transaction - # # without telling the user. - # raise ActiveRecord::Rollback, "Call tech support!" - # end - # end - # # ActiveRecord::Rollback is the only exception that won't be passed on - # # by ActiveRecord::Base.transaction, so this line will still be reached - # # even on Friday. - # redirect_to root_url - # end - # end - class Rollback < ActiveRecordError - end - - # Raised when attribute has a name reserved by Active Record (when attribute has name of one of Active Record instance methods). - class DangerousAttributeError < ActiveRecordError - end - - # Raised when you've tried to access a column which wasn't loaded by your finder. - # Typically this is because <tt>:select</tt> has been specified. - class MissingAttributeError < NoMethodError - end - - # Raised when unknown attributes are supplied via mass assignment. - class UnknownAttributeError < NoMethodError - end - - # Raised when an error occurred while doing a mass assignment to an attribute through the - # <tt>attributes=</tt> method. The exception has an +attribute+ property that is the name of the - # offending attribute. - class AttributeAssignmentError < ActiveRecordError - attr_reader :exception, :attribute - def initialize(message, exception, attribute) - @exception = exception - @attribute = attribute - @message = message - end - end - - # Raised when there are multiple errors while doing a mass assignment through the +attributes+ - # method. The exception has an +errors+ property that contains an array of AttributeAssignmentError - # objects, each corresponding to the error while assigning to an attribute. - class MultiparameterAssignmentErrors < ActiveRecordError - attr_reader :errors - def initialize(errors) - @errors = errors - end - end - - # Active Record objects don't specify their attributes directly, but rather infer them from the table definition with - # which they're linked. Adding, removing, and changing attributes and their type is done directly in the database. Any change - # is instantly reflected in the Active Record objects. The mapping that binds a given Active Record class to a certain - # database table will happen automatically in most common cases, but can be overwritten for the uncommon ones. - # - # See the mapping rules in table_name and the full example in link:files/README.html for more insight. - # - # == Creation - # - # Active Records accept constructor parameters either in a hash or as a block. The hash method is especially useful when - # you're receiving the data from somewhere else, like an HTTP request. It works like this: - # - # user = User.new(:name => "David", :occupation => "Code Artist") - # user.name # => "David" - # - # You can also use block initialization: - # - # user = User.new do |u| - # u.name = "David" - # u.occupation = "Code Artist" - # end - # - # And of course you can just create a bare object and specify the attributes after the fact: - # - # user = User.new - # user.name = "David" - # user.occupation = "Code Artist" - # - # == Conditions - # - # Conditions can either be specified as a string, array, or hash representing the WHERE-part of an SQL statement. - # The array form is to be used when the condition input is tainted and requires sanitization. The string form can - # be used for statements that don't involve tainted data. The hash form works much like the array form, except - # only equality and range is possible. Examples: - # - # class User < ActiveRecord::Base - # def self.authenticate_unsafely(user_name, password) - # find(:first, :conditions => "user_name = '#{user_name}' AND password = '#{password}'") - # end - # - # def self.authenticate_safely(user_name, password) - # find(:first, :conditions => [ "user_name = ? AND password = ?", user_name, password ]) - # end - # - # def self.authenticate_safely_simply(user_name, password) - # find(:first, :conditions => { :user_name => user_name, :password => password }) - # end - # end - # - # The <tt>authenticate_unsafely</tt> method inserts the parameters directly into the query and is thus susceptible to SQL-injection - # attacks if the <tt>user_name</tt> and +password+ parameters come directly from an HTTP request. The <tt>authenticate_safely</tt> and - # <tt>authenticate_safely_simply</tt> both will sanitize the <tt>user_name</tt> and +password+ before inserting them in the query, - # which will ensure that an attacker can't escape the query and fake the login (or worse). - # - # When using multiple parameters in the conditions, it can easily become hard to read exactly what the fourth or fifth - # question mark is supposed to represent. In those cases, you can resort to named bind variables instead. That's done by replacing - # the question marks with symbols and supplying a hash with values for the matching symbol keys: - # - # Company.find(:first, :conditions => [ - # "id = :id AND name = :name AND division = :division AND created_at > :accounting_date", - # { :id => 3, :name => "37signals", :division => "First", :accounting_date => '2005-01-01' } - # ]) - # - # Similarly, a simple hash without a statement will generate conditions based on equality with the SQL AND - # operator. For instance: - # - # Student.find(:all, :conditions => { :first_name => "Harvey", :status => 1 }) - # Student.find(:all, :conditions => params[:student]) - # - # A range may be used in the hash to use the SQL BETWEEN operator: - # - # Student.find(:all, :conditions => { :grade => 9..12 }) - # - # An array may be used in the hash to use the SQL IN operator: - # - # Student.find(:all, :conditions => { :grade => [9,11,12] }) - # - # == Overwriting default accessors - # - # All column values are automatically available through basic accessors on the Active Record object, but sometimes you - # want to specialize this behavior. This can be done by overwriting the default accessors (using the same - # name as the attribute) and calling <tt>read_attribute(attr_name)</tt> and <tt>write_attribute(attr_name, value)</tt> to actually change things. - # Example: - # - # class Song < ActiveRecord::Base - # # Uses an integer of seconds to hold the length of the song - # - # def length=(minutes) - # write_attribute(:length, minutes.to_i * 60) - # end - # - # def length - # read_attribute(:length) / 60 - # end - # end - # - # You can alternatively use <tt>self[:attribute]=(value)</tt> and <tt>self[:attribute]</tt> instead of <tt>write_attribute(:attribute, value)</tt> and - # <tt>read_attribute(:attribute)</tt> as a shorter form. - # - # == Attribute query methods - # - # In addition to the basic accessors, query methods are also automatically available on the Active Record object. - # Query methods allow you to test whether an attribute value is present. - # - # For example, an Active Record User with the <tt>name</tt> attribute has a <tt>name?</tt> method that you can call - # to determine whether the user has a name: - # - # user = User.new(:name => "David") - # user.name? # => true - # - # anonymous = User.new(:name => "") - # anonymous.name? # => false - # - # == Accessing attributes before they have been typecasted - # - # Sometimes you want to be able to read the raw attribute data without having the column-determined typecast run its course first. - # That can be done by using the <tt><attribute>_before_type_cast</tt> accessors that all attributes have. For example, if your Account model - # has a <tt>balance</tt> attribute, you can call <tt>account.balance_before_type_cast</tt> or <tt>account.id_before_type_cast</tt>. - # - # This is especially useful in validation situations where the user might supply a string for an integer field and you want to display - # the original string back in an error message. Accessing the attribute normally would typecast the string to 0, which isn't what you - # want. - # - # == Dynamic attribute-based finders - # - # Dynamic attribute-based finders are a cleaner way of getting (and/or creating) objects by simple queries without turning to SQL. They work by - # appending the name of an attribute to <tt>find_by_</tt>, <tt>find_last_by_</tt>, or <tt>find_all_by_</tt>, so you get finders like <tt>Person.find_by_user_name</tt>, - # <tt>Person.find_all_by_last_name</tt>, and <tt>Payment.find_by_transaction_id</tt>. So instead of writing - # <tt>Person.find(:first, :conditions => ["user_name = ?", user_name])</tt>, you just do <tt>Person.find_by_user_name(user_name)</tt>. - # And instead of writing <tt>Person.find(:all, :conditions => ["last_name = ?", last_name])</tt>, you just do <tt>Person.find_all_by_last_name(last_name)</tt>. - # - # It's also possible to use multiple attributes in the same find by separating them with "_and_", so you get finders like - # <tt>Person.find_by_user_name_and_password</tt> or even <tt>Payment.find_by_purchaser_and_state_and_country</tt>. So instead of writing - # <tt>Person.find(:first, :conditions => ["user_name = ? AND password = ?", user_name, password])</tt>, you just do - # <tt>Person.find_by_user_name_and_password(user_name, password)</tt>. - # - # It's even possible to use all the additional parameters to find. For example, the full interface for <tt>Payment.find_all_by_amount</tt> - # is actually <tt>Payment.find_all_by_amount(amount, options)</tt>. And the full interface to <tt>Person.find_by_user_name</tt> is - # actually <tt>Person.find_by_user_name(user_name, options)</tt>. So you could call <tt>Payment.find_all_by_amount(50, :order => "created_on")</tt>. - # Also you may call <tt>Payment.find_last_by_amount(amount, options)</tt> returning the last record matching that amount and options. - # - # The same dynamic finder style can be used to create the object if it doesn't already exist. This dynamic finder is called with - # <tt>find_or_create_by_</tt> and will return the object if it already exists and otherwise creates it, then returns it. Protected attributes won't be set unless they are given in a block. For example: - # - # # No 'Summer' tag exists - # Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer") - # - # # Now the 'Summer' tag does exist - # Tag.find_or_create_by_name("Summer") # equal to Tag.find_by_name("Summer") - # - # # Now 'Bob' exist and is an 'admin' - # User.find_or_create_by_name('Bob', :age => 40) { |u| u.admin = true } - # - # Use the <tt>find_or_initialize_by_</tt> finder if you want to return a new record without saving it first. Protected attributes won't be set unless they are given in a block. For example: - # - # # No 'Winter' tag exists - # winter = Tag.find_or_initialize_by_name("Winter") - # winter.new_record? # true - # - # To find by a subset of the attributes to be used for instantiating a new object, pass a hash instead of - # a list of parameters. For example: - # - # Tag.find_or_create_by_name(:name => "rails", :creator => current_user) - # - # That will either find an existing tag named "rails", or create a new one while setting the user that created it. - # - # == Saving arrays, hashes, and other non-mappable objects in text columns - # - # Active Record can serialize any object in text columns using YAML. To do so, you must specify this with a call to the class method +serialize+. - # This makes it possible to store arrays, hashes, and other non-mappable objects without doing any additional work. Example: - # - # class User < ActiveRecord::Base - # serialize :preferences - # end - # - # user = User.create(:preferences => { "background" => "black", "display" => large }) - # User.find(user.id).preferences # => { "background" => "black", "display" => large } - # - # You can also specify a class option as the second parameter that'll raise an exception if a serialized object is retrieved as a - # descendant of a class not in the hierarchy. Example: - # - # class User < ActiveRecord::Base - # serialize :preferences, Hash - # end - # - # user = User.create(:preferences => %w( one two three )) - # User.find(user.id).preferences # raises SerializationTypeMismatch - # - # == Single table inheritance - # - # Active Record allows inheritance by storing the name of the class in a column that by default is named "type" (can be changed - # by overwriting <tt>Base.inheritance_column</tt>). This means that an inheritance looking like this: - # - # class Company < ActiveRecord::Base; end - # class Firm < Company; end - # class Client < Company; end - # class PriorityClient < Client; end - # - # When you do <tt>Firm.create(:name => "37signals")</tt>, this record will be saved in the companies table with type = "Firm". You can then - # fetch this row again using <tt>Company.find(:first, "name = '37signals'")</tt> and it will return a Firm object. - # - # If you don't have a type column defined in your table, single-table inheritance won't be triggered. In that case, it'll work just - # like normal subclasses with no special magic for differentiating between them or reloading the right type with find. - # - # Note, all the attributes for all the cases are kept in the same table. Read more: - # http://www.martinfowler.com/eaaCatalog/singleTableInheritance.html - # - # == Connection to multiple databases in different models - # - # Connections are usually created through ActiveRecord::Base.establish_connection and retrieved by ActiveRecord::Base.connection. - # All classes inheriting from ActiveRecord::Base will use this connection. But you can also set a class-specific connection. - # For example, if Course is an ActiveRecord::Base, but resides in a different database, you can just say <tt>Course.establish_connection</tt> - # and Course and all of its subclasses will use this connection instead. - # - # This feature is implemented by keeping a connection pool in ActiveRecord::Base that is a Hash indexed by the class. If a connection is - # requested, the retrieve_connection method will go up the class-hierarchy until a connection is found in the connection pool. - # - # == Exceptions - # - # * ActiveRecordError - Generic error class and superclass of all other errors raised by Active Record. - # * AdapterNotSpecified - The configuration hash used in <tt>establish_connection</tt> didn't include an - # <tt>:adapter</tt> key. - # * AdapterNotFound - The <tt>:adapter</tt> key used in <tt>establish_connection</tt> specified a non-existent adapter - # (or a bad spelling of an existing one). - # * AssociationTypeMismatch - The object assigned to the association wasn't of the type specified in the association definition. - # * SerializationTypeMismatch - The serialized object wasn't of the class specified as the second parameter. - # * ConnectionNotEstablished+ - No connection has been established. Use <tt>establish_connection</tt> before querying. - # * RecordNotFound - No record responded to the +find+ method. Either the row with the given ID doesn't exist - # or the row didn't meet the additional restrictions. Some +find+ calls do not raise this exception to signal - # nothing was found, please check its documentation for further details. - # * StatementInvalid - The database server rejected the SQL statement. The precise error is added in the message. - # * MultiparameterAssignmentErrors - Collection of errors that occurred during a mass assignment using the - # <tt>attributes=</tt> method. The +errors+ property of this exception contains an array of AttributeAssignmentError - # objects that should be inspected to determine which attributes triggered the errors. - # * AttributeAssignmentError - An error occurred while doing a mass assignment through the <tt>attributes=</tt> method. - # You can inspect the +attribute+ property of the exception object to determine which attribute triggered the error. - # - # *Note*: The attributes listed are class-level attributes (accessible from both the class and instance level). - # So it's possible to assign a logger to the class through <tt>Base.logger=</tt> which will then be used by all - # instances in the current object space. - class Base - ## - # :singleton-method: - # Accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then passed - # on to any new database connections made and which can be retrieved on both a class and instance level by calling +logger+. - cattr_accessor :logger, :instance_writer => false - - def self.inherited(child) #:nodoc: - @@subclasses[self] ||= [] - @@subclasses[self] << child - super - end - - def self.reset_subclasses #:nodoc: - nonreloadables = [] - subclasses.each do |klass| - unless ActiveSupport::Dependencies.autoloaded? klass - nonreloadables << klass - next - end - klass.instance_variables.each { |var| klass.send(:remove_instance_variable, var) } - klass.instance_methods(false).each { |m| klass.send :undef_method, m } - end - @@subclasses = {} - nonreloadables.each { |klass| (@@subclasses[klass.superclass] ||= []) << klass } - end - - @@subclasses = {} - - ## - # :singleton-method: - # Contains the database configuration - as is typically stored in config/database.yml - - # as a Hash. - # - # For example, the following database.yml... - # - # development: - # adapter: sqlite3 - # database: db/development.sqlite3 - # - # production: - # adapter: sqlite3 - # database: db/production.sqlite3 - # - # ...would result in ActiveRecord::Base.configurations to look like this: - # - # { - # 'development' => { - # 'adapter' => 'sqlite3', - # 'database' => 'db/development.sqlite3' - # }, - # 'production' => { - # 'adapter' => 'sqlite3', - # 'database' => 'db/production.sqlite3' - # } - # } - cattr_accessor :configurations, :instance_writer => false - @@configurations = {} - - ## - # :singleton-method: - # Accessor for the prefix type that will be prepended to every primary key column name. The options are :table_name and - # :table_name_with_underscore. If the first is specified, the Product class will look for "productid" instead of "id" as - # the primary column. If the latter is specified, the Product class will look for "product_id" instead of "id". Remember - # that this is a global setting for all Active Records. - cattr_accessor :primary_key_prefix_type, :instance_writer => false - @@primary_key_prefix_type = nil - - ## - # :singleton-method: - # Accessor for the name of the prefix string to prepend to every table name. So if set to "basecamp_", all - # table names will be named like "basecamp_projects", "basecamp_people", etc. This is a convenient way of creating a namespace - # for tables in a shared database. By default, the prefix is the empty string. - cattr_accessor :table_name_prefix, :instance_writer => false - @@table_name_prefix = "" - - ## - # :singleton-method: - # Works like +table_name_prefix+, but appends instead of prepends (set to "_basecamp" gives "projects_basecamp", - # "people_basecamp"). By default, the suffix is the empty string. - cattr_accessor :table_name_suffix, :instance_writer => false - @@table_name_suffix = "" - - ## - # :singleton-method: - # Indicates whether table names should be the pluralized versions of the corresponding class names. - # If true, the default table name for a Product class will be +products+. If false, it would just be +product+. - # See table_name for the full rules on table/class naming. This is true, by default. - cattr_accessor :pluralize_table_names, :instance_writer => false - @@pluralize_table_names = true - - ## - # :singleton-method: - # Determines whether to use ANSI codes to colorize the logging statements committed by the connection adapter. These colors - # make it much easier to overview things during debugging (when used through a reader like +tail+ and on a black background), but - # may complicate matters if you use software like syslog. This is true, by default. - cattr_accessor :colorize_logging, :instance_writer => false - @@colorize_logging = true - - ## - # :singleton-method: - # Determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates and times from the database. - # This is set to :local by default. - cattr_accessor :default_timezone, :instance_writer => false - @@default_timezone = :local - - ## - # :singleton-method: - # Specifies the format to use when dumping the database schema with Rails' - # Rakefile. If :sql, the schema is dumped as (potentially database- - # specific) SQL statements. If :ruby, the schema is dumped as an - # ActiveRecord::Schema file which can be loaded into any database that - # supports migrations. Use :ruby if you want to have different database - # adapters for, e.g., your development and test environments. - cattr_accessor :schema_format , :instance_writer => false - @@schema_format = :ruby - - ## - # :singleton-method: - # Specify whether or not to use timestamps for migration numbers - cattr_accessor :timestamped_migrations , :instance_writer => false - @@timestamped_migrations = true - - # Determine whether to store the full constant name including namespace when using STI - superclass_delegating_accessor :store_full_sti_class - self.store_full_sti_class = false - - # Stores the default scope for the class - class_inheritable_accessor :default_scoping, :instance_writer => false - self.default_scoping = [] - - class << self # Class methods - # Find operates with four different retrieval approaches: - # - # * Find by id - This can either be a specific id (1), a list of ids (1, 5, 6), or an array of ids ([5, 6, 10]). - # If no record can be found for all of the listed ids, then RecordNotFound will be raised. - # * Find first - This will return the first record matched by the options used. These options can either be specific - # conditions or merely an order. If no record can be matched, +nil+ is returned. Use - # <tt>Model.find(:first, *args)</tt> or its shortcut <tt>Model.first(*args)</tt>. - # * Find last - This will return the last record matched by the options used. These options can either be specific - # conditions or merely an order. If no record can be matched, +nil+ is returned. Use - # <tt>Model.find(:last, *args)</tt> or its shortcut <tt>Model.last(*args)</tt>. - # * Find all - This will return all the records matched by the options used. - # If no records are found, an empty array is returned. Use - # <tt>Model.find(:all, *args)</tt> or its shortcut <tt>Model.all(*args)</tt>. - # - # All approaches accept an options hash as their last parameter. - # - # ==== Parameters - # - # * <tt>:conditions</tt> - An SQL fragment like "administrator = 1", <tt>[ "user_name = ?", username ]</tt>, or <tt>["user_name = :user_name", { :user_name => user_name }]</tt>. See conditions in the intro. - # * <tt>:order</tt> - An SQL fragment like "created_at DESC, name". - # * <tt>:group</tt> - An attribute name by which the result should be grouped. Uses the <tt>GROUP BY</tt> SQL-clause. - # * <tt>:having</tt> - Combined with +:group+ this can be used to filter the records that a <tt>GROUP BY</tt> returns. Uses the <tt>HAVING</tt> SQL-clause. - # * <tt>:limit</tt> - An integer determining the limit on the number of rows that should be returned. - # * <tt>:offset</tt> - An integer determining the offset from where the rows should be fetched. So at 5, it would skip rows 0 through 4. - # * <tt>:joins</tt> - Either an SQL fragment for additional joins like "LEFT JOIN comments ON comments.post_id = id" (rarely needed), - # named associations in the same form used for the <tt>:include</tt> option, which will perform an <tt>INNER JOIN</tt> on the associated table(s), - # or an array containing a mixture of both strings and named associations. - # If the value is a string, then the records will be returned read-only since they will have attributes that do not correspond to the table's columns. - # Pass <tt>:readonly => false</tt> to override. - # * <tt>:include</tt> - Names associations that should be loaded alongside. The symbols named refer - # to already defined associations. See eager loading under Associations. - # * <tt>:select</tt> - By default, this is "*" as in "SELECT * FROM", but can be changed if you, for example, want to do a join but not - # include the joined columns. Takes a string with the SELECT SQL fragment (e.g. "id, name"). - # * <tt>:from</tt> - By default, this is the table name of the class, but can be changed to an alternate table name (or even the name - # of a database view). - # * <tt>:readonly</tt> - Mark the returned records read-only so they cannot be saved or updated. - # * <tt>:lock</tt> - An SQL fragment like "FOR UPDATE" or "LOCK IN SHARE MODE". - # <tt>:lock => true</tt> gives connection's default exclusive lock, usually "FOR UPDATE". - # - # ==== Examples - # - # # find by id - # Person.find(1) # returns the object for ID = 1 - # Person.find(1, 2, 6) # returns an array for objects with IDs in (1, 2, 6) - # Person.find([7, 17]) # returns an array for objects with IDs in (7, 17) - # Person.find([1]) # returns an array for the object with ID = 1 - # Person.find(1, :conditions => "administrator = 1", :order => "created_on DESC") - # - # Note that returned records may not be in the same order as the ids you - # provide since database rows are unordered. Give an explicit <tt>:order</tt> - # to ensure the results are sorted. - # - # ==== Examples - # - # # find first - # Person.find(:first) # returns the first object fetched by SELECT * FROM people - # Person.find(:first, :conditions => [ "user_name = ?", user_name]) - # Person.find(:first, :conditions => [ "user_name = :u", { :u => user_name }]) - # Person.find(:first, :order => "created_on DESC", :offset => 5) - # - # # find last - # Person.find(:last) # returns the last object fetched by SELECT * FROM people - # Person.find(:last, :conditions => [ "user_name = ?", user_name]) - # Person.find(:last, :order => "created_on DESC", :offset => 5) - # - # # find all - # Person.find(:all) # returns an array of objects for all the rows fetched by SELECT * FROM people - # Person.find(:all, :conditions => [ "category IN (?)", categories], :limit => 50) - # Person.find(:all, :conditions => { :friends => ["Bob", "Steve", "Fred"] } - # Person.find(:all, :offset => 10, :limit => 10) - # Person.find(:all, :include => [ :account, :friends ]) - # Person.find(:all, :group => "category") - # - # Example for find with a lock: Imagine two concurrent transactions: - # each will read <tt>person.visits == 2</tt>, add 1 to it, and save, resulting - # in two saves of <tt>person.visits = 3</tt>. By locking the row, the second - # transaction has to wait until the first is finished; we get the - # expected <tt>person.visits == 4</tt>. - # - # Person.transaction do - # person = Person.find(1, :lock => true) - # person.visits += 1 - # person.save! - # end - def find(*args) - options = args.extract_options! - validate_find_options(options) - set_readonly_option!(options) - - case args.first - when :first then find_initial(options) - when :last then find_last(options) - when :all then find_every(options) - else find_from_ids(args, options) - end - end - - # A convenience wrapper for <tt>find(:first, *args)</tt>. You can pass in all the - # same arguments to this method as you can to <tt>find(:first)</tt>. - def first(*args) - find(:first, *args) - end - - # A convenience wrapper for <tt>find(:last, *args)</tt>. You can pass in all the - # same arguments to this method as you can to <tt>find(:last)</tt>. - def last(*args) - find(:last, *args) - end - - # This is an alias for find(:all). You can pass in all the same arguments to this method as you can - # to find(:all) - def all(*args) - find(:all, *args) - end - - # Executes a custom SQL query against your database and returns all the results. The results will - # be returned as an array with columns requested encapsulated as attributes of the model you call - # this method from. If you call <tt>Product.find_by_sql</tt> then the results will be returned in - # a Product object with the attributes you specified in the SQL query. - # - # If you call a complicated SQL query which spans multiple tables the columns specified by the - # SELECT will be attributes of the model, whether or not they are columns of the corresponding - # table. - # - # The +sql+ parameter is a full SQL query as a string. It will be called as is, there will be - # no database agnostic conversions performed. This should be a last resort because using, for example, - # MySQL specific terms will lock you to using that particular database engine or require you to - # change your call if you switch engines. - # - # ==== Examples - # # A simple SQL query spanning multiple tables - # Post.find_by_sql "SELECT p.title, c.author FROM posts p, comments c WHERE p.id = c.post_id" - # > [#<Post:0x36bff9c @attributes={"title"=>"Ruby Meetup", "first_name"=>"Quentin"}>, ...] - # - # # You can use the same string replacement techniques as you can with ActiveRecord#find - # Post.find_by_sql ["SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date] - # > [#<Post:0x36bff9c @attributes={"first_name"=>"The Cheap Man Buys Twice"}>, ...] - def find_by_sql(sql) - connection.select_all(sanitize_sql(sql), "#{name} Load").collect! { |record| instantiate(record) } - end - - # Returns true if a record exists in the table that matches the +id+ or - # conditions given, or false otherwise. The argument can take five forms: - # - # * Integer - Finds the record with this primary key. - # * String - Finds the record with a primary key corresponding to this - # string (such as <tt>'5'</tt>). - # * Array - Finds the record that matches these +find+-style conditions - # (such as <tt>['color = ?', 'red']</tt>). - # * Hash - Finds the record that matches these +find+-style conditions - # (such as <tt>{:color => 'red'}</tt>). - # * No args - Returns false if the table is empty, true otherwise. - # - # For more information about specifying conditions as a Hash or Array, - # see the Conditions section in the introduction to ActiveRecord::Base. - # - # Note: You can't pass in a condition as a string (like <tt>name = - # 'Jamie'</tt>), since it would be sanitized and then queried against - # the primary key column, like <tt>id = 'name = \'Jamie\''</tt>. - # - # ==== Examples - # Person.exists?(5) - # Person.exists?('5') - # Person.exists?(:name => "David") - # Person.exists?(['name LIKE ?', "%#{query}%"]) - # Person.exists? - def exists?(id_or_conditions = {}) - connection.select_all( - construct_finder_sql( - :select => "#{quoted_table_name}.#{primary_key}", - :conditions => expand_id_conditions(id_or_conditions), - :limit => 1 - ), - "#{name} Exists" - ).size > 0 - end - - # Creates an object (or multiple objects) and saves it to the database, if validations pass. - # The resulting object is returned whether the object was saved successfully to the database or not. - # - # The +attributes+ parameter can be either be a Hash or an Array of Hashes. These Hashes describe the - # attributes on the objects that are to be created. - # - # ==== Examples - # # Create a single new object - # User.create(:first_name => 'Jamie') - # - # # Create an Array of new objects - # User.create([{ :first_name => 'Jamie' }, { :first_name => 'Jeremy' }]) - # - # # Create a single object and pass it into a block to set other attributes. - # User.create(:first_name => 'Jamie') do |u| - # u.is_admin = false - # end - # - # # Creating an Array of new objects using a block, where the block is executed for each object: - # User.create([{ :first_name => 'Jamie' }, { :first_name => 'Jeremy' }]) do |u| - # u.is_admin = false - # end - def create(attributes = nil, &block) - if attributes.is_a?(Array) - attributes.collect { |attr| create(attr, &block) } - else - object = new(attributes) - yield(object) if block_given? - object.save - object - end - end - - # Updates an object (or multiple objects) and saves it to the database, if validations pass. - # The resulting object is returned whether the object was saved successfully to the database or not. - # - # ==== Parameters - # - # * +id+ - This should be the id or an array of ids to be updated. - # * +attributes+ - This should be a Hash of attributes to be set on the object, or an array of Hashes. - # - # ==== Examples - # - # # Updating one record: - # Person.update(15, { :user_name => 'Samuel', :group => 'expert' }) - # - # # Updating multiple records: - # people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy" } } - # Person.update(people.keys, people.values) - def update(id, attributes) - if id.is_a?(Array) - idx = -1 - id.collect { |one_id| idx += 1; update(one_id, attributes[idx]) } - else - object = find(id) - object.update_attributes(attributes) - object - end - end - - # Deletes the row with a primary key matching the +id+ argument, using a - # SQL +DELETE+ statement, and returns the number of rows deleted. Active - # Record objects are not instantiated, so the object's callbacks are not - # executed, including any <tt>:dependent</tt> association options or - # Observer methods. - # - # You can delete multiple rows at once by passing an Array of <tt>id</tt>s. - # - # Note: Although it is often much faster than the alternative, - # <tt>#destroy</tt>, skipping callbacks might bypass business logic in - # your application that ensures referential integrity or performs other - # essential jobs. - # - # ==== Examples - # - # # Delete a single row - # Todo.delete(1) - # - # # Delete multiple rows - # Todo.delete([2,3,4]) - def delete(id) - delete_all([ "#{connection.quote_column_name(primary_key)} IN (?)", id ]) - end - - # Destroy an object (or multiple objects) that has the given id, the object is instantiated first, - # therefore all callbacks and filters are fired off before the object is deleted. This method is - # less efficient than ActiveRecord#delete but allows cleanup methods and other actions to be run. - # - # This essentially finds the object (or multiple objects) with the given id, creates a new object - # from the attributes, and then calls destroy on it. - # - # ==== Parameters - # - # * +id+ - Can be either an Integer or an Array of Integers. - # - # ==== Examples - # - # # Destroy a single object - # Todo.destroy(1) - # - # # Destroy multiple objects - # todos = [1,2,3] - # Todo.destroy(todos) - def destroy(id) - if id.is_a?(Array) - id.map { |one_id| destroy(one_id) } - else - find(id).destroy - end - end - - # Updates all records with details given if they match a set of conditions supplied, limits and order can - # also be supplied. This method constructs a single SQL UPDATE statement and sends it straight to the - # database. It does not instantiate the involved models and it does not trigger Active Record callbacks. - # - # ==== Parameters - # - # * +updates+ - A string of column and value pairs that will be set on any records that match conditions. This creates the SET clause of the generated SQL. - # * +conditions+ - An SQL fragment like "administrator = 1" or [ "user_name = ?", username ]. See conditions in the intro for more info. - # * +options+ - Additional options are <tt>:limit</tt> and <tt>:order</tt>, see the examples for usage. - # - # ==== Examples - # - # # Update all billing objects with the 3 different attributes given - # Billing.update_all( "category = 'authorized', approved = 1, author = 'David'" ) - # - # # Update records that match our conditions - # Billing.update_all( "author = 'David'", "title LIKE '%Rails%'" ) - # - # # Update records that match our conditions but limit it to 5 ordered by date - # Billing.update_all( "author = 'David'", "title LIKE '%Rails%'", - # :order => 'created_at', :limit => 5 ) - def update_all(updates, conditions = nil, options = {}) - sql = "UPDATE #{quoted_table_name} SET #{sanitize_sql_for_assignment(updates)} " - - scope = scope(:find) - - select_sql = "" - add_conditions!(select_sql, conditions, scope) - - if options.has_key?(:limit) || (scope && scope[:limit]) - # Only take order from scope if limit is also provided by scope, this - # is useful for updating a has_many association with a limit. - add_order!(select_sql, options[:order], scope) - - add_limit!(select_sql, options, scope) - sql.concat(connection.limited_update_conditions(select_sql, quoted_table_name, connection.quote_column_name(primary_key))) - else - add_order!(select_sql, options[:order], nil) - sql.concat(select_sql) - end - - connection.update(sql, "#{name} Update") - end - - # Destroys the records matching +conditions+ by instantiating each - # record and calling its +destroy+ method. Each object's callbacks are - # executed (including <tt>:dependent</tt> association options and - # +before_destroy+/+after_destroy+ Observer methods). Returns the - # collection of objects that were destroyed; each will be frozen, to - # reflect that no changes should be made (since they can't be - # persisted). - # - # Note: Instantiation, callback execution, and deletion of each - # record can be time consuming when you're removing many records at - # once. It generates at least one SQL +DELETE+ query per record (or - # possibly more, to enforce your callbacks). If you want to delete many - # rows quickly, without concern for their associations or callbacks, use - # +delete_all+ instead. - # - # ==== Parameters - # - # * +conditions+ - A string, array, or hash that specifies which records - # to destroy. If omitted, all records are destroyed. See the - # Conditions section in the introduction to ActiveRecord::Base for - # more information. - # - # ==== Examples - # - # Person.destroy_all("last_login < '2004-04-04'") - # Person.destroy_all(:status => "inactive") - def destroy_all(conditions = nil) - find(:all, :conditions => conditions).each { |object| object.destroy } - end - - # Deletes the records matching +conditions+ without instantiating the records first, and hence not - # calling the +destroy+ method nor invoking callbacks. This is a single SQL DELETE statement that - # goes straight to the database, much more efficient than +destroy_all+. Be careful with relations - # though, in particular <tt>:dependent</tt> rules defined on associations are not honored. Returns - # the number of rows affected. - # - # ==== Parameters - # - # * +conditions+ - Conditions are specified the same way as with +find+ method. - # - # ==== Example - # - # Post.delete_all("person_id = 5 AND (category = 'Something' OR category = 'Else')") - # Post.delete_all(["person_id = ? AND (category = ? OR category = ?)", 5, 'Something', 'Else']) - # - # Both calls delete the affected posts all at once with a single DELETE statement. If you need to destroy dependent - # associations or call your <tt>before_*</tt> or +after_destroy+ callbacks, use the +destroy_all+ method instead. - def delete_all(conditions = nil) - sql = "DELETE FROM #{quoted_table_name} " - add_conditions!(sql, conditions, scope(:find)) - connection.delete(sql, "#{name} Delete all") - end - - # Returns the result of an SQL statement that should only include a COUNT(*) in the SELECT part. - # The use of this method should be restricted to complicated SQL queries that can't be executed - # using the ActiveRecord::Calculations class methods. Look into those before using this. - # - # ==== Parameters - # - # * +sql+ - An SQL statement which should return a count query from the database, see the example below. - # - # ==== Examples - # - # Product.count_by_sql "SELECT COUNT(*) FROM sales s, customers c WHERE s.customer_id = c.id" - def count_by_sql(sql) - sql = sanitize_conditions(sql) - connection.select_value(sql, "#{name} Count").to_i - end - - # A generic "counter updater" implementation, intended primarily to be - # used by increment_counter and decrement_counter, but which may also - # be useful on its own. It simply does a direct SQL update for the record - # with the given ID, altering the given hash of counters by the amount - # given by the corresponding value: - # - # ==== Parameters - # - # * +id+ - The id of the object you wish to update a counter on or an Array of ids. - # * +counters+ - An Array of Hashes containing the names of the fields - # to update as keys and the amount to update the field by as values. - # - # ==== Examples - # - # # For the Post with id of 5, decrement the comment_count by 1, and - # # increment the action_count by 1 - # Post.update_counters 5, :comment_count => -1, :action_count => 1 - # # Executes the following SQL: - # # UPDATE posts - # # SET comment_count = comment_count - 1, - # # action_count = action_count + 1 - # # WHERE id = 5 - # - # # For the Posts with id of 10 and 15, increment the comment_count by 1 - # Post.update_counters [10, 15], :comment_count => 1 - # # Executes the following SQL: - # # UPDATE posts - # # SET comment_count = comment_count + 1, - # # WHERE id IN (10, 15) - def update_counters(id, counters) - updates = counters.inject([]) { |list, (counter_name, increment)| - sign = increment < 0 ? "-" : "+" - list << "#{connection.quote_column_name(counter_name)} = COALESCE(#{connection.quote_column_name(counter_name)}, 0) #{sign} #{increment.abs}" - }.join(", ") - - if id.is_a?(Array) - ids_list = id.map {|i| quote_value(i)}.join(', ') - condition = "IN (#{ids_list})" - else - condition = "= #{quote_value(id)}" - end - - update_all(updates, "#{connection.quote_column_name(primary_key)} #{condition}") - end - - # Increment a number field by one, usually representing a count. - # - # This is used for caching aggregate values, so that they don't need to be computed every time. - # For example, a DiscussionBoard may cache post_count and comment_count otherwise every time the board is - # shown it would have to run an SQL query to find how many posts and comments there are. - # - # ==== Parameters - # - # * +counter_name+ - The name of the field that should be incremented. - # * +id+ - The id of the object that should be incremented. - # - # ==== Examples - # - # # Increment the post_count column for the record with an id of 5 - # DiscussionBoard.increment_counter(:post_count, 5) - def increment_counter(counter_name, id) - update_counters(id, counter_name => 1) - end - - # Decrement a number field by one, usually representing a count. - # - # This works the same as increment_counter but reduces the column value by 1 instead of increasing it. - # - # ==== Parameters - # - # * +counter_name+ - The name of the field that should be decremented. - # * +id+ - The id of the object that should be decremented. - # - # ==== Examples - # - # # Decrement the post_count column for the record with an id of 5 - # DiscussionBoard.decrement_counter(:post_count, 5) - def decrement_counter(counter_name, id) - update_counters(id, counter_name => -1) - end - - # Attributes named in this macro are protected from mass-assignment, - # such as <tt>new(attributes)</tt>, - # <tt>update_attributes(attributes)</tt>, or - # <tt>attributes=(attributes)</tt>. - # - # Mass-assignment to these attributes will simply be ignored, to assign - # to them you can use direct writer methods. This is meant to protect - # sensitive attributes from being overwritten by malicious users - # tampering with URLs or forms. - # - # class Customer < ActiveRecord::Base - # attr_protected :credit_rating - # end - # - # customer = Customer.new("name" => David, "credit_rating" => "Excellent") - # customer.credit_rating # => nil - # customer.attributes = { "description" => "Jolly fellow", "credit_rating" => "Superb" } - # customer.credit_rating # => nil - # - # customer.credit_rating = "Average" - # customer.credit_rating # => "Average" - # - # To start from an all-closed default and enable attributes as needed, - # have a look at +attr_accessible+. - def attr_protected(*attributes) - write_inheritable_attribute(:attr_protected, Set.new(attributes.map(&:to_s)) + (protected_attributes || [])) - end - - # Returns an array of all the attributes that have been protected from mass-assignment. - def protected_attributes # :nodoc: - read_inheritable_attribute(:attr_protected) - end - - # Specifies a white list of model attributes that can be set via - # mass-assignment, such as <tt>new(attributes)</tt>, - # <tt>update_attributes(attributes)</tt>, or - # <tt>attributes=(attributes)</tt> - # - # This is the opposite of the +attr_protected+ macro: Mass-assignment - # will only set attributes in this list, to assign to the rest of - # attributes you can use direct writer methods. This is meant to protect - # sensitive attributes from being overwritten by malicious users - # tampering with URLs or forms. If you'd rather start from an all-open - # default and restrict attributes as needed, have a look at - # +attr_protected+. - # - # class Customer < ActiveRecord::Base - # attr_accessible :name, :nickname - # end - # - # customer = Customer.new(:name => "David", :nickname => "Dave", :credit_rating => "Excellent") - # customer.credit_rating # => nil - # customer.attributes = { :name => "Jolly fellow", :credit_rating => "Superb" } - # customer.credit_rating # => nil - # - # customer.credit_rating = "Average" - # customer.credit_rating # => "Average" - def attr_accessible(*attributes) - write_inheritable_attribute(:attr_accessible, Set.new(attributes.map(&:to_s)) + (accessible_attributes || [])) - end - - # Returns an array of all the attributes that have been made accessible to mass-assignment. - def accessible_attributes # :nodoc: - read_inheritable_attribute(:attr_accessible) - end - - # Attributes listed as readonly can be set for a new record, but will be ignored in database updates afterwards. - def attr_readonly(*attributes) - write_inheritable_attribute(:attr_readonly, Set.new(attributes.map(&:to_s)) + (readonly_attributes || [])) - end - - # Returns an array of all the attributes that have been specified as readonly. - def readonly_attributes - read_inheritable_attribute(:attr_readonly) - end - - # If you have an attribute that needs to be saved to the database as an object, and retrieved as the same object, - # then specify the name of that attribute using this method and it will be handled automatically. - # The serialization is done through YAML. If +class_name+ is specified, the serialized object must be of that - # class on retrieval or SerializationTypeMismatch will be raised. - # - # ==== Parameters - # - # * +attr_name+ - The field name that should be serialized. - # * +class_name+ - Optional, class name that the object type should be equal to. - # - # ==== Example - # # Serialize a preferences attribute - # class User - # serialize :preferences - # end - def serialize(attr_name, class_name = Object) - serialized_attributes[attr_name.to_s] = class_name - end - - # Returns a hash of all the attributes that have been specified for serialization as keys and their class restriction as values. - def serialized_attributes - read_inheritable_attribute(:attr_serialized) or write_inheritable_attribute(:attr_serialized, {}) - end - - # Guesses the table name (in forced lower-case) based on the name of the class in the inheritance hierarchy descending - # directly from ActiveRecord::Base. So if the hierarchy looks like: Reply < Message < ActiveRecord::Base, then Message is used - # to guess the table name even when called on Reply. The rules used to do the guess are handled by the Inflector class - # in Active Support, which knows almost all common English inflections. You can add new inflections in config/initializers/inflections.rb. - # - # Nested classes are given table names prefixed by the singular form of - # the parent's table name. Enclosing modules are not considered. - # - # ==== Examples - # - # class Invoice < ActiveRecord::Base; end; - # file class table_name - # invoice.rb Invoice invoices - # - # class Invoice < ActiveRecord::Base; class Lineitem < ActiveRecord::Base; end; end; - # file class table_name - # invoice.rb Invoice::Lineitem invoice_lineitems - # - # module Invoice; class Lineitem < ActiveRecord::Base; end; end; - # file class table_name - # invoice/lineitem.rb Invoice::Lineitem lineitems - # - # Additionally, the class-level +table_name_prefix+ is prepended and the - # +table_name_suffix+ is appended. So if you have "myapp_" as a prefix, - # the table name guess for an Invoice class becomes "myapp_invoices". - # Invoice::Lineitem becomes "myapp_invoice_lineitems". - # - # You can also overwrite this class method to allow for unguessable - # links, such as a Mouse class with a link to a "mice" table. Example: - # - # class Mouse < ActiveRecord::Base - # set_table_name "mice" - # end - def table_name - reset_table_name - end - - def reset_table_name #:nodoc: - base = base_class - - name = - # STI subclasses always use their superclass' table. - unless self == base - base.table_name - else - # Nested classes are prefixed with singular parent table name. - if parent < ActiveRecord::Base && !parent.abstract_class? - contained = parent.table_name - contained = contained.singularize if parent.pluralize_table_names - contained << '_' - end - name = "#{table_name_prefix}#{contained}#{undecorated_table_name(base.name)}#{table_name_suffix}" - end - - set_table_name(name) - name - end - - # Defines the primary key field -- can be overridden in subclasses. Overwriting will negate any effect of the - # primary_key_prefix_type setting, though. - def primary_key - reset_primary_key - end - - def reset_primary_key #:nodoc: - key = get_primary_key(base_class.name) - set_primary_key(key) - key - end - - def get_primary_key(base_name) #:nodoc: - key = 'id' - case primary_key_prefix_type - when :table_name - key = base_name.to_s.foreign_key(false) - when :table_name_with_underscore - key = base_name.to_s.foreign_key - end - key - end - - # Defines the column name for use with single table inheritance - # -- can be set in subclasses like so: self.inheritance_column = "type_id" - def inheritance_column - @inheritance_column ||= "type".freeze - end - - # Lazy-set the sequence name to the connection's default. This method - # is only ever called once since set_sequence_name overrides it. - def sequence_name #:nodoc: - reset_sequence_name - end - - def reset_sequence_name #:nodoc: - default = connection.default_sequence_name(table_name, primary_key) - set_sequence_name(default) - default - end - - # Sets the table name to use to the given value, or (if the value - # is nil or false) to the value returned by the given block. - # - # class Project < ActiveRecord::Base - # set_table_name "project" - # end - def set_table_name(value = nil, &block) - define_attr_method :table_name, value, &block - end - alias :table_name= :set_table_name - - # Sets the name of the primary key column to use to the given value, - # or (if the value is nil or false) to the value returned by the given - # block. - # - # class Project < ActiveRecord::Base - # set_primary_key "sysid" - # end - def set_primary_key(value = nil, &block) - define_attr_method :primary_key, value, &block - end - alias :primary_key= :set_primary_key - - # Sets the name of the inheritance column to use to the given value, - # or (if the value # is nil or false) to the value returned by the - # given block. - # - # class Project < ActiveRecord::Base - # set_inheritance_column do - # original_inheritance_column + "_id" - # end - # end - def set_inheritance_column(value = nil, &block) - define_attr_method :inheritance_column, value, &block - end - alias :inheritance_column= :set_inheritance_column - - # Sets the name of the sequence to use when generating ids to the given - # value, or (if the value is nil or false) to the value returned by the - # given block. This is required for Oracle and is useful for any - # database which relies on sequences for primary key generation. - # - # If a sequence name is not explicitly set when using Oracle or Firebird, - # it will default to the commonly used pattern of: #{table_name}_seq - # - # If a sequence name is not explicitly set when using PostgreSQL, it - # will discover the sequence corresponding to your primary key for you. - # - # class Project < ActiveRecord::Base - # set_sequence_name "projectseq" # default would have been "project_seq" - # end - def set_sequence_name(value = nil, &block) - define_attr_method :sequence_name, value, &block - end - alias :sequence_name= :set_sequence_name - - # Turns the +table_name+ back into a class name following the reverse rules of +table_name+. - def class_name(table_name = table_name) # :nodoc: - # remove any prefix and/or suffix from the table name - class_name = table_name[table_name_prefix.length..-(table_name_suffix.length + 1)].camelize - class_name = class_name.singularize if pluralize_table_names - class_name - end - - # Indicates whether the table associated with this class exists - def table_exists? - connection.table_exists?(table_name) - end - - # Returns an array of column objects for the table associated with this class. - def columns - unless defined?(@columns) && @columns - @columns = connection.columns(table_name, "#{name} Columns") - @columns.each { |column| column.primary = column.name == primary_key } - end - @columns - end - - # Returns a hash of column objects for the table associated with this class. - def columns_hash - @columns_hash ||= columns.inject({}) { |hash, column| hash[column.name] = column; hash } - end - - # Returns an array of column names as strings. - def column_names - @column_names ||= columns.map { |column| column.name } - end - - # Returns an array of column objects where the primary id, all columns ending in "_id" or "_count", - # and columns used for single table inheritance have been removed. - def content_columns - @content_columns ||= columns.reject { |c| c.primary || c.name =~ /(_id|_count)$/ || c.name == inheritance_column } - end - - # Returns a hash of all the methods added to query each of the columns in the table with the name of the method as the key - # and true as the value. This makes it possible to do O(1) lookups in respond_to? to check if a given method for attribute - # is available. - def column_methods_hash #:nodoc: - @dynamic_methods_hash ||= column_names.inject(Hash.new(false)) do |methods, attr| - attr_name = attr.to_s - methods[attr.to_sym] = attr_name - methods["#{attr}=".to_sym] = attr_name - methods["#{attr}?".to_sym] = attr_name - methods["#{attr}_before_type_cast".to_sym] = attr_name - methods - end - end - - # Resets all the cached information about columns, which will cause them - # to be reloaded on the next request. - # - # The most common usage pattern for this method is probably in a migration, - # when just after creating a table you want to populate it with some default - # values, eg: - # - # class CreateJobLevels < ActiveRecord::Migration - # def self.up - # create_table :job_levels do |t| - # t.integer :id - # t.string :name - # - # t.timestamps - # end - # - # JobLevel.reset_column_information - # %w{assistant executive manager director}.each do |type| - # JobLevel.create(:name => type) - # end - # end - # - # def self.down - # drop_table :job_levels - # end - # end - def reset_column_information - generated_methods.each { |name| undef_method(name) } - @column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @generated_methods = @inheritance_column = nil - end - - def reset_column_information_and_inheritable_attributes_for_all_subclasses#:nodoc: - subclasses.each { |klass| klass.reset_inheritable_attributes; klass.reset_column_information } - end - - def self_and_descendants_from_active_record#nodoc: - klass = self - classes = [klass] - while klass != klass.base_class - classes << klass = klass.superclass - end - classes - rescue - # OPTIMIZE this rescue is to fix this test: ./test/cases/reflection_test.rb:56:in `test_human_name_for_column' - # Appearantly the method base_class causes some trouble. - # It now works for sure. - [self] - end - - # Transforms attribute key names into a more humane format, such as "First name" instead of "first_name". Example: - # Person.human_attribute_name("first_name") # => "First name" - # This used to be depricated in favor of humanize, but is now preferred, because it automatically uses the I18n - # module now. - # Specify +options+ with additional translating options. - def human_attribute_name(attribute_key_name, options = {}) - defaults = self_and_descendants_from_active_record.map do |klass| - :"#{klass.name.underscore}.#{attribute_key_name}" - end - defaults << options[:default] if options[:default] - defaults.flatten! - defaults << attribute_key_name.humanize - options[:count] ||= 1 - I18n.translate(defaults.shift, options.merge(:default => defaults, :scope => [:activerecord, :attributes])) - end - - # Transform the modelname into a more humane format, using I18n. - # Defaults to the basic humanize method. - # Default scope of the translation is activerecord.models - # Specify +options+ with additional translating options. - def human_name(options = {}) - defaults = self_and_descendants_from_active_record.map do |klass| - :"#{klass.name.underscore}" - end - defaults << self.name.humanize - I18n.translate(defaults.shift, {:scope => [:activerecord, :models], :count => 1, :default => defaults}.merge(options)) - end - - # True if this isn't a concrete subclass needing a STI type condition. - def descends_from_active_record? - if superclass.abstract_class? - superclass.descends_from_active_record? - else - superclass == Base || !columns_hash.include?(inheritance_column) - end - end - - def finder_needs_type_condition? #:nodoc: - # This is like this because benchmarking justifies the strange :false stuff - :true == (@finder_needs_type_condition ||= descends_from_active_record? ? :false : :true) - end - - # Returns a string like 'Post id:integer, title:string, body:text' - def inspect - if self == Base - super - elsif abstract_class? - "#{super}(abstract)" - elsif table_exists? - attr_list = columns.map { |c| "#{c.name}: #{c.type}" } * ', ' - "#{super}(#{attr_list})" - else - "#{super}(Table doesn't exist)" - end - end - - def quote_value(value, column = nil) #:nodoc: - connection.quote(value,column) - end - - # Used to sanitize objects before they're used in an SQL SELECT statement. Delegates to <tt>connection.quote</tt>. - def sanitize(object) #:nodoc: - connection.quote(object) - end - - # Log and benchmark multiple statements in a single block. Example: - # - # Project.benchmark("Creating project") do - # project = Project.create("name" => "stuff") - # project.create_manager("name" => "David") - # project.milestones << Milestone.find(:all) - # end - # - # The benchmark is only recorded if the current level of the logger is less than or equal to the <tt>log_level</tt>, - # which makes it easy to include benchmarking statements in production software that will remain inexpensive because - # the benchmark will only be conducted if the log level is low enough. - # - # The logging of the multiple statements is turned off unless <tt>use_silence</tt> is set to false. - def benchmark(title, log_level = Logger::DEBUG, use_silence = true) - if logger && logger.level <= log_level - result = nil - ms = Benchmark.ms { result = use_silence ? silence { yield } : yield } - logger.add(log_level, '%s (%.1fms)' % [title, ms]) - result - else - yield - end - end - - # Silences the logger for the duration of the block. - def silence - old_logger_level, logger.level = logger.level, Logger::ERROR if logger - yield - ensure - logger.level = old_logger_level if logger - end - - # Overwrite the default class equality method to provide support for association proxies. - def ===(object) - object.is_a?(self) - end - - # Returns the base AR subclass that this class descends from. If A - # extends AR::Base, A.base_class will return A. If B descends from A - # through some arbitrarily deep hierarchy, B.base_class will return A. - def base_class - class_of_active_record_descendant(self) - end - - # Set this to true if this is an abstract class (see <tt>abstract_class?</tt>). - attr_accessor :abstract_class - - # Returns whether this class is a base AR class. If A is a base class and - # B descends from A, then B.base_class will return B. - def abstract_class? - defined?(@abstract_class) && @abstract_class == true - end - - def respond_to?(method_id, include_private = false) - if match = DynamicFinderMatch.match(method_id) - return true if all_attributes_exists?(match.attribute_names) - elsif match = DynamicScopeMatch.match(method_id) - return true if all_attributes_exists?(match.attribute_names) - end - - super - end - - def sti_name - store_full_sti_class ? name : name.demodulize - end - - # Merges conditions so that the result is a valid +condition+ - def merge_conditions(*conditions) - segments = [] - - conditions.each do |condition| - unless condition.blank? - sql = sanitize_sql(condition) - segments << sql unless sql.blank? - end - end - - "(#{segments.join(') AND (')})" unless segments.empty? - end - - private - def find_initial(options) - options.update(:limit => 1) - find_every(options).first - end - - def find_last(options) - order = options[:order] - - if order - order = reverse_sql_order(order) - elsif !scoped?(:find, :order) - order = "#{table_name}.#{primary_key} DESC" - end - - if scoped?(:find, :order) - scope = scope(:find) - original_scoped_order = scope[:order] - scope[:order] = reverse_sql_order(original_scoped_order) - end - - begin - find_initial(options.merge({ :order => order })) - ensure - scope[:order] = original_scoped_order if original_scoped_order - end - end - - def reverse_sql_order(order_query) - reversed_query = order_query.to_s.split(/,/).each { |s| - if s.match(/\s(asc|ASC)$/) - s.gsub!(/\s(asc|ASC)$/, ' DESC') - elsif s.match(/\s(desc|DESC)$/) - s.gsub!(/\s(desc|DESC)$/, ' ASC') - elsif !s.match(/\s(asc|ASC|desc|DESC)$/) - s.concat(' DESC') - end - }.join(',') - end - - def find_every(options) - include_associations = merge_includes(scope(:find, :include), options[:include]) - - if include_associations.any? && references_eager_loaded_tables?(options) - records = find_with_associations(options) - else - records = find_by_sql(construct_finder_sql(options)) - if include_associations.any? - preload_associations(records, include_associations) - end - end - - records.each { |record| record.readonly! } if options[:readonly] - - records - end - - def find_from_ids(ids, options) - expects_array = ids.first.kind_of?(Array) - return ids.first if expects_array && ids.first.empty? - - ids = ids.flatten.compact.uniq - - case ids.size - when 0 - raise RecordNotFound, "Couldn't find #{name} without an ID" - when 1 - result = find_one(ids.first, options) - expects_array ? [ result ] : result - else - find_some(ids, options) - end - end - - def find_one(id, options) - conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions] - options.update :conditions => "#{quoted_table_name}.#{connection.quote_column_name(primary_key)} = #{quote_value(id,columns_hash[primary_key])}#{conditions}" - - # Use find_every(options).first since the primary key condition - # already ensures we have a single record. Using find_initial adds - # a superfluous :limit => 1. - if result = find_every(options).first - result - else - raise RecordNotFound, "Couldn't find #{name} with ID=#{id}#{conditions}" - end - end - - def find_some(ids, options) - conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions] - ids_list = ids.map { |id| quote_value(id,columns_hash[primary_key]) }.join(',') - options.update :conditions => "#{quoted_table_name}.#{connection.quote_column_name(primary_key)} IN (#{ids_list})#{conditions}" - - result = find_every(options) - - # Determine expected size from limit and offset, not just ids.size. - expected_size = - if options[:limit] && ids.size > options[:limit] - options[:limit] - else - ids.size - end - - # 11 ids with limit 3, offset 9 should give 2 results. - if options[:offset] && (ids.size - options[:offset] < expected_size) - expected_size = ids.size - options[:offset] - end - - if result.size == expected_size - result - else - raise RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids_list})#{conditions} (found #{result.size} results, but was looking for #{expected_size})" - end - end - - # Finder methods must instantiate through this method to work with the - # single-table inheritance model that makes it possible to create - # objects of different types from the same table. - def instantiate(record) - object = - if subclass_name = record[inheritance_column] - # No type given. - if subclass_name.empty? - allocate - - else - # Ignore type if no column is present since it was probably - # pulled in from a sloppy join. - unless columns_hash.include?(inheritance_column) - allocate - - else - begin - compute_type(subclass_name).allocate - rescue NameError - raise SubclassNotFound, - "The single-table inheritance mechanism failed to locate the subclass: '#{record[inheritance_column]}'. " + - "This error is raised because the column '#{inheritance_column}' is reserved for storing the class in case of inheritance. " + - "Please rename this column if you didn't intend it to be used for storing the inheritance class " + - "or overwrite #{self.to_s}.inheritance_column to use another column for that information." - end - end - end - else - allocate - end - - object.instance_variable_set("@attributes", record) - object.instance_variable_set("@attributes_cache", Hash.new) - - if object.respond_to_without_attributes?(:after_find) - object.send(:callback, :after_find) - end - - if object.respond_to_without_attributes?(:after_initialize) - object.send(:callback, :after_initialize) - end - - object - end - - # Nest the type name in the same module as this class. - # Bar is "MyApp::Business::Bar" relative to MyApp::Business::Foo - def type_name_with_module(type_name) - if store_full_sti_class - type_name - else - (/^::/ =~ type_name) ? type_name : "#{parent.name}::#{type_name}" - end - end - - def default_select(qualified) - if qualified - quoted_table_name + '.*' - else - '*' - end - end - - def construct_finder_sql(options) - scope = scope(:find) - sql = "SELECT #{options[:select] || (scope && scope[:select]) || default_select(options[:joins] || (scope && scope[:joins]))} " - sql << "FROM #{options[:from] || (scope && scope[:from]) || quoted_table_name} " - - add_joins!(sql, options[:joins], scope) - add_conditions!(sql, options[:conditions], scope) - - add_group!(sql, options[:group], options[:having], scope) - add_order!(sql, options[:order], scope) - add_limit!(sql, options, scope) - add_lock!(sql, options, scope) - - sql - end - - # Merges includes so that the result is a valid +include+ - def merge_includes(first, second) - (safe_to_array(first) + safe_to_array(second)).uniq - end - - def merge_joins(*joins) - if joins.any?{|j| j.is_a?(String) || array_of_strings?(j) } - joins = joins.collect do |join| - join = [join] if join.is_a?(String) - unless array_of_strings?(join) - join_dependency = ActiveRecord::Associations::ClassMethods::InnerJoinDependency.new(self, join, nil) - join = join_dependency.join_associations.collect { |assoc| assoc.association_join } - end - join - end - joins.flatten.map{|j| j.strip}.uniq - else - joins.collect{|j| safe_to_array(j)}.flatten.uniq - end - end - - # Object#to_a is deprecated, though it does have the desired behavior - def safe_to_array(o) - case o - when NilClass - [] - when Array - o - else - [o] - end - end - - def array_of_strings?(o) - o.is_a?(Array) && o.all?{|obj| obj.is_a?(String)} - end - - def add_order!(sql, order, scope = :auto) - scope = scope(:find) if :auto == scope - scoped_order = scope[:order] if scope - if order - sql << " ORDER BY #{order}" - if scoped_order && scoped_order != order - sql << ", #{scoped_order}" - end - else - sql << " ORDER BY #{scoped_order}" if scoped_order - end - end - - def add_group!(sql, group, having, scope = :auto) - if group - sql << " GROUP BY #{group}" - sql << " HAVING #{sanitize_sql_for_conditions(having)}" if having - else - scope = scope(:find) if :auto == scope - if scope && (scoped_group = scope[:group]) - sql << " GROUP BY #{scoped_group}" - sql << " HAVING #{sanitize_sql_for_conditions(scope[:having])}" if scope[:having] - end - end - end - - # The optional scope argument is for the current <tt>:find</tt> scope. - def add_limit!(sql, options, scope = :auto) - scope = scope(:find) if :auto == scope - - if scope - options[:limit] ||= scope[:limit] - options[:offset] ||= scope[:offset] - end - - connection.add_limit_offset!(sql, options) - end - - # The optional scope argument is for the current <tt>:find</tt> scope. - # The <tt>:lock</tt> option has precedence over a scoped <tt>:lock</tt>. - def add_lock!(sql, options, scope = :auto) - scope = scope(:find) if :auto == scope - options = options.reverse_merge(:lock => scope[:lock]) if scope - connection.add_lock!(sql, options) - end - - # The optional scope argument is for the current <tt>:find</tt> scope. - def add_joins!(sql, joins, scope = :auto) - scope = scope(:find) if :auto == scope - merged_joins = scope && scope[:joins] && joins ? merge_joins(scope[:joins], joins) : (joins || scope && scope[:joins]) - case merged_joins - when Symbol, Hash, Array - if array_of_strings?(merged_joins) - sql << merged_joins.join(' ') + " " - else - join_dependency = ActiveRecord::Associations::ClassMethods::InnerJoinDependency.new(self, merged_joins, nil) - sql << " #{join_dependency.join_associations.collect { |assoc| assoc.association_join }.join} " - end - when String - sql << " #{merged_joins} " - end - end - - # Adds a sanitized version of +conditions+ to the +sql+ string. Note that the passed-in +sql+ string is changed. - # The optional scope argument is for the current <tt>:find</tt> scope. - def add_conditions!(sql, conditions, scope = :auto) - scope = scope(:find) if :auto == scope - conditions = [conditions] - conditions << scope[:conditions] if scope - conditions << type_condition if finder_needs_type_condition? - merged_conditions = merge_conditions(*conditions) - sql << "WHERE #{merged_conditions} " unless merged_conditions.blank? - end - - def type_condition(table_alias=nil) - quoted_table_alias = self.connection.quote_table_name(table_alias || table_name) - quoted_inheritance_column = connection.quote_column_name(inheritance_column) - type_condition = subclasses.inject("#{quoted_table_alias}.#{quoted_inheritance_column} = '#{sti_name}' ") do |condition, subclass| - condition << "OR #{quoted_table_alias}.#{quoted_inheritance_column} = '#{subclass.sti_name}' " - end - - " (#{type_condition}) " - end - - # Guesses the table name, but does not decorate it with prefix and suffix information. - def undecorated_table_name(class_name = base_class.name) - table_name = class_name.to_s.demodulize.underscore - table_name = table_name.pluralize if pluralize_table_names - table_name - end - - # Enables dynamic finders like <tt>find_by_user_name(user_name)</tt> and <tt>find_by_user_name_and_password(user_name, password)</tt> - # that are turned into <tt>find(:first, :conditions => ["user_name = ?", user_name])</tt> and - # <tt>find(:first, :conditions => ["user_name = ? AND password = ?", user_name, password])</tt> respectively. Also works for - # <tt>find(:all)</tt> by using <tt>find_all_by_amount(50)</tt> that is turned into <tt>find(:all, :conditions => ["amount = ?", 50])</tt>. - # - # It's even possible to use all the additional parameters to +find+. For example, the full interface for +find_all_by_amount+ - # is actually <tt>find_all_by_amount(amount, options)</tt>. - # - # Also enables dynamic scopes like scoped_by_user_name(user_name) and scoped_by_user_name_and_password(user_name, password) that - # are turned into scoped(:conditions => ["user_name = ?", user_name]) and scoped(:conditions => ["user_name = ? AND password = ?", user_name, password]) - # respectively. - # - # Each dynamic finder, scope or initializer/creator is also defined in the class after it is first invoked, so that future - # attempts to use it do not run through method_missing. - def method_missing(method_id, *arguments, &block) - if match = DynamicFinderMatch.match(method_id) - attribute_names = match.attribute_names - super unless all_attributes_exists?(attribute_names) - if match.finder? - finder = match.finder - bang = match.bang? - # def self.find_by_login_and_activated(*args) - # options = args.extract_options! - # attributes = construct_attributes_from_arguments( - # [:login,:activated], - # args - # ) - # finder_options = { :conditions => attributes } - # validate_find_options(options) - # set_readonly_option!(options) - # - # if options[:conditions] - # with_scope(:find => finder_options) do - # find(:first, options) - # end - # else - # find(:first, options.merge(finder_options)) - # end - # end - self.class_eval %{ - def self.#{method_id}(*args) - options = args.extract_options! - attributes = construct_attributes_from_arguments( - [:#{attribute_names.join(',:')}], - args - ) - finder_options = { :conditions => attributes } - validate_find_options(options) - set_readonly_option!(options) - - #{'result = ' if bang}if options[:conditions] - with_scope(:find => finder_options) do - find(:#{finder}, options) - end - else - find(:#{finder}, options.merge(finder_options)) - end - #{'result || raise(RecordNotFound, "Couldn\'t find #{name} with #{attributes.to_a.collect {|pair| "#{pair.first} = #{pair.second}"}.join(\', \')}")' if bang} - end - }, __FILE__, __LINE__ - send(method_id, *arguments) - elsif match.instantiator? - instantiator = match.instantiator - # def self.find_or_create_by_user_id(*args) - # guard_protected_attributes = false - # - # if args[0].is_a?(Hash) - # guard_protected_attributes = true - # attributes = args[0].with_indifferent_access - # find_attributes = attributes.slice(*[:user_id]) - # else - # find_attributes = attributes = construct_attributes_from_arguments([:user_id], args) - # end - # - # options = { :conditions => find_attributes } - # set_readonly_option!(options) - # - # record = find(:first, options) - # - # if record.nil? - # record = self.new { |r| r.send(:attributes=, attributes, guard_protected_attributes) } - # yield(record) if block_given? - # record.save - # record - # else - # record - # end - # end - self.class_eval %{ - def self.#{method_id}(*args) - guard_protected_attributes = false - - if args[0].is_a?(Hash) - guard_protected_attributes = true - attributes = args[0].with_indifferent_access - find_attributes = attributes.slice(*[:#{attribute_names.join(',:')}]) - else - find_attributes = attributes = construct_attributes_from_arguments([:#{attribute_names.join(',:')}], args) - end - - options = { :conditions => find_attributes } - set_readonly_option!(options) - - record = find(:first, options) - - if record.nil? - record = self.new { |r| r.send(:attributes=, attributes, guard_protected_attributes) } - #{'yield(record) if block_given?'} - #{'record.save' if instantiator == :create} - record - else - record - end - end - }, __FILE__, __LINE__ - send(method_id, *arguments, &block) - end - elsif match = DynamicScopeMatch.match(method_id) - attribute_names = match.attribute_names - super unless all_attributes_exists?(attribute_names) - if match.scope? - self.class_eval %{ - def self.#{method_id}(*args) # def self.scoped_by_user_name_and_password(*args) - options = args.extract_options! # options = args.extract_options! - attributes = construct_attributes_from_arguments( # attributes = construct_attributes_from_arguments( - [:#{attribute_names.join(',:')}], args # [:user_name, :password], args - ) # ) - # - scoped(:conditions => attributes) # scoped(:conditions => attributes) - end # end - }, __FILE__, __LINE__ - send(method_id, *arguments) - end - else - super - end - end - - def construct_attributes_from_arguments(attribute_names, arguments) - attributes = {} - attribute_names.each_with_index { |name, idx| attributes[name] = arguments[idx] } - attributes - end - - # Similar in purpose to +expand_hash_conditions_for_aggregates+. - def expand_attribute_names_for_aggregates(attribute_names) - expanded_attribute_names = [] - attribute_names.each do |attribute_name| - unless (aggregation = reflect_on_aggregation(attribute_name.to_sym)).nil? - aggregate_mapping(aggregation).each do |field_attr, aggregate_attr| - expanded_attribute_names << field_attr - end - else - expanded_attribute_names << attribute_name - end - end - expanded_attribute_names - end - - def all_attributes_exists?(attribute_names) - attribute_names = expand_attribute_names_for_aggregates(attribute_names) - attribute_names.all? { |name| column_methods_hash.include?(name.to_sym) } - end - - def attribute_condition(quoted_column_name, argument) - case argument - when nil then "#{quoted_column_name} IS ?" - when Array, ActiveRecord::Associations::AssociationCollection, ActiveRecord::NamedScope::Scope then "#{quoted_column_name} IN (?)" - when Range then if argument.exclude_end? - "#{quoted_column_name} >= ? AND #{quoted_column_name} < ?" - else - "#{quoted_column_name} BETWEEN ? AND ?" - end - else "#{quoted_column_name} = ?" - end - end - - # Interpret Array and Hash as conditions and anything else as an id. - def expand_id_conditions(id_or_conditions) - case id_or_conditions - when Array, Hash then id_or_conditions - else sanitize_sql(primary_key => id_or_conditions) - end - end - - # Defines an "attribute" method (like +inheritance_column+ or - # +table_name+). A new (class) method will be created with the - # given name. If a value is specified, the new method will - # return that value (as a string). Otherwise, the given block - # will be used to compute the value of the method. - # - # The original method will be aliased, with the new name being - # prefixed with "original_". This allows the new method to - # access the original value. - # - # Example: - # - # class A < ActiveRecord::Base - # define_attr_method :primary_key, "sysid" - # define_attr_method( :inheritance_column ) do - # original_inheritance_column + "_id" - # end - # end - def define_attr_method(name, value=nil, &block) - sing = class << self; self; end - sing.send :alias_method, "original_#{name}", name - if block_given? - sing.send :define_method, name, &block - else - # use eval instead of a block to work around a memory leak in dev - # mode in fcgi - sing.class_eval "def #{name}; #{value.to_s.inspect}; end" - end - end - - protected - # Scope parameters to method calls within the block. Takes a hash of method_name => parameters hash. - # method_name may be <tt>:find</tt> or <tt>:create</tt>. <tt>:find</tt> parameters may include the <tt>:conditions</tt>, <tt>:joins</tt>, - # <tt>:include</tt>, <tt>:offset</tt>, <tt>:limit</tt>, and <tt>:readonly</tt> options. <tt>:create</tt> parameters are an attributes hash. - # - # class Article < ActiveRecord::Base - # def self.create_with_scope - # with_scope(:find => { :conditions => "blog_id = 1" }, :create => { :blog_id => 1 }) do - # find(1) # => SELECT * from articles WHERE blog_id = 1 AND id = 1 - # a = create(1) - # a.blog_id # => 1 - # end - # end - # end - # - # In nested scopings, all previous parameters are overwritten by the innermost rule, with the exception of - # <tt>:conditions</tt>, <tt>:include</tt>, and <tt>:joins</tt> options in <tt>:find</tt>, which are merged. - # - # <tt>:joins</tt> options are uniqued so multiple scopes can join in the same table without table aliasing - # problems. If you need to join multiple tables, but still want one of the tables to be uniqued, use the - # array of strings format for your joins. - # - # class Article < ActiveRecord::Base - # def self.find_with_scope - # with_scope(:find => { :conditions => "blog_id = 1", :limit => 1 }, :create => { :blog_id => 1 }) do - # with_scope(:find => { :limit => 10 }) - # find(:all) # => SELECT * from articles WHERE blog_id = 1 LIMIT 10 - # end - # with_scope(:find => { :conditions => "author_id = 3" }) - # find(:all) # => SELECT * from articles WHERE blog_id = 1 AND author_id = 3 LIMIT 1 - # end - # end - # end - # end - # - # You can ignore any previous scopings by using the <tt>with_exclusive_scope</tt> method. - # - # class Article < ActiveRecord::Base - # def self.find_with_exclusive_scope - # with_scope(:find => { :conditions => "blog_id = 1", :limit => 1 }) do - # with_exclusive_scope(:find => { :limit => 10 }) - # find(:all) # => SELECT * from articles LIMIT 10 - # end - # end - # end - # end - # - # *Note*: the +:find+ scope also has effect on update and deletion methods, - # like +update_all+ and +delete_all+. - def with_scope(method_scoping = {}, action = :merge, &block) - method_scoping = method_scoping.method_scoping if method_scoping.respond_to?(:method_scoping) - - # Dup first and second level of hash (method and params). - method_scoping = method_scoping.inject({}) do |hash, (method, params)| - hash[method] = (params == true) ? params : params.dup - hash - end - - method_scoping.assert_valid_keys([ :find, :create ]) - - if f = method_scoping[:find] - f.assert_valid_keys(VALID_FIND_OPTIONS) - set_readonly_option! f - end - - # Merge scopings - if [:merge, :reverse_merge].include?(action) && current_scoped_methods - method_scoping = current_scoped_methods.inject(method_scoping) do |hash, (method, params)| - case hash[method] - when Hash - if method == :find - (hash[method].keys + params.keys).uniq.each do |key| - merge = hash[method][key] && params[key] # merge if both scopes have the same key - if key == :conditions && merge - if params[key].is_a?(Hash) && hash[method][key].is_a?(Hash) - hash[method][key] = merge_conditions(hash[method][key].deep_merge(params[key])) - else - hash[method][key] = merge_conditions(params[key], hash[method][key]) - end - elsif key == :include && merge - hash[method][key] = merge_includes(hash[method][key], params[key]).uniq - elsif key == :joins && merge - hash[method][key] = merge_joins(params[key], hash[method][key]) - else - hash[method][key] = hash[method][key] || params[key] - end - end - else - if action == :reverse_merge - hash[method] = hash[method].merge(params) - else - hash[method] = params.merge(hash[method]) - end - end - else - hash[method] = params - end - hash - end - end - - self.scoped_methods << method_scoping - begin - yield - ensure - self.scoped_methods.pop - end - end - - # Works like with_scope, but discards any nested properties. - def with_exclusive_scope(method_scoping = {}, &block) - with_scope(method_scoping, :overwrite, &block) - end - - def subclasses #:nodoc: - @@subclasses[self] ||= [] - @@subclasses[self] + extra = @@subclasses[self].inject([]) {|list, subclass| list + subclass.subclasses } - end - - # Sets the default options for the model. The format of the - # <tt>options</tt> argument is the same as in find. - # - # class Person < ActiveRecord::Base - # default_scope :order => 'last_name, first_name' - # end - def default_scope(options = {}) - self.default_scoping << { :find => options, :create => (options.is_a?(Hash) && options.has_key?(:conditions)) ? options[:conditions] : {} } - end - - # Test whether the given method and optional key are scoped. - def scoped?(method, key = nil) #:nodoc: - if current_scoped_methods && (scope = current_scoped_methods[method]) - !key || !scope[key].nil? - end - end - - # Retrieve the scope for the given method and optional key. - def scope(method, key = nil) #:nodoc: - if current_scoped_methods && (scope = current_scoped_methods[method]) - key ? scope[key] : scope - end - end - - def scoped_methods #:nodoc: - Thread.current[:"#{self}_scoped_methods"] ||= self.default_scoping.dup - end - - def current_scoped_methods #:nodoc: - scoped_methods.last - end - - # Returns the class type of the record using the current module as a prefix. So descendants of - # MyApp::Business::Account would appear as MyApp::Business::AccountSubclass. - def compute_type(type_name) - modularized_name = type_name_with_module(type_name) - silence_warnings do - begin - class_eval(modularized_name, __FILE__, __LINE__) - rescue NameError - class_eval(type_name, __FILE__, __LINE__) - end - end - end - - # Returns the class descending directly from ActiveRecord::Base or an - # abstract class, if any, in the inheritance hierarchy. - def class_of_active_record_descendant(klass) - if klass.superclass == Base || klass.superclass.abstract_class? - klass - elsif klass.superclass.nil? - raise ActiveRecordError, "#{name} doesn't belong in a hierarchy descending from ActiveRecord" - else - class_of_active_record_descendant(klass.superclass) - end - end - - # Returns the name of the class descending directly from Active Record in the inheritance hierarchy. - def class_name_of_active_record_descendant(klass) #:nodoc: - klass.base_class.name - end - - # Accepts an array, hash, or string of SQL conditions and sanitizes - # them into a valid SQL fragment for a WHERE clause. - # ["name='%s' and group_id='%s'", "foo'bar", 4] returns "name='foo''bar' and group_id='4'" - # { :name => "foo'bar", :group_id => 4 } returns "name='foo''bar' and group_id='4'" - # "name='foo''bar' and group_id='4'" returns "name='foo''bar' and group_id='4'" - def sanitize_sql_for_conditions(condition) - return nil if condition.blank? - - case condition - when Array; sanitize_sql_array(condition) - when Hash; sanitize_sql_hash_for_conditions(condition) - else condition - end - end - alias_method :sanitize_sql, :sanitize_sql_for_conditions - - # Accepts an array, hash, or string of SQL conditions and sanitizes - # them into a valid SQL fragment for a SET clause. - # { :name => nil, :group_id => 4 } returns "name = NULL , group_id='4'" - def sanitize_sql_for_assignment(assignments) - case assignments - when Array; sanitize_sql_array(assignments) - when Hash; sanitize_sql_hash_for_assignment(assignments) - else assignments - end - end - - def aggregate_mapping(reflection) - mapping = reflection.options[:mapping] || [reflection.name, reflection.name] - mapping.first.is_a?(Array) ? mapping : [mapping] - end - - # Accepts a hash of SQL conditions and replaces those attributes - # that correspond to a +composed_of+ relationship with their expanded - # aggregate attribute values. - # Given: - # class Person < ActiveRecord::Base - # composed_of :address, :class_name => "Address", - # :mapping => [%w(address_street street), %w(address_city city)] - # end - # Then: - # { :address => Address.new("813 abc st.", "chicago") } - # # => { :address_street => "813 abc st.", :address_city => "chicago" } - def expand_hash_conditions_for_aggregates(attrs) - expanded_attrs = {} - attrs.each do |attr, value| - unless (aggregation = reflect_on_aggregation(attr.to_sym)).nil? - mapping = aggregate_mapping(aggregation) - mapping.each do |field_attr, aggregate_attr| - if mapping.size == 1 && !value.respond_to?(aggregate_attr) - expanded_attrs[field_attr] = value - else - expanded_attrs[field_attr] = value.send(aggregate_attr) - end - end - else - expanded_attrs[attr] = value - end - end - expanded_attrs - end - - # Sanitizes a hash of attribute/value pairs into SQL conditions for a WHERE clause. - # { :name => "foo'bar", :group_id => 4 } - # # => "name='foo''bar' and group_id= 4" - # { :status => nil, :group_id => [1,2,3] } - # # => "status IS NULL and group_id IN (1,2,3)" - # { :age => 13..18 } - # # => "age BETWEEN 13 AND 18" - # { 'other_records.id' => 7 } - # # => "`other_records`.`id` = 7" - # { :other_records => { :id => 7 } } - # # => "`other_records`.`id` = 7" - # And for value objects on a composed_of relationship: - # { :address => Address.new("123 abc st.", "chicago") } - # # => "address_street='123 abc st.' and address_city='chicago'" - def sanitize_sql_hash_for_conditions(attrs, table_name = quoted_table_name) - attrs = expand_hash_conditions_for_aggregates(attrs) - - conditions = attrs.map do |attr, value| - unless value.is_a?(Hash) - attr = attr.to_s - - # Extract table name from qualified attribute names. - if attr.include?('.') - table_name, attr = attr.split('.', 2) - table_name = connection.quote_table_name(table_name) - end - - attribute_condition("#{table_name}.#{connection.quote_column_name(attr)}", value) - else - sanitize_sql_hash_for_conditions(value, connection.quote_table_name(attr.to_s)) - end - end.join(' AND ') - - replace_bind_variables(conditions, expand_range_bind_variables(attrs.values)) - end - alias_method :sanitize_sql_hash, :sanitize_sql_hash_for_conditions - - # Sanitizes a hash of attribute/value pairs into SQL conditions for a SET clause. - # { :status => nil, :group_id => 1 } - # # => "status = NULL , group_id = 1" - def sanitize_sql_hash_for_assignment(attrs) - attrs.map do |attr, value| - "#{connection.quote_column_name(attr)} = #{quote_bound_value(value)}" - end.join(', ') - end - - # Accepts an array of conditions. The array has each value - # sanitized and interpolated into the SQL statement. - # ["name='%s' and group_id='%s'", "foo'bar", 4] returns "name='foo''bar' and group_id='4'" - def sanitize_sql_array(ary) - statement, *values = ary - if values.first.is_a?(Hash) and statement =~ /:\w+/ - replace_named_bind_variables(statement, values.first) - elsif statement.include?('?') - replace_bind_variables(statement, values) - else - statement % values.collect { |value| connection.quote_string(value.to_s) } - end - end - - alias_method :sanitize_conditions, :sanitize_sql - - def replace_bind_variables(statement, values) #:nodoc: - raise_if_bind_arity_mismatch(statement, statement.count('?'), values.size) - bound = values.dup - statement.gsub('?') { quote_bound_value(bound.shift) } - end - - def replace_named_bind_variables(statement, bind_vars) #:nodoc: - statement.gsub(/(:?):([a-zA-Z]\w*)/) do - if $1 == ':' # skip postgresql casts - $& # return the whole match - elsif bind_vars.include?(match = $2.to_sym) - quote_bound_value(bind_vars[match]) - else - raise PreparedStatementInvalid, "missing value for :#{match} in #{statement}" - end - end - end - - def expand_range_bind_variables(bind_vars) #:nodoc: - expanded = [] - - bind_vars.each do |var| - next if var.is_a?(Hash) - - if var.is_a?(Range) - expanded << var.first - expanded << var.last - else - expanded << var - end - end - - expanded - end - - def quote_bound_value(value) #:nodoc: - if value.respond_to?(:map) && !value.acts_like?(:string) - if value.respond_to?(:empty?) && value.empty? - connection.quote(nil) - else - value.map { |v| connection.quote(v) }.join(',') - end - else - connection.quote(value) - end - end - - def raise_if_bind_arity_mismatch(statement, expected, provided) #:nodoc: - unless expected == provided - raise PreparedStatementInvalid, "wrong number of bind variables (#{provided} for #{expected}) in: #{statement}" - end - end - - VALID_FIND_OPTIONS = [ :conditions, :include, :joins, :limit, :offset, - :order, :select, :readonly, :group, :having, :from, :lock ] - - def validate_find_options(options) #:nodoc: - options.assert_valid_keys(VALID_FIND_OPTIONS) - end - - def set_readonly_option!(options) #:nodoc: - # Inherit :readonly from finder scope if set. Otherwise, - # if :joins is not blank then :readonly defaults to true. - unless options.has_key?(:readonly) - if scoped_readonly = scope(:find, :readonly) - options[:readonly] = scoped_readonly - elsif !options[:joins].blank? && !options[:select] - options[:readonly] = true - end - end - end - - def encode_quoted_value(value) #:nodoc: - quoted_value = connection.quote(value) - quoted_value = "'#{quoted_value[1..-2].gsub(/\'/, "\\\\'")}'" if quoted_value.include?("\\\'") # (for ruby mode) " - quoted_value - end - end - - public - # New objects can be instantiated as either empty (pass no construction parameter) or pre-set with - # attributes but not yet saved (pass a hash with key names matching the associated table column names). - # In both instances, valid attribute keys are determined by the column names of the associated table -- - # hence you can't have attributes that aren't part of the table columns. - def initialize(attributes = nil) - @attributes = attributes_from_column_definition - @attributes_cache = {} - @new_record = true - ensure_proper_type - self.attributes = attributes unless attributes.nil? - self.class.send(:scope, :create).each { |att,value| self.send("#{att}=", value) } if self.class.send(:scoped?, :create) - result = yield self if block_given? - callback(:after_initialize) if respond_to_without_attributes?(:after_initialize) - result - end - - # A model instance's primary key is always available as model.id - # whether you name it the default 'id' or set it to something else. - def id - attr_name = self.class.primary_key - column = column_for_attribute(attr_name) - - self.class.send(:define_read_method, :id, attr_name, column) - # now that the method exists, call it - self.send attr_name.to_sym - - end - - # Returns a String, which Action Pack uses for constructing an URL to this - # object. The default implementation returns this record's id as a String, - # or nil if this record's unsaved. - # - # For example, suppose that you have a User model, and that you have a - # <tt>map.resources :users</tt> route. Normally, +user_path+ will - # construct a path with the user object's 'id' in it: - # - # user = User.find_by_name('Phusion') - # user_path(user) # => "/users/1" - # - # You can override +to_param+ in your model to make +user_path+ construct - # a path using the user's name instead of the user's id: - # - # class User < ActiveRecord::Base - # def to_param # overridden - # name - # end - # end - # - # user = User.find_by_name('Phusion') - # user_path(user) # => "/users/Phusion" - def to_param - # We can't use alias_method here, because method 'id' optimizes itself on the fly. - (id = self.id) ? id.to_s : nil # Be sure to stringify the id for routes - end - - # Returns a cache key that can be used to identify this record. - # - # ==== Examples - # - # Product.new.cache_key # => "products/new" - # Product.find(5).cache_key # => "products/5" (updated_at not available) - # Person.find(5).cache_key # => "people/5-20071224150000" (updated_at available) - def cache_key - case - when new_record? - "#{self.class.model_name.cache_key}/new" - when timestamp = self[:updated_at] - "#{self.class.model_name.cache_key}/#{id}-#{timestamp.to_s(:number)}" - else - "#{self.class.model_name.cache_key}/#{id}" - end - end - - def id_before_type_cast #:nodoc: - read_attribute_before_type_cast(self.class.primary_key) - end - - def quoted_id #:nodoc: - quote_value(id, column_for_attribute(self.class.primary_key)) - end - - # Sets the primary ID. - def id=(value) - write_attribute(self.class.primary_key, value) - end - - # Returns true if this object hasn't been saved yet -- that is, a record for the object doesn't exist yet; otherwise, returns false. - def new_record? - @new_record || false - end - - # :call-seq: - # save(perform_validation = true) - # - # Saves the model. - # - # If the model is new a record gets created in the database, otherwise - # the existing record gets updated. - # - # If +perform_validation+ is true validations run. If any of them fail - # the action is cancelled and +save+ returns +false+. If the flag is - # false validations are bypassed altogether. See - # ActiveRecord::Validations for more information. - # - # There's a series of callbacks associated with +save+. If any of the - # <tt>before_*</tt> callbacks return +false+ the action is cancelled and - # +save+ returns +false+. See ActiveRecord::Callbacks for further - # details. - def save - create_or_update - end - - # Saves the model. - # - # If the model is new a record gets created in the database, otherwise - # the existing record gets updated. - # - # With <tt>save!</tt> validations always run. If any of them fail - # ActiveRecord::RecordInvalid gets raised. See ActiveRecord::Validations - # for more information. - # - # There's a series of callbacks associated with <tt>save!</tt>. If any of - # the <tt>before_*</tt> callbacks return +false+ the action is cancelled - # and <tt>save!</tt> raises ActiveRecord::RecordNotSaved. See - # ActiveRecord::Callbacks for further details. - def save! - create_or_update || raise(RecordNotSaved) - end - - # Deletes the record in the database and freezes this instance to - # reflect that no changes should be made (since they can't be - # persisted). Returns the frozen instance. - # - # The row is simply removed with a SQL +DELETE+ statement on the - # record's primary key, and no callbacks are executed. - # - # To enforce the object's +before_destroy+ and +after_destroy+ - # callbacks, Observer methods, or any <tt>:dependent</tt> association - # options, use <tt>#destroy</tt>. - def delete - self.class.delete(id) unless new_record? - freeze - end - - # Deletes the record in the database and freezes this instance to reflect that no changes should - # be made (since they can't be persisted). - def destroy - unless new_record? - connection.delete( - "DELETE FROM #{self.class.quoted_table_name} " + - "WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quoted_id}", - "#{self.class.name} Destroy" - ) - end - - freeze - end - - # Returns a clone of the record that hasn't been assigned an id yet and - # is treated as a new record. Note that this is a "shallow" clone: - # it copies the object's attributes only, not its associations. - # The extent of a "deep" clone is application-specific and is therefore - # left to the application to implement according to its need. - def clone - attrs = clone_attributes(:read_attribute_before_type_cast) - attrs.delete(self.class.primary_key) - record = self.class.new - record.send :instance_variable_set, '@attributes', attrs - record - end - - # Returns an instance of the specified +klass+ with the attributes of the current record. This is mostly useful in relation to - # single-table inheritance structures where you want a subclass to appear as the superclass. This can be used along with record - # identification in Action Pack to allow, say, <tt>Client < Company</tt> to do something like render <tt>:partial => @client.becomes(Company)</tt> - # to render that instance using the companies/company partial instead of clients/client. - # - # Note: The new instance will share a link to the same attributes as the original class. So any change to the attributes in either - # instance will affect the other. - def becomes(klass) - returning klass.new do |became| - became.instance_variable_set("@attributes", @attributes) - became.instance_variable_set("@attributes_cache", @attributes_cache) - became.instance_variable_set("@new_record", new_record?) - end - end - - # Updates a single attribute and saves the record without going through the normal validation procedure. - # This is especially useful for boolean flags on existing records. The regular +update_attribute+ method - # in Base is replaced with this when the validations module is mixed in, which it is by default. - def update_attribute(name, value) - send(name.to_s + '=', value) - save(false) - end - - # Updates all the attributes from the passed-in Hash and saves the record. If the object is invalid, the saving will - # fail and false will be returned. - def update_attributes(attributes) - self.attributes = attributes - save - end - - # Updates an object just like Base.update_attributes but calls save! instead of save so an exception is raised if the record is invalid. - def update_attributes!(attributes) - self.attributes = attributes - save! - end - - # Initializes +attribute+ to zero if +nil+ and adds the value passed as +by+ (default is 1). - # The increment is performed directly on the underlying attribute, no setter is invoked. - # Only makes sense for number-based attributes. Returns +self+. - def increment(attribute, by = 1) - self[attribute] ||= 0 - self[attribute] += by - self - end - - # Wrapper around +increment+ that saves the record. This method differs from - # its non-bang version in that it passes through the attribute setter. - # Saving is not subjected to validation checks. Returns +true+ if the - # record could be saved. - def increment!(attribute, by = 1) - increment(attribute, by).update_attribute(attribute, self[attribute]) - end - - # Initializes +attribute+ to zero if +nil+ and subtracts the value passed as +by+ (default is 1). - # The decrement is performed directly on the underlying attribute, no setter is invoked. - # Only makes sense for number-based attributes. Returns +self+. - def decrement(attribute, by = 1) - self[attribute] ||= 0 - self[attribute] -= by - self - end - - # Wrapper around +decrement+ that saves the record. This method differs from - # its non-bang version in that it passes through the attribute setter. - # Saving is not subjected to validation checks. Returns +true+ if the - # record could be saved. - def decrement!(attribute, by = 1) - decrement(attribute, by).update_attribute(attribute, self[attribute]) - end - - # Assigns to +attribute+ the boolean opposite of <tt>attribute?</tt>. So - # if the predicate returns +true+ the attribute will become +false+. This - # method toggles directly the underlying value without calling any setter. - # Returns +self+. - def toggle(attribute) - self[attribute] = !send("#{attribute}?") - self - end - - # Wrapper around +toggle+ that saves the record. This method differs from - # its non-bang version in that it passes through the attribute setter. - # Saving is not subjected to validation checks. Returns +true+ if the - # record could be saved. - def toggle!(attribute) - toggle(attribute).update_attribute(attribute, self[attribute]) - end - - # Reloads the attributes of this object from the database. - # The optional options argument is passed to find when reloading so you - # may do e.g. record.reload(:lock => true) to reload the same record with - # an exclusive row lock. - def reload(options = nil) - clear_aggregation_cache - clear_association_cache - @attributes.update(self.class.find(self.id, options).instance_variable_get('@attributes')) - @attributes_cache = {} - self - end - - # Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example, - # "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)). - # (Alias for the protected read_attribute method). - def [](attr_name) - read_attribute(attr_name) - end - - # Updates the attribute identified by <tt>attr_name</tt> with the specified +value+. - # (Alias for the protected write_attribute method). - def []=(attr_name, value) - write_attribute(attr_name, value) - end - - # Allows you to set all the attributes at once by passing in a hash with keys - # matching the attribute names (which again matches the column names). - # - # If +guard_protected_attributes+ is true (the default), then sensitive - # attributes can be protected from this form of mass-assignment by using - # the +attr_protected+ macro. Or you can alternatively specify which - # attributes *can* be accessed with the +attr_accessible+ macro. Then all the - # attributes not included in that won't be allowed to be mass-assigned. - # - # class User < ActiveRecord::Base - # attr_protected :is_admin - # end - # - # user = User.new - # user.attributes = { :username => 'Phusion', :is_admin => true } - # user.username # => "Phusion" - # user.is_admin? # => false - # - # user.send(:attributes=, { :username => 'Phusion', :is_admin => true }, false) - # user.is_admin? # => true - def attributes=(new_attributes, guard_protected_attributes = true) - return if new_attributes.nil? - attributes = new_attributes.dup - attributes.stringify_keys! - - multi_parameter_attributes = [] - attributes = remove_attributes_protected_from_mass_assignment(attributes) if guard_protected_attributes - - attributes.each do |k, v| - if k.include?("(") - multi_parameter_attributes << [ k, v ] - else - respond_to?(:"#{k}=") ? send(:"#{k}=", v) : raise(UnknownAttributeError, "unknown attribute: #{k}") - end - end - - assign_multiparameter_attributes(multi_parameter_attributes) - end - - # Returns a hash of all the attributes with their names as keys and the values of the attributes as values. - def attributes - self.attribute_names.inject({}) do |attrs, name| - attrs[name] = read_attribute(name) - attrs - end - end - - # Returns a hash of attributes before typecasting and deserialization. - def attributes_before_type_cast - self.attribute_names.inject({}) do |attrs, name| - attrs[name] = read_attribute_before_type_cast(name) - attrs - end - end - - # Returns an <tt>#inspect</tt>-like string for the value of the - # attribute +attr_name+. String attributes are elided after 50 - # characters, and Date and Time attributes are returned in the - # <tt>:db</tt> format. Other attributes return the value of - # <tt>#inspect</tt> without modification. - # - # person = Person.create!(:name => "David Heinemeier Hansson " * 3) - # - # person.attribute_for_inspect(:name) - # # => '"David Heinemeier Hansson David Heinemeier Hansson D..."' - # - # person.attribute_for_inspect(:created_at) - # # => '"2009-01-12 04:48:57"' - def attribute_for_inspect(attr_name) - value = read_attribute(attr_name) - - if value.is_a?(String) && value.length > 50 - "#{value[0..50]}...".inspect - elsif value.is_a?(Date) || value.is_a?(Time) - %("#{value.to_s(:db)}") - else - value.inspect - end - end - - # Returns true if the specified +attribute+ has been set by the user or by a database load and is neither - # nil nor empty? (the latter only applies to objects that respond to empty?, most notably Strings). - def attribute_present?(attribute) - value = read_attribute(attribute) - !value.blank? - end - - # Returns true if the given attribute is in the attributes hash - def has_attribute?(attr_name) - @attributes.has_key?(attr_name.to_s) - end - - # Returns an array of names for the attributes available on this object sorted alphabetically. - def attribute_names - @attributes.keys.sort - end - - # Returns the column object for the named attribute. - def column_for_attribute(name) - self.class.columns_hash[name.to_s] - end - - # Returns true if the +comparison_object+ is the same object, or is of the same type and has the same id. - def ==(comparison_object) - comparison_object.equal?(self) || - (comparison_object.instance_of?(self.class) && - comparison_object.id == id && - !comparison_object.new_record?) - end - - # Delegates to == - def eql?(comparison_object) - self == (comparison_object) - end - - # Delegates to id in order to allow two records of the same type and id to work with something like: - # [ Person.find(1), Person.find(2), Person.find(3) ] & [ Person.find(1), Person.find(4) ] # => [ Person.find(1) ] - def hash - id.hash - end - - # Freeze the attributes hash such that associations are still accessible, even on destroyed records. - def freeze - @attributes.freeze; self - end - - # Returns +true+ if the attributes hash has been frozen. - def frozen? - @attributes.frozen? - end - - # Returns +true+ if the record is read only. Records loaded through joins with piggy-back - # attributes will be marked as read only since they cannot be saved. - def readonly? - defined?(@readonly) && @readonly == true - end - - # Marks this record as read only. - def readonly! - @readonly = true - end - - # Returns the contents of the record as a nicely formatted string. - def inspect - attributes_as_nice_string = self.class.column_names.collect { |name| - if has_attribute?(name) || new_record? - "#{name}: #{attribute_for_inspect(name)}" - end - }.compact.join(", ") - "#<#{self.class} #{attributes_as_nice_string}>" - end - - private - def create_or_update - raise ReadOnlyRecord if readonly? - result = new_record? ? create : update - result != false - end - - # Updates the associated record with values matching those of the instance attributes. - # Returns the number of affected rows. - def update(attribute_names = @attributes.keys) - quoted_attributes = attributes_with_quotes(false, false, attribute_names) - return 0 if quoted_attributes.empty? - connection.update( - "UPDATE #{self.class.quoted_table_name} " + - "SET #{quoted_comma_pair_list(connection, quoted_attributes)} " + - "WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quote_value(id)}", - "#{self.class.name} Update" - ) - end - - # Creates a record with values matching those of the instance attributes - # and returns its id. - def create - if self.id.nil? && connection.prefetch_primary_key?(self.class.table_name) - self.id = connection.next_sequence_value(self.class.sequence_name) - end - - quoted_attributes = attributes_with_quotes - - statement = if quoted_attributes.empty? - connection.empty_insert_statement(self.class.table_name) - else - "INSERT INTO #{self.class.quoted_table_name} " + - "(#{quoted_column_names.join(', ')}) " + - "VALUES(#{quoted_attributes.values.join(', ')})" - end - - self.id = connection.insert(statement, "#{self.class.name} Create", - self.class.primary_key, self.id, self.class.sequence_name) - - @new_record = false - id - end - - # Sets the attribute used for single table inheritance to this class name if this is not the ActiveRecord::Base descendant. - # Considering the hierarchy Reply < Message < ActiveRecord::Base, this makes it possible to do Reply.new without having to - # set <tt>Reply[Reply.inheritance_column] = "Reply"</tt> yourself. No such attribute would be set for objects of the - # Message class in that example. - def ensure_proper_type - unless self.class.descends_from_active_record? - write_attribute(self.class.inheritance_column, self.class.sti_name) - end - end - - def convert_number_column_value(value) - if value == false - 0 - elsif value == true - 1 - elsif value.is_a?(String) && value.blank? - nil - else - value - end - end - - def remove_attributes_protected_from_mass_assignment(attributes) - safe_attributes = - if self.class.accessible_attributes.nil? && self.class.protected_attributes.nil? - attributes.reject { |key, value| attributes_protected_by_default.include?(key.gsub(/\(.+/, "")) } - elsif self.class.protected_attributes.nil? - attributes.reject { |key, value| !self.class.accessible_attributes.include?(key.gsub(/\(.+/, "")) || attributes_protected_by_default.include?(key.gsub(/\(.+/, "")) } - elsif self.class.accessible_attributes.nil? - attributes.reject { |key, value| self.class.protected_attributes.include?(key.gsub(/\(.+/,"")) || attributes_protected_by_default.include?(key.gsub(/\(.+/, "")) } - else - raise "Declare either attr_protected or attr_accessible for #{self.class}, but not both." - end - - removed_attributes = attributes.keys - safe_attributes.keys - - if removed_attributes.any? - log_protected_attribute_removal(removed_attributes) - end - - safe_attributes - end - - # Removes attributes which have been marked as readonly. - def remove_readonly_attributes(attributes) - unless self.class.readonly_attributes.nil? - attributes.delete_if { |key, value| self.class.readonly_attributes.include?(key.gsub(/\(.+/,"")) } - else - attributes - end - end - - def log_protected_attribute_removal(*attributes) - logger.debug "WARNING: Can't mass-assign these protected attributes: #{attributes.join(', ')}" - end - - # The primary key and inheritance column can never be set by mass-assignment for security reasons. - def attributes_protected_by_default - default = [ self.class.primary_key, self.class.inheritance_column ] - default << 'id' unless self.class.primary_key.eql? 'id' - default - end - - # Returns a copy of the attributes hash where all the values have been safely quoted for use in - # an SQL statement. - def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys) - quoted = {} - connection = self.class.connection - attribute_names.each do |name| - if (column = column_for_attribute(name)) && (include_primary_key || !column.primary) - value = read_attribute(name) - - # We need explicit to_yaml because quote() does not properly convert Time/Date fields to YAML. - if value && self.class.serialized_attributes.has_key?(name) && (value.acts_like?(:date) || value.acts_like?(:time)) - value = value.to_yaml - end - - quoted[name] = connection.quote(value, column) - end - end - include_readonly_attributes ? quoted : remove_readonly_attributes(quoted) - end - - # Quote strings appropriately for SQL statements. - def quote_value(value, column = nil) - self.class.connection.quote(value, column) - end - - # Interpolate custom SQL string in instance context. - # Optional record argument is meant for custom insert_sql. - def interpolate_sql(sql, record = nil) - instance_eval("%@#{sql.gsub('@', '\@')}@") - end - - # Initializes the attributes array with keys matching the columns from the linked table and - # the values matching the corresponding default value of that column, so - # that a new instance, or one populated from a passed-in Hash, still has all the attributes - # that instances loaded from the database would. - def attributes_from_column_definition - self.class.columns.inject({}) do |attributes, column| - attributes[column.name] = column.default unless column.name == self.class.primary_key - attributes - end - end - - # Instantiates objects for all attribute classes that needs more than one constructor parameter. This is done - # by calling new on the column type or aggregation type (through composed_of) object with these parameters. - # So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate - # written_on (a date type) with Date.new("2004", "6", "24"). You can also specify a typecast character in the - # parentheses to have the parameters typecasted before they're used in the constructor. Use i for Fixnum, f for Float, - # s for String, and a for Array. If all the values for a given attribute are empty, the attribute will be set to nil. - def assign_multiparameter_attributes(pairs) - execute_callstack_for_multiparameter_attributes( - extract_callstack_for_multiparameter_attributes(pairs) - ) - end - - def instantiate_time_object(name, values) - if self.class.send(:create_time_zone_conversion_attribute?, name, column_for_attribute(name)) - Time.zone.local(*values) - else - Time.time_with_datetime_fallback(@@default_timezone, *values) - end - end - - def execute_callstack_for_multiparameter_attributes(callstack) - errors = [] - callstack.each do |name, values| - klass = (self.class.reflect_on_aggregation(name.to_sym) || column_for_attribute(name)).klass - if values.empty? - send(name + "=", nil) - else - begin - value = if Time == klass - instantiate_time_object(name, values) - elsif Date == klass - begin - Date.new(*values) - rescue ArgumentError => ex # if Date.new raises an exception on an invalid date - instantiate_time_object(name, values).to_date # we instantiate Time object and convert it back to a date thus using Time's logic in handling invalid dates - end - else - klass.new(*values) - end - - send(name + "=", value) - rescue => ex - errors << AttributeAssignmentError.new("error on assignment #{values.inspect} to #{name}", ex, name) - end - end - end - unless errors.empty? - raise MultiparameterAssignmentErrors.new(errors), "#{errors.size} error(s) on assignment of multiparameter attributes" - end - end - - def extract_callstack_for_multiparameter_attributes(pairs) - attributes = { } - - for pair in pairs - multiparameter_name, value = pair - attribute_name = multiparameter_name.split("(").first - attributes[attribute_name] = [] unless attributes.include?(attribute_name) - - unless value.empty? - attributes[attribute_name] << - [ find_parameter_position(multiparameter_name), type_cast_attribute_value(multiparameter_name, value) ] - end - end - - attributes.each { |name, values| attributes[name] = values.sort_by{ |v| v.first }.collect { |v| v.last } } - end - - def type_cast_attribute_value(multiparameter_name, value) - multiparameter_name =~ /\([0-9]*([a-z])\)/ ? value.send("to_" + $1) : value - end - - def find_parameter_position(multiparameter_name) - multiparameter_name.scan(/\(([0-9]*).*\)/).first.first - end - - # Returns a comma-separated pair list, like "key1 = val1, key2 = val2". - def comma_pair_list(hash) - hash.inject([]) { |list, pair| list << "#{pair.first} = #{pair.last}" }.join(", ") - end - - def quoted_column_names(attributes = attributes_with_quotes) - connection = self.class.connection - attributes.keys.collect do |column_name| - connection.quote_column_name(column_name) - end - end - - def self.quoted_table_name - self.connection.quote_table_name(self.table_name) - end - - def quote_columns(quoter, hash) - hash.inject({}) do |quoted, (name, value)| - quoted[quoter.quote_column_name(name)] = value - quoted - end - end - - def quoted_comma_pair_list(quoter, hash) - comma_pair_list(quote_columns(quoter, hash)) - end - - def object_from_yaml(string) - return string unless string.is_a?(String) && string =~ /^---/ - YAML::load(string) rescue string - end - - def clone_attributes(reader_method = :read_attribute, attributes = {}) - self.attribute_names.inject(attributes) do |attrs, name| - attrs[name] = clone_attribute_value(reader_method, name) - attrs - end - end - - def clone_attribute_value(reader_method, attribute_name) - value = send(reader_method, attribute_name) - value.duplicable? ? value.clone : value - rescue TypeError, NoMethodError - value - end - end - - Base.class_eval do - extend QueryCache::ClassMethods - include Validations - include Locking::Optimistic, Locking::Pessimistic - include AttributeMethods - include Dirty - include Callbacks, Observing, Timestamp - include Associations, AssociationPreload, NamedScope - - # AutosaveAssociation needs to be included before Transactions, because we want - # #save_with_autosave_associations to be wrapped inside a transaction. - include AutosaveAssociation, NestedAttributes - - include Aggregations, Transactions, Reflection, Batches, Calculations, Serialization - end -end - -# TODO: Remove this and make it work with LAZY flag -require 'active_record/connection_adapters/abstract_adapter' diff --git a/vendor/rails/activerecord/lib/active_record/batches.rb b/vendor/rails/activerecord/lib/active_record/batches.rb deleted file mode 100644 index 03bd4f9..0000000 --- a/vendor/rails/activerecord/lib/active_record/batches.rb +++ /dev/null @@ -1,73 +0,0 @@ -module ActiveRecord - module Batches # :nodoc: - def self.included(base) - base.extend(ClassMethods) - end - - # When processing large numbers of records, it's often a good idea to do so in batches to prevent memory ballooning. - module ClassMethods - # Yields each record that was found by the find +options+. The find is performed by find_in_batches - # with a batch size of 1000 (or as specified by the +batch_size+ option). - # - # Example: - # - # Person.find_each(:conditions => "age > 21") do |person| - # person.party_all_night! - # end - # - # Note: This method is only intended to use for batch processing of large amounts of records that wouldn't fit in - # memory all at once. If you just need to loop over less than 1000 records, it's probably better just to use the - # regular find methods. - def find_each(options = {}) - find_in_batches(options) do |records| - records.each { |record| yield record } - end - - self - end - - # Yields each batch of records that was found by the find +options+ as an array. The size of each batch is - # set by the +batch_size+ option; the default is 1000. - # - # You can control the starting point for the batch processing by supplying the +start+ option. This is especially - # useful if you want multiple workers dealing with the same processing queue. You can make worker 1 handle all the - # records between id 0 and 10,000 and worker 2 handle from 10,000 and beyond (by setting the +start+ option on that - # worker). - # - # It's not possible to set the order. That is automatically set to ascending on the primary key ("id ASC") - # to make the batch ordering work. This also mean that this method only works with integer-based primary keys. - # You can't set the limit either, that's used to control the the batch sizes. - # - # Example: - # - # Person.find_in_batches(:conditions => "age > 21") do |group| - # sleep(50) # Make sure it doesn't get too crowded in there! - # group.each { |person| person.party_all_night! } - # end - def find_in_batches(options = {}) - raise "You can't specify an order, it's forced to be #{batch_order}" if options[:order] - raise "You can't specify a limit, it's forced to be the batch_size" if options[:limit] - - start = options.delete(:start).to_i - batch_size = options.delete(:batch_size) || 1000 - - with_scope(:find => options.merge(:order => batch_order, :limit => batch_size)) do - records = find(:all, :conditions => [ "#{table_name}.#{primary_key} >= ?", start ]) - - while records.any? - yield records - - break if records.size < batch_size - records = find(:all, :conditions => [ "#{table_name}.#{primary_key} > ?", records.last.id ]) - end - end - end - - - private - def batch_order - "#{table_name}.#{primary_key} ASC" - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/lib/active_record/calculations.rb b/vendor/rails/activerecord/lib/active_record/calculations.rb deleted file mode 100644 index f077818..0000000 --- a/vendor/rails/activerecord/lib/active_record/calculations.rb +++ /dev/null @@ -1,317 +0,0 @@ -module ActiveRecord - module Calculations #:nodoc: - CALCULATIONS_OPTIONS = [:conditions, :joins, :order, :select, :group, :having, :distinct, :limit, :offset, :include, :from] - def self.included(base) - base.extend(ClassMethods) - end - - module ClassMethods - # Count operates using three different approaches. - # - # * Count all: By not passing any parameters to count, it will return a count of all the rows for the model. - # * Count using column: By passing a column name to count, it will return a count of all the rows for the model with supplied column present - # * Count using options will find the row count matched by the options used. - # - # The third approach, count using options, accepts an option hash as the only parameter. The options are: - # - # * <tt>:conditions</tt>: An SQL fragment like "administrator = 1" or [ "user_name = ?", username ]. See conditions in the intro to ActiveRecord::Base. - # * <tt>:joins</tt>: Either an SQL fragment for additional joins like "LEFT JOIN comments ON comments.post_id = id" (rarely needed) - # or named associations in the same form used for the <tt>:include</tt> option, which will perform an INNER JOIN on the associated table(s). - # If the value is a string, then the records will be returned read-only since they will have attributes that do not correspond to the table's columns. - # Pass <tt>:readonly => false</tt> to override. - # * <tt>:include</tt>: Named associations that should be loaded alongside using LEFT OUTER JOINs. The symbols named refer - # to already defined associations. When using named associations, count returns the number of DISTINCT items for the model you're counting. - # See eager loading under Associations. - # * <tt>:order</tt>: An SQL fragment like "created_at DESC, name" (really only used with GROUP BY calculations). - # * <tt>:group</tt>: An attribute name by which the result should be grouped. Uses the GROUP BY SQL-clause. - # * <tt>:select</tt>: By default, this is * as in SELECT * FROM, but can be changed if you, for example, want to do a join but not - # include the joined columns. - # * <tt>:distinct</tt>: Set this to true to make this a distinct calculation, such as SELECT COUNT(DISTINCT posts.id) ... - # * <tt>:from</tt> - By default, this is the table name of the class, but can be changed to an alternate table name (or even the name - # of a database view). - # - # Examples for counting all: - # Person.count # returns the total count of all people - # - # Examples for counting by column: - # Person.count(:age) # returns the total count of all people whose age is present in database - # - # Examples for count with options: - # Person.count(:conditions => "age > 26") - # Person.count(:conditions => "age > 26 AND job.salary > 60000", :include => :job) # because of the named association, it finds the DISTINCT count using LEFT OUTER JOIN. - # Person.count(:conditions => "age > 26 AND job.salary > 60000", :joins => "LEFT JOIN jobs on jobs.person_id = person.id") # finds the number of rows matching the conditions and joins. - # Person.count('id', :conditions => "age > 26") # Performs a COUNT(id) - # Person.count(:all, :conditions => "age > 26") # Performs a COUNT(*) (:all is an alias for '*') - # - # Note: <tt>Person.count(:all)</tt> will not work because it will use <tt>:all</tt> as the condition. Use Person.count instead. - def count(*args) - calculate(:count, *construct_count_options_from_args(*args)) - end - - # Calculates the average value on a given column. The value is returned as - # a float, or +nil+ if there's no row. See +calculate+ for examples with - # options. - # - # Person.average('age') # => 35.8 - def average(column_name, options = {}) - calculate(:avg, column_name, options) - end - - # Calculates the minimum value on a given column. The value is returned - # with the same data type of the column, or +nil+ if there's no row. See - # +calculate+ for examples with options. - # - # Person.minimum('age') # => 7 - def minimum(column_name, options = {}) - calculate(:min, column_name, options) - end - - # Calculates the maximum value on a given column. The value is returned - # with the same data type of the column, or +nil+ if there's no row. See - # +calculate+ for examples with options. - # - # Person.maximum('age') # => 93 - def maximum(column_name, options = {}) - calculate(:max, column_name, options) - end - - # Calculates the sum of values on a given column. The value is returned - # with the same data type of the column, 0 if there's no row. See - # +calculate+ for examples with options. - # - # Person.sum('age') # => 4562 - def sum(column_name, options = {}) - calculate(:sum, column_name, options) - end - - # This calculates aggregate values in the given column. Methods for count, sum, average, minimum, and maximum have been added as shortcuts. - # Options such as <tt>:conditions</tt>, <tt>:order</tt>, <tt>:group</tt>, <tt>:having</tt>, and <tt>:joins</tt> can be passed to customize the query. - # - # There are two basic forms of output: - # * Single aggregate value: The single value is type cast to Fixnum for COUNT, Float for AVG, and the given column's type for everything else. - # * Grouped values: This returns an ordered hash of the values and groups them by the <tt>:group</tt> option. It takes either a column name, or the name - # of a belongs_to association. - # - # values = Person.maximum(:age, :group => 'last_name') - # puts values["Drake"] - # => 43 - # - # drake = Family.find_by_last_name('Drake') - # values = Person.maximum(:age, :group => :family) # Person belongs_to :family - # puts values[drake] - # => 43 - # - # values.each do |family, max_age| - # ... - # end - # - # Options: - # * <tt>:conditions</tt> - An SQL fragment like "administrator = 1" or [ "user_name = ?", username ]. See conditions in the intro to ActiveRecord::Base. - # * <tt>:include</tt>: Eager loading, see Associations for details. Since calculations don't load anything, the purpose of this is to access fields on joined tables in your conditions, order, or group clauses. - # * <tt>:joins</tt> - An SQL fragment for additional joins like "LEFT JOIN comments ON comments.post_id = id". (Rarely needed). - # The records will be returned read-only since they will have attributes that do not correspond to the table's columns. - # * <tt>:order</tt> - An SQL fragment like "created_at DESC, name" (really only used with GROUP BY calculations). - # * <tt>:group</tt> - An attribute name by which the result should be grouped. Uses the GROUP BY SQL-clause. - # * <tt>:select</tt> - By default, this is * as in SELECT * FROM, but can be changed if you for example want to do a join, but not - # include the joined columns. - # * <tt>:distinct</tt> - Set this to true to make this a distinct calculation, such as SELECT COUNT(DISTINCT posts.id) ... - # - # Examples: - # Person.calculate(:count, :all) # The same as Person.count - # Person.average(:age) # SELECT AVG(age) FROM people... - # Person.minimum(:age, :conditions => ['last_name != ?', 'Drake']) # Selects the minimum age for everyone with a last name other than 'Drake' - # Person.minimum(:age, :having => 'min(age) > 17', :group => :last_name) # Selects the minimum age for any family without any minors - # Person.sum("2 * age") - def calculate(operation, column_name, options = {}) - validate_calculation_options(operation, options) - column_name = options[:select] if options[:select] - column_name = '*' if column_name == :all - column = column_for column_name - catch :invalid_query do - if options[:group] - return execute_grouped_calculation(operation, column_name, column, options) - else - return execute_simple_calculation(operation, column_name, column, options) - end - end - 0 - end - - protected - def construct_count_options_from_args(*args) - options = {} - column_name = :all - - # We need to handle - # count() - # count(:column_name=:all) - # count(options={}) - # count(column_name=:all, options={}) - # selects specified by scopes - case args.size - when 0 - column_name = scope(:find)[:select] if scope(:find) - when 1 - if args[0].is_a?(Hash) - column_name = scope(:find)[:select] if scope(:find) - options = args[0] - else - column_name = args[0] - end - when 2 - column_name, options = args - else - raise ArgumentError, "Unexpected parameters passed to count(): #{args.inspect}" - end - - [column_name || :all, options] - end - - def construct_calculation_sql(operation, column_name, options) #:nodoc: - operation = operation.to_s.downcase - options = options.symbolize_keys - - scope = scope(:find) - merged_includes = merge_includes(scope ? scope[:include] : [], options[:include]) - aggregate_alias = column_alias_for(operation, column_name) - column_name = "#{connection.quote_table_name(table_name)}.#{column_name}" if column_names.include?(column_name.to_s) - - if operation == 'count' - if merged_includes.any? - options[:distinct] = true - column_name = options[:select] || [connection.quote_table_name(table_name), primary_key] * '.' - end - - if options[:distinct] - use_workaround = !connection.supports_count_distinct? - end - end - - if options[:distinct] && column_name.to_s !~ /\s*DISTINCT\s+/i - distinct = 'DISTINCT ' - end - sql = "SELECT #{operation}(#{distinct}#{column_name}) AS #{aggregate_alias}" - - # A (slower) workaround if we're using a backend, like sqlite, that doesn't support COUNT DISTINCT. - sql = "SELECT COUNT(*) AS #{aggregate_alias}" if use_workaround - - sql << ", #{options[:group_field]} AS #{options[:group_alias]}" if options[:group] - if options[:from] - sql << " FROM #{options[:from]} " - else - sql << " FROM (SELECT #{distinct}#{column_name}" if use_workaround - sql << " FROM #{connection.quote_table_name(table_name)} " - end - - joins = "" - add_joins!(joins, options[:joins], scope) - - if merged_includes.any? - join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(self, merged_includes, joins) - sql << join_dependency.join_associations.collect{|join| join.association_join }.join - end - - sql << joins unless joins.blank? - - add_conditions!(sql, options[:conditions], scope) - add_limited_ids_condition!(sql, options, join_dependency) if join_dependency && !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit]) - - if options[:group] - group_key = connection.adapter_name == 'FrontBase' ? :group_alias : :group_field - sql << " GROUP BY #{options[group_key]} " - end - - if options[:group] && options[:having] - having = sanitize_sql_for_conditions(options[:having]) - - # FrontBase requires identifiers in the HAVING clause and chokes on function calls - if connection.adapter_name == 'FrontBase' - having.downcase! - having.gsub!(/#{operation}\s*\(\s*#{column_name}\s*\)/, aggregate_alias) - end - - sql << " HAVING #{having} " - end - - sql << " ORDER BY #{options[:order]} " if options[:order] - add_limit!(sql, options, scope) - sql << ") #{aggregate_alias}_subquery" if use_workaround - sql - end - - def execute_simple_calculation(operation, column_name, column, options) #:nodoc: - value = connection.select_value(construct_calculation_sql(operation, column_name, options)) - type_cast_calculated_value(value, column, operation) - end - - def execute_grouped_calculation(operation, column_name, column, options) #:nodoc: - group_attr = options[:group].to_s - association = reflect_on_association(group_attr.to_sym) - associated = association && association.macro == :belongs_to # only count belongs_to associations - group_field = associated ? association.primary_key_name : group_attr - group_alias = column_alias_for(group_field) - group_column = column_for group_field - sql = construct_calculation_sql(operation, column_name, options.merge(:group_field => group_field, :group_alias => group_alias)) - calculated_data = connection.select_all(sql) - aggregate_alias = column_alias_for(operation, column_name) - - if association - key_ids = calculated_data.collect { |row| row[group_alias] } - key_records = association.klass.base_class.find(key_ids) - key_records = key_records.inject({}) { |hsh, r| hsh.merge(r.id => r) } - end - - calculated_data.inject(ActiveSupport::OrderedHash.new) do |all, row| - key = type_cast_calculated_value(row[group_alias], group_column) - key = key_records[key] if associated - value = row[aggregate_alias] - all[key] = type_cast_calculated_value(value, column, operation) - all - end - end - - private - def validate_calculation_options(operation, options = {}) - options.assert_valid_keys(CALCULATIONS_OPTIONS) - end - - # Converts the given keys to the value that the database adapter returns as - # a usable column name: - # - # column_alias_for("users.id") # => "users_id" - # column_alias_for("sum(id)") # => "sum_id" - # column_alias_for("count(distinct users.id)") # => "count_distinct_users_id" - # column_alias_for("count(*)") # => "count_all" - # column_alias_for("count", "id") # => "count_id" - def column_alias_for(*keys) - table_name = keys.join(' ') - table_name.downcase! - table_name.gsub!(/\*/, 'all') - table_name.gsub!(/\W+/, ' ') - table_name.strip! - table_name.gsub!(/ +/, '_') - - connection.table_alias_for(table_name) - end - - def column_for(field) - field_name = field.to_s.split('.').last - columns.detect { |c| c.name.to_s == field_name } - end - - def type_cast_calculated_value(value, column, operation = nil) - operation = operation.to_s.downcase - case operation - when 'count' then value.to_i - when 'sum' then type_cast_using_column(value || '0', column) - when 'avg' then value && (value.is_a?(Fixnum) ? value.to_f : value).to_d - else type_cast_using_column(value, column) - end - end - - def type_cast_using_column(value, column) - column ? column.type_cast(value) : value - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/callbacks.rb b/vendor/rails/activerecord/lib/active_record/callbacks.rb deleted file mode 100644 index e375037..0000000 --- a/vendor/rails/activerecord/lib/active_record/callbacks.rb +++ /dev/null @@ -1,360 +0,0 @@ -require 'observer' - -module ActiveRecord - # Callbacks are hooks into the lifecycle of an Active Record object that allow you to trigger logic - # before or after an alteration of the object state. This can be used to make sure that associated and - # dependent objects are deleted when +destroy+ is called (by overwriting +before_destroy+) or to massage attributes - # before they're validated (by overwriting +before_validation+). As an example of the callbacks initiated, consider - # the <tt>Base#save</tt> call for a new record: - # - # * (-) <tt>save</tt> - # * (-) <tt>valid</tt> - # * (1) <tt>before_validation</tt> - # * (2) <tt>before_validation_on_create</tt> - # * (-) <tt>validate</tt> - # * (-) <tt>validate_on_create</tt> - # * (3) <tt>after_validation</tt> - # * (4) <tt>after_validation_on_create</tt> - # * (5) <tt>before_save</tt> - # * (6) <tt>before_create</tt> - # * (-) <tt>create</tt> - # * (7) <tt>after_create</tt> - # * (8) <tt>after_save</tt> - # - # That's a total of eight callbacks, which gives you immense power to react and prepare for each state in the - # Active Record lifecycle. The sequence for calling <tt>Base#save</tt> an existing record is similar, except that each - # <tt>_on_create</tt> callback is replaced by the corresponding <tt>_on_update</tt> callback. - # - # Examples: - # class CreditCard < ActiveRecord::Base - # # Strip everything but digits, so the user can specify "555 234 34" or - # # "5552-3434" or both will mean "55523434" - # def before_validation_on_create - # self.number = number.gsub(/[^0-9]/, "") if attribute_present?("number") - # end - # end - # - # class Subscription < ActiveRecord::Base - # before_create :record_signup - # - # private - # def record_signup - # self.signed_up_on = Date.today - # end - # end - # - # class Firm < ActiveRecord::Base - # # Destroys the associated clients and people when the firm is destroyed - # before_destroy { |record| Person.destroy_all "firm_id = #{record.id}" } - # before_destroy { |record| Client.destroy_all "client_of = #{record.id}" } - # end - # - # == Inheritable callback queues - # - # Besides the overwritable callback methods, it's also possible to register callbacks through the use of the callback macros. - # Their main advantage is that the macros add behavior into a callback queue that is kept intact down through an inheritance - # hierarchy. Example: - # - # class Topic < ActiveRecord::Base - # before_destroy :destroy_author - # end - # - # class Reply < Topic - # before_destroy :destroy_readers - # end - # - # Now, when <tt>Topic#destroy</tt> is run only +destroy_author+ is called. When <tt>Reply#destroy</tt> is run, both +destroy_author+ and - # +destroy_readers+ are called. Contrast this to the situation where we've implemented the save behavior through overwriteable - # methods: - # - # class Topic < ActiveRecord::Base - # def before_destroy() destroy_author end - # end - # - # class Reply < Topic - # def before_destroy() destroy_readers end - # end - # - # In that case, <tt>Reply#destroy</tt> would only run +destroy_readers+ and _not_ +destroy_author+. So, use the callback macros when - # you want to ensure that a certain callback is called for the entire hierarchy, and use the regular overwriteable methods - # when you want to leave it up to each descendant to decide whether they want to call +super+ and trigger the inherited callbacks. - # - # *IMPORTANT:* In order for inheritance to work for the callback queues, you must specify the callbacks before specifying the - # associations. Otherwise, you might trigger the loading of a child before the parent has registered the callbacks and they won't - # be inherited. - # - # == Types of callbacks - # - # There are four types of callbacks accepted by the callback macros: Method references (symbol), callback objects, - # inline methods (using a proc), and inline eval methods (using a string). Method references and callback objects are the - # recommended approaches, inline methods using a proc are sometimes appropriate (such as for creating mix-ins), and inline - # eval methods are deprecated. - # - # The method reference callbacks work by specifying a protected or private method available in the object, like this: - # - # class Topic < ActiveRecord::Base - # before_destroy :delete_parents - # - # private - # def delete_parents - # self.class.delete_all "parent_id = #{id}" - # end - # end - # - # The callback objects have methods named after the callback called with the record as the only parameter, such as: - # - # class BankAccount < ActiveRecord::Base - # before_save EncryptionWrapper.new - # after_save EncryptionWrapper.new - # after_initialize EncryptionWrapper.new - # end - # - # class EncryptionWrapper - # def before_save(record) - # record.credit_card_number = encrypt(record.credit_card_number) - # end - # - # def after_save(record) - # record.credit_card_number = decrypt(record.credit_card_number) - # end - # - # alias_method :after_find, :after_save - # - # private - # def encrypt(value) - # # Secrecy is committed - # end - # - # def decrypt(value) - # # Secrecy is unveiled - # end - # end - # - # So you specify the object you want messaged on a given callback. When that callback is triggered, the object has - # a method by the name of the callback messaged. You can make these callbacks more flexible by passing in other - # initialization data such as the name of the attribute to work with: - # - # class BankAccount < ActiveRecord::Base - # before_save EncryptionWrapper.new("credit_card_number") - # after_save EncryptionWrapper.new("credit_card_number") - # after_initialize EncryptionWrapper.new("credit_card_number") - # end - # - # class EncryptionWrapper - # def initialize(attribute) - # @attribute = attribute - # end - # - # def before_save(record) - # record.send("#{@attribute}=", encrypt(record.send("#{@attribute}"))) - # end - # - # def after_save(record) - # record.send("#{@attribute}=", decrypt(record.send("#{@attribute}"))) - # end - # - # alias_method :after_find, :after_save - # - # private - # def encrypt(value) - # # Secrecy is committed - # end - # - # def decrypt(value) - # # Secrecy is unveiled - # end - # end - # - # The callback macros usually accept a symbol for the method they're supposed to run, but you can also pass a "method string", - # which will then be evaluated within the binding of the callback. Example: - # - # class Topic < ActiveRecord::Base - # before_destroy 'self.class.delete_all "parent_id = #{id}"' - # end - # - # Notice that single quotes (') are used so the <tt>#{id}</tt> part isn't evaluated until the callback is triggered. Also note that these - # inline callbacks can be stacked just like the regular ones: - # - # class Topic < ActiveRecord::Base - # before_destroy 'self.class.delete_all "parent_id = #{id}"', - # 'puts "Evaluated after parents are destroyed"' - # end - # - # == The +after_find+ and +after_initialize+ exceptions - # - # Because +after_find+ and +after_initialize+ are called for each object found and instantiated by a finder, such as <tt>Base.find(:all)</tt>, we've had - # to implement a simple performance constraint (50% more speed on a simple test case). Unlike all the other callbacks, +after_find+ and - # +after_initialize+ will only be run if an explicit implementation is defined (<tt>def after_find</tt>). In that case, all of the - # callback types will be called. - # - # == <tt>before_validation*</tt> returning statements - # - # If the returning value of a +before_validation+ callback can be evaluated to +false+, the process will be aborted and <tt>Base#save</tt> will return +false+. - # If Base#save! is called it will raise a ActiveRecord::RecordInvalid exception. - # Nothing will be appended to the errors object. - # - # == Canceling callbacks - # - # If a <tt>before_*</tt> callback returns +false+, all the later callbacks and the associated action are cancelled. If an <tt>after_*</tt> callback returns - # +false+, all the later callbacks are cancelled. Callbacks are generally run in the order they are defined, with the exception of callbacks - # defined as methods on the model, which are called last. - # - # == Transactions - # - # The entire callback chain of a +save+, <tt>save!</tt>, or +destroy+ call runs - # within a transaction. That includes <tt>after_*</tt> hooks. If everything - # goes fine a COMMIT is executed once the chain has been completed. - # - # If a <tt>before_*</tt> callback cancels the action a ROLLBACK is issued. You - # can also trigger a ROLLBACK raising an exception in any of the callbacks, - # including <tt>after_*</tt> hooks. Note, however, that in that case the client - # needs to be aware of it because an ordinary +save+ will raise such exception - # instead of quietly returning +false+. - module Callbacks - CALLBACKS = %w( - after_find after_initialize before_save after_save before_create after_create before_update after_update before_validation - after_validation before_validation_on_create after_validation_on_create before_validation_on_update - after_validation_on_update before_destroy after_destroy - ) - - def self.included(base) #:nodoc: - base.extend Observable - - [:create_or_update, :valid?, :create, :update, :destroy].each do |method| - base.send :alias_method_chain, method, :callbacks - end - - base.send :include, ActiveSupport::Callbacks - base.define_callbacks *CALLBACKS - end - - # Is called when the object was instantiated by one of the finders, like <tt>Base.find</tt>. - #def after_find() end - - # Is called after the object has been instantiated by a call to <tt>Base.new</tt>. - #def after_initialize() end - - # Is called _before_ <tt>Base.save</tt> (regardless of whether it's a +create+ or +update+ save). - def before_save() end - - # Is called _after_ <tt>Base.save</tt> (regardless of whether it's a +create+ or +update+ save). - # Note that this callback is still wrapped in the transaction around +save+. For example, if you - # invoke an external indexer at this point it won't see the changes in the database. - # - # class Contact < ActiveRecord::Base - # after_save { logger.info( 'New contact saved!' ) } - # end - def after_save() end - def create_or_update_with_callbacks #:nodoc: - return false if callback(:before_save) == false - if result = create_or_update_without_callbacks - callback(:after_save) - end - result - end - private :create_or_update_with_callbacks - - # Is called _before_ <tt>Base.save</tt> on new objects that haven't been saved yet (no record exists). - def before_create() end - - # Is called _after_ <tt>Base.save</tt> on new objects that haven't been saved yet (no record exists). - # Note that this callback is still wrapped in the transaction around +save+. For example, if you - # invoke an external indexer at this point it won't see the changes in the database. - def after_create() end - def create_with_callbacks #:nodoc: - return false if callback(:before_create) == false - result = create_without_callbacks - callback(:after_create) - result - end - private :create_with_callbacks - - # Is called _before_ <tt>Base.save</tt> on existing objects that have a record. - def before_update() end - - # Is called _after_ <tt>Base.save</tt> on existing objects that have a record. - # Note that this callback is still wrapped in the transaction around +save+. For example, if you - # invoke an external indexer at this point it won't see the changes in the database. - def after_update() end - - def update_with_callbacks(*args) #:nodoc: - return false if callback(:before_update) == false - result = update_without_callbacks(*args) - callback(:after_update) - result - end - private :update_with_callbacks - - # Is called _before_ <tt>Validations.validate</tt> (which is part of the <tt>Base.save</tt> call). - def before_validation() end - - # Is called _after_ <tt>Validations.validate</tt> (which is part of the <tt>Base.save</tt> call). - def after_validation() end - - # Is called _before_ <tt>Validations.validate</tt> (which is part of the <tt>Base.save</tt> call) on new objects - # that haven't been saved yet (no record exists). - def before_validation_on_create() end - - # Is called _after_ <tt>Validations.validate</tt> (which is part of the <tt>Base.save</tt> call) on new objects - # that haven't been saved yet (no record exists). - def after_validation_on_create() end - - # Is called _before_ <tt>Validations.validate</tt> (which is part of the <tt>Base.save</tt> call) on - # existing objects that have a record. - def before_validation_on_update() end - - # Is called _after_ <tt>Validations.validate</tt> (which is part of the <tt>Base.save</tt> call) on - # existing objects that have a record. - def after_validation_on_update() end - - def valid_with_callbacks? #:nodoc: - return false if callback(:before_validation) == false - if new_record? then result = callback(:before_validation_on_create) else result = callback(:before_validation_on_update) end - return false if false == result - - result = valid_without_callbacks? - - callback(:after_validation) - if new_record? then callback(:after_validation_on_create) else callback(:after_validation_on_update) end - - return result - end - - # Is called _before_ <tt>Base.destroy</tt>. - # - # Note: If you need to _destroy_ or _nullify_ associated records first, - # use the <tt>:dependent</tt> option on your associations. - def before_destroy() end - - # Is called _after_ <tt>Base.destroy</tt> (and all the attributes have been frozen). - # - # class Contact < ActiveRecord::Base - # after_destroy { |record| logger.info( "Contact #{record.id} was destroyed." ) } - # end - def after_destroy() end - def destroy_with_callbacks #:nodoc: - return false if callback(:before_destroy) == false - result = destroy_without_callbacks - callback(:after_destroy) - result - end - - private - def callback(method) - result = run_callbacks(method) { |result, object| false == result } - - if result != false && respond_to_without_attributes?(method) - result = send(method) - end - - notify(method) - - return result - end - - def notify(method) #:nodoc: - self.class.changed - self.class.notify_observers(method, self) - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb deleted file mode 100644 index aac84cc..0000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ /dev/null @@ -1,371 +0,0 @@ -require 'monitor' -require 'set' - -module ActiveRecord - # Raised when a connection could not be obtained within the connection - # acquisition timeout period. - class ConnectionTimeoutError < ConnectionNotEstablished - end - - module ConnectionAdapters - # Connection pool base class for managing ActiveRecord database - # connections. - # - # == Introduction - # - # A connection pool synchronizes thread access to a limited number of - # database connections. The basic idea is that each thread checks out a - # database connection from the pool, uses that connection, and checks the - # connection back in. ConnectionPool is completely thread-safe, and will - # ensure that a connection cannot be used by two threads at the same time, - # as long as ConnectionPool's contract is correctly followed. It will also - # handle cases in which there are more threads than connections: if all - # connections have been checked out, and a thread tries to checkout a - # connection anyway, then ConnectionPool will wait until some other thread - # has checked in a connection. - # - # == Obtaining (checking out) a connection - # - # Connections can be obtained and used from a connection pool in several - # ways: - # - # 1. Simply use ActiveRecord::Base.connection as with ActiveRecord 2.1 and - # earlier (pre-connection-pooling). Eventually, when you're done with - # the connection(s) and wish it to be returned to the pool, you call - # ActiveRecord::Base.clear_active_connections!. This will be the - # default behavior for ActiveRecord when used in conjunction with - # ActionPack's request handling cycle. - # 2. Manually check out a connection from the pool with - # ActiveRecord::Base.connection_pool.checkout. You are responsible for - # returning this connection to the pool when finished by calling - # ActiveRecord::Base.connection_pool.checkin(connection). - # 3. Use ActiveRecord::Base.connection_pool.with_connection(&block), which - # obtains a connection, yields it as the sole argument to the block, - # and returns it to the pool after the block completes. - # - # Connections in the pool are actually AbstractAdapter objects (or objects - # compatible with AbstractAdapter's interface). - # - # == Options - # - # There are two connection-pooling-related options that you can add to - # your database connection configuration: - # - # * +pool+: number indicating size of connection pool (default 5) - # * +wait_timeout+: number of seconds to block and wait for a connection - # before giving up and raising a timeout error (default 5 seconds). - class ConnectionPool - attr_reader :spec - - # Creates a new ConnectionPool object. +spec+ is a ConnectionSpecification - # object which describes database connection information (e.g. adapter, - # host name, username, password, etc), as well as the maximum size for - # this ConnectionPool. - # - # The default ConnectionPool maximum size is 5. - def initialize(spec) - @spec = spec - - # The cache of reserved connections mapped to threads - @reserved_connections = {} - - # The mutex used to synchronize pool access - @connection_mutex = Monitor.new - @queue = @connection_mutex.new_cond - - # default 5 second timeout unless on ruby 1.9 - @timeout = - if RUBY_VERSION < '1.9' - spec.config[:wait_timeout] || 5 - end - - # default max pool size to 5 - @size = (spec.config[:pool] && spec.config[:pool].to_i) || 5 - - @connections = [] - @checked_out = [] - end - - # Retrieve the connection associated with the current thread, or call - # #checkout to obtain one if necessary. - # - # #connection can be called any number of times; the connection is - # held in a hash keyed by the thread id. - def connection - if conn = @reserved_connections[current_connection_id] - conn - else - @reserved_connections[current_connection_id] = checkout - end - end - - # Signal that the thread is finished with the current connection. - # #release_connection releases the connection-thread association - # and returns the connection to the pool. - def release_connection - conn = @reserved_connections.delete(current_connection_id) - checkin conn if conn - end - - # Reserve a connection, and yield it to a block. Ensure the connection is - # checked back in when finished. - def with_connection - conn = checkout - yield conn - ensure - checkin conn - end - - # Returns true if a connection has already been opened. - def connected? - !@connections.empty? - end - - # Disconnects all connections in the pool, and clears the pool. - def disconnect! - @reserved_connections.each do |name,conn| - checkin conn - end - @reserved_connections = {} - @connections.each do |conn| - conn.disconnect! - end - @connections = [] - end - - # Clears the cache which maps classes - def clear_reloadable_connections! - @reserved_connections.each do |name, conn| - checkin conn - end - @reserved_connections = {} - @connections.each do |conn| - conn.disconnect! if conn.requires_reloading? - end - @connections = [] - end - - # Verify active connections and remove and disconnect connections - # associated with stale threads. - def verify_active_connections! #:nodoc: - clear_stale_cached_connections! - @connections.each do |connection| - connection.verify! - end - end - - # Return any checked-out connections back to the pool by threads that - # are no longer alive. - def clear_stale_cached_connections! - remove_stale_cached_threads!(@reserved_connections) do |name, conn| - checkin conn - end - end - - # Check-out a database connection from the pool, indicating that you want - # to use it. You should call #checkin when you no longer need this. - # - # This is done by either returning an existing connection, or by creating - # a new connection. If the maximum number of connections for this pool has - # already been reached, but the pool is empty (i.e. they're all being used), - # then this method will wait until a thread has checked in a connection. - # The wait time is bounded however: if no connection can be checked out - # within the timeout specified for this pool, then a ConnectionTimeoutError - # exception will be raised. - # - # Returns: an AbstractAdapter object. - # - # Raises: - # - ConnectionTimeoutError: no connection can be obtained from the pool - # within the timeout period. - def checkout - # Checkout an available connection - @connection_mutex.synchronize do - loop do - conn = if @checked_out.size < @connections.size - checkout_existing_connection - elsif @connections.size < @size - checkout_new_connection - end - return conn if conn - # No connections available; wait for one - if @queue.wait(@timeout) - next - else - # try looting dead threads - clear_stale_cached_connections! - if @size == @checked_out.size - raise ConnectionTimeoutError, "could not obtain a database connection#{" within #{@timeout} seconds" if @timeout}. The max pool size is currently #{@size}; consider increasing it." - end - end - end - end - end - - # Check-in a database connection back into the pool, indicating that you - # no longer need this connection. - # - # +conn+: an AbstractAdapter object, which was obtained by earlier by - # calling +checkout+ on this pool. - def checkin(conn) - @connection_mutex.synchronize do - conn.run_callbacks :checkin - @checked_out.delete conn - @queue.signal - end - end - - synchronize :clear_reloadable_connections!, :verify_active_connections!, - :connected?, :disconnect!, :with => :@connection_mutex - - private - def new_connection - ActiveRecord::Base.send(spec.adapter_method, spec.config) - end - - def current_connection_id #:nodoc: - Thread.current.object_id - end - - # Remove stale threads from the cache. - def remove_stale_cached_threads!(cache, &block) - keys = Set.new(cache.keys) - - Thread.list.each do |thread| - keys.delete(thread.object_id) if thread.alive? - end - keys.each do |key| - next unless cache.has_key?(key) - block.call(key, cache[key]) - cache.delete(key) - end - end - - def checkout_new_connection - c = new_connection - @connections << c - checkout_and_verify(c) - end - - def checkout_existing_connection - c = (@connections - @checked_out).first - checkout_and_verify(c) - end - - def checkout_and_verify(c) - c.verify! - c.run_callbacks :checkout - @checked_out << c - c - end - end - - # ConnectionHandler is a collection of ConnectionPool objects. It is used - # for keeping separate connection pools for ActiveRecord models that connect - # to different databases. - # - # For example, suppose that you have 5 models, with the following hierarchy: - # - # | - # +-- Book - # | | - # | +-- ScaryBook - # | +-- GoodBook - # +-- Author - # +-- BankAccount - # - # Suppose that Book is to connect to a separate database (i.e. one other - # than the default database). Then Book, ScaryBook and GoodBook will all use - # the same connection pool. Likewise, Author and BankAccount will use the - # same connection pool. However, the connection pool used by Author/BankAccount - # is not the same as the one used by Book/ScaryBook/GoodBook. - # - # Normally there is only a single ConnectionHandler instance, accessible via - # ActiveRecord::Base.connection_handler. ActiveRecord models use this to - # determine that connection pool that they should use. - class ConnectionHandler - def initialize(pools = {}) - @connection_pools = pools - end - - def connection_pools - @connection_pools ||= {} - end - - def establish_connection(name, spec) - @connection_pools[name] = ConnectionAdapters::ConnectionPool.new(spec) - end - - # Returns any connections in use by the current thread back to the pool, - # and also returns connections to the pool cached by threads that are no - # longer alive. - def clear_active_connections! - @connection_pools.each_value {|pool| pool.release_connection } - end - - # Clears the cache which maps classes - def clear_reloadable_connections! - @connection_pools.each_value {|pool| pool.clear_reloadable_connections! } - end - - def clear_all_connections! - @connection_pools.each_value {|pool| pool.disconnect! } - end - - # Verify active connections. - def verify_active_connections! #:nodoc: - @connection_pools.each_value {|pool| pool.verify_active_connections! } - end - - # Locate the connection of the nearest super class. This can be an - # active or defined connection: if it is the latter, it will be - # opened and set as the active connection for the class it was defined - # for (not necessarily the current class). - def retrieve_connection(klass) #:nodoc: - pool = retrieve_connection_pool(klass) - (pool && pool.connection) or raise ConnectionNotEstablished - end - - # Returns true if a connection that's accessible to this class has - # already been opened. - def connected?(klass) - conn = retrieve_connection_pool(klass) - conn ? conn.connected? : false - end - - # Remove the connection for this class. This will close the active - # connection and the defined connection (if they exist). The result - # can be used as an argument for establish_connection, for easily - # re-establishing the connection. - def remove_connection(klass) - pool = @connection_pools[klass.name] - @connection_pools.delete_if { |key, value| value == pool } - pool.disconnect! if pool - pool.spec.config if pool - end - - def retrieve_connection_pool(klass) - pool = @connection_pools[klass.name] - return pool if pool - return nil if ActiveRecord::Base == klass - retrieve_connection_pool klass.superclass - end - end - - class ConnectionManagement - def initialize(app) - @app = app - end - - def call(env) - @app.call(env) - ensure - # Don't return connection (and peform implicit rollback) if - # this request is a part of integration test - unless env.key?("rack.test") - ActiveRecord::Base.clear_active_connections! - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb deleted file mode 100644 index bbc290f..0000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +++ /dev/null @@ -1,139 +0,0 @@ -module ActiveRecord - class Base - class ConnectionSpecification #:nodoc: - attr_reader :config, :adapter_method - def initialize (config, adapter_method) - @config, @adapter_method = config, adapter_method - end - end - - ## - # :singleton-method: - # The connection handler - cattr_accessor :connection_handler, :instance_writer => false - @@connection_handler = ConnectionAdapters::ConnectionHandler.new - - # Returns the connection currently associated with the class. This can - # also be used to "borrow" the connection to do database work that isn't - # easily done without going straight to SQL. - def connection - self.class.connection - end - - # Establishes the connection to the database. Accepts a hash as input where - # the <tt>:adapter</tt> key must be specified with the name of a database adapter (in lower-case) - # example for regular databases (MySQL, Postgresql, etc): - # - # ActiveRecord::Base.establish_connection( - # :adapter => "mysql", - # :host => "localhost", - # :username => "myuser", - # :password => "mypass", - # :database => "somedatabase" - # ) - # - # Example for SQLite database: - # - # ActiveRecord::Base.establish_connection( - # :adapter => "sqlite", - # :database => "path/to/dbfile" - # ) - # - # Also accepts keys as strings (for parsing from YAML for example): - # - # ActiveRecord::Base.establish_connection( - # "adapter" => "sqlite", - # "database" => "path/to/dbfile" - # ) - # - # The exceptions AdapterNotSpecified, AdapterNotFound and ArgumentError - # may be returned on an error. - def self.establish_connection(spec = nil) - case spec - when nil - raise AdapterNotSpecified unless defined? RAILS_ENV - establish_connection(RAILS_ENV) - when ConnectionSpecification - @@connection_handler.establish_connection(name, spec) - when Symbol, String - if configuration = configurations[spec.to_s] - establish_connection(configuration) - else - raise AdapterNotSpecified, "#{spec} database is not configured" - end - else - spec = spec.symbolize_keys - unless spec.key?(:adapter) then raise AdapterNotSpecified, "database configuration does not specify adapter" end - - begin - require 'rubygems' - gem "activerecord-#{spec[:adapter]}-adapter" - require "active_record/connection_adapters/#{spec[:adapter]}_adapter" - rescue LoadError - begin - require "active_record/connection_adapters/#{spec[:adapter]}_adapter" - rescue LoadError - raise "Please install the #{spec[:adapter]} adapter: `gem install activerecord-#{spec[:adapter]}-adapter` (#{$!})" - end - end - - adapter_method = "#{spec[:adapter]}_connection" - if !respond_to?(adapter_method) - raise AdapterNotFound, "database configuration specifies nonexistent #{spec[:adapter]} adapter" - end - - remove_connection - establish_connection(ConnectionSpecification.new(spec, adapter_method)) - end - end - - class << self - # Deprecated and no longer has any effect. - def allow_concurrency - ActiveSupport::Deprecation.warn("ActiveRecord::Base.allow_concurrency has been deprecated and no longer has any effect. Please remove all references to allow_concurrency.") - end - - # Deprecated and no longer has any effect. - def allow_concurrency=(flag) - ActiveSupport::Deprecation.warn("ActiveRecord::Base.allow_concurrency= has been deprecated and no longer has any effect. Please remove all references to allow_concurrency=.") - end - - # Deprecated and no longer has any effect. - def verification_timeout - ActiveSupport::Deprecation.warn("ActiveRecord::Base.verification_timeout has been deprecated and no longer has any effect. Please remove all references to verification_timeout.") - end - - # Deprecated and no longer has any effect. - def verification_timeout=(flag) - ActiveSupport::Deprecation.warn("ActiveRecord::Base.verification_timeout= has been deprecated and no longer has any effect. Please remove all references to verification_timeout=.") - end - - # Returns the connection currently associated with the class. This can - # also be used to "borrow" the connection to do database work unrelated - # to any of the specific Active Records. - def connection - retrieve_connection - end - - def connection_pool - connection_handler.retrieve_connection_pool(self) - end - - def retrieve_connection - connection_handler.retrieve_connection(self) - end - - # Returns true if +ActiveRecord+ is connected. - def connected? - connection_handler.connected?(self) - end - - def remove_connection(klass = self) - connection_handler.remove_connection(klass) - end - - delegate :clear_active_connections!, :clear_reloadable_connections!, - :clear_all_connections!,:verify_active_connections!, :to => :connection_handler - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb deleted file mode 100644 index 08601da..0000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ /dev/null @@ -1,289 +0,0 @@ -module ActiveRecord - module ConnectionAdapters # :nodoc: - module DatabaseStatements - # Returns an array of record hashes with the column names as keys and - # column values as values. - def select_all(sql, name = nil) - select(sql, name) - end - - # Returns a record hash with the column names as keys and column values - # as values. - def select_one(sql, name = nil) - result = select_all(sql, name) - result.first if result - end - - # Returns a single value from a record - def select_value(sql, name = nil) - if result = select_one(sql, name) - result.values.first - end - end - - # Returns an array of the values of the first column in a select: - # select_values("SELECT id FROM companies LIMIT 3") => [1,2,3] - def select_values(sql, name = nil) - result = select_rows(sql, name) - result.map { |v| v[0] } - end - - # Returns an array of arrays containing the field values. - # Order is the same as that returned by +columns+. - def select_rows(sql, name = nil) - end - undef_method :select_rows - - # Executes the SQL statement in the context of this connection. - def execute(sql, name = nil, skip_logging = false) - end - undef_method :execute - - # Returns the last auto-generated ID from the affected table. - def insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) - insert_sql(sql, name, pk, id_value, sequence_name) - end - - # Executes the update statement and returns the number of rows affected. - def update(sql, name = nil) - update_sql(sql, name) - end - - # Executes the delete statement and returns the number of rows affected. - def delete(sql, name = nil) - delete_sql(sql, name) - end - - # Checks whether there is currently no transaction active. This is done - # by querying the database driver, and does not use the transaction - # house-keeping information recorded by #increment_open_transactions and - # friends. - # - # Returns true if there is no transaction active, false if there is a - # transaction active, and nil if this information is unknown. - # - # Not all adapters supports transaction state introspection. Currently, - # only the PostgreSQL adapter supports this. - def outside_transaction? - nil - end - - # Runs the given block in a database transaction, and returns the result - # of the block. - # - # == Nested transactions support - # - # Most databases don't support true nested transactions. At the time of - # writing, the only database that supports true nested transactions that - # we're aware of, is MS-SQL. - # - # In order to get around this problem, #transaction will emulate the effect - # of nested transactions, by using savepoints: - # http://dev.mysql.com/doc/refman/5.0/en/savepoints.html - # Savepoints are supported by MySQL and PostgreSQL, but not SQLite3. - # - # It is safe to call this method if a database transaction is already open, - # i.e. if #transaction is called within another #transaction block. In case - # of a nested call, #transaction will behave as follows: - # - # - The block will be run without doing anything. All database statements - # that happen within the block are effectively appended to the already - # open database transaction. - # - However, if +:requires_new+ is set, the block will be wrapped in a - # database savepoint acting as a sub-transaction. - # - # === Caveats - # - # MySQL doesn't support DDL transactions. If you perform a DDL operation, - # then any created savepoints will be automatically released. For example, - # if you've created a savepoint, then you execute a CREATE TABLE statement, - # then the savepoint that was created will be automatically released. - # - # This means that, on MySQL, you shouldn't execute DDL operations inside - # a #transaction call that you know might create a savepoint. Otherwise, - # #transaction will raise exceptions when it tries to release the - # already-automatically-released savepoints: - # - # Model.connection.transaction do # BEGIN - # Model.connection.transaction(:requires_new => true) do # CREATE SAVEPOINT active_record_1 - # Model.connection.create_table(...) - # # active_record_1 now automatically released - # end # RELEASE SAVEPOINT active_record_1 <--- BOOM! database error! - # end - def transaction(options = {}) - options.assert_valid_keys :requires_new, :joinable - - last_transaction_joinable = @transaction_joinable - if options.has_key?(:joinable) - @transaction_joinable = options[:joinable] - else - @transaction_joinable = true - end - requires_new = options[:requires_new] || !last_transaction_joinable - - transaction_open = false - begin - if block_given? - if requires_new || open_transactions == 0 - if open_transactions == 0 - begin_db_transaction - elsif requires_new - create_savepoint - end - increment_open_transactions - transaction_open = true - end - yield - end - rescue Exception => database_transaction_rollback - if transaction_open && !outside_transaction? - transaction_open = false - decrement_open_transactions - if open_transactions == 0 - rollback_db_transaction - else - rollback_to_savepoint - end - end - raise unless database_transaction_rollback.is_a?(ActiveRecord::Rollback) - end - ensure - @transaction_joinable = last_transaction_joinable - - if outside_transaction? - @open_transactions = 0 - elsif transaction_open - decrement_open_transactions - begin - if open_transactions == 0 - commit_db_transaction - else - release_savepoint - end - rescue Exception => database_transaction_rollback - if open_transactions == 0 - rollback_db_transaction - else - rollback_to_savepoint - end - raise - end - end - end - - # Begins the transaction (and turns off auto-committing). - def begin_db_transaction() end - - # Commits the transaction (and turns on auto-committing). - def commit_db_transaction() end - - # Rolls back the transaction (and turns on auto-committing). Must be - # done if the transaction block raises an exception or returns false. - def rollback_db_transaction() end - - # Alias for <tt>add_limit_offset!</tt>. - def add_limit!(sql, options) - add_limit_offset!(sql, options) if options - end - - # Appends +LIMIT+ and +OFFSET+ options to an SQL statement, or some SQL - # fragment that has the same semantics as LIMIT and OFFSET. - # - # +options+ must be a Hash which contains a +:limit+ option (required) - # and an +:offset+ option (optional). - # - # This method *modifies* the +sql+ parameter. - # - # ===== Examples - # add_limit_offset!('SELECT * FROM suppliers', {:limit => 10, :offset => 50}) - # generates - # SELECT * FROM suppliers LIMIT 10 OFFSET 50 - def add_limit_offset!(sql, options) - if limit = options[:limit] - sql << " LIMIT #{sanitize_limit(limit)}" - if offset = options[:offset] - sql << " OFFSET #{offset.to_i}" - end - end - sql - end - - # Appends a locking clause to an SQL statement. - # This method *modifies* the +sql+ parameter. - # # SELECT * FROM suppliers FOR UPDATE - # add_lock! 'SELECT * FROM suppliers', :lock => true - # add_lock! 'SELECT * FROM suppliers', :lock => ' FOR UPDATE' - def add_lock!(sql, options) - case lock = options[:lock] - when true; sql << ' FOR UPDATE' - when String; sql << " #{lock}" - end - end - - def default_sequence_name(table, column) - nil - end - - # Set the sequence to the max value of the table's column. - def reset_sequence!(table, column, sequence = nil) - # Do nothing by default. Implement for PostgreSQL, Oracle, ... - end - - # Inserts the given fixture into the table. Overridden in adapters that require - # something beyond a simple insert (eg. Oracle). - def insert_fixture(fixture, table_name) - execute "INSERT INTO #{quote_table_name(table_name)} (#{fixture.key_list}) VALUES (#{fixture.value_list})", 'Fixture Insert' - end - - def empty_insert_statement(table_name) - "INSERT INTO #{quote_table_name(table_name)} VALUES(DEFAULT)" - end - - def case_sensitive_equality_operator - "=" - end - - def limited_update_conditions(where_sql, quoted_table_name, quoted_primary_key) - "WHERE #{quoted_primary_key} IN (SELECT #{quoted_primary_key} FROM #{quoted_table_name} #{where_sql})" - end - - protected - # Returns an array of record hashes with the column names as keys and - # column values as values. - def select(sql, name = nil) - end - undef_method :select - - # Returns the last auto-generated ID from the affected table. - def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) - execute(sql, name) - id_value - end - - # Executes the update statement and returns the number of rows affected. - def update_sql(sql, name = nil) - execute(sql, name) - end - - # Executes the delete statement and returns the number of rows affected. - def delete_sql(sql, name = nil) - update_sql(sql, name) - end - - # Sanitizes the given LIMIT parameter in order to prevent SQL injection. - # - # +limit+ may be anything that can evaluate to a string via #to_s. It - # should look like an integer, or a comma-delimited list of integers. - # - # Returns the sanitized limit parameter, either as an integer, or as a - # string which contains a comma-delimited list of integers. - def sanitize_limit(limit) - if limit.to_s =~ /,/ - limit.to_s.split(',').map{ |i| i.to_i }.join(',') - else - limit.to_i - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb deleted file mode 100644 index 00c7109..0000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb +++ /dev/null @@ -1,94 +0,0 @@ -module ActiveRecord - module ConnectionAdapters # :nodoc: - module QueryCache - class << self - def included(base) - base.class_eval do - alias_method_chain :columns, :query_cache - alias_method_chain :select_all, :query_cache - end - - dirties_query_cache base, :insert, :update, :delete - end - - def dirties_query_cache(base, *method_names) - method_names.each do |method_name| - base.class_eval <<-end_code, __FILE__, __LINE__ - def #{method_name}_with_query_dirty(*args) # def update_with_query_dirty(*args) - clear_query_cache if @query_cache_enabled # clear_query_cache if @query_cache_enabled - #{method_name}_without_query_dirty(*args) # update_without_query_dirty(*args) - end # end - # - alias_method_chain :#{method_name}, :query_dirty # alias_method_chain :update, :query_dirty - end_code - end - end - end - - attr_reader :query_cache, :query_cache_enabled - - # Enable the query cache within the block. - def cache - old, @query_cache_enabled = @query_cache_enabled, true - @query_cache ||= {} - yield - ensure - clear_query_cache - @query_cache_enabled = old - end - - # Disable the query cache within the block. - def uncached - old, @query_cache_enabled = @query_cache_enabled, false - yield - ensure - @query_cache_enabled = old - end - - # Clears the query cache. - # - # One reason you may wish to call this method explicitly is between queries - # that ask the database to randomize results. Otherwise the cache would see - # the same SQL query and repeatedly return the same result each time, silently - # undermining the randomness you were expecting. - def clear_query_cache - @query_cache.clear if @query_cache - end - - def select_all_with_query_cache(*args) - if @query_cache_enabled - cache_sql(args.first) { select_all_without_query_cache(*args) } - else - select_all_without_query_cache(*args) - end - end - - def columns_with_query_cache(*args) - if @query_cache_enabled - @query_cache["SHOW FIELDS FROM #{args.first}"] ||= columns_without_query_cache(*args) - else - columns_without_query_cache(*args) - end - end - - private - def cache_sql(sql) - result = - if @query_cache.has_key?(sql) - log_info(sql, "CACHE", 0.0) - @query_cache[sql] - else - @query_cache[sql] = yield - end - - if Array === result - result.collect { |row| row.dup } - else - result.duplicable? ? result.dup : result - end - rescue TypeError - result - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb deleted file mode 100644 index 3a7bf35..0000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +++ /dev/null @@ -1,69 +0,0 @@ -module ActiveRecord - module ConnectionAdapters # :nodoc: - module Quoting - # Quotes the column value to help prevent - # {SQL injection attacks}[http://en.wikipedia.org/wiki/SQL_injection]. - def quote(value, column = nil) - # records are quoted as their primary key - return value.quoted_id if value.respond_to?(:quoted_id) - - case value - when String, ActiveSupport::Multibyte::Chars - value = value.to_s - if column && column.type == :binary && column.class.respond_to?(:string_to_binary) - "#{quoted_string_prefix}'#{quote_string(column.class.string_to_binary(value))}'" # ' (for ruby-mode) - elsif column && [:integer, :float].include?(column.type) - value = column.type == :integer ? value.to_i : value.to_f - value.to_s - else - "#{quoted_string_prefix}'#{quote_string(value)}'" # ' (for ruby-mode) - end - when NilClass then "NULL" - when TrueClass then (column && column.type == :integer ? '1' : quoted_true) - when FalseClass then (column && column.type == :integer ? '0' : quoted_false) - when Float, Fixnum, Bignum then value.to_s - # BigDecimals need to be output in a non-normalized form and quoted. - when BigDecimal then value.to_s('F') - else - if value.acts_like?(:date) || value.acts_like?(:time) - "'#{quoted_date(value)}'" - else - "#{quoted_string_prefix}'#{quote_string(value.to_yaml)}'" - end - end - end - - # Quotes a string, escaping any ' (single quote) and \ (backslash) - # characters. - def quote_string(s) - s.gsub(/\\/, '\&\&').gsub(/'/, "''") # ' (for ruby-mode) - end - - # Quotes the column name. Defaults to no quoting. - def quote_column_name(column_name) - column_name - end - - # Quotes the table name. Defaults to column name quoting. - def quote_table_name(table_name) - quote_column_name(table_name) - end - - def quoted_true - "'t'" - end - - def quoted_false - "'f'" - end - - def quoted_date(value) - value.to_s(:db) - end - - def quoted_string_prefix - '' - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb deleted file mode 100644 index 24c734c..0000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ /dev/null @@ -1,708 +0,0 @@ -require 'date' -require 'set' -require 'bigdecimal' -require 'bigdecimal/util' - -module ActiveRecord - module ConnectionAdapters #:nodoc: - # An abstract definition of a column in a table. - class Column - TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].to_set - FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE'].to_set - - module Format - ISO_DATE = /\A(\d{4})-(\d\d)-(\d\d)\z/ - ISO_DATETIME = /\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)(\.\d+)?\z/ - end - - attr_reader :name, :default, :type, :limit, :null, :sql_type, :precision, :scale - attr_accessor :primary - - # Instantiates a new column in the table. - # - # +name+ is the column's name, such as <tt>supplier_id</tt> in <tt>supplier_id int(11)</tt>. - # +default+ is the type-casted default value, such as +new+ in <tt>sales_stage varchar(20) default 'new'</tt>. - # +sql_type+ is only used to extract the column's length, if necessary. For example +60+ in <tt>company_name varchar(60)</tt>. - # +null+ determines if this column allows +NULL+ values. - def initialize(name, default, sql_type = nil, null = true) - @name, @sql_type, @null = name, sql_type, null - @limit, @precision, @scale = extract_limit(sql_type), extract_precision(sql_type), extract_scale(sql_type) - @type = simplified_type(sql_type) - @default = extract_default(default) - - @primary = nil - end - - # Returns +true+ if the column is either of type string or text. - def text? - type == :string || type == :text - end - - # Returns +true+ if the column is either of type integer, float or decimal. - def number? - type == :integer || type == :float || type == :decimal - end - - def has_default? - !default.nil? - end - - # Returns the Ruby class that corresponds to the abstract data type. - def klass - case type - when :integer then Fixnum - when :float then Float - when :decimal then BigDecimal - when :datetime then Time - when :date then Date - when :timestamp then Time - when :time then Time - when :text, :string then String - when :binary then String - when :boolean then Object - end - end - - # Casts value (which is a String) to an appropriate instance. - def type_cast(value) - return nil if value.nil? - case type - when :string then value - when :text then value - when :integer then value.to_i rescue value ? 1 : 0 - when :float then value.to_f - when :decimal then self.class.value_to_decimal(value) - when :datetime then self.class.string_to_time(value) - when :timestamp then self.class.string_to_time(value) - when :time then self.class.string_to_dummy_time(value) - when :date then self.class.string_to_date(value) - when :binary then self.class.binary_to_string(value) - when :boolean then self.class.value_to_boolean(value) - else value - end - end - - def type_cast_code(var_name) - case type - when :string then nil - when :text then nil - when :integer then "(#{var_name}.to_i rescue #{var_name} ? 1 : 0)" - when :float then "#{var_name}.to_f" - when :decimal then "#{self.class.name}.value_to_decimal(#{var_name})" - when :datetime then "#{self.class.name}.string_to_time(#{var_name})" - when :timestamp then "#{self.class.name}.string_to_time(#{var_name})" - when :time then "#{self.class.name}.string_to_dummy_time(#{var_name})" - when :date then "#{self.class.name}.string_to_date(#{var_name})" - when :binary then "#{self.class.name}.binary_to_string(#{var_name})" - when :boolean then "#{self.class.name}.value_to_boolean(#{var_name})" - else nil - end - end - - # Returns the human name of the column name. - # - # ===== Examples - # Column.new('sales_stage', ...).human_name # => 'Sales stage' - def human_name - Base.human_attribute_name(@name) - end - - def extract_default(default) - type_cast(default) - end - - class << self - # Used to convert from Strings to BLOBs - def string_to_binary(value) - value - end - - # Used to convert from BLOBs to Strings - def binary_to_string(value) - value - end - - def string_to_date(string) - return string unless string.is_a?(String) - return nil if string.empty? - - fast_string_to_date(string) || fallback_string_to_date(string) - end - - def string_to_time(string) - return string unless string.is_a?(String) - return nil if string.empty? - - fast_string_to_time(string) || fallback_string_to_time(string) - end - - def string_to_dummy_time(string) - return string unless string.is_a?(String) - return nil if string.empty? - - string_to_time "2000-01-01 #{string}" - end - - # convert something to a boolean - def value_to_boolean(value) - if value.is_a?(String) && value.blank? - nil - else - TRUE_VALUES.include?(value) - end - end - - # convert something to a BigDecimal - def value_to_decimal(value) - # Using .class is faster than .is_a? and - # subclasses of BigDecimal will be handled - # in the else clause - if value.class == BigDecimal - value - elsif value.respond_to?(:to_d) - value.to_d - else - value.to_s.to_d - end - end - - protected - # '0.123456' -> 123456 - # '1.123456' -> 123456 - def microseconds(time) - ((time[:sec_fraction].to_f % 1) * 1_000_000).to_i - end - - def new_date(year, mon, mday) - if year && year != 0 - Date.new(year, mon, mday) rescue nil - end - end - - def new_time(year, mon, mday, hour, min, sec, microsec) - # Treat 0000-00-00 00:00:00 as nil. - return nil if year.nil? || year == 0 - - Time.time_with_datetime_fallback(Base.default_timezone, year, mon, mday, hour, min, sec, microsec) rescue nil - end - - def fast_string_to_date(string) - if string =~ Format::ISO_DATE - new_date $1.to_i, $2.to_i, $3.to_i - end - end - - # Doesn't handle time zones. - def fast_string_to_time(string) - if string =~ Format::ISO_DATETIME - microsec = ($7.to_f * 1_000_000).to_i - new_time $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i, microsec - end - end - - def fallback_string_to_date(string) - new_date(*::Date._parse(string, false).values_at(:year, :mon, :mday)) - end - - def fallback_string_to_time(string) - time_hash = Date._parse(string) - time_hash[:sec_fraction] = microseconds(time_hash) - - new_time(*time_hash.values_at(:year, :mon, :mday, :hour, :min, :sec, :sec_fraction)) - end - end - - private - def extract_limit(sql_type) - $1.to_i if sql_type =~ /\((.*)\)/ - end - - def extract_precision(sql_type) - $2.to_i if sql_type =~ /^(numeric|decimal|number)\((\d+)(,\d+)?\)/i - end - - def extract_scale(sql_type) - case sql_type - when /^(numeric|decimal|number)\((\d+)\)/i then 0 - when /^(numeric|decimal|number)\((\d+)(,(\d+))\)/i then $4.to_i - end - end - - def simplified_type(field_type) - case field_type - when /int/i - :integer - when /float|double/i - :float - when /decimal|numeric|number/i - extract_scale(field_type) == 0 ? :integer : :decimal - when /datetime/i - :datetime - when /timestamp/i - :timestamp - when /time/i - :time - when /date/i - :date - when /clob/i, /text/i - :text - when /blob/i, /binary/i - :binary - when /char/i, /string/i - :string - when /boolean/i - :boolean - end - end - end - - class IndexDefinition < Struct.new(:table, :name, :unique, :columns) #:nodoc: - end - - # Abstract representation of a column definition. Instances of this type - # are typically created by methods in TableDefinition, and added to the - # +columns+ attribute of said TableDefinition object, in order to be used - # for generating a number of table creation or table changing SQL statements. - class ColumnDefinition < Struct.new(:base, :name, :type, :limit, :precision, :scale, :default, :null) #:nodoc: - - def sql_type - base.type_to_sql(type.to_sym, limit, precision, scale) rescue type - end - - def to_sql - column_sql = "#{base.quote_column_name(name)} #{sql_type}" - column_options = {} - column_options[:null] = null unless null.nil? - column_options[:default] = default unless default.nil? - add_column_options!(column_sql, column_options) unless type.to_sym == :primary_key - column_sql - end - alias to_s :to_sql - - private - - def add_column_options!(sql, options) - base.add_column_options!(sql, options.merge(:column => self)) - end - end - - # Represents the schema of an SQL table in an abstract way. This class - # provides methods for manipulating the schema representation. - # - # Inside migration files, the +t+ object in +create_table+ and - # +change_table+ is actually of this type: - # - # class SomeMigration < ActiveRecord::Migration - # def self.up - # create_table :foo do |t| - # puts t.class # => "ActiveRecord::ConnectionAdapters::TableDefinition" - # end - # end - # - # def self.down - # ... - # end - # end - # - # The table definitions - # The Columns are stored as a ColumnDefinition in the +columns+ attribute. - class TableDefinition - # An array of ColumnDefinition objects, representing the column changes - # that have been defined. - attr_accessor :columns - - def initialize(base) - @columns = [] - @base = base - end - - # Appends a primary key definition to the table definition. - # Can be called multiple times, but this is probably not a good idea. - def primary_key(name) - column(name, :primary_key) - end - - # Returns a ColumnDefinition for the column with name +name+. - def [](name) - @columns.find {|column| column.name.to_s == name.to_s} - end - - # Instantiates a new column for the table. - # The +type+ parameter is normally one of the migrations native types, - # which is one of the following: - # <tt>:primary_key</tt>, <tt>:string</tt>, <tt>:text</tt>, - # <tt>:integer</tt>, <tt>:float</tt>, <tt>:decimal</tt>, - # <tt>:datetime</tt>, <tt>:timestamp</tt>, <tt>:time</tt>, - # <tt>:date</tt>, <tt>:binary</tt>, <tt>:boolean</tt>. - # - # You may use a type not in this list as long as it is supported by your - # database (for example, "polygon" in MySQL), but this will not be database - # agnostic and should usually be avoided. - # - # Available options are (none of these exists by default): - # * <tt>:limit</tt> - - # Requests a maximum column length. This is number of characters for <tt>:string</tt> and <tt>:text</tt> columns and number of bytes for :binary and :integer columns. - # * <tt>:default</tt> - - # The column's default value. Use nil for NULL. - # * <tt>:null</tt> - - # Allows or disallows +NULL+ values in the column. This option could - # have been named <tt>:null_allowed</tt>. - # * <tt>:precision</tt> - - # Specifies the precision for a <tt>:decimal</tt> column. - # * <tt>:scale</tt> - - # Specifies the scale for a <tt>:decimal</tt> column. - # - # For clarity's sake: the precision is the number of significant digits, - # while the scale is the number of digits that can be stored following - # the decimal point. For example, the number 123.45 has a precision of 5 - # and a scale of 2. A decimal with a precision of 5 and a scale of 2 can - # range from -999.99 to 999.99. - # - # Please be aware of different RDBMS implementations behavior with - # <tt>:decimal</tt> columns: - # * The SQL standard says the default scale should be 0, <tt>:scale</tt> <= - # <tt>:precision</tt>, and makes no comments about the requirements of - # <tt>:precision</tt>. - # * MySQL: <tt>:precision</tt> [1..63], <tt>:scale</tt> [0..30]. - # Default is (10,0). - # * PostgreSQL: <tt>:precision</tt> [1..infinity], - # <tt>:scale</tt> [0..infinity]. No default. - # * SQLite2: Any <tt>:precision</tt> and <tt>:scale</tt> may be used. - # Internal storage as strings. No default. - # * SQLite3: No restrictions on <tt>:precision</tt> and <tt>:scale</tt>, - # but the maximum supported <tt>:precision</tt> is 16. No default. - # * Oracle: <tt>:precision</tt> [1..38], <tt>:scale</tt> [-84..127]. - # Default is (38,0). - # * DB2: <tt>:precision</tt> [1..63], <tt>:scale</tt> [0..62]. - # Default unknown. - # * Firebird: <tt>:precision</tt> [1..18], <tt>:scale</tt> [0..18]. - # Default (9,0). Internal types NUMERIC and DECIMAL have different - # storage rules, decimal being better. - # * FrontBase?: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38]. - # Default (38,0). WARNING Max <tt>:precision</tt>/<tt>:scale</tt> for - # NUMERIC is 19, and DECIMAL is 38. - # * SqlServer?: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38]. - # Default (38,0). - # * Sybase: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38]. - # Default (38,0). - # * OpenBase?: Documentation unclear. Claims storage in <tt>double</tt>. - # - # This method returns <tt>self</tt>. - # - # == Examples - # # Assuming td is an instance of TableDefinition - # td.column(:granted, :boolean) - # # granted BOOLEAN - # - # td.column(:picture, :binary, :limit => 2.megabytes) - # # => picture BLOB(2097152) - # - # td.column(:sales_stage, :string, :limit => 20, :default => 'new', :null => false) - # # => sales_stage VARCHAR(20) DEFAULT 'new' NOT NULL - # - # td.column(:bill_gates_money, :decimal, :precision => 15, :scale => 2) - # # => bill_gates_money DECIMAL(15,2) - # - # td.column(:sensor_reading, :decimal, :precision => 30, :scale => 20) - # # => sensor_reading DECIMAL(30,20) - # - # # While <tt>:scale</tt> defaults to zero on most databases, it - # # probably wouldn't hurt to include it. - # td.column(:huge_integer, :decimal, :precision => 30) - # # => huge_integer DECIMAL(30) - # - # # Defines a column with a database-specific type. - # td.column(:foo, 'polygon') - # # => foo polygon - # - # == Short-hand examples - # - # Instead of calling +column+ directly, you can also work with the short-hand definitions for the default types. - # They use the type as the method name instead of as a parameter and allow for multiple columns to be defined - # in a single statement. - # - # What can be written like this with the regular calls to column: - # - # create_table "products", :force => true do |t| - # t.column "shop_id", :integer - # t.column "creator_id", :integer - # t.column "name", :string, :default => "Untitled" - # t.column "value", :string, :default => "Untitled" - # t.column "created_at", :datetime - # t.column "updated_at", :datetime - # end - # - # Can also be written as follows using the short-hand: - # - # create_table :products do |t| - # t.integer :shop_id, :creator_id - # t.string :name, :value, :default => "Untitled" - # t.timestamps - # end - # - # There's a short-hand method for each of the type values declared at the top. And then there's - # TableDefinition#timestamps that'll add created_at and +updated_at+ as datetimes. - # - # TableDefinition#references will add an appropriately-named _id column, plus a corresponding _type - # column if the <tt>:polymorphic</tt> option is supplied. If <tt>:polymorphic</tt> is a hash of options, these will be - # used when creating the <tt>_type</tt> column. So what can be written like this: - # - # create_table :taggings do |t| - # t.integer :tag_id, :tagger_id, :taggable_id - # t.string :tagger_type - # t.string :taggable_type, :default => 'Photo' - # end - # - # Can also be written as follows using references: - # - # create_table :taggings do |t| - # t.references :tag - # t.references :tagger, :polymorphic => true - # t.references :taggable, :polymorphic => { :default => 'Photo' } - # end - def column(name, type, options = {}) - column = self[name] || ColumnDefinition.new(@base, name, type) - if options[:limit] - column.limit = options[:limit] - elsif native[type.to_sym].is_a?(Hash) - column.limit = native[type.to_sym][:limit] - end - column.precision = options[:precision] - column.scale = options[:scale] - column.default = options[:default] - column.null = options[:null] - @columns << column unless @columns.include? column - self - end - - %w( string text integer float decimal datetime timestamp time date binary boolean ).each do |column_type| - class_eval <<-EOV - def #{column_type}(*args) # def string(*args) - options = args.extract_options! # options = args.extract_options! - column_names = args # column_names = args - # - column_names.each { |name| column(name, '#{column_type}', options) } # column_names.each { |name| column(name, 'string', options) } - end # end - EOV - end - - # Appends <tt>:datetime</tt> columns <tt>:created_at</tt> and - # <tt>:updated_at</tt> to the table. - def timestamps(*args) - options = args.extract_options! - column(:created_at, :datetime, options) - column(:updated_at, :datetime, options) - end - - def references(*args) - options = args.extract_options! - polymorphic = options.delete(:polymorphic) - args.each do |col| - column("#{col}_id", :integer, options) - column("#{col}_type", :string, polymorphic.is_a?(Hash) ? polymorphic : options) unless polymorphic.nil? - end - end - alias :belongs_to :references - - # Returns a String whose contents are the column definitions - # concatenated together. This string can then be prepended and appended to - # to generate the final SQL to create the table. - def to_sql - @columns * ', ' - end - - private - def native - @base.native_database_types - end - end - - # Represents a SQL table in an abstract way for updating a table. - # Also see TableDefinition and SchemaStatements#create_table - # - # Available transformations are: - # - # change_table :table do |t| - # t.column - # t.index - # t.timestamps - # t.change - # t.change_default - # t.rename - # t.references - # t.belongs_to - # t.string - # t.text - # t.integer - # t.float - # t.decimal - # t.datetime - # t.timestamp - # t.time - # t.date - # t.binary - # t.boolean - # t.remove - # t.remove_references - # t.remove_belongs_to - # t.remove_index - # t.remove_timestamps - # end - # - class Table - def initialize(table_name, base) - @table_name = table_name - @base = base - end - - # Adds a new column to the named table. - # See TableDefinition#column for details of the options you can use. - # ===== Example - # ====== Creating a simple column - # t.column(:name, :string) - def column(column_name, type, options = {}) - @base.add_column(@table_name, column_name, type, options) - end - - # Adds a new index to the table. +column_name+ can be a single Symbol, or - # an Array of Symbols. See SchemaStatements#add_index - # - # ===== Examples - # ====== Creating a simple index - # t.index(:name) - # ====== Creating a unique index - # t.index([:branch_id, :party_id], :unique => true) - # ====== Creating a named index - # t.index([:branch_id, :party_id], :unique => true, :name => 'by_branch_party') - def index(column_name, options = {}) - @base.add_index(@table_name, column_name, options) - end - - # Adds timestamps (created_at and updated_at) columns to the table. See SchemaStatements#add_timestamps - # ===== Example - # t.timestamps - def timestamps - @base.add_timestamps(@table_name) - end - - # Changes the column's definition according to the new options. - # See TableDefinition#column for details of the options you can use. - # ===== Examples - # t.change(:name, :string, :limit => 80) - # t.change(:description, :text) - def change(column_name, type, options = {}) - @base.change_column(@table_name, column_name, type, options) - end - - # Sets a new default value for a column. See SchemaStatements#change_column_default - # ===== Examples - # t.change_default(:qualification, 'new') - # t.change_default(:authorized, 1) - def change_default(column_name, default) - @base.change_column_default(@table_name, column_name, default) - end - - # Removes the column(s) from the table definition. - # ===== Examples - # t.remove(:qualification) - # t.remove(:qualification, :experience) - def remove(*column_names) - @base.remove_column(@table_name, column_names) - end - - # Removes the given index from the table. - # - # ===== Examples - # ====== Remove the suppliers_name_index in the suppliers table - # t.remove_index :name - # ====== Remove the index named accounts_branch_id_index in the accounts table - # t.remove_index :column => :branch_id - # ====== Remove the index named accounts_branch_id_party_id_index in the accounts table - # t.remove_index :column => [:branch_id, :party_id] - # ====== Remove the index named by_branch_party in the accounts table - # t.remove_index :name => :by_branch_party - def remove_index(options = {}) - @base.remove_index(@table_name, options) - end - - # Removes the timestamp columns (created_at and updated_at) from the table. - # ===== Example - # t.remove_timestamps - def remove_timestamps - @base.remove_timestamps(@table_name) - end - - # Renames a column. - # ===== Example - # t.rename(:description, :name) - def rename(column_name, new_column_name) - @base.rename_column(@table_name, column_name, new_column_name) - end - - # Adds a reference. Optionally adds a +type+ column. - # <tt>references</tt> and <tt>belongs_to</tt> are acceptable. - # ===== Examples - # t.references(:goat) - # t.references(:goat, :polymorphic => true) - # t.belongs_to(:goat) - def references(*args) - options = args.extract_options! - polymorphic = options.delete(:polymorphic) - args.each do |col| - @base.add_column(@table_name, "#{col}_id", :integer, options) - @base.add_column(@table_name, "#{col}_type", :string, polymorphic.is_a?(Hash) ? polymorphic : options) unless polymorphic.nil? - end - end - alias :belongs_to :references - - # Removes a reference. Optionally removes a +type+ column. - # <tt>remove_references</tt> and <tt>remove_belongs_to</tt> are acceptable. - # ===== Examples - # t.remove_references(:goat) - # t.remove_references(:goat, :polymorphic => true) - # t.remove_belongs_to(:goat) - def remove_references(*args) - options = args.extract_options! - polymorphic = options.delete(:polymorphic) - args.each do |col| - @base.remove_column(@table_name, "#{col}_id") - @base.remove_column(@table_name, "#{col}_type") unless polymorphic.nil? - end - end - alias :remove_belongs_to :remove_references - - # Adds a column or columns of a specified type - # ===== Examples - # t.string(:goat) - # t.string(:goat, :sheep) - %w( string text integer float decimal datetime timestamp time date binary boolean ).each do |column_type| - class_eval <<-EOV - def #{column_type}(*args) # def string(*args) - options = args.extract_options! # options = args.extract_options! - column_names = args # column_names = args - # - column_names.each do |name| # column_names.each do |name| - column = ColumnDefinition.new(@base, name, '#{column_type}') # column = ColumnDefinition.new(@base, name, 'string') - if options[:limit] # if options[:limit] - column.limit = options[:limit] # column.limit = options[:limit] - elsif native['#{column_type}'.to_sym].is_a?(Hash) # elsif native['string'.to_sym].is_a?(Hash) - column.limit = native['#{column_type}'.to_sym][:limit] # column.limit = native['string'.to_sym][:limit] - end # end - column.precision = options[:precision] # column.precision = options[:precision] - column.scale = options[:scale] # column.scale = options[:scale] - column.default = options[:default] # column.default = options[:default] - column.null = options[:null] # column.null = options[:null] - @base.add_column(@table_name, name, column.sql_type, options) # @base.add_column(@table_name, name, column.sql_type, options) - end # end - end # end - EOV - end - - private - def native - @base.native_database_types - end - end - - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb deleted file mode 100644 index c29c156..0000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ /dev/null @@ -1,434 +0,0 @@ -module ActiveRecord - module ConnectionAdapters # :nodoc: - module SchemaStatements - # Returns a Hash of mappings from the abstract data types to the native - # database types. See TableDefinition#column for details on the recognized - # abstract data types. - def native_database_types - {} - end - - # This is the maximum length a table alias can be - def table_alias_length - 255 - end - - # Truncates a table alias according to the limits of the current adapter. - def table_alias_for(table_name) - table_name[0..table_alias_length-1].gsub(/\./, '_') - end - - # def tables(name = nil) end - - def table_exists?(table_name) - tables.include?(table_name.to_s) - end - - # Returns an array of indexes for the given table. - # def indexes(table_name, name = nil) end - - # Returns an array of Column objects for the table specified by +table_name+. - # See the concrete implementation for details on the expected parameter values. - def columns(table_name, name = nil) end - - # Creates a new table with the name +table_name+. +table_name+ may either - # be a String or a Symbol. - # - # There are two ways to work with +create_table+. You can use the block - # form or the regular form, like this: - # - # === Block form - # # create_table() passes a TableDefinition object to the block. - # # This form will not only create the table, but also columns for the - # # table. - # create_table(:suppliers) do |t| - # t.column :name, :string, :limit => 60 - # # Other fields here - # end - # - # === Regular form - # # Creates a table called 'suppliers' with no columns. - # create_table(:suppliers) - # # Add a column to 'suppliers'. - # add_column(:suppliers, :name, :string, {:limit => 60}) - # - # The +options+ hash can include the following keys: - # [<tt>:id</tt>] - # Whether to automatically add a primary key column. Defaults to true. - # Join tables for +has_and_belongs_to_many+ should set <tt>:id => false</tt>. - # [<tt>:primary_key</tt>] - # The name of the primary key, if one is to be added automatically. - # Defaults to +id+. - # [<tt>:options</tt>] - # Any extra options you want appended to the table definition. - # [<tt>:temporary</tt>] - # Make a temporary table. - # [<tt>:force</tt>] - # Set to true to drop the table before creating it. - # Defaults to false. - # - # ===== Examples - # ====== Add a backend specific option to the generated SQL (MySQL) - # create_table(:suppliers, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8') - # generates: - # CREATE TABLE suppliers ( - # id int(11) DEFAULT NULL auto_increment PRIMARY KEY - # ) ENGINE=InnoDB DEFAULT CHARSET=utf8 - # - # ====== Rename the primary key column - # create_table(:objects, :primary_key => 'guid') do |t| - # t.column :name, :string, :limit => 80 - # end - # generates: - # CREATE TABLE objects ( - # guid int(11) DEFAULT NULL auto_increment PRIMARY KEY, - # name varchar(80) - # ) - # - # ====== Do not add a primary key column - # create_table(:categories_suppliers, :id => false) do |t| - # t.column :category_id, :integer - # t.column :supplier_id, :integer - # end - # generates: - # CREATE TABLE categories_suppliers ( - # category_id int, - # supplier_id int - # ) - # - # See also TableDefinition#column for details on how to create columns. - def create_table(table_name, options = {}) - table_definition = TableDefinition.new(self) - table_definition.primary_key(options[:primary_key] || Base.get_primary_key(table_name)) unless options[:id] == false - - yield table_definition - - if options[:force] && table_exists?(table_name) - drop_table(table_name, options) - end - - create_sql = "CREATE#{' TEMPORARY' if options[:temporary]} TABLE " - create_sql << "#{quote_table_name(table_name)} (" - create_sql << table_definition.to_sql - create_sql << ") #{options[:options]}" - execute create_sql - end - - # A block for changing columns in +table+. - # - # === Example - # # change_table() yields a Table instance - # change_table(:suppliers) do |t| - # t.column :name, :string, :limit => 60 - # # Other column alterations here - # end - # - # ===== Examples - # ====== Add a column - # change_table(:suppliers) do |t| - # t.column :name, :string, :limit => 60 - # end - # - # ====== Add 2 integer columns - # change_table(:suppliers) do |t| - # t.integer :width, :height, :null => false, :default => 0 - # end - # - # ====== Add created_at/updated_at columns - # change_table(:suppliers) do |t| - # t.timestamps - # end - # - # ====== Add a foreign key column - # change_table(:suppliers) do |t| - # t.references :company - # end - # - # Creates a <tt>company_id(integer)</tt> column - # - # ====== Add a polymorphic foreign key column - # change_table(:suppliers) do |t| - # t.belongs_to :company, :polymorphic => true - # end - # - # Creates <tt>company_type(varchar)</tt> and <tt>company_id(integer)</tt> columns - # - # ====== Remove a column - # change_table(:suppliers) do |t| - # t.remove :company - # end - # - # ====== Remove several columns - # change_table(:suppliers) do |t| - # t.remove :company_id - # t.remove :width, :height - # end - # - # ====== Remove an index - # change_table(:suppliers) do |t| - # t.remove_index :company_id - # end - # - # See also Table for details on - # all of the various column transformation - def change_table(table_name) - yield Table.new(table_name, self) - end - - # Renames a table. - # ===== Example - # rename_table('octopuses', 'octopi') - def rename_table(table_name, new_name) - raise NotImplementedError, "rename_table is not implemented" - end - - # Drops a table from the database. - def drop_table(table_name, options = {}) - execute "DROP TABLE #{quote_table_name(table_name)}" - end - - # Adds a new column to the named table. - # See TableDefinition#column for details of the options you can use. - def add_column(table_name, column_name, type, options = {}) - add_column_sql = "ALTER TABLE #{quote_table_name(table_name)} ADD #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}" - add_column_options!(add_column_sql, options) - execute(add_column_sql) - end - - # Removes the column(s) from the table definition. - # ===== Examples - # remove_column(:suppliers, :qualification) - # remove_columns(:suppliers, :qualification, :experience) - def remove_column(table_name, *column_names) - column_names.flatten.each do |column_name| - execute "ALTER TABLE #{quote_table_name(table_name)} DROP #{quote_column_name(column_name)}" - end - end - alias :remove_columns :remove_column - - # Changes the column's definition according to the new options. - # See TableDefinition#column for details of the options you can use. - # ===== Examples - # change_column(:suppliers, :name, :string, :limit => 80) - # change_column(:accounts, :description, :text) - def change_column(table_name, column_name, type, options = {}) - raise NotImplementedError, "change_column is not implemented" - end - - # Sets a new default value for a column. If you want to set the default - # value to +NULL+, you are out of luck. You need to - # DatabaseStatements#execute the appropriate SQL statement yourself. - # ===== Examples - # change_column_default(:suppliers, :qualification, 'new') - # change_column_default(:accounts, :authorized, 1) - def change_column_default(table_name, column_name, default) - raise NotImplementedError, "change_column_default is not implemented" - end - - # Renames a column. - # ===== Example - # rename_column(:suppliers, :description, :name) - def rename_column(table_name, column_name, new_column_name) - raise NotImplementedError, "rename_column is not implemented" - end - - # Adds a new index to the table. +column_name+ can be a single Symbol, or - # an Array of Symbols. - # - # The index will be named after the table and the first column name, - # unless you pass <tt>:name</tt> as an option. - # - # When creating an index on multiple columns, the first column is used as a name - # for the index. For example, when you specify an index on two columns - # [<tt>:first</tt>, <tt>:last</tt>], the DBMS creates an index for both columns as well as an - # index for the first column <tt>:first</tt>. Using just the first name for this index - # makes sense, because you will never have to create a singular index with this - # name. - # - # ===== Examples - # ====== Creating a simple index - # add_index(:suppliers, :name) - # generates - # CREATE INDEX suppliers_name_index ON suppliers(name) - # ====== Creating a unique index - # add_index(:accounts, [:branch_id, :party_id], :unique => true) - # generates - # CREATE UNIQUE INDEX accounts_branch_id_party_id_index ON accounts(branch_id, party_id) - # ====== Creating a named index - # add_index(:accounts, [:branch_id, :party_id], :unique => true, :name => 'by_branch_party') - # generates - # CREATE UNIQUE INDEX by_branch_party ON accounts(branch_id, party_id) - def add_index(table_name, column_name, options = {}) - column_names = Array(column_name) - index_name = index_name(table_name, :column => column_names) - - if Hash === options # legacy support, since this param was a string - index_type = options[:unique] ? "UNIQUE" : "" - index_name = options[:name] || index_name - else - index_type = options - end - quoted_column_names = column_names.map { |e| quote_column_name(e) }.join(", ") - execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} (#{quoted_column_names})" - end - - # Remove the given index from the table. - # - # Remove the suppliers_name_index in the suppliers table. - # remove_index :suppliers, :name - # Remove the index named accounts_branch_id_index in the accounts table. - # remove_index :accounts, :column => :branch_id - # Remove the index named accounts_branch_id_party_id_index in the accounts table. - # remove_index :accounts, :column => [:branch_id, :party_id] - # Remove the index named by_branch_party in the accounts table. - # remove_index :accounts, :name => :by_branch_party - def remove_index(table_name, options = {}) - execute "DROP INDEX #{quote_column_name(index_name(table_name, options))} ON #{table_name}" - end - - def index_name(table_name, options) #:nodoc: - if Hash === options # legacy support - if options[:column] - "index_#{table_name}_on_#{Array(options[:column]) * '_and_'}" - elsif options[:name] - options[:name] - else - raise ArgumentError, "You must specify the index name" - end - else - index_name(table_name, :column => options) - end - end - - # Returns a string of <tt>CREATE TABLE</tt> SQL statement(s) for recreating the - # entire structure of the database. - def structure_dump - end - - def dump_schema_information #:nodoc: - sm_table = ActiveRecord::Migrator.schema_migrations_table_name - migrated = select_values("SELECT version FROM #{sm_table}") - migrated.map { |v| "INSERT INTO #{sm_table} (version) VALUES ('#{v}');" }.join("\n\n") - end - - # Should not be called normally, but this operation is non-destructive. - # The migrations module handles this automatically. - def initialize_schema_migrations_table - sm_table = ActiveRecord::Migrator.schema_migrations_table_name - - unless tables.detect { |t| t == sm_table } - create_table(sm_table, :id => false) do |schema_migrations_table| - schema_migrations_table.column :version, :string, :null => false - end - add_index sm_table, :version, :unique => true, - :name => 'unique_schema_migrations' - - # Backwards-compatibility: if we find schema_info, assume we've - # migrated up to that point: - si_table = Base.table_name_prefix + 'schema_info' + Base.table_name_suffix - - if tables.detect { |t| t == si_table } - - old_version = select_value("SELECT version FROM #{quote_table_name(si_table)}").to_i - assume_migrated_upto_version(old_version) - drop_table(si_table) - end - end - end - - def assume_migrated_upto_version(version) - version = version.to_i - sm_table = quote_table_name(ActiveRecord::Migrator.schema_migrations_table_name) - - migrated = select_values("SELECT version FROM #{sm_table}").map(&:to_i) - versions = Dir['db/migrate/[0-9]*_*.rb'].map do |filename| - filename.split('/').last.split('_').first.to_i - end - - unless migrated.include?(version) - execute "INSERT INTO #{sm_table} (version) VALUES ('#{version}')" - end - - inserted = Set.new - (versions - migrated).each do |v| - if inserted.include?(v) - raise "Duplicate migration #{v}. Please renumber your migrations to resolve the conflict." - elsif v < version - execute "INSERT INTO #{sm_table} (version) VALUES ('#{v}')" - inserted << v - end - end - end - - def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc: - if native = native_database_types[type] - column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup - - if type == :decimal # ignore limit, use precision and scale - scale ||= native[:scale] - - if precision ||= native[:precision] - if scale - column_type_sql << "(#{precision},#{scale})" - else - column_type_sql << "(#{precision})" - end - elsif scale - raise ArgumentError, "Error adding decimal column: precision cannot be empty if scale if specified" - end - - elsif (type != :primary_key) && (limit ||= native.is_a?(Hash) && native[:limit]) - column_type_sql << "(#{limit})" - end - - column_type_sql - else - type - end - end - - def add_column_options!(sql, options) #:nodoc: - sql << " DEFAULT #{quote(options[:default], options[:column])}" if options_include_default?(options) - # must explicitly check for :null to allow change_column to work on migrations - if options[:null] == false - sql << " NOT NULL" - end - end - - # SELECT DISTINCT clause for a given set of columns and a given ORDER BY clause. - # Both PostgreSQL and Oracle overrides this for custom DISTINCT syntax. - # - # distinct("posts.id", "posts.created_at desc") - def distinct(columns, order_by) - "DISTINCT #{columns}" - end - - # ORDER BY clause for the passed order option. - # PostgreSQL overrides this due to its stricter standards compliance. - def add_order_by_for_association_limiting!(sql, options) - sql << " ORDER BY #{options[:order]}" - end - - # Adds timestamps (created_at and updated_at) columns to the named table. - # ===== Examples - # add_timestamps(:suppliers) - def add_timestamps(table_name) - add_column table_name, :created_at, :datetime - add_column table_name, :updated_at, :datetime - end - - # Removes the timestamp columns (created_at and updated_at) from the table definition. - # ===== Examples - # remove_timestamps(:suppliers) - def remove_timestamps(table_name) - remove_column table_name, :updated_at - remove_column table_name, :created_at - end - - protected - def options_include_default?(options) - options.include?(:default) && !(options[:null] == false && options[:default].nil?) - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb deleted file mode 100755 index a8cd9f0..0000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ /dev/null @@ -1,234 +0,0 @@ -require 'benchmark' -require 'date' -require 'bigdecimal' -require 'bigdecimal/util' - -# TODO: Autoload these files -require 'active_record/connection_adapters/abstract/schema_definitions' -require 'active_record/connection_adapters/abstract/schema_statements' -require 'active_record/connection_adapters/abstract/database_statements' -require 'active_record/connection_adapters/abstract/quoting' -require 'active_record/connection_adapters/abstract/connection_pool' -require 'active_record/connection_adapters/abstract/connection_specification' -require 'active_record/connection_adapters/abstract/query_cache' - -module ActiveRecord - module ConnectionAdapters # :nodoc: - # ActiveRecord supports multiple database systems. AbstractAdapter and - # related classes form the abstraction layer which makes this possible. - # An AbstractAdapter represents a connection to a database, and provides an - # abstract interface for database-specific functionality such as establishing - # a connection, escaping values, building the right SQL fragments for ':offset' - # and ':limit' options, etc. - # - # All the concrete database adapters follow the interface laid down in this class. - # ActiveRecord::Base.connection returns an AbstractAdapter object, which - # you can use. - # - # Most of the methods in the adapter are useful during migrations. Most - # notably, the instance methods provided by SchemaStatement are very useful. - class AbstractAdapter - include Quoting, DatabaseStatements, SchemaStatements - include QueryCache - include ActiveSupport::Callbacks - define_callbacks :checkout, :checkin - - @@row_even = true - - def initialize(connection, logger = nil) #:nodoc: - @connection, @logger = connection, logger - @runtime = 0 - @last_verification = 0 - @query_cache_enabled = false - end - - # Returns the human-readable name of the adapter. Use mixed case - one - # can always use downcase if needed. - def adapter_name - 'Abstract' - end - - # Does this adapter support migrations? Backend specific, as the - # abstract adapter always returns +false+. - def supports_migrations? - false - end - - # Does this adapter support using DISTINCT within COUNT? This is +true+ - # for all adapters except sqlite. - def supports_count_distinct? - true - end - - # Does this adapter support DDL rollbacks in transactions? That is, would - # CREATE TABLE or ALTER TABLE get rolled back by a transaction? PostgreSQL, - # SQL Server, and others support this. MySQL and others do not. - def supports_ddl_transactions? - false - end - - # Does this adapter support savepoints? PostgreSQL and MySQL do, SQLite - # does not. - def supports_savepoints? - false - end - - # Should primary key values be selected from their corresponding - # sequence before the insert statement? If true, next_sequence_value - # is called before each insert to set the record's primary key. - # This is false for all adapters but Firebird. - def prefetch_primary_key?(table_name = nil) - false - end - - def reset_runtime #:nodoc: - rt, @runtime = @runtime, 0 - rt - end - - # QUOTING ================================================== - - # Override to return the quoted table name. Defaults to column quoting. - def quote_table_name(name) - quote_column_name(name) - end - - # REFERENTIAL INTEGRITY ==================================== - - # Override to turn off referential integrity while executing <tt>&block</tt>. - def disable_referential_integrity(&block) - yield - end - - # CONNECTION MANAGEMENT ==================================== - - # Checks whether the connection to the database is still active. This includes - # checking whether the database is actually capable of responding, i.e. whether - # the connection isn't stale. - def active? - @active != false - end - - # Disconnects from the database if already connected, and establishes a - # new connection with the database. - def reconnect! - @active = true - end - - # Disconnects from the database if already connected. Otherwise, this - # method does nothing. - def disconnect! - @active = false - end - - # Reset the state of this connection, directing the DBMS to clear - # transactions and other connection-related server-side state. Usually a - # database-dependent operation. - # - # The default implementation does nothing; the implementation should be - # overridden by concrete adapters. - def reset! - # this should be overridden by concrete adapters - end - - # Returns true if its safe to reload the connection between requests for development mode. - def requires_reloading? - true - end - - # Checks whether the connection to the database is still active (i.e. not stale). - # This is done under the hood by calling <tt>active?</tt>. If the connection - # is no longer active, then this method will reconnect to the database. - def verify!(*ignored) - reconnect! unless active? - end - - # Provides access to the underlying database driver for this adapter. For - # example, this method returns a Mysql object in case of MysqlAdapter, - # and a PGconn object in case of PostgreSQLAdapter. - # - # This is useful for when you need to call a proprietary method such as - # PostgreSQL's lo_* methods. - def raw_connection - @connection - end - - def open_transactions - @open_transactions ||= 0 - end - - def increment_open_transactions - @open_transactions ||= 0 - @open_transactions += 1 - end - - def decrement_open_transactions - @open_transactions -= 1 - end - - def transaction_joinable=(joinable) - @transaction_joinable = joinable - end - - def create_savepoint - end - - def rollback_to_savepoint - end - - def release_savepoint - end - - def current_savepoint_name - "active_record_#{open_transactions}" - end - - def log_info(sql, name, ms) - if @logger && @logger.debug? - name = '%s (%.1fms)' % [name || 'SQL', ms] - @logger.debug(format_log_entry(name, sql.squeeze(' '))) - end - end - - protected - def log(sql, name) - if block_given? - result = nil - ms = Benchmark.ms { result = yield } - @runtime += ms - log_info(sql, name, ms) - result - else - log_info(sql, name, 0) - nil - end - rescue Exception => e - # Log message and raise exception. - # Set last_verification to 0, so that connection gets verified - # upon reentering the request loop - @last_verification = 0 - message = "#{e.class.name}: #{e.message}: #{sql}" - log_info(message, name, 0) - raise ActiveRecord::StatementInvalid, message - end - - def format_log_entry(message, dump = nil) - if ActiveRecord::Base.colorize_logging - if @@row_even - @@row_even = false - message_color, dump_color = "4;36;1", "0;1" - else - @@row_even = true - message_color, dump_color = "4;35;1", "0" - end - - log_entry = " \e[#{message_color}m#{message}\e[0m " - log_entry << "\e[#{dump_color}m%#{String === dump ? 's' : 'p'}\e[0m" % dump if dump - log_entry - else - "%s %s" % [message, dump] - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb deleted file mode 100644 index 9300df2..0000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ /dev/null @@ -1,617 +0,0 @@ -require 'active_record/connection_adapters/abstract_adapter' -require 'set' - -module MysqlCompat #:nodoc: - # add all_hashes method to standard mysql-c bindings or pure ruby version - def self.define_all_hashes_method! - raise 'Mysql not loaded' unless defined?(::Mysql) - - target = defined?(Mysql::Result) ? Mysql::Result : MysqlRes - return if target.instance_methods.include?('all_hashes') - - # Ruby driver has a version string and returns null values in each_hash - # C driver >= 2.7 returns null values in each_hash - if Mysql.const_defined?(:VERSION) && (Mysql::VERSION.is_a?(String) || Mysql::VERSION >= 20700) - target.class_eval <<-'end_eval' - def all_hashes # def all_hashes - rows = [] # rows = [] - each_hash { |row| rows << row } # each_hash { |row| rows << row } - rows # rows - end # end - end_eval - - # adapters before 2.7 don't have a version constant - # and don't return null values in each_hash - else - target.class_eval <<-'end_eval' - def all_hashes # def all_hashes - rows = [] # rows = [] - all_fields = fetch_fields.inject({}) { |fields, f| # all_fields = fetch_fields.inject({}) { |fields, f| - fields[f.name] = nil; fields # fields[f.name] = nil; fields - } # } - each_hash { |row| rows << all_fields.dup.update(row) } # each_hash { |row| rows << all_fields.dup.update(row) } - rows # rows - end # end - end_eval - end - - unless target.instance_methods.include?('all_hashes') || - target.instance_methods.include?(:all_hashes) - raise "Failed to defined #{target.name}#all_hashes method. Mysql::VERSION = #{Mysql::VERSION.inspect}" - end - end -end - -module ActiveRecord - class Base - # Establishes a connection to the database that's used by all Active Record objects. - def self.mysql_connection(config) # :nodoc: - config = config.symbolize_keys - host = config[:host] - port = config[:port] - socket = config[:socket] - username = config[:username] ? config[:username].to_s : 'root' - password = config[:password].to_s - - if config.has_key?(:database) - database = config[:database] - else - raise ArgumentError, "No database specified. Missing argument: database." - end - - # Require the MySQL driver and define Mysql::Result.all_hashes - unless defined? Mysql - begin - require_library_or_gem('mysql') - rescue LoadError - $stderr.puts '!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.' - raise - end - end - MysqlCompat.define_all_hashes_method! - - mysql = Mysql.init - mysql.ssl_set(config[:sslkey], config[:sslcert], config[:sslca], config[:sslcapath], config[:sslcipher]) if config[:sslca] || config[:sslkey] - - ConnectionAdapters::MysqlAdapter.new(mysql, logger, [host, username, password, database, port, socket], config) - end - end - - module ConnectionAdapters - class MysqlColumn < Column #:nodoc: - def extract_default(default) - if type == :binary || type == :text - if default.blank? - return null ? nil : '' - else - raise ArgumentError, "#{type} columns cannot have a default value: #{default.inspect}" - end - elsif missing_default_forged_as_empty_string?(default) - nil - else - super - end - end - - def has_default? - return false if type == :binary || type == :text #mysql forbids defaults on blob and text columns - super - end - - private - def simplified_type(field_type) - return :boolean if MysqlAdapter.emulate_booleans && field_type.downcase.index("tinyint(1)") - return :string if field_type =~ /enum/i - super - end - - def extract_limit(sql_type) - case sql_type - when /blob|text/i - case sql_type - when /tiny/i - 255 - when /medium/i - 16777215 - when /long/i - 2147483647 # mysql only allows 2^31-1, not 2^32-1, somewhat inconsistently with the tiny/medium/normal cases - else - super # we could return 65535 here, but we leave it undecorated by default - end - when /^bigint/i; 8 - when /^int/i; 4 - when /^mediumint/i; 3 - when /^smallint/i; 2 - when /^tinyint/i; 1 - else - super - end - end - - # MySQL misreports NOT NULL column default when none is given. - # We can't detect this for columns which may have a legitimate '' - # default (string) but we can for others (integer, datetime, boolean, - # and the rest). - # - # Test whether the column has default '', is not null, and is not - # a type allowing default ''. - def missing_default_forged_as_empty_string?(default) - type != :string && !null && default == '' - end - end - - # The MySQL adapter will work with both Ruby/MySQL, which is a Ruby-based MySQL adapter that comes bundled with Active Record, and with - # the faster C-based MySQL/Ruby adapter (available both as a gem and from http://www.tmtm.org/en/mysql/ruby/). - # - # Options: - # - # * <tt>:host</tt> - Defaults to "localhost". - # * <tt>:port</tt> - Defaults to 3306. - # * <tt>:socket</tt> - Defaults to "/tmp/mysql.sock". - # * <tt>:username</tt> - Defaults to "root" - # * <tt>:password</tt> - Defaults to nothing. - # * <tt>:database</tt> - The name of the database. No default, must be provided. - # * <tt>:encoding</tt> - (Optional) Sets the client encoding by executing "SET NAMES <encoding>" after connection. - # * <tt>:reconnect</tt> - Defaults to false (See MySQL documentation: http://dev.mysql.com/doc/refman/5.0/en/auto-reconnect.html). - # * <tt>:sslca</tt> - Necessary to use MySQL with an SSL connection. - # * <tt>:sslkey</tt> - Necessary to use MySQL with an SSL connection. - # * <tt>:sslcert</tt> - Necessary to use MySQL with an SSL connection. - # * <tt>:sslcapath</tt> - Necessary to use MySQL with an SSL connection. - # * <tt>:sslcipher</tt> - Necessary to use MySQL with an SSL connection. - # - class MysqlAdapter < AbstractAdapter - - ## - # :singleton-method: - # By default, the MysqlAdapter will consider all columns of type <tt>tinyint(1)</tt> - # as boolean. If you wish to disable this emulation (which was the default - # behavior in versions 0.13.1 and earlier) you can add the following line - # to your environment.rb file: - # - # ActiveRecord::ConnectionAdapters::MysqlAdapter.emulate_booleans = false - cattr_accessor :emulate_booleans - self.emulate_booleans = true - - ADAPTER_NAME = 'MySQL'.freeze - - LOST_CONNECTION_ERROR_MESSAGES = [ - "Server shutdown in progress", - "Broken pipe", - "Lost connection to MySQL server during query", - "MySQL server has gone away" ] - - QUOTED_TRUE, QUOTED_FALSE = '1'.freeze, '0'.freeze - - NATIVE_DATABASE_TYPES = { - :primary_key => "int(11) DEFAULT NULL auto_increment PRIMARY KEY".freeze, - :string => { :name => "varchar", :limit => 255 }, - :text => { :name => "text" }, - :integer => { :name => "int", :limit => 4 }, - :float => { :name => "float" }, - :decimal => { :name => "decimal" }, - :datetime => { :name => "datetime" }, - :timestamp => { :name => "datetime" }, - :time => { :name => "time" }, - :date => { :name => "date" }, - :binary => { :name => "blob" }, - :boolean => { :name => "tinyint", :limit => 1 } - } - - def initialize(connection, logger, connection_options, config) - super(connection, logger) - @connection_options, @config = connection_options, config - @quoted_column_names, @quoted_table_names = {}, {} - connect - end - - def adapter_name #:nodoc: - ADAPTER_NAME - end - - def supports_migrations? #:nodoc: - true - end - - def supports_savepoints? #:nodoc: - true - end - - def native_database_types #:nodoc: - NATIVE_DATABASE_TYPES - end - - - # QUOTING ================================================== - - def quote(value, column = nil) - if value.kind_of?(String) && column && column.type == :binary && column.class.respond_to?(:string_to_binary) - s = column.class.string_to_binary(value).unpack("H*")[0] - "x'#{s}'" - elsif value.kind_of?(BigDecimal) - value.to_s("F") - else - super - end - end - - def quote_column_name(name) #:nodoc: - @quoted_column_names[name] ||= "`#{name}`" - end - - def quote_table_name(name) #:nodoc: - @quoted_table_names[name] ||= quote_column_name(name).gsub('.', '`.`') - end - - def quote_string(string) #:nodoc: - @connection.quote(string) - end - - def quoted_true - QUOTED_TRUE - end - - def quoted_false - QUOTED_FALSE - end - - # REFERENTIAL INTEGRITY ==================================== - - def disable_referential_integrity(&block) #:nodoc: - old = select_value("SELECT @@FOREIGN_KEY_CHECKS") - - begin - update("SET FOREIGN_KEY_CHECKS = 0") - yield - ensure - update("SET FOREIGN_KEY_CHECKS = #{old}") - end - end - - # CONNECTION MANAGEMENT ==================================== - - def active? - if @connection.respond_to?(:stat) - @connection.stat - else - @connection.query 'select 1' - end - - # mysql-ruby doesn't raise an exception when stat fails. - if @connection.respond_to?(:errno) - @connection.errno.zero? - else - true - end - rescue Mysql::Error - false - end - - def reconnect! - disconnect! - connect - end - - def disconnect! - @connection.close rescue nil - end - - def reset! - if @connection.respond_to?(:change_user) - # See http://bugs.mysql.com/bug.php?id=33540 -- the workaround way to - # reset the connection is to change the user to the same user. - @connection.change_user(@config[:username], @config[:password], @config[:database]) - configure_connection - end - end - - # DATABASE STATEMENTS ====================================== - - def select_rows(sql, name = nil) - @connection.query_with_result = true - result = execute(sql, name) - rows = [] - result.each { |row| rows << row } - result.free - rows - end - - # Executes a SQL query and returns a MySQL::Result object. Note that you have to free the Result object after you're done using it. - def execute(sql, name = nil) #:nodoc: - log(sql, name) { @connection.query(sql) } - rescue ActiveRecord::StatementInvalid => exception - if exception.message.split(":").first =~ /Packets out of order/ - raise ActiveRecord::StatementInvalid, "'Packets out of order' error was received from the database. Please update your mysql bindings (gem install mysql) and read http://dev.mysql.com/doc/mysql/en/password-hashing.html for more information. If you're on Windows, use the Instant Rails installer to get the updated mysql bindings." - else - raise - end - end - - def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) #:nodoc: - super sql, name - id_value || @connection.insert_id - end - - def update_sql(sql, name = nil) #:nodoc: - super - @connection.affected_rows - end - - def begin_db_transaction #:nodoc: - execute "BEGIN" - rescue Exception - # Transactions aren't supported - end - - def commit_db_transaction #:nodoc: - execute "COMMIT" - rescue Exception - # Transactions aren't supported - end - - def rollback_db_transaction #:nodoc: - execute "ROLLBACK" - rescue Exception - # Transactions aren't supported - end - - def create_savepoint - execute("SAVEPOINT #{current_savepoint_name}") - end - - def rollback_to_savepoint - execute("ROLLBACK TO SAVEPOINT #{current_savepoint_name}") - end - - def release_savepoint - execute("RELEASE SAVEPOINT #{current_savepoint_name}") - end - - def add_limit_offset!(sql, options) #:nodoc: - if limit = options[:limit] - limit = sanitize_limit(limit) - unless offset = options[:offset] - sql << " LIMIT #{limit}" - else - sql << " LIMIT #{offset.to_i}, #{limit}" - end - end - end - - - # SCHEMA STATEMENTS ======================================== - - def structure_dump #:nodoc: - if supports_views? - sql = "SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'" - else - sql = "SHOW TABLES" - end - - select_all(sql).inject("") do |structure, table| - table.delete('Table_type') - structure += select_one("SHOW CREATE TABLE #{quote_table_name(table.to_a.first.last)}")["Create Table"] + ";\n\n" - end - end - - def recreate_database(name, options = {}) #:nodoc: - drop_database(name) - create_database(name, options) - end - - # Create a new MySQL database with optional <tt>:charset</tt> and <tt>:collation</tt>. - # Charset defaults to utf8. - # - # Example: - # create_database 'charset_test', :charset => 'latin1', :collation => 'latin1_bin' - # create_database 'matt_development' - # create_database 'matt_development', :charset => :big5 - def create_database(name, options = {}) - if options[:collation] - execute "CREATE DATABASE `#{name}` DEFAULT CHARACTER SET `#{options[:charset] || 'utf8'}` COLLATE `#{options[:collation]}`" - else - execute "CREATE DATABASE `#{name}` DEFAULT CHARACTER SET `#{options[:charset] || 'utf8'}`" - end - end - - def drop_database(name) #:nodoc: - execute "DROP DATABASE IF EXISTS `#{name}`" - end - - def current_database - select_value 'SELECT DATABASE() as db' - end - - # Returns the database character set. - def charset - show_variable 'character_set_database' - end - - # Returns the database collation strategy. - def collation - show_variable 'collation_database' - end - - def tables(name = nil) #:nodoc: - tables = [] - result = execute("SHOW TABLES", name) - result.each { |field| tables << field[0] } - result.free - tables - end - - def drop_table(table_name, options = {}) - super(table_name, options) - end - - def indexes(table_name, name = nil)#:nodoc: - indexes = [] - current_index = nil - result = execute("SHOW KEYS FROM #{quote_table_name(table_name)}", name) - result.each do |row| - if current_index != row[2] - next if row[2] == "PRIMARY" # skip the primary key - current_index = row[2] - indexes << IndexDefinition.new(row[0], row[2], row[1] == "0", []) - end - - indexes.last.columns << row[4] - end - result.free - indexes - end - - def columns(table_name, name = nil)#:nodoc: - sql = "SHOW FIELDS FROM #{quote_table_name(table_name)}" - columns = [] - result = execute(sql, name) - result.each { |field| columns << MysqlColumn.new(field[0], field[4], field[1], field[2] == "YES") } - result.free - columns - end - - def create_table(table_name, options = {}) #:nodoc: - super(table_name, options.reverse_merge(:options => "ENGINE=InnoDB")) - end - - def rename_table(table_name, new_name) - execute "RENAME TABLE #{quote_table_name(table_name)} TO #{quote_table_name(new_name)}" - end - - def change_column_default(table_name, column_name, default) #:nodoc: - column = column_for(table_name, column_name) - change_column table_name, column_name, column.sql_type, :default => default - end - - def change_column_null(table_name, column_name, null, default = nil) - column = column_for(table_name, column_name) - - unless null || default.nil? - execute("UPDATE #{quote_table_name(table_name)} SET #{quote_column_name(column_name)}=#{quote(default)} WHERE #{quote_column_name(column_name)} IS NULL") - end - - change_column table_name, column_name, column.sql_type, :null => null - end - - def change_column(table_name, column_name, type, options = {}) #:nodoc: - column = column_for(table_name, column_name) - - unless options_include_default?(options) - options[:default] = column.default - end - - unless options.has_key?(:null) - options[:null] = column.null - end - - change_column_sql = "ALTER TABLE #{quote_table_name(table_name)} CHANGE #{quote_column_name(column_name)} #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}" - add_column_options!(change_column_sql, options) - execute(change_column_sql) - end - - def rename_column(table_name, column_name, new_column_name) #:nodoc: - options = {} - if column = columns(table_name).find { |c| c.name == column_name.to_s } - options[:default] = column.default - options[:null] = column.null - else - raise ActiveRecordError, "No such column: #{table_name}.#{column_name}" - end - current_type = select_one("SHOW COLUMNS FROM #{quote_table_name(table_name)} LIKE '#{column_name}'")["Type"] - rename_column_sql = "ALTER TABLE #{quote_table_name(table_name)} CHANGE #{quote_column_name(column_name)} #{quote_column_name(new_column_name)} #{current_type}" - add_column_options!(rename_column_sql, options) - execute(rename_column_sql) - end - - # Maps logical Rails types to MySQL-specific data types. - def type_to_sql(type, limit = nil, precision = nil, scale = nil) - return super unless type.to_s == 'integer' - - case limit - when 1; 'tinyint' - when 2; 'smallint' - when 3; 'mediumint' - when nil, 4, 11; 'int(11)' # compatibility with MySQL default - when 5..8; 'bigint' - else raise(ActiveRecordError, "No integer type has byte size #{limit}") - end - end - - - # SHOW VARIABLES LIKE 'name' - def show_variable(name) - variables = select_all("SHOW VARIABLES LIKE '#{name}'") - variables.first['Value'] unless variables.empty? - end - - # Returns a table's primary key and belonging sequence. - def pk_and_sequence_for(table) #:nodoc: - keys = [] - result = execute("describe #{quote_table_name(table)}") - result.each_hash do |h| - keys << h["Field"]if h["Key"] == "PRI" - end - result.free - keys.length == 1 ? [keys.first, nil] : nil - end - - def case_sensitive_equality_operator - "= BINARY" - end - - def limited_update_conditions(where_sql, quoted_table_name, quoted_primary_key) - where_sql - end - - private - def connect - encoding = @config[:encoding] - if encoding - @connection.options(Mysql::SET_CHARSET_NAME, encoding) rescue nil - end - - if @config[:sslca] || @config[:sslkey] - @connection.ssl_set(@config[:sslkey], @config[:sslcert], @config[:sslca], @config[:sslcapath], @config[:sslcipher]) - end - - @connection.real_connect(*@connection_options) - - # reconnect must be set after real_connect is called, because real_connect sets it to false internally - @connection.reconnect = !!@config[:reconnect] if @connection.respond_to?(:reconnect=) - - configure_connection - end - - def configure_connection - encoding = @config[:encoding] - execute("SET NAMES '#{encoding}'") if encoding - - # By default, MySQL 'where id is null' selects the last inserted id. - # Turn this off. http://dev.rubyonrails.org/ticket/6778 - execute("SET SQL_AUTO_IS_NULL=0") - end - - def select(sql, name = nil) - @connection.query_with_result = true - result = execute(sql, name) - rows = result.all_hashes - result.free - rows - end - - def supports_views? - version[0] >= 5 - end - - def version - @version ||= @connection.server_info.scan(/^(\d+)\.(\d+)\.(\d+)/).flatten.map { |v| v.to_i } - end - - def column_for(table_name, column_name) - unless column = columns(table_name).find { |c| c.name == column_name.to_s } - raise "No such column: #{table_name}.#{column_name}" - end - column - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb deleted file mode 100644 index 913bb52..0000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ /dev/null @@ -1,1050 +0,0 @@ -require 'active_record/connection_adapters/abstract_adapter' - -begin - require_library_or_gem 'pg' -rescue LoadError => e - begin - require_library_or_gem 'postgres' - class PGresult - alias_method :nfields, :num_fields unless self.method_defined?(:nfields) - alias_method :ntuples, :num_tuples unless self.method_defined?(:ntuples) - alias_method :ftype, :type unless self.method_defined?(:ftype) - alias_method :cmd_tuples, :cmdtuples unless self.method_defined?(:cmd_tuples) - end - rescue LoadError - raise e - end -end - -module ActiveRecord - class Base - # Establishes a connection to the database that's used by all Active Record objects - def self.postgresql_connection(config) # :nodoc: - config = config.symbolize_keys - host = config[:host] - port = config[:port] || 5432 - username = config[:username].to_s if config[:username] - password = config[:password].to_s if config[:password] - - if config.has_key?(:database) - database = config[:database] - else - raise ArgumentError, "No database specified. Missing argument: database." - end - - # The postgres drivers don't allow the creation of an unconnected PGconn object, - # so just pass a nil connection object for the time being. - ConnectionAdapters::PostgreSQLAdapter.new(nil, logger, [host, port, nil, nil, database, username, password], config) - end - end - - module ConnectionAdapters - # PostgreSQL-specific extensions to column definitions in a table. - class PostgreSQLColumn < Column #:nodoc: - # Instantiates a new PostgreSQL column definition in a table. - def initialize(name, default, sql_type = nil, null = true) - super(name, self.class.extract_value_from_default(default), sql_type, null) - end - - private - def extract_limit(sql_type) - case sql_type - when /^bigint/i; 8 - when /^smallint/i; 2 - else super - end - end - - # Extracts the scale from PostgreSQL-specific data types. - def extract_scale(sql_type) - # Money type has a fixed scale of 2. - sql_type =~ /^money/ ? 2 : super - end - - # Extracts the precision from PostgreSQL-specific data types. - def extract_precision(sql_type) - # Actual code is defined dynamically in PostgreSQLAdapter.connect - # depending on the server specifics - super - end - - # Maps PostgreSQL-specific data types to logical Rails types. - def simplified_type(field_type) - case field_type - # Numeric and monetary types - when /^(?:real|double precision)$/ - :float - # Monetary types - when /^money$/ - :decimal - # Character types - when /^(?:character varying|bpchar)(?:\(\d+\))?$/ - :string - # Binary data types - when /^bytea$/ - :binary - # Date/time types - when /^timestamp with(?:out)? time zone$/ - :datetime - when /^interval$/ - :string - # Geometric types - when /^(?:point|line|lseg|box|"?path"?|polygon|circle)$/ - :string - # Network address types - when /^(?:cidr|inet|macaddr)$/ - :string - # Bit strings - when /^bit(?: varying)?(?:\(\d+\))?$/ - :string - # XML type - when /^xml$/ - :string - # Arrays - when /^\D+\[\]$/ - :string - # Object identifier types - when /^oid$/ - :integer - # Pass through all types that are not specific to PostgreSQL. - else - super - end - end - - # Extracts the value from a PostgreSQL column default definition. - def self.extract_value_from_default(default) - case default - # Numeric types - when /\A\(?(-?\d+(\.\d*)?\)?)\z/ - $1 - # Character types - when /\A'(.*)'::(?:character varying|bpchar|text)\z/m - $1 - # Character types (8.1 formatting) - when /\AE'(.*)'::(?:character varying|bpchar|text)\z/m - $1.gsub(/\\(\d\d\d)/) { $1.oct.chr } - # Binary data types - when /\A'(.*)'::bytea\z/m - $1 - # Date/time types - when /\A'(.+)'::(?:time(?:stamp)? with(?:out)? time zone|date)\z/ - $1 - when /\A'(.*)'::interval\z/ - $1 - # Boolean type - when 'true' - true - when 'false' - false - # Geometric types - when /\A'(.*)'::(?:point|line|lseg|box|"?path"?|polygon|circle)\z/ - $1 - # Network address types - when /\A'(.*)'::(?:cidr|inet|macaddr)\z/ - $1 - # Bit string types - when /\AB'(.*)'::"?bit(?: varying)?"?\z/ - $1 - # XML type - when /\A'(.*)'::xml\z/m - $1 - # Arrays - when /\A'(.*)'::"?\D+"?\[\]\z/ - $1 - # Object identifier types - when /\A-?\d+\z/ - $1 - else - # Anything else is blank, some user type, or some function - # and we can't know the value of that, so return nil. - nil - end - end - end - end - - module ConnectionAdapters - # The PostgreSQL adapter works both with the native C (http://ruby.scripting.ca/postgres/) and the pure - # Ruby (available both as gem and from http://rubyforge.org/frs/?group_id=234&release_id=1944) drivers. - # - # Options: - # - # * <tt>:host</tt> - Defaults to "localhost". - # * <tt>:port</tt> - Defaults to 5432. - # * <tt>:username</tt> - Defaults to nothing. - # * <tt>:password</tt> - Defaults to nothing. - # * <tt>:database</tt> - The name of the database. No default, must be provided. - # * <tt>:schema_search_path</tt> - An optional schema search path for the connection given as a string of comma-separated schema names. This is backward-compatible with the <tt>:schema_order</tt> option. - # * <tt>:encoding</tt> - An optional client encoding that is used in a <tt>SET client_encoding TO <encoding></tt> call on the connection. - # * <tt>:min_messages</tt> - An optional client min messages that is used in a <tt>SET client_min_messages TO <min_messages></tt> call on the connection. - # * <tt>:allow_concurrency</tt> - If true, use async query methods so Ruby threads don't deadlock; otherwise, use blocking query methods. - class PostgreSQLAdapter < AbstractAdapter - ADAPTER_NAME = 'PostgreSQL'.freeze - - NATIVE_DATABASE_TYPES = { - :primary_key => "serial primary key".freeze, - :string => { :name => "character varying", :limit => 255 }, - :text => { :name => "text" }, - :integer => { :name => "integer" }, - :float => { :name => "float" }, - :decimal => { :name => "decimal" }, - :datetime => { :name => "timestamp" }, - :timestamp => { :name => "timestamp" }, - :time => { :name => "time" }, - :date => { :name => "date" }, - :binary => { :name => "bytea" }, - :boolean => { :name => "boolean" } - } - - # Returns 'PostgreSQL' as adapter name for identification purposes. - def adapter_name - ADAPTER_NAME - end - - # Initializes and connects a PostgreSQL adapter. - def initialize(connection, logger, connection_parameters, config) - super(connection, logger) - @connection_parameters, @config = connection_parameters, config - - connect - end - - # Is this connection alive and ready for queries? - def active? - if @connection.respond_to?(:status) - @connection.status == PGconn::CONNECTION_OK - else - # We're asking the driver, not ActiveRecord, so use @connection.query instead of #query - @connection.query 'SELECT 1' - true - end - # postgres-pr raises a NoMethodError when querying if no connection is available. - rescue PGError, NoMethodError - false - end - - # Close then reopen the connection. - def reconnect! - if @connection.respond_to?(:reset) - @connection.reset - configure_connection - else - disconnect! - connect - end - end - - # Close the connection. - def disconnect! - @connection.close rescue nil - end - - def native_database_types #:nodoc: - NATIVE_DATABASE_TYPES - end - - # Does PostgreSQL support migrations? - def supports_migrations? - true - end - - # Does PostgreSQL support standard conforming strings? - def supports_standard_conforming_strings? - # Temporarily set the client message level above error to prevent unintentional - # error messages in the logs when working on a PostgreSQL database server that - # does not support standard conforming strings. - client_min_messages_old = client_min_messages - self.client_min_messages = 'panic' - - # postgres-pr does not raise an exception when client_min_messages is set higher - # than error and "SHOW standard_conforming_strings" fails, but returns an empty - # PGresult instead. - has_support = query('SHOW standard_conforming_strings')[0][0] rescue false - self.client_min_messages = client_min_messages_old - has_support - end - - def supports_insert_with_returning? - postgresql_version >= 80200 - end - - def supports_ddl_transactions? - true - end - - def supports_savepoints? - true - end - - # Returns the configured supported identifier length supported by PostgreSQL, - # or report the default of 63 on PostgreSQL 7.x. - def table_alias_length - @table_alias_length ||= (postgresql_version >= 80000 ? query('SHOW max_identifier_length')[0][0].to_i : 63) - end - - # QUOTING ================================================== - - # Escapes binary strings for bytea input to the database. - def escape_bytea(value) - if PGconn.respond_to?(:escape_bytea) - self.class.instance_eval do - define_method(:escape_bytea) do |value| - PGconn.escape_bytea(value) if value - end - end - else - self.class.instance_eval do - define_method(:escape_bytea) do |value| - if value - result = '' - value.each_byte { |c| result << sprintf('\\\\%03o', c) } - result - end - end - end - end - escape_bytea(value) - end - - # Unescapes bytea output from a database to the binary string it represents. - # NOTE: This is NOT an inverse of escape_bytea! This is only to be used - # on escaped binary output from database drive. - def unescape_bytea(value) - # In each case, check if the value actually is escaped PostgreSQL bytea output - # or an unescaped Active Record attribute that was just written. - if PGconn.respond_to?(:unescape_bytea) - self.class.instance_eval do - define_method(:unescape_bytea) do |value| - if value =~ /\\\d{3}/ - PGconn.unescape_bytea(value) - else - value - end - end - end - else - self.class.instance_eval do - define_method(:unescape_bytea) do |value| - if value =~ /\\\d{3}/ - result = '' - i, max = 0, value.size - while i < max - char = value[i] - if char == ?\\ - if value[i+1] == ?\\ - char = ?\\ - i += 1 - else - char = value[i+1..i+3].oct - i += 3 - end - end - result << char - i += 1 - end - result - else - value - end - end - end - end - unescape_bytea(value) - end - - # Quotes PostgreSQL-specific data types for SQL input. - def quote(value, column = nil) #:nodoc: - if value.kind_of?(String) && column && column.type == :binary - "#{quoted_string_prefix}'#{escape_bytea(value)}'" - elsif value.kind_of?(String) && column && column.sql_type =~ /^xml$/ - "xml '#{quote_string(value)}'" - elsif value.kind_of?(Numeric) && column && column.sql_type =~ /^money$/ - # Not truly string input, so doesn't require (or allow) escape string syntax. - "'#{value.to_s}'" - elsif value.kind_of?(String) && column && column.sql_type =~ /^bit/ - case value - when /^[01]*$/ - "B'#{value}'" # Bit-string notation - when /^[0-9A-F]*$/i - "X'#{value}'" # Hexadecimal notation - end - else - super - end - end - - # Quotes strings for use in SQL input in the postgres driver for better performance. - def quote_string(s) #:nodoc: - if PGconn.respond_to?(:escape) - self.class.instance_eval do - define_method(:quote_string) do |s| - PGconn.escape(s) - end - end - else - # There are some incorrectly compiled postgres drivers out there - # that don't define PGconn.escape. - self.class.instance_eval do - remove_method(:quote_string) - end - end - quote_string(s) - end - - # Quotes column names for use in SQL queries. - def quote_column_name(name) #:nodoc: - %("#{name}") - end - - # Quote date/time values for use in SQL input. Includes microseconds - # if the value is a Time responding to usec. - def quoted_date(value) #:nodoc: - if value.acts_like?(:time) && value.respond_to?(:usec) - "#{super}.#{sprintf("%06d", value.usec)}" - else - super - end - end - - # REFERENTIAL INTEGRITY ==================================== - - def supports_disable_referential_integrity?() #:nodoc: - version = query("SHOW server_version")[0][0].split('.') - (version[0].to_i >= 8 && version[1].to_i >= 1) ? true : false - rescue - return false - end - - def disable_referential_integrity(&block) #:nodoc: - if supports_disable_referential_integrity?() then - execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER ALL" }.join(";")) - end - yield - ensure - if supports_disable_referential_integrity?() then - execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER ALL" }.join(";")) - end - end - - # DATABASE STATEMENTS ====================================== - - # Executes a SELECT query and returns an array of rows. Each row is an - # array of field values. - def select_rows(sql, name = nil) - select_raw(sql, name).last - end - - # Executes an INSERT query and returns the new record's ID - def insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) - # Extract the table from the insert sql. Yuck. - table = sql.split(" ", 4)[2].gsub('"', '') - - # Try an insert with 'returning id' if available (PG >= 8.2) - if supports_insert_with_returning? - pk, sequence_name = *pk_and_sequence_for(table) unless pk - if pk - id = select_value("#{sql} RETURNING #{quote_column_name(pk)}") - clear_query_cache - return id - end - end - - # Otherwise, insert then grab last_insert_id. - if insert_id = super - insert_id - else - # If neither pk nor sequence name is given, look them up. - unless pk || sequence_name - pk, sequence_name = *pk_and_sequence_for(table) - end - - # If a pk is given, fallback to default sequence name. - # Don't fetch last insert id for a table without a pk. - if pk && sequence_name ||= default_sequence_name(table, pk) - last_insert_id(table, sequence_name) - end - end - end - - # create a 2D array representing the result set - def result_as_array(res) #:nodoc: - # check if we have any binary column and if they need escaping - unescape_col = [] - for j in 0...res.nfields do - # unescape string passed BYTEA field (OID == 17) - unescape_col << ( res.ftype(j)==17 ) - end - - ary = [] - for i in 0...res.ntuples do - ary << [] - for j in 0...res.nfields do - data = res.getvalue(i,j) - data = unescape_bytea(data) if unescape_col[j] and data.is_a?(String) - ary[i] << data - end - end - return ary - end - - - # Queries the database and returns the results in an Array-like object - def query(sql, name = nil) #:nodoc: - log(sql, name) do - if @async - res = @connection.async_exec(sql) - else - res = @connection.exec(sql) - end - return result_as_array(res) - end - end - - # Executes an SQL statement, returning a PGresult object on success - # or raising a PGError exception otherwise. - def execute(sql, name = nil) - log(sql, name) do - if @async - @connection.async_exec(sql) - else - @connection.exec(sql) - end - end - end - - # Executes an UPDATE query and returns the number of affected tuples. - def update_sql(sql, name = nil) - super.cmd_tuples - end - - # Begins a transaction. - def begin_db_transaction - execute "BEGIN" - end - - # Commits a transaction. - def commit_db_transaction - execute "COMMIT" - end - - # Aborts a transaction. - def rollback_db_transaction - execute "ROLLBACK" - end - - if defined?(PGconn::PQTRANS_IDLE) - # The ruby-pg driver supports inspecting the transaction status, - # while the ruby-postgres driver does not. - def outside_transaction? - @connection.transaction_status == PGconn::PQTRANS_IDLE - end - end - - def create_savepoint - execute("SAVEPOINT #{current_savepoint_name}") - end - - def rollback_to_savepoint - execute("ROLLBACK TO SAVEPOINT #{current_savepoint_name}") - end - - def release_savepoint - execute("RELEASE SAVEPOINT #{current_savepoint_name}") - end - - # SCHEMA STATEMENTS ======================================== - - def recreate_database(name) #:nodoc: - drop_database(name) - create_database(name) - end - - # Create a new PostgreSQL database. Options include <tt>:owner</tt>, <tt>:template</tt>, - # <tt>:encoding</tt>, <tt>:tablespace</tt>, and <tt>:connection_limit</tt> (note that MySQL uses - # <tt>:charset</tt> while PostgreSQL uses <tt>:encoding</tt>). - # - # Example: - # create_database config[:database], config - # create_database 'foo_development', :encoding => 'unicode' - def create_database(name, options = {}) - options = options.reverse_merge(:encoding => "utf8") - - option_string = options.symbolize_keys.sum do |key, value| - case key - when :owner - " OWNER = \"#{value}\"" - when :template - " TEMPLATE = \"#{value}\"" - when :encoding - " ENCODING = '#{value}'" - when :tablespace - " TABLESPACE = \"#{value}\"" - when :connection_limit - " CONNECTION LIMIT = #{value}" - else - "" - end - end - - execute "CREATE DATABASE #{quote_table_name(name)}#{option_string}" - end - - # Drops a PostgreSQL database - # - # Example: - # drop_database 'matt_development' - def drop_database(name) #:nodoc: - if postgresql_version >= 80200 - execute "DROP DATABASE IF EXISTS #{quote_table_name(name)}" - else - begin - execute "DROP DATABASE #{quote_table_name(name)}" - rescue ActiveRecord::StatementInvalid - @logger.warn "#{name} database doesn't exist." if @logger - end - end - end - - - # Returns the list of all tables in the schema search path or a specified schema. - def tables(name = nil) - schemas = schema_search_path.split(/,/).map { |p| quote(p) }.join(',') - query(<<-SQL, name).map { |row| row[0] } - SELECT tablename - FROM pg_tables - WHERE schemaname IN (#{schemas}) - SQL - end - - # Returns the list of all indexes for a table. - def indexes(table_name, name = nil) - schemas = schema_search_path.split(/,/).map { |p| quote(p) }.join(',') - result = query(<<-SQL, name) - SELECT distinct i.relname, d.indisunique, a.attname - FROM pg_class t, pg_class i, pg_index d, pg_attribute a - WHERE i.relkind = 'i' - AND d.indexrelid = i.oid - AND d.indisprimary = 'f' - AND t.oid = d.indrelid - AND t.relname = '#{table_name}' - AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN (#{schemas}) ) - AND a.attrelid = t.oid - AND ( d.indkey[0]=a.attnum OR d.indkey[1]=a.attnum - OR d.indkey[2]=a.attnum OR d.indkey[3]=a.attnum - OR d.indkey[4]=a.attnum OR d.indkey[5]=a.attnum - OR d.indkey[6]=a.attnum OR d.indkey[7]=a.attnum - OR d.indkey[8]=a.attnum OR d.indkey[9]=a.attnum ) - ORDER BY i.relname - SQL - - current_index = nil - indexes = [] - - result.each do |row| - if current_index != row[0] - indexes << IndexDefinition.new(table_name, row[0], row[1] == "t", []) - current_index = row[0] - end - - indexes.last.columns << row[2] - end - - indexes - end - - # Returns the list of all column definitions for a table. - def columns(table_name, name = nil) - # Limit, precision, and scale are all handled by the superclass. - column_definitions(table_name).collect do |name, type, default, notnull| - PostgreSQLColumn.new(name, default, type, notnull == 'f') - end - end - - # Returns the current database name. - def current_database - query('select current_database()')[0][0] - end - - # Returns the current database encoding format. - def encoding - query(<<-end_sql)[0][0] - SELECT pg_encoding_to_char(pg_database.encoding) FROM pg_database - WHERE pg_database.datname LIKE '#{current_database}' - end_sql - end - - # Sets the schema search path to a string of comma-separated schema names. - # Names beginning with $ have to be quoted (e.g. $user => '$user'). - # See: http://www.postgresql.org/docs/current/static/ddl-schemas.html - # - # This should be not be called manually but set in database.yml. - def schema_search_path=(schema_csv) - if schema_csv - execute "SET search_path TO #{schema_csv}" - @schema_search_path = schema_csv - end - end - - # Returns the active schema search path. - def schema_search_path - @schema_search_path ||= query('SHOW search_path')[0][0] - end - - # Returns the current client message level. - def client_min_messages - query('SHOW client_min_messages')[0][0] - end - - # Set the client message level. - def client_min_messages=(level) - execute("SET client_min_messages TO '#{level}'") - end - - # Returns the sequence name for a table's primary key or some other specified key. - def default_sequence_name(table_name, pk = nil) #:nodoc: - default_pk, default_seq = pk_and_sequence_for(table_name) - default_seq || "#{table_name}_#{pk || default_pk || 'id'}_seq" - end - - # Resets the sequence of a table's primary key to the maximum value. - def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc: - unless pk and sequence - default_pk, default_sequence = pk_and_sequence_for(table) - pk ||= default_pk - sequence ||= default_sequence - end - if pk - if sequence - quoted_sequence = quote_column_name(sequence) - - select_value <<-end_sql, 'Reset sequence' - SELECT setval('#{quoted_sequence}', (SELECT COALESCE(MAX(#{quote_column_name pk})+(SELECT increment_by FROM #{quoted_sequence}), (SELECT min_value FROM #{quoted_sequence})) FROM #{quote_table_name(table)}), false) - end_sql - else - @logger.warn "#{table} has primary key #{pk} with no default sequence" if @logger - end - end - end - - # Returns a table's primary key and belonging sequence. - def pk_and_sequence_for(table) #:nodoc: - # First try looking for a sequence with a dependency on the - # given table's primary key. - result = query(<<-end_sql, 'PK and serial sequence')[0] - SELECT attr.attname, seq.relname - FROM pg_class seq, - pg_attribute attr, - pg_depend dep, - pg_namespace name, - pg_constraint cons - WHERE seq.oid = dep.objid - AND seq.relkind = 'S' - AND attr.attrelid = dep.refobjid - AND attr.attnum = dep.refobjsubid - AND attr.attrelid = cons.conrelid - AND attr.attnum = cons.conkey[1] - AND cons.contype = 'p' - AND dep.refobjid = '#{table}'::regclass - end_sql - - if result.nil? or result.empty? - # If that fails, try parsing the primary key's default value. - # Support the 7.x and 8.0 nextval('foo'::text) as well as - # the 8.1+ nextval('foo'::regclass). - result = query(<<-end_sql, 'PK and custom sequence')[0] - SELECT attr.attname, - CASE - WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN - substr(split_part(def.adsrc, '''', 2), - strpos(split_part(def.adsrc, '''', 2), '.')+1) - ELSE split_part(def.adsrc, '''', 2) - END - FROM pg_class t - JOIN pg_attribute attr ON (t.oid = attrelid) - JOIN pg_attrdef def ON (adrelid = attrelid AND adnum = attnum) - JOIN pg_constraint cons ON (conrelid = adrelid AND adnum = conkey[1]) - WHERE t.oid = '#{table}'::regclass - AND cons.contype = 'p' - AND def.adsrc ~* 'nextval' - end_sql - end - - # [primary_key, sequence] - [result.first, result.last] - rescue - nil - end - - # Renames a table. - def rename_table(name, new_name) - execute "ALTER TABLE #{quote_table_name(name)} RENAME TO #{quote_table_name(new_name)}" - end - - # Adds a new column to the named table. - # See TableDefinition#column for details of the options you can use. - def add_column(table_name, column_name, type, options = {}) - default = options[:default] - notnull = options[:null] == false - - # Add the column. - execute("ALTER TABLE #{quote_table_name(table_name)} ADD COLUMN #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}") - - change_column_default(table_name, column_name, default) if options_include_default?(options) - change_column_null(table_name, column_name, false, default) if notnull - end - - # Changes the column of a table. - def change_column(table_name, column_name, type, options = {}) - quoted_table_name = quote_table_name(table_name) - - begin - execute "ALTER TABLE #{quoted_table_name} ALTER COLUMN #{quote_column_name(column_name)} TYPE #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}" - rescue ActiveRecord::StatementInvalid => e - raise e if postgresql_version > 80000 - # This is PostgreSQL 7.x, so we have to use a more arcane way of doing it. - begin - begin_db_transaction - tmp_column_name = "#{column_name}_ar_tmp" - add_column(table_name, tmp_column_name, type, options) - execute "UPDATE #{quoted_table_name} SET #{quote_column_name(tmp_column_name)} = CAST(#{quote_column_name(column_name)} AS #{type_to_sql(type, options[:limit], options[:precision], options[:scale])})" - remove_column(table_name, column_name) - rename_column(table_name, tmp_column_name, column_name) - commit_db_transaction - rescue - rollback_db_transaction - end - end - - change_column_default(table_name, column_name, options[:default]) if options_include_default?(options) - change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null) - end - - # Changes the default value of a table column. - def change_column_default(table_name, column_name, default) - execute "ALTER TABLE #{quote_table_name(table_name)} ALTER COLUMN #{quote_column_name(column_name)} SET DEFAULT #{quote(default)}" - end - - def change_column_null(table_name, column_name, null, default = nil) - unless null || default.nil? - execute("UPDATE #{quote_table_name(table_name)} SET #{quote_column_name(column_name)}=#{quote(default)} WHERE #{quote_column_name(column_name)} IS NULL") - end - execute("ALTER TABLE #{quote_table_name(table_name)} ALTER #{quote_column_name(column_name)} #{null ? 'DROP' : 'SET'} NOT NULL") - end - - # Renames a column in a table. - def rename_column(table_name, column_name, new_column_name) - execute "ALTER TABLE #{quote_table_name(table_name)} RENAME COLUMN #{quote_column_name(column_name)} TO #{quote_column_name(new_column_name)}" - end - - # Drops an index from a table. - def remove_index(table_name, options = {}) - execute "DROP INDEX #{index_name(table_name, options)}" - end - - # Maps logical Rails types to PostgreSQL-specific data types. - def type_to_sql(type, limit = nil, precision = nil, scale = nil) - return super unless type.to_s == 'integer' - - case limit - when 1..2; 'smallint' - when 3..4, nil; 'integer' - when 5..8; 'bigint' - else raise(ActiveRecordError, "No integer type has byte size #{limit}. Use a numeric with precision 0 instead.") - end - end - - # Returns a SELECT DISTINCT clause for a given set of columns and a given ORDER BY clause. - # - # PostgreSQL requires the ORDER BY columns in the select list for distinct queries, and - # requires that the ORDER BY include the distinct column. - # - # distinct("posts.id", "posts.created_at desc") - def distinct(columns, order_by) #:nodoc: - return "DISTINCT #{columns}" if order_by.blank? - - # Construct a clean list of column names from the ORDER BY clause, removing - # any ASC/DESC modifiers - order_columns = order_by.split(',').collect { |s| s.split.first } - order_columns.delete_if &:blank? - order_columns = order_columns.zip((0...order_columns.size).to_a).map { |s,i| "#{s} AS alias_#{i}" } - - # Return a DISTINCT ON() clause that's distinct on the columns we want but includes - # all the required columns for the ORDER BY to work properly. - sql = "DISTINCT ON (#{columns}) #{columns}, " - sql << order_columns * ', ' - end - - # Returns an ORDER BY clause for the passed order option. - # - # PostgreSQL does not allow arbitrary ordering when using DISTINCT ON, so we work around this - # by wrapping the +sql+ string as a sub-select and ordering in that query. - def add_order_by_for_association_limiting!(sql, options) #:nodoc: - return sql if options[:order].blank? - - order = options[:order].split(',').collect { |s| s.strip }.reject(&:blank?) - order.map! { |s| 'DESC' if s =~ /\bdesc$/i } - order = order.zip((0...order.size).to_a).map { |s,i| "id_list.alias_#{i} #{s}" }.join(', ') - - sql.replace "SELECT * FROM (#{sql}) AS id_list ORDER BY #{order}" - end - - protected - # Returns the version of the connected PostgreSQL version. - def postgresql_version - @postgresql_version ||= - if @connection.respond_to?(:server_version) - @connection.server_version - else - # Mimic PGconn.server_version behavior - begin - query('SELECT version()')[0][0] =~ /PostgreSQL (\d+)\.(\d+)\.(\d+)/ - ($1.to_i * 10000) + ($2.to_i * 100) + $3.to_i - rescue - 0 - end - end - end - - private - # The internal PostgreSQL identifier of the money data type. - MONEY_COLUMN_TYPE_OID = 790 #:nodoc: - - # Connects to a PostgreSQL server and sets up the adapter depending on the - # connected server's characteristics. - def connect - @connection = PGconn.connect(*@connection_parameters) - PGconn.translate_results = false if PGconn.respond_to?(:translate_results=) - - # Ignore async_exec and async_query when using postgres-pr. - @async = @config[:allow_concurrency] && @connection.respond_to?(:async_exec) - - # Use escape string syntax if available. We cannot do this lazily when encountering - # the first string, because that could then break any transactions in progress. - # See: http://www.postgresql.org/docs/current/static/runtime-config-compatible.html - # If PostgreSQL doesn't know the standard_conforming_strings parameter then it doesn't - # support escape string syntax. Don't override the inherited quoted_string_prefix. - if supports_standard_conforming_strings? - self.class.instance_eval do - define_method(:quoted_string_prefix) { 'E' } - end - end - - # Money type has a fixed precision of 10 in PostgreSQL 8.2 and below, and as of - # PostgreSQL 8.3 it has a fixed precision of 19. PostgreSQLColumn.extract_precision - # should know about this but can't detect it there, so deal with it here. - money_precision = (postgresql_version >= 80300) ? 19 : 10 - PostgreSQLColumn.module_eval(<<-end_eval) - def extract_precision(sql_type) # def extract_precision(sql_type) - if sql_type =~ /^money$/ # if sql_type =~ /^money$/ - #{money_precision} # 19 - else # else - super # super - end # end - end # end - end_eval - - configure_connection - end - - # Configures the encoding, verbosity, and schema search path of the connection. - # This is called by #connect and should not be called manually. - def configure_connection - if @config[:encoding] - if @connection.respond_to?(:set_client_encoding) - @connection.set_client_encoding(@config[:encoding]) - else - execute("SET client_encoding TO '#{@config[:encoding]}'") - end - end - self.client_min_messages = @config[:min_messages] if @config[:min_messages] - self.schema_search_path = @config[:schema_search_path] || @config[:schema_order] - end - - # Returns the current ID of a table's sequence. - def last_insert_id(table, sequence_name) #:nodoc: - Integer(select_value("SELECT currval('#{sequence_name}')")) - end - - # Executes a SELECT query and returns the results, performing any data type - # conversions that are required to be performed here instead of in PostgreSQLColumn. - def select(sql, name = nil) - fields, rows = select_raw(sql, name) - result = [] - for row in rows - row_hash = {} - fields.each_with_index do |f, i| - row_hash[f] = row[i] - end - result << row_hash - end - result - end - - def select_raw(sql, name = nil) - res = execute(sql, name) - results = result_as_array(res) - fields = [] - rows = [] - if res.ntuples > 0 - fields = res.fields - results.each do |row| - hashed_row = {} - row.each_index do |cell_index| - # If this is a money type column and there are any currency symbols, - # then strip them off. Indeed it would be prettier to do this in - # PostgreSQLColumn.string_to_decimal but would break form input - # fields that call value_before_type_cast. - if res.ftype(cell_index) == MONEY_COLUMN_TYPE_OID - # Because money output is formatted according to the locale, there are two - # cases to consider (note the decimal separators): - # (1) $12,345,678.12 - # (2) $12.345.678,12 - case column = row[cell_index] - when /^-?\D+[\d,]+\.\d{2}$/ # (1) - row[cell_index] = column.gsub(/[^-\d\.]/, '') - when /^-?\D+[\d\.]+,\d{2}$/ # (2) - row[cell_index] = column.gsub(/[^-\d,]/, '').sub(/,/, '.') - end - end - - hashed_row[fields[cell_index]] = column - end - rows << row - end - end - res.clear - return fields, rows - end - - # Returns the list of a table's column names, data types, and default values. - # - # The underlying query is roughly: - # SELECT column.name, column.type, default.value - # FROM column LEFT JOIN default - # ON column.table_id = default.table_id - # AND column.num = default.column_num - # WHERE column.table_id = get_table_id('table_name') - # AND column.num > 0 - # AND NOT column.is_dropped - # ORDER BY column.num - # - # If the table name is not prefixed with a schema, the database will - # take the first match from the schema search path. - # - # Query implementation notes: - # - format_type includes the column size constraint, e.g. varchar(50) - # - ::regclass is a function that gives the id for a table name - def column_definitions(table_name) #:nodoc: - query <<-end_sql - SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull - FROM pg_attribute a LEFT JOIN pg_attrdef d - ON a.attrelid = d.adrelid AND a.attnum = d.adnum - WHERE a.attrelid = '#{table_name}'::regclass - AND a.attnum > 0 AND NOT a.attisdropped - ORDER BY a.attnum - end_sql - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb deleted file mode 100644 index 75420f6..0000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'active_record/connection_adapters/sqlite_adapter' - -module ActiveRecord - class Base - # sqlite3 adapter reuses sqlite_connection. - def self.sqlite3_connection(config) # :nodoc: - parse_sqlite_config!(config) - - unless self.class.const_defined?(:SQLite3) - require_library_or_gem(config[:adapter]) - end - - db = SQLite3::Database.new( - config[:database], - :results_as_hash => true, - :type_translation => false - ) - - db.busy_timeout(config[:timeout]) unless config[:timeout].nil? - - ConnectionAdapters::SQLite3Adapter.new(db, logger, config) - end - end - - module ConnectionAdapters #:nodoc: - class SQLite3Adapter < SQLiteAdapter # :nodoc: - def table_structure(table_name) - returning structure = @connection.table_info(quote_table_name(table_name)) do - raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure.empty? - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb deleted file mode 100644 index afd6472..0000000 --- a/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ /dev/null @@ -1,438 +0,0 @@ -require 'active_record/connection_adapters/abstract_adapter' - -module ActiveRecord - class Base - class << self - # Establishes a connection to the database that's used by all Active Record objects - def sqlite_connection(config) # :nodoc: - parse_sqlite_config!(config) - - unless self.class.const_defined?(:SQLite) - require_library_or_gem(config[:adapter]) - - db = SQLite::Database.new(config[:database], 0) - db.show_datatypes = "ON" if !defined? SQLite::Version - db.results_as_hash = true if defined? SQLite::Version - db.type_translation = false - - # "Downgrade" deprecated sqlite API - if SQLite.const_defined?(:Version) - ConnectionAdapters::SQLite2Adapter.new(db, logger, config) - else - ConnectionAdapters::DeprecatedSQLiteAdapter.new(db, logger, config) - end - end - end - - private - def parse_sqlite_config!(config) - config[:database] ||= config[:dbfile] - # Require database. - unless config[:database] - raise ArgumentError, "No database file specified. Missing argument: database" - end - - # Allow database path relative to RAILS_ROOT, but only if - # the database path is not the special path that tells - # Sqlite to build a database only in memory. - if Object.const_defined?(:RAILS_ROOT) && ':memory:' != config[:database] - config[:database] = File.expand_path(config[:database], RAILS_ROOT) - end - end - end - end - - module ConnectionAdapters #:nodoc: - class SQLiteColumn < Column #:nodoc: - class << self - def string_to_binary(value) - value.gsub(/\0|\%/n) do |b| - case b - when "\0" then "%00" - when "%" then "%25" - end - end - end - - def binary_to_string(value) - value.gsub(/%00|%25/n) do |b| - case b - when "%00" then "\0" - when "%25" then "%" - end - end - end - end - end - - # The SQLite adapter works with both the 2.x and 3.x series of SQLite with the sqlite-ruby drivers (available both as gems and - # from http://rubyforge.org/projects/sqlite-ruby/). - # - # Options: - # - # * <tt>:database</tt> - Path to the database file. - class SQLiteAdapter < AbstractAdapter - class Version - include Comparable - - def initialize(version_string) - @version = version_string.split('.').map(&:to_i) - end - - def <=>(version_string) - @version <=> version_string.split('.').map(&:to_i) - end - end - - def initialize(connection, logger, config) - super(connection, logger) - @config = config - end - - def adapter_name #:nodoc: - 'SQLite' - end - - def supports_ddl_transactions? - sqlite_version >= '2.0.0' - end - - def supports_migrations? #:nodoc: - true - end - - def requires_reloading? - true - end - - def supports_add_column? - sqlite_version >= '3.1.6' - end - - def disconnect! - super - @connection.close rescue nil - end - - def supports_count_distinct? #:nodoc: - sqlite_version >= '3.2.6' - end - - def supports_autoincrement? #:nodoc: - sqlite_version >= '3.1.0' - end - - def native_database_types #:nodoc: - { - :primary_key => default_primary_key_type, - :string => { :name => "varchar", :limit => 255 }, - :text => { :name => "text" }, - :integer => { :name => "integer" }, - :float => { :name => "float" }, - :decimal => { :name => "decimal" }, - :datetime => { :name => "datetime" }, - :timestamp => { :name => "datetime" }, - :time => { :name => "time" }, - :date => { :name => "date" }, - :binary => { :name => "blob" }, - :boolean => { :name => "boolean" } - } - end - - - # QUOTING ================================================== - - def quote_string(s) #:nodoc: - @connection.class.quote(s) - end - - def quote_column_name(name) #:nodoc: - %Q("#{name}") - end - - - # DATABASE STATEMENTS ====================================== - - def execute(sql, name = nil) #:nodoc: - catch_schema_changes { log(sql, name) { @connection.execute(sql) } } - end - - def update_sql(sql, name = nil) #:nodoc: - super - @connection.changes - end - - def delete_sql(sql, name = nil) #:nodoc: - sql += " WHERE 1=1" unless sql =~ /WHERE/i - super sql, name - end - - def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) #:nodoc: - super || @connection.last_insert_row_id - end - - def select_rows(sql, name = nil) - execute(sql, name).map do |row| - (0...(row.size / 2)).map { |i| row[i] } - end - end - - def begin_db_transaction #:nodoc: - catch_schema_changes { @connection.transaction } - end - - def commit_db_transaction #:nodoc: - catch_schema_changes { @connection.commit } - end - - def rollback_db_transaction #:nodoc: - catch_schema_changes { @connection.rollback } - end - - # SELECT ... FOR UPDATE is redundant since the table is locked. - def add_lock!(sql, options) #:nodoc: - sql - end - - - # SCHEMA STATEMENTS ======================================== - - def tables(name = nil) #:nodoc: - sql = <<-SQL - SELECT name - FROM sqlite_master - WHERE type = 'table' AND NOT name = 'sqlite_sequence' - SQL - - execute(sql, name).map do |row| - row[0] - end - end - - def columns(table_name, name = nil) #:nodoc: - table_structure(table_name).map do |field| - SQLiteColumn.new(field['name'], field['dflt_value'], field['type'], field['notnull'] == "0") - end - end - - def indexes(table_name, name = nil) #:nodoc: - execute("PRAGMA index_list(#{quote_table_name(table_name)})", name).map do |row| - index = IndexDefinition.new(table_name, row['name']) - index.unique = row['unique'] != '0' - index.columns = execute("PRAGMA index_info('#{index.name}')").map { |col| col['name'] } - index - end - end - - def primary_key(table_name) #:nodoc: - column = table_structure(table_name).find {|field| field['pk'].to_i == 1} - column ? column['name'] : nil - end - - def remove_index(table_name, options={}) #:nodoc: - execute "DROP INDEX #{quote_column_name(index_name(table_name, options))}" - end - - def rename_table(name, new_name) - execute "ALTER TABLE #{name} RENAME TO #{new_name}" - end - - # See: http://www.sqlite.org/lang_altertable.html - # SQLite has an additional restriction on the ALTER TABLE statement - def valid_alter_table_options( type, options) - type.to_sym != :primary_key - end - - def add_column(table_name, column_name, type, options = {}) #:nodoc: - if supports_add_column? && valid_alter_table_options( type, options ) - super(table_name, column_name, type, options) - else - alter_table(table_name) do |definition| - definition.column(column_name, type, options) - end - end - end - - def remove_column(table_name, *column_names) #:nodoc: - column_names.flatten.each do |column_name| - alter_table(table_name) do |definition| - definition.columns.delete(definition[column_name]) - end - end - end - alias :remove_columns :remove_column - - def change_column_default(table_name, column_name, default) #:nodoc: - alter_table(table_name) do |definition| - definition[column_name].default = default - end - end - - def change_column_null(table_name, column_name, null, default = nil) - unless null || default.nil? - execute("UPDATE #{quote_table_name(table_name)} SET #{quote_column_name(column_name)}=#{quote(default)} WHERE #{quote_column_name(column_name)} IS NULL") - end - alter_table(table_name) do |definition| - definition[column_name].null = null - end - end - - def change_column(table_name, column_name, type, options = {}) #:nodoc: - alter_table(table_name) do |definition| - include_default = options_include_default?(options) - definition[column_name].instance_eval do - self.type = type - self.limit = options[:limit] if options.include?(:limit) - self.default = options[:default] if include_default - self.null = options[:null] if options.include?(:null) - end - end - end - - def rename_column(table_name, column_name, new_column_name) #:nodoc: - unless columns(table_name).detect{|c| c.name == column_name.to_s } - raise ActiveRecord::ActiveRecordError, "Missing column #{table_name}.#{column_name}" - end - alter_table(table_name, :rename => {column_name.to_s => new_column_name.to_s}) - end - - def empty_insert_statement(table_name) - "INSERT INTO #{table_name} VALUES(NULL)" - end - - protected - def select(sql, name = nil) #:nodoc: - execute(sql, name).map do |row| - record = {} - row.each_key do |key| - if key.is_a?(String) - record[key.sub(/^"?\w+"?\./, '')] = row[key] - end - end - record - end - end - - def table_structure(table_name) - returning structure = execute("PRAGMA table_info(#{quote_table_name(table_name)})") do - raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure.empty? - end - end - - def alter_table(table_name, options = {}) #:nodoc: - altered_table_name = "altered_#{table_name}" - caller = lambda {|definition| yield definition if block_given?} - - transaction do - move_table(table_name, altered_table_name, - options.merge(:temporary => true)) - move_table(altered_table_name, table_name, &caller) - end - end - - def move_table(from, to, options = {}, &block) #:nodoc: - copy_table(from, to, options, &block) - drop_table(from) - end - - def copy_table(from, to, options = {}) #:nodoc: - options = options.merge(:id => (!columns(from).detect{|c| c.name == 'id'}.nil? && 'id' == primary_key(from).to_s)) - create_table(to, options) do |definition| - @definition = definition - columns(from).each do |column| - column_name = options[:rename] ? - (options[:rename][column.name] || - options[:rename][column.name.to_sym] || - column.name) : column.name - - @definition.column(column_name, column.type, - :limit => column.limit, :default => column.default, - :null => column.null) - end - @definition.primary_key(primary_key(from)) if primary_key(from) - yield @definition if block_given? - end - - copy_table_indexes(from, to, options[:rename] || {}) - copy_table_contents(from, to, - @definition.columns.map {|column| column.name}, - options[:rename] || {}) - end - - def copy_table_indexes(from, to, rename = {}) #:nodoc: - indexes(from).each do |index| - name = index.name - if to == "altered_#{from}" - name = "temp_#{name}" - elsif from == "altered_#{to}" - name = name[5..-1] - end - - to_column_names = columns(to).map(&:name) - columns = index.columns.map {|c| rename[c] || c }.select do |column| - to_column_names.include?(column) - end - - unless columns.empty? - # index name can't be the same - opts = { :name => name.gsub(/_(#{from})_/, "_#{to}_") } - opts[:unique] = true if index.unique - add_index(to, columns, opts) - end - end - end - - def copy_table_contents(from, to, columns, rename = {}) #:nodoc: - column_mappings = Hash[*columns.map {|name| [name, name]}.flatten] - rename.inject(column_mappings) {|map, a| map[a.last] = a.first; map} - from_columns = columns(from).collect {|col| col.name} - columns = columns.find_all{|col| from_columns.include?(column_mappings[col])} - quoted_columns = columns.map { |col| quote_column_name(col) } * ',' - - quoted_to = quote_table_name(to) - @connection.execute "SELECT * FROM #{quote_table_name(from)}" do |row| - sql = "INSERT INTO #{quoted_to} (#{quoted_columns}) VALUES (" - sql << columns.map {|col| quote row[column_mappings[col]]} * ', ' - sql << ')' - @connection.execute sql - end - end - - def catch_schema_changes - return yield - rescue ActiveRecord::StatementInvalid => exception - if exception.message =~ /database schema has changed/ - reconnect! - retry - else - raise - end - end - - def sqlite_version - @sqlite_version ||= SQLiteAdapter::Version.new(select_value('select sqlite_version(*)')) - end - - def default_primary_key_type - if supports_autoincrement? - 'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'.freeze - else - 'INTEGER PRIMARY KEY NOT NULL'.freeze - end - end - end - - class SQLite2Adapter < SQLiteAdapter # :nodoc: - def rename_table(name, new_name) - move_table(name, new_name) - end - end - - class DeprecatedSQLiteAdapter < SQLite2Adapter # :nodoc: - def insert(sql, name = nil, pk = nil, id_value = nil) - execute(sql, name = nil) - id_value || @connection.last_insert_rowid - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/dirty.rb b/vendor/rails/activerecord/lib/active_record/dirty.rb deleted file mode 100644 index 4a2510a..0000000 --- a/vendor/rails/activerecord/lib/active_record/dirty.rb +++ /dev/null @@ -1,183 +0,0 @@ -module ActiveRecord - # Track unsaved attribute changes. - # - # A newly instantiated object is unchanged: - # person = Person.find_by_name('uncle bob') - # person.changed? # => false - # - # Change the name: - # person.name = 'Bob' - # person.changed? # => true - # person.name_changed? # => true - # person.name_was # => 'uncle bob' - # person.name_change # => ['uncle bob', 'Bob'] - # person.name = 'Bill' - # person.name_change # => ['uncle bob', 'Bill'] - # - # Save the changes: - # person.save - # person.changed? # => false - # person.name_changed? # => false - # - # Assigning the same value leaves the attribute unchanged: - # person.name = 'Bill' - # person.name_changed? # => false - # person.name_change # => nil - # - # Which attributes have changed? - # person.name = 'bob' - # person.changed # => ['name'] - # person.changes # => { 'name' => ['Bill', 'bob'] } - # - # Before modifying an attribute in-place: - # person.name_will_change! - # person.name << 'by' - # person.name_change # => ['uncle bob', 'uncle bobby'] - module Dirty - DIRTY_SUFFIXES = ['_changed?', '_change', '_will_change!', '_was'] - - def self.included(base) - base.attribute_method_suffix *DIRTY_SUFFIXES - base.alias_method_chain :write_attribute, :dirty - base.alias_method_chain :save, :dirty - base.alias_method_chain :save!, :dirty - base.alias_method_chain :update, :dirty - base.alias_method_chain :reload, :dirty - - base.superclass_delegating_accessor :partial_updates - base.partial_updates = true - - base.send(:extend, ClassMethods) - end - - # Do any attributes have unsaved changes? - # person.changed? # => false - # person.name = 'bob' - # person.changed? # => true - def changed? - !changed_attributes.empty? - end - - # List of attributes with unsaved changes. - # person.changed # => [] - # person.name = 'bob' - # person.changed # => ['name'] - def changed - changed_attributes.keys - end - - # Map of changed attrs => [original value, new value]. - # person.changes # => {} - # person.name = 'bob' - # person.changes # => { 'name' => ['bill', 'bob'] } - def changes - changed.inject({}) { |h, attr| h[attr] = attribute_change(attr); h } - end - - # Attempts to +save+ the record and clears changed attributes if successful. - def save_with_dirty(*args) #:nodoc: - if status = save_without_dirty(*args) - changed_attributes.clear - end - status - end - - # Attempts to <tt>save!</tt> the record and clears changed attributes if successful. - def save_with_dirty!(*args) #:nodoc: - status = save_without_dirty!(*args) - changed_attributes.clear - status - end - - # <tt>reload</tt> the record and clears changed attributes. - def reload_with_dirty(*args) #:nodoc: - record = reload_without_dirty(*args) - changed_attributes.clear - record - end - - private - # Map of change <tt>attr => original value</tt>. - def changed_attributes - @changed_attributes ||= {} - end - - # Handle <tt>*_changed?</tt> for +method_missing+. - def attribute_changed?(attr) - changed_attributes.include?(attr) - end - - # Handle <tt>*_change</tt> for +method_missing+. - def attribute_change(attr) - [changed_attributes[attr], __send__(attr)] if attribute_changed?(attr) - end - - # Handle <tt>*_was</tt> for +method_missing+. - def attribute_was(attr) - attribute_changed?(attr) ? changed_attributes[attr] : __send__(attr) - end - - # Handle <tt>*_will_change!</tt> for +method_missing+. - def attribute_will_change!(attr) - changed_attributes[attr] = clone_attribute_value(:read_attribute, attr) - end - - # Wrap write_attribute to remember original attribute value. - def write_attribute_with_dirty(attr, value) - attr = attr.to_s - - # The attribute already has an unsaved change. - if changed_attributes.include?(attr) - old = changed_attributes[attr] - changed_attributes.delete(attr) unless field_changed?(attr, old, value) - else - old = clone_attribute_value(:read_attribute, attr) - changed_attributes[attr] = old if field_changed?(attr, old, value) - end - - # Carry on. - write_attribute_without_dirty(attr, value) - end - - def update_with_dirty - if partial_updates? - # Serialized attributes should always be written in case they've been - # changed in place. - update_without_dirty(changed | self.class.serialized_attributes.keys) - else - update_without_dirty - end - end - - def field_changed?(attr, old, value) - if column = column_for_attribute(attr) - if column.number? && column.null && (old.nil? || old == 0) && value.blank? - # For nullable numeric columns, NULL gets stored in database for blank (i.e. '') values. - # Hence we don't record it as a change if the value changes from nil to ''. - # If an old value of 0 is set to '' we want this to get changed to nil as otherwise it'll - # be typecast back to 0 (''.to_i => 0) - value = nil - else - value = column.type_cast(value) - end - end - - old != value - end - - module ClassMethods - def self.extended(base) - base.metaclass.alias_method_chain(:alias_attribute, :dirty) - end - - def alias_attribute_with_dirty(new_name, old_name) - alias_attribute_without_dirty(new_name, old_name) - DIRTY_SUFFIXES.each do |suffix| - module_eval <<-STR, __FILE__, __LINE__+1 - def #{new_name}#{suffix}; self.#{old_name}#{suffix}; end # def subject_changed?; self.title_changed?; end - STR - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/dynamic_finder_match.rb b/vendor/rails/activerecord/lib/active_record/dynamic_finder_match.rb deleted file mode 100644 index 8f9f05c..0000000 --- a/vendor/rails/activerecord/lib/active_record/dynamic_finder_match.rb +++ /dev/null @@ -1,41 +0,0 @@ -module ActiveRecord - class DynamicFinderMatch - def self.match(method) - df_match = self.new(method) - df_match.finder ? df_match : nil - end - - def initialize(method) - @finder = :first - case method.to_s - when /^find_(all_by|last_by|by)_([_a-zA-Z]\w*)$/ - @finder = :last if $1 == 'last_by' - @finder = :all if $1 == 'all_by' - names = $2 - when /^find_by_([_a-zA-Z]\w*)\!$/ - @bang = true - names = $1 - when /^find_or_(initialize|create)_by_([_a-zA-Z]\w*)$/ - @instantiator = $1 == 'initialize' ? :new : :create - names = $2 - else - @finder = nil - end - @attribute_names = names && names.split('_and_') - end - - attr_reader :finder, :attribute_names, :instantiator - - def finder? - !@finder.nil? && @instantiator.nil? - end - - def instantiator? - @finder == :first && !@instantiator.nil? - end - - def bang? - @bang - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/dynamic_scope_match.rb b/vendor/rails/activerecord/lib/active_record/dynamic_scope_match.rb deleted file mode 100644 index f796ba6..0000000 --- a/vendor/rails/activerecord/lib/active_record/dynamic_scope_match.rb +++ /dev/null @@ -1,25 +0,0 @@ -module ActiveRecord - class DynamicScopeMatch - def self.match(method) - ds_match = self.new(method) - ds_match.scope ? ds_match : nil - end - - def initialize(method) - @scope = true - case method.to_s - when /^scoped_by_([_a-zA-Z]\w*)$/ - names = $1 - else - @scope = nil - end - @attribute_names = names && names.split('_and_') - end - - attr_reader :scope, :attribute_names - - def scope? - !@scope.nil? - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/fixtures.rb b/vendor/rails/activerecord/lib/active_record/fixtures.rb deleted file mode 100644 index c650111..0000000 --- a/vendor/rails/activerecord/lib/active_record/fixtures.rb +++ /dev/null @@ -1,993 +0,0 @@ -require 'erb' -require 'yaml' -require 'csv' -require 'active_support/dependencies' -require 'active_support/test_case' - -if RUBY_VERSION < '1.9' - module YAML #:nodoc: - class Omap #:nodoc: - def keys; map { |k, v| k } end - def values; map { |k, v| v } end - end - end -end - -if defined? ActiveRecord - class FixtureClassNotFound < ActiveRecord::ActiveRecordError #:nodoc: - end -else - class FixtureClassNotFound < StandardError #:nodoc: - end -end - -# Fixtures are a way of organizing data that you want to test against; in short, sample data. -# -# = Fixture formats -# -# Fixtures come in 3 flavors: -# -# 1. YAML fixtures -# 2. CSV fixtures -# 3. Single-file fixtures -# -# == YAML fixtures -# -# This type of fixture is in YAML format and the preferred default. YAML is a file format which describes data structures -# in a non-verbose, human-readable format. It ships with Ruby 1.8.1+. -# -# Unlike single-file fixtures, YAML fixtures are stored in a single file per model, which are placed in the directory appointed -# by <tt>ActiveSupport::TestCase.fixture_path=(path)</tt> (this is automatically configured for Rails, so you can just -# put your files in <tt><your-rails-app>/test/fixtures/</tt>). The fixture file ends with the <tt>.yml</tt> file extension (Rails example: -# <tt><your-rails-app>/test/fixtures/web_sites.yml</tt>). The format of a YAML fixture file looks like this: -# -# rubyonrails: -# id: 1 -# name: Ruby on Rails -# url: http://www.rubyonrails.org -# -# google: -# id: 2 -# name: Google -# url: http://www.google.com -# -# This YAML fixture file includes two fixtures. Each YAML fixture (ie. record) is given a name and is followed by an -# indented list of key/value pairs in the "key: value" format. Records are separated by a blank line for your viewing -# pleasure. -# -# Note that YAML fixtures are unordered. If you want ordered fixtures, use the omap YAML type. See http://yaml.org/type/omap.html -# for the specification. You will need ordered fixtures when you have foreign key constraints on keys in the same table. -# This is commonly needed for tree structures. Example: -# -# --- !omap -# - parent: -# id: 1 -# parent_id: NULL -# title: Parent -# - child: -# id: 2 -# parent_id: 1 -# title: Child -# -# == CSV fixtures -# -# Fixtures can also be kept in the Comma Separated Value (CSV) format. Akin to YAML fixtures, CSV fixtures are stored -# in a single file, but instead end with the <tt>.csv</tt> file extension -# (Rails example: <tt><your-rails-app>/test/fixtures/web_sites.csv</tt>). -# -# The format of this type of fixture file is much more compact than the others, but also a little harder to read by us -# humans. The first line of the CSV file is a comma-separated list of field names. The rest of the file is then comprised -# of the actual data (1 per line). Here's an example: -# -# id, name, url -# 1, Ruby On Rails, http://www.rubyonrails.org -# 2, Google, http://www.google.com -# -# Should you have a piece of data with a comma character in it, you can place double quotes around that value. If you -# need to use a double quote character, you must escape it with another double quote. -# -# Another unique attribute of the CSV fixture is that it has *no* fixture name like the other two formats. Instead, the -# fixture names are automatically generated by deriving the class name of the fixture file and adding an incrementing -# number to the end. In our example, the 1st fixture would be called "web_site_1" and the 2nd one would be called -# "web_site_2". -# -# Most databases and spreadsheets support exporting to CSV format, so this is a great format for you to choose if you -# have existing data somewhere already. -# -# == Single-file fixtures -# -# This type of fixture was the original format for Active Record that has since been deprecated in favor of the YAML and CSV formats. -# Fixtures for this format are created by placing text files in a sub-directory (with the name of the model) to the directory -# appointed by <tt>ActiveSupport::TestCase.fixture_path=(path)</tt> (this is automatically configured for Rails, so you can just -# put your files in <tt><your-rails-app>/test/fixtures/<your-model-name>/</tt> -- -# like <tt><your-rails-app>/test/fixtures/web_sites/</tt> for the WebSite model). -# -# Each text file placed in this directory represents a "record". Usually these types of fixtures are named without -# extensions, but if you are on a Windows machine, you might consider adding <tt>.txt</tt> as the extension. Here's what the -# above example might look like: -# -# web_sites/google -# web_sites/yahoo.txt -# web_sites/ruby-on-rails -# -# The file format of a standard fixture is simple. Each line is a property (or column in db speak) and has the syntax -# of "name => value". Here's an example of the ruby-on-rails fixture above: -# -# id => 1 -# name => Ruby on Rails -# url => http://www.rubyonrails.org -# -# = Using fixtures in testcases -# -# Since fixtures are a testing construct, we use them in our unit and functional tests. There are two ways to use the -# fixtures, but first let's take a look at a sample unit test: -# -# require 'test_helper' -# -# class WebSiteTest < ActiveSupport::TestCase -# test "web_site_count" do -# assert_equal 2, WebSite.count -# end -# end -# -# By default, the <tt>test_helper module</tt> will load all of your fixtures into your test database, so this test will succeed. -# The testing environment will automatically load the all fixtures into the database before each test. -# To ensure consistent data, the environment deletes the fixtures before running the load. -# -# In addition to being available in the database, the fixture's data may also be accessed by -# using a special dynamic method, which has the same name as the model, and accepts the -# name of the fixture to instantiate: -# -# test "find" do -# assert_equal "Ruby on Rails", web_sites(:rubyonrails).name -# end -# -# Alternatively, you may enable auto-instantiation of the fixture data. For instance, take the following tests: -# -# test "find_alt_method_1" do -# assert_equal "Ruby on Rails", @web_sites['rubyonrails']['name'] -# end -# -# test "find_alt_method_2" do -# assert_equal "Ruby on Rails", @rubyonrails.news -# end -# -# In order to use these methods to access fixtured data within your testcases, you must specify one of the -# following in your <tt>ActiveSupport::TestCase</tt>-derived class: -# -# - to fully enable instantiated fixtures (enable alternate methods #1 and #2 above) -# self.use_instantiated_fixtures = true -# -# - create only the hash for the fixtures, do not 'find' each instance (enable alternate method #1 only) -# self.use_instantiated_fixtures = :no_instances -# -# Using either of these alternate methods incurs a performance hit, as the fixtured data must be fully -# traversed in the database to create the fixture hash and/or instance variables. This is expensive for -# large sets of fixtured data. -# -# = Dynamic fixtures with ERb -# -# Some times you don't care about the content of the fixtures as much as you care about the volume. In these cases, you can -# mix ERb in with your YAML or CSV fixtures to create a bunch of fixtures for load testing, like: -# -# <% for i in 1..1000 %> -# fix_<%= i %>: -# id: <%= i %> -# name: guy_<%= 1 %> -# <% end %> -# -# This will create 1000 very simple YAML fixtures. -# -# Using ERb, you can also inject dynamic values into your fixtures with inserts like <tt><%= Date.today.strftime("%Y-%m-%d") %></tt>. -# This is however a feature to be used with some caution. The point of fixtures are that they're stable units of predictable -# sample data. If you feel that you need to inject dynamic values, then perhaps you should reexamine whether your application -# is properly testable. Hence, dynamic values in fixtures are to be considered a code smell. -# -# = Transactional fixtures -# -# TestCases can use begin+rollback to isolate their changes to the database instead of having to delete+insert for every test case. -# -# class FooTest < ActiveSupport::TestCase -# self.use_transactional_fixtures = true -# -# test "godzilla" do -# assert !Foo.find(:all).empty? -# Foo.destroy_all -# assert Foo.find(:all).empty? -# end -# -# test "godzilla aftermath" do -# assert !Foo.find(:all).empty? -# end -# end -# -# If you preload your test database with all fixture data (probably in the Rakefile task) and use transactional fixtures, -# then you may omit all fixtures declarations in your test cases since all the data's already there and every case rolls back its changes. -# -# In order to use instantiated fixtures with preloaded data, set +self.pre_loaded_fixtures+ to true. This will provide -# access to fixture data for every table that has been loaded through fixtures (depending on the value of +use_instantiated_fixtures+) -# -# When *not* to use transactional fixtures: -# -# 1. You're testing whether a transaction works correctly. Nested transactions don't commit until all parent transactions commit, -# particularly, the fixtures transaction which is begun in setup and rolled back in teardown. Thus, you won't be able to verify -# the results of your transaction until Active Record supports nested transactions or savepoints (in progress). -# 2. Your database does not support transactions. Every Active Record database supports transactions except MySQL MyISAM. -# Use InnoDB, MaxDB, or NDB instead. -# -# = Advanced YAML Fixtures -# -# YAML fixtures that don't specify an ID get some extra features: -# -# * Stable, autogenerated IDs -# * Label references for associations (belongs_to, has_one, has_many) -# * HABTM associations as inline lists -# * Autofilled timestamp columns -# * Fixture label interpolation -# * Support for YAML defaults -# -# == Stable, autogenerated IDs -# -# Here, have a monkey fixture: -# -# george: -# id: 1 -# name: George the Monkey -# -# reginald: -# id: 2 -# name: Reginald the Pirate -# -# Each of these fixtures has two unique identifiers: one for the database -# and one for the humans. Why don't we generate the primary key instead? -# Hashing each fixture's label yields a consistent ID: -# -# george: # generated id: 503576764 -# name: George the Monkey -# -# reginald: # generated id: 324201669 -# name: Reginald the Pirate -# -# Active Record looks at the fixture's model class, discovers the correct -# primary key, and generates it right before inserting the fixture -# into the database. -# -# The generated ID for a given label is constant, so we can discover -# any fixture's ID without loading anything, as long as we know the label. -# -# == Label references for associations (belongs_to, has_one, has_many) -# -# Specifying foreign keys in fixtures can be very fragile, not to -# mention difficult to read. Since Active Record can figure out the ID of -# any fixture from its label, you can specify FK's by label instead of ID. -# -# === belongs_to -# -# Let's break out some more monkeys and pirates. -# -# ### in pirates.yml -# -# reginald: -# id: 1 -# name: Reginald the Pirate -# monkey_id: 1 -# -# ### in monkeys.yml -# -# george: -# id: 1 -# name: George the Monkey -# pirate_id: 1 -# -# Add a few more monkeys and pirates and break this into multiple files, -# and it gets pretty hard to keep track of what's going on. Let's -# use labels instead of IDs: -# -# ### in pirates.yml -# -# reginald: -# name: Reginald the Pirate -# monkey: george -# -# ### in monkeys.yml -# -# george: -# name: George the Monkey -# pirate: reginald -# -# Pow! All is made clear. Active Record reflects on the fixture's model class, -# finds all the +belongs_to+ associations, and allows you to specify -# a target *label* for the *association* (monkey: george) rather than -# a target *id* for the *FK* (<tt>monkey_id: 1</tt>). -# -# ==== Polymorphic belongs_to -# -# Supporting polymorphic relationships is a little bit more complicated, since -# Active Record needs to know what type your association is pointing at. Something -# like this should look familiar: -# -# ### in fruit.rb -# -# belongs_to :eater, :polymorphic => true -# -# ### in fruits.yml -# -# apple: -# id: 1 -# name: apple -# eater_id: 1 -# eater_type: Monkey -# -# Can we do better? You bet! -# -# apple: -# eater: george (Monkey) -# -# Just provide the polymorphic target type and Active Record will take care of the rest. -# -# === has_and_belongs_to_many -# -# Time to give our monkey some fruit. -# -# ### in monkeys.yml -# -# george: -# id: 1 -# name: George the Monkey -# pirate_id: 1 -# -# ### in fruits.yml -# -# apple: -# id: 1 -# name: apple -# -# orange: -# id: 2 -# name: orange -# -# grape: -# id: 3 -# name: grape -# -# ### in fruits_monkeys.yml -# -# apple_george: -# fruit_id: 1 -# monkey_id: 1 -# -# orange_george: -# fruit_id: 2 -# monkey_id: 1 -# -# grape_george: -# fruit_id: 3 -# monkey_id: 1 -# -# Let's make the HABTM fixture go away. -# -# ### in monkeys.yml -# -# george: -# name: George the Monkey -# pirate: reginald -# fruits: apple, orange, grape -# -# ### in fruits.yml -# -# apple: -# name: apple -# -# orange: -# name: orange -# -# grape: -# name: grape -# -# Zap! No more fruits_monkeys.yml file. We've specified the list of fruits -# on George's fixture, but we could've just as easily specified a list -# of monkeys on each fruit. As with +belongs_to+, Active Record reflects on -# the fixture's model class and discovers the +has_and_belongs_to_many+ -# associations. -# -# == Autofilled timestamp columns -# -# If your table/model specifies any of Active Record's -# standard timestamp columns (+created_at+, +created_on+, +updated_at+, +updated_on+), -# they will automatically be set to <tt>Time.now</tt>. -# -# If you've set specific values, they'll be left alone. -# -# == Fixture label interpolation -# -# The label of the current fixture is always available as a column value: -# -# geeksomnia: -# name: Geeksomnia's Account -# subdomain: $LABEL -# -# Also, sometimes (like when porting older join table fixtures) you'll need -# to be able to get ahold of the identifier for a given label. ERB -# to the rescue: -# -# george_reginald: -# monkey_id: <%= Fixtures.identify(:reginald) %> -# pirate_id: <%= Fixtures.identify(:george) %> -# -# == Support for YAML defaults -# -# You probably already know how to use YAML to set and reuse defaults in -# your <tt>database.yml</tt> file. You can use the same technique in your fixtures: -# -# DEFAULTS: &DEFAULTS -# created_on: <%= 3.weeks.ago.to_s(:db) %> -# -# first: -# name: Smurf -# <<: *DEFAULTS -# -# second: -# name: Fraggle -# <<: *DEFAULTS -# -# Any fixture labeled "DEFAULTS" is safely ignored. - -class Fixtures < (RUBY_VERSION < '1.9' ? YAML::Omap : Hash) - DEFAULT_FILTER_RE = /\.ya?ml$/ - - @@all_cached_fixtures = {} - - def self.reset_cache(connection = nil) - connection ||= ActiveRecord::Base.connection - @@all_cached_fixtures[connection.object_id] = {} - end - - def self.cache_for_connection(connection) - @@all_cached_fixtures[connection.object_id] ||= {} - @@all_cached_fixtures[connection.object_id] - end - - def self.fixture_is_cached?(connection, table_name) - cache_for_connection(connection)[table_name] - end - - def self.cached_fixtures(connection, keys_to_fetch = nil) - if keys_to_fetch - fixtures = cache_for_connection(connection).values_at(*keys_to_fetch) - else - fixtures = cache_for_connection(connection).values - end - fixtures.size > 1 ? fixtures : fixtures.first - end - - def self.cache_fixtures(connection, fixtures_map) - cache_for_connection(connection).update(fixtures_map) - end - - def self.instantiate_fixtures(object, table_name, fixtures, load_instances = true) - object.instance_variable_set "@#{table_name.to_s.gsub('.','_')}", fixtures - if load_instances - ActiveRecord::Base.silence do - fixtures.each do |name, fixture| - begin - object.instance_variable_set "@#{name}", fixture.find - rescue FixtureClassNotFound - nil - end - end - end - end - end - - def self.instantiate_all_loaded_fixtures(object, load_instances = true) - all_loaded_fixtures.each do |table_name, fixtures| - Fixtures.instantiate_fixtures(object, table_name, fixtures, load_instances) - end - end - - cattr_accessor :all_loaded_fixtures - self.all_loaded_fixtures = {} - - def self.create_fixtures(fixtures_directory, table_names, class_names = {}) - table_names = [table_names].flatten.map { |n| n.to_s } - connection = block_given? ? yield : ActiveRecord::Base.connection - - table_names_to_fetch = table_names.reject { |table_name| fixture_is_cached?(connection, table_name) } - - unless table_names_to_fetch.empty? - ActiveRecord::Base.silence do - connection.disable_referential_integrity do - fixtures_map = {} - - fixtures = table_names_to_fetch.map do |table_name| - fixtures_map[table_name] = Fixtures.new(connection, File.split(table_name.to_s).last, class_names[table_name.to_sym], File.join(fixtures_directory, table_name.to_s)) - end - - all_loaded_fixtures.update(fixtures_map) - - connection.transaction(:requires_new => true) do - fixtures.reverse.each { |fixture| fixture.delete_existing_fixtures } - fixtures.each { |fixture| fixture.insert_fixtures } - - # Cap primary key sequences to max(pk). - if connection.respond_to?(:reset_pk_sequence!) - table_names.each do |table_name| - connection.reset_pk_sequence!(table_name) - end - end - end - - cache_fixtures(connection, fixtures_map) - end - end - end - cached_fixtures(connection, table_names) - end - - # Returns a consistent identifier for +label+. This will always - # be a positive integer, and will always be the same for a given - # label, assuming the same OS, platform, and version of Ruby. - def self.identify(label) - label.to_s.hash.abs - end - - attr_reader :table_name, :name - - def initialize(connection, table_name, class_name, fixture_path, file_filter = DEFAULT_FILTER_RE) - @connection, @table_name, @fixture_path, @file_filter = connection, table_name, fixture_path, file_filter - @name = table_name # preserve fixture base name - @class_name = class_name || - (ActiveRecord::Base.pluralize_table_names ? @table_name.singularize.camelize : @table_name.camelize) - @table_name = "#{ActiveRecord::Base.table_name_prefix}#{@table_name}#{ActiveRecord::Base.table_name_suffix}" - @table_name = class_name.table_name if class_name.respond_to?(:table_name) - @connection = class_name.connection if class_name.respond_to?(:connection) - read_fixture_files - end - - def delete_existing_fixtures - @connection.delete "DELETE FROM #{@connection.quote_table_name(table_name)}", 'Fixture Delete' - end - - def insert_fixtures - now = ActiveRecord::Base.default_timezone == :utc ? Time.now.utc : Time.now - now = now.to_s(:db) - - # allow a standard key to be used for doing defaults in YAML - if is_a?(Hash) - delete('DEFAULTS') - else - delete(assoc('DEFAULTS')) - end - - # track any join tables we need to insert later - habtm_fixtures = Hash.new do |h, habtm| - h[habtm] = HabtmFixtures.new(@connection, habtm.options[:join_table], nil, nil) - end - - each do |label, fixture| - row = fixture.to_hash - - if model_class && model_class < ActiveRecord::Base - # fill in timestamp columns if they aren't specified and the model is set to record_timestamps - if model_class.record_timestamps - timestamp_column_names.each do |name| - row[name] = now unless row.key?(name) - end - end - - # interpolate the fixture label - row.each do |key, value| - row[key] = label if value == "$LABEL" - end - - # generate a primary key if necessary - if has_primary_key_column? && !row.include?(primary_key_name) - row[primary_key_name] = Fixtures.identify(label) - end - - # If STI is used, find the correct subclass for association reflection - reflection_class = - if row.include?(inheritance_column_name) - row[inheritance_column_name].constantize rescue model_class - else - model_class - end - - reflection_class.reflect_on_all_associations.each do |association| - case association.macro - when :belongs_to - # Do not replace association name with association foreign key if they are named the same - fk_name = (association.options[:foreign_key] || "#{association.name}_id").to_s - - if association.name.to_s != fk_name && value = row.delete(association.name.to_s) - if association.options[:polymorphic] - if value.sub!(/\s*\(([^\)]*)\)\s*$/, "") - target_type = $1 - target_type_name = (association.options[:foreign_type] || "#{association.name}_type").to_s - - # support polymorphic belongs_to as "label (Type)" - row[target_type_name] = target_type - end - end - - row[fk_name] = Fixtures.identify(value) - end - when :has_and_belongs_to_many - if (targets = row.delete(association.name.to_s)) - targets = targets.is_a?(Array) ? targets : targets.split(/\s*,\s*/) - join_fixtures = habtm_fixtures[association] - - targets.each do |target| - join_fixtures["#{label}_#{target}"] = Fixture.new( - { association.primary_key_name => row[primary_key_name], - association.association_foreign_key => Fixtures.identify(target) }, nil) - end - end - end - end - end - - @connection.insert_fixture(fixture, @table_name) - end - - # insert any HABTM join tables we discovered - habtm_fixtures.values.each do |fixture| - fixture.delete_existing_fixtures - fixture.insert_fixtures - end - end - - private - class HabtmFixtures < ::Fixtures #:nodoc: - def read_fixture_files; end - end - - def model_class - unless defined?(@model_class) - @model_class = - if @class_name.nil? || @class_name.is_a?(Class) - @class_name - else - @class_name.constantize rescue nil - end - end - - @model_class - end - - def primary_key_name - @primary_key_name ||= model_class && model_class.primary_key - end - - def has_primary_key_column? - @has_primary_key_column ||= model_class && primary_key_name && - model_class.columns.find { |c| c.name == primary_key_name } - end - - def timestamp_column_names - @timestamp_column_names ||= %w(created_at created_on updated_at updated_on).select do |name| - column_names.include?(name) - end - end - - def inheritance_column_name - @inheritance_column_name ||= model_class && model_class.inheritance_column - end - - def column_names - @column_names ||= @connection.columns(@table_name).collect(&:name) - end - - def read_fixture_files - if File.file?(yaml_file_path) - read_yaml_fixture_files - elsif File.file?(csv_file_path) - read_csv_fixture_files - end - end - - def read_yaml_fixture_files - yaml_string = "" - Dir["#{@fixture_path}/**/*.yml"].select { |f| test(?f, f) }.each do |subfixture_path| - yaml_string << IO.read(subfixture_path) - end - yaml_string << IO.read(yaml_file_path) - - if yaml = parse_yaml_string(yaml_string) - # If the file is an ordered map, extract its children. - yaml_value = - if yaml.respond_to?(:type_id) && yaml.respond_to?(:value) - yaml.value - else - [yaml] - end - - yaml_value.each do |fixture| - raise Fixture::FormatError, "Bad data for #{@class_name} fixture named #{fixture}" unless fixture.respond_to?(:each) - fixture.each do |name, data| - unless data - raise Fixture::FormatError, "Bad data for #{@class_name} fixture named #{name} (nil)" - end - - self[name] = Fixture.new(data, model_class) - end - end - end - end - - def read_csv_fixture_files - reader = CSV.parse(erb_render(IO.read(csv_file_path))) - header = reader.shift - i = 0 - reader.each do |row| - data = {} - row.each_with_index { |cell, j| data[header[j].to_s.strip] = cell.to_s.strip } - self["#{@class_name.to_s.underscore}_#{i+=1}"] = Fixture.new(data, model_class) - end - end - - def yaml_file_path - "#{@fixture_path}.yml" - end - - def csv_file_path - @fixture_path + ".csv" - end - - def yaml_fixtures_key(path) - File.basename(@fixture_path).split(".").first - end - - def parse_yaml_string(fixture_content) - YAML::load(erb_render(fixture_content)) - rescue => error - raise Fixture::FormatError, "a YAML error occurred parsing #{yaml_file_path}. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html\nThe exact error was:\n #{error.class}: #{error}" - end - - def erb_render(fixture_content) - ERB.new(fixture_content).result - end -end - -class Fixture #:nodoc: - include Enumerable - - class FixtureError < StandardError #:nodoc: - end - - class FormatError < FixtureError #:nodoc: - end - - attr_reader :model_class - - def initialize(fixture, model_class) - @fixture = fixture - @model_class = model_class.is_a?(Class) ? model_class : model_class.constantize rescue nil - end - - def class_name - @model_class.name if @model_class - end - - def each - @fixture.each { |item| yield item } - end - - def [](key) - @fixture[key] - end - - def to_hash - @fixture - end - - def key_list - columns = @fixture.keys.collect{ |column_name| ActiveRecord::Base.connection.quote_column_name(column_name) } - columns.join(", ") - end - - def value_list - list = @fixture.inject([]) do |fixtures, (key, value)| - col = model_class.columns_hash[key] if model_class.respond_to?(:ancestors) && model_class.ancestors.include?(ActiveRecord::Base) - fixtures << ActiveRecord::Base.connection.quote(value, col).gsub('[^\]\\n', "\n").gsub('[^\]\\r', "\r") - end - list * ', ' - end - - def find - if model_class - model_class.find(self[model_class.primary_key]) - else - raise FixtureClassNotFound, "No class attached to find." - end - end -end - -module ActiveRecord - module TestFixtures - def self.included(base) - base.class_eval do - setup :setup_fixtures - teardown :teardown_fixtures - - superclass_delegating_accessor :fixture_path - superclass_delegating_accessor :fixture_table_names - superclass_delegating_accessor :fixture_class_names - superclass_delegating_accessor :use_transactional_fixtures - superclass_delegating_accessor :use_instantiated_fixtures # true, false, or :no_instances - superclass_delegating_accessor :pre_loaded_fixtures - - self.fixture_table_names = [] - self.use_transactional_fixtures = false - self.use_instantiated_fixtures = true - self.pre_loaded_fixtures = false - - self.fixture_class_names = {} - end - - base.extend ClassMethods - end - - module ClassMethods - def set_fixture_class(class_names = {}) - self.fixture_class_names = self.fixture_class_names.merge(class_names) - end - - def fixtures(*table_names) - if table_names.first == :all - table_names = Dir["#{fixture_path}/*.yml"] + Dir["#{fixture_path}/*.csv"] - table_names.map! { |f| File.basename(f).split('.')[0..-2].join('.') } - else - table_names = table_names.flatten.map { |n| n.to_s } - end - - self.fixture_table_names |= table_names - require_fixture_classes(table_names) - setup_fixture_accessors(table_names) - end - - def try_to_load_dependency(file_name) - require_dependency file_name - rescue LoadError => e - # Let's hope the developer has included it himself - - # Let's warn in case this is a subdependency, otherwise - # subdependency error messages are totally cryptic - if ActiveRecord::Base.logger - ActiveRecord::Base.logger.warn("Unable to load #{file_name}, underlying cause #{e.message} \n\n #{e.backtrace.join("\n")}") - end - end - - def require_fixture_classes(table_names = nil) - (table_names || fixture_table_names).each do |table_name| - file_name = table_name.to_s - file_name = file_name.singularize if ActiveRecord::Base.pluralize_table_names - try_to_load_dependency(file_name) - end - end - - def setup_fixture_accessors(table_names = nil) - table_names = [table_names] if table_names && !table_names.respond_to?(:each) - (table_names || fixture_table_names).each do |table_name| - table_name = table_name.to_s.tr('.', '_') - - define_method(table_name) do |*fixtures| - force_reload = fixtures.pop if fixtures.last == true || fixtures.last == :reload - - @fixture_cache[table_name] ||= {} - - instances = fixtures.map do |fixture| - @fixture_cache[table_name].delete(fixture) if force_reload - - if @loaded_fixtures[table_name][fixture.to_s] - @fixture_cache[table_name][fixture] ||= @loaded_fixtures[table_name][fixture.to_s].find - else - raise StandardError, "No fixture with name '#{fixture}' found for table '#{table_name}'" - end - end - - instances.size == 1 ? instances.first : instances - end - end - end - - def uses_transaction(*methods) - @uses_transaction = [] unless defined?(@uses_transaction) - @uses_transaction.concat methods.map(&:to_s) - end - - def uses_transaction?(method) - @uses_transaction = [] unless defined?(@uses_transaction) - @uses_transaction.include?(method.to_s) - end - end - - def run_in_transaction? - use_transactional_fixtures && - !self.class.uses_transaction?(method_name) - end - - def setup_fixtures - return unless defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank? - - if pre_loaded_fixtures && !use_transactional_fixtures - raise RuntimeError, 'pre_loaded_fixtures requires use_transactional_fixtures' - end - - @fixture_cache = {} - @@already_loaded_fixtures ||= {} - - # Load fixtures once and begin transaction. - if run_in_transaction? - if @@already_loaded_fixtures[self.class] - @loaded_fixtures = @@already_loaded_fixtures[self.class] - else - load_fixtures - @@already_loaded_fixtures[self.class] = @loaded_fixtures - end - ActiveRecord::Base.connection.increment_open_transactions - ActiveRecord::Base.connection.transaction_joinable = false - ActiveRecord::Base.connection.begin_db_transaction - # Load fixtures for every test. - else - Fixtures.reset_cache - @@already_loaded_fixtures[self.class] = nil - load_fixtures - end - - # Instantiate fixtures for every test if requested. - instantiate_fixtures if use_instantiated_fixtures - end - - def teardown_fixtures - return unless defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank? - - unless run_in_transaction? - Fixtures.reset_cache - end - - # Rollback changes if a transaction is active. - if run_in_transaction? && ActiveRecord::Base.connection.open_transactions != 0 - ActiveRecord::Base.connection.rollback_db_transaction - ActiveRecord::Base.connection.decrement_open_transactions - end - ActiveRecord::Base.clear_active_connections! - end - - private - def load_fixtures - @loaded_fixtures = {} - fixtures = Fixtures.create_fixtures(fixture_path, fixture_table_names, fixture_class_names) - unless fixtures.nil? - if fixtures.instance_of?(Fixtures) - @loaded_fixtures[fixtures.name] = fixtures - else - fixtures.each { |f| @loaded_fixtures[f.name] = f } - end - end - end - - # for pre_loaded_fixtures, only require the classes once. huge speed improvement - @@required_fixture_classes = false - - def instantiate_fixtures - if pre_loaded_fixtures - raise RuntimeError, 'Load fixtures before instantiating them.' if Fixtures.all_loaded_fixtures.empty? - unless @@required_fixture_classes - self.class.require_fixture_classes Fixtures.all_loaded_fixtures.keys - @@required_fixture_classes = true - end - Fixtures.instantiate_all_loaded_fixtures(self, load_instances?) - else - raise RuntimeError, 'Load fixtures before instantiating them.' if @loaded_fixtures.nil? - @loaded_fixtures.each do |table_name, fixtures| - Fixtures.instantiate_fixtures(self, table_name, fixtures, load_instances?) - end - end - end - - def load_instances? - use_instantiated_fixtures != :no_instances - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/i18n_interpolation_deprecation.rb b/vendor/rails/activerecord/lib/active_record/i18n_interpolation_deprecation.rb deleted file mode 100644 index cd634e1..0000000 --- a/vendor/rails/activerecord/lib/active_record/i18n_interpolation_deprecation.rb +++ /dev/null @@ -1,26 +0,0 @@ -# Deprecates the use of the former message interpolation syntax in activerecord -# as in "must have %d characters". The new syntax uses explicit variable names -# as in "{{value}} must have {{count}} characters". - -require 'i18n/backend/simple' -module I18n - module Backend - class Simple - DEPRECATED_INTERPOLATORS = { '%d' => '{{count}}', '%s' => '{{value}}' } - - protected - def interpolate_with_deprecated_syntax(locale, string, values = {}) - return string unless string.is_a?(String) - - string = string.gsub(/%d|%s/) do |s| - instead = DEPRECATED_INTERPOLATORS[s] - ActiveSupport::Deprecation.warn "using #{s} in messages is deprecated; use #{instead} instead." - instead - end - - interpolate_without_deprecated_syntax(locale, string, values) - end - alias_method_chain :interpolate, :deprecated_syntax - end - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/lib/active_record/locale/en.yml b/vendor/rails/activerecord/lib/active_record/locale/en.yml deleted file mode 100644 index bf8a71d..0000000 --- a/vendor/rails/activerecord/lib/active_record/locale/en.yml +++ /dev/null @@ -1,54 +0,0 @@ -en: - activerecord: - errors: - # The values :model, :attribute and :value are always available for interpolation - # The value :count is available when applicable. Can be used for pluralization. - messages: - inclusion: "is not included in the list" - exclusion: "is reserved" - invalid: "is invalid" - confirmation: "doesn't match confirmation" - accepted: "must be accepted" - empty: "can't be empty" - blank: "can't be blank" - too_long: "is too long (maximum is {{count}} characters)" - too_short: "is too short (minimum is {{count}} characters)" - wrong_length: "is the wrong length (should be {{count}} characters)" - taken: "has already been taken" - not_a_number: "is not a number" - greater_than: "must be greater than {{count}}" - greater_than_or_equal_to: "must be greater than or equal to {{count}}" - equal_to: "must be equal to {{count}}" - less_than: "must be less than {{count}}" - less_than_or_equal_to: "must be less than or equal to {{count}}" - odd: "must be odd" - even: "must be even" - # Append your own errors here or at the model/attributes scope. - - # You can define own errors for models or model attributes. - # The values :model, :attribute and :value are always available for interpolation. - # - # For example, - # models: - # user: - # blank: "This is a custom blank message for {{model}}: {{attribute}}" - # attributes: - # login: - # blank: "This is a custom blank message for User login" - # Will define custom blank validation message for User model and - # custom blank validation message for login attribute of User model. - #models: - - # Translate model names. Used in Model.human_name(). - #models: - # For example, - # user: "Dude" - # will translate User model name to "Dude" - - # Translate model attribute names. Used in Model.human_attribute_name(attribute). - #attributes: - # For example, - # user: - # login: "Handle" - # will translate User attribute "login" as "Handle" - diff --git a/vendor/rails/activerecord/lib/active_record/locking/optimistic.rb b/vendor/rails/activerecord/lib/active_record/locking/optimistic.rb deleted file mode 100644 index 7fa7e26..0000000 --- a/vendor/rails/activerecord/lib/active_record/locking/optimistic.rb +++ /dev/null @@ -1,181 +0,0 @@ -module ActiveRecord - module Locking - # == What is Optimistic Locking - # - # Optimistic locking allows multiple users to access the same record for edits, and assumes a minimum of - # conflicts with the data. It does this by checking whether another process has made changes to a record since - # it was opened, an ActiveRecord::StaleObjectError is thrown if that has occurred and the update is ignored. - # - # Check out ActiveRecord::Locking::Pessimistic for an alternative. - # - # == Usage - # - # Active Records support optimistic locking if the field <tt>lock_version</tt> is present. Each update to the - # record increments the lock_version column and the locking facilities ensure that records instantiated twice - # will let the last one saved raise a StaleObjectError if the first was also updated. Example: - # - # p1 = Person.find(1) - # p2 = Person.find(1) - # - # p1.first_name = "Michael" - # p1.save - # - # p2.first_name = "should fail" - # p2.save # Raises a ActiveRecord::StaleObjectError - # - # Optimistic locking will also check for stale data when objects are destroyed. Example: - # - # p1 = Person.find(1) - # p2 = Person.find(1) - # - # p1.first_name = "Michael" - # p1.save - # - # p2.destroy # Raises a ActiveRecord::StaleObjectError - # - # You're then responsible for dealing with the conflict by rescuing the exception and either rolling back, merging, - # or otherwise apply the business logic needed to resolve the conflict. - # - # You must ensure that your database schema defaults the lock_version column to 0. - # - # This behavior can be turned off by setting <tt>ActiveRecord::Base.lock_optimistically = false</tt>. - # To override the name of the lock_version column, invoke the <tt>set_locking_column</tt> method. - # This method uses the same syntax as <tt>set_table_name</tt> - module Optimistic - def self.included(base) #:nodoc: - base.extend ClassMethods - - base.cattr_accessor :lock_optimistically, :instance_writer => false - base.lock_optimistically = true - - base.alias_method_chain :update, :lock - base.alias_method_chain :destroy, :lock - base.alias_method_chain :attributes_from_column_definition, :lock - - class << base - alias_method :locking_column=, :set_locking_column - end - end - - def locking_enabled? #:nodoc: - self.class.locking_enabled? - end - - private - def attributes_from_column_definition_with_lock - result = attributes_from_column_definition_without_lock - - # If the locking column has no default value set, - # start the lock version at zero. Note we can't use - # locking_enabled? at this point as @attributes may - # not have been initialized yet - - if lock_optimistically && result.include?(self.class.locking_column) - result[self.class.locking_column] ||= 0 - end - - return result - end - - def update_with_lock(attribute_names = @attributes.keys) #:nodoc: - return update_without_lock(attribute_names) unless locking_enabled? - return 0 if attribute_names.empty? - - lock_col = self.class.locking_column - previous_value = send(lock_col).to_i - send(lock_col + '=', previous_value + 1) - - attribute_names += [lock_col] - attribute_names.uniq! - - begin - affected_rows = connection.update(<<-end_sql, "#{self.class.name} Update with optimistic locking") - UPDATE #{self.class.quoted_table_name} - SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false, false, attribute_names))} - WHERE #{self.class.primary_key} = #{quote_value(id)} - AND #{self.class.quoted_locking_column} = #{quote_value(previous_value)} - end_sql - - unless affected_rows == 1 - raise ActiveRecord::StaleObjectError, "Attempted to update a stale object" - end - - affected_rows - - # If something went wrong, revert the version. - rescue Exception - send(lock_col + '=', previous_value) - raise - end - end - - def destroy_with_lock #:nodoc: - return destroy_without_lock unless locking_enabled? - - unless new_record? - lock_col = self.class.locking_column - previous_value = send(lock_col).to_i - - affected_rows = connection.delete( - "DELETE FROM #{self.class.quoted_table_name} " + - "WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quoted_id} " + - "AND #{self.class.quoted_locking_column} = #{quote_value(previous_value)}", - "#{self.class.name} Destroy" - ) - - unless affected_rows == 1 - raise ActiveRecord::StaleObjectError, "Attempted to delete a stale object" - end - end - - freeze - end - - module ClassMethods - DEFAULT_LOCKING_COLUMN = 'lock_version' - - def self.extended(base) - class <<base - alias_method_chain :update_counters, :lock - end - end - - # Is optimistic locking enabled for this table? Returns true if the - # +lock_optimistically+ flag is set to true (which it is, by default) - # and the table includes the +locking_column+ column (defaults to - # +lock_version+). - def locking_enabled? - lock_optimistically && columns_hash[locking_column] - end - - # Set the column to use for optimistic locking. Defaults to +lock_version+. - def set_locking_column(value = nil, &block) - define_attr_method :locking_column, value, &block - value - end - - # The version column used for optimistic locking. Defaults to +lock_version+. - def locking_column - reset_locking_column - end - - # Quote the column name used for optimistic locking. - def quoted_locking_column - connection.quote_column_name(locking_column) - end - - # Reset the column used for optimistic locking back to the +lock_version+ default. - def reset_locking_column - set_locking_column DEFAULT_LOCKING_COLUMN - end - - # Make sure the lock version column gets updated when counters are - # updated. - def update_counters_with_lock(id, counters) - counters = counters.merge(locking_column => 1) if locking_enabled? - update_counters_without_lock(id, counters) - end - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/locking/pessimistic.rb b/vendor/rails/activerecord/lib/active_record/locking/pessimistic.rb deleted file mode 100644 index 3206595..0000000 --- a/vendor/rails/activerecord/lib/active_record/locking/pessimistic.rb +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright (c) 2006 Shugo Maeda <shugo@ruby-lang.org> -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject -# to the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -module ActiveRecord - module Locking - # Locking::Pessimistic provides support for row-level locking using - # SELECT ... FOR UPDATE and other lock types. - # - # Pass <tt>:lock => true</tt> to ActiveRecord::Base.find to obtain an exclusive - # lock on the selected rows: - # # select * from accounts where id=1 for update - # Account.find(1, :lock => true) - # - # Pass <tt>:lock => 'some locking clause'</tt> to give a database-specific locking clause - # of your own such as 'LOCK IN SHARE MODE' or 'FOR UPDATE NOWAIT'. - # - # Example: - # Account.transaction do - # # select * from accounts where name = 'shugo' limit 1 for update - # shugo = Account.find(:first, :conditions => "name = 'shugo'", :lock => true) - # yuko = Account.find(:first, :conditions => "name = 'yuko'", :lock => true) - # shugo.balance -= 100 - # shugo.save! - # yuko.balance += 100 - # yuko.save! - # end - # - # You can also use ActiveRecord::Base#lock! method to lock one record by id. - # This may be better if you don't need to lock every row. Example: - # Account.transaction do - # # select * from accounts where ... - # accounts = Account.find(:all, :conditions => ...) - # account1 = accounts.detect { |account| ... } - # account2 = accounts.detect { |account| ... } - # # select * from accounts where id=? for update - # account1.lock! - # account2.lock! - # account1.balance -= 100 - # account1.save! - # account2.balance += 100 - # account2.save! - # end - # - # Database-specific information on row locking: - # MySQL: http://dev.mysql.com/doc/refman/5.1/en/innodb-locking-reads.html - # PostgreSQL: http://www.postgresql.org/docs/8.1/interactive/sql-select.html#SQL-FOR-UPDATE-SHARE - module Pessimistic - # Obtain a row lock on this record. Reloads the record to obtain the requested - # lock. Pass an SQL locking clause to append the end of the SELECT statement - # or pass true for "FOR UPDATE" (the default, an exclusive row lock). Returns - # the locked record. - def lock!(lock = true) - reload(:lock => lock) unless new_record? - self - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/migration.rb b/vendor/rails/activerecord/lib/active_record/migration.rb deleted file mode 100644 index 657acd6..0000000 --- a/vendor/rails/activerecord/lib/active_record/migration.rb +++ /dev/null @@ -1,566 +0,0 @@ -module ActiveRecord - class IrreversibleMigration < ActiveRecordError#:nodoc: - end - - class DuplicateMigrationVersionError < ActiveRecordError#:nodoc: - def initialize(version) - super("Multiple migrations have the version number #{version}") - end - end - - class DuplicateMigrationNameError < ActiveRecordError#:nodoc: - def initialize(name) - super("Multiple migrations have the name #{name}") - end - end - - class UnknownMigrationVersionError < ActiveRecordError #:nodoc: - def initialize(version) - super("No migration with version number #{version}") - end - end - - class IllegalMigrationNameError < ActiveRecordError#:nodoc: - def initialize(name) - super("Illegal name for migration file: #{name}\n\t(only lower case letters, numbers, and '_' allowed)") - end - end - - # Migrations can manage the evolution of a schema used by several physical databases. It's a solution - # to the common problem of adding a field to make a new feature work in your local database, but being unsure of how to - # push that change to other developers and to the production server. With migrations, you can describe the transformations - # in self-contained classes that can be checked into version control systems and executed against another database that - # might be one, two, or five versions behind. - # - # Example of a simple migration: - # - # class AddSsl < ActiveRecord::Migration - # def self.up - # add_column :accounts, :ssl_enabled, :boolean, :default => 1 - # end - # - # def self.down - # remove_column :accounts, :ssl_enabled - # end - # end - # - # This migration will add a boolean flag to the accounts table and remove it if you're backing out of the migration. - # It shows how all migrations have two class methods +up+ and +down+ that describes the transformations required to implement - # or remove the migration. These methods can consist of both the migration specific methods like add_column and remove_column, - # but may also contain regular Ruby code for generating data needed for the transformations. - # - # Example of a more complex migration that also needs to initialize data: - # - # class AddSystemSettings < ActiveRecord::Migration - # def self.up - # create_table :system_settings do |t| - # t.string :name - # t.string :label - # t.text :value - # t.string :type - # t.integer :position - # end - # - # SystemSetting.create :name => "notice", :label => "Use notice?", :value => 1 - # end - # - # def self.down - # drop_table :system_settings - # end - # end - # - # This migration first adds the system_settings table, then creates the very first row in it using the Active Record model - # that relies on the table. It also uses the more advanced create_table syntax where you can specify a complete table schema - # in one block call. - # - # == Available transformations - # - # * <tt>create_table(name, options)</tt> Creates a table called +name+ and makes the table object available to a block - # that can then add columns to it, following the same format as add_column. See example above. The options hash is for - # fragments like "DEFAULT CHARSET=UTF-8" that are appended to the create table definition. - # * <tt>drop_table(name)</tt>: Drops the table called +name+. - # * <tt>rename_table(old_name, new_name)</tt>: Renames the table called +old_name+ to +new_name+. - # * <tt>add_column(table_name, column_name, type, options)</tt>: Adds a new column to the table called +table_name+ - # named +column_name+ specified to be one of the following types: - # <tt>:string</tt>, <tt>:text</tt>, <tt>:integer</tt>, <tt>:float</tt>, <tt>:decimal</tt>, <tt>:datetime</tt>, <tt>:timestamp</tt>, <tt>:time</tt>, - # <tt>:date</tt>, <tt>:binary</tt>, <tt>:boolean</tt>. A default value can be specified by passing an - # +options+ hash like <tt>{ :default => 11 }</tt>. Other options include <tt>:limit</tt> and <tt>:null</tt> (e.g. <tt>{ :limit => 50, :null => false }</tt>) - # -- see ActiveRecord::ConnectionAdapters::TableDefinition#column for details. - # * <tt>rename_column(table_name, column_name, new_column_name)</tt>: Renames a column but keeps the type and content. - # * <tt>change_column(table_name, column_name, type, options)</tt>: Changes the column to a different type using the same - # parameters as add_column. - # * <tt>remove_column(table_name, column_name)</tt>: Removes the column named +column_name+ from the table called +table_name+. - # * <tt>add_index(table_name, column_names, options)</tt>: Adds a new index with the name of the column. Other options include - # <tt>:name</tt> and <tt>:unique</tt> (e.g. <tt>{ :name => "users_name_index", :unique => true }</tt>). - # * <tt>remove_index(table_name, index_name)</tt>: Removes the index specified by +index_name+. - # - # == Irreversible transformations - # - # Some transformations are destructive in a manner that cannot be reversed. Migrations of that kind should raise - # an <tt>ActiveRecord::IrreversibleMigration</tt> exception in their +down+ method. - # - # == Running migrations from within Rails - # - # The Rails package has several tools to help create and apply migrations. - # - # To generate a new migration, you can use - # script/generate migration MyNewMigration - # - # where MyNewMigration is the name of your migration. The generator will - # create an empty migration file <tt>nnn_my_new_migration.rb</tt> in the <tt>db/migrate/</tt> - # directory where <tt>nnn</tt> is the next largest migration number. - # - # You may then edit the <tt>self.up</tt> and <tt>self.down</tt> methods of - # MyNewMigration. - # - # There is a special syntactic shortcut to generate migrations that add fields to a table. - # script/generate migration add_fieldname_to_tablename fieldname:string - # - # This will generate the file <tt>nnn_add_fieldname_to_tablename</tt>, which will look like this: - # class AddFieldnameToTablename < ActiveRecord::Migration - # def self.up - # add_column :tablenames, :fieldname, :string - # end - # - # def self.down - # remove_column :tablenames, :fieldname - # end - # end - # - # To run migrations against the currently configured database, use - # <tt>rake db:migrate</tt>. This will update the database by running all of the - # pending migrations, creating the <tt>schema_migrations</tt> table - # (see "About the schema_migrations table" section below) if missing. It will also - # invoke the db:schema:dump task, which will update your db/schema.rb file - # to match the structure of your database. - # - # To roll the database back to a previous migration version, use - # <tt>rake db:migrate VERSION=X</tt> where <tt>X</tt> is the version to which - # you wish to downgrade. If any of the migrations throw an - # <tt>ActiveRecord::IrreversibleMigration</tt> exception, that step will fail and you'll - # have some manual work to do. - # - # == Database support - # - # Migrations are currently supported in MySQL, PostgreSQL, SQLite, - # SQL Server, Sybase, and Oracle (all supported databases except DB2). - # - # == More examples - # - # Not all migrations change the schema. Some just fix the data: - # - # class RemoveEmptyTags < ActiveRecord::Migration - # def self.up - # Tag.find(:all).each { |tag| tag.destroy if tag.pages.empty? } - # end - # - # def self.down - # # not much we can do to restore deleted data - # raise ActiveRecord::IrreversibleMigration, "Can't recover the deleted tags" - # end - # end - # - # Others remove columns when they migrate up instead of down: - # - # class RemoveUnnecessaryItemAttributes < ActiveRecord::Migration - # def self.up - # remove_column :items, :incomplete_items_count - # remove_column :items, :completed_items_count - # end - # - # def self.down - # add_column :items, :incomplete_items_count - # add_column :items, :completed_items_count - # end - # end - # - # And sometimes you need to do something in SQL not abstracted directly by migrations: - # - # class MakeJoinUnique < ActiveRecord::Migration - # def self.up - # execute "ALTER TABLE `pages_linked_pages` ADD UNIQUE `page_id_linked_page_id` (`page_id`,`linked_page_id`)" - # end - # - # def self.down - # execute "ALTER TABLE `pages_linked_pages` DROP INDEX `page_id_linked_page_id`" - # end - # end - # - # == Using a model after changing its table - # - # Sometimes you'll want to add a column in a migration and populate it immediately after. In that case, you'll need - # to make a call to Base#reset_column_information in order to ensure that the model has the latest column data from - # after the new column was added. Example: - # - # class AddPeopleSalary < ActiveRecord::Migration - # def self.up - # add_column :people, :salary, :integer - # Person.reset_column_information - # Person.find(:all).each do |p| - # p.update_attribute :salary, SalaryCalculator.compute(p) - # end - # end - # end - # - # == Controlling verbosity - # - # By default, migrations will describe the actions they are taking, writing - # them to the console as they happen, along with benchmarks describing how - # long each step took. - # - # You can quiet them down by setting ActiveRecord::Migration.verbose = false. - # - # You can also insert your own messages and benchmarks by using the +say_with_time+ - # method: - # - # def self.up - # ... - # say_with_time "Updating salaries..." do - # Person.find(:all).each do |p| - # p.update_attribute :salary, SalaryCalculator.compute(p) - # end - # end - # ... - # end - # - # The phrase "Updating salaries..." would then be printed, along with the - # benchmark for the block when the block completes. - # - # == About the schema_migrations table - # - # Rails versions 2.0 and prior used to create a table called - # <tt>schema_info</tt> when using migrations. This table contained the - # version of the schema as of the last applied migration. - # - # Starting with Rails 2.1, the <tt>schema_info</tt> table is - # (automatically) replaced by the <tt>schema_migrations</tt> table, which - # contains the version numbers of all the migrations applied. - # - # As a result, it is now possible to add migration files that are numbered - # lower than the current schema version: when migrating up, those - # never-applied "interleaved" migrations will be automatically applied, and - # when migrating down, never-applied "interleaved" migrations will be skipped. - # - # == Timestamped Migrations - # - # By default, Rails generates migrations that look like: - # - # 20080717013526_your_migration_name.rb - # - # The prefix is a generation timestamp (in UTC). - # - # If you'd prefer to use numeric prefixes, you can turn timestamped migrations - # off by setting: - # - # config.active_record.timestamped_migrations = false - # - # In environment.rb. - # - class Migration - @@verbose = true - cattr_accessor :verbose - - class << self - def up_with_benchmarks #:nodoc: - migrate(:up) - end - - def down_with_benchmarks #:nodoc: - migrate(:down) - end - - # Execute this migration in the named direction - def migrate(direction) - return unless respond_to?(direction) - - case direction - when :up then announce "migrating" - when :down then announce "reverting" - end - - result = nil - time = Benchmark.measure { result = send("#{direction}_without_benchmarks") } - - case direction - when :up then announce "migrated (%.4fs)" % time.real; write - when :down then announce "reverted (%.4fs)" % time.real; write - end - - result - end - - # Because the method added may do an alias_method, it can be invoked - # recursively. We use @ignore_new_methods as a guard to indicate whether - # it is safe for the call to proceed. - def singleton_method_added(sym) #:nodoc: - return if defined?(@ignore_new_methods) && @ignore_new_methods - - begin - @ignore_new_methods = true - - case sym - when :up, :down - klass = (class << self; self; end) - klass.send(:alias_method_chain, sym, "benchmarks") - end - ensure - @ignore_new_methods = false - end - end - - def write(text="") - puts(text) if verbose - end - - def announce(message) - text = "#{@version} #{name}: #{message}" - length = [0, 75 - text.length].max - write "== %s %s" % [text, "=" * length] - end - - def say(message, subitem=false) - write "#{subitem ? " ->" : "--"} #{message}" - end - - def say_with_time(message) - say(message) - result = nil - time = Benchmark.measure { result = yield } - say "%.4fs" % time.real, :subitem - say("#{result} rows", :subitem) if result.is_a?(Integer) - result - end - - def suppress_messages - save, self.verbose = verbose, false - yield - ensure - self.verbose = save - end - - def connection - ActiveRecord::Base.connection - end - - def method_missing(method, *arguments, &block) - arg_list = arguments.map(&:inspect) * ', ' - - say_with_time "#{method}(#{arg_list})" do - unless arguments.empty? || method == :execute - arguments[0] = Migrator.proper_table_name(arguments.first) - end - connection.send(method, *arguments, &block) - end - end - end - end - - # MigrationProxy is used to defer loading of the actual migration classes - # until they are needed - class MigrationProxy - - attr_accessor :name, :version, :filename - - delegate :migrate, :announce, :write, :to=>:migration - - private - - def migration - @migration ||= load_migration - end - - def load_migration - load(filename) - name.constantize - end - - end - - class Migrator#:nodoc: - class << self - def migrate(migrations_path, target_version = nil) - case - when target_version.nil? then up(migrations_path, target_version) - when current_version > target_version then down(migrations_path, target_version) - else up(migrations_path, target_version) - end - end - - def rollback(migrations_path, steps=1) - migrator = self.new(:down, migrations_path) - start_index = migrator.migrations.index(migrator.current_migration) - - return unless start_index - - finish = migrator.migrations[start_index + steps] - down(migrations_path, finish ? finish.version : 0) - end - - def up(migrations_path, target_version = nil) - self.new(:up, migrations_path, target_version).migrate - end - - def down(migrations_path, target_version = nil) - self.new(:down, migrations_path, target_version).migrate - end - - def run(direction, migrations_path, target_version) - self.new(direction, migrations_path, target_version).run - end - - def schema_migrations_table_name - Base.table_name_prefix + 'schema_migrations' + Base.table_name_suffix - end - - def get_all_versions - Base.connection.select_values("SELECT version FROM #{schema_migrations_table_name}").map(&:to_i).sort - end - - def current_version - sm_table = schema_migrations_table_name - if Base.connection.table_exists?(sm_table) - get_all_versions.max || 0 - else - 0 - end - end - - def proper_table_name(name) - # Use the Active Record objects own table_name, or pre/suffix from ActiveRecord::Base if name is a symbol/string - name.table_name rescue "#{ActiveRecord::Base.table_name_prefix}#{name}#{ActiveRecord::Base.table_name_suffix}" - end - end - - def initialize(direction, migrations_path, target_version = nil) - raise StandardError.new("This database does not yet support migrations") unless Base.connection.supports_migrations? - Base.connection.initialize_schema_migrations_table - @direction, @migrations_path, @target_version = direction, migrations_path, target_version - end - - def current_version - migrated.last || 0 - end - - def current_migration - migrations.detect { |m| m.version == current_version } - end - - def run - target = migrations.detect { |m| m.version == @target_version } - raise UnknownMigrationVersionError.new(@target_version) if target.nil? - unless (up? && migrated.include?(target.version.to_i)) || (down? && !migrated.include?(target.version.to_i)) - target.migrate(@direction) - record_version_state_after_migrating(target.version) - end - end - - def migrate - current = migrations.detect { |m| m.version == current_version } - target = migrations.detect { |m| m.version == @target_version } - - if target.nil? && !@target_version.nil? && @target_version > 0 - raise UnknownMigrationVersionError.new(@target_version) - end - - start = up? ? 0 : (migrations.index(current) || 0) - finish = migrations.index(target) || migrations.size - 1 - runnable = migrations[start..finish] - - # skip the last migration if we're headed down, but not ALL the way down - runnable.pop if down? && !target.nil? - - runnable.each do |migration| - Base.logger.info "Migrating to #{migration.name} (#{migration.version})" - - # On our way up, we skip migrating the ones we've already migrated - next if up? && migrated.include?(migration.version.to_i) - - # On our way down, we skip reverting the ones we've never migrated - if down? && !migrated.include?(migration.version.to_i) - migration.announce 'never migrated, skipping'; migration.write - next - end - - begin - ddl_transaction do - migration.migrate(@direction) - record_version_state_after_migrating(migration.version) - end - rescue => e - canceled_msg = Base.connection.supports_ddl_transactions? ? "this and " : "" - raise StandardError, "An error has occurred, #{canceled_msg}all later migrations canceled:\n\n#{e}", e.backtrace - end - end - end - - def migrations - @migrations ||= begin - files = Dir["#{@migrations_path}/[0-9]*_*.rb"] - - migrations = files.inject([]) do |klasses, file| - version, name = file.scan(/([0-9]+)_([_a-z0-9]*).rb/).first - - raise IllegalMigrationNameError.new(file) unless version - version = version.to_i - - if klasses.detect { |m| m.version == version } - raise DuplicateMigrationVersionError.new(version) - end - - if klasses.detect { |m| m.name == name.camelize } - raise DuplicateMigrationNameError.new(name.camelize) - end - - klasses << returning(MigrationProxy.new) do |migration| - migration.name = name.camelize - migration.version = version - migration.filename = file - end - end - - migrations = migrations.sort_by(&:version) - down? ? migrations.reverse : migrations - end - end - - def pending_migrations - already_migrated = migrated - migrations.reject { |m| already_migrated.include?(m.version.to_i) } - end - - def migrated - @migrated_versions ||= self.class.get_all_versions - end - - private - def record_version_state_after_migrating(version) - sm_table = self.class.schema_migrations_table_name - - @migrated_versions ||= [] - if down? - @migrated_versions.delete(version.to_i) - Base.connection.update("DELETE FROM #{sm_table} WHERE version = '#{version}'") - else - @migrated_versions.push(version.to_i).sort! - Base.connection.insert("INSERT INTO #{sm_table} (version) VALUES ('#{version}')") - end - end - - def up? - @direction == :up - end - - def down? - @direction == :down - end - - # Wrap the migration in a transaction only if supported by the adapter. - def ddl_transaction(&block) - if Base.connection.supports_ddl_transactions? - Base.transaction { block.call } - else - block.call - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/named_scope.rb b/vendor/rails/activerecord/lib/active_record/named_scope.rb deleted file mode 100644 index 1f3ef30..0000000 --- a/vendor/rails/activerecord/lib/active_record/named_scope.rb +++ /dev/null @@ -1,197 +0,0 @@ -module ActiveRecord - module NamedScope - # All subclasses of ActiveRecord::Base have one named scope: - # * <tt>scoped</tt> - which allows for the creation of anonymous \scopes, on the fly: <tt>Shirt.scoped(:conditions => {:color => 'red'}).scoped(:include => :washing_instructions)</tt> - # - # These anonymous \scopes tend to be useful when procedurally generating complex queries, where passing - # intermediate values (scopes) around as first-class objects is convenient. - # - # You can define a scope that applies to all finders using ActiveRecord::Base.default_scope. - def self.included(base) - base.class_eval do - extend ClassMethods - named_scope :scoped, lambda { |scope| scope } - end - end - - module ClassMethods - def scopes - read_inheritable_attribute(:scopes) || write_inheritable_attribute(:scopes, {}) - end - - # Adds a class method for retrieving and querying objects. A scope represents a narrowing of a database query, - # such as <tt>:conditions => {:color => :red}, :select => 'shirts.*', :include => :washing_instructions</tt>. - # - # class Shirt < ActiveRecord::Base - # named_scope :red, :conditions => {:color => 'red'} - # named_scope :dry_clean_only, :joins => :washing_instructions, :conditions => ['washing_instructions.dry_clean_only = ?', true] - # end - # - # The above calls to <tt>named_scope</tt> define class methods Shirt.red and Shirt.dry_clean_only. Shirt.red, - # in effect, represents the query <tt>Shirt.find(:all, :conditions => {:color => 'red'})</tt>. - # - # Unlike <tt>Shirt.find(...)</tt>, however, the object returned by Shirt.red is not an Array; it resembles the association object - # constructed by a <tt>has_many</tt> declaration. For instance, you can invoke <tt>Shirt.red.find(:first)</tt>, <tt>Shirt.red.count</tt>, - # <tt>Shirt.red.find(:all, :conditions => {:size => 'small'})</tt>. Also, just - # as with the association objects, named \scopes act like an Array, implementing Enumerable; <tt>Shirt.red.each(&block)</tt>, - # <tt>Shirt.red.first</tt>, and <tt>Shirt.red.inject(memo, &block)</tt> all behave as if Shirt.red really was an Array. - # - # These named \scopes are composable. For instance, <tt>Shirt.red.dry_clean_only</tt> will produce all shirts that are both red and dry clean only. - # Nested finds and calculations also work with these compositions: <tt>Shirt.red.dry_clean_only.count</tt> returns the number of garments - # for which these criteria obtain. Similarly with <tt>Shirt.red.dry_clean_only.average(:thread_count)</tt>. - # - # All \scopes are available as class methods on the ActiveRecord::Base descendant upon which the \scopes were defined. But they are also available to - # <tt>has_many</tt> associations. If, - # - # class Person < ActiveRecord::Base - # has_many :shirts - # end - # - # then <tt>elton.shirts.red.dry_clean_only</tt> will return all of Elton's red, dry clean - # only shirts. - # - # Named \scopes can also be procedural: - # - # class Shirt < ActiveRecord::Base - # named_scope :colored, lambda { |color| - # { :conditions => { :color => color } } - # } - # end - # - # In this example, <tt>Shirt.colored('puce')</tt> finds all puce shirts. - # - # Named \scopes can also have extensions, just as with <tt>has_many</tt> declarations: - # - # class Shirt < ActiveRecord::Base - # named_scope :red, :conditions => {:color => 'red'} do - # def dom_id - # 'red_shirts' - # end - # end - # end - # - # - # For testing complex named \scopes, you can examine the scoping options using the - # <tt>proxy_options</tt> method on the proxy itself. - # - # class Shirt < ActiveRecord::Base - # named_scope :colored, lambda { |color| - # { :conditions => { :color => color } } - # } - # end - # - # expected_options = { :conditions => { :colored => 'red' } } - # assert_equal expected_options, Shirt.colored('red').proxy_options - def named_scope(name, options = {}, &block) - name = name.to_sym - scopes[name] = lambda do |parent_scope, *args| - Scope.new(parent_scope, case options - when Hash - options - when Proc - case parent_scope - when Scope - with_scope(:find => parent_scope.proxy_options) { options.call(*args) } - else - options.call(*args) - end - end, &block) - end - (class << self; self end).instance_eval do - define_method name do |*args| - scopes[name].call(self, *args) - end - end - end - end - - class Scope - attr_reader :proxy_scope, :proxy_options, :current_scoped_methods_when_defined - NON_DELEGATE_METHODS = %w(nil? send object_id class extend find size count sum average maximum minimum paginate first last empty? any? respond_to?).to_set - [].methods.each do |m| - unless m =~ /^__/ || NON_DELEGATE_METHODS.include?(m.to_s) - delegate m, :to => :proxy_found - end - end - - delegate :scopes, :with_scope, :to => :proxy_scope - - def initialize(proxy_scope, options, &block) - options ||= {} - [options[:extend]].flatten.each { |extension| extend extension } if options[:extend] - extend Module.new(&block) if block_given? - unless Scope === proxy_scope - @current_scoped_methods_when_defined = proxy_scope.send(:current_scoped_methods) - end - @proxy_scope, @proxy_options = proxy_scope, options.except(:extend) - end - - def reload - load_found; self - end - - def first(*args) - if args.first.kind_of?(Integer) || (@found && !args.first.kind_of?(Hash)) - proxy_found.first(*args) - else - find(:first, *args) - end - end - - def last(*args) - if args.first.kind_of?(Integer) || (@found && !args.first.kind_of?(Hash)) - proxy_found.last(*args) - else - find(:last, *args) - end - end - - def size - @found ? @found.length : count - end - - def empty? - @found ? @found.empty? : count.zero? - end - - def respond_to?(method, include_private = false) - super || @proxy_scope.respond_to?(method, include_private) - end - - def any? - if block_given? - proxy_found.any? { |*block_args| yield(*block_args) } - else - !empty? - end - end - - protected - def proxy_found - @found || load_found - end - - private - def method_missing(method, *args, &block) - if scopes.include?(method) - scopes[method].call(self, *args) - else - with_scope({:find => proxy_options, :create => proxy_options[:conditions].is_a?(Hash) ? proxy_options[:conditions] : {}}, :reverse_merge) do - method = :new if method == :build - if current_scoped_methods_when_defined - with_scope current_scoped_methods_when_defined do - proxy_scope.send(method, *args, &block) - end - else - proxy_scope.send(method, *args, &block) - end - end - end - end - - def load_found - @found = find(:all) - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/nested_attributes.rb b/vendor/rails/activerecord/lib/active_record/nested_attributes.rb deleted file mode 100644 index e3122d1..0000000 --- a/vendor/rails/activerecord/lib/active_record/nested_attributes.rb +++ /dev/null @@ -1,329 +0,0 @@ -module ActiveRecord - module NestedAttributes #:nodoc: - def self.included(base) - base.extend(ClassMethods) - base.class_inheritable_accessor :reject_new_nested_attributes_procs, :instance_writer => false - base.reject_new_nested_attributes_procs = {} - end - - # == Nested Attributes - # - # Nested attributes allow you to save attributes on associated records - # through the parent. By default nested attribute updating is turned off, - # you can enable it using the accepts_nested_attributes_for class method. - # When you enable nested attributes an attribute writer is defined on - # the model. - # - # The attribute writer is named after the association, which means that - # in the following example, two new methods are added to your model: - # <tt>author_attributes=(attributes)</tt> and - # <tt>pages_attributes=(attributes)</tt>. - # - # class Book < ActiveRecord::Base - # has_one :author - # has_many :pages - # - # accepts_nested_attributes_for :author, :pages - # end - # - # Note that the <tt>:autosave</tt> option is automatically enabled on every - # association that accepts_nested_attributes_for is used for. - # - # === One-to-one - # - # Consider a Member model that has one Avatar: - # - # class Member < ActiveRecord::Base - # has_one :avatar - # accepts_nested_attributes_for :avatar - # end - # - # Enabling nested attributes on a one-to-one association allows you to - # create the member and avatar in one go: - # - # params = { :member => { :name => 'Jack', :avatar_attributes => { :icon => 'smiling' } } } - # member = Member.create(params) - # member.avatar.id # => 2 - # member.avatar.icon # => 'smiling' - # - # It also allows you to update the avatar through the member: - # - # params = { :member' => { :avatar_attributes => { :id => '2', :icon => 'sad' } } } - # member.update_attributes params['member'] - # member.avatar.icon # => 'sad' - # - # By default you will only be able to set and update attributes on the - # associated model. If you want to destroy the associated model through the - # attributes hash, you have to enable it first using the - # <tt>:allow_destroy</tt> option. - # - # class Member < ActiveRecord::Base - # has_one :avatar - # accepts_nested_attributes_for :avatar, :allow_destroy => true - # end - # - # Now, when you add the <tt>_delete</tt> key to the attributes hash, with a - # value that evaluates to +true+, you will destroy the associated model: - # - # member.avatar_attributes = { :id => '2', :_delete => '1' } - # member.avatar.marked_for_destruction? # => true - # member.save - # member.avatar #=> nil - # - # Note that the model will _not_ be destroyed until the parent is saved. - # - # === One-to-many - # - # Consider a member that has a number of posts: - # - # class Member < ActiveRecord::Base - # has_many :posts - # accepts_nested_attributes_for :posts - # end - # - # You can now set or update attributes on an associated post model through - # the attribute hash. - # - # For each hash that does _not_ have an <tt>id</tt> key a new record will - # be instantiated, unless the hash also contains a <tt>_delete</tt> key - # that evaluates to +true+. - # - # params = { :member => { - # :name => 'joe', :posts_attributes => [ - # { :title => 'Kari, the awesome Ruby documentation browser!' }, - # { :title => 'The egalitarian assumption of the modern citizen' }, - # { :title => '', :_delete => '1' } # this will be ignored - # ] - # }} - # - # member = Member.create(params['member']) - # member.posts.length # => 2 - # member.posts.first.title # => 'Kari, the awesome Ruby documentation browser!' - # member.posts.second.title # => 'The egalitarian assumption of the modern citizen' - # - # You may also set a :reject_if proc to silently ignore any new record - # hashes if they fail to pass your criteria. For example, the previous - # example could be rewritten as: - # - # class Member < ActiveRecord::Base - # has_many :posts - # accepts_nested_attributes_for :posts, :reject_if => proc { |attributes| attributes['title'].blank? } - # end - # - # params = { :member => { - # :name => 'joe', :posts_attributes => [ - # { :title => 'Kari, the awesome Ruby documentation browser!' }, - # { :title => 'The egalitarian assumption of the modern citizen' }, - # { :title => '' } # this will be ignored because of the :reject_if proc - # ] - # }} - # - # member = Member.create(params['member']) - # member.posts.length # => 2 - # member.posts.first.title # => 'Kari, the awesome Ruby documentation browser!' - # member.posts.second.title # => 'The egalitarian assumption of the modern citizen' - # - # If the hash contains an <tt>id</tt> key that matches an already - # associated record, the matching record will be modified: - # - # member.attributes = { - # :name => 'Joe', - # :posts_attributes => [ - # { :id => 1, :title => '[UPDATED] An, as of yet, undisclosed awesome Ruby documentation browser!' }, - # { :id => 2, :title => '[UPDATED] other post' } - # ] - # } - # - # member.posts.first.title # => '[UPDATED] An, as of yet, undisclosed awesome Ruby documentation browser!' - # member.posts.second.title # => '[UPDATED] other post' - # - # By default the associated records are protected from being destroyed. If - # you want to destroy any of the associated records through the attributes - # hash, you have to enable it first using the <tt>:allow_destroy</tt> - # option. This will allow you to also use the <tt>_delete</tt> key to - # destroy existing records: - # - # class Member < ActiveRecord::Base - # has_many :posts - # accepts_nested_attributes_for :posts, :allow_destroy => true - # end - # - # params = { :member => { - # :posts_attributes => [{ :id => '2', :_delete => '1' }] - # }} - # - # member.attributes = params['member'] - # member.posts.detect { |p| p.id == 2 }.marked_for_destruction? # => true - # member.posts.length #=> 2 - # member.save - # member.posts.length # => 1 - # - # === Saving - # - # All changes to models, including the destruction of those marked for - # destruction, are saved and destroyed automatically and atomically when - # the parent model is saved. This happens inside the transaction initiated - # by the parents save method. See ActiveRecord::AutosaveAssociation. - module ClassMethods - # Defines an attributes writer for the specified association(s). If you - # are using <tt>attr_protected</tt> or <tt>attr_accessible</tt>, then you - # will need to add the attribute writer to the allowed list. - # - # Supported options: - # [:allow_destroy] - # If true, destroys any members from the attributes hash with a - # <tt>_delete</tt> key and a value that evaluates to +true+ - # (eg. 1, '1', true, or 'true'). This option is off by default. - # [:reject_if] - # Allows you to specify a Proc that checks whether a record should be - # built for a certain attribute hash. The hash is passed to the Proc - # and the Proc should return either +true+ or +false+. When no Proc - # is specified a record will be built for all attribute hashes that - # do not have a <tt>_delete</tt> that evaluates to true. - # - # Examples: - # # creates avatar_attributes= - # accepts_nested_attributes_for :avatar, :reject_if => proc { |attributes| attributes['name'].blank? } - # # creates avatar_attributes= and posts_attributes= - # accepts_nested_attributes_for :avatar, :posts, :allow_destroy => true - def accepts_nested_attributes_for(*attr_names) - options = { :allow_destroy => false } - options.update(attr_names.extract_options!) - options.assert_valid_keys(:allow_destroy, :reject_if) - - attr_names.each do |association_name| - if reflection = reflect_on_association(association_name) - type = case reflection.macro - when :has_one, :belongs_to - :one_to_one - when :has_many, :has_and_belongs_to_many - :collection - end - - reflection.options[:autosave] = true - self.reject_new_nested_attributes_procs[association_name.to_sym] = options[:reject_if] - - # def pirate_attributes=(attributes) - # assign_nested_attributes_for_one_to_one_association(:pirate, attributes, false) - # end - class_eval %{ - def #{association_name}_attributes=(attributes) - assign_nested_attributes_for_#{type}_association(:#{association_name}, attributes, #{options[:allow_destroy]}) - end - }, __FILE__, __LINE__ - else - raise ArgumentError, "No association found for name `#{association_name}'. Has it been defined yet?" - end - end - end - end - - # Returns ActiveRecord::AutosaveAssociation::marked_for_destruction? It's - # used in conjunction with fields_for to build a form element for the - # destruction of this association. - # - # See ActionView::Helpers::FormHelper::fields_for for more info. - def _delete - marked_for_destruction? - end - - private - - # Attribute hash keys that should not be assigned as normal attributes. - # These hash keys are nested attributes implementation details. - UNASSIGNABLE_KEYS = %w{ id _delete } - - # Assigns the given attributes to the association. - # - # If the given attributes include an <tt>:id</tt> that matches the existing - # record’s id, then the existing record will be modified. Otherwise a new - # record will be built. - # - # If the given attributes include a matching <tt>:id</tt> attribute _and_ a - # <tt>:_delete</tt> key set to a truthy value, then the existing record - # will be marked for destruction. - def assign_nested_attributes_for_one_to_one_association(association_name, attributes, allow_destroy) - attributes = attributes.stringify_keys - - if attributes['id'].blank? - unless reject_new_record?(association_name, attributes) - send("build_#{association_name}", attributes.except(*UNASSIGNABLE_KEYS)) - end - elsif (existing_record = send(association_name)) && existing_record.id.to_s == attributes['id'].to_s - assign_to_or_mark_for_destruction(existing_record, attributes, allow_destroy) - end - end - - # Assigns the given attributes to the collection association. - # - # Hashes with an <tt>:id</tt> value matching an existing associated record - # will update that record. Hashes without an <tt>:id</tt> value will build - # a new record for the association. Hashes with a matching <tt>:id</tt> - # value and a <tt>:_delete</tt> key set to a truthy value will mark the - # matched record for destruction. - # - # For example: - # - # assign_nested_attributes_for_collection_association(:people, { - # '1' => { :id => '1', :name => 'Peter' }, - # '2' => { :name => 'John' }, - # '3' => { :id => '2', :_delete => true } - # }) - # - # Will update the name of the Person with ID 1, build a new associated - # person with the name `John', and mark the associatied Person with ID 2 - # for destruction. - # - # Also accepts an Array of attribute hashes: - # - # assign_nested_attributes_for_collection_association(:people, [ - # { :id => '1', :name => 'Peter' }, - # { :name => 'John' }, - # { :id => '2', :_delete => true } - # ]) - def assign_nested_attributes_for_collection_association(association_name, attributes_collection, allow_destroy) - unless attributes_collection.is_a?(Hash) || attributes_collection.is_a?(Array) - raise ArgumentError, "Hash or Array expected, got #{attributes_collection.class.name} (#{attributes_collection.inspect})" - end - - if attributes_collection.is_a? Hash - attributes_collection = attributes_collection.sort_by { |index, _| index.to_i }.map { |_, attributes| attributes } - end - - attributes_collection.each do |attributes| - attributes = attributes.stringify_keys - - if attributes['id'].blank? - unless reject_new_record?(association_name, attributes) - send(association_name).build(attributes.except(*UNASSIGNABLE_KEYS)) - end - elsif existing_record = send(association_name).detect { |record| record.id.to_s == attributes['id'].to_s } - assign_to_or_mark_for_destruction(existing_record, attributes, allow_destroy) - end - end - end - - # Updates a record with the +attributes+ or marks it for destruction if - # +allow_destroy+ is +true+ and has_delete_flag? returns +true+. - def assign_to_or_mark_for_destruction(record, attributes, allow_destroy) - if has_delete_flag?(attributes) && allow_destroy - record.mark_for_destruction - else - record.attributes = attributes.except(*UNASSIGNABLE_KEYS) - end - end - - # Determines if a hash contains a truthy _delete key. - def has_delete_flag?(hash) - ConnectionAdapters::Column.value_to_boolean hash['_delete'] - end - - # Determines if a new record should be build by checking for - # has_delete_flag? or if a <tt>:reject_if</tt> proc exists for this - # association and evaluates to +true+. - def reject_new_record?(association_name, attributes) - has_delete_flag?(attributes) || - self.class.reject_new_nested_attributes_procs[association_name].try(:call, attributes) - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/observer.rb b/vendor/rails/activerecord/lib/active_record/observer.rb deleted file mode 100644 index b35e407..0000000 --- a/vendor/rails/activerecord/lib/active_record/observer.rb +++ /dev/null @@ -1,197 +0,0 @@ -require 'singleton' -require 'set' - -module ActiveRecord - module Observing # :nodoc: - def self.included(base) - base.extend ClassMethods - end - - module ClassMethods - # Activates the observers assigned. Examples: - # - # # Calls PersonObserver.instance - # ActiveRecord::Base.observers = :person_observer - # - # # Calls Cacher.instance and GarbageCollector.instance - # ActiveRecord::Base.observers = :cacher, :garbage_collector - # - # # Same as above, just using explicit class references - # ActiveRecord::Base.observers = Cacher, GarbageCollector - # - # Note: Setting this does not instantiate the observers yet. +instantiate_observers+ is - # called during startup, and before each development request. - def observers=(*observers) - @observers = observers.flatten - end - - # Gets the current observers. - def observers - @observers ||= [] - end - - # Instantiate the global Active Record observers. - def instantiate_observers - return if @observers.blank? - @observers.each do |observer| - if observer.respond_to?(:to_sym) # Symbol or String - observer.to_s.camelize.constantize.instance - elsif observer.respond_to?(:instance) - observer.instance - else - raise ArgumentError, "#{observer} must be a lowercase, underscored class name (or an instance of the class itself) responding to the instance method. Example: Person.observers = :big_brother # calls BigBrother.instance" - end - end - end - - protected - # Notify observers when the observed class is subclassed. - def inherited(subclass) - super - changed - notify_observers :observed_class_inherited, subclass - end - end - end - - # Observer classes respond to lifecycle callbacks to implement trigger-like - # behavior outside the original class. This is a great way to reduce the - # clutter that normally comes when the model class is burdened with - # functionality that doesn't pertain to the core responsibility of the - # class. Example: - # - # class CommentObserver < ActiveRecord::Observer - # def after_save(comment) - # Notifications.deliver_comment("admin@do.com", "New comment was posted", comment) - # end - # end - # - # This Observer sends an email when a Comment#save is finished. - # - # class ContactObserver < ActiveRecord::Observer - # def after_create(contact) - # contact.logger.info('New contact added!') - # end - # - # def after_destroy(contact) - # contact.logger.warn("Contact with an id of #{contact.id} was destroyed!") - # end - # end - # - # This Observer uses logger to log when specific callbacks are triggered. - # - # == Observing a class that can't be inferred - # - # Observers will by default be mapped to the class with which they share a name. So CommentObserver will - # be tied to observing Comment, ProductManagerObserver to ProductManager, and so on. If you want to name your observer - # differently than the class you're interested in observing, you can use the Observer.observe class method which takes - # either the concrete class (Product) or a symbol for that class (:product): - # - # class AuditObserver < ActiveRecord::Observer - # observe :account - # - # def after_update(account) - # AuditTrail.new(account, "UPDATED") - # end - # end - # - # If the audit observer needs to watch more than one kind of object, this can be specified with multiple arguments: - # - # class AuditObserver < ActiveRecord::Observer - # observe :account, :balance - # - # def after_update(record) - # AuditTrail.new(record, "UPDATED") - # end - # end - # - # The AuditObserver will now act on both updates to Account and Balance by treating them both as records. - # - # == Available callback methods - # - # The observer can implement callback methods for each of the methods described in the Callbacks module. - # - # == Storing Observers in Rails - # - # If you're using Active Record within Rails, observer classes are usually stored in app/models with the - # naming convention of app/models/audit_observer.rb. - # - # == Configuration - # - # In order to activate an observer, list it in the <tt>config.active_record.observers</tt> configuration setting in your - # <tt>config/environment.rb</tt> file. - # - # config.active_record.observers = :comment_observer, :signup_observer - # - # Observers will not be invoked unless you define these in your application configuration. - # - # == Loading - # - # Observers register themselves in the model class they observe, since it is the class that - # notifies them of events when they occur. As a side-effect, when an observer is loaded its - # corresponding model class is loaded. - # - # Up to (and including) Rails 2.0.2 observers were instantiated between plugins and - # application initializers. Now observers are loaded after application initializers, - # so observed models can make use of extensions. - # - # If by any chance you are using observed models in the initialization you can still - # load their observers by calling <tt>ModelObserver.instance</tt> before. Observers are - # singletons and that call instantiates and registers them. - # - class Observer - include Singleton - - class << self - # Attaches the observer to the supplied model classes. - def observe(*models) - models.flatten! - models.collect! { |model| model.is_a?(Symbol) ? model.to_s.camelize.constantize : model } - define_method(:observed_classes) { Set.new(models) } - end - - # The class observed by default is inferred from the observer's class name: - # assert_equal Person, PersonObserver.observed_class - def observed_class - if observed_class_name = name[/(.*)Observer/, 1] - observed_class_name.constantize - else - nil - end - end - end - - # Start observing the declared classes and their subclasses. - def initialize - Set.new(observed_classes + observed_subclasses).each { |klass| add_observer! klass } - end - - # Send observed_method(object) if the method exists. - def update(observed_method, object) #:nodoc: - send(observed_method, object) if respond_to?(observed_method) - end - - # Special method sent by the observed class when it is inherited. - # Passes the new subclass. - def observed_class_inherited(subclass) #:nodoc: - self.class.observe(observed_classes + [subclass]) - add_observer!(subclass) - end - - protected - def observed_classes - Set.new([self.class.observed_class].compact.flatten) - end - - def observed_subclasses - observed_classes.sum([]) { |klass| klass.send(:subclasses) } - end - - def add_observer!(klass) - klass.add_observer(self) - if respond_to?(:after_find) && !klass.method_defined?(:after_find) - klass.class_eval 'def after_find() end' - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/query_cache.rb b/vendor/rails/activerecord/lib/active_record/query_cache.rb deleted file mode 100644 index eb92bc2..0000000 --- a/vendor/rails/activerecord/lib/active_record/query_cache.rb +++ /dev/null @@ -1,33 +0,0 @@ -module ActiveRecord - class QueryCache - module ClassMethods - # Enable the query cache within the block if Active Record is configured. - def cache(&block) - if ActiveRecord::Base.configurations.blank? - yield - else - connection.cache(&block) - end - end - - # Disable the query cache within the block if Active Record is configured. - def uncached(&block) - if ActiveRecord::Base.configurations.blank? - yield - else - connection.uncached(&block) - end - end - end - - def initialize(app) - @app = app - end - - def call(env) - ActiveRecord::Base.cache do - @app.call(env) - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/reflection.rb b/vendor/rails/activerecord/lib/active_record/reflection.rb deleted file mode 100644 index 2d4c1d5..0000000 --- a/vendor/rails/activerecord/lib/active_record/reflection.rb +++ /dev/null @@ -1,320 +0,0 @@ -module ActiveRecord - module Reflection # :nodoc: - def self.included(base) - base.extend(ClassMethods) - end - - # Reflection allows you to interrogate Active Record classes and objects about their associations and aggregations. - # This information can, for example, be used in a form builder that took an Active Record object and created input - # fields for all of the attributes depending on their type and displayed the associations to other objects. - # - # You can find the interface for the AggregateReflection and AssociationReflection classes in the abstract MacroReflection class. - module ClassMethods - def create_reflection(macro, name, options, active_record) - case macro - when :has_many, :belongs_to, :has_one, :has_and_belongs_to_many - klass = options[:through] ? ThroughReflection : AssociationReflection - reflection = klass.new(macro, name, options, active_record) - when :composed_of - reflection = AggregateReflection.new(macro, name, options, active_record) - end - write_inheritable_hash :reflections, name => reflection - reflection - end - - # Returns a hash containing all AssociationReflection objects for the current class - # Example: - # - # Invoice.reflections - # Account.reflections - # - def reflections - read_inheritable_attribute(:reflections) || write_inheritable_attribute(:reflections, {}) - end - - # Returns an array of AggregateReflection objects for all the aggregations in the class. - def reflect_on_all_aggregations - reflections.values.select { |reflection| reflection.is_a?(AggregateReflection) } - end - - # Returns the AggregateReflection object for the named +aggregation+ (use the symbol). Example: - # - # Account.reflect_on_aggregation(:balance) # returns the balance AggregateReflection - # - def reflect_on_aggregation(aggregation) - reflections[aggregation].is_a?(AggregateReflection) ? reflections[aggregation] : nil - end - - # Returns an array of AssociationReflection objects for all the associations in the class. If you only want to reflect on a - # certain association type, pass in the symbol (<tt>:has_many</tt>, <tt>:has_one</tt>, <tt>:belongs_to</tt>) for that as the first parameter. - # Example: - # - # Account.reflect_on_all_associations # returns an array of all associations - # Account.reflect_on_all_associations(:has_many) # returns an array of all has_many associations - # - def reflect_on_all_associations(macro = nil) - association_reflections = reflections.values.select { |reflection| reflection.is_a?(AssociationReflection) } - macro ? association_reflections.select { |reflection| reflection.macro == macro } : association_reflections - end - - # Returns the AssociationReflection object for the named +association+ (use the symbol). Example: - # - # Account.reflect_on_association(:owner) # returns the owner AssociationReflection - # Invoice.reflect_on_association(:line_items).macro # returns :has_many - # - def reflect_on_association(association) - reflections[association].is_a?(AssociationReflection) ? reflections[association] : nil - end - - # Returns an array of AssociationReflection objects for all associations which have <tt>:autosave</tt> enabled. - def reflect_on_all_autosave_associations - reflections.values.select { |reflection| reflection.options[:autosave] } - end - end - - - # Abstract base class for AggregateReflection and AssociationReflection that describes the interface available for both of - # those classes. Objects of AggregateReflection and AssociationReflection are returned by the Reflection::ClassMethods. - class MacroReflection - attr_reader :active_record - - def initialize(macro, name, options, active_record) - @macro, @name, @options, @active_record = macro, name, options, active_record - end - - # Returns the name of the macro. For example, <tt>composed_of :balance, :class_name => 'Money'</tt> will return - # <tt>:balance</tt> or for <tt>has_many :clients</tt> it will return <tt>:clients</tt>. - def name - @name - end - - # Returns the macro type. For example, <tt>composed_of :balance, :class_name => 'Money'</tt> will return <tt>:composed_of</tt> - # or for <tt>has_many :clients</tt> will return <tt>:has_many</tt>. - def macro - @macro - end - - # Returns the hash of options used for the macro. For example, it would return <tt>{ :class_name => "Money" }</tt> for - # <tt>composed_of :balance, :class_name => 'Money'</tt> or +{}+ for <tt>has_many :clients</tt>. - def options - @options - end - - # Returns the class for the macro. For example, <tt>composed_of :balance, :class_name => 'Money'</tt> returns the Money - # class and <tt>has_many :clients</tt> returns the Client class. - def klass - @klass ||= class_name.constantize - end - - # Returns the class name for the macro. For example, <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>'Money'</tt> - # and <tt>has_many :clients</tt> returns <tt>'Client'</tt>. - def class_name - @class_name ||= options[:class_name] || derive_class_name - end - - # Returns +true+ if +self+ and +other_aggregation+ have the same +name+ attribute, +active_record+ attribute, - # and +other_aggregation+ has an options hash assigned to it. - def ==(other_aggregation) - other_aggregation.kind_of?(self.class) && name == other_aggregation.name && other_aggregation.options && active_record == other_aggregation.active_record - end - - def sanitized_conditions #:nodoc: - @sanitized_conditions ||= klass.send(:sanitize_sql, options[:conditions]) if options[:conditions] - end - - # Returns +true+ if +self+ is a +belongs_to+ reflection. - def belongs_to? - macro == :belongs_to - end - - private - def derive_class_name - name.to_s.camelize - end - end - - - # Holds all the meta-data about an aggregation as it was specified in the Active Record class. - class AggregateReflection < MacroReflection #:nodoc: - end - - # Holds all the meta-data about an association as it was specified in the Active Record class. - class AssociationReflection < MacroReflection #:nodoc: - # Returns the target association's class: - # - # class Author < ActiveRecord::Base - # has_many :books - # end - # - # Author.reflect_on_association(:books).klass - # # => Book - # - # <b>Note:</b> do not call +klass.new+ or +klass.create+ to instantiate - # a new association object. Use +build_association+ or +create_association+ - # instead. This allows plugins to hook into association object creation. - def klass - @klass ||= active_record.send(:compute_type, class_name) - end - - # Returns a new, unsaved instance of the associated class. +options+ will - # be passed to the class's constructor. - def build_association(*options) - klass.new(*options) - end - - # Creates a new instance of the associated class, and immediates saves it - # with ActiveRecord::Base#save. +options+ will be passed to the class's - # creation method. Returns the newly created object. - def create_association(*options) - klass.create(*options) - end - - # Creates a new instance of the associated class, and immediates saves it - # with ActiveRecord::Base#save!. +options+ will be passed to the class's - # creation method. If the created record doesn't pass validations, then an - # exception will be raised. - # - # Returns the newly created object. - def create_association!(*options) - klass.create!(*options) - end - - def table_name - @table_name ||= klass.table_name - end - - def quoted_table_name - @quoted_table_name ||= klass.quoted_table_name - end - - def primary_key_name - @primary_key_name ||= options[:foreign_key] || derive_primary_key_name - end - - def association_foreign_key - @association_foreign_key ||= @options[:association_foreign_key] || class_name.foreign_key - end - - def counter_cache_column - if options[:counter_cache] == true - "#{active_record.name.demodulize.underscore.pluralize}_count" - elsif options[:counter_cache] - options[:counter_cache] - end - end - - def columns(tbl_name, log_msg) - @columns ||= klass.connection.columns(tbl_name, log_msg) - end - - def reset_column_information - @columns = nil - end - - def check_validity! - end - - def through_reflection - false - end - - def through_reflection_primary_key_name - end - - def source_reflection - nil - end - - private - def derive_class_name - class_name = name.to_s.camelize - class_name = class_name.singularize if [ :has_many, :has_and_belongs_to_many ].include?(macro) - class_name - end - - def derive_primary_key_name - if belongs_to? - "#{name}_id" - elsif options[:as] - "#{options[:as]}_id" - else - active_record.name.foreign_key - end - end - end - - # Holds all the meta-data about a :through association as it was specified in the Active Record class. - class ThroughReflection < AssociationReflection #:nodoc: - # Gets the source of the through reflection. It checks both a singularized and pluralized form for <tt>:belongs_to</tt> or <tt>:has_many</tt>. - # (The <tt>:tags</tt> association on Tagging below.) - # - # class Post < ActiveRecord::Base - # has_many :taggings - # has_many :tags, :through => :taggings - # end - # - def source_reflection - @source_reflection ||= source_reflection_names.collect { |name| through_reflection.klass.reflect_on_association(name) }.compact.first - end - - # Returns the AssociationReflection object specified in the <tt>:through</tt> option - # of a HasManyThrough or HasOneThrough association. Example: - # - # class Post < ActiveRecord::Base - # has_many :taggings - # has_many :tags, :through => :taggings - # end - # - # tags_reflection = Post.reflect_on_association(:tags) - # taggings_reflection = tags_reflection.through_reflection - # - def through_reflection - @through_reflection ||= active_record.reflect_on_association(options[:through]) - end - - # Gets an array of possible <tt>:through</tt> source reflection names: - # - # [:singularized, :pluralized] - # - def source_reflection_names - @source_reflection_names ||= (options[:source] ? [options[:source]] : [name.to_s.singularize, name]).collect { |n| n.to_sym } - end - - def check_validity! - if through_reflection.nil? - raise HasManyThroughAssociationNotFoundError.new(active_record.name, self) - end - - if source_reflection.nil? - raise HasManyThroughSourceAssociationNotFoundError.new(self) - end - - if options[:source_type] && source_reflection.options[:polymorphic].nil? - raise HasManyThroughAssociationPointlessSourceTypeError.new(active_record.name, self, source_reflection) - end - - if source_reflection.options[:polymorphic] && options[:source_type].nil? - raise HasManyThroughAssociationPolymorphicError.new(active_record.name, self, source_reflection) - end - - unless [:belongs_to, :has_many].include?(source_reflection.macro) && source_reflection.options[:through].nil? - raise HasManyThroughSourceAssociationMacroError.new(self) - end - end - - def through_reflection_primary_key - through_reflection.belongs_to? ? through_reflection.klass.primary_key : through_reflection.primary_key_name - end - - def through_reflection_primary_key_name - through_reflection.primary_key_name if through_reflection.belongs_to? - end - - private - def derive_class_name - # get the class_name of the belongs_to association of the through reflection - options[:source_type] || source_reflection.class_name - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/schema.rb b/vendor/rails/activerecord/lib/active_record/schema.rb deleted file mode 100644 index 8a32cf1..0000000 --- a/vendor/rails/activerecord/lib/active_record/schema.rb +++ /dev/null @@ -1,51 +0,0 @@ -module ActiveRecord - # Allows programmers to programmatically define a schema in a portable - # DSL. This means you can define tables, indexes, etc. without using SQL - # directly, so your applications can more easily support multiple - # databases. - # - # Usage: - # - # ActiveRecord::Schema.define do - # create_table :authors do |t| - # t.string :name, :null => false - # end - # - # add_index :authors, :name, :unique - # - # create_table :posts do |t| - # t.integer :author_id, :null => false - # t.string :subject - # t.text :body - # t.boolean :private, :default => false - # end - # - # add_index :posts, :author_id - # end - # - # ActiveRecord::Schema is only supported by database adapters that also - # support migrations, the two features being very similar. - class Schema < Migration - private_class_method :new - - # Eval the given block. All methods available to the current connection - # adapter are available within the block, so you can easily use the - # database definition DSL to build up your schema (+create_table+, - # +add_index+, etc.). - # - # The +info+ hash is optional, and if given is used to define metadata - # about the current schema (currently, only the schema's version): - # - # ActiveRecord::Schema.define(:version => 20380119000001) do - # ... - # end - def self.define(info={}, &block) - instance_eval(&block) - - unless info[:version].blank? - initialize_schema_migrations_table - assume_migrated_upto_version info[:version] - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/schema_dumper.rb b/vendor/rails/activerecord/lib/active_record/schema_dumper.rb deleted file mode 100644 index 557a554..0000000 --- a/vendor/rails/activerecord/lib/active_record/schema_dumper.rb +++ /dev/null @@ -1,179 +0,0 @@ -require 'stringio' -require 'bigdecimal' - -module ActiveRecord - # This class is used to dump the database schema for some connection to some - # output format (i.e., ActiveRecord::Schema). - class SchemaDumper #:nodoc: - private_class_method :new - - ## - # :singleton-method: - # A list of tables which should not be dumped to the schema. - # Acceptable values are strings as well as regexp. - # This setting is only used if ActiveRecord::Base.schema_format == :ruby - cattr_accessor :ignore_tables - @@ignore_tables = [] - - def self.dump(connection=ActiveRecord::Base.connection, stream=STDOUT) - new(connection).dump(stream) - stream - end - - def dump(stream) - header(stream) - tables(stream) - trailer(stream) - stream - end - - private - - def initialize(connection) - @connection = connection - @types = @connection.native_database_types - @version = Migrator::current_version rescue nil - end - - def header(stream) - define_params = @version ? ":version => #{@version}" : "" - - stream.puts <<HEADER -# 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(#{define_params}) do - -HEADER - end - - def trailer(stream) - stream.puts "end" - end - - def tables(stream) - @connection.tables.sort.each do |tbl| - next if ['schema_migrations', ignore_tables].flatten.any? do |ignored| - case ignored - when String; tbl == ignored - when Regexp; tbl =~ ignored - else - raise StandardError, 'ActiveRecord::SchemaDumper.ignore_tables accepts an array of String and / or Regexp values.' - end - end - table(tbl, stream) - end - end - - def table(table, stream) - columns = @connection.columns(table) - begin - tbl = StringIO.new - - if @connection.respond_to?(:pk_and_sequence_for) - pk, pk_seq = @connection.pk_and_sequence_for(table) - end - pk ||= 'id' - - tbl.print " create_table #{table.inspect}" - if columns.detect { |c| c.name == pk } - if pk != 'id' - tbl.print %Q(, :primary_key => "#{pk}") - end - else - tbl.print ", :id => false" - end - tbl.print ", :force => true" - tbl.puts " do |t|" - - column_specs = columns.map do |column| - raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" if @types[column.type].nil? - next if column.name == pk - spec = {} - spec[:name] = column.name.inspect - spec[:type] = column.type.to_s - spec[:limit] = column.limit.inspect if column.limit != @types[column.type][:limit] && column.type != :decimal - spec[:precision] = column.precision.inspect if !column.precision.nil? - spec[:scale] = column.scale.inspect if !column.scale.nil? - spec[:null] = 'false' if !column.null - spec[:default] = default_string(column.default) if column.has_default? - (spec.keys - [:name, :type]).each{ |k| spec[k].insert(0, "#{k.inspect} => ")} - spec - end.compact - - # find all migration keys used in this table - keys = [:name, :limit, :precision, :scale, :default, :null] & column_specs.map(&:keys).flatten - - # figure out the lengths for each column based on above keys - lengths = keys.map{ |key| column_specs.map{ |spec| spec[key] ? spec[key].length + 2 : 0 }.max } - - # the string we're going to sprintf our values against, with standardized column widths - format_string = lengths.map{ |len| "%-#{len}s" } - - # find the max length for the 'type' column, which is special - type_length = column_specs.map{ |column| column[:type].length }.max - - # add column type definition to our format string - format_string.unshift " t.%-#{type_length}s " - - format_string *= '' - - column_specs.each do |colspec| - values = keys.zip(lengths).map{ |key, len| colspec.key?(key) ? colspec[key] + ", " : " " * len } - values.unshift colspec[:type] - tbl.print((format_string % values).gsub(/,\s*$/, '')) - tbl.puts - end - - tbl.puts " end" - tbl.puts - - indexes(table, tbl) - - tbl.rewind - stream.print tbl.read - rescue => e - stream.puts "# Could not dump table #{table.inspect} because of following #{e.class}" - stream.puts "# #{e.message}" - stream.puts - end - - stream - end - - def default_string(value) - case value - when BigDecimal - value.to_s - when Date, DateTime, Time - "'" + value.to_s(:db) + "'" - else - value.inspect - end - end - - def indexes(table, stream) - if (indexes = @connection.indexes(table)).any? - add_index_statements = indexes.map do |index| - statment_parts = [ ('add_index ' + index.table.inspect) ] - statment_parts << index.columns.inspect - statment_parts << (':name => ' + index.name.inspect) - statment_parts << ':unique => true' if index.unique - - ' ' + statment_parts.join(', ') - end - - stream.puts add_index_statements.sort.join("\n") - stream.puts - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/lib/active_record/serialization.rb b/vendor/rails/activerecord/lib/active_record/serialization.rb deleted file mode 100644 index 870b4b2..0000000 --- a/vendor/rails/activerecord/lib/active_record/serialization.rb +++ /dev/null @@ -1,100 +0,0 @@ -require 'active_support/json' - -module ActiveRecord #:nodoc: - module Serialization - class Serializer #:nodoc: - attr_reader :options - - def initialize(record, options = {}) - @record, @options = record, options.dup - end - - # To replicate the behavior in ActiveRecord#attributes, - # <tt>:except</tt> takes precedence over <tt>:only</tt>. If <tt>:only</tt> is not set - # for a N level model but is set for the N+1 level models, - # then because <tt>:except</tt> is set to a default value, the second - # level model can have both <tt>:except</tt> and <tt>:only</tt> set. So if - # <tt>:only</tt> is set, always delete <tt>:except</tt>. - def serializable_attribute_names - attribute_names = @record.attribute_names - - if options[:only] - options.delete(:except) - attribute_names = attribute_names & Array(options[:only]).collect { |n| n.to_s } - else - options[:except] = Array(options[:except]) | Array(@record.class.inheritance_column) - attribute_names = attribute_names - options[:except].collect { |n| n.to_s } - end - - attribute_names - end - - def serializable_method_names - Array(options[:methods]).inject([]) do |method_attributes, name| - method_attributes << name if @record.respond_to?(name.to_s) - method_attributes - end - end - - def serializable_names - serializable_attribute_names + serializable_method_names - end - - # Add associations specified via the <tt>:includes</tt> option. - # Expects a block that takes as arguments: - # +association+ - name of the association - # +records+ - the association record(s) to be serialized - # +opts+ - options for the association records - def add_includes(&block) - if include_associations = options.delete(:include) - base_only_or_except = { :except => options[:except], - :only => options[:only] } - - include_has_options = include_associations.is_a?(Hash) - associations = include_has_options ? include_associations.keys : Array(include_associations) - - for association in associations - records = case @record.class.reflect_on_association(association).macro - when :has_many, :has_and_belongs_to_many - @record.send(association).to_a - when :has_one, :belongs_to - @record.send(association) - end - - unless records.nil? - association_options = include_has_options ? include_associations[association] : base_only_or_except - opts = options.merge(association_options) - yield(association, records, opts) - end - end - - options[:include] = include_associations - end - end - - def serializable_record - returning(serializable_record = {}) do - serializable_names.each { |name| serializable_record[name] = @record.send(name) } - add_includes do |association, records, opts| - if records.is_a?(Enumerable) - serializable_record[association] = records.collect { |r| self.class.new(r, opts).serializable_record } - else - serializable_record[association] = self.class.new(records, opts).serializable_record - end - end - end - end - - def serialize - # overwrite to implement - end - - def to_s(&block) - serialize(&block) - end - end - end -end - -require 'active_record/serializers/xml_serializer' -require 'active_record/serializers/json_serializer' diff --git a/vendor/rails/activerecord/lib/active_record/serializers/json_serializer.rb b/vendor/rails/activerecord/lib/active_record/serializers/json_serializer.rb deleted file mode 100644 index 1fd65ed..0000000 --- a/vendor/rails/activerecord/lib/active_record/serializers/json_serializer.rb +++ /dev/null @@ -1,99 +0,0 @@ -module ActiveRecord #:nodoc: - module Serialization - def self.included(base) - base.cattr_accessor :include_root_in_json, :instance_writer => false - base.extend ClassMethods - end - - # Returns a JSON string representing the model. Some configuration is - # available through +options+. - # - # The option <tt>ActiveRecord::Base.include_root_in_json</tt> controls the - # top-level behavior of to_json. In a new Rails application, it is set to - # <tt>true</tt> in initializers/new_rails_defaults.rb. When it is <tt>true</tt>, - # to_json will emit a single root node named after the object's type. For example: - # - # konata = User.find(1) - # ActiveRecord::Base.include_root_in_json = true - # konata.to_json - # # => { "user": {"id": 1, "name": "Konata Izumi", "age": 16, - # "created_at": "2006/08/01", "awesome": true} } - # - # ActiveRecord::Base.include_root_in_json = false - # konata.to_json - # # => {"id": 1, "name": "Konata Izumi", "age": 16, - # "created_at": "2006/08/01", "awesome": true} - # - # The remainder of the examples in this section assume include_root_in_json is set to - # <tt>false</tt>. - # - # Without any +options+, the returned JSON string will include all - # the model's attributes. For example: - # - # konata = User.find(1) - # konata.to_json - # # => {"id": 1, "name": "Konata Izumi", "age": 16, - # "created_at": "2006/08/01", "awesome": true} - # - # The <tt>:only</tt> and <tt>:except</tt> options can be used to limit the attributes - # included, and work similar to the +attributes+ method. For example: - # - # konata.to_json(:only => [ :id, :name ]) - # # => {"id": 1, "name": "Konata Izumi"} - # - # konata.to_json(:except => [ :id, :created_at, :age ]) - # # => {"name": "Konata Izumi", "awesome": true} - # - # To include any methods on the model, use <tt>:methods</tt>. - # - # konata.to_json(:methods => :permalink) - # # => {"id": 1, "name": "Konata Izumi", "age": 16, - # "created_at": "2006/08/01", "awesome": true, - # "permalink": "1-konata-izumi"} - # - # To include associations, use <tt>:include</tt>. - # - # konata.to_json(:include => :posts) - # # => {"id": 1, "name": "Konata Izumi", "age": 16, - # "created_at": "2006/08/01", "awesome": true, - # "posts": [{"id": 1, "author_id": 1, "title": "Welcome to the weblog"}, - # {"id": 2, author_id: 1, "title": "So I was thinking"}]} - # - # 2nd level and higher order associations work as well: - # - # konata.to_json(:include => { :posts => { - # :include => { :comments => { - # :only => :body } }, - # :only => :title } }) - # # => {"id": 1, "name": "Konata Izumi", "age": 16, - # "created_at": "2006/08/01", "awesome": true, - # "posts": [{"comments": [{"body": "1st post!"}, {"body": "Second!"}], - # "title": "Welcome to the weblog"}, - # {"comments": [{"body": "Don't think too hard"}], - # "title": "So I was thinking"}]} - def to_json(options = {}) - if include_root_in_json - "{#{self.class.json_class_name}: #{JsonSerializer.new(self, options).to_s}}" - else - JsonSerializer.new(self, options).to_s - end - end - - def from_json(json) - self.attributes = ActiveSupport::JSON.decode(json) - self - end - - class JsonSerializer < ActiveRecord::Serialization::Serializer #:nodoc: - def serialize - serializable_record.to_json - end - end - - module ClassMethods - def json_class_name - @json_class_name ||= name.demodulize.underscore.inspect - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/serializers/xml_serializer.rb b/vendor/rails/activerecord/lib/active_record/serializers/xml_serializer.rb deleted file mode 100644 index fa75874..0000000 --- a/vendor/rails/activerecord/lib/active_record/serializers/xml_serializer.rb +++ /dev/null @@ -1,353 +0,0 @@ -module ActiveRecord #:nodoc: - module Serialization - # Builds an XML document to represent the model. Some configuration is - # available through +options+. However more complicated cases should - # override ActiveRecord::Base#to_xml. - # - # By default the generated XML document will include the processing - # instruction and all the object's attributes. For example: - # - # <?xml version="1.0" encoding="UTF-8"?> - # <topic> - # <title>The First Topic</title> - # <author-name>David</author-name> - # <id type="integer">1</id> - # <approved type="boolean">false</approved> - # <replies-count type="integer">0</replies-count> - # <bonus-time type="datetime">2000-01-01T08:28:00+12:00</bonus-time> - # <written-on type="datetime">2003-07-16T09:28:00+1200</written-on> - # <content>Have a nice day</content> - # <author-email-address>david@loudthinking.com</author-email-address> - # <parent-id></parent-id> - # <last-read type="date">2004-04-15</last-read> - # </topic> - # - # This behavior can be controlled with <tt>:only</tt>, <tt>:except</tt>, - # <tt>:skip_instruct</tt>, <tt>:skip_types</tt>, <tt>:dasherize</tt> and <tt>:camelize</tt> . - # The <tt>:only</tt> and <tt>:except</tt> options are the same as for the - # +attributes+ method. The default is to dasherize all column names, but you - # can disable this setting <tt>:dasherize</tt> to +false+. Setting <tt>:camelize</tt> - # to +true+ will camelize all column names - this also overrides <tt>:dasherize</tt>. - # To not have the column type included in the XML output set <tt>:skip_types</tt> to +true+. - # - # For instance: - # - # topic.to_xml(:skip_instruct => true, :except => [ :id, :bonus_time, :written_on, :replies_count ]) - # - # <topic> - # <title>The First Topic</title> - # <author-name>David</author-name> - # <approved type="boolean">false</approved> - # <content>Have a nice day</content> - # <author-email-address>david@loudthinking.com</author-email-address> - # <parent-id></parent-id> - # <last-read type="date">2004-04-15</last-read> - # </topic> - # - # To include first level associations use <tt>:include</tt>: - # - # firm.to_xml :include => [ :account, :clients ] - # - # <?xml version="1.0" encoding="UTF-8"?> - # <firm> - # <id type="integer">1</id> - # <rating type="integer">1</rating> - # <name>37signals</name> - # <clients type="array"> - # <client> - # <rating type="integer">1</rating> - # <name>Summit</name> - # </client> - # <client> - # <rating type="integer">1</rating> - # <name>Microsoft</name> - # </client> - # </clients> - # <account> - # <id type="integer">1</id> - # <credit-limit type="integer">50</credit-limit> - # </account> - # </firm> - # - # To include deeper levels of associations pass a hash like this: - # - # firm.to_xml :include => {:account => {}, :clients => {:include => :address}} - # <?xml version="1.0" encoding="UTF-8"?> - # <firm> - # <id type="integer">1</id> - # <rating type="integer">1</rating> - # <name>37signals</name> - # <clients type="array"> - # <client> - # <rating type="integer">1</rating> - # <name>Summit</name> - # <address> - # ... - # </address> - # </client> - # <client> - # <rating type="integer">1</rating> - # <name>Microsoft</name> - # <address> - # ... - # </address> - # </client> - # </clients> - # <account> - # <id type="integer">1</id> - # <credit-limit type="integer">50</credit-limit> - # </account> - # </firm> - # - # To include any methods on the model being called use <tt>:methods</tt>: - # - # firm.to_xml :methods => [ :calculated_earnings, :real_earnings ] - # - # <firm> - # # ... normal attributes as shown above ... - # <calculated-earnings>100000000000000000</calculated-earnings> - # <real-earnings>5</real-earnings> - # </firm> - # - # To call any additional Procs use <tt>:procs</tt>. The Procs are passed a - # modified version of the options hash that was given to +to_xml+: - # - # proc = Proc.new { |options| options[:builder].tag!('abc', 'def') } - # firm.to_xml :procs => [ proc ] - # - # <firm> - # # ... normal attributes as shown above ... - # <abc>def</abc> - # </firm> - # - # Alternatively, you can yield the builder object as part of the +to_xml+ call: - # - # firm.to_xml do |xml| - # xml.creator do - # xml.first_name "David" - # xml.last_name "Heinemeier Hansson" - # end - # end - # - # <firm> - # # ... normal attributes as shown above ... - # <creator> - # <first_name>David</first_name> - # <last_name>Heinemeier Hansson</last_name> - # </creator> - # </firm> - # - # As noted above, you may override +to_xml+ in your ActiveRecord::Base - # subclasses to have complete control about what's generated. The general - # form of doing this is: - # - # class IHaveMyOwnXML < ActiveRecord::Base - # def to_xml(options = {}) - # options[:indent] ||= 2 - # xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent]) - # xml.instruct! unless options[:skip_instruct] - # xml.level_one do - # xml.tag!(:second_level, 'content') - # end - # end - # end - def to_xml(options = {}, &block) - serializer = XmlSerializer.new(self, options) - block_given? ? serializer.to_s(&block) : serializer.to_s - end - - def from_xml(xml) - self.attributes = Hash.from_xml(xml).values.first - self - end - end - - class XmlSerializer < ActiveRecord::Serialization::Serializer #:nodoc: - def builder - @builder ||= begin - options[:indent] ||= 2 - builder = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent]) - - unless options[:skip_instruct] - builder.instruct! - options[:skip_instruct] = true - end - - builder - end - end - - def root - root = (options[:root] || @record.class.to_s.underscore).to_s - reformat_name(root) - end - - def dasherize? - !options.has_key?(:dasherize) || options[:dasherize] - end - - def camelize? - options.has_key?(:camelize) && options[:camelize] - end - - def reformat_name(name) - name = name.camelize if camelize? - dasherize? ? name.dasherize : name - end - - def serializable_attributes - serializable_attribute_names.collect { |name| Attribute.new(name, @record) } - end - - def serializable_method_attributes - Array(options[:methods]).inject([]) do |method_attributes, name| - method_attributes << MethodAttribute.new(name.to_s, @record) if @record.respond_to?(name.to_s) - method_attributes - end - end - - def add_attributes - (serializable_attributes + serializable_method_attributes).each do |attribute| - add_tag(attribute) - end - end - - def add_procs - if procs = options.delete(:procs) - [ *procs ].each do |proc| - proc.call(options) - end - end - end - - def add_tag(attribute) - builder.tag!( - reformat_name(attribute.name), - attribute.value.to_s, - attribute.decorations(!options[:skip_types]) - ) - end - - def add_associations(association, records, opts) - if records.is_a?(Enumerable) - tag = reformat_name(association.to_s) - type = options[:skip_types] ? {} : {:type => "array"} - - if records.empty? - builder.tag!(tag, type) - else - builder.tag!(tag, type) do - association_name = association.to_s.singularize - records.each do |record| - if options[:skip_types] - record_type = {} - else - record_class = (record.class.to_s.underscore == association_name) ? nil : record.class.name - record_type = {:type => record_class} - end - - record.to_xml opts.merge(:root => association_name).merge(record_type) - end - end - end - else - if record = @record.send(association) - record.to_xml(opts.merge(:root => association)) - end - end - end - - def serialize - args = [root] - if options[:namespace] - args << {:xmlns=>options[:namespace]} - end - - if options[:type] - args << {:type=>options[:type]} - end - - builder.tag!(*args) do - add_attributes - procs = options.delete(:procs) - add_includes { |association, records, opts| add_associations(association, records, opts) } - options[:procs] = procs - add_procs - yield builder if block_given? - end - end - - class Attribute #:nodoc: - attr_reader :name, :value, :type - - def initialize(name, record) - @name, @record = name, record - - @type = compute_type - @value = compute_value - end - - # There is a significant speed improvement if the value - # does not need to be escaped, as <tt>tag!</tt> escapes all values - # to ensure that valid XML is generated. For known binary - # values, it is at least an order of magnitude faster to - # Base64 encode binary values and directly put them in the - # output XML than to pass the original value or the Base64 - # encoded value to the <tt>tag!</tt> method. It definitely makes - # no sense to Base64 encode the value and then give it to - # <tt>tag!</tt>, since that just adds additional overhead. - def needs_encoding? - ![ :binary, :date, :datetime, :boolean, :float, :integer ].include?(type) - end - - def decorations(include_types = true) - decorations = {} - - if type == :binary - decorations[:encoding] = 'base64' - end - - if include_types && type != :string - decorations[:type] = type - end - - if value.nil? - decorations[:nil] = true - end - - decorations - end - - protected - def compute_type - type = @record.class.serialized_attributes.has_key?(name) ? :yaml : @record.class.columns_hash[name].type - - case type - when :text - :string - when :time - :datetime - else - type - end - end - - def compute_value - value = @record.send(name) - - if formatter = Hash::XML_FORMATTING[type.to_s] - value ? formatter.call(value) : nil - else - value - end - end - end - - class MethodAttribute < Attribute #:nodoc: - protected - def compute_type - Hash::XML_TYPE_NAMES[@record.send(name).class.name] || :string - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/session_store.rb b/vendor/rails/activerecord/lib/active_record/session_store.rb deleted file mode 100644 index 3cc4640..0000000 --- a/vendor/rails/activerecord/lib/active_record/session_store.rb +++ /dev/null @@ -1,318 +0,0 @@ -module ActiveRecord - # A session store backed by an Active Record class. A default class is - # provided, but any object duck-typing to an Active Record Session class - # with text +session_id+ and +data+ attributes is sufficient. - # - # The default assumes a +sessions+ tables with columns: - # +id+ (numeric primary key), - # +session_id+ (text, or longtext if your session data exceeds 65K), and - # +data+ (text or longtext; careful if your session data exceeds 65KB). - # The +session_id+ column should always be indexed for speedy lookups. - # Session data is marshaled to the +data+ column in Base64 format. - # If the data you write is larger than the column's size limit, - # ActionController::SessionOverflowError will be raised. - # - # You may configure the table name, primary key, and data column. - # For example, at the end of <tt>config/environment.rb</tt>: - # ActiveRecord::SessionStore::Session.table_name = 'legacy_session_table' - # ActiveRecord::SessionStore::Session.primary_key = 'session_id' - # ActiveRecord::SessionStore::Session.data_column_name = 'legacy_session_data' - # Note that setting the primary key to the +session_id+ frees you from - # having a separate +id+ column if you don't want it. However, you must - # set <tt>session.model.id = session.session_id</tt> by hand! A before filter - # on ApplicationController is a good place. - # - # Since the default class is a simple Active Record, you get timestamps - # for free if you add +created_at+ and +updated_at+ datetime columns to - # the +sessions+ table, making periodic session expiration a snap. - # - # You may provide your own session class implementation, whether a - # feature-packed Active Record or a bare-metal high-performance SQL - # store, by setting - # ActiveRecord::SessionStore.session_class = MySessionClass - # You must implement these methods: - # self.find_by_session_id(session_id) - # initialize(hash_of_session_id_and_data) - # attr_reader :session_id - # attr_accessor :data - # save - # destroy - # - # The example SqlBypass class is a generic SQL session store. You may - # use it as a basis for high-performance database-specific stores. - class SessionStore < ActionController::Session::AbstractStore - # The default Active Record class. - class Session < ActiveRecord::Base - ## - # :singleton-method: - # Customizable data column name. Defaults to 'data'. - cattr_accessor :data_column_name - self.data_column_name = 'data' - - before_save :marshal_data! - before_save :raise_on_session_data_overflow! - - class << self - def data_column_size_limit - @data_column_size_limit ||= columns_hash[@@data_column_name].limit - end - - # Hook to set up sessid compatibility. - def find_by_session_id(session_id) - setup_sessid_compatibility! - find_by_session_id(session_id) - end - - def marshal(data) - ActiveSupport::Base64.encode64(Marshal.dump(data)) if data - end - - def unmarshal(data) - Marshal.load(ActiveSupport::Base64.decode64(data)) if data - end - - def create_table! - connection.execute <<-end_sql - CREATE TABLE #{table_name} ( - id INTEGER PRIMARY KEY, - #{connection.quote_column_name('session_id')} TEXT UNIQUE, - #{connection.quote_column_name(@@data_column_name)} TEXT(255) - ) - end_sql - end - - def drop_table! - connection.execute "DROP TABLE #{table_name}" - end - - private - # Compatibility with tables using sessid instead of session_id. - def setup_sessid_compatibility! - # Reset column info since it may be stale. - reset_column_information - if columns_hash['sessid'] - def self.find_by_session_id(*args) - find_by_sessid(*args) - end - - define_method(:session_id) { sessid } - define_method(:session_id=) { |session_id| self.sessid = session_id } - else - def self.find_by_session_id(session_id) - find :first, :conditions => {:session_id=>session_id} - end - end - end - end - - # Lazy-unmarshal session state. - def data - @data ||= self.class.unmarshal(read_attribute(@@data_column_name)) || {} - end - - attr_writer :data - - # Has the session been loaded yet? - def loaded? - !!@data - end - - private - def marshal_data! - return false if !loaded? - write_attribute(@@data_column_name, self.class.marshal(self.data)) - end - - # Ensures that the data about to be stored in the database is not - # larger than the data storage column. Raises - # ActionController::SessionOverflowError. - def raise_on_session_data_overflow! - return false if !loaded? - limit = self.class.data_column_size_limit - if loaded? and limit and read_attribute(@@data_column_name).size > limit - raise ActionController::SessionOverflowError - end - end - end - - # A barebones session store which duck-types with the default session - # store but bypasses Active Record and issues SQL directly. This is - # an example session model class meant as a basis for your own classes. - # - # The database connection, table name, and session id and data columns - # are configurable class attributes. Marshaling and unmarshaling - # are implemented as class methods that you may override. By default, - # marshaling data is - # - # ActiveSupport::Base64.encode64(Marshal.dump(data)) - # - # and unmarshaling data is - # - # Marshal.load(ActiveSupport::Base64.decode64(data)) - # - # This marshaling behavior is intended to store the widest range of - # binary session data in a +text+ column. For higher performance, - # store in a +blob+ column instead and forgo the Base64 encoding. - class SqlBypass - ## - # :singleton-method: - # Use the ActiveRecord::Base.connection by default. - cattr_accessor :connection - - ## - # :singleton-method: - # The table name defaults to 'sessions'. - cattr_accessor :table_name - @@table_name = 'sessions' - - ## - # :singleton-method: - # The session id field defaults to 'session_id'. - cattr_accessor :session_id_column - @@session_id_column = 'session_id' - - ## - # :singleton-method: - # The data field defaults to 'data'. - cattr_accessor :data_column - @@data_column = 'data' - - class << self - def connection - @@connection ||= ActiveRecord::Base.connection - end - - # Look up a session by id and unmarshal its data if found. - def find_by_session_id(session_id) - if record = @@connection.select_one("SELECT * FROM #{@@table_name} WHERE #{@@session_id_column}=#{@@connection.quote(session_id)}") - new(:session_id => session_id, :marshaled_data => record['data']) - end - end - - def marshal(data) - ActiveSupport::Base64.encode64(Marshal.dump(data)) if data - end - - def unmarshal(data) - Marshal.load(ActiveSupport::Base64.decode64(data)) if data - end - - def create_table! - @@connection.execute <<-end_sql - CREATE TABLE #{table_name} ( - id INTEGER PRIMARY KEY, - #{@@connection.quote_column_name(session_id_column)} TEXT UNIQUE, - #{@@connection.quote_column_name(data_column)} TEXT - ) - end_sql - end - - def drop_table! - @@connection.execute "DROP TABLE #{table_name}" - end - end - - attr_reader :session_id - attr_writer :data - - # Look for normal and marshaled data, self.find_by_session_id's way of - # telling us to postpone unmarshaling until the data is requested. - # We need to handle a normal data attribute in case of a new record. - def initialize(attributes) - @session_id, @data, @marshaled_data = attributes[:session_id], attributes[:data], attributes[:marshaled_data] - @new_record = @marshaled_data.nil? - end - - def new_record? - @new_record - end - - # Lazy-unmarshal session state. - def data - unless @data - if @marshaled_data - @data, @marshaled_data = self.class.unmarshal(@marshaled_data) || {}, nil - else - @data = {} - end - end - @data - end - - def loaded? - !!@data - end - - def save - return false if !loaded? - marshaled_data = self.class.marshal(data) - - if @new_record - @new_record = false - @@connection.update <<-end_sql, 'Create session' - INSERT INTO #{@@table_name} ( - #{@@connection.quote_column_name(@@session_id_column)}, - #{@@connection.quote_column_name(@@data_column)} ) - VALUES ( - #{@@connection.quote(session_id)}, - #{@@connection.quote(marshaled_data)} ) - end_sql - else - @@connection.update <<-end_sql, 'Update session' - UPDATE #{@@table_name} - SET #{@@connection.quote_column_name(@@data_column)}=#{@@connection.quote(marshaled_data)} - WHERE #{@@connection.quote_column_name(@@session_id_column)}=#{@@connection.quote(session_id)} - end_sql - end - end - - def destroy - unless @new_record - @@connection.delete <<-end_sql, 'Destroy session' - DELETE FROM #{@@table_name} - WHERE #{@@connection.quote_column_name(@@session_id_column)}=#{@@connection.quote(session_id)} - end_sql - end - end - end - - # The class used for session storage. Defaults to - # ActiveRecord::SessionStore::Session - cattr_accessor :session_class - self.session_class = Session - - SESSION_RECORD_KEY = 'rack.session.record'.freeze - - private - def get_session(env, sid) - Base.silence do - sid ||= generate_sid - session = find_session(sid) - env[SESSION_RECORD_KEY] = session - [sid, session.data] - end - end - - def set_session(env, sid, session_data) - Base.silence do - record = env[SESSION_RECORD_KEY] ||= find_session(sid) - record.data = session_data - return false unless record.save - - session_data = record.data - if session_data && session_data.respond_to?(:each_value) - session_data.each_value do |obj| - obj.clear_association_cache if obj.respond_to?(:clear_association_cache) - end - end - end - - return true - end - - def find_session(id) - @@session_class.find_by_session_id(id) || - @@session_class.new(:session_id => id, :data => {}) - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/test_case.rb b/vendor/rails/activerecord/lib/active_record/test_case.rb deleted file mode 100644 index 8c6abaa..0000000 --- a/vendor/rails/activerecord/lib/active_record/test_case.rb +++ /dev/null @@ -1,66 +0,0 @@ -require "active_support/test_case" - -module ActiveRecord - class TestCase < ActiveSupport::TestCase #:nodoc: - def assert_date_from_db(expected, actual, message = nil) - # SybaseAdapter doesn't have a separate column type just for dates, - # so the time is in the string and incorrectly formatted - if current_adapter?(:SybaseAdapter) - assert_equal expected.to_s, actual.to_date.to_s, message - else - assert_equal expected.to_s, actual.to_s, message - end - end - - def assert_sql(*patterns_to_match) - $queries_executed = [] - yield - ensure - failed_patterns = [] - patterns_to_match.each do |pattern| - failed_patterns << pattern unless $queries_executed.any?{ |sql| pattern === sql } - end - assert failed_patterns.empty?, "Query pattern(s) #{failed_patterns.map(&:inspect).join(', ')} not found." - end - - def assert_queries(num = 1) - $queries_executed = [] - yield - ensure - %w{ BEGIN COMMIT }.each { |x| $queries_executed.delete(x) } - assert_equal num, $queries_executed.size, "#{$queries_executed.size} instead of #{num} queries were executed.#{$queries_executed.size == 0 ? '' : "\nQueries:\n#{$queries_executed.join("\n")}"}" - end - - def assert_no_queries(&block) - assert_queries(0, &block) - end - - def self.use_concurrent_connections - setup :connection_allow_concurrency_setup - teardown :connection_allow_concurrency_teardown - end - - def connection_allow_concurrency_setup - @connection = ActiveRecord::Base.remove_connection - ActiveRecord::Base.establish_connection(@connection.merge({:allow_concurrency => true})) - end - - def connection_allow_concurrency_teardown - ActiveRecord::Base.clear_all_connections! - ActiveRecord::Base.establish_connection(@connection) - end - - def with_kcode(kcode) - if RUBY_VERSION < '1.9' - orig_kcode, $KCODE = $KCODE, kcode - begin - yield - ensure - $KCODE = orig_kcode - end - else - yield - end - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/timestamp.rb b/vendor/rails/activerecord/lib/active_record/timestamp.rb deleted file mode 100644 index 8dbe80a..0000000 --- a/vendor/rails/activerecord/lib/active_record/timestamp.rb +++ /dev/null @@ -1,41 +0,0 @@ -module ActiveRecord - # Active Record automatically timestamps create and update operations if the table has fields - # named created_at/created_on or updated_at/updated_on. - # - # Timestamping can be turned off by setting - # <tt>ActiveRecord::Base.record_timestamps = false</tt> - # - # Timestamps are in the local timezone by default but you can use UTC by setting - # <tt>ActiveRecord::Base.default_timezone = :utc</tt> - module Timestamp - def self.included(base) #:nodoc: - base.alias_method_chain :create, :timestamps - base.alias_method_chain :update, :timestamps - - base.class_inheritable_accessor :record_timestamps, :instance_writer => false - base.record_timestamps = true - end - - private - def create_with_timestamps #:nodoc: - if record_timestamps - t = self.class.default_timezone == :utc ? Time.now.utc : Time.now - write_attribute('created_at', t) if respond_to?(:created_at) && created_at.nil? - write_attribute('created_on', t) if respond_to?(:created_on) && created_on.nil? - - write_attribute('updated_at', t) if respond_to?(:updated_at) && updated_at.nil? - write_attribute('updated_on', t) if respond_to?(:updated_on) && updated_on.nil? - end - create_without_timestamps - end - - def update_with_timestamps(*args) #:nodoc: - if record_timestamps && (!partial_updates? || changed?) - t = self.class.default_timezone == :utc ? Time.now.utc : Time.now - write_attribute('updated_at', t) if respond_to?(:updated_at) - write_attribute('updated_on', t) if respond_to?(:updated_on) - end - update_without_timestamps(*args) - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/transactions.rb b/vendor/rails/activerecord/lib/active_record/transactions.rb deleted file mode 100644 index 0b6e52c..0000000 --- a/vendor/rails/activerecord/lib/active_record/transactions.rb +++ /dev/null @@ -1,235 +0,0 @@ -require 'thread' - -module ActiveRecord - # See ActiveRecord::Transactions::ClassMethods for documentation. - module Transactions - class TransactionError < ActiveRecordError # :nodoc: - end - - def self.included(base) - base.extend(ClassMethods) - - base.class_eval do - [:destroy, :save, :save!].each do |method| - alias_method_chain method, :transactions - end - end - end - - # Transactions are protective blocks where SQL statements are only permanent - # if they can all succeed as one atomic action. The classic example is a - # transfer between two accounts where you can only have a deposit if the - # withdrawal succeeded and vice versa. Transactions enforce the integrity of - # the database and guard the data against program errors or database - # break-downs. So basically you should use transaction blocks whenever you - # have a number of statements that must be executed together or not at all. - # Example: - # - # ActiveRecord::Base.transaction do - # david.withdrawal(100) - # mary.deposit(100) - # end - # - # This example will only take money from David and give to Mary if neither - # +withdrawal+ nor +deposit+ raises an exception. Exceptions will force a - # ROLLBACK that returns the database to the state before the transaction was - # begun. Be aware, though, that the objects will _not_ have their instance - # data returned to their pre-transactional state. - # - # == Different Active Record classes in a single transaction - # - # Though the transaction class method is called on some Active Record class, - # the objects within the transaction block need not all be instances of - # that class. This is because transactions are per-database connection, not - # per-model. - # - # In this example a <tt>Balance</tt> record is transactionally saved even - # though <tt>transaction</tt> is called on the <tt>Account</tt> class: - # - # Account.transaction do - # balance.save! - # account.save! - # end - # - # Note that the +transaction+ method is also available as a model instance - # method. For example, you can also do this: - # - # balance.transaction do - # balance.save! - # account.save! - # end - # - # == Transactions are not distributed across database connections - # - # A transaction acts on a single database connection. If you have - # multiple class-specific databases, the transaction will not protect - # interaction among them. One workaround is to begin a transaction - # on each class whose models you alter: - # - # Student.transaction do - # Course.transaction do - # course.enroll(student) - # student.units += course.units - # end - # end - # - # This is a poor solution, but full distributed transactions are beyond - # the scope of Active Record. - # - # == Save and destroy are automatically wrapped in a transaction - # - # Both Base#save and Base#destroy come wrapped in a transaction that ensures - # that whatever you do in validations or callbacks will happen under the - # protected cover of a transaction. So you can use validations to check for - # values that the transaction depends on or you can raise exceptions in the - # callbacks to rollback, including <tt>after_*</tt> callbacks. - # - # == Exception handling and rolling back - # - # Also have in mind that exceptions thrown within a transaction block will - # be propagated (after triggering the ROLLBACK), so you should be ready to - # catch those in your application code. - # - # One exception is the ActiveRecord::Rollback exception, which will trigger - # a ROLLBACK when raised, but not be re-raised by the transaction block. - # - # *Warning*: one should not catch ActiveRecord::StatementInvalid exceptions - # inside a transaction block. StatementInvalid exceptions indicate that an - # error occurred at the database level, for example when a unique constraint - # is violated. On some database systems, such as PostgreSQL, database errors - # inside a transaction causes the entire transaction to become unusable - # until it's restarted from the beginning. Here is an example which - # demonstrates the problem: - # - # # Suppose that we have a Number model with a unique column called 'i'. - # Number.transaction do - # Number.create(:i => 0) - # begin - # # This will raise a unique constraint error... - # Number.create(:i => 0) - # rescue ActiveRecord::StatementInvalid - # # ...which we ignore. - # end - # - # # On PostgreSQL, the transaction is now unusable. The following - # # statement will cause a PostgreSQL error, even though the unique - # # constraint is no longer violated: - # Number.create(:i => 1) - # # => "PGError: ERROR: current transaction is aborted, commands - # # ignored until end of transaction block" - # end - # - # One should restart the entire transaction if a StatementError occurred. - # - # == Nested transactions - # - # #transaction calls can be nested. By default, this makes all database - # statements in the nested transaction block become part of the parent - # transaction. For example: - # - # User.transaction do - # User.create(:username => 'Kotori') - # User.transaction do - # User.create(:username => 'Nemu') - # raise ActiveRecord::Rollback - # end - # end - # - # User.find(:all) # => empty - # - # It is also possible to requires a sub-transaction by passing - # <tt>:requires_new => true</tt>. If anything goes wrong, the - # database rolls back to the beginning of the sub-transaction - # without rolling back the parent transaction. For example: - # - # User.transaction do - # User.create(:username => 'Kotori') - # User.transaction(:requires_new => true) do - # User.create(:username => 'Nemu') - # raise ActiveRecord::Rollback - # end - # end - # - # User.find(:all) # => Returns only Kotori - # - # Most databases don't support true nested transactions. At the time of - # writing, the only database that we're aware of that supports true nested - # transactions, is MS-SQL. Because of this, Active Record emulates nested - # transactions by using savepoints. See - # http://dev.mysql.com/doc/refman/5.0/en/savepoints.html - # for more information about savepoints. - # - # === Caveats - # - # If you're on MySQL, then do not use DDL operations in nested transactions - # blocks that are emulated with savepoints. That is, do not execute statements - # like 'CREATE TABLE' inside such blocks. This is because MySQL automatically - # releases all savepoints upon executing a DDL operation. When #transaction - # is finished and tries to release the savepoint it created earlier, a - # database error will occur because the savepoint has already been - # automatically released. The following example demonstrates the problem: - # - # Model.connection.transaction do # BEGIN - # Model.connection.transaction(:requires_new => true) do # CREATE SAVEPOINT active_record_1 - # Model.connection.create_table(...) # active_record_1 now automatically released - # end # RELEASE savepoint active_record_1 - # # ^^^^ BOOM! database error! - # end - module ClassMethods - # See ActiveRecord::Transactions::ClassMethods for detailed documentation. - def transaction(options = {}, &block) - # See the ConnectionAdapters::DatabaseStatements#transaction API docs. - connection.transaction(options, &block) - end - end - - # See ActiveRecord::Transactions::ClassMethods for detailed documentation. - def transaction(&block) - self.class.transaction(&block) - end - - def destroy_with_transactions #:nodoc: - with_transaction_returning_status(:destroy_without_transactions) - end - - def save_with_transactions(perform_validation = true) #:nodoc: - rollback_active_record_state! { with_transaction_returning_status(:save_without_transactions, perform_validation) } - end - - def save_with_transactions! #:nodoc: - rollback_active_record_state! { self.class.transaction { save_without_transactions! } } - end - - # Reset id and @new_record if the transaction rolls back. - def rollback_active_record_state! - id_present = has_attribute?(self.class.primary_key) - previous_id = id - previous_new_record = new_record? - yield - rescue Exception - @new_record = previous_new_record - if id_present - self.id = previous_id - else - @attributes.delete(self.class.primary_key) - @attributes_cache.delete(self.class.primary_key) - end - raise - end - - # Executes +method+ within a transaction and captures its return value as a - # status flag. If the status is true the transaction is committed, otherwise - # a ROLLBACK is issued. In any case the status flag is returned. - # - # This method is available within the context of an ActiveRecord::Base - # instance. - def with_transaction_returning_status(method, *args) - status = nil - self.class.transaction do - status = send(method, *args) - raise ActiveRecord::Rollback unless status - end - status - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/validations.rb b/vendor/rails/activerecord/lib/active_record/validations.rb deleted file mode 100644 index 4e084f0..0000000 --- a/vendor/rails/activerecord/lib/active_record/validations.rb +++ /dev/null @@ -1,1066 +0,0 @@ -module ActiveRecord - # Raised by <tt>save!</tt> and <tt>create!</tt> when the record is invalid. Use the - # +record+ method to retrieve the record which did not validate. - # begin - # complex_operation_that_calls_save!_internally - # rescue ActiveRecord::RecordInvalid => invalid - # puts invalid.record.errors - # end - class RecordInvalid < ActiveRecordError - attr_reader :record - def initialize(record) - @record = record - super("Validation failed: #{@record.errors.full_messages.join(", ")}") - end - end - - # Active Record validation is reported to and from this object, which is used by Base#save to - # determine whether the object is in a valid state to be saved. See usage example in Validations. - class Errors - include Enumerable - - class << self - def default_error_messages - ActiveSupport::Deprecation.warn("ActiveRecord::Errors.default_error_messages has been deprecated. Please use I18n.translate('activerecord.errors.messages').") - I18n.translate 'activerecord.errors.messages' - end - end - - def initialize(base) # :nodoc: - @base, @errors = base, {} - end - - # Adds an error to the base object instead of any particular attribute. This is used - # to report errors that don't tie to any specific attribute, but rather to the object - # as a whole. These error messages don't get prepended with any field name when iterating - # with +each_full+, so they should be complete sentences. - def add_to_base(msg) - add(:base, msg) - end - - # Adds an error message (+messsage+) to the +attribute+, which will be returned on a call to <tt>on(attribute)</tt> - # for the same attribute and ensure that this error object returns false when asked if <tt>empty?</tt>. More than one - # error can be added to the same +attribute+ in which case an array will be returned on a call to <tt>on(attribute)</tt>. - # If no +messsage+ is supplied, :invalid is assumed. - # If +message+ is a Symbol, it will be translated, using the appropriate scope (see translate_error). - def add(attribute, message = nil, options = {}) - message ||= :invalid - message = generate_message(attribute, message, options) if message.is_a?(Symbol) - @errors[attribute.to_s] ||= [] - @errors[attribute.to_s] << message - end - - # Will add an error message to each of the attributes in +attributes+ that is empty. - def add_on_empty(attributes, custom_message = nil) - for attr in [attributes].flatten - value = @base.respond_to?(attr.to_s) ? @base.send(attr.to_s) : @base[attr.to_s] - is_empty = value.respond_to?(:empty?) ? value.empty? : false - add(attr, :empty, :default => custom_message) unless !value.nil? && !is_empty - end - end - - # Will add an error message to each of the attributes in +attributes+ that is blank (using Object#blank?). - def add_on_blank(attributes, custom_message = nil) - for attr in [attributes].flatten - value = @base.respond_to?(attr.to_s) ? @base.send(attr.to_s) : @base[attr.to_s] - add(attr, :blank, :default => custom_message) if value.blank? - end - end - - # Translates an error message in it's default scope (<tt>activerecord.errrors.messages</tt>). - # Error messages are first looked up in <tt>models.MODEL.attributes.ATTRIBUTE.MESSAGE</tt>, if it's not there, - # it's looked up in <tt>models.MODEL.MESSAGE</tt> and if that is not there it returns the translation of the - # default message (e.g. <tt>activerecord.errors.messages.MESSAGE</tt>). The translated model name, - # translated attribute name and the value are available for interpolation. - # - # When using inheritence in your models, it will check all the inherited models too, but only if the model itself - # hasn't been found. Say you have <tt>class Admin < User; end</tt> and you wanted the translation for the <tt>:blank</tt> - # error +message+ for the <tt>title</tt> +attribute+, it looks for these translations: - # - # <ol> - # <li><tt>activerecord.errors.models.admin.attributes.title.blank</tt></li> - # <li><tt>activerecord.errors.models.admin.blank</tt></li> - # <li><tt>activerecord.errors.models.user.attributes.title.blank</tt></li> - # <li><tt>activerecord.errors.models.user.blank</tt></li> - # <li><tt>activerecord.errors.messages.blank</tt></li> - # <li>any default you provided through the +options+ hash (in the activerecord.errors scope)</li> - # </ol> - def generate_message(attribute, message = :invalid, options = {}) - - message, options[:default] = options[:default], message if options[:default].is_a?(Symbol) - - defaults = @base.class.self_and_descendants_from_active_record.map do |klass| - [ :"models.#{klass.name.underscore}.attributes.#{attribute}.#{message}", - :"models.#{klass.name.underscore}.#{message}" ] - end - - defaults << options.delete(:default) - defaults = defaults.compact.flatten << :"messages.#{message}" - - key = defaults.shift - value = @base.respond_to?(attribute) ? @base.send(attribute) : nil - - options = { :default => defaults, - :model => @base.class.human_name, - :attribute => @base.class.human_attribute_name(attribute.to_s), - :value => value, - :scope => [:activerecord, :errors] - }.merge(options) - - I18n.translate(key, options) - end - - # Returns true if the specified +attribute+ has errors associated with it. - # - # class Company < ActiveRecord::Base - # validates_presence_of :name, :address, :email - # validates_length_of :name, :in => 5..30 - # end - # - # company = Company.create(:address => '123 First St.') - # company.errors.invalid?(:name) # => true - # company.errors.invalid?(:address) # => false - def invalid?(attribute) - !@errors[attribute.to_s].nil? - end - - # Returns +nil+, if no errors are associated with the specified +attribute+. - # Returns the error message, if one error is associated with the specified +attribute+. - # Returns an array of error messages, if more than one error is associated with the specified +attribute+. - # - # class Company < ActiveRecord::Base - # validates_presence_of :name, :address, :email - # validates_length_of :name, :in => 5..30 - # end - # - # company = Company.create(:address => '123 First St.') - # company.errors.on(:name) # => ["is too short (minimum is 5 characters)", "can't be blank"] - # company.errors.on(:email) # => "can't be blank" - # company.errors.on(:address) # => nil - def on(attribute) - errors = @errors[attribute.to_s] - return nil if errors.nil? - errors.size == 1 ? errors.first : errors - end - - alias :[] :on - - # Returns errors assigned to the base object through +add_to_base+ according to the normal rules of <tt>on(attribute)</tt>. - def on_base - on(:base) - end - - # Yields each attribute and associated message per error added. - # - # class Company < ActiveRecord::Base - # validates_presence_of :name, :address, :email - # validates_length_of :name, :in => 5..30 - # end - # - # company = Company.create(:address => '123 First St.') - # company.errors.each{|attr,msg| puts "#{attr} - #{msg}" } - # # => name - is too short (minimum is 5 characters) - # # name - can't be blank - # # address - can't be blank - def each - @errors.each_key { |attr| @errors[attr].each { |msg| yield attr, msg } } - end - - # Yields each full error message added. So <tt>Person.errors.add("first_name", "can't be empty")</tt> will be returned - # through iteration as "First name can't be empty". - # - # class Company < ActiveRecord::Base - # validates_presence_of :name, :address, :email - # validates_length_of :name, :in => 5..30 - # end - # - # company = Company.create(:address => '123 First St.') - # company.errors.each_full{|msg| puts msg } - # # => Name is too short (minimum is 5 characters) - # # Name can't be blank - # # Address can't be blank - def each_full - full_messages.each { |msg| yield msg } - end - - # Returns all the full error messages in an array. - # - # class Company < ActiveRecord::Base - # validates_presence_of :name, :address, :email - # validates_length_of :name, :in => 5..30 - # end - # - # company = Company.create(:address => '123 First St.') - # company.errors.full_messages # => - # ["Name is too short (minimum is 5 characters)", "Name can't be blank", "Address can't be blank"] - def full_messages(options = {}) - full_messages = [] - - @errors.each_key do |attr| - @errors[attr].each do |message| - next unless message - - if attr == "base" - full_messages << message - else - attr_name = @base.class.human_attribute_name(attr) - full_messages << attr_name + I18n.t('activerecord.errors.format.separator', :default => ' ') + message - end - end - end - full_messages - end - - # Returns true if no errors have been added. - def empty? - @errors.empty? - end - - # Removes all errors that have been added. - def clear - @errors = {} - end - - # Returns the total number of errors added. Two errors added to the same attribute will be counted as such. - def size - @errors.values.inject(0) { |error_count, attribute| error_count + attribute.size } - end - - alias_method :count, :size - alias_method :length, :size - - # Returns an XML representation of this error object. - # - # class Company < ActiveRecord::Base - # validates_presence_of :name, :address, :email - # validates_length_of :name, :in => 5..30 - # end - # - # company = Company.create(:address => '123 First St.') - # company.errors.to_xml - # # => <?xml version="1.0" encoding="UTF-8"?> - # # <errors> - # # <error>Name is too short (minimum is 5 characters)</error> - # # <error>Name can't be blank</error> - # # <error>Address can't be blank</error> - # # </errors> - def to_xml(options={}) - options[:root] ||= "errors" - options[:indent] ||= 2 - options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent]) - - options[:builder].instruct! unless options.delete(:skip_instruct) - options[:builder].errors do |e| - full_messages.each { |msg| e.error(msg) } - end - end - - end - - - # Please do have a look at ActiveRecord::Validations::ClassMethods for a higher level of validations. - # - # Active Records implement validation by overwriting Base#validate (or the variations, +validate_on_create+ and - # +validate_on_update+). Each of these methods can inspect the state of the object, which usually means ensuring - # that a number of attributes have a certain value (such as not empty, within a given range, matching a certain regular expression). - # - # Example: - # - # class Person < ActiveRecord::Base - # protected - # def validate - # errors.add_on_empty %w( first_name last_name ) - # errors.add("phone_number", "has invalid format") unless phone_number =~ /[0-9]*/ - # end - # - # def validate_on_create # is only run the first time a new object is saved - # unless valid_discount?(membership_discount) - # errors.add("membership_discount", "has expired") - # end - # end - # - # def validate_on_update - # errors.add_to_base("No changes have occurred") if unchanged_attributes? - # end - # end - # - # person = Person.new("first_name" => "David", "phone_number" => "what?") - # person.save # => false (and doesn't do the save) - # person.errors.empty? # => false - # person.errors.count # => 2 - # person.errors.on "last_name" # => "can't be empty" - # person.errors.on "phone_number" # => "has invalid format" - # person.errors.each_full { |msg| puts msg } - # # => "Last name can't be empty\n" + - # # "Phone number has invalid format" - # - # person.attributes = { "last_name" => "Heinemeier", "phone_number" => "555-555" } - # person.save # => true (and person is now saved in the database) - # - # An Errors object is automatically created for every Active Record. - module Validations - VALIDATIONS = %w( validate validate_on_create validate_on_update ) - - def self.included(base) # :nodoc: - base.extend ClassMethods - base.class_eval do - alias_method_chain :save, :validation - alias_method_chain :save!, :validation - end - - base.send :include, ActiveSupport::Callbacks - base.define_callbacks *VALIDATIONS - end - - # Active Record classes can implement validations in several ways. The highest level, easiest to read, - # and recommended approach is to use the declarative <tt>validates_..._of</tt> class methods (and - # +validates_associated+) documented below. These are sufficient for most model validations. - # - # Slightly lower level is +validates_each+. It provides some of the same options as the purely declarative - # validation methods, but like all the lower-level approaches it requires manually adding to the errors collection - # when the record is invalid. - # - # At a yet lower level, a model can use the class methods +validate+, +validate_on_create+ and +validate_on_update+ - # to add validation methods or blocks. These are ActiveSupport::Callbacks and follow the same rules of inheritance - # and chaining. - # - # The lowest level style is to define the instance methods +validate+, +validate_on_create+ and +validate_on_update+ - # as documented in ActiveRecord::Validations. - # - # == +validate+, +validate_on_create+ and +validate_on_update+ Class Methods - # - # Calls to these methods add a validation method or block to the class. Again, this approach is recommended - # only when the higher-level methods documented below (<tt>validates_..._of</tt> and +validates_associated+) are - # insufficient to handle the required validation. - # - # This can be done with a symbol pointing to a method: - # - # class Comment < ActiveRecord::Base - # validate :must_be_friends - # - # def must_be_friends - # errors.add_to_base("Must be friends to leave a comment") unless commenter.friend_of?(commentee) - # end - # end - # - # Or with a block which is passed the current record to be validated: - # - # class Comment < ActiveRecord::Base - # validate do |comment| - # comment.must_be_friends - # end - # - # def must_be_friends - # errors.add_to_base("Must be friends to leave a comment") unless commenter.friend_of?(commentee) - # end - # end - # - # This usage applies to +validate_on_create+ and +validate_on_update+ as well. - module ClassMethods - DEFAULT_VALIDATION_OPTIONS = { - :on => :save, - :allow_nil => false, - :allow_blank => false, - :message => nil - }.freeze - - ALL_RANGE_OPTIONS = [ :is, :within, :in, :minimum, :maximum ].freeze - ALL_NUMERICALITY_CHECKS = { :greater_than => '>', :greater_than_or_equal_to => '>=', - :equal_to => '==', :less_than => '<', :less_than_or_equal_to => '<=', - :odd => 'odd?', :even => 'even?' }.freeze - - # Validates each attribute against a block. - # - # class Person < ActiveRecord::Base - # validates_each :first_name, :last_name do |record, attr, value| - # record.errors.add attr, 'starts with z.' if value[0] == ?z - # end - # end - # - # Options: - # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>). - # * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+. - # * <tt>:allow_blank</tt> - Skip validation if attribute is blank. - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_each(*attrs) - options = attrs.extract_options!.symbolize_keys - attrs = attrs.flatten - - # Declare the validation. - send(validation_method(options[:on] || :save), options) do |record| - attrs.each do |attr| - value = record.send(attr) - next if (value.nil? && options[:allow_nil]) || (value.blank? && options[:allow_blank]) - yield record, attr, value - end - end - end - - # Encapsulates the pattern of wanting to validate a password or email address field with a confirmation. Example: - # - # Model: - # class Person < ActiveRecord::Base - # validates_confirmation_of :user_name, :password - # validates_confirmation_of :email_address, :message => "should match confirmation" - # end - # - # View: - # <%= password_field "person", "password" %> - # <%= password_field "person", "password_confirmation" %> - # - # The added +password_confirmation+ attribute is virtual; it exists only as an in-memory attribute for validating the password. - # To achieve this, the validation adds accessors to the model for the confirmation attribute. NOTE: This check is performed - # only if +password_confirmation+ is not +nil+, and by default only on save. To require confirmation, make sure to add a presence - # check for the confirmation attribute: - # - # validates_presence_of :password_confirmation, :if => :password_changed? - # - # Configuration options: - # * <tt>:message</tt> - A custom error message (default is: "doesn't match confirmation"). - # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>). - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_confirmation_of(*attr_names) - configuration = { :on => :save } - configuration.update(attr_names.extract_options!) - - attr_accessor(*(attr_names.map { |n| "#{n}_confirmation" })) - - validates_each(attr_names, configuration) do |record, attr_name, value| - unless record.send("#{attr_name}_confirmation").nil? or value == record.send("#{attr_name}_confirmation") - record.errors.add(attr_name, :confirmation, :default => configuration[:message]) - end - end - end - - # Encapsulates the pattern of wanting to validate the acceptance of a terms of service check box (or similar agreement). Example: - # - # class Person < ActiveRecord::Base - # validates_acceptance_of :terms_of_service - # validates_acceptance_of :eula, :message => "must be abided" - # end - # - # If the database column does not exist, the +terms_of_service+ attribute is entirely virtual. This check is - # performed only if +terms_of_service+ is not +nil+ and by default on save. - # - # Configuration options: - # * <tt>:message</tt> - A custom error message (default is: "must be accepted"). - # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>). - # * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+ (default is true). - # * <tt>:accept</tt> - Specifies value that is considered accepted. The default value is a string "1", which - # makes it easy to relate to an HTML checkbox. This should be set to +true+ if you are validating a database - # column, since the attribute is typecast from "1" to +true+ before validation. - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_acceptance_of(*attr_names) - configuration = { :on => :save, :allow_nil => true, :accept => "1" } - configuration.update(attr_names.extract_options!) - - db_cols = begin - column_names - rescue Exception # To ignore both statement and connection errors - [] - end - names = attr_names.reject { |name| db_cols.include?(name.to_s) } - attr_accessor(*names) - - validates_each(attr_names,configuration) do |record, attr_name, value| - unless value == configuration[:accept] - record.errors.add(attr_name, :accepted, :default => configuration[:message]) - end - end - end - - # Validates that the specified attributes are not blank (as defined by Object#blank?). Happens by default on save. Example: - # - # class Person < ActiveRecord::Base - # validates_presence_of :first_name - # end - # - # The first_name attribute must be in the object and it cannot be blank. - # - # If you want to validate the presence of a boolean field (where the real values are true and false), - # you will want to use <tt>validates_inclusion_of :field_name, :in => [true, false]</tt>. - # - # This is due to the way Object#blank? handles boolean values: <tt>false.blank? # => true</tt>. - # - # Configuration options: - # * <tt>message</tt> - A custom error message (default is: "can't be blank"). - # * <tt>on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, - # <tt>:update</tt>). - # * <tt>if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). - # The method, proc or string should return or evaluate to a true or false value. - # * <tt>unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). - # The method, proc or string should return or evaluate to a true or false value. - # - def validates_presence_of(*attr_names) - configuration = { :on => :save } - configuration.update(attr_names.extract_options!) - - # can't use validates_each here, because it cannot cope with nonexistent attributes, - # while errors.add_on_empty can - send(validation_method(configuration[:on]), configuration) do |record| - record.errors.add_on_blank(attr_names, configuration[:message]) - end - end - - # Validates that the specified attribute matches the length restrictions supplied. Only one option can be used at a time: - # - # class Person < ActiveRecord::Base - # validates_length_of :first_name, :maximum=>30 - # validates_length_of :last_name, :maximum=>30, :message=>"less than {{count}} if you don't mind" - # validates_length_of :fax, :in => 7..32, :allow_nil => true - # validates_length_of :phone, :in => 7..32, :allow_blank => true - # validates_length_of :user_name, :within => 6..20, :too_long => "pick a shorter name", :too_short => "pick a longer name" - # validates_length_of :fav_bra_size, :minimum => 1, :too_short => "please enter at least {{count}} character" - # validates_length_of :smurf_leader, :is => 4, :message => "papa is spelled with {{count}} characters... don't play me." - # validates_length_of :essay, :minimum => 100, :too_short => "Your essay must be at least {{count}} words."), :tokenizer => lambda {|str| str.scan(/\w+/) } - # end - # - # Configuration options: - # * <tt>:minimum</tt> - The minimum size of the attribute. - # * <tt>:maximum</tt> - The maximum size of the attribute. - # * <tt>:is</tt> - The exact size of the attribute. - # * <tt>:within</tt> - A range specifying the minimum and maximum size of the attribute. - # * <tt>:in</tt> - A synonym(or alias) for <tt>:within</tt>. - # * <tt>:allow_nil</tt> - Attribute may be +nil+; skip validation. - # * <tt>:allow_blank</tt> - Attribute may be blank; skip validation. - # * <tt>:too_long</tt> - The error message if the attribute goes over the maximum (default is: "is too long (maximum is {{count}} characters)"). - # * <tt>:too_short</tt> - The error message if the attribute goes under the minimum (default is: "is too short (min is {{count}} characters)"). - # * <tt>:wrong_length</tt> - The error message if using the <tt>:is</tt> method and the attribute is the wrong size (default is: "is the wrong length (should be {{count}} characters)"). - # * <tt>:message</tt> - The error message to use for a <tt>:minimum</tt>, <tt>:maximum</tt>, or <tt>:is</tt> violation. An alias of the appropriate <tt>too_long</tt>/<tt>too_short</tt>/<tt>wrong_length</tt> message. - # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>). - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:tokenizer</tt> - Specifies how to split up the attribute string. (e.g. <tt>:tokenizer => lambda {|str| str.scan(/\w+/)}</tt> to - # count words as in above example.) - # Defaults to <tt>lambda{ |value| value.split(//) }</tt> which counts individual characters. - def validates_length_of(*attrs) - # Merge given options with defaults. - options = { - :tokenizer => lambda {|value| value.split(//)} - }.merge(DEFAULT_VALIDATION_OPTIONS) - options.update(attrs.extract_options!.symbolize_keys) - - # Ensure that one and only one range option is specified. - range_options = ALL_RANGE_OPTIONS & options.keys - case range_options.size - when 0 - raise ArgumentError, 'Range unspecified. Specify the :within, :maximum, :minimum, or :is option.' - when 1 - # Valid number of options; do nothing. - else - raise ArgumentError, 'Too many range options specified. Choose only one.' - end - - # Get range option and value. - option = range_options.first - option_value = options[range_options.first] - key = {:is => :wrong_length, :minimum => :too_short, :maximum => :too_long}[option] - custom_message = options[:message] || options[key] - - case option - when :within, :in - raise ArgumentError, ":#{option} must be a Range" unless option_value.is_a?(Range) - - validates_each(attrs, options) do |record, attr, value| - value = options[:tokenizer].call(value) if value.kind_of?(String) - if value.nil? or value.size < option_value.begin - record.errors.add(attr, :too_short, :default => custom_message || options[:too_short], :count => option_value.begin) - elsif value.size > option_value.end - record.errors.add(attr, :too_long, :default => custom_message || options[:too_long], :count => option_value.end) - end - end - when :is, :minimum, :maximum - raise ArgumentError, ":#{option} must be a nonnegative Integer" unless option_value.is_a?(Integer) and option_value >= 0 - - # Declare different validations per option. - validity_checks = { :is => "==", :minimum => ">=", :maximum => "<=" } - - validates_each(attrs, options) do |record, attr, value| - value = options[:tokenizer].call(value) if value.kind_of?(String) - unless !value.nil? and value.size.method(validity_checks[option])[option_value] - record.errors.add(attr, key, :default => custom_message, :count => option_value) - end - end - end - end - - alias_method :validates_size_of, :validates_length_of - - - # Validates whether the value of the specified attributes are unique across the system. Useful for making sure that only one user - # can be named "davidhh". - # - # class Person < ActiveRecord::Base - # validates_uniqueness_of :user_name, :scope => :account_id - # end - # - # It can also validate whether the value of the specified attributes are unique based on multiple scope parameters. For example, - # making sure that a teacher can only be on the schedule once per semester for a particular class. - # - # class TeacherSchedule < ActiveRecord::Base - # validates_uniqueness_of :teacher_id, :scope => [:semester_id, :class_id] - # end - # - # When the record is created, a check is performed to make sure that no record exists in the database with the given value for the specified - # attribute (that maps to a column). When the record is updated, the same check is made but disregarding the record itself. - # - # Configuration options: - # * <tt>:message</tt> - Specifies a custom error message (default is: "has already been taken"). - # * <tt>:scope</tt> - One or more columns by which to limit the scope of the uniqueness constraint. - # * <tt>:case_sensitive</tt> - Looks for an exact match. Ignored by non-text columns (+true+ by default). - # * <tt>:allow_nil</tt> - If set to true, skips this validation if the attribute is +nil+ (default is +false+). - # * <tt>:allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is +false+). - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # - # === Concurrency and integrity - # - # Using this validation method in conjunction with ActiveRecord::Base#save - # does not guarantee the absence of duplicate record insertions, because - # uniqueness checks on the application level are inherently prone to race - # conditions. For example, suppose that two users try to post a Comment at - # the same time, and a Comment's title must be unique. At the database-level, - # the actions performed by these users could be interleaved in the following manner: - # - # User 1 | User 2 - # ------------------------------------+-------------------------------------- - # # User 1 checks whether there's | - # # already a comment with the title | - # # 'My Post'. This is not the case. | - # SELECT * FROM comments | - # WHERE title = 'My Post' | - # | - # | # User 2 does the same thing and also - # | # infers that his title is unique. - # | SELECT * FROM comments - # | WHERE title = 'My Post' - # | - # # User 1 inserts his comment. | - # INSERT INTO comments | - # (title, content) VALUES | - # ('My Post', 'hi!') | - # | - # | # User 2 does the same thing. - # | INSERT INTO comments - # | (title, content) VALUES - # | ('My Post', 'hello!') - # | - # | # ^^^^^^ - # | # Boom! We now have a duplicate - # | # title! - # - # This could even happen if you use transactions with the 'serializable' - # isolation level. There are several ways to get around this problem: - # - By locking the database table before validating, and unlocking it after - # saving. However, table locking is very expensive, and thus not - # recommended. - # - By locking a lock file before validating, and unlocking it after saving. - # This does not work if you've scaled your Rails application across - # multiple web servers (because they cannot share lock files, or cannot - # do that efficiently), and thus not recommended. - # - Creating a unique index on the field, by using - # ActiveRecord::ConnectionAdapters::SchemaStatements#add_index. In the - # rare case that a race condition occurs, the database will guarantee - # the field's uniqueness. - # - # When the database catches such a duplicate insertion, - # ActiveRecord::Base#save will raise an ActiveRecord::StatementInvalid - # exception. You can either choose to let this error propagate (which - # will result in the default Rails exception page being shown), or you - # can catch it and restart the transaction (e.g. by telling the user - # that the title already exists, and asking him to re-enter the title). - # This technique is also known as optimistic concurrency control: - # http://en.wikipedia.org/wiki/Optimistic_concurrency_control - # - # Active Record currently provides no way to distinguish unique - # index constraint errors from other types of database errors, so you - # will have to parse the (database-specific) exception message to detect - # such a case. - def validates_uniqueness_of(*attr_names) - configuration = { :case_sensitive => true } - configuration.update(attr_names.extract_options!) - - validates_each(attr_names,configuration) do |record, attr_name, value| - # The check for an existing value should be run from a class that - # isn't abstract. This means working down from the current class - # (self), to the first non-abstract class. Since classes don't know - # their subclasses, we have to build the hierarchy between self and - # the record's class. - class_hierarchy = [record.class] - while class_hierarchy.first != self - class_hierarchy.insert(0, class_hierarchy.first.superclass) - end - - # Now we can work our way down the tree to the first non-abstract - # class (which has a database table to query from). - finder_class = class_hierarchy.detect { |klass| !klass.abstract_class? } - - column = finder_class.columns_hash[attr_name.to_s] - - if value.nil? - comparison_operator = "IS ?" - elsif column.text? - comparison_operator = "#{connection.case_sensitive_equality_operator} ?" - value = column.limit ? value.to_s[0, column.limit] : value.to_s - else - comparison_operator = "= ?" - end - - sql_attribute = "#{record.class.quoted_table_name}.#{connection.quote_column_name(attr_name)}" - - if value.nil? || (configuration[:case_sensitive] || !column.text?) - condition_sql = "#{sql_attribute} #{comparison_operator}" - condition_params = [value] - else - condition_sql = "LOWER(#{sql_attribute}) #{comparison_operator}" - condition_params = [value.mb_chars.downcase] - end - - if scope = configuration[:scope] - Array(scope).map do |scope_item| - scope_value = record.send(scope_item) - condition_sql << " AND " << attribute_condition("#{record.class.quoted_table_name}.#{scope_item}", scope_value) - condition_params << scope_value - end - end - - unless record.new_record? - condition_sql << " AND #{record.class.quoted_table_name}.#{record.class.primary_key} <> ?" - condition_params << record.send(:id) - end - - finder_class.with_exclusive_scope do - if finder_class.exists?([condition_sql, *condition_params]) - record.errors.add(attr_name, :taken, :default => configuration[:message], :value => value) - end - end - end - end - - - # Validates whether the value of the specified attribute is of the correct form by matching it against the regular expression - # provided. - # - # class Person < ActiveRecord::Base - # validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :on => :create - # end - # - # Note: use <tt>\A</tt> and <tt>\Z</tt> to match the start and end of the string, <tt>^</tt> and <tt>$</tt> match the start/end of a line. - # - # A regular expression must be provided or else an exception will be raised. - # - # Configuration options: - # * <tt>:message</tt> - A custom error message (default is: "is invalid"). - # * <tt>:allow_nil</tt> - If set to true, skips this validation if the attribute is +nil+ (default is +false+). - # * <tt>:allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is +false+). - # * <tt>:with</tt> - The regular expression used to validate the format with (note: must be supplied!). - # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>). - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_format_of(*attr_names) - configuration = { :on => :save, :with => nil } - configuration.update(attr_names.extract_options!) - - raise(ArgumentError, "A regular expression must be supplied as the :with option of the configuration hash") unless configuration[:with].is_a?(Regexp) - - validates_each(attr_names, configuration) do |record, attr_name, value| - unless value.to_s =~ configuration[:with] - record.errors.add(attr_name, :invalid, :default => configuration[:message], :value => value) - end - end - end - - # Validates whether the value of the specified attribute is available in a particular enumerable object. - # - # class Person < ActiveRecord::Base - # validates_inclusion_of :gender, :in => %w( m f ), :message => "woah! what are you then!??!!" - # validates_inclusion_of :age, :in => 0..99 - # validates_inclusion_of :format, :in => %w( jpg gif png ), :message => "extension {{value}} is not included in the list" - # end - # - # Configuration options: - # * <tt>:in</tt> - An enumerable object of available items. - # * <tt>:message</tt> - Specifies a custom error message (default is: "is not included in the list"). - # * <tt>:allow_nil</tt> - If set to true, skips this validation if the attribute is +nil+ (default is +false+). - # * <tt>:allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is +false+). - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_inclusion_of(*attr_names) - configuration = { :on => :save } - configuration.update(attr_names.extract_options!) - - enum = configuration[:in] || configuration[:within] - - raise(ArgumentError, "An object with the method include? is required must be supplied as the :in option of the configuration hash") unless enum.respond_to?(:include?) - - validates_each(attr_names, configuration) do |record, attr_name, value| - unless enum.include?(value) - record.errors.add(attr_name, :inclusion, :default => configuration[:message], :value => value) - end - end - end - - # Validates that the value of the specified attribute is not in a particular enumerable object. - # - # class Person < ActiveRecord::Base - # validates_exclusion_of :username, :in => %w( admin superuser ), :message => "You don't belong here" - # validates_exclusion_of :age, :in => 30..60, :message => "This site is only for under 30 and over 60" - # validates_exclusion_of :format, :in => %w( mov avi ), :message => "extension {{value}} is not allowed" - # end - # - # Configuration options: - # * <tt>:in</tt> - An enumerable object of items that the value shouldn't be part of. - # * <tt>:message</tt> - Specifies a custom error message (default is: "is reserved"). - # * <tt>:allow_nil</tt> - If set to true, skips this validation if the attribute is +nil+ (default is +false+). - # * <tt>:allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is +false+). - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_exclusion_of(*attr_names) - configuration = { :on => :save } - configuration.update(attr_names.extract_options!) - - enum = configuration[:in] || configuration[:within] - - raise(ArgumentError, "An object with the method include? is required must be supplied as the :in option of the configuration hash") unless enum.respond_to?(:include?) - - validates_each(attr_names, configuration) do |record, attr_name, value| - if enum.include?(value) - record.errors.add(attr_name, :exclusion, :default => configuration[:message], :value => value) - end - end - end - - # Validates whether the associated object or objects are all valid themselves. Works with any kind of association. - # - # class Book < ActiveRecord::Base - # has_many :pages - # belongs_to :library - # - # validates_associated :pages, :library - # end - # - # Warning: If, after the above definition, you then wrote: - # - # class Page < ActiveRecord::Base - # belongs_to :book - # - # validates_associated :book - # end - # - # this would specify a circular dependency and cause infinite recursion. - # - # NOTE: This validation will not fail if the association hasn't been assigned. If you want to ensure that the association - # is both present and guaranteed to be valid, you also need to use +validates_presence_of+. - # - # Configuration options: - # * <tt>:message</tt> - A custom error message (default is: "is invalid") - # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>). - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_associated(*attr_names) - configuration = { :on => :save } - configuration.update(attr_names.extract_options!) - - validates_each(attr_names, configuration) do |record, attr_name, value| - unless (value.is_a?(Array) ? value : [value]).collect { |r| r.nil? || r.valid? }.all? - record.errors.add(attr_name, :invalid, :default => configuration[:message], :value => value) - end - end - end - - # Validates whether the value of the specified attribute is numeric by trying to convert it to - # a float with Kernel.Float (if <tt>only_integer</tt> is false) or applying it to the regular expression - # <tt>/\A[\+\-]?\d+\Z/</tt> (if <tt>only_integer</tt> is set to true). - # - # class Person < ActiveRecord::Base - # validates_numericality_of :value, :on => :create - # end - # - # Configuration options: - # * <tt>:message</tt> - A custom error message (default is: "is not a number"). - # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>). - # * <tt>:only_integer</tt> - Specifies whether the value has to be an integer, e.g. an integral value (default is +false+). - # * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+ (default is +false+). Notice that for fixnum and float columns empty strings are converted to +nil+. - # * <tt>:greater_than</tt> - Specifies the value must be greater than the supplied value. - # * <tt>:greater_than_or_equal_to</tt> - Specifies the value must be greater than or equal the supplied value. - # * <tt>:equal_to</tt> - Specifies the value must be equal to the supplied value. - # * <tt>:less_than</tt> - Specifies the value must be less than the supplied value. - # * <tt>:less_than_or_equal_to</tt> - Specifies the value must be less than or equal the supplied value. - # * <tt>:odd</tt> - Specifies the value must be an odd number. - # * <tt>:even</tt> - Specifies the value must be an even number. - # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should - # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should - # not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The - # method, proc or string should return or evaluate to a true or false value. - def validates_numericality_of(*attr_names) - configuration = { :on => :save, :only_integer => false, :allow_nil => false } - configuration.update(attr_names.extract_options!) - - - numericality_options = ALL_NUMERICALITY_CHECKS.keys & configuration.keys - - (numericality_options - [ :odd, :even ]).each do |option| - raise ArgumentError, ":#{option} must be a number" unless configuration[option].is_a?(Numeric) - end - - validates_each(attr_names,configuration) do |record, attr_name, value| - raw_value = record.send("#{attr_name}_before_type_cast") || value - - next if configuration[:allow_nil] and raw_value.nil? - - if configuration[:only_integer] - unless raw_value.to_s =~ /\A[+-]?\d+\Z/ - record.errors.add(attr_name, :not_a_number, :value => raw_value, :default => configuration[:message]) - next - end - raw_value = raw_value.to_i - else - begin - raw_value = Kernel.Float(raw_value) - rescue ArgumentError, TypeError - record.errors.add(attr_name, :not_a_number, :value => raw_value, :default => configuration[:message]) - next - end - end - - numericality_options.each do |option| - case option - when :odd, :even - unless raw_value.to_i.method(ALL_NUMERICALITY_CHECKS[option])[] - record.errors.add(attr_name, option, :value => raw_value, :default => configuration[:message]) - end - else - record.errors.add(attr_name, option, :default => configuration[:message], :value => raw_value, :count => configuration[option]) unless raw_value.method(ALL_NUMERICALITY_CHECKS[option])[configuration[option]] - end - end - end - end - - # Creates an object just like Base.create but calls save! instead of save - # so an exception is raised if the record is invalid. - def create!(attributes = nil, &block) - if attributes.is_a?(Array) - attributes.collect { |attr| create!(attr, &block) } - else - object = new(attributes) - yield(object) if block_given? - object.save! - object - end - end - - private - def validation_method(on) - case on - when :save then :validate - when :create then :validate_on_create - when :update then :validate_on_update - end - end - end - - # The validation process on save can be skipped by passing false. The regular Base#save method is - # replaced with this when the validations module is mixed in, which it is by default. - def save_with_validation(perform_validation = true) - if perform_validation && valid? || !perform_validation - save_without_validation - else - false - end - end - - # Attempts to save the record just like Base#save but will raise a RecordInvalid exception instead of returning false - # if the record is not valid. - def save_with_validation! - if valid? - save_without_validation! - else - raise RecordInvalid.new(self) - end - end - - # Runs +validate+ and +validate_on_create+ or +validate_on_update+ and returns true if no errors were added otherwise false. - def valid? - errors.clear - - run_callbacks(:validate) - validate - - if new_record? - run_callbacks(:validate_on_create) - validate_on_create - else - run_callbacks(:validate_on_update) - validate_on_update - end - - errors.empty? - end - - # Performs the opposite of <tt>valid?</tt>. Returns true if errors were added, false otherwise. - def invalid? - !valid? - end - - # Returns the Errors object that holds all information about attribute error messages. - def errors - @errors ||= Errors.new(self) - end - - protected - # Overwrite this method for validation checks on all saves and use <tt>Errors.add(field, msg)</tt> for invalid attributes. - def validate - end - - # Overwrite this method for validation checks used only on creation. - def validate_on_create - end - - # Overwrite this method for validation checks used only on updates. - def validate_on_update - end - end -end diff --git a/vendor/rails/activerecord/lib/active_record/version.rb b/vendor/rails/activerecord/lib/active_record/version.rb deleted file mode 100644 index 852807b..0000000 --- a/vendor/rails/activerecord/lib/active_record/version.rb +++ /dev/null @@ -1,9 +0,0 @@ -module ActiveRecord - module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 2 - - STRING = [MAJOR, MINOR, TINY].join('.') - end -end diff --git a/vendor/rails/activerecord/lib/activerecord.rb b/vendor/rails/activerecord/lib/activerecord.rb deleted file mode 100644 index cd62b2a..0000000 --- a/vendor/rails/activerecord/lib/activerecord.rb +++ /dev/null @@ -1 +0,0 @@ -require 'active_record' diff --git a/vendor/rails/activerecord/test/assets/example.log b/vendor/rails/activerecord/test/assets/example.log deleted file mode 100644 index f084369..0000000 --- a/vendor/rails/activerecord/test/assets/example.log +++ /dev/null @@ -1 +0,0 @@ -# Logfile created on Wed Oct 31 16:05:13 +0000 2007 by logger.rb/1.5.2.9 diff --git a/vendor/rails/activerecord/test/assets/flowers.jpg b/vendor/rails/activerecord/test/assets/flowers.jpg deleted file mode 100644 index fe9df54..0000000 Binary files a/vendor/rails/activerecord/test/assets/flowers.jpg and /dev/null differ diff --git a/vendor/rails/activerecord/test/cases/aaa_create_tables_test.rb b/vendor/rails/activerecord/test/cases/aaa_create_tables_test.rb deleted file mode 100644 index 3911afa..0000000 --- a/vendor/rails/activerecord/test/cases/aaa_create_tables_test.rb +++ /dev/null @@ -1,24 +0,0 @@ -# The filename begins with "aaa" to ensure this is the first test. -require "cases/helper" - -class AAACreateTablesTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def test_load_schema - eval(File.read(SCHEMA_ROOT + "/schema.rb")) - if File.exists?(adapter_specific_schema_file) - eval(File.read(adapter_specific_schema_file)) - end - assert true - end - - def test_drop_and_create_courses_table - eval(File.read(SCHEMA_ROOT + "/schema2.rb")) - assert true - end - - private - def adapter_specific_schema_file - SCHEMA_ROOT + '/' + ActiveRecord::Base.connection.adapter_name.downcase + '_specific_schema.rb' - end -end diff --git a/vendor/rails/activerecord/test/cases/active_schema_test_mysql.rb b/vendor/rails/activerecord/test/cases/active_schema_test_mysql.rb deleted file mode 100644 index 9aff538..0000000 --- a/vendor/rails/activerecord/test/cases/active_schema_test_mysql.rb +++ /dev/null @@ -1,100 +0,0 @@ -require "cases/helper" - -class ActiveSchemaTest < ActiveRecord::TestCase - def setup - ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do - alias_method :execute_without_stub, :execute - def execute(sql, name = nil) return sql end - end - end - - def teardown - ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do - remove_method :execute - alias_method :execute, :execute_without_stub - end - end - - def test_drop_table - assert_equal "DROP TABLE `people`", drop_table(:people) - end - - if current_adapter?(:MysqlAdapter) - def test_create_mysql_database_with_encoding - assert_equal "CREATE DATABASE `matt` DEFAULT CHARACTER SET `utf8`", create_database(:matt) - assert_equal "CREATE DATABASE `aimonetti` DEFAULT CHARACTER SET `latin1`", create_database(:aimonetti, {:charset => 'latin1'}) - assert_equal "CREATE DATABASE `matt_aimonetti` DEFAULT CHARACTER SET `big5` COLLATE `big5_chinese_ci`", create_database(:matt_aimonetti, {:charset => :big5, :collation => :big5_chinese_ci}) - end - - def test_recreate_mysql_database_with_encoding - create_database(:luca, {:charset => 'latin1'}) - assert_equal "CREATE DATABASE `luca` DEFAULT CHARACTER SET `latin1`", recreate_database(:luca, {:charset => 'latin1'}) - end - end - - def test_add_column - assert_equal "ALTER TABLE `people` ADD `last_name` varchar(255)", add_column(:people, :last_name, :string) - end - - def test_add_column_with_limit - assert_equal "ALTER TABLE `people` ADD `key` varchar(32)", add_column(:people, :key, :string, :limit => 32) - end - - def test_drop_table_with_specific_database - assert_equal "DROP TABLE `otherdb`.`people`", drop_table('otherdb.people') - end - - def test_add_timestamps - with_real_execute do - begin - ActiveRecord::Base.connection.create_table :delete_me do |t| - end - ActiveRecord::Base.connection.add_timestamps :delete_me - assert column_present?('delete_me', 'updated_at', 'datetime') - assert column_present?('delete_me', 'created_at', 'datetime') - ensure - ActiveRecord::Base.connection.drop_table :delete_me rescue nil - end - end - end - - def test_remove_timestamps - with_real_execute do - begin - ActiveRecord::Base.connection.create_table :delete_me do |t| - t.timestamps - end - ActiveRecord::Base.connection.remove_timestamps :delete_me - assert !column_present?('delete_me', 'updated_at', 'datetime') - assert !column_present?('delete_me', 'created_at', 'datetime') - ensure - ActiveRecord::Base.connection.drop_table :delete_me rescue nil - end - end - end - - private - def with_real_execute - #we need to actually modify some data, so we make execute point to the original method - ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do - alias_method :execute_with_stub, :execute - alias_method :execute, :execute_without_stub - end - yield - ensure - #before finishing, we restore the alias to the mock-up method - ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do - alias_method :execute, :execute_with_stub - end - end - - - def method_missing(method_symbol, *arguments) - ActiveRecord::Base.connection.send(method_symbol, *arguments) - end - - def column_present?(table_name, column_name, type) - results = ActiveRecord::Base.connection.select_all("SHOW FIELDS FROM #{table_name} LIKE '#{column_name}'") - results.first && results.first['Type'] == type - end -end diff --git a/vendor/rails/activerecord/test/cases/active_schema_test_postgresql.rb b/vendor/rails/activerecord/test/cases/active_schema_test_postgresql.rb deleted file mode 100644 index af80f72..0000000 --- a/vendor/rails/activerecord/test/cases/active_schema_test_postgresql.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'cases/helper' - -class PostgresqlActiveSchemaTest < Test::Unit::TestCase - def setup - ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do - alias_method :real_execute, :execute - def execute(sql, name = nil) sql end - end - end - - def teardown - ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send(:alias_method, :execute, :real_execute) - end - - def test_create_database_with_encoding - assert_equal %(CREATE DATABASE "matt" ENCODING = 'utf8'), create_database(:matt) - assert_equal %(CREATE DATABASE "aimonetti" ENCODING = 'latin1'), create_database(:aimonetti, :encoding => :latin1) - end - - private - def method_missing(method_symbol, *arguments) - ActiveRecord::Base.connection.send(method_symbol, *arguments) - end -end diff --git a/vendor/rails/activerecord/test/cases/adapter_test.rb b/vendor/rails/activerecord/test/cases/adapter_test.rb deleted file mode 100644 index 0477064..0000000 --- a/vendor/rails/activerecord/test/cases/adapter_test.rb +++ /dev/null @@ -1,133 +0,0 @@ -require "cases/helper" - -class AdapterTest < ActiveRecord::TestCase - def setup - @connection = ActiveRecord::Base.connection - end - - def test_tables - tables = @connection.tables - assert tables.include?("accounts") - assert tables.include?("authors") - assert tables.include?("tasks") - assert tables.include?("topics") - end - - def test_table_exists? - assert @connection.table_exists?("accounts") - assert !@connection.table_exists?("nonexistingtable") - end - - def test_indexes - idx_name = "accounts_idx" - - if @connection.respond_to?(:indexes) - indexes = @connection.indexes("accounts") - assert indexes.empty? - - @connection.add_index :accounts, :firm_id, :name => idx_name - indexes = @connection.indexes("accounts") - assert_equal "accounts", indexes.first.table - # OpenBase does not have the concept of a named index - # Indexes are merely properties of columns. - assert_equal idx_name, indexes.first.name unless current_adapter?(:OpenBaseAdapter) - assert !indexes.first.unique - assert_equal ["firm_id"], indexes.first.columns - else - warn "#{@connection.class} does not respond to #indexes" - end - - ensure - @connection.remove_index(:accounts, :name => idx_name) rescue nil - end - - def test_current_database - if @connection.respond_to?(:current_database) - assert_equal ENV['ARUNIT_DB_NAME'] || "activerecord_unittest", @connection.current_database - end - end - - if current_adapter?(:MysqlAdapter) - def test_charset - assert_not_nil @connection.charset - assert_not_equal 'character_set_database', @connection.charset - assert_equal @connection.show_variable('character_set_database'), @connection.charset - end - - def test_collation - assert_not_nil @connection.collation - assert_not_equal 'collation_database', @connection.collation - assert_equal @connection.show_variable('collation_database'), @connection.collation - end - - def test_show_nonexistent_variable_returns_nil - assert_nil @connection.show_variable('foo_bar_baz') - end - end - - if current_adapter?(:PostgreSQLAdapter) - def test_encoding - assert_not_nil @connection.encoding - end - end - - def test_table_alias - def @connection.test_table_alias_length() 10; end - class << @connection - alias_method :old_table_alias_length, :table_alias_length - alias_method :table_alias_length, :test_table_alias_length - end - - assert_equal 'posts', @connection.table_alias_for('posts') - assert_equal 'posts_comm', @connection.table_alias_for('posts_comments') - assert_equal 'dbo_posts', @connection.table_alias_for('dbo.posts') - - class << @connection - remove_method :table_alias_length - alias_method :table_alias_length, :old_table_alias_length - end - end - - # test resetting sequences in odd tables in postgreSQL - if ActiveRecord::Base.connection.respond_to?(:reset_pk_sequence!) - require 'models/movie' - require 'models/subscriber' - - def test_reset_empty_table_with_custom_pk - Movie.delete_all - Movie.connection.reset_pk_sequence! 'movies' - assert_equal 1, Movie.create(:name => 'fight club').id - end - - if ActiveRecord::Base.connection.adapter_name != "FrontBase" - def test_reset_table_with_non_integer_pk - Subscriber.delete_all - Subscriber.connection.reset_pk_sequence! 'subscribers' - sub = Subscriber.new(:name => 'robert drake') - sub.id = 'bob drake' - assert_nothing_raised { sub.save! } - end - end - end - - def test_add_limit_offset_should_sanitize_sql_injection_for_limit_without_comas - sql_inject = "1 select * from schema" - assert_equal " LIMIT 1", @connection.add_limit_offset!("", :limit=>sql_inject) - if current_adapter?(:MysqlAdapter) - assert_equal " LIMIT 7, 1", @connection.add_limit_offset!("", :limit=>sql_inject, :offset=>7) - else - assert_equal " LIMIT 1 OFFSET 7", @connection.add_limit_offset!("", :limit=>sql_inject, :offset=>7) - end - end - - def test_add_limit_offset_should_sanitize_sql_injection_for_limit_with_comas - sql_inject = "1, 7 procedure help()" - if current_adapter?(:MysqlAdapter) - assert_equal " LIMIT 1,7", @connection.add_limit_offset!("", :limit=>sql_inject) - assert_equal " LIMIT 7, 1", @connection.add_limit_offset!("", :limit=> '1 ; DROP TABLE USERS', :offset=>7) - else - assert_equal " LIMIT 1,7", @connection.add_limit_offset!("", :limit=>sql_inject) - assert_equal " LIMIT 1,7 OFFSET 7", @connection.add_limit_offset!("", :limit=>sql_inject, :offset=>7) - end - end -end diff --git a/vendor/rails/activerecord/test/cases/aggregations_test.rb b/vendor/rails/activerecord/test/cases/aggregations_test.rb deleted file mode 100644 index 4e0e1c7..0000000 --- a/vendor/rails/activerecord/test/cases/aggregations_test.rb +++ /dev/null @@ -1,167 +0,0 @@ -require "cases/helper" -require 'models/customer' - -class AggregationsTest < ActiveRecord::TestCase - fixtures :customers - - def test_find_single_value_object - assert_equal 50, customers(:david).balance.amount - assert_kind_of Money, customers(:david).balance - assert_equal 300, customers(:david).balance.exchange_to("DKK").amount - end - - def test_find_multiple_value_object - assert_equal customers(:david).address_street, customers(:david).address.street - assert( - customers(:david).address.close_to?(Address.new("Different Street", customers(:david).address_city, customers(:david).address_country)) - ) - end - - def test_change_single_value_object - customers(:david).balance = Money.new(100) - customers(:david).save - assert_equal 100, customers(:david).reload.balance.amount - end - - def test_immutable_value_objects - customers(:david).balance = Money.new(100) - assert_raise(ActiveSupport::FrozenObjectError) { customers(:david).balance.instance_eval { @amount = 20 } } - end - - def test_inferred_mapping - assert_equal "35.544623640962634", customers(:david).gps_location.latitude - assert_equal "-105.9309951055148", customers(:david).gps_location.longitude - - customers(:david).gps_location = GpsLocation.new("39x-110") - - assert_equal "39", customers(:david).gps_location.latitude - assert_equal "-110", customers(:david).gps_location.longitude - - customers(:david).save - - customers(:david).reload - - assert_equal "39", customers(:david).gps_location.latitude - assert_equal "-110", customers(:david).gps_location.longitude - end - - def test_reloaded_instance_refreshes_aggregations - assert_equal "35.544623640962634", customers(:david).gps_location.latitude - assert_equal "-105.9309951055148", customers(:david).gps_location.longitude - - Customer.update_all("gps_location = '24x113'") - customers(:david).reload - assert_equal '24x113', customers(:david)['gps_location'] - - assert_equal GpsLocation.new('24x113'), customers(:david).gps_location - end - - def test_gps_equality - assert GpsLocation.new('39x110') == GpsLocation.new('39x110') - end - - def test_gps_inequality - assert GpsLocation.new('39x110') != GpsLocation.new('39x111') - end - - def test_allow_nil_gps_is_nil - assert_equal nil, customers(:zaphod).gps_location - end - - def test_allow_nil_gps_set_to_nil - customers(:david).gps_location = nil - customers(:david).save - customers(:david).reload - assert_equal nil, customers(:david).gps_location - end - - def test_allow_nil_set_address_attributes_to_nil - customers(:zaphod).address = nil - assert_equal nil, customers(:zaphod).attributes[:address_street] - assert_equal nil, customers(:zaphod).attributes[:address_city] - assert_equal nil, customers(:zaphod).attributes[:address_country] - end - - def test_allow_nil_address_set_to_nil - customers(:zaphod).address = nil - customers(:zaphod).save - customers(:zaphod).reload - assert_equal nil, customers(:zaphod).address - end - - def test_nil_raises_error_when_allow_nil_is_false - assert_raise(NoMethodError) { customers(:david).balance = nil } - end - - def test_allow_nil_address_loaded_when_only_some_attributes_are_nil - customers(:zaphod).address_street = nil - customers(:zaphod).save - customers(:zaphod).reload - assert_kind_of Address, customers(:zaphod).address - assert customers(:zaphod).address.street.nil? - end - - def test_nil_assignment_results_in_nil - customers(:david).gps_location = GpsLocation.new('39x111') - assert_not_equal nil, customers(:david).gps_location - customers(:david).gps_location = nil - assert_equal nil, customers(:david).gps_location - end - - def test_custom_constructor - assert_equal 'Barney GUMBLE', customers(:barney).fullname.to_s - assert_kind_of Fullname, customers(:barney).fullname - end - - def test_custom_converter - customers(:barney).fullname = 'Barnoit Gumbleau' - assert_equal 'Barnoit GUMBLEAU', customers(:barney).fullname.to_s - assert_kind_of Fullname, customers(:barney).fullname - end -end - -class DeprecatedAggregationsTest < ActiveRecord::TestCase - class Person < ActiveRecord::Base; end - - def test_conversion_block_is_deprecated - assert_deprecated 'conversion block has been deprecated' do - Person.composed_of(:balance, :class_name => "Money", :mapping => %w(balance amount)) { |balance| balance.to_money } - end - end - - def test_conversion_block_used_when_converter_option_is_nil - assert_deprecated 'conversion block has been deprecated' do - Person.composed_of(:balance, :class_name => "Money", :mapping => %w(balance amount)) { |balance| balance.to_money } - end - assert_raise(NoMethodError) { Person.new.balance = 5 } - end - - def test_converter_option_overrides_conversion_block - assert_deprecated 'conversion block has been deprecated' do - Person.composed_of(:balance, :class_name => "Money", :mapping => %w(balance amount), :converter => Proc.new { |balance| Money.new(balance) }) { |balance| balance.to_money } - end - - person = Person.new - assert_nothing_raised { person.balance = 5 } - assert_equal 5, person.balance.amount - assert_kind_of Money, person.balance - end -end - -class OverridingAggregationsTest < ActiveRecord::TestCase - class Name; end - class DifferentName; end - - class Person < ActiveRecord::Base - composed_of :composed_of, :mapping => %w(person_first_name first_name) - end - - class DifferentPerson < Person - composed_of :composed_of, :class_name => 'DifferentName', :mapping => %w(different_person_first_name first_name) - end - - def test_composed_of_aggregation_redefinition_reflections_should_differ_and_not_inherited - assert_not_equal Person.reflect_on_aggregation(:composed_of), - DifferentPerson.reflect_on_aggregation(:composed_of) - end -end diff --git a/vendor/rails/activerecord/test/cases/ar_schema_test.rb b/vendor/rails/activerecord/test/cases/ar_schema_test.rb deleted file mode 100644 index 4c1589d..0000000 --- a/vendor/rails/activerecord/test/cases/ar_schema_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require "cases/helper" - -if ActiveRecord::Base.connection.supports_migrations? - - class ActiveRecordSchemaTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @connection = ActiveRecord::Base.connection - end - - def teardown - @connection.drop_table :fruits rescue nil - end - - def test_schema_define - ActiveRecord::Schema.define(:version => 7) do - create_table :fruits do |t| - t.column :color, :string - t.column :fruit_size, :string # NOTE: "size" is reserved in Oracle - t.column :texture, :string - t.column :flavor, :string - end - end - - assert_nothing_raised { @connection.select_all "SELECT * FROM fruits" } - assert_nothing_raised { @connection.select_all "SELECT * FROM schema_migrations" } - assert_equal 7, ActiveRecord::Migrator::current_version - end - end - -end diff --git a/vendor/rails/activerecord/test/cases/associations/belongs_to_associations_test.rb b/vendor/rails/activerecord/test/cases/associations/belongs_to_associations_test.rb deleted file mode 100644 index 13a78a1..0000000 --- a/vendor/rails/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ /dev/null @@ -1,345 +0,0 @@ -require "cases/helper" -require 'models/developer' -require 'models/project' -require 'models/company' -require 'models/topic' -require 'models/reply' -require 'models/computer' -require 'models/customer' -require 'models/order' -require 'models/post' -require 'models/author' -require 'models/tag' -require 'models/tagging' -require 'models/comment' -require 'models/sponsor' -require 'models/member' - -class BelongsToAssociationsTest < ActiveRecord::TestCase - fixtures :accounts, :companies, :developers, :projects, :topics, - :developers_projects, :computers, :authors, :posts, :tags, :taggings, :comments - - def test_belongs_to - Client.find(3).firm.name - assert_equal companies(:first_firm).name, Client.find(3).firm.name - assert !Client.find(3).firm.nil?, "Microsoft should have a firm" - end - - def test_proxy_assignment - account = Account.find(1) - assert_nothing_raised { account.firm = account.firm } - end - - def test_triple_equality - assert Client.find(3).firm === Firm - assert Firm === Client.find(3).firm - end - - def test_type_mismatch - assert_raise(ActiveRecord::AssociationTypeMismatch) { Account.find(1).firm = 1 } - assert_raise(ActiveRecord::AssociationTypeMismatch) { Account.find(1).firm = Project.find(1) } - end - - def test_natural_assignment - apple = Firm.create("name" => "Apple") - citibank = Account.create("credit_limit" => 10) - citibank.firm = apple - assert_equal apple.id, citibank.firm_id - end - - def test_no_unexpected_aliasing - first_firm = companies(:first_firm) - another_firm = companies(:another_firm) - - citibank = Account.create("credit_limit" => 10) - citibank.firm = first_firm - original_proxy = citibank.firm - citibank.firm = another_firm - - assert_equal first_firm.object_id, original_proxy.target.object_id - assert_equal another_firm.object_id, citibank.firm.target.object_id - end - - def test_creating_the_belonging_object - citibank = Account.create("credit_limit" => 10) - apple = citibank.create_firm("name" => "Apple") - assert_equal apple, citibank.firm - citibank.save - citibank.reload - assert_equal apple, citibank.firm - end - - def test_building_the_belonging_object - citibank = Account.create("credit_limit" => 10) - apple = citibank.build_firm("name" => "Apple") - citibank.save - assert_equal apple.id, citibank.firm_id - end - - def test_natural_assignment_to_nil - client = Client.find(3) - client.firm = nil - client.save - assert_nil client.firm(true) - assert_nil client.client_of - end - - def test_with_different_class_name - assert_equal Company.find(1).name, Company.find(3).firm_with_other_name.name - assert_not_nil Company.find(3).firm_with_other_name, "Microsoft should have a firm" - end - - def test_with_condition - assert_equal Company.find(1).name, Company.find(3).firm_with_condition.name - assert_not_nil Company.find(3).firm_with_condition, "Microsoft should have a firm" - end - - def test_with_select - assert_equal Company.find(2).firm_with_select.attributes.size, 1 - assert_equal Company.find(2, :include => :firm_with_select ).firm_with_select.attributes.size, 1 - end - - def test_belongs_to_counter - debate = Topic.create("title" => "debate") - assert_equal 0, debate.send(:read_attribute, "replies_count"), "No replies yet" - - trash = debate.replies.create("title" => "blah!", "content" => "world around!") - assert_equal 1, Topic.find(debate.id).send(:read_attribute, "replies_count"), "First reply created" - - trash.destroy - assert_equal 0, Topic.find(debate.id).send(:read_attribute, "replies_count"), "First reply deleted" - end - - def test_belongs_to_counter_with_assigning_nil - p = Post.find(1) - c = Comment.find(1) - - assert_equal p.id, c.post_id - assert_equal 2, Post.find(p.id).comments.size - - c.post = nil - - assert_equal 1, Post.find(p.id).comments.size - end - - def test_belongs_to_counter_with_reassigning - t1 = Topic.create("title" => "t1") - t2 = Topic.create("title" => "t2") - r1 = Reply.new("title" => "r1", "content" => "r1") - r1.topic = t1 - - assert r1.save - assert_equal 1, Topic.find(t1.id).replies.size - assert_equal 0, Topic.find(t2.id).replies.size - - r1.topic = Topic.find(t2.id) - - assert r1.save - assert_equal 0, Topic.find(t1.id).replies.size - assert_equal 1, Topic.find(t2.id).replies.size - - r1.topic = nil - - assert_equal 0, Topic.find(t1.id).replies.size - assert_equal 0, Topic.find(t2.id).replies.size - - r1.topic = t1 - - assert_equal 1, Topic.find(t1.id).replies.size - assert_equal 0, Topic.find(t2.id).replies.size - - r1.destroy - - assert_equal 0, Topic.find(t1.id).replies.size - assert_equal 0, Topic.find(t2.id).replies.size - end - - def test_belongs_to_reassign_with_namespaced_models_and_counters - t1 = Web::Topic.create("title" => "t1") - t2 = Web::Topic.create("title" => "t2") - r1 = Web::Reply.new("title" => "r1", "content" => "r1") - r1.topic = t1 - - assert r1.save - assert_equal 1, Web::Topic.find(t1.id).replies.size - assert_equal 0, Web::Topic.find(t2.id).replies.size - - r1.topic = Web::Topic.find(t2.id) - - assert r1.save - assert_equal 0, Web::Topic.find(t1.id).replies.size - assert_equal 1, Web::Topic.find(t2.id).replies.size - end - - def test_belongs_to_counter_after_save - topic = Topic.create!(:title => "monday night") - topic.replies.create!(:title => "re: monday night", :content => "football") - assert_equal 1, Topic.find(topic.id)[:replies_count] - - topic.save! - assert_equal 1, Topic.find(topic.id)[:replies_count] - end - - def test_belongs_to_counter_after_update_attributes - topic = Topic.create!(:title => "37s") - topic.replies.create!(:title => "re: 37s", :content => "rails") - assert_equal 1, Topic.find(topic.id)[:replies_count] - - topic.update_attributes(:title => "37signals") - assert_equal 1, Topic.find(topic.id)[:replies_count] - end - - def test_belongs_to_counter_after_save - topic = Topic.create("title" => "monday night") - topic.replies.create("title" => "re: monday night", "content" => "football") - assert_equal 1, Topic.find(topic.id).send(:read_attribute, "replies_count") - - topic.save - assert_equal 1, Topic.find(topic.id).send(:read_attribute, "replies_count") - end - - def test_belongs_to_counter_after_update_attributes - topic = Topic.create("title" => "37s") - topic.replies.create("title" => "re: 37s", "content" => "rails") - assert_equal 1, Topic.find(topic.id).send(:read_attribute, "replies_count") - - topic.update_attributes("title" => "37signals") - assert_equal 1, Topic.find(topic.id).send(:read_attribute, "replies_count") - end - - def test_assignment_before_child_saved - final_cut = Client.new("name" => "Final Cut") - firm = Firm.find(1) - final_cut.firm = firm - assert final_cut.new_record? - assert final_cut.save - assert !final_cut.new_record? - assert !firm.new_record? - assert_equal firm, final_cut.firm - assert_equal firm, final_cut.firm(true) - end - - def test_new_record_with_foreign_key_but_no_object - c = Client.new("firm_id" => 1) - assert_equal Firm.find(:first), c.firm_with_basic_id - end - - def test_forgetting_the_load_when_foreign_key_enters_late - c = Client.new - assert_nil c.firm_with_basic_id - - c.firm_id = 1 - assert_equal Firm.find(:first), c.firm_with_basic_id - end - - def test_field_name_same_as_foreign_key - computer = Computer.find(1) - assert_not_nil computer.developer, ":foreign key == attribute didn't lock up" # ' - end - - def test_counter_cache - topic = Topic.create :title => "Zoom-zoom-zoom" - assert_equal 0, topic[:replies_count] - - reply = Reply.create(:title => "re: zoom", :content => "speedy quick!") - reply.topic = topic - - assert_equal 1, topic.reload[:replies_count] - assert_equal 1, topic.replies.size - - topic[:replies_count] = 15 - assert_equal 15, topic.replies.size - end - - def test_custom_counter_cache - reply = Reply.create(:title => "re: zoom", :content => "speedy quick!") - assert_equal 0, reply[:replies_count] - - silly = SillyReply.create(:title => "gaga", :content => "boo-boo") - silly.reply = reply - - assert_equal 1, reply.reload[:replies_count] - assert_equal 1, reply.replies.size - - reply[:replies_count] = 17 - assert_equal 17, reply.replies.size - end - - def test_association_assignment_sticks - post = Post.find(:first) - - author1, author2 = Author.find(:all, :limit => 2) - assert_not_nil author1 - assert_not_nil author2 - - # make sure the association is loaded - post.author - - # set the association by id, directly - post.author_id = author2.id - - # save and reload - post.save! - post.reload - - # the author id of the post should be the id we set - assert_equal post.author_id, author2.id - end - - def test_cant_save_readonly_association - assert_raise(ActiveRecord::ReadOnlyRecord) { companies(:first_client).readonly_firm.save! } - assert companies(:first_client).readonly_firm.readonly? - end - - def test_polymorphic_assignment_foreign_type_field_updating - # should update when assigning a saved record - sponsor = Sponsor.new - member = Member.create - sponsor.sponsorable = member - assert_equal "Member", sponsor.sponsorable_type - - # should update when assigning a new record - sponsor = Sponsor.new - member = Member.new - sponsor.sponsorable = member - assert_equal "Member", sponsor.sponsorable_type - end - - def test_polymorphic_assignment_updates_foreign_id_field_for_new_and_saved_records - sponsor = Sponsor.new - saved_member = Member.create - new_member = Member.new - - sponsor.sponsorable = saved_member - assert_equal saved_member.id, sponsor.sponsorable_id - - sponsor.sponsorable = new_member - assert_equal nil, sponsor.sponsorable_id - end - - def test_belongs_to_proxy_should_not_respond_to_private_methods - assert_raise(NoMethodError) { companies(:first_firm).private_method } - assert_raise(NoMethodError) { companies(:second_client).firm.private_method } - end - - def test_belongs_to_proxy_should_respond_to_private_methods_via_send - companies(:first_firm).send(:private_method) - companies(:second_client).firm.send(:private_method) - end - - def test_save_of_record_with_loaded_belongs_to - @account = companies(:first_firm).account - - assert_nothing_raised do - Account.find(@account.id).save! - Account.find(@account.id, :include => :firm).save! - end - - @account.firm.delete - - assert_nothing_raised do - Account.find(@account.id).save! - Account.find(@account.id, :include => :firm).save! - end - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/callbacks_test.rb b/vendor/rails/activerecord/test/cases/associations/callbacks_test.rb deleted file mode 100644 index 91b1af1..0000000 --- a/vendor/rails/activerecord/test/cases/associations/callbacks_test.rb +++ /dev/null @@ -1,161 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/comment' -require 'models/author' -require 'models/category' -require 'models/project' -require 'models/developer' - -class AssociationCallbacksTest < ActiveRecord::TestCase - fixtures :posts, :authors, :projects, :developers - - def setup - @david = authors(:david) - @thinking = posts(:thinking) - @authorless = posts(:authorless) - assert @david.post_log.empty? - end - - def test_adding_macro_callbacks - @david.posts_with_callbacks << @thinking - assert_equal ["before_adding#{@thinking.id}", "after_adding#{@thinking.id}"], @david.post_log - @david.posts_with_callbacks << @thinking - assert_equal ["before_adding#{@thinking.id}", "after_adding#{@thinking.id}", "before_adding#{@thinking.id}", - "after_adding#{@thinking.id}"], @david.post_log - end - - def test_adding_with_proc_callbacks - @david.posts_with_proc_callbacks << @thinking - assert_equal ["before_adding#{@thinking.id}", "after_adding#{@thinking.id}"], @david.post_log - @david.posts_with_proc_callbacks << @thinking - assert_equal ["before_adding#{@thinking.id}", "after_adding#{@thinking.id}", "before_adding#{@thinking.id}", - "after_adding#{@thinking.id}"], @david.post_log - end - - def test_removing_with_macro_callbacks - first_post, second_post = @david.posts_with_callbacks[0, 2] - @david.posts_with_callbacks.delete(first_post) - assert_equal ["before_removing#{first_post.id}", "after_removing#{first_post.id}"], @david.post_log - @david.posts_with_callbacks.delete(second_post) - assert_equal ["before_removing#{first_post.id}", "after_removing#{first_post.id}", "before_removing#{second_post.id}", - "after_removing#{second_post.id}"], @david.post_log - end - - def test_removing_with_proc_callbacks - first_post, second_post = @david.posts_with_callbacks[0, 2] - @david.posts_with_proc_callbacks.delete(first_post) - assert_equal ["before_removing#{first_post.id}", "after_removing#{first_post.id}"], @david.post_log - @david.posts_with_proc_callbacks.delete(second_post) - assert_equal ["before_removing#{first_post.id}", "after_removing#{first_post.id}", "before_removing#{second_post.id}", - "after_removing#{second_post.id}"], @david.post_log - end - - def test_multiple_callbacks - @david.posts_with_multiple_callbacks << @thinking - assert_equal ["before_adding#{@thinking.id}", "before_adding_proc#{@thinking.id}", "after_adding#{@thinking.id}", - "after_adding_proc#{@thinking.id}"], @david.post_log - @david.posts_with_multiple_callbacks << @thinking - assert_equal ["before_adding#{@thinking.id}", "before_adding_proc#{@thinking.id}", "after_adding#{@thinking.id}", - "after_adding_proc#{@thinking.id}", "before_adding#{@thinking.id}", "before_adding_proc#{@thinking.id}", - "after_adding#{@thinking.id}", "after_adding_proc#{@thinking.id}"], @david.post_log - end - - def test_has_many_callbacks_with_create - morten = Author.create :name => "Morten" - post = morten.posts_with_proc_callbacks.create! :title => "Hello", :body => "How are you doing?" - assert_equal ["before_adding<new>", "after_adding#{post.id}"], morten.post_log - end - - def test_has_many_callbacks_with_create! - morten = Author.create! :name => "Morten" - post = morten.posts_with_proc_callbacks.create :title => "Hello", :body => "How are you doing?" - assert_equal ["before_adding<new>", "after_adding#{post.id}"], morten.post_log - end - - def test_has_many_callbacks_for_save_on_parent - jack = Author.new :name => "Jack" - post = jack.posts_with_callbacks.build :title => "Call me back!", :body => "Before you wake up and after you sleep" - - callback_log = ["before_adding<new>", "after_adding#{jack.posts_with_callbacks.first.id}"] - assert_equal callback_log, jack.post_log - assert jack.save - assert_equal 1, jack.posts_with_callbacks.count - assert_equal callback_log, jack.post_log - end - - def test_has_and_belongs_to_many_add_callback - david = developers(:david) - ar = projects(:active_record) - assert ar.developers_log.empty? - ar.developers_with_callbacks << david - assert_equal ["before_adding#{david.id}", "after_adding#{david.id}"], ar.developers_log - ar.developers_with_callbacks << david - assert_equal ["before_adding#{david.id}", "after_adding#{david.id}", "before_adding#{david.id}", - "after_adding#{david.id}"], ar.developers_log - end - - def test_has_and_belongs_to_many_after_add_called_after_save - ar = projects(:active_record) - assert ar.developers_log.empty? - alice = Developer.new(:name => 'alice') - ar.developers_with_callbacks << alice - assert_equal"after_adding#{alice.id}", ar.developers_log.last - - bob = ar.developers_with_callbacks.create(:name => 'bob') - assert_equal "after_adding#{bob.id}", ar.developers_log.last - - ar.developers_with_callbacks.build(:name => 'charlie') - assert_equal "after_adding<new>", ar.developers_log.last - end - - - def test_has_and_belongs_to_many_remove_callback - david = developers(:david) - jamis = developers(:jamis) - activerecord = projects(:active_record) - assert activerecord.developers_log.empty? - activerecord.developers_with_callbacks.delete(david) - assert_equal ["before_removing#{david.id}", "after_removing#{david.id}"], activerecord.developers_log - - activerecord.developers_with_callbacks.delete(jamis) - assert_equal ["before_removing#{david.id}", "after_removing#{david.id}", "before_removing#{jamis.id}", - "after_removing#{jamis.id}"], activerecord.developers_log - end - - def test_has_and_belongs_to_many_remove_callback_on_clear - activerecord = projects(:active_record) - assert activerecord.developers_log.empty? - if activerecord.developers_with_callbacks.size == 0 - activerecord.developers << developers(:david) - activerecord.developers << developers(:jamis) - activerecord.reload - assert activerecord.developers_with_callbacks.size == 2 - end - log_array = activerecord.developers_with_callbacks.collect {|d| ["before_removing#{d.id}","after_removing#{d.id}"]}.flatten.sort - assert activerecord.developers_with_callbacks.clear - assert_equal log_array, activerecord.developers_log.sort - end - - def test_has_many_and_belongs_to_many_callbacks_for_save_on_parent - project = Project.new :name => "Callbacks" - project.developers_with_callbacks.build :name => "Jack", :salary => 95000 - - callback_log = ["before_adding<new>", "after_adding<new>"] - assert_equal callback_log, project.developers_log - assert project.save - assert_equal 1, project.developers_with_callbacks.size - assert_equal callback_log, project.developers_log - end - - def test_dont_add_if_before_callback_raises_exception - assert !@david.unchangable_posts.include?(@authorless) - begin - @david.unchangable_posts << @authorless - rescue Exception => e - end - assert @david.post_log.empty? - assert !@david.unchangable_posts.include?(@authorless) - @david.reload - assert !@david.unchangable_posts.include?(@authorless) - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/cascaded_eager_loading_test.rb b/vendor/rails/activerecord/test/cases/associations/cascaded_eager_loading_test.rb deleted file mode 100644 index 45e74ea..0000000 --- a/vendor/rails/activerecord/test/cases/associations/cascaded_eager_loading_test.rb +++ /dev/null @@ -1,131 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/comment' -require 'models/author' -require 'models/category' -require 'models/categorization' -require 'models/company' -require 'models/topic' -require 'models/reply' - -class CascadedEagerLoadingTest < ActiveRecord::TestCase - fixtures :authors, :mixins, :companies, :posts, :topics, :accounts, :comments, :categorizations - - def test_eager_association_loading_with_cascaded_two_levels - authors = Author.find(:all, :include=>{:posts=>:comments}, :order=>"authors.id") - assert_equal 2, authors.size - assert_equal 5, authors[0].posts.size - assert_equal 1, authors[1].posts.size - assert_equal 9, authors[0].posts.collect{|post| post.comments.size }.inject(0){|sum,i| sum+i} - end - - def test_eager_association_loading_with_cascaded_two_levels_and_one_level - authors = Author.find(:all, :include=>[{:posts=>:comments}, :categorizations], :order=>"authors.id") - assert_equal 2, authors.size - assert_equal 5, authors[0].posts.size - assert_equal 1, authors[1].posts.size - assert_equal 9, authors[0].posts.collect{|post| post.comments.size }.inject(0){|sum,i| sum+i} - assert_equal 1, authors[0].categorizations.size - assert_equal 2, authors[1].categorizations.size - end - - def test_eager_association_loading_with_cascaded_two_levels_with_two_has_many_associations - authors = Author.find(:all, :include=>{:posts=>[:comments, :categorizations]}, :order=>"authors.id") - assert_equal 2, authors.size - assert_equal 5, authors[0].posts.size - assert_equal 1, authors[1].posts.size - assert_equal 9, authors[0].posts.collect{|post| post.comments.size }.inject(0){|sum,i| sum+i} - end - - def test_eager_association_loading_with_cascaded_two_levels_and_self_table_reference - authors = Author.find(:all, :include=>{:posts=>[:comments, :author]}, :order=>"authors.id") - assert_equal 2, authors.size - assert_equal 5, authors[0].posts.size - assert_equal authors(:david).name, authors[0].name - assert_equal [authors(:david).name], authors[0].posts.collect{|post| post.author.name}.uniq - end - - def test_eager_association_loading_with_cascaded_two_levels_with_condition - authors = Author.find(:all, :include=>{:posts=>:comments}, :conditions=>"authors.id=1", :order=>"authors.id") - assert_equal 1, authors.size - assert_equal 5, authors[0].posts.size - end - - def test_eager_association_loading_with_cascaded_three_levels_by_ping_pong - firms = Firm.find(:all, :include=>{:account=>{:firm=>:account}}, :order=>"companies.id") - assert_equal 2, firms.size - assert_equal firms.first.account, firms.first.account.firm.account - assert_equal companies(:first_firm).account, assert_no_queries { firms.first.account.firm.account } - assert_equal companies(:first_firm).account.firm.account, assert_no_queries { firms.first.account.firm.account } - end - - def test_eager_association_loading_with_has_many_sti - topics = Topic.find(:all, :include => :replies, :order => 'topics.id') - first, second, = topics(:first).replies.size, topics(:second).replies.size - assert_no_queries do - assert_equal first, topics[0].replies.size - assert_equal second, topics[1].replies.size - end - end - - def test_eager_association_loading_with_has_many_sti_and_subclasses - silly = SillyReply.new(:title => "gaga", :content => "boo-boo", :parent_id => 1) - silly.parent_id = 1 - assert silly.save - - topics = Topic.find(:all, :include => :replies, :order => 'topics.id, replies_topics.id') - assert_no_queries do - assert_equal 2, topics[0].replies.size - assert_equal 0, topics[1].replies.size - end - end - - def test_eager_association_loading_with_belongs_to_sti - replies = Reply.find(:all, :include => :topic, :order => 'topics.id') - assert replies.include?(topics(:second)) - assert !replies.include?(topics(:first)) - assert_equal topics(:first), assert_no_queries { replies.first.topic } - end - - def test_eager_association_loading_with_multiple_stis_and_order - author = Author.find(:first, :include => { :posts => [ :special_comments , :very_special_comment ] }, :order => 'authors.name, comments.body, very_special_comments_posts.body', :conditions => 'posts.id = 4') - assert_equal authors(:david), author - assert_no_queries do - author.posts.first.special_comments - author.posts.first.very_special_comment - end - end - - def test_eager_association_loading_of_stis_with_multiple_references - authors = Author.find(:all, :include => { :posts => { :special_comments => { :post => [ :special_comments, :very_special_comment ] } } }, :order => 'comments.body, very_special_comments_posts.body', :conditions => 'posts.id = 4') - assert_equal [authors(:david)], authors - assert_no_queries do - authors.first.posts.first.special_comments.first.post.special_comments - authors.first.posts.first.special_comments.first.post.very_special_comment - end - end - - def test_eager_association_loading_where_first_level_returns_nil - authors = Author.find(:all, :include => {:post_about_thinking => :comments}, :order => 'authors.id DESC') - assert_equal [authors(:mary), authors(:david)], authors - assert_no_queries do - authors[1].post_about_thinking.comments.first - end - end -end - -require 'models/vertex' -require 'models/edge' -class CascadedEagerLoadingTest < ActiveRecord::TestCase - fixtures :edges, :vertices - - def test_eager_association_loading_with_recursive_cascading_four_levels_has_many_through - source = Vertex.find(:first, :include=>{:sinks=>{:sinks=>{:sinks=>:sinks}}}, :order => 'vertices.id') - assert_equal vertices(:vertex_4), assert_no_queries { source.sinks.first.sinks.first.sinks.first } - end - - def test_eager_association_loading_with_recursive_cascading_four_levels_has_and_belongs_to_many - sink = Vertex.find(:first, :include=>{:sources=>{:sources=>{:sources=>:sources}}}, :order => 'vertices.id DESC') - assert_equal vertices(:vertex_1), assert_no_queries { sink.sources.first.sources.first.sources.first.sources.first } - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb b/vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb deleted file mode 100644 index 7c47061..0000000 --- a/vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'cases/helper' -require 'models/post' -require 'models/tagging' - -module Namespaced - class Post < ActiveRecord::Base - set_table_name 'posts' - has_one :tagging, :as => :taggable, :class_name => 'Tagging' - end -end - -class EagerLoadIncludeFullStiClassNamesTest < ActiveRecord::TestCase - - def setup - generate_test_objects - end - - def generate_test_objects - post = Namespaced::Post.create( :title => 'Great stuff', :body => 'This is not', :author_id => 1 ) - tagging = Tagging.create( :taggable => post ) - end - - def test_class_names - old = ActiveRecord::Base.store_full_sti_class - - ActiveRecord::Base.store_full_sti_class = false - post = Namespaced::Post.find_by_title( 'Great stuff', :include => :tagging ) - assert_nil post.tagging - - ActiveRecord::Base.store_full_sti_class = true - post = Namespaced::Post.find_by_title( 'Great stuff', :include => :tagging ) - assert_equal 'Tagging', post.tagging.class.name - ensure - ActiveRecord::Base.store_full_sti_class = old - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/eager_load_nested_include_test.rb b/vendor/rails/activerecord/test/cases/associations/eager_load_nested_include_test.rb deleted file mode 100644 index 1b2e0fc..0000000 --- a/vendor/rails/activerecord/test/cases/associations/eager_load_nested_include_test.rb +++ /dev/null @@ -1,130 +0,0 @@ -require 'cases/helper' -require 'models/author' -require 'models/post' -require 'models/comment' -require 'models/category' -require 'models/categorization' - -module Remembered - def self.included(base) - base.extend ClassMethods - base.class_eval do - after_create :remember - protected - def remember; self.class.remembered << self; end - end - end - - module ClassMethods - def remembered; @@remembered ||= []; end - def rand; @@remembered.rand; end - end -end - -class ShapeExpression < ActiveRecord::Base - belongs_to :shape, :polymorphic => true - belongs_to :paint, :polymorphic => true -end - -class Circle < ActiveRecord::Base - has_many :shape_expressions, :as => :shape - include Remembered -end -class Square < ActiveRecord::Base - has_many :shape_expressions, :as => :shape - include Remembered -end -class Triangle < ActiveRecord::Base - has_many :shape_expressions, :as => :shape - include Remembered -end -class PaintColor < ActiveRecord::Base - has_many :shape_expressions, :as => :paint - belongs_to :non_poly, :foreign_key => "non_poly_one_id", :class_name => "NonPolyOne" - include Remembered -end -class PaintTexture < ActiveRecord::Base - has_many :shape_expressions, :as => :paint - belongs_to :non_poly, :foreign_key => "non_poly_two_id", :class_name => "NonPolyTwo" - include Remembered -end -class NonPolyOne < ActiveRecord::Base - has_many :paint_colors - include Remembered -end -class NonPolyTwo < ActiveRecord::Base - has_many :paint_textures - include Remembered -end - - - -class EagerLoadPolyAssocsTest < ActiveRecord::TestCase - NUM_SIMPLE_OBJS = 50 - NUM_SHAPE_EXPRESSIONS = 100 - - def setup - generate_test_object_graphs - end - - def teardown - [Circle, Square, Triangle, PaintColor, PaintTexture, - ShapeExpression, NonPolyOne, NonPolyTwo].each do |c| - c.delete_all - end - - end - - - def generate_test_object_graphs - 1.upto(NUM_SIMPLE_OBJS) do - [Circle, Square, Triangle, NonPolyOne, NonPolyTwo].map(&:create!) - end - 1.upto(NUM_SIMPLE_OBJS) do - PaintColor.create!(:non_poly_one_id => NonPolyOne.rand.id) - PaintTexture.create!(:non_poly_two_id => NonPolyTwo.rand.id) - end - 1.upto(NUM_SHAPE_EXPRESSIONS) do - shape_type = [Circle, Square, Triangle].rand - paint_type = [PaintColor, PaintTexture].rand - ShapeExpression.create!(:shape_type => shape_type.to_s, :shape_id => shape_type.rand.id, - :paint_type => paint_type.to_s, :paint_id => paint_type.rand.id) - end - end - - def test_include_query - res = 0 - res = ShapeExpression.find :all, :include => [ :shape, { :paint => :non_poly } ] - assert_equal NUM_SHAPE_EXPRESSIONS, res.size - assert_queries(0) do - res.each do |se| - assert_not_nil se.paint.non_poly, "this is the association that was loading incorrectly before the change" - assert_not_nil se.shape, "just making sure other associations still work" - end - end - end -end - -class EagerLoadNestedIncludeWithMissingDataTest < ActiveRecord::TestCase - def setup - @davey_mcdave = Author.create(:name => 'Davey McDave') - @first_post = @davey_mcdave.posts.create(:title => 'Davey Speaks', :body => 'Expressive wordage') - @first_comment = @first_post.comments.create(:body => 'Inflamatory doublespeak') - @first_categorization = @davey_mcdave.categorizations.create(:category => Category.first, :post => @first_post) - end - - def teardown - @davey_mcdave.destroy - @first_post.destroy - @first_comment.destroy - @first_categorization.destroy - end - - def test_missing_data_in_a_nested_include_should_not_cause_errors_when_constructing_objects - assert_nothing_raised do - # @davey_mcdave doesn't have any author_favorites - includes = {:posts => :comments, :categorizations => :category, :author_favorites => :favorite_author } - Author.all :include => includes, :conditions => {:authors => {:name => @davey_mcdave.name}}, :order => 'categories.name' - end - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/cases/associations/eager_singularization_test.rb b/vendor/rails/activerecord/test/cases/associations/eager_singularization_test.rb deleted file mode 100644 index 07d0b24..0000000 --- a/vendor/rails/activerecord/test/cases/associations/eager_singularization_test.rb +++ /dev/null @@ -1,145 +0,0 @@ -require "cases/helper" - -class Virus < ActiveRecord::Base - belongs_to :octopus -end -class Octopus < ActiveRecord::Base - has_one :virus -end -class Pass < ActiveRecord::Base - belongs_to :bus -end -class Bus < ActiveRecord::Base - has_many :passes -end -class Mess < ActiveRecord::Base - has_and_belongs_to_many :crises -end -class Crisis < ActiveRecord::Base - has_and_belongs_to_many :messes - has_many :analyses, :dependent => :destroy - has_many :successes, :through => :analyses - has_many :dresses, :dependent => :destroy - has_many :compresses, :through => :dresses -end -class Analysis < ActiveRecord::Base - belongs_to :crisis - belongs_to :success -end -class Success < ActiveRecord::Base - has_many :analyses, :dependent => :destroy - has_many :crises, :through => :analyses -end -class Dress < ActiveRecord::Base - belongs_to :crisis - has_many :compresses -end -class Compress < ActiveRecord::Base - belongs_to :dress -end - - -class EagerSingularizationTest < ActiveRecord::TestCase - - def setup - if ActiveRecord::Base.connection.supports_migrations? - ActiveRecord::Base.connection.create_table :viri do |t| - t.column :octopus_id, :integer - t.column :species, :string - end - ActiveRecord::Base.connection.create_table :octopi do |t| - t.column :species, :string - end - ActiveRecord::Base.connection.create_table :passes do |t| - t.column :bus_id, :integer - t.column :rides, :integer - end - ActiveRecord::Base.connection.create_table :buses do |t| - t.column :name, :string - end - ActiveRecord::Base.connection.create_table :crises_messes, :id => false do |t| - t.column :crisis_id, :integer - t.column :mess_id, :integer - end - ActiveRecord::Base.connection.create_table :messes do |t| - t.column :name, :string - end - ActiveRecord::Base.connection.create_table :crises do |t| - t.column :name, :string - end - ActiveRecord::Base.connection.create_table :successes do |t| - t.column :name, :string - end - ActiveRecord::Base.connection.create_table :analyses do |t| - t.column :crisis_id, :integer - t.column :success_id, :integer - end - ActiveRecord::Base.connection.create_table :dresses do |t| - t.column :crisis_id, :integer - end - ActiveRecord::Base.connection.create_table :compresses do |t| - t.column :dress_id, :integer - end - @have_tables = true - else - @have_tables = false - end - end - - def teardown - ActiveRecord::Base.connection.drop_table :viri - ActiveRecord::Base.connection.drop_table :octopi - ActiveRecord::Base.connection.drop_table :passes - ActiveRecord::Base.connection.drop_table :buses - ActiveRecord::Base.connection.drop_table :crises_messes - ActiveRecord::Base.connection.drop_table :messes - ActiveRecord::Base.connection.drop_table :crises - ActiveRecord::Base.connection.drop_table :successes - ActiveRecord::Base.connection.drop_table :analyses - ActiveRecord::Base.connection.drop_table :dresses - ActiveRecord::Base.connection.drop_table :compresses - end - - def test_eager_no_extra_singularization_belongs_to - return unless @have_tables - assert_nothing_raised do - Virus.find(:all, :include => :octopus) - end - end - - def test_eager_no_extra_singularization_has_one - return unless @have_tables - assert_nothing_raised do - Octopus.find(:all, :include => :virus) - end - end - - def test_eager_no_extra_singularization_has_many - return unless @have_tables - assert_nothing_raised do - Bus.find(:all, :include => :passes) - end - end - - def test_eager_no_extra_singularization_has_and_belongs_to_many - return unless @have_tables - assert_nothing_raised do - Crisis.find(:all, :include => :messes) - Mess.find(:all, :include => :crises) - end - end - - def test_eager_no_extra_singularization_has_many_through_belongs_to - return unless @have_tables - assert_nothing_raised do - Crisis.find(:all, :include => :successes) - end - end - - def test_eager_no_extra_singularization_has_many_through_has_many - return unless @have_tables - assert_nothing_raised do - Crisis.find(:all, :include => :compresses) - end - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/eager_test.rb b/vendor/rails/activerecord/test/cases/associations/eager_test.rb deleted file mode 100644 index 4072381..0000000 --- a/vendor/rails/activerecord/test/cases/associations/eager_test.rb +++ /dev/null @@ -1,822 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/tagging' -require 'models/tag' -require 'models/comment' -require 'models/author' -require 'models/category' -require 'models/company' -require 'models/person' -require 'models/reader' -require 'models/owner' -require 'models/pet' -require 'models/reference' -require 'models/job' -require 'models/subscriber' -require 'models/subscription' -require 'models/book' -require 'models/developer' -require 'models/project' - -class EagerAssociationTest < ActiveRecord::TestCase - fixtures :posts, :comments, :authors, :author_addresses, :categories, :categories_posts, - :companies, :accounts, :tags, :taggings, :people, :readers, - :owners, :pets, :author_favorites, :jobs, :references, :subscribers, :subscriptions, :books, - :developers, :projects, :developers_projects - - def test_loading_with_one_association - posts = Post.find(:all, :include => :comments) - post = posts.find { |p| p.id == 1 } - assert_equal 2, post.comments.size - assert post.comments.include?(comments(:greetings)) - - post = Post.find(:first, :include => :comments, :conditions => "posts.title = 'Welcome to the weblog'") - assert_equal 2, post.comments.size - assert post.comments.include?(comments(:greetings)) - - posts = Post.find(:all, :include => :last_comment) - post = posts.find { |p| p.id == 1 } - assert_equal Post.find(1).last_comment, post.last_comment - end - - def test_loading_with_one_association_with_non_preload - posts = Post.find(:all, :include => :last_comment, :order => 'comments.id DESC') - post = posts.find { |p| p.id == 1 } - assert_equal Post.find(1).last_comment, post.last_comment - end - - def test_loading_conditions_with_or - posts = authors(:david).posts.find(:all, :include => :comments, :conditions => "comments.body like 'Normal%' OR comments.#{QUOTED_TYPE} = 'SpecialComment'") - assert_nil posts.detect { |p| p.author_id != authors(:david).id }, - "expected to find only david's posts" - end - - def test_with_ordering - list = Post.find(:all, :include => :comments, :order => "posts.id DESC") - [:eager_other, :sti_habtm, :sti_post_and_comments, :sti_comments, - :authorless, :thinking, :welcome - ].each_with_index do |post, index| - assert_equal posts(post), list[index] - end - end - - def test_with_two_tables_in_from_without_getting_double_quoted - posts = Post.find(:all, - :select => "posts.*", - :from => "authors, posts", - :include => :comments, - :conditions => "posts.author_id = authors.id", - :order => "posts.id" - ) - - assert_equal 2, posts.first.comments.size - end - - def test_loading_with_multiple_associations - posts = Post.find(:all, :include => [ :comments, :author, :categories ], :order => "posts.id") - assert_equal 2, posts.first.comments.size - assert_equal 2, posts.first.categories.size - assert posts.first.comments.include?(comments(:greetings)) - end - - def test_duplicate_middle_objects - comments = Comment.find :all, :conditions => 'post_id = 1', :include => [:post => :author] - assert_no_queries do - comments.each {|comment| comment.post.author.name} - end - end - - def test_including_duplicate_objects_from_belongs_to - popular_post = Post.create!(:title => 'foo', :body => "I like cars!") - comment = popular_post.comments.create!(:body => "lol") - popular_post.readers.create!(:person => people(:michael)) - popular_post.readers.create!(:person => people(:david)) - - readers = Reader.find(:all, :conditions => ["post_id = ?", popular_post.id], - :include => {:post => :comments}) - readers.each do |reader| - assert_equal [comment], reader.post.comments - end - end - - def test_including_duplicate_objects_from_has_many - car_post = Post.create!(:title => 'foo', :body => "I like cars!") - car_post.categories << categories(:general) - car_post.categories << categories(:technology) - - comment = car_post.comments.create!(:body => "hmm") - categories = Category.find(:all, :conditions => ["posts.id=?", car_post.id], - :include => {:posts => :comments}) - categories.each do |category| - assert_equal [comment], category.posts[0].comments - end - end - - def test_finding_with_includes_on_has_many_association_with_same_include_includes_only_once - author_id = authors(:david).id - author = assert_queries(3) { Author.find(author_id, :include => {:posts_with_comments => :comments}) } # find the author, then find the posts, then find the comments - author.posts_with_comments.each do |post_with_comments| - assert_equal post_with_comments.comments.length, post_with_comments.comments.count - assert_equal nil, post_with_comments.comments.uniq! - end - end - - def test_finding_with_includes_on_has_one_assocation_with_same_include_includes_only_once - author = authors(:david) - post = author.post_about_thinking_with_last_comment - last_comment = post.last_comment - author = assert_queries(3) { Author.find(author.id, :include => {:post_about_thinking_with_last_comment => :last_comment})} # find the author, then find the posts, then find the comments - assert_no_queries do - assert_equal post, author.post_about_thinking_with_last_comment - assert_equal last_comment, author.post_about_thinking_with_last_comment.last_comment - end - end - - def test_finding_with_includes_on_belongs_to_association_with_same_include_includes_only_once - post = posts(:welcome) - author = post.author - author_address = author.author_address - post = assert_queries(3) { Post.find(post.id, :include => {:author_with_address => :author_address}) } # find the post, then find the author, then find the address - assert_no_queries do - assert_equal author, post.author_with_address - assert_equal author_address, post.author_with_address.author_address - end - end - - def test_finding_with_includes_on_null_belongs_to_association_with_same_include_includes_only_once - post = posts(:welcome) - post.update_attributes!(:author => nil) - post = assert_queries(1) { Post.find(post.id, :include => {:author_with_address => :author_address}) } # find the post, then find the author which is null so no query for the author or address - assert_no_queries do - assert_equal nil, post.author_with_address - end - end - - def test_loading_from_an_association - posts = authors(:david).posts.find(:all, :include => :comments, :order => "posts.id") - assert_equal 2, posts.first.comments.size - end - - def test_loading_from_an_association_that_has_a_hash_of_conditions - assert_nothing_raised do - Author.find(:all, :include => :hello_posts_with_hash_conditions) - end - assert !Author.find(authors(:david).id, :include => :hello_posts_with_hash_conditions).hello_posts.empty? - end - - def test_loading_with_no_associations - assert_nil Post.find(posts(:authorless).id, :include => :author).author - end - - def test_nested_loading_with_no_associations - assert_nothing_raised do - Post.find(posts(:authorless).id, :include => {:author => :author_addresss}) - end - end - - def test_eager_association_loading_with_belongs_to_and_foreign_keys - pets = Pet.find(:all, :include => :owner) - assert_equal 3, pets.length - end - - def test_eager_association_loading_with_belongs_to - comments = Comment.find(:all, :include => :post) - assert_equal 10, comments.length - titles = comments.map { |c| c.post.title } - assert titles.include?(posts(:welcome).title) - assert titles.include?(posts(:sti_post_and_comments).title) - end - - def test_eager_association_loading_with_belongs_to_and_limit - comments = Comment.find(:all, :include => :post, :limit => 5, :order => 'comments.id') - assert_equal 5, comments.length - assert_equal [1,2,3,5,6], comments.collect { |c| c.id } - end - - def test_eager_association_loading_with_belongs_to_and_limit_and_conditions - comments = Comment.find(:all, :include => :post, :conditions => 'post_id = 4', :limit => 3, :order => 'comments.id') - assert_equal 3, comments.length - assert_equal [5,6,7], comments.collect { |c| c.id } - end - - def test_eager_association_loading_with_belongs_to_and_limit_and_offset - comments = Comment.find(:all, :include => :post, :limit => 3, :offset => 2, :order => 'comments.id') - assert_equal 3, comments.length - assert_equal [3,5,6], comments.collect { |c| c.id } - end - - def test_eager_association_loading_with_belongs_to_and_limit_and_offset_and_conditions - comments = Comment.find(:all, :include => :post, :conditions => 'post_id = 4', :limit => 3, :offset => 1, :order => 'comments.id') - assert_equal 3, comments.length - assert_equal [6,7,8], comments.collect { |c| c.id } - end - - def test_eager_association_loading_with_belongs_to_and_limit_and_offset_and_conditions_array - comments = Comment.find(:all, :include => :post, :conditions => ['post_id = ?',4], :limit => 3, :offset => 1, :order => 'comments.id') - assert_equal 3, comments.length - assert_equal [6,7,8], comments.collect { |c| c.id } - end - - def test_eager_association_loading_with_belongs_to_and_conditions_string_with_unquoted_table_name - assert_nothing_raised do - Comment.find(:all, :include => :post, :conditions => ['posts.id = ?',4]) - end - end - - def test_eager_association_loading_with_belongs_to_and_conditions_string_with_quoted_table_name - quoted_posts_id= Comment.connection.quote_table_name('posts') + '.' + Comment.connection.quote_column_name('id') - assert_nothing_raised do - Comment.find(:all, :include => :post, :conditions => ["#{quoted_posts_id} = ?",4]) - end - end - - def test_eager_association_loading_with_belongs_to_and_order_string_with_unquoted_table_name - assert_nothing_raised do - Comment.find(:all, :include => :post, :order => 'posts.id') - end - end - - def test_eager_association_loading_with_belongs_to_and_order_string_with_quoted_table_name - quoted_posts_id= Comment.connection.quote_table_name('posts') + '.' + Comment.connection.quote_column_name('id') - assert_nothing_raised do - Comment.find(:all, :include => :post, :order => quoted_posts_id) - end - end - - def test_eager_association_loading_with_belongs_to_and_limit_and_multiple_associations - posts = Post.find(:all, :include => [:author, :very_special_comment], :limit => 1, :order => 'posts.id') - assert_equal 1, posts.length - assert_equal [1], posts.collect { |p| p.id } - end - - def test_eager_association_loading_with_belongs_to_and_limit_and_offset_and_multiple_associations - posts = Post.find(:all, :include => [:author, :very_special_comment], :limit => 1, :offset => 1, :order => 'posts.id') - assert_equal 1, posts.length - assert_equal [2], posts.collect { |p| p.id } - end - - def test_eager_association_loading_with_belongs_to_inferred_foreign_key_from_association_name - author_favorite = AuthorFavorite.find(:first, :include => :favorite_author) - assert_equal authors(:mary), assert_no_queries { author_favorite.favorite_author } - end - - def test_eager_load_belongs_to_quotes_table_and_column_names - job = Job.find jobs(:unicyclist).id, :include => :ideal_reference - references(:michael_unicyclist) - assert_no_queries{ assert_equal references(:michael_unicyclist), job.ideal_reference} - end - - def test_eager_load_has_one_quotes_table_and_column_names - michael = Person.find(people(:michael), :include => :favourite_reference) - references(:michael_unicyclist) - assert_no_queries{ assert_equal references(:michael_unicyclist), michael.favourite_reference} - end - - def test_eager_load_has_many_quotes_table_and_column_names - michael = Person.find(people(:michael), :include => :references) - references(:michael_magician,:michael_unicyclist) - assert_no_queries{ assert_equal references(:michael_magician,:michael_unicyclist), michael.references.sort_by(&:id) } - end - - def test_eager_load_has_many_through_quotes_table_and_column_names - michael = Person.find(people(:michael), :include => :jobs) - jobs(:magician, :unicyclist) - assert_no_queries{ assert_equal jobs(:unicyclist, :magician), michael.jobs.sort_by(&:id) } - end - - def test_eager_load_has_many_with_string_keys - subscriptions = subscriptions(:webster_awdr, :webster_rfr) - subscriber =Subscriber.find(subscribers(:second).id, :include => :subscriptions) - assert_equal subscriptions, subscriber.subscriptions.sort_by(&:id) - end - - def test_eager_load_has_many_through_with_string_keys - books = books(:awdr, :rfr) - subscriber = Subscriber.find(subscribers(:second).id, :include => :books) - assert_equal books, subscriber.books.sort_by(&:id) - end - - def test_eager_load_belongs_to_with_string_keys - subscriber = subscribers(:second) - subscription = Subscription.find(subscriptions(:webster_awdr).id, :include => :subscriber) - assert_equal subscriber, subscription.subscriber - end - - def test_eager_association_loading_with_explicit_join - posts = Post.find(:all, :include => :comments, :joins => "INNER JOIN authors ON posts.author_id = authors.id AND authors.name = 'Mary'", :limit => 1, :order => 'author_id') - assert_equal 1, posts.length - end - - def test_eager_with_has_many_through - posts_with_comments = people(:michael).posts.find(:all, :include => :comments, :order => 'posts.id') - posts_with_author = people(:michael).posts.find(:all, :include => :author, :order => 'posts.id') - posts_with_comments_and_author = people(:michael).posts.find(:all, :include => [ :comments, :author ], :order => 'posts.id') - assert_equal 2, posts_with_comments.inject(0) { |sum, post| sum += post.comments.size } - assert_equal authors(:david), assert_no_queries { posts_with_author.first.author } - assert_equal authors(:david), assert_no_queries { posts_with_comments_and_author.first.author } - end - - def test_eager_with_has_many_through_a_belongs_to_association - author = authors(:mary) - post = Post.create!(:author => author, :title => "TITLE", :body => "BODY") - author.author_favorites.create(:favorite_author_id => 1) - author.author_favorites.create(:favorite_author_id => 2) - posts_with_author_favorites = author.posts.find(:all, :include => :author_favorites) - assert_no_queries { posts_with_author_favorites.first.author_favorites.first.author_id } - end - - def test_eager_with_has_many_through_an_sti_join_model - author = Author.find(:first, :include => :special_post_comments, :order => 'authors.id') - assert_equal [comments(:does_it_hurt)], assert_no_queries { author.special_post_comments } - end - - def test_eager_with_has_many_through_an_sti_join_model_with_conditions_on_both - author = Author.find(:first, :include => :special_nonexistant_post_comments, :order => 'authors.id') - assert_equal [], author.special_nonexistant_post_comments - end - - def test_eager_with_has_many_through_join_model_with_conditions - assert_equal Author.find(:first, :include => :hello_post_comments, - :order => 'authors.id').hello_post_comments.sort_by(&:id), - Author.find(:first, :order => 'authors.id').hello_post_comments.sort_by(&:id) - end - - def test_eager_with_has_many_through_join_model_with_conditions_on_top_level - assert_equal comments(:more_greetings), Author.find(authors(:david).id, :include => :comments_with_order_and_conditions).comments_with_order_and_conditions.first - end - - def test_eager_with_has_many_through_join_model_with_include - author_comments = Author.find(authors(:david).id, :include => :comments_with_include).comments_with_include.to_a - assert_no_queries do - author_comments.first.post.title - end - end - - def test_eager_with_has_many_and_limit - posts = Post.find(:all, :order => 'posts.id asc', :include => [ :author, :comments ], :limit => 2) - assert_equal 2, posts.size - assert_equal 3, posts.inject(0) { |sum, post| sum += post.comments.size } - end - - def test_eager_with_has_many_and_limit_and_conditions - if current_adapter?(:OpenBaseAdapter) - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => "FETCHBLOB(posts.body) = 'hello'", :order => "posts.id") - else - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => "posts.body = 'hello'", :order => "posts.id") - end - assert_equal 2, posts.size - assert_equal [4,5], posts.collect { |p| p.id } - end - - def test_eager_with_has_many_and_limit_and_conditions_array - if current_adapter?(:OpenBaseAdapter) - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => [ "FETCHBLOB(posts.body) = ?", 'hello' ], :order => "posts.id") - else - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => [ "posts.body = ?", 'hello' ], :order => "posts.id") - end - assert_equal 2, posts.size - assert_equal [4,5], posts.collect { |p| p.id } - end - - def test_eager_with_has_many_and_limit_and_conditions_array_on_the_eagers - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => [ "authors.name = ?", 'David' ]) - assert_equal 2, posts.size - - count = Post.count(:include => [ :author, :comments ], :limit => 2, :conditions => [ "authors.name = ?", 'David' ]) - assert_equal count, posts.size - end - - def test_eager_with_has_many_and_limit_and_high_offset - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, :conditions => [ "authors.name = ?", 'David' ]) - assert_equal 0, posts.size - end - - def test_eager_with_has_many_and_limit_and_high_offset_and_multiple_array_conditions - assert_queries(1) do - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, - :conditions => [ "authors.name = ? and comments.body = ?", 'David', 'go crazy' ]) - assert_equal 0, posts.size - end - end - - def test_eager_with_has_many_and_limit_and_high_offset_and_multiple_hash_conditions - assert_queries(1) do - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, - :conditions => { 'authors.name' => 'David', 'comments.body' => 'go crazy' }) - assert_equal 0, posts.size - end - end - - def test_count_eager_with_has_many_and_limit_and_high_offset - posts = Post.count(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, :conditions => [ "authors.name = ?", 'David' ]) - assert_equal 0, posts - end - - def test_eager_with_has_many_and_limit_with_no_results - posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => "posts.title = 'magic forest'") - assert_equal 0, posts.size - end - - def test_eager_count_performed_on_a_has_many_association_with_multi_table_conditional - author = authors(:david) - author_posts_without_comments = author.posts.select { |post| post.comments.blank? } - assert_equal author_posts_without_comments.size, author.posts.count(:all, :include => :comments, :conditions => 'comments.id is null') - end - - def test_eager_count_performed_on_a_has_many_through_association_with_multi_table_conditional - person = people(:michael) - person_posts_without_comments = person.posts.select { |post| post.comments.blank? } - assert_equal person_posts_without_comments.size, person.posts_with_no_comments.count - end - - def test_eager_with_has_and_belongs_to_many_and_limit - posts = Post.find(:all, :include => :categories, :order => "posts.id", :limit => 3) - assert_equal 3, posts.size - assert_equal 2, posts[0].categories.size - assert_equal 1, posts[1].categories.size - assert_equal 0, posts[2].categories.size - assert posts[0].categories.include?(categories(:technology)) - assert posts[1].categories.include?(categories(:general)) - end - - def test_eager_with_has_many_and_limit_and_conditions_on_the_eagers - posts = authors(:david).posts.find(:all, - :include => :comments, - :conditions => "comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment'", - :limit => 2 - ) - assert_equal 2, posts.size - - count = Post.count( - :include => [ :comments, :author ], - :conditions => "authors.name = 'David' AND (comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment')", - :limit => 2 - ) - assert_equal count, posts.size - end - - def test_eager_with_has_many_and_limit_and_scoped_conditions_on_the_eagers - posts = nil - Post.with_scope(:find => { - :include => :comments, - :conditions => "comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment'" - }) do - posts = authors(:david).posts.find(:all, :limit => 2) - assert_equal 2, posts.size - end - - Post.with_scope(:find => { - :include => [ :comments, :author ], - :conditions => "authors.name = 'David' AND (comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment')" - }) do - count = Post.count(:limit => 2) - assert_equal count, posts.size - end - end - - def test_eager_with_has_many_and_limit_and_scoped_and_explicit_conditions_on_the_eagers - Post.with_scope(:find => { :conditions => "1=1" }) do - posts = authors(:david).posts.find(:all, - :include => :comments, - :conditions => "comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment'", - :limit => 2 - ) - assert_equal 2, posts.size - - count = Post.count( - :include => [ :comments, :author ], - :conditions => "authors.name = 'David' AND (comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment')", - :limit => 2 - ) - assert_equal count, posts.size - end - end - - def test_eager_with_scoped_order_using_association_limiting_without_explicit_scope - posts_with_explicit_order = Post.find(:all, :conditions => 'comments.id is not null', :include => :comments, :order => 'posts.id DESC', :limit => 2) - posts_with_scoped_order = Post.with_scope(:find => {:order => 'posts.id DESC'}) do - Post.find(:all, :conditions => 'comments.id is not null', :include => :comments, :limit => 2) - end - assert_equal posts_with_explicit_order, posts_with_scoped_order - end - - def test_eager_association_loading_with_habtm - posts = Post.find(:all, :include => :categories, :order => "posts.id") - assert_equal 2, posts[0].categories.size - assert_equal 1, posts[1].categories.size - assert_equal 0, posts[2].categories.size - assert posts[0].categories.include?(categories(:technology)) - assert posts[1].categories.include?(categories(:general)) - end - - def test_eager_with_inheritance - posts = SpecialPost.find(:all, :include => [ :comments ]) - end - - def test_eager_has_one_with_association_inheritance - post = Post.find(4, :include => [ :very_special_comment ]) - assert_equal "VerySpecialComment", post.very_special_comment.class.to_s - end - - def test_eager_has_many_with_association_inheritance - post = Post.find(4, :include => [ :special_comments ]) - post.special_comments.each do |special_comment| - assert_equal "SpecialComment", special_comment.class.to_s - end - end - - def test_eager_habtm_with_association_inheritance - post = Post.find(6, :include => [ :special_categories ]) - assert_equal 1, post.special_categories.size - post.special_categories.each do |special_category| - assert_equal "SpecialCategory", special_category.class.to_s - end - end - - def test_eager_with_has_one_dependent_does_not_destroy_dependent - assert_not_nil companies(:first_firm).account - f = Firm.find(:first, :include => :account, - :conditions => ["companies.name = ?", "37signals"]) - assert_not_nil f.account - assert_equal companies(:first_firm, :reload).account, f.account - end - - def test_eager_with_multi_table_conditional_properly_counts_the_records_when_using_size - author = authors(:david) - posts_with_no_comments = author.posts.select { |post| post.comments.blank? } - assert_equal posts_with_no_comments.size, author.posts_with_no_comments.size - assert_equal posts_with_no_comments, author.posts_with_no_comments - end - - def test_eager_with_invalid_association_reference - assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") { - post = Post.find(6, :include=> :monkeys ) - } - assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") { - post = Post.find(6, :include=>[ :monkeys ]) - } - assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") { - post = Post.find(6, :include=>[ 'monkeys' ]) - } - assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys, :elephants") { - post = Post.find(6, :include=>[ :monkeys, :elephants ]) - } - end - - def find_all_ordered(className, include=nil) - className.find(:all, :order=>"#{className.table_name}.#{className.primary_key}", :include=>include) - end - - def test_limited_eager_with_order - assert_equal posts(:thinking, :sti_comments), Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title)', :limit => 2, :offset => 1) - assert_equal posts(:sti_post_and_comments, :sti_comments), Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title) DESC', :limit => 2, :offset => 1) - end - - def test_limited_eager_with_multiple_order_columns - assert_equal posts(:thinking, :sti_comments), Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title), posts.id', :limit => 2, :offset => 1) - assert_equal posts(:sti_post_and_comments, :sti_comments), Post.find(:all, :include => [:author, :comments], :conditions => "authors.name = 'David'", :order => 'UPPER(posts.title) DESC, posts.id', :limit => 2, :offset => 1) - end - - def test_preload_with_interpolation - assert_equal [comments(:greetings)], Post.find(posts(:welcome).id, :include => :comments_with_interpolated_conditions).comments_with_interpolated_conditions - end - - def test_polymorphic_type_condition - post = Post.find(posts(:thinking).id, :include => :taggings) - assert post.taggings.include?(taggings(:thinking_general)) - post = SpecialPost.find(posts(:thinking).id, :include => :taggings) - assert post.taggings.include?(taggings(:thinking_general)) - end - - def test_eager_with_multiple_associations_with_same_table_has_many_and_habtm - # Eager includes of has many and habtm associations aren't necessarily sorted in the same way - def assert_equal_after_sort(item1, item2, item3 = nil) - assert_equal(item1.sort{|a,b| a.id <=> b.id}, item2.sort{|a,b| a.id <=> b.id}) - assert_equal(item3.sort{|a,b| a.id <=> b.id}, item2.sort{|a,b| a.id <=> b.id}) if item3 - end - # Test regular association, association with conditions, association with - # STI, and association with conditions assured not to be true - post_types = [:posts, :other_posts, :special_posts] - # test both has_many and has_and_belongs_to_many - [Author, Category].each do |className| - d1 = find_all_ordered(className) - # test including all post types at once - d2 = find_all_ordered(className, post_types) - d1.each_index do |i| - assert_equal(d1[i], d2[i]) - assert_equal_after_sort(d1[i].posts, d2[i].posts) - post_types[1..-1].each do |post_type| - # test including post_types together - d3 = find_all_ordered(className, [:posts, post_type]) - assert_equal(d1[i], d3[i]) - assert_equal_after_sort(d1[i].posts, d3[i].posts) - assert_equal_after_sort(d1[i].send(post_type), d2[i].send(post_type), d3[i].send(post_type)) - end - end - end - end - - def test_eager_with_multiple_associations_with_same_table_has_one - d1 = find_all_ordered(Firm) - d2 = find_all_ordered(Firm, :account) - d1.each_index do |i| - assert_equal(d1[i], d2[i]) - assert_equal(d1[i].account, d2[i].account) - end - end - - def test_eager_with_multiple_associations_with_same_table_belongs_to - firm_types = [:firm, :firm_with_basic_id, :firm_with_other_name, :firm_with_condition] - d1 = find_all_ordered(Client) - d2 = find_all_ordered(Client, firm_types) - d1.each_index do |i| - assert_equal(d1[i], d2[i]) - firm_types.each { |type| assert_equal(d1[i].send(type), d2[i].send(type)) } - end - end - def test_eager_with_valid_association_as_string_not_symbol - assert_nothing_raised { Post.find(:all, :include => 'comments') } - end - - def test_eager_with_floating_point_numbers - assert_queries(2) do - # Before changes, the floating point numbers will be interpreted as table names and will cause this to run in one query - Comment.find :all, :conditions => "123.456 = 123.456", :include => :post - end - end - - def test_preconfigured_includes_with_belongs_to - author = posts(:welcome).author_with_posts - assert_no_queries {assert_equal 5, author.posts.size} - end - - def test_preconfigured_includes_with_has_one - comment = posts(:sti_comments).very_special_comment_with_post - assert_no_queries {assert_equal posts(:sti_comments), comment.post} - end - - def test_preconfigured_includes_with_has_many - posts = authors(:david).posts_with_comments - one = posts.detect { |p| p.id == 1 } - assert_no_queries do - assert_equal 5, posts.size - assert_equal 2, one.comments.size - end - end - - def test_preconfigured_includes_with_habtm - posts = authors(:david).posts_with_categories - one = posts.detect { |p| p.id == 1 } - assert_no_queries do - assert_equal 5, posts.size - assert_equal 2, one.categories.size - end - end - - def test_preconfigured_includes_with_has_many_and_habtm - posts = authors(:david).posts_with_comments_and_categories - one = posts.detect { |p| p.id == 1 } - assert_no_queries do - assert_equal 5, posts.size - assert_equal 2, one.comments.size - assert_equal 2, one.categories.size - end - end - - def test_count_with_include - if current_adapter?(:SybaseAdapter) - assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "len(comments.body) > 15") - elsif current_adapter?(:OpenBaseAdapter) - assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "length(FETCHBLOB(comments.body)) > 15") - else - assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "length(comments.body) > 15") - end - end - - def test_load_with_sti_sharing_association - assert_queries(2) do #should not do 1 query per subclass - Comment.find :all, :include => :post - end - end - - def test_conditions_on_join_table_with_include_and_limit - assert_equal 3, Developer.find(:all, :include => 'projects', :conditions => 'developers_projects.access_level = 1', :limit => 5).size - end - - def test_order_on_join_table_with_include_and_limit - assert_equal 5, Developer.find(:all, :include => 'projects', :order => 'developers_projects.joined_on DESC', :limit => 5).size - end - - def test_eager_loading_with_order_on_joined_table_preloads - posts = assert_queries(2) do - Post.find(:all, :joins => :comments, :include => :author, :order => 'comments.id DESC') - end - assert_equal posts(:eager_other), posts[0] - assert_equal authors(:mary), assert_no_queries { posts[0].author} - end - - def test_eager_loading_with_conditions_on_joined_table_preloads - posts = assert_queries(2) do - Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id') - end - assert_equal [posts(:welcome)], posts - assert_equal authors(:david), assert_no_queries { posts[0].author} - - posts = assert_queries(2) do - Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id') - end - assert_equal [posts(:welcome)], posts - assert_equal authors(:david), assert_no_queries { posts[0].author} - - posts = assert_queries(2) do - Post.find(:all, :include => :author, :joins => {:taggings => :tag}, :conditions => "tags.name = 'General'", :order => 'posts.id') - end - assert_equal posts(:welcome, :thinking), posts - - posts = assert_queries(2) do - Post.find(:all, :include => :author, :joins => {:taggings => {:tag => :taggings}}, :conditions => "taggings_tags.super_tag_id=2", :order => 'posts.id') - end - assert_equal posts(:welcome, :thinking), posts - - end - - def test_eager_loading_with_conditions_on_string_joined_table_preloads - posts = assert_queries(2) do - Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => "INNER JOIN comments on comments.post_id = posts.id", :conditions => "comments.body like 'Thank you%'", :order => 'posts.id') - end - assert_equal [posts(:welcome)], posts - assert_equal authors(:david), assert_no_queries { posts[0].author} - - posts = assert_queries(2) do - Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => ["INNER JOIN comments on comments.post_id = posts.id"], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id') - end - assert_equal [posts(:welcome)], posts - assert_equal authors(:david), assert_no_queries { posts[0].author} - - end - - def test_eager_loading_with_select_on_joined_table_preloads - posts = assert_queries(2) do - Post.find(:all, :select => 'posts.*, authors.name as author_name', :include => :comments, :joins => :author, :order => 'posts.id') - end - assert_equal 'David', posts[0].author_name - assert_equal posts(:welcome).comments, assert_no_queries { posts[0].comments} - end - - def test_eager_loading_with_conditions_on_join_model_preloads - authors = assert_queries(2) do - Author.find(:all, :include => :author_address, :joins => :comments, :conditions => "posts.title like 'Welcome%'") - end - assert_equal authors(:david), authors[0] - assert_equal author_addresses(:david_address), authors[0].author_address - end - - def test_preload_belongs_to_uses_exclusive_scope - people = Person.males.find(:all, :include => :primary_contact) - assert_not_equal people.length, 0 - people.each do |person| - assert_no_queries {assert_not_nil person.primary_contact} - assert_equal Person.find(person.id).primary_contact, person.primary_contact - end - end - - def test_preload_has_many_uses_exclusive_scope - people = Person.males.find :all, :include => :agents - people.each do |person| - assert_equal Person.find(person.id).agents, person.agents - end - end - - def test_preload_has_many_using_primary_key - expected = Firm.find(:first).clients_using_primary_key.to_a - firm = Firm.find :first, :include => :clients_using_primary_key - assert_no_queries do - assert_equal expected, firm.clients_using_primary_key - end - end - - def test_include_has_many_using_primary_key - expected = Firm.find(1).clients_using_primary_key.sort_by &:name - firm = Firm.find 1, :include => :clients_using_primary_key, :order => 'clients_using_primary_keys_companies.name' - assert_no_queries do - assert_equal expected, firm.clients_using_primary_key - end - end - - def test_preload_has_one_using_primary_key - expected = Firm.find(:first).account_using_primary_key - firm = Firm.find :first, :include => :account_using_primary_key - assert_no_queries do - assert_equal expected, firm.account_using_primary_key - end - end - - def test_include_has_one_using_primary_key - expected = Firm.find(1).account_using_primary_key - firm = Firm.find(:all, :include => :account_using_primary_key, :order => 'accounts.id').detect {|f| f.id == 1} - assert_no_queries do - assert_equal expected, firm.account_using_primary_key - end - end - -end diff --git a/vendor/rails/activerecord/test/cases/associations/extension_test.rb b/vendor/rails/activerecord/test/cases/associations/extension_test.rb deleted file mode 100644 index 9390633..0000000 --- a/vendor/rails/activerecord/test/cases/associations/extension_test.rb +++ /dev/null @@ -1,62 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/comment' -require 'models/project' -require 'models/developer' -require 'models/company_in_module' - -class AssociationsExtensionsTest < ActiveRecord::TestCase - fixtures :projects, :developers, :developers_projects, :comments, :posts - - def test_extension_on_has_many - assert_equal comments(:more_greetings), posts(:welcome).comments.find_most_recent - end - - def test_extension_on_habtm - assert_equal projects(:action_controller), developers(:david).projects.find_most_recent - end - - def test_named_extension_on_habtm - assert_equal projects(:action_controller), developers(:david).projects_extended_by_name.find_most_recent - end - - def test_named_two_extensions_on_habtm - assert_equal projects(:action_controller), developers(:david).projects_extended_by_name_twice.find_most_recent - assert_equal projects(:active_record), developers(:david).projects_extended_by_name_twice.find_least_recent - end - - def test_named_extension_and_block_on_habtm - assert_equal projects(:action_controller), developers(:david).projects_extended_by_name_and_block.find_most_recent - assert_equal projects(:active_record), developers(:david).projects_extended_by_name_and_block.find_least_recent - end - - def test_marshalling_extensions - david = developers(:david) - assert_equal projects(:action_controller), david.projects.find_most_recent - - david = Marshal.load(Marshal.dump(david)) - assert_equal projects(:action_controller), david.projects.find_most_recent - end - - def test_marshalling_named_extensions - david = developers(:david) - assert_equal projects(:action_controller), david.projects_extended_by_name.find_most_recent - - david = Marshal.load(Marshal.dump(david)) - assert_equal projects(:action_controller), david.projects_extended_by_name.find_most_recent - end - - - def test_extension_name - extension = Proc.new {} - name = :association_name - - assert_equal 'DeveloperAssociationNameAssociationExtension', Developer.send(:create_extension_modules, name, extension, []).first.name - assert_equal 'MyApplication::Business::DeveloperAssociationNameAssociationExtension', -MyApplication::Business::Developer.send(:create_extension_modules, name, extension, []).first.name - assert_equal 'MyApplication::Business::DeveloperAssociationNameAssociationExtension', MyApplication::Business::Developer.send(:create_extension_modules, name, extension, []).first.name - assert_equal 'MyApplication::Business::DeveloperAssociationNameAssociationExtension', MyApplication::Business::Developer.send(:create_extension_modules, name, extension, []).first.name - end - - -end diff --git a/vendor/rails/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/vendor/rails/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb deleted file mode 100644 index 5e8b2ca..0000000 --- a/vendor/rails/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ /dev/null @@ -1,822 +0,0 @@ -require "cases/helper" -require 'models/developer' -require 'models/project' -require 'models/company' -require 'models/topic' -require 'models/reply' -require 'models/computer' -require 'models/customer' -require 'models/order' -require 'models/categorization' -require 'models/category' -require 'models/post' -require 'models/author' -require 'models/comment' -require 'models/tag' -require 'models/tagging' -require 'models/person' -require 'models/reader' -require 'models/parrot' -require 'models/pirate' -require 'models/treasure' -require 'models/price_estimate' -require 'models/club' -require 'models/member' -require 'models/membership' -require 'models/sponsor' - -class ProjectWithAfterCreateHook < ActiveRecord::Base - set_table_name 'projects' - has_and_belongs_to_many :developers, - :class_name => "DeveloperForProjectWithAfterCreateHook", - :join_table => "developers_projects", - :foreign_key => "project_id", - :association_foreign_key => "developer_id" - - after_create :add_david - - def add_david - david = DeveloperForProjectWithAfterCreateHook.find_by_name('David') - david.projects << self - end -end - -class DeveloperForProjectWithAfterCreateHook < ActiveRecord::Base - set_table_name 'developers' - has_and_belongs_to_many :projects, - :class_name => "ProjectWithAfterCreateHook", - :join_table => "developers_projects", - :association_foreign_key => "project_id", - :foreign_key => "developer_id" -end - -class ProjectWithSymbolsForKeys < ActiveRecord::Base - set_table_name 'projects' - has_and_belongs_to_many :developers, - :class_name => "DeveloperWithSymbolsForKeys", - :join_table => :developers_projects, - :foreign_key => :project_id, - :association_foreign_key => "developer_id" -end - -class DeveloperWithSymbolsForKeys < ActiveRecord::Base - set_table_name 'developers' - has_and_belongs_to_many :projects, - :class_name => "ProjectWithSymbolsForKeys", - :join_table => :developers_projects, - :association_foreign_key => :project_id, - :foreign_key => "developer_id" -end - -class DeveloperWithCounterSQL < ActiveRecord::Base - set_table_name 'developers' - has_and_belongs_to_many :projects, - :class_name => "DeveloperWithCounterSQL", - :join_table => "developers_projects", - :association_foreign_key => "project_id", - :foreign_key => "developer_id", - :counter_sql => 'SELECT COUNT(*) AS count_all FROM projects INNER JOIN developers_projects ON projects.id = developers_projects.project_id WHERE developers_projects.developer_id =#{id}' -end - -class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase - fixtures :accounts, :companies, :categories, :posts, :categories_posts, :developers, :projects, :developers_projects, - :parrots, :pirates, :treasures, :price_estimates, :tags, :taggings - - def test_has_and_belongs_to_many - david = Developer.find(1) - - assert !david.projects.empty? - assert_equal 2, david.projects.size - - active_record = Project.find(1) - assert !active_record.developers.empty? - assert_equal 3, active_record.developers.size - assert active_record.developers.include?(david) - end - - def test_triple_equality - assert !(Array === Developer.find(1).projects) - assert Developer.find(1).projects === Array - end - - def test_adding_single - jamis = Developer.find(2) - jamis.projects.reload # causing the collection to load - action_controller = Project.find(2) - assert_equal 1, jamis.projects.size - assert_equal 1, action_controller.developers.size - - jamis.projects << action_controller - - assert_equal 2, jamis.projects.size - assert_equal 2, jamis.projects(true).size - assert_equal 2, action_controller.developers(true).size - end - - def test_adding_type_mismatch - jamis = Developer.find(2) - assert_raise(ActiveRecord::AssociationTypeMismatch) { jamis.projects << nil } - assert_raise(ActiveRecord::AssociationTypeMismatch) { jamis.projects << 1 } - end - - def test_adding_from_the_project - jamis = Developer.find(2) - action_controller = Project.find(2) - action_controller.developers.reload - assert_equal 1, jamis.projects.size - assert_equal 1, action_controller.developers.size - - action_controller.developers << jamis - - assert_equal 2, jamis.projects(true).size - assert_equal 2, action_controller.developers.size - assert_equal 2, action_controller.developers(true).size - end - - def test_adding_from_the_project_fixed_timestamp - jamis = Developer.find(2) - action_controller = Project.find(2) - action_controller.developers.reload - assert_equal 1, jamis.projects.size - assert_equal 1, action_controller.developers.size - updated_at = jamis.updated_at - - action_controller.developers << jamis - - assert_equal updated_at, jamis.updated_at - assert_equal 2, jamis.projects(true).size - assert_equal 2, action_controller.developers.size - assert_equal 2, action_controller.developers(true).size - end - - def test_adding_multiple - aredridel = Developer.new("name" => "Aredridel") - aredridel.save - aredridel.projects.reload - aredridel.projects.push(Project.find(1), Project.find(2)) - assert_equal 2, aredridel.projects.size - assert_equal 2, aredridel.projects(true).size - end - - def test_adding_a_collection - aredridel = Developer.new("name" => "Aredridel") - aredridel.save - aredridel.projects.reload - aredridel.projects.concat([Project.find(1), Project.find(2)]) - assert_equal 2, aredridel.projects.size - assert_equal 2, aredridel.projects(true).size - end - - def test_adding_uses_default_values_on_join_table - ac = projects(:action_controller) - assert !developers(:jamis).projects.include?(ac) - developers(:jamis).projects << ac - - assert developers(:jamis, :reload).projects.include?(ac) - project = developers(:jamis).projects.detect { |p| p == ac } - assert_equal 1, project.access_level.to_i - end - - def test_habtm_attribute_access_and_respond_to - project = developers(:jamis).projects[0] - assert project.has_attribute?("name") - assert project.has_attribute?("joined_on") - assert project.has_attribute?("access_level") - assert project.respond_to?("name") - assert project.respond_to?("name=") - assert project.respond_to?("name?") - assert project.respond_to?("joined_on") - # given that the 'join attribute' won't be persisted, I don't - # think we should define the mutators - #assert project.respond_to?("joined_on=") - assert project.respond_to?("joined_on?") - assert project.respond_to?("access_level") - #assert project.respond_to?("access_level=") - assert project.respond_to?("access_level?") - end - - def test_habtm_adding_before_save - no_of_devels = Developer.count - no_of_projects = Project.count - aredridel = Developer.new("name" => "Aredridel") - aredridel.projects.concat([Project.find(1), p = Project.new("name" => "Projekt")]) - assert aredridel.new_record? - assert p.new_record? - assert aredridel.save - assert !aredridel.new_record? - assert_equal no_of_devels+1, Developer.count - assert_equal no_of_projects+1, Project.count - assert_equal 2, aredridel.projects.size - assert_equal 2, aredridel.projects(true).size - end - - def test_habtm_saving_multiple_relationships - new_project = Project.new("name" => "Grimetime") - amount_of_developers = 4 - developers = (0...amount_of_developers).collect {|i| Developer.create(:name => "JME #{i}") }.reverse - - new_project.developer_ids = [developers[0].id, developers[1].id] - new_project.developers_with_callback_ids = [developers[2].id, developers[3].id] - assert new_project.save - - new_project.reload - assert_equal amount_of_developers, new_project.developers.size - assert_equal developers, new_project.developers - end - - def test_habtm_unique_order_preserved - assert_equal developers(:poor_jamis, :jamis, :david), projects(:active_record).non_unique_developers - assert_equal developers(:poor_jamis, :jamis, :david), projects(:active_record).developers - end - - def test_build - devel = Developer.find(1) - proj = assert_no_queries { devel.projects.build("name" => "Projekt") } - assert !devel.projects.loaded? - - assert_equal devel.projects.last, proj - assert devel.projects.loaded? - - assert proj.new_record? - devel.save - assert !proj.new_record? - assert_equal devel.projects.last, proj - assert_equal Developer.find(1).projects.sort_by(&:id).last, proj # prove join table is updated - end - - def test_build_by_new_record - devel = Developer.new(:name => "Marcel", :salary => 75000) - proj1 = devel.projects.build(:name => "Make bed") - proj2 = devel.projects.build(:name => "Lie in it") - assert_equal devel.projects.last, proj2 - assert proj2.new_record? - devel.save - assert !devel.new_record? - assert !proj2.new_record? - assert_equal devel.projects.last, proj2 - assert_equal Developer.find_by_name("Marcel").projects.last, proj2 # prove join table is updated - end - - def test_create - devel = Developer.find(1) - proj = devel.projects.create("name" => "Projekt") - assert !devel.projects.loaded? - - assert_equal devel.projects.last, proj - assert !devel.projects.loaded? - - assert !proj.new_record? - assert_equal Developer.find(1).projects.sort_by(&:id).last, proj # prove join table is updated - end - - def test_create_by_new_record - devel = Developer.new(:name => "Marcel", :salary => 75000) - proj1 = devel.projects.build(:name => "Make bed") - proj2 = devel.projects.build(:name => "Lie in it") - assert_equal devel.projects.last, proj2 - assert proj2.new_record? - devel.save - assert !devel.new_record? - assert !proj2.new_record? - assert_equal devel.projects.last, proj2 - assert_equal Developer.find_by_name("Marcel").projects.last, proj2 # prove join table is updated - end - - def test_creation_respects_hash_condition - post = categories(:general).post_with_conditions.build(:body => '') - - assert post.save - assert_equal 'Yet Another Testing Title', post.title - - another_post = categories(:general).post_with_conditions.create(:body => '') - - assert !another_post.new_record? - assert_equal 'Yet Another Testing Title', another_post.title - end - - def test_uniq_after_the_fact - dev = developers(:jamis) - dev.projects << projects(:active_record) - dev.projects << projects(:active_record) - - assert_equal 3, dev.projects.size - assert_equal 1, dev.projects.uniq.size - end - - def test_uniq_before_the_fact - projects(:active_record).developers << developers(:jamis) - projects(:active_record).developers << developers(:david) - assert_equal 3, projects(:active_record, :reload).developers.size - end - - def test_uniq_option_prevents_duplicate_push - project = projects(:active_record) - project.developers << developers(:jamis) - project.developers << developers(:david) - assert_equal 3, project.developers.size - - project.developers << developers(:david) - project.developers << developers(:jamis) - assert_equal 3, project.developers.size - end - - def test_deleting - david = Developer.find(1) - active_record = Project.find(1) - david.projects.reload - assert_equal 2, david.projects.size - assert_equal 3, active_record.developers.size - - david.projects.delete(active_record) - - assert_equal 1, david.projects.size - assert_equal 1, david.projects(true).size - assert_equal 2, active_record.developers(true).size - end - - def test_deleting_array - david = Developer.find(1) - david.projects.reload - david.projects.delete(Project.find(:all)) - assert_equal 0, david.projects.size - assert_equal 0, david.projects(true).size - end - - def test_deleting_with_sql - david = Developer.find(1) - active_record = Project.find(1) - active_record.developers.reload - assert_equal 3, active_record.developers_by_sql.size - - active_record.developers_by_sql.delete(david) - assert_equal 2, active_record.developers_by_sql(true).size - end - - def test_deleting_array_with_sql - active_record = Project.find(1) - active_record.developers.reload - assert_equal 3, active_record.developers_by_sql.size - - active_record.developers_by_sql.delete(Developer.find(:all)) - assert_equal 0, active_record.developers_by_sql(true).size - end - - def test_deleting_all - david = Developer.find(1) - david.projects.reload - david.projects.clear - assert_equal 0, david.projects.size - assert_equal 0, david.projects(true).size - end - - def test_removing_associations_on_destroy - david = DeveloperWithBeforeDestroyRaise.find(1) - assert !david.projects.empty? - assert_nothing_raised { david.destroy } - assert david.projects.empty? - assert DeveloperWithBeforeDestroyRaise.connection.select_all("SELECT * FROM developers_projects WHERE developer_id = 1").empty? - end - - def test_additional_columns_from_join_table - assert_date_from_db Date.new(2004, 10, 10), Developer.find(1).projects.first.joined_on.to_date - end - - def test_destroying - david = Developer.find(1) - active_record = Project.find(1) - david.projects.reload - assert_equal 2, david.projects.size - assert_equal 3, active_record.developers.size - - assert_difference "Project.count", -1 do - david.projects.destroy(active_record) - end - - assert_equal 1, david.reload.projects.size - assert_equal 1, david.projects(true).size - end - - def test_destroying_array - david = Developer.find(1) - david.projects.reload - - assert_difference "Project.count", -Project.count do - david.projects.destroy(Project.find(:all)) - end - - assert_equal 0, david.reload.projects.size - assert_equal 0, david.projects(true).size - end - - def test_destroy_all - david = Developer.find(1) - david.projects.reload - assert !david.projects.empty? - david.projects.destroy_all - assert david.projects.empty? - assert david.projects(true).empty? - end - - def test_deprecated_push_with_attributes_was_removed - jamis = developers(:jamis) - assert_raise(NoMethodError) do - jamis.projects.push_with_attributes(projects(:action_controller), :joined_on => Date.today) - end - end - - def test_associations_with_conditions - assert_equal 3, projects(:active_record).developers.size - assert_equal 1, projects(:active_record).developers_named_david.size - assert_equal 1, projects(:active_record).developers_named_david_with_hash_conditions.size - - assert_equal developers(:david), projects(:active_record).developers_named_david.find(developers(:david).id) - assert_equal developers(:david), projects(:active_record).developers_named_david_with_hash_conditions.find(developers(:david).id) - assert_equal developers(:david), projects(:active_record).salaried_developers.find(developers(:david).id) - - projects(:active_record).developers_named_david.clear - assert_equal 2, projects(:active_record, :reload).developers.size - end - - def test_find_in_association - # Using sql - assert_equal developers(:david), projects(:active_record).developers.find(developers(:david).id), "SQL find" - - # Using ruby - active_record = projects(:active_record) - active_record.developers.reload - assert_equal developers(:david), active_record.developers.find(developers(:david).id), "Ruby find" - end - - def test_include_uses_array_include_after_loaded - project = projects(:active_record) - project.developers.class # force load target - - developer = project.developers.first - - assert_no_queries do - assert project.developers.loaded? - assert project.developers.include?(developer) - end - end - - def test_include_checks_if_record_exists_if_target_not_loaded - project = projects(:active_record) - developer = project.developers.first - - project.reload - assert ! project.developers.loaded? - assert_queries(1) do - assert project.developers.include?(developer) - end - assert ! project.developers.loaded? - end - - def test_include_returns_false_for_non_matching_record_to_verify_scoping - project = projects(:active_record) - developer = Developer.create :name => "Bryan", :salary => 50_000 - - assert ! project.developers.loaded? - assert ! project.developers.include?(developer) - end - - def test_find_in_association_with_custom_finder_sql - assert_equal developers(:david), projects(:active_record).developers_with_finder_sql.find(developers(:david).id), "SQL find" - - active_record = projects(:active_record) - active_record.developers_with_finder_sql.reload - assert_equal developers(:david), active_record.developers_with_finder_sql.find(developers(:david).id), "Ruby find" - end - - def test_find_in_association_with_custom_finder_sql_and_multiple_interpolations - # interpolate once: - assert_equal [developers(:david), developers(:jamis), developers(:poor_jamis)], projects(:active_record).developers_with_finder_sql, "first interpolation" - # interpolate again, for a different project id - assert_equal [developers(:david)], projects(:action_controller).developers_with_finder_sql, "second interpolation" - end - - def test_find_in_association_with_custom_finder_sql_and_string_id - assert_equal developers(:david), projects(:active_record).developers_with_finder_sql.find(developers(:david).id.to_s), "SQL find" - end - - def test_find_with_merged_options - assert_equal 1, projects(:active_record).limited_developers.size - assert_equal 1, projects(:active_record).limited_developers.find(:all).size - assert_equal 3, projects(:active_record).limited_developers.find(:all, :limit => nil).size - end - - def test_dynamic_find_should_respect_association_order - # Developers are ordered 'name DESC, id DESC' - low_id_jamis = developers(:jamis) - middle_id_jamis = developers(:poor_jamis) - high_id_jamis = projects(:active_record).developers.create(:name => 'Jamis') - - assert_equal high_id_jamis, projects(:active_record).developers.find(:first, :conditions => "name = 'Jamis'") - assert_equal high_id_jamis, projects(:active_record).developers.find_by_name('Jamis') - end - - def test_dynamic_find_order_should_override_association_order - # Developers are ordered 'name DESC, id DESC' - low_id_jamis = developers(:jamis) - middle_id_jamis = developers(:poor_jamis) - high_id_jamis = projects(:active_record).developers.create(:name => 'Jamis') - - assert_equal low_id_jamis, projects(:active_record).developers.find(:first, :conditions => "name = 'Jamis'", :order => 'id') - assert_equal low_id_jamis, projects(:active_record).developers.find_by_name('Jamis', :order => 'id') - end - - def test_dynamic_find_all_should_respect_association_order - # Developers are ordered 'name DESC, id DESC' - low_id_jamis = developers(:jamis) - middle_id_jamis = developers(:poor_jamis) - high_id_jamis = projects(:active_record).developers.create(:name => 'Jamis') - - assert_equal [high_id_jamis, middle_id_jamis, low_id_jamis], projects(:active_record).developers.find(:all, :conditions => "name = 'Jamis'") - assert_equal [high_id_jamis, middle_id_jamis, low_id_jamis], projects(:active_record).developers.find_all_by_name('Jamis') - end - - def test_dynamic_find_all_order_should_override_association_order - # Developers are ordered 'name DESC, id DESC' - low_id_jamis = developers(:jamis) - middle_id_jamis = developers(:poor_jamis) - high_id_jamis = projects(:active_record).developers.create(:name => 'Jamis') - - assert_equal [low_id_jamis, middle_id_jamis, high_id_jamis], projects(:active_record).developers.find(:all, :conditions => "name = 'Jamis'", :order => 'id') - assert_equal [low_id_jamis, middle_id_jamis, high_id_jamis], projects(:active_record).developers.find_all_by_name('Jamis', :order => 'id') - end - - def test_dynamic_find_all_should_respect_association_limit - assert_equal 1, projects(:active_record).limited_developers.find(:all, :conditions => "name = 'Jamis'").length - assert_equal 1, projects(:active_record).limited_developers.find_all_by_name('Jamis').length - end - - def test_dynamic_find_all_order_should_override_association_limit - assert_equal 2, projects(:active_record).limited_developers.find(:all, :conditions => "name = 'Jamis'", :limit => 9_000).length - assert_equal 2, projects(:active_record).limited_developers.find_all_by_name('Jamis', :limit => 9_000).length - end - - def test_dynamic_find_all_should_respect_readonly_access - projects(:active_record).readonly_developers.each { |d| assert_raise(ActiveRecord::ReadOnlyRecord) { d.save! } if d.valid?} - projects(:active_record).readonly_developers.each { |d| d.readonly? } - end - - def test_new_with_values_in_collection - jamis = DeveloperForProjectWithAfterCreateHook.find_by_name('Jamis') - david = DeveloperForProjectWithAfterCreateHook.find_by_name('David') - project = ProjectWithAfterCreateHook.new(:name => "Cooking with Bertie") - project.developers << jamis - project.save! - project.reload - - assert project.developers.include?(jamis) - assert project.developers.include?(david) - end - - def test_find_in_association_with_options - developers = projects(:active_record).developers.find(:all) - assert_equal 3, developers.size - - assert_equal developers(:poor_jamis), projects(:active_record).developers.find(:first, :conditions => "salary < 10000") - assert_equal developers(:jamis), projects(:active_record).developers.find(:first, :order => "salary DESC") - end - - def test_replace_with_less - david = developers(:david) - david.projects = [projects(:action_controller)] - assert david.save - assert_equal 1, david.projects.length - end - - def test_replace_with_new - david = developers(:david) - david.projects = [projects(:action_controller), Project.new("name" => "ActionWebSearch")] - david.save - assert_equal 2, david.projects.length - assert !david.projects.include?(projects(:active_record)) - end - - def test_replace_on_new_object - new_developer = Developer.new("name" => "Matz") - new_developer.projects = [projects(:action_controller), Project.new("name" => "ActionWebSearch")] - new_developer.save - assert_equal 2, new_developer.projects.length - end - - def test_consider_type - developer = Developer.find(:first) - special_project = SpecialProject.create("name" => "Special Project") - - other_project = developer.projects.first - developer.special_projects << special_project - developer.reload - - assert developer.projects.include?(special_project) - assert developer.special_projects.include?(special_project) - assert !developer.special_projects.include?(other_project) - end - - def test_update_attributes_after_push_without_duplicate_join_table_rows - developer = Developer.new("name" => "Kano") - project = SpecialProject.create("name" => "Special Project") - assert developer.save - developer.projects << project - developer.update_attribute("name", "Bruza") - assert_equal 1, Developer.connection.select_value(<<-end_sql).to_i - SELECT count(*) FROM developers_projects - WHERE project_id = #{project.id} - AND developer_id = #{developer.id} - end_sql - end - - def test_updating_attributes_on_non_rich_associations - welcome = categories(:technology).posts.first - welcome.title = "Something else" - assert welcome.save! - end - - def test_habtm_respects_select - categories(:technology).select_testing_posts(true).each do |o| - assert_respond_to o, :correctness_marker - end - assert_respond_to categories(:technology).select_testing_posts.find(:first), :correctness_marker - end - - def test_updating_attributes_on_rich_associations - david = projects(:action_controller).developers.first - david.name = "DHH" - assert_raise(ActiveRecord::ReadOnlyRecord) { david.save! } - end - - def test_updating_attributes_on_rich_associations_with_limited_find_from_reflection - david = projects(:action_controller).selected_developers.first - david.name = "DHH" - assert_nothing_raised { david.save! } - end - - - def test_updating_attributes_on_rich_associations_with_limited_find - david = projects(:action_controller).developers.find(:all, :select => "developers.*").first - david.name = "DHH" - assert david.save! - end - - def test_join_table_alias - assert_equal 3, Developer.find(:all, :include => {:projects => :developers}, :conditions => 'developers_projects_join.joined_on IS NOT NULL').size - end - - def test_join_with_group - group = Developer.columns.inject([]) do |g, c| - g << "developers.#{c.name}" - g << "developers_projects_2.#{c.name}" - end - Project.columns.each { |c| group << "projects.#{c.name}" } - - assert_equal 3, Developer.find(:all, :include => {:projects => :developers}, :conditions => 'developers_projects_join.joined_on IS NOT NULL', :group => group.join(",")).size - end - - def test_find_grouped - all_posts_from_category1 = Post.find(:all, :conditions => "category_id = 1", :joins => :categories) - grouped_posts_of_category1 = Post.find(:all, :conditions => "category_id = 1", :group => "author_id", :select => 'count(posts.id) as posts_count', :joins => :categories) - assert_equal 4, all_posts_from_category1.size - assert_equal 1, grouped_posts_of_category1.size - end - - def test_find_scoped_grouped - assert_equal 4, categories(:general).posts_gruoped_by_title.size - assert_equal 1, categories(:technology).posts_gruoped_by_title.size - end - - def test_find_scoped_grouped_having - assert_equal 2, projects(:active_record).well_payed_salary_groups.size - assert projects(:active_record).well_payed_salary_groups.all? { |g| g.salary > 10000 } - end - - def test_get_ids - assert_equal projects(:active_record, :action_controller).map(&:id).sort, developers(:david).project_ids.sort - assert_equal [projects(:active_record).id], developers(:jamis).project_ids - end - - def test_get_ids_for_loaded_associations - developer = developers(:david) - developer.projects(true) - assert_queries(0) do - developer.project_ids - developer.project_ids - end - end - - def test_get_ids_for_unloaded_associations_does_not_load_them - developer = developers(:david) - assert !developer.projects.loaded? - assert_equal projects(:active_record, :action_controller).map(&:id).sort, developer.project_ids.sort - assert !developer.projects.loaded? - end - - def test_assign_ids - developer = Developer.new("name" => "Joe") - developer.project_ids = projects(:active_record, :action_controller).map(&:id) - developer.save - developer.reload - assert_equal 2, developer.projects.length - assert_equal [projects(:active_record), projects(:action_controller)].map(&:id).sort, developer.project_ids.sort - end - - def test_assign_ids_ignoring_blanks - developer = Developer.new("name" => "Joe") - developer.project_ids = [projects(:active_record).id, nil, projects(:action_controller).id, ''] - developer.save - developer.reload - assert_equal 2, developer.projects.length - assert_equal [projects(:active_record), projects(:action_controller)].map(&:id).sort, developer.project_ids.sort - end - - def test_select_limited_ids_list - # Set timestamps - Developer.transaction do - Developer.find(:all, :order => 'id').each_with_index do |record, i| - record.update_attributes(:created_at => 5.years.ago + (i * 5.minutes)) - end - end - - join_base = ActiveRecord::Associations::ClassMethods::JoinDependency::JoinBase.new(Project) - join_dep = ActiveRecord::Associations::ClassMethods::JoinDependency.new(join_base, :developers, nil) - projects = Project.send(:select_limited_ids_list, {:order => 'developers.created_at'}, join_dep) - assert !projects.include?("'"), projects - assert_equal %w(1 2), projects.scan(/\d/).sort - end - - def test_scoped_find_on_through_association_doesnt_return_read_only_records - tag = Post.find(1).tags.find_by_name("General") - - assert_nothing_raised do - tag.save! - end - end - - def test_has_many_through_polymorphic_has_manys_works - assert_equal [10, 20].to_set, pirates(:redbeard).treasure_estimates.map(&:price).to_set - end - - def test_symbols_as_keys - developer = DeveloperWithSymbolsForKeys.new(:name => 'David') - project = ProjectWithSymbolsForKeys.new(:name => 'Rails Testing') - project.developers << developer - project.save! - - assert_equal 1, project.developers.size - assert_equal 1, developer.projects.size - assert_equal developer, project.developers.find(:first) - assert_equal project, developer.projects.find(:first) - end - - def test_self_referential_habtm_without_foreign_key_set_should_raise_exception - assert_raise(ActiveRecord::HasAndBelongsToManyAssociationForeignKeyNeeded) { - Member.class_eval do - has_and_belongs_to_many :friends, :class_name => "Member", :join_table => "member_friends" - end - } - end - - def test_dynamic_find_should_respect_association_include - # SQL error in sort clause if :include is not included - # due to Unknown column 'authors.id' - assert Category.find(1).posts_with_authors_sorted_by_author_id.find_by_title('Welcome to the weblog') - end - - def test_counting_on_habtm_association_and_not_array - david = Developer.find(1) - # Extra parameter just to make sure we aren't falling back to - # Array#count in Ruby >=1.8.7, which would raise an ArgumentError - assert_nothing_raised { david.projects.count(:all, :conditions => '1=1') } - end - - def test_count - david = Developer.find(1) - assert_equal 2, david.projects.count - end - - def test_count_with_counter_sql - developer = DeveloperWithCounterSQL.create(:name => 'tekin') - developer.project_ids = [projects(:active_record).id] - developer.save - developer.reload - assert_equal 1, developer.projects.count - end - - def test_association_proxy_transaction_method_starts_transaction_in_association_class - Post.expects(:transaction) - Category.find(:first).posts.transaction do - # nothing - end - end - - def test_caching_of_columns - david = Developer.find(1) - # clear cache possibly created by other tests - david.projects.reset_column_information - assert_queries(0) { david.projects.columns; david.projects.columns } - # and again to verify that reset_column_information clears the cache correctly - david.projects.reset_column_information - assert_queries(0) { david.projects.columns; david.projects.columns } - end - -end diff --git a/vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb b/vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb deleted file mode 100644 index 30edf79..0000000 --- a/vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb +++ /dev/null @@ -1,1062 +0,0 @@ -require "cases/helper" -require 'models/developer' -require 'models/project' -require 'models/company' -require 'models/topic' -require 'models/reply' -require 'models/category' -require 'models/post' -require 'models/author' -require 'models/comment' -require 'models/person' -require 'models/reader' - -class HasManyAssociationsTest < ActiveRecord::TestCase - fixtures :accounts, :categories, :companies, :developers, :projects, - :developers_projects, :topics, :authors, :comments, :author_addresses, - :people, :posts, :readers - - def setup - Client.destroyed_client_ids.clear - end - - def force_signal37_to_load_all_clients_of_firm - companies(:first_firm).clients_of_firm.each {|f| } - end - - def test_counting_with_counter_sql - assert_equal 2, Firm.find(:first).clients.count - end - - def test_counting - assert_equal 2, Firm.find(:first).plain_clients.count - end - - def test_counting_with_empty_hash_conditions - assert_equal 2, Firm.find(:first).plain_clients.count(:conditions => {}) - end - - def test_counting_with_single_conditions - assert_equal 1, Firm.find(:first).plain_clients.count(:conditions => ['name=?', "Microsoft"]) - end - - def test_counting_with_single_hash - assert_equal 1, Firm.find(:first).plain_clients.count(:conditions => {:name => "Microsoft"}) - end - - def test_counting_with_column_name_and_hash - assert_equal 2, Firm.find(:first).plain_clients.count(:name) - end - - def test_counting_with_association_limit - firm = companies(:first_firm) - assert_equal firm.limited_clients.length, firm.limited_clients.size - assert_equal firm.limited_clients.length, firm.limited_clients.count - end - - def test_finding - assert_equal 2, Firm.find(:first).clients.length - end - - def test_find_with_blank_conditions - [[], {}, nil, ""].each do |blank| - assert_equal 2, Firm.find(:first).clients.find(:all, :conditions => blank).size - end - end - - def test_find_many_with_merged_options - assert_equal 1, companies(:first_firm).limited_clients.size - assert_equal 1, companies(:first_firm).limited_clients.find(:all).size - assert_equal 2, companies(:first_firm).limited_clients.find(:all, :limit => nil).size - end - - def test_dynamic_find_last_without_specified_order - assert_equal companies(:second_client), companies(:first_firm).unsorted_clients.find_last_by_type('Client') - end - - def test_dynamic_find_should_respect_association_order - assert_equal companies(:second_client), companies(:first_firm).clients_sorted_desc.find(:first, :conditions => "type = 'Client'") - assert_equal companies(:second_client), companies(:first_firm).clients_sorted_desc.find_by_type('Client') - end - - def test_dynamic_find_order_should_override_association_order - assert_equal companies(:first_client), companies(:first_firm).clients_sorted_desc.find(:first, :conditions => "type = 'Client'", :order => 'id') - assert_equal companies(:first_client), companies(:first_firm).clients_sorted_desc.find_by_type('Client', :order => 'id') - end - - def test_dynamic_find_all_should_respect_association_order - assert_equal [companies(:second_client), companies(:first_client)], companies(:first_firm).clients_sorted_desc.find(:all, :conditions => "type = 'Client'") - assert_equal [companies(:second_client), companies(:first_client)], companies(:first_firm).clients_sorted_desc.find_all_by_type('Client') - end - - def test_dynamic_find_all_order_should_override_association_order - assert_equal [companies(:first_client), companies(:second_client)], companies(:first_firm).clients_sorted_desc.find(:all, :conditions => "type = 'Client'", :order => 'id') - assert_equal [companies(:first_client), companies(:second_client)], companies(:first_firm).clients_sorted_desc.find_all_by_type('Client', :order => 'id') - end - - def test_dynamic_find_all_should_respect_association_limit - assert_equal 1, companies(:first_firm).limited_clients.find(:all, :conditions => "type = 'Client'").length - assert_equal 1, companies(:first_firm).limited_clients.find_all_by_type('Client').length - end - - def test_dynamic_find_all_limit_should_override_association_limit - assert_equal 2, companies(:first_firm).limited_clients.find(:all, :conditions => "type = 'Client'", :limit => 9_000).length - assert_equal 2, companies(:first_firm).limited_clients.find_all_by_type('Client', :limit => 9_000).length - end - - def test_dynamic_find_all_should_respect_readonly_access - companies(:first_firm).readonly_clients.find(:all).each { |c| assert_raise(ActiveRecord::ReadOnlyRecord) { c.save! } } - companies(:first_firm).readonly_clients.find(:all).each { |c| assert c.readonly? } - end - - def test_cant_save_has_many_readonly_association - authors(:david).readonly_comments.each { |c| assert_raise(ActiveRecord::ReadOnlyRecord) { c.save! } } - authors(:david).readonly_comments.each { |c| assert c.readonly? } - end - - def test_triple_equality - assert !(Array === Firm.find(:first).clients) - assert Firm.find(:first).clients === Array - end - - def test_finding_default_orders - assert_equal "Summit", Firm.find(:first).clients.first.name - end - - def test_finding_with_different_class_name_and_order - assert_equal "Microsoft", Firm.find(:first).clients_sorted_desc.first.name - end - - def test_finding_with_foreign_key - assert_equal "Microsoft", Firm.find(:first).clients_of_firm.first.name - end - - def test_finding_with_condition - assert_equal "Microsoft", Firm.find(:first).clients_like_ms.first.name - end - - def test_finding_with_condition_hash - assert_equal "Microsoft", Firm.find(:first).clients_like_ms_with_hash_conditions.first.name - end - - def test_finding_using_primary_key - assert_equal "Summit", Firm.find(:first).clients_using_primary_key.first.name - end - - def test_finding_using_sql - firm = Firm.find(:first) - first_client = firm.clients_using_sql.first - assert_not_nil first_client - assert_equal "Microsoft", first_client.name - assert_equal 1, firm.clients_using_sql.size - assert_equal 1, Firm.find(:first).clients_using_sql.size - end - - def test_counting_using_sql - assert_equal 1, Firm.find(:first).clients_using_counter_sql.size - assert Firm.find(:first).clients_using_counter_sql.any? - assert_equal 0, Firm.find(:first).clients_using_zero_counter_sql.size - assert !Firm.find(:first).clients_using_zero_counter_sql.any? - end - - def test_counting_non_existant_items_using_sql - assert_equal 0, Firm.find(:first).no_clients_using_counter_sql.size - end - - def test_belongs_to_sanity - c = Client.new - assert_nil c.firm - - if c.firm - assert false, "belongs_to failed if check" - end - - unless c.firm - else - assert false, "belongs_to failed unless check" - end - end - - def test_find_ids - firm = Firm.find(:first) - - assert_raise(ActiveRecord::RecordNotFound) { firm.clients.find } - - client = firm.clients.find(2) - assert_kind_of Client, client - - client_ary = firm.clients.find([2]) - assert_kind_of Array, client_ary - assert_equal client, client_ary.first - - client_ary = firm.clients.find(2, 3) - assert_kind_of Array, client_ary - assert_equal 2, client_ary.size - assert_equal client, client_ary.first - - assert_raise(ActiveRecord::RecordNotFound) { firm.clients.find(2, 99) } - end - - def test_find_string_ids_when_using_finder_sql - firm = Firm.find(:first) - - client = firm.clients_using_finder_sql.find("2") - assert_kind_of Client, client - - client_ary = firm.clients_using_finder_sql.find(["2"]) - assert_kind_of Array, client_ary - assert_equal client, client_ary.first - - client_ary = firm.clients_using_finder_sql.find("2", "3") - assert_kind_of Array, client_ary - assert_equal 2, client_ary.size - assert client_ary.include?(client) - end - - def test_find_all - firm = Firm.find(:first) - assert_equal 2, firm.clients.find(:all, :conditions => "#{QUOTED_TYPE} = 'Client'").length - assert_equal 1, firm.clients.find(:all, :conditions => "name = 'Summit'").length - end - - def test_find_each - firm = companies(:first_firm) - - assert ! firm.clients.loaded? - - assert_queries(3) do - firm.clients.find_each(:batch_size => 1) {|c| assert_equal firm.id, c.firm_id } - end - - assert ! firm.clients.loaded? - end - - def test_find_each_with_conditions - firm = companies(:first_firm) - - assert_queries(2) do - firm.clients.find_each(:batch_size => 1, :conditions => {:name => "Microsoft"}) do |c| - assert_equal firm.id, c.firm_id - assert_equal "Microsoft", c.name - end - end - - assert ! firm.clients.loaded? - end - - def test_find_in_batches - firm = companies(:first_firm) - - assert ! firm.clients.loaded? - - assert_queries(2) do - firm.clients.find_in_batches(:batch_size => 2) do |clients| - clients.each {|c| assert_equal firm.id, c.firm_id } - end - end - - assert ! firm.clients.loaded? - end - - def test_find_all_sanitized - firm = Firm.find(:first) - summit = firm.clients.find(:all, :conditions => "name = 'Summit'") - assert_equal summit, firm.clients.find(:all, :conditions => ["name = ?", "Summit"]) - assert_equal summit, firm.clients.find(:all, :conditions => ["name = :name", { :name => "Summit" }]) - end - - def test_find_first - firm = Firm.find(:first) - client2 = Client.find(2) - assert_equal firm.clients.first, firm.clients.find(:first) - assert_equal client2, firm.clients.find(:first, :conditions => "#{QUOTED_TYPE} = 'Client'") - end - - def test_find_first_sanitized - firm = Firm.find(:first) - client2 = Client.find(2) - assert_equal client2, firm.clients.find(:first, :conditions => ["#{QUOTED_TYPE} = ?", 'Client']) - assert_equal client2, firm.clients.find(:first, :conditions => ["#{QUOTED_TYPE} = :type", { :type => 'Client' }]) - end - - def test_find_in_collection - assert_equal Client.find(2).name, companies(:first_firm).clients.find(2).name - assert_raise(ActiveRecord::RecordNotFound) { companies(:first_firm).clients.find(6) } - end - - def test_find_grouped - all_clients_of_firm1 = Client.find(:all, :conditions => "firm_id = 1") - grouped_clients_of_firm1 = Client.find(:all, :conditions => "firm_id = 1", :group => "firm_id", :select => 'firm_id, count(id) as clients_count') - assert_equal 2, all_clients_of_firm1.size - assert_equal 1, grouped_clients_of_firm1.size - end - - def test_find_scoped_grouped - assert_equal 1, companies(:first_firm).clients_grouped_by_firm_id.size - assert_equal 1, companies(:first_firm).clients_grouped_by_firm_id.length - assert_equal 2, companies(:first_firm).clients_grouped_by_name.size - assert_equal 2, companies(:first_firm).clients_grouped_by_name.length - end - - def test_find_scoped_grouped_having - assert_equal 1, authors(:david).popular_grouped_posts.length - assert_equal 0, authors(:mary).popular_grouped_posts.length - end - - def test_adding - force_signal37_to_load_all_clients_of_firm - natural = Client.new("name" => "Natural Company") - companies(:first_firm).clients_of_firm << natural - assert_equal 2, companies(:first_firm).clients_of_firm.size # checking via the collection - assert_equal 2, companies(:first_firm).clients_of_firm(true).size # checking using the db - assert_equal natural, companies(:first_firm).clients_of_firm.last - end - - def test_adding_using_create - first_firm = companies(:first_firm) - assert_equal 2, first_firm.plain_clients.size - natural = first_firm.plain_clients.create(:name => "Natural Company") - assert_equal 3, first_firm.plain_clients.length - assert_equal 3, first_firm.plain_clients.size - end - - def test_create_with_bang_on_has_many_when_parent_is_new_raises - assert_raise(ActiveRecord::RecordNotSaved) do - firm = Firm.new - firm.plain_clients.create! :name=>"Whoever" - end - end - - def test_regular_create_on_has_many_when_parent_is_new_raises - assert_raise(ActiveRecord::RecordNotSaved) do - firm = Firm.new - firm.plain_clients.create :name=>"Whoever" - end - end - - def test_create_with_bang_on_has_many_raises_when_record_not_saved - assert_raise(ActiveRecord::RecordInvalid) do - firm = Firm.find(:first) - firm.plain_clients.create! - end - end - - def test_create_with_bang_on_habtm_when_parent_is_new_raises - assert_raise(ActiveRecord::RecordNotSaved) do - Developer.new("name" => "Aredridel").projects.create! - end - end - - def test_adding_a_mismatch_class - assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << nil } - assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << 1 } - assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << Topic.find(1) } - end - - def test_adding_a_collection - force_signal37_to_load_all_clients_of_firm - companies(:first_firm).clients_of_firm.concat([Client.new("name" => "Natural Company"), Client.new("name" => "Apple")]) - assert_equal 3, companies(:first_firm).clients_of_firm.size - assert_equal 3, companies(:first_firm).clients_of_firm(true).size - end - - def test_build - company = companies(:first_firm) - new_client = assert_no_queries { company.clients_of_firm.build("name" => "Another Client") } - assert !company.clients_of_firm.loaded? - - assert_equal "Another Client", new_client.name - assert new_client.new_record? - assert_equal new_client, company.clients_of_firm.last - end - - def test_collection_size_after_building - company = companies(:first_firm) # company already has one client - company.clients_of_firm.build("name" => "Another Client") - company.clients_of_firm.build("name" => "Yet Another Client") - assert_equal 3, company.clients_of_firm.size - end - - def test_collection_size_twice_for_regressions - post = posts(:thinking) - assert_equal 0, post.readers.size - # This test needs a post that has no readers, we assert it to ensure it holds, - # but need to reload the post because the very call to #size hides the bug. - post.reload - post.readers.build - size1 = post.readers.size - size2 = post.readers.size - assert_equal size1, size2 - end - - def test_build_many - company = companies(:first_firm) - new_clients = assert_no_queries { company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) } - assert_equal 2, new_clients.size - end - - def test_build_followed_by_save_does_not_load_target - new_client = companies(:first_firm).clients_of_firm.build("name" => "Another Client") - assert companies(:first_firm).save - assert !companies(:first_firm).clients_of_firm.loaded? - end - - def test_build_without_loading_association - first_topic = topics(:first) - Reply.column_names - - assert_equal 1, first_topic.replies.length - - assert_no_queries do - first_topic.replies.build(:title => "Not saved", :content => "Superstars") - assert_equal 2, first_topic.replies.size - end - - assert_equal 2, first_topic.replies.to_ary.size - end - - def test_build_via_block - company = companies(:first_firm) - new_client = assert_no_queries { company.clients_of_firm.build {|client| client.name = "Another Client" } } - assert !company.clients_of_firm.loaded? - - assert_equal "Another Client", new_client.name - assert new_client.new_record? - assert_equal new_client, company.clients_of_firm.last - end - - def test_build_many_via_block - company = companies(:first_firm) - new_clients = assert_no_queries do - company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) do |client| - client.name = "changed" - end - end - - assert_equal 2, new_clients.size - assert_equal "changed", new_clients.first.name - assert_equal "changed", new_clients.last.name - end - - def test_create_without_loading_association - first_firm = companies(:first_firm) - Firm.column_names - Client.column_names - - assert_equal 1, first_firm.clients_of_firm.size - first_firm.clients_of_firm.reset - - assert_queries(1) do - first_firm.clients_of_firm.create(:name => "Superstars") - end - - assert_equal 2, first_firm.clients_of_firm.size - end - - def test_create - force_signal37_to_load_all_clients_of_firm - new_client = companies(:first_firm).clients_of_firm.create("name" => "Another Client") - assert !new_client.new_record? - assert_equal new_client, companies(:first_firm).clients_of_firm.last - assert_equal new_client, companies(:first_firm).clients_of_firm(true).last - end - - def test_create_many - companies(:first_firm).clients_of_firm.create([{"name" => "Another Client"}, {"name" => "Another Client II"}]) - assert_equal 3, companies(:first_firm).clients_of_firm(true).size - end - - def test_create_followed_by_save_does_not_load_target - new_client = companies(:first_firm).clients_of_firm.create("name" => "Another Client") - assert companies(:first_firm).save - assert !companies(:first_firm).clients_of_firm.loaded? - end - - def test_find_or_initialize - the_client = companies(:first_firm).clients.find_or_initialize_by_name("Yet another client") - assert_equal companies(:first_firm).id, the_client.firm_id - assert_equal "Yet another client", the_client.name - assert the_client.new_record? - end - - def test_find_or_create - number_of_clients = companies(:first_firm).clients.size - the_client = companies(:first_firm).clients.find_or_create_by_name("Yet another client") - assert_equal number_of_clients + 1, companies(:first_firm, :reload).clients.size - assert_equal the_client, companies(:first_firm).clients.find_or_create_by_name("Yet another client") - assert_equal number_of_clients + 1, companies(:first_firm, :reload).clients.size - end - - def test_deleting - force_signal37_to_load_all_clients_of_firm - companies(:first_firm).clients_of_firm.delete(companies(:first_firm).clients_of_firm.first) - assert_equal 0, companies(:first_firm).clients_of_firm.size - assert_equal 0, companies(:first_firm).clients_of_firm(true).size - end - - def test_deleting_before_save - new_firm = Firm.new("name" => "A New Firm, Inc.") - new_client = new_firm.clients_of_firm.build("name" => "Another Client") - assert_equal 1, new_firm.clients_of_firm.size - new_firm.clients_of_firm.delete(new_client) - assert_equal 0, new_firm.clients_of_firm.size - end - - def test_deleting_a_collection - force_signal37_to_load_all_clients_of_firm - companies(:first_firm).clients_of_firm.create("name" => "Another Client") - assert_equal 2, companies(:first_firm).clients_of_firm.size - companies(:first_firm).clients_of_firm.delete([companies(:first_firm).clients_of_firm[0], companies(:first_firm).clients_of_firm[1]]) - assert_equal 0, companies(:first_firm).clients_of_firm.size - assert_equal 0, companies(:first_firm).clients_of_firm(true).size - end - - def test_delete_all - force_signal37_to_load_all_clients_of_firm - companies(:first_firm).clients_of_firm.create("name" => "Another Client") - assert_equal 2, companies(:first_firm).clients_of_firm.size - companies(:first_firm).clients_of_firm.delete_all - assert_equal 0, companies(:first_firm).clients_of_firm.size - assert_equal 0, companies(:first_firm).clients_of_firm(true).size - end - - def test_delete_all_with_not_yet_loaded_association_collection - force_signal37_to_load_all_clients_of_firm - companies(:first_firm).clients_of_firm.create("name" => "Another Client") - assert_equal 2, companies(:first_firm).clients_of_firm.size - companies(:first_firm).clients_of_firm.reset - companies(:first_firm).clients_of_firm.delete_all - assert_equal 0, companies(:first_firm).clients_of_firm.size - assert_equal 0, companies(:first_firm).clients_of_firm(true).size - end - - def test_clearing_an_association_collection - firm = companies(:first_firm) - client_id = firm.clients_of_firm.first.id - assert_equal 1, firm.clients_of_firm.size - - firm.clients_of_firm.clear - - assert_equal 0, firm.clients_of_firm.size - assert_equal 0, firm.clients_of_firm(true).size - assert_equal [], Client.destroyed_client_ids[firm.id] - - # Should not be destroyed since the association is not dependent. - assert_nothing_raised do - assert Client.find(client_id).firm.nil? - end - end - - def test_clearing_a_dependent_association_collection - firm = companies(:first_firm) - client_id = firm.dependent_clients_of_firm.first.id - assert_equal 1, firm.dependent_clients_of_firm.size - - # :dependent means destroy is called on each client - firm.dependent_clients_of_firm.clear - - assert_equal 0, firm.dependent_clients_of_firm.size - assert_equal 0, firm.dependent_clients_of_firm(true).size - assert_equal [client_id], Client.destroyed_client_ids[firm.id] - - # Should be destroyed since the association is dependent. - assert Client.find_by_id(client_id).nil? - end - - def test_clearing_an_exclusively_dependent_association_collection - firm = companies(:first_firm) - client_id = firm.exclusively_dependent_clients_of_firm.first.id - assert_equal 1, firm.exclusively_dependent_clients_of_firm.size - - assert_equal [], Client.destroyed_client_ids[firm.id] - - # :exclusively_dependent means each client is deleted directly from - # the database without looping through them calling destroy. - firm.exclusively_dependent_clients_of_firm.clear - - assert_equal 0, firm.exclusively_dependent_clients_of_firm.size - assert_equal 0, firm.exclusively_dependent_clients_of_firm(true).size - # no destroy-filters should have been called - assert_equal [], Client.destroyed_client_ids[firm.id] - - # Should be destroyed since the association is exclusively dependent. - assert Client.find_by_id(client_id).nil? - end - - def test_dependent_association_respects_optional_conditions_on_delete - firm = companies(:odegy) - Client.create(:client_of => firm.id, :name => "BigShot Inc.") - Client.create(:client_of => firm.id, :name => "SmallTime Inc.") - # only one of two clients is included in the association due to the :conditions key - assert_equal 2, Client.find_all_by_client_of(firm.id).size - assert_equal 1, firm.dependent_conditional_clients_of_firm.size - firm.destroy - # only the correctly associated client should have been deleted - assert_equal 1, Client.find_all_by_client_of(firm.id).size - end - - def test_dependent_association_respects_optional_sanitized_conditions_on_delete - firm = companies(:odegy) - Client.create(:client_of => firm.id, :name => "BigShot Inc.") - Client.create(:client_of => firm.id, :name => "SmallTime Inc.") - # only one of two clients is included in the association due to the :conditions key - assert_equal 2, Client.find_all_by_client_of(firm.id).size - assert_equal 1, firm.dependent_sanitized_conditional_clients_of_firm.size - firm.destroy - # only the correctly associated client should have been deleted - assert_equal 1, Client.find_all_by_client_of(firm.id).size - end - - def test_dependent_association_respects_optional_hash_conditions_on_delete - firm = companies(:odegy) - Client.create(:client_of => firm.id, :name => "BigShot Inc.") - Client.create(:client_of => firm.id, :name => "SmallTime Inc.") - # only one of two clients is included in the association due to the :conditions key - assert_equal 2, Client.find_all_by_client_of(firm.id).size - assert_equal 1, firm.dependent_sanitized_conditional_clients_of_firm.size - firm.destroy - # only the correctly associated client should have been deleted - assert_equal 1, Client.find_all_by_client_of(firm.id).size - end - - - def test_creation_respects_hash_condition - ms_client = companies(:first_firm).clients_like_ms_with_hash_conditions.build - - assert ms_client.save - assert_equal 'Microsoft', ms_client.name - - another_ms_client = companies(:first_firm).clients_like_ms_with_hash_conditions.create - - assert !another_ms_client.new_record? - assert_equal 'Microsoft', another_ms_client.name - end - - def test_dependent_delete_and_destroy_with_belongs_to - author_address = author_addresses(:david_address) - assert_equal [], AuthorAddress.destroyed_author_address_ids[authors(:david).id] - - assert_difference "AuthorAddress.count", -2 do - authors(:david).destroy - end - - assert_equal nil, AuthorAddress.find_by_id(authors(:david).author_address_id) - assert_equal nil, AuthorAddress.find_by_id(authors(:david).author_address_extra_id) - end - - def test_invalid_belongs_to_dependent_option_raises_exception - assert_raise ArgumentError do - Author.belongs_to :special_author_address, :dependent => :nullify - end - end - - def test_clearing_without_initial_access - firm = companies(:first_firm) - - firm.clients_of_firm.clear - - assert_equal 0, firm.clients_of_firm.size - assert_equal 0, firm.clients_of_firm(true).size - end - - def test_deleting_a_item_which_is_not_in_the_collection - force_signal37_to_load_all_clients_of_firm - summit = Client.find_by_name('Summit') - companies(:first_firm).clients_of_firm.delete(summit) - assert_equal 1, companies(:first_firm).clients_of_firm.size - assert_equal 1, companies(:first_firm).clients_of_firm(true).size - assert_equal 2, summit.client_of - end - - def test_deleting_type_mismatch - david = Developer.find(1) - david.projects.reload - assert_raise(ActiveRecord::AssociationTypeMismatch) { david.projects.delete(1) } - end - - def test_deleting_self_type_mismatch - david = Developer.find(1) - david.projects.reload - assert_raise(ActiveRecord::AssociationTypeMismatch) { david.projects.delete(Project.find(1).developers) } - end - - def test_destroying - force_signal37_to_load_all_clients_of_firm - - assert_difference "Client.count", -1 do - companies(:first_firm).clients_of_firm.destroy(companies(:first_firm).clients_of_firm.first) - end - - assert_equal 0, companies(:first_firm).reload.clients_of_firm.size - assert_equal 0, companies(:first_firm).clients_of_firm(true).size - end - - def test_destroying_a_collection - force_signal37_to_load_all_clients_of_firm - companies(:first_firm).clients_of_firm.create("name" => "Another Client") - assert_equal 2, companies(:first_firm).clients_of_firm.size - - assert_difference "Client.count", -2 do - companies(:first_firm).clients_of_firm.destroy([companies(:first_firm).clients_of_firm[0], companies(:first_firm).clients_of_firm[1]]) - end - - assert_equal 0, companies(:first_firm).reload.clients_of_firm.size - assert_equal 0, companies(:first_firm).clients_of_firm(true).size - end - - def test_destroy_all - force_signal37_to_load_all_clients_of_firm - assert !companies(:first_firm).clients_of_firm.empty?, "37signals has clients after load" - companies(:first_firm).clients_of_firm.destroy_all - assert companies(:first_firm).clients_of_firm.empty?, "37signals has no clients after destroy all" - assert companies(:first_firm).clients_of_firm(true).empty?, "37signals has no clients after destroy all and refresh" - end - - def test_dependence - firm = companies(:first_firm) - assert_equal 2, firm.clients.size - firm.destroy - assert Client.find(:all, :conditions => "firm_id=#{firm.id}").empty? - end - - def test_destroy_dependent_when_deleted_from_association - firm = Firm.find(:first) - assert_equal 2, firm.clients.size - - client = firm.clients.first - firm.clients.delete(client) - - assert_raise(ActiveRecord::RecordNotFound) { Client.find(client.id) } - assert_raise(ActiveRecord::RecordNotFound) { firm.clients.find(client.id) } - assert_equal 1, firm.clients.size - end - - def test_three_levels_of_dependence - topic = Topic.create "title" => "neat and simple" - reply = topic.replies.create "title" => "neat and simple", "content" => "still digging it" - silly_reply = reply.replies.create "title" => "neat and simple", "content" => "ain't complaining" - - assert_nothing_raised { topic.destroy } - end - - uses_transaction :test_dependence_with_transaction_support_on_failure - def test_dependence_with_transaction_support_on_failure - firm = companies(:first_firm) - clients = firm.clients - assert_equal 2, clients.length - clients.last.instance_eval { def before_destroy() raise "Trigger rollback" end } - - firm.destroy rescue "do nothing" - - assert_equal 2, Client.find(:all, :conditions => "firm_id=#{firm.id}").size - end - - def test_dependence_on_account - num_accounts = Account.count - companies(:first_firm).destroy - assert_equal num_accounts - 1, Account.count - end - - def test_depends_and_nullify - num_accounts = Account.count - num_companies = Company.count - - core = companies(:rails_core) - assert_equal accounts(:rails_core_account), core.account - assert_equal companies(:leetsoft, :jadedpixel), core.companies - core.destroy - assert_nil accounts(:rails_core_account).reload.firm_id - assert_nil companies(:leetsoft).reload.client_of - assert_nil companies(:jadedpixel).reload.client_of - - - assert_equal num_accounts, Account.count - end - - def test_included_in_collection - assert companies(:first_firm).clients.include?(Client.find(2)) - end - - def test_adding_array_and_collection - assert_nothing_raised { Firm.find(:first).clients + Firm.find(:all).last.clients } - end - - def test_find_all_without_conditions - firm = companies(:first_firm) - assert_equal 2, firm.clients.find(:all).length - end - - def test_replace_with_less - firm = Firm.find(:first) - firm.clients = [companies(:first_client)] - assert firm.save, "Could not save firm" - firm.reload - assert_equal 1, firm.clients.length - end - - def test_replace_with_less_and_dependent_nullify - num_companies = Company.count - companies(:rails_core).companies = [] - assert_equal num_companies, Company.count - end - - def test_replace_with_new - firm = Firm.find(:first) - firm.clients = [companies(:second_client), Client.new("name" => "New Client")] - firm.save - firm.reload - assert_equal 2, firm.clients.length - assert !firm.clients.include?(:first_client) - end - - def test_get_ids - assert_equal [companies(:first_client).id, companies(:second_client).id], companies(:first_firm).client_ids - end - - def test_get_ids_for_loaded_associations - company = companies(:first_firm) - company.clients(true) - assert_queries(0) do - company.client_ids - company.client_ids - end - end - - def test_get_ids_for_unloaded_associations_does_not_load_them - company = companies(:first_firm) - assert !company.clients.loaded? - assert_equal [companies(:first_client).id, companies(:second_client).id], company.client_ids - assert !company.clients.loaded? - end - - def test_get_ids_for_unloaded_finder_sql_associations_loads_them - company = companies(:first_firm) - assert !company.clients_using_sql.loaded? - assert_equal [companies(:second_client).id], company.clients_using_sql_ids - assert company.clients_using_sql.loaded? - end - - def test_assign_ids_ignoring_blanks - firm = Firm.create!(:name => 'Apple') - firm.client_ids = [companies(:first_client).id, nil, companies(:second_client).id, ''] - firm.save! - - assert_equal 2, firm.clients(true).size - assert firm.clients.include?(companies(:second_client)) - end - - def test_get_ids_for_through - assert_equal [comments(:eager_other_comment1).id], authors(:mary).comment_ids - end - - def test_modifying_a_through_a_has_many_should_raise - [ - lambda { authors(:mary).comment_ids = [comments(:greetings).id, comments(:more_greetings).id] }, - lambda { authors(:mary).comments = [comments(:greetings), comments(:more_greetings)] }, - lambda { authors(:mary).comments << Comment.create!(:body => "Yay", :post_id => 424242) }, - lambda { authors(:mary).comments.delete(authors(:mary).comments.first) }, - ].each {|block| assert_raise(ActiveRecord::HasManyThroughCantAssociateThroughHasManyReflection, &block) } - end - - def test_dynamic_find_should_respect_association_order_for_through - assert_equal Comment.find(10), authors(:david).comments_desc.find(:first, :conditions => "comments.type = 'SpecialComment'") - assert_equal Comment.find(10), authors(:david).comments_desc.find_by_type('SpecialComment') - end - - def test_dynamic_find_order_should_override_association_order_for_through - assert_equal Comment.find(3), authors(:david).comments_desc.find(:first, :conditions => "comments.type = 'SpecialComment'", :order => 'comments.id') - assert_equal Comment.find(3), authors(:david).comments_desc.find_by_type('SpecialComment', :order => 'comments.id') - end - - def test_dynamic_find_all_should_respect_association_order_for_through - assert_equal [Comment.find(10), Comment.find(7), Comment.find(6), Comment.find(3)], authors(:david).comments_desc.find(:all, :conditions => "comments.type = 'SpecialComment'") - assert_equal [Comment.find(10), Comment.find(7), Comment.find(6), Comment.find(3)], authors(:david).comments_desc.find_all_by_type('SpecialComment') - end - - def test_dynamic_find_all_order_should_override_association_order_for_through - assert_equal [Comment.find(3), Comment.find(6), Comment.find(7), Comment.find(10)], authors(:david).comments_desc.find(:all, :conditions => "comments.type = 'SpecialComment'", :order => 'comments.id') - assert_equal [Comment.find(3), Comment.find(6), Comment.find(7), Comment.find(10)], authors(:david).comments_desc.find_all_by_type('SpecialComment', :order => 'comments.id') - end - - def test_dynamic_find_all_should_respect_association_limit_for_through - assert_equal 1, authors(:david).limited_comments.find(:all, :conditions => "comments.type = 'SpecialComment'").length - assert_equal 1, authors(:david).limited_comments.find_all_by_type('SpecialComment').length - end - - def test_dynamic_find_all_order_should_override_association_limit_for_through - assert_equal 4, authors(:david).limited_comments.find(:all, :conditions => "comments.type = 'SpecialComment'", :limit => 9_000).length - assert_equal 4, authors(:david).limited_comments.find_all_by_type('SpecialComment', :limit => 9_000).length - end - - def test_find_all_include_over_the_same_table_for_through - assert_equal 2, people(:michael).posts.find(:all, :include => :people).length - end - - def test_has_many_through_respects_hash_conditions - assert_equal authors(:david).hello_posts, authors(:david).hello_posts_with_hash_conditions - assert_equal authors(:david).hello_post_comments, authors(:david).hello_post_comments_with_hash_conditions - end - - def test_include_uses_array_include_after_loaded - firm = companies(:first_firm) - firm.clients.class # force load target - - client = firm.clients.first - - assert_no_queries do - assert firm.clients.loaded? - assert firm.clients.include?(client) - end - end - - def test_include_checks_if_record_exists_if_target_not_loaded - firm = companies(:first_firm) - client = firm.clients.first - - firm.reload - assert ! firm.clients.loaded? - assert_queries(1) do - assert firm.clients.include?(client) - end - assert ! firm.clients.loaded? - end - - def test_include_loads_collection_if_target_uses_finder_sql - firm = companies(:first_firm) - client = firm.clients_using_sql.first - - firm.reload - assert ! firm.clients_using_sql.loaded? - assert firm.clients_using_sql.include?(client) - assert firm.clients_using_sql.loaded? - end - - - def test_include_returns_false_for_non_matching_record_to_verify_scoping - firm = companies(:first_firm) - client = Client.create!(:name => 'Not Associated') - - assert ! firm.clients.loaded? - assert ! firm.clients.include?(client) - end - - def test_calling_first_or_last_on_association_should_not_load_association - firm = companies(:first_firm) - firm.clients.first - firm.clients.last - assert !firm.clients.loaded? - end - - def test_calling_first_or_last_on_loaded_association_should_not_fetch_with_query - firm = companies(:first_firm) - firm.clients.class # force load target - assert firm.clients.loaded? - - assert_no_queries do - firm.clients.first - assert_equal 2, firm.clients.first(2).size - firm.clients.last - assert_equal 2, firm.clients.last(2).size - end - end - - def test_calling_first_or_last_on_existing_record_with_build_should_load_association - firm = companies(:first_firm) - firm.clients.build(:name => 'Foo') - assert !firm.clients.loaded? - - assert_queries 1 do - firm.clients.first - firm.clients.last - end - - assert firm.clients.loaded? - end - - def test_calling_first_or_last_on_existing_record_with_create_should_not_load_association - firm = companies(:first_firm) - firm.clients.create(:name => 'Foo') - assert !firm.clients.loaded? - - assert_queries 2 do - firm.clients.first - firm.clients.last - end - - assert !firm.clients.loaded? - end - - def test_calling_first_or_last_on_new_record_should_not_run_queries - firm = Firm.new - - assert_no_queries do - firm.clients.first - firm.clients.last - end - end - - def test_calling_first_or_last_with_find_options_on_loaded_association_should_fetch_with_query - firm = companies(:first_firm) - firm.clients.class # force load target - - assert_queries 2 do - assert firm.clients.loaded? - firm.clients.first(:order => 'name') - firm.clients.last(:order => 'name') - end - end - - def test_calling_first_or_last_with_integer_on_association_should_load_association - firm = companies(:first_firm) - - assert_queries 1 do - firm.clients.first(2) - firm.clients.last(2) - end - - assert firm.clients.loaded? - end - - def test_joins_with_namespaced_model_should_use_correct_type - old = ActiveRecord::Base.store_full_sti_class - ActiveRecord::Base.store_full_sti_class = true - - firm = Namespaced::Firm.create({ :name => 'Some Company' }) - firm.clients.create({ :name => 'Some Client' }) - - stats = Namespaced::Firm.find(firm.id, { - :select => "#{Namespaced::Firm.table_name}.id, COUNT(#{Namespaced::Client.table_name}.id) AS num_clients", - :joins => :clients, - :group => "#{Namespaced::Firm.table_name}.id" - }) - assert_equal 1, stats.num_clients.to_i - - ensure - ActiveRecord::Base.store_full_sti_class = old - end - - def test_association_proxy_transaction_method_starts_transaction_in_association_class - Comment.expects(:transaction) - Post.find(:first).comments.transaction do - # nothing - end - end - - def test_sending_new_to_association_proxy_should_have_same_effect_as_calling_new - client_association = companies(:first_firm).clients - assert_equal client_association.new.attributes, client_association.send(:new).attributes - end - - def test_respond_to_private_class_methods - client_association = companies(:first_firm).clients - assert !client_association.respond_to?(:private_method) - assert client_association.respond_to?(:private_method, true) - end - - def test_creating_using_primary_key - firm = Firm.find(:first) - client = firm.clients_using_primary_key.create!(:name => 'test') - assert_equal firm.name, client.firm_name - end -end - diff --git a/vendor/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb b/vendor/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb deleted file mode 100644 index 97efca7..0000000 --- a/vendor/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ /dev/null @@ -1,279 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/person' -require 'models/reference' -require 'models/job' -require 'models/reader' -require 'models/comment' -require 'models/tag' -require 'models/tagging' -require 'models/author' -require 'models/owner' -require 'models/pet' -require 'models/toy' - -class HasManyThroughAssociationsTest < ActiveRecord::TestCase - fixtures :posts, :readers, :people, :comments, :authors, :owners, :pets, :toys - - def test_associate_existing - assert_queries(2) { posts(:thinking);people(:david) } - - posts(:thinking).people - - assert_queries(1) do - posts(:thinking).people << people(:david) - end - - assert_queries(1) do - assert posts(:thinking).people.include?(people(:david)) - end - - assert posts(:thinking).reload.people(true).include?(people(:david)) - end - - def test_associating_new - assert_queries(1) { posts(:thinking) } - new_person = nil # so block binding catches it - - assert_queries(0) do - new_person = Person.new :first_name => 'bob' - end - - # Associating new records always saves them - # Thus, 1 query for the new person record, 1 query for the new join table record - assert_queries(2) do - posts(:thinking).people << new_person - end - - assert_queries(1) do - assert posts(:thinking).people.include?(new_person) - end - - assert posts(:thinking).reload.people(true).include?(new_person) - end - - def test_associate_new_by_building - assert_queries(1) { posts(:thinking) } - - assert_queries(0) do - posts(:thinking).people.build(:first_name=>"Bob") - posts(:thinking).people.new(:first_name=>"Ted") - end - - # Should only need to load the association once - assert_queries(1) do - assert posts(:thinking).people.collect(&:first_name).include?("Bob") - assert posts(:thinking).people.collect(&:first_name).include?("Ted") - end - - # 2 queries for each new record (1 to save the record itself, 1 for the join model) - # * 2 new records = 4 - # + 1 query to save the actual post = 5 - assert_queries(5) do - posts(:thinking).body += '-changed' - posts(:thinking).save - end - - assert posts(:thinking).reload.people(true).collect(&:first_name).include?("Bob") - assert posts(:thinking).reload.people(true).collect(&:first_name).include?("Ted") - end - - def test_delete_association - assert_queries(2){posts(:welcome);people(:michael); } - - assert_queries(1) do - posts(:welcome).people.delete(people(:michael)) - end - - assert_queries(1) do - assert posts(:welcome).people.empty? - end - - assert posts(:welcome).reload.people(true).empty? - end - - def test_destroy_association - assert_difference "Person.count", -1 do - posts(:welcome).people.destroy(people(:michael)) - end - - assert posts(:welcome).reload.people.empty? - assert posts(:welcome).people(true).empty? - end - - def test_destroy_all - assert_difference "Person.count", -1 do - posts(:welcome).people.destroy_all - end - - assert posts(:welcome).reload.people.empty? - assert posts(:welcome).people(true).empty? - end - - def test_replace_association - assert_queries(4){posts(:welcome);people(:david);people(:michael); posts(:welcome).people(true)} - - # 1 query to delete the existing reader (michael) - # 1 query to associate the new reader (david) - assert_queries(2) do - posts(:welcome).people = [people(:david)] - end - - assert_queries(0){ - assert posts(:welcome).people.include?(people(:david)) - assert !posts(:welcome).people.include?(people(:michael)) - } - - assert posts(:welcome).reload.people(true).include?(people(:david)) - assert !posts(:welcome).reload.people(true).include?(people(:michael)) - end - - def test_associate_with_create - assert_queries(1) { posts(:thinking) } - - # 1 query for the new record, 1 for the join table record - # No need to update the actual collection yet! - assert_queries(2) do - posts(:thinking).people.create(:first_name=>"Jeb") - end - - # *Now* we actually need the collection so it's loaded - assert_queries(1) do - assert posts(:thinking).people.collect(&:first_name).include?("Jeb") - end - - assert posts(:thinking).reload.people(true).collect(&:first_name).include?("Jeb") - end - - def test_associate_with_create_and_no_options - peeps = posts(:thinking).people.count - posts(:thinking).people.create(:first_name => 'foo') - assert_equal peeps + 1, posts(:thinking).people.count - end - - def test_associate_with_create_exclamation_and_no_options - peeps = posts(:thinking).people.count - posts(:thinking).people.create!(:first_name => 'foo') - assert_equal peeps + 1, posts(:thinking).people.count - end - - def test_clear_associations - assert_queries(2) { posts(:welcome);posts(:welcome).people(true) } - - assert_queries(1) do - posts(:welcome).people.clear - end - - assert_queries(0) do - assert posts(:welcome).people.empty? - end - - assert posts(:welcome).reload.people(true).empty? - end - - def test_association_callback_ordering - Post.reset_log - log = Post.log - post = posts(:thinking) - - post.people_with_callbacks << people(:michael) - assert_equal [ - [:added, :before, "Michael"], - [:added, :after, "Michael"] - ], log.last(2) - - post.people_with_callbacks.push(people(:david), Person.create!(:first_name => "Bob"), Person.new(:first_name => "Lary")) - assert_equal [ - [:added, :before, "David"], - [:added, :after, "David"], - [:added, :before, "Bob"], - [:added, :after, "Bob"], - [:added, :before, "Lary"], - [:added, :after, "Lary"] - ],log.last(6) - - post.people_with_callbacks.build(:first_name => "Ted") - assert_equal [ - [:added, :before, "Ted"], - [:added, :after, "Ted"] - ], log.last(2) - - post.people_with_callbacks.create(:first_name => "Sam") - assert_equal [ - [:added, :before, "Sam"], - [:added, :after, "Sam"] - ], log.last(2) - - post.people_with_callbacks = [people(:michael),people(:david), Person.new(:first_name => "Julian"), Person.create!(:first_name => "Roger")] - assert_equal (%w(Ted Bob Sam Lary) * 2).sort, log[-12..-5].collect(&:last).sort - assert_equal [ - [:added, :before, "Julian"], - [:added, :after, "Julian"], - [:added, :before, "Roger"], - [:added, :after, "Roger"] - ], log.last(4) - - post.people_with_callbacks.clear - assert_equal (%w(Michael David Julian Roger) * 2).sort, log.last(8).collect(&:last).sort - end - - def test_dynamic_find_should_respect_association_include - # SQL error in sort clause if :include is not included - # due to Unknown column 'comments.id' - assert Person.find(1).posts_with_comments_sorted_by_comment_id.find_by_title('Welcome to the weblog') - end - - def test_count_with_include_should_alias_join_table - assert_equal 2, people(:michael).posts.count(:include => :readers) - end - - def test_inner_join_with_quoted_table_name - assert_equal 2, people(:michael).jobs.size - end - - def test_get_ids - assert_equal [posts(:welcome).id, posts(:authorless).id].sort, people(:michael).post_ids.sort - end - - def test_get_ids_for_loaded_associations - person = people(:michael) - person.posts(true) - assert_queries(0) do - person.post_ids - person.post_ids - end - end - - def test_get_ids_for_unloaded_associations_does_not_load_them - person = people(:michael) - assert !person.posts.loaded? - assert_equal [posts(:welcome).id, posts(:authorless).id].sort, person.post_ids.sort - assert !person.posts.loaded? - end - - def test_association_proxy_transaction_method_starts_transaction_in_association_class - Tag.expects(:transaction) - Post.find(:first).tags.transaction do - # nothing - end - end - - def test_has_many_association_through_a_belongs_to_association_where_the_association_doesnt_exist - author = authors(:mary) - post = Post.create!(:title => "TITLE", :body => "BODY") - assert_equal [], post.author_favorites - end - - def test_has_many_association_through_a_belongs_to_association - author = authors(:mary) - post = Post.create!(:author => author, :title => "TITLE", :body => "BODY") - author.author_favorites.create(:favorite_author_id => 1) - author.author_favorites.create(:favorite_author_id => 2) - author.author_favorites.create(:favorite_author_id => 3) - assert_equal post.author.author_favorites, post.author_favorites - end - - def test_has_many_association_through_a_has_many_association_with_nonstandard_primary_keys - assert_equal 1, owners(:blackbeard).toys.count - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/has_one_associations_test.rb b/vendor/rails/activerecord/test/cases/associations/has_one_associations_test.rb deleted file mode 100644 index 1ddb3f4..0000000 --- a/vendor/rails/activerecord/test/cases/associations/has_one_associations_test.rb +++ /dev/null @@ -1,309 +0,0 @@ -require "cases/helper" -require 'models/developer' -require 'models/project' -require 'models/company' - -class HasOneAssociationsTest < ActiveRecord::TestCase - fixtures :accounts, :companies, :developers, :projects, :developers_projects - - def setup - Account.destroyed_account_ids.clear - end - - def test_has_one - assert_equal companies(:first_firm).account, Account.find(1) - assert_equal Account.find(1).credit_limit, companies(:first_firm).account.credit_limit - end - - def test_has_one_cache_nils - firm = companies(:another_firm) - assert_queries(1) { assert_nil firm.account } - assert_queries(0) { assert_nil firm.account } - - firms = Firm.find(:all, :include => :account) - assert_queries(0) { firms.each(&:account) } - end - - def test_with_select - assert_equal Firm.find(1).account_with_select.attributes.size, 2 - assert_equal Firm.find(1, :include => :account_with_select).account_with_select.attributes.size, 2 - end - - def test_finding_using_primary_key - firm = companies(:first_firm) - assert_equal Account.find_by_firm_id(firm.id), firm.account - firm.firm_id = companies(:rails_core).id - assert_equal accounts(:rails_core_account), firm.account_using_primary_key - end - - def test_can_marshal_has_one_association_with_nil_target - firm = Firm.new - assert_nothing_raised do - assert_equal firm.attributes, Marshal.load(Marshal.dump(firm)).attributes - end - - firm.account - assert_nothing_raised do - assert_equal firm.attributes, Marshal.load(Marshal.dump(firm)).attributes - end - end - - def test_proxy_assignment - company = companies(:first_firm) - assert_nothing_raised { company.account = company.account } - end - - def test_triple_equality - assert Account === companies(:first_firm).account - assert companies(:first_firm).account === Account - end - - def test_type_mismatch - assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).account = 1 } - assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).account = Project.find(1) } - end - - def test_natural_assignment - apple = Firm.create("name" => "Apple") - citibank = Account.create("credit_limit" => 10) - apple.account = citibank - assert_equal apple.id, citibank.firm_id - end - - def test_natural_assignment_to_nil - old_account_id = companies(:first_firm).account.id - companies(:first_firm).account = nil - companies(:first_firm).save - assert_nil companies(:first_firm).account - # account is dependent, therefore is destroyed when reference to owner is lost - assert_raise(ActiveRecord::RecordNotFound) { Account.find(old_account_id) } - end - - def test_nullification_on_association_change - firm = companies(:rails_core) - old_account_id = firm.account.id - firm.account = Account.new - # account is dependent with nullify, therefore its firm_id should be nil - assert_nil Account.find(old_account_id).firm_id - end - - def test_association_changecalls_delete - companies(:first_firm).deletable_account = Account.new - assert_equal [], Account.destroyed_account_ids[companies(:first_firm).id] - end - - def test_association_change_calls_destroy - companies(:first_firm).account = Account.new - assert_equal [companies(:first_firm).id], Account.destroyed_account_ids[companies(:first_firm).id] - end - - def test_natural_assignment_to_already_associated_record - company = companies(:first_firm) - account = accounts(:signals37) - assert_equal company.account, account - company.account = account - company.reload - account.reload - assert_equal company.account, account - end - - def test_assignment_without_replacement - apple = Firm.create("name" => "Apple") - citibank = Account.create("credit_limit" => 10) - apple.account = citibank - assert_equal apple.id, citibank.firm_id - - hsbc = apple.build_account({ :credit_limit => 20}, false) - assert_equal apple.id, hsbc.firm_id - hsbc.save - assert_equal apple.id, citibank.firm_id - - nykredit = apple.create_account({ :credit_limit => 30}, false) - assert_equal apple.id, nykredit.firm_id - assert_equal apple.id, citibank.firm_id - assert_equal apple.id, hsbc.firm_id - end - - def test_assignment_without_replacement_on_create - apple = Firm.create("name" => "Apple") - citibank = Account.create("credit_limit" => 10) - apple.account = citibank - assert_equal apple.id, citibank.firm_id - - hsbc = apple.create_account({:credit_limit => 10}, false) - assert_equal apple.id, hsbc.firm_id - hsbc.save - assert_equal apple.id, citibank.firm_id - end - - def test_dependence - num_accounts = Account.count - - firm = Firm.find(1) - assert !firm.account.nil? - account_id = firm.account.id - assert_equal [], Account.destroyed_account_ids[firm.id] - - firm.destroy - assert_equal num_accounts - 1, Account.count - assert_equal [account_id], Account.destroyed_account_ids[firm.id] - end - - def test_exclusive_dependence - num_accounts = Account.count - - firm = ExclusivelyDependentFirm.find(9) - assert !firm.account.nil? - account_id = firm.account.id - assert_equal [], Account.destroyed_account_ids[firm.id] - - firm.destroy - assert_equal num_accounts - 1, Account.count - assert_equal [], Account.destroyed_account_ids[firm.id] - end - - def test_dependence_with_nil_associate - firm = DependentFirm.new(:name => 'nullify') - firm.save! - assert_nothing_raised { firm.destroy } - end - - def test_succesful_build_association - firm = Firm.new("name" => "GlobalMegaCorp") - firm.save - - account = firm.build_account("credit_limit" => 1000) - assert account.save - assert_equal account, firm.account - end - - def test_failing_build_association - firm = Firm.new("name" => "GlobalMegaCorp") - firm.save - - account = firm.build_account - assert !account.save - assert_equal "can't be empty", account.errors.on("credit_limit") - end - - def test_build_association_twice_without_saving_affects_nothing - count_of_account = Account.count - firm = Firm.find(:first) - account1 = firm.build_account("credit_limit" => 1000) - account2 = firm.build_account("credit_limit" => 2000) - - assert_equal count_of_account, Account.count - end - - def test_create_association - firm = Firm.create(:name => "GlobalMegaCorp") - account = firm.create_account(:credit_limit => 1000) - assert_equal account, firm.reload.account - end - - def test_build - firm = Firm.new("name" => "GlobalMegaCorp") - firm.save - - firm.account = account = Account.new("credit_limit" => 1000) - assert_equal account, firm.account - assert account.save - assert_equal account, firm.account - end - - def test_failing_build_association - firm = Firm.new("name" => "GlobalMegaCorp") - firm.save - - firm.account = account = Account.new - assert_equal account, firm.account - assert !account.save - assert_equal account, firm.account - assert_equal "can't be empty", account.errors.on("credit_limit") - end - - def test_create - firm = Firm.new("name" => "GlobalMegaCorp") - firm.save - firm.account = account = Account.create("credit_limit" => 1000) - assert_equal account, firm.account - end - - def test_create_before_save - firm = Firm.new("name" => "GlobalMegaCorp") - firm.account = account = Account.create("credit_limit" => 1000) - assert_equal account, firm.account - end - - def test_dependence_with_missing_association - Account.destroy_all - firm = Firm.find(1) - assert firm.account.nil? - firm.destroy - end - - def test_dependence_with_missing_association_and_nullify - Account.destroy_all - firm = DependentFirm.find(:first) - assert firm.account.nil? - firm.destroy - end - - def test_finding_with_interpolated_condition - firm = Firm.find(:first) - superior = firm.clients.create(:name => 'SuperiorCo') - superior.rating = 10 - superior.save - assert_equal 10, firm.clients_with_interpolated_conditions.first.rating - end - - def test_assignment_before_child_saved - firm = Firm.find(1) - firm.account = a = Account.new("credit_limit" => 1000) - assert !a.new_record? - assert_equal a, firm.account - assert_equal a, firm.account - assert_equal a, firm.account(true) - end - - def test_save_still_works_after_accessing_nil_has_one - jp = Company.new :name => 'Jaded Pixel' - jp.dummy_account.nil? - - assert_nothing_raised do - jp.save! - end - end - - def test_cant_save_readonly_association - assert_raise(ActiveRecord::ReadOnlyRecord) { companies(:first_firm).readonly_account.save! } - assert companies(:first_firm).readonly_account.readonly? - end - - def test_has_one_proxy_should_not_respond_to_private_methods - assert_raise(NoMethodError) { accounts(:signals37).private_method } - assert_raise(NoMethodError) { companies(:first_firm).account.private_method } - end - - def test_has_one_proxy_should_respond_to_private_methods_via_send - accounts(:signals37).send(:private_method) - companies(:first_firm).account.send(:private_method) - end - - def test_save_of_record_with_loaded_has_one - @firm = companies(:first_firm) - assert_not_nil @firm.account - - assert_nothing_raised do - Firm.find(@firm.id).save! - Firm.find(@firm.id, :include => :account).save! - end - - @firm.account.destroy - - assert_nothing_raised do - Firm.find(@firm.id).save! - Firm.find(@firm.id, :include => :account).save! - end - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/has_one_through_associations_test.rb b/vendor/rails/activerecord/test/cases/associations/has_one_through_associations_test.rb deleted file mode 100644 index 12c5987..0000000 --- a/vendor/rails/activerecord/test/cases/associations/has_one_through_associations_test.rb +++ /dev/null @@ -1,192 +0,0 @@ -require "cases/helper" -require 'models/club' -require 'models/member_type' -require 'models/member' -require 'models/membership' -require 'models/sponsor' -require 'models/organization' -require 'models/member_detail' - -class HasOneThroughAssociationsTest < ActiveRecord::TestCase - fixtures :member_types, :members, :clubs, :memberships, :sponsors, :organizations - - def setup - @member = members(:groucho) - end - - def test_has_one_through_with_has_one - assert_equal clubs(:boring_club), @member.club - end - - def test_has_one_through_with_has_many - assert_equal clubs(:moustache_club), @member.favourite_club - end - - def test_creating_association_creates_through_record - new_member = Member.create(:name => "Chris") - new_member.club = Club.create(:name => "LRUG") - assert_not_nil new_member.current_membership - assert_not_nil new_member.club - end - - def test_replace_target_record - new_club = Club.create(:name => "Marx Bros") - @member.club = new_club - @member.reload - assert_equal new_club, @member.club - end - - def test_replacing_target_record_deletes_old_association - assert_no_difference "Membership.count" do - new_club = Club.create(:name => "Bananarama") - @member.club = new_club - @member.reload - end - end - - def test_has_one_through_polymorphic - assert_equal clubs(:moustache_club), @member.sponsor_club - end - - def has_one_through_to_has_many - assert_equal 2, @member.fellow_members.size - end - - def test_has_one_through_eager_loading - members = assert_queries(3) do #base table, through table, clubs table - Member.find(:all, :include => :club, :conditions => ["name = ?", "Groucho Marx"]) - end - assert_equal 1, members.size - assert_not_nil assert_no_queries {members[0].club} - end - - def test_has_one_through_eager_loading_through_polymorphic - members = assert_queries(3) do #base table, through table, clubs table - Member.find(:all, :include => :sponsor_club, :conditions => ["name = ?", "Groucho Marx"]) - end - assert_equal 1, members.size - assert_not_nil assert_no_queries {members[0].sponsor_club} - end - - def test_has_one_through_polymorphic_with_source_type - assert_equal members(:groucho), clubs(:moustache_club).sponsored_member - end - - def test_eager_has_one_through_polymorphic_with_source_type - clubs = Club.find(:all, :include => :sponsored_member, :conditions => ["name = ?","Moustache and Eyebrow Fancier Club"]) - # Only the eyebrow fanciers club has a sponsored_member - assert_not_nil assert_no_queries {clubs[0].sponsored_member} - end - - def test_has_one_through_nonpreload_eagerloading - members = assert_queries(1) do - Member.find(:all, :include => :club, :conditions => ["members.name = ?", "Groucho Marx"], :order => 'clubs.name') #force fallback - end - assert_equal 1, members.size - assert_not_nil assert_no_queries {members[0].club} - end - - def test_has_one_through_nonpreload_eager_loading_through_polymorphic - members = assert_queries(1) do - Member.find(:all, :include => :sponsor_club, :conditions => ["members.name = ?", "Groucho Marx"], :order => 'clubs.name') #force fallback - end - assert_equal 1, members.size - assert_not_nil assert_no_queries {members[0].sponsor_club} - end - - def test_has_one_through_nonpreload_eager_loading_through_polymorphic_with_more_than_one_through_record - Sponsor.new(:sponsor_club => clubs(:crazy_club), :sponsorable => members(:groucho)).save! - members = assert_queries(1) do - Member.find(:all, :include => :sponsor_club, :conditions => ["members.name = ?", "Groucho Marx"], :order => 'clubs.name DESC') #force fallback - end - assert_equal 1, members.size - assert_not_nil assert_no_queries { members[0].sponsor_club } - assert_equal clubs(:crazy_club), members[0].sponsor_club - end - - def test_uninitialized_has_one_through_should_return_nil_for_unsaved_record - assert_nil Member.new.club - end - - def test_assigning_association_correctly_assigns_target - new_member = Member.create(:name => "Chris") - new_member.club = new_club = Club.create(:name => "LRUG") - assert_equal new_club, new_member.club.target - end - - def test_has_one_through_proxy_should_not_respond_to_private_methods - assert_raise(NoMethodError) { clubs(:moustache_club).private_method } - assert_raise(NoMethodError) { @member.club.private_method } - end - - def test_has_one_through_proxy_should_respond_to_private_methods_via_send - clubs(:moustache_club).send(:private_method) - @member.club.send(:private_method) - end - - def test_assigning_to_has_one_through_preserves_decorated_join_record - @organization = organizations(:nsa) - assert_difference 'MemberDetail.count', 1 do - @member_detail = MemberDetail.new(:extra_data => 'Extra') - @member.member_detail = @member_detail - @member.organization = @organization - end - assert_equal @organization, @member.organization - assert @organization.members.include?(@member) - assert_equal 'Extra', @member.member_detail.extra_data - end - - def test_reassigning_has_one_through - @organization = organizations(:nsa) - @new_organization = organizations(:discordians) - - assert_difference 'MemberDetail.count', 1 do - @member_detail = MemberDetail.new(:extra_data => 'Extra') - @member.member_detail = @member_detail - @member.organization = @organization - end - assert_equal @organization, @member.organization - assert_equal 'Extra', @member.member_detail.extra_data - assert @organization.members.include?(@member) - assert !@new_organization.members.include?(@member) - - assert_no_difference 'MemberDetail.count' do - @member.organization = @new_organization - end - assert_equal @new_organization, @member.organization - assert_equal 'Extra', @member.member_detail.extra_data - assert !@organization.members.include?(@member) - assert @new_organization.members.include?(@member) - end - - def test_preloading_has_one_through_on_belongs_to - assert_not_nil @member.member_type - @organization = organizations(:nsa) - @member_detail = MemberDetail.new - @member.member_detail = @member_detail - @member.organization = @organization - @member_details = assert_queries(3) do - MemberDetail.find(:all, :include => :member_type) - end - @new_detail = @member_details[0] - assert @new_detail.loaded_member_type? - assert_not_nil assert_no_queries { @new_detail.member_type } - end - - def test_save_of_record_with_loaded_has_one_through - @club = @member.club - assert_not_nil @club.sponsored_member - - assert_nothing_raised do - Club.find(@club.id).save! - Club.find(@club.id, :include => :sponsored_member).save! - end - - @club.sponsor.destroy - - assert_nothing_raised do - Club.find(@club.id).save! - Club.find(@club.id, :include => :sponsored_member).save! - end - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/inner_join_association_test.rb b/vendor/rails/activerecord/test/cases/associations/inner_join_association_test.rb deleted file mode 100644 index f87c914..0000000 --- a/vendor/rails/activerecord/test/cases/associations/inner_join_association_test.rb +++ /dev/null @@ -1,88 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/comment' -require 'models/author' -require 'models/category' -require 'models/categorization' - -class InnerJoinAssociationTest < ActiveRecord::TestCase - fixtures :authors, :posts, :comments, :categories, :categories_posts, :categorizations - - def test_construct_finder_sql_creates_inner_joins - sql = Author.send(:construct_finder_sql, :joins => :posts) - assert_match /INNER JOIN .?posts.? ON .?posts.?.author_id = authors.id/, sql - end - - def test_construct_finder_sql_cascades_inner_joins - sql = Author.send(:construct_finder_sql, :joins => {:posts => :comments}) - assert_match /INNER JOIN .?posts.? ON .?posts.?.author_id = authors.id/, sql - assert_match /INNER JOIN .?comments.? ON .?comments.?.post_id = posts.id/, sql - end - - def test_construct_finder_sql_inner_joins_through_associations - sql = Author.send(:construct_finder_sql, :joins => :categorized_posts) - assert_match /INNER JOIN .?categorizations.?.*INNER JOIN .?posts.?/, sql - end - - def test_construct_finder_sql_applies_association_conditions - sql = Author.send(:construct_finder_sql, :joins => :categories_like_general, :conditions => "TERMINATING_MARKER") - assert_match /INNER JOIN .?categories.? ON.*AND.*.?General.?.*TERMINATING_MARKER/, sql - end - - def test_construct_finder_sql_unpacks_nested_joins - sql = Author.send(:construct_finder_sql, :joins => {:posts => [[:comments]]}) - assert_no_match /inner join.*inner join.*inner join/i, sql, "only two join clauses should be present" - assert_match /INNER JOIN .?posts.? ON .?posts.?.author_id = authors.id/, sql - assert_match /INNER JOIN .?comments.? ON .?comments.?.post_id = .?posts.?.id/, sql - end - - def test_construct_finder_sql_ignores_empty_joins_hash - sql = Author.send(:construct_finder_sql, :joins => {}) - assert_no_match /JOIN/i, sql - end - - def test_construct_finder_sql_ignores_empty_joins_array - sql = Author.send(:construct_finder_sql, :joins => []) - assert_no_match /JOIN/i, sql - end - - def test_find_with_implicit_inner_joins_honors_readonly_without_select - authors = Author.find(:all, :joins => :posts) - assert !authors.empty?, "expected authors to be non-empty" - assert authors.all? {|a| a.readonly? }, "expected all authors to be readonly" - end - - def test_find_with_implicit_inner_joins_honors_readonly_with_select - authors = Author.find(:all, :select => 'authors.*', :joins => :posts) - assert !authors.empty?, "expected authors to be non-empty" - assert authors.all? {|a| !a.readonly? }, "expected no authors to be readonly" - end - - def test_find_with_implicit_inner_joins_honors_readonly_false - authors = Author.find(:all, :joins => :posts, :readonly => false) - assert !authors.empty?, "expected authors to be non-empty" - assert authors.all? {|a| !a.readonly? }, "expected no authors to be readonly" - end - - def test_find_with_implicit_inner_joins_does_not_set_associations - authors = Author.find(:all, :select => 'authors.*', :joins => :posts) - assert !authors.empty?, "expected authors to be non-empty" - assert authors.all? {|a| !a.send(:instance_variable_names).include?("@posts")}, "expected no authors to have the @posts association loaded" - end - - def test_count_honors_implicit_inner_joins - real_count = Author.find(:all).sum{|a| a.posts.count } - assert_equal real_count, Author.count(:joins => :posts), "plain inner join count should match the number of referenced posts records" - end - - def test_calculate_honors_implicit_inner_joins - real_count = Author.find(:all).sum{|a| a.posts.count } - assert_equal real_count, Author.calculate(:count, 'authors.id', :joins => :posts), "plain inner join count should match the number of referenced posts records" - end - - def test_calculate_honors_implicit_inner_joins_and_distinct_and_conditions - real_count = Author.find(:all).select {|a| a.posts.any? {|p| p.title =~ /^Welcome/} }.length - authors_with_welcoming_post_titles = Author.calculate(:count, 'authors.id', :joins => :posts, :distinct => true, :conditions => "posts.title like 'Welcome%'") - assert_equal real_count, authors_with_welcoming_post_titles, "inner join and conditions should have only returned authors posting titles starting with 'Welcome'" - end -end diff --git a/vendor/rails/activerecord/test/cases/associations/join_model_test.rb b/vendor/rails/activerecord/test/cases/associations/join_model_test.rb deleted file mode 100644 index b1060d0..0000000 --- a/vendor/rails/activerecord/test/cases/associations/join_model_test.rb +++ /dev/null @@ -1,712 +0,0 @@ -require "cases/helper" -require 'models/tag' -require 'models/tagging' -require 'models/post' -require 'models/item' -require 'models/comment' -require 'models/author' -require 'models/category' -require 'models/categorization' -require 'models/vertex' -require 'models/edge' -require 'models/book' -require 'models/citation' - -class AssociationsJoinModelTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - fixtures :posts, :authors, :categories, :categorizations, :comments, :tags, :taggings, :author_favorites, :vertices, :items, :books - - def test_has_many - assert authors(:david).categories.include?(categories(:general)) - end - - def test_has_many_inherited - assert authors(:mary).categories.include?(categories(:sti_test)) - end - - def test_inherited_has_many - assert categories(:sti_test).authors.include?(authors(:mary)) - end - - def test_has_many_uniq_through_join_model - assert_equal 2, authors(:mary).categorized_posts.size - assert_equal 1, authors(:mary).unique_categorized_posts.size - end - - def test_has_many_uniq_through_count - author = authors(:mary) - assert !authors(:mary).unique_categorized_posts.loaded? - assert_queries(1) { assert_equal 1, author.unique_categorized_posts.count } - assert_queries(1) { assert_equal 1, author.unique_categorized_posts.count(:title) } - assert_queries(1) { assert_equal 0, author.unique_categorized_posts.count(:title, :conditions => "title is NULL") } - assert !authors(:mary).unique_categorized_posts.loaded? - end - - def test_has_many_uniq_through_find - assert_equal 1, authors(:mary).unique_categorized_posts.find(:all).size - end - - def test_has_many_uniq_through_dynamic_find - assert_equal 1, authors(:mary).unique_categorized_posts.find_all_by_title("So I was thinking").size - end - - def test_polymorphic_has_many - assert posts(:welcome).taggings.include?(taggings(:welcome_general)) - end - - def test_polymorphic_has_one - assert_equal taggings(:welcome_general), posts(:welcome).tagging - end - - def test_polymorphic_belongs_to - assert_equal posts(:welcome), posts(:welcome).taggings.first.taggable - end - - def test_polymorphic_has_many_going_through_join_model - assert_equal tags(:general), tag = posts(:welcome).tags.first - assert_no_queries do - tag.tagging - end - end - - def test_count_polymorphic_has_many - assert_equal 1, posts(:welcome).taggings.count - assert_equal 1, posts(:welcome).tags.count - end - - def test_polymorphic_has_many_going_through_join_model_with_find - assert_equal tags(:general), tag = posts(:welcome).tags.find(:first) - assert_no_queries do - tag.tagging - end - end - - def test_polymorphic_has_many_going_through_join_model_with_include_on_source_reflection - assert_equal tags(:general), tag = posts(:welcome).funky_tags.first - assert_no_queries do - tag.tagging - end - end - - def test_polymorphic_has_many_going_through_join_model_with_include_on_source_reflection_with_find - assert_equal tags(:general), tag = posts(:welcome).funky_tags.find(:first) - assert_no_queries do - tag.tagging - end - end - - def test_polymorphic_has_many_going_through_join_model_with_disabled_include - assert_equal tags(:general), tag = posts(:welcome).tags.add_joins_and_select.first - assert_queries 1 do - tag.tagging - end - end - - def test_polymorphic_has_many_going_through_join_model_with_custom_select_and_joins - assert_equal tags(:general), tag = posts(:welcome).tags.add_joins_and_select.first - tag.author_id - end - - def test_polymorphic_has_many_going_through_join_model_with_custom_foreign_key - assert_equal tags(:misc), taggings(:welcome_general).super_tag - assert_equal tags(:misc), posts(:welcome).super_tags.first - end - - def test_polymorphic_has_many_create_model_with_inheritance_and_custom_base_class - post = SubStiPost.create :title => 'SubStiPost', :body => 'SubStiPost body' - assert_instance_of SubStiPost, post - - tagging = tags(:misc).taggings.create(:taggable => post) - assert_equal "SubStiPost", tagging.taggable_type - end - - def test_polymorphic_has_many_going_through_join_model_with_inheritance - assert_equal tags(:general), posts(:thinking).tags.first - end - - def test_polymorphic_has_many_going_through_join_model_with_inheritance_with_custom_class_name - assert_equal tags(:general), posts(:thinking).funky_tags.first - end - - def test_polymorphic_has_many_create_model_with_inheritance - post = posts(:thinking) - assert_instance_of SpecialPost, post - - tagging = tags(:misc).taggings.create(:taggable => post) - assert_equal "Post", tagging.taggable_type - end - - def test_polymorphic_has_one_create_model_with_inheritance - tagging = tags(:misc).create_tagging(:taggable => posts(:thinking)) - assert_equal "Post", tagging.taggable_type - end - - def test_set_polymorphic_has_many - tagging = tags(:misc).taggings.create - posts(:thinking).taggings << tagging - assert_equal "Post", tagging.taggable_type - end - - def test_set_polymorphic_has_one - tagging = tags(:misc).taggings.create - posts(:thinking).tagging = tagging - assert_equal "Post", tagging.taggable_type - end - - def test_create_polymorphic_has_many_with_scope - old_count = posts(:welcome).taggings.count - tagging = posts(:welcome).taggings.create(:tag => tags(:misc)) - assert_equal "Post", tagging.taggable_type - assert_equal old_count+1, posts(:welcome).taggings.count - end - - def test_create_bang_polymorphic_with_has_many_scope - old_count = posts(:welcome).taggings.count - tagging = posts(:welcome).taggings.create!(:tag => tags(:misc)) - assert_equal "Post", tagging.taggable_type - assert_equal old_count+1, posts(:welcome).taggings.count - end - - def test_create_polymorphic_has_one_with_scope - old_count = Tagging.count - tagging = posts(:welcome).tagging.create(:tag => tags(:misc)) - assert_equal "Post", tagging.taggable_type - assert_equal old_count+1, Tagging.count - end - - def test_delete_polymorphic_has_many_with_delete_all - assert_equal 1, posts(:welcome).taggings.count - posts(:welcome).taggings.first.update_attribute :taggable_type, 'PostWithHasManyDeleteAll' - post = find_post_with_dependency(1, :has_many, :taggings, :delete_all) - - old_count = Tagging.count - post.destroy - assert_equal old_count-1, Tagging.count - assert_equal 0, posts(:welcome).taggings.count - end - - def test_delete_polymorphic_has_many_with_destroy - assert_equal 1, posts(:welcome).taggings.count - posts(:welcome).taggings.first.update_attribute :taggable_type, 'PostWithHasManyDestroy' - post = find_post_with_dependency(1, :has_many, :taggings, :destroy) - - old_count = Tagging.count - post.destroy - assert_equal old_count-1, Tagging.count - assert_equal 0, posts(:welcome).taggings.count - end - - def test_delete_polymorphic_has_many_with_nullify - assert_equal 1, posts(:welcome).taggings.count - posts(:welcome).taggings.first.update_attribute :taggable_type, 'PostWithHasManyNullify' - post = find_post_with_dependency(1, :has_many, :taggings, :nullify) - - old_count = Tagging.count - post.destroy - assert_equal old_count, Tagging.count - assert_equal 0, posts(:welcome).taggings.count - end - - def test_delete_polymorphic_has_one_with_destroy - assert posts(:welcome).tagging - posts(:welcome).tagging.update_attribute :taggable_type, 'PostWithHasOneDestroy' - post = find_post_with_dependency(1, :has_one, :tagging, :destroy) - - old_count = Tagging.count - post.destroy - assert_equal old_count-1, Tagging.count - assert_nil posts(:welcome).tagging(true) - end - - def test_delete_polymorphic_has_one_with_nullify - assert posts(:welcome).tagging - posts(:welcome).tagging.update_attribute :taggable_type, 'PostWithHasOneNullify' - post = find_post_with_dependency(1, :has_one, :tagging, :nullify) - - old_count = Tagging.count - post.destroy - assert_equal old_count, Tagging.count - assert_nil posts(:welcome).tagging(true) - end - - def test_has_many_with_piggyback - assert_equal "2", categories(:sti_test).authors.first.post_id.to_s - end - - def test_include_has_many_through - posts = Post.find(:all, :order => 'posts.id') - posts_with_authors = Post.find(:all, :include => :authors, :order => 'posts.id') - assert_equal posts.length, posts_with_authors.length - posts.length.times do |i| - assert_equal posts[i].authors.length, assert_no_queries { posts_with_authors[i].authors.length } - end - end - - def test_include_polymorphic_has_one - post = Post.find_by_id(posts(:welcome).id, :include => :tagging) - tagging = taggings(:welcome_general) - assert_no_queries do - assert_equal tagging, post.tagging - end - end - - def test_include_polymorphic_has_one_defined_in_abstract_parent - item = Item.find_by_id(items(:dvd).id, :include => :tagging) - tagging = taggings(:godfather) - assert_no_queries do - assert_equal tagging, item.tagging - end - end - - def test_include_polymorphic_has_many_through - posts = Post.find(:all, :order => 'posts.id') - posts_with_tags = Post.find(:all, :include => :tags, :order => 'posts.id') - assert_equal posts.length, posts_with_tags.length - posts.length.times do |i| - assert_equal posts[i].tags.length, assert_no_queries { posts_with_tags[i].tags.length } - end - end - - def test_include_polymorphic_has_many - posts = Post.find(:all, :order => 'posts.id') - posts_with_taggings = Post.find(:all, :include => :taggings, :order => 'posts.id') - assert_equal posts.length, posts_with_taggings.length - posts.length.times do |i| - assert_equal posts[i].taggings.length, assert_no_queries { posts_with_taggings[i].taggings.length } - end - end - - def test_has_many_find_all - assert_equal [categories(:general)], authors(:david).categories.find(:all) - end - - def test_has_many_find_first - assert_equal categories(:general), authors(:david).categories.find(:first) - end - - def test_has_many_with_hash_conditions - assert_equal categories(:general), authors(:david).categories_like_general.find(:first) - end - - def test_has_many_find_conditions - assert_equal categories(:general), authors(:david).categories.find(:first, :conditions => "categories.name = 'General'") - assert_equal nil, authors(:david).categories.find(:first, :conditions => "categories.name = 'Technology'") - end - - def test_has_many_class_methods_called_by_method_missing - assert_equal categories(:general), authors(:david).categories.find_all_by_name('General').first - assert_equal nil, authors(:david).categories.find_by_name('Technology') - end - - def test_has_many_array_methods_called_by_method_missing - assert true, authors(:david).categories.any? { |category| category.name == 'General' } - assert_nothing_raised { authors(:david).categories.sort } - end - - def test_has_many_going_through_join_model_with_custom_foreign_key - assert_equal [], posts(:thinking).authors - assert_equal [authors(:mary)], posts(:authorless).authors - end - - def test_both_scoped_and_explicit_joins_should_be_respected - assert_nothing_raised do - Post.send(:with_scope, :find => {:joins => "left outer join comments on comments.id = posts.id"}) do - Post.find :all, :select => "comments.id, authors.id", :joins => "left outer join authors on authors.id = posts.author_id" - end - end - end - - def test_belongs_to_polymorphic_with_counter_cache - assert_equal 0, posts(:welcome)[:taggings_count] - tagging = posts(:welcome).taggings.create(:tag => tags(:general)) - assert_equal 1, posts(:welcome, :reload)[:taggings_count] - tagging.destroy - assert posts(:welcome, :reload)[:taggings_count].zero? - end - - def test_unavailable_through_reflection - assert_raise(ActiveRecord::HasManyThroughAssociationNotFoundError) { authors(:david).nothings } - end - - def test_has_many_through_join_model_with_conditions - assert_equal [], posts(:welcome).invalid_taggings - assert_equal [], posts(:welcome).invalid_tags - end - - def test_has_many_polymorphic - assert_raise ActiveRecord::HasManyThroughAssociationPolymorphicError do - assert_equal posts(:welcome, :thinking), tags(:general).taggables - end - assert_raise ActiveRecord::EagerLoadPolymorphicError do - assert_equal posts(:welcome, :thinking), tags(:general).taggings.find(:all, :include => :taggable, :conditions => 'bogus_table.column = 1') - end - end - - def test_has_many_polymorphic_with_source_type - assert_equal posts(:welcome, :thinking), tags(:general).tagged_posts - end - - def test_eager_has_many_polymorphic_with_source_type - tag_with_include = Tag.find(tags(:general).id, :include => :tagged_posts) - desired = posts(:welcome, :thinking) - assert_no_queries do - assert_equal desired, tag_with_include.tagged_posts - end - assert_equal 5, tag_with_include.taggings.length - end - - def test_has_many_through_has_many_find_all - assert_equal comments(:greetings), authors(:david).comments.find(:all, :order => 'comments.id').first - end - - def test_has_many_through_has_many_find_all_with_custom_class - assert_equal comments(:greetings), authors(:david).funky_comments.find(:all, :order => 'comments.id').first - end - - def test_has_many_through_has_many_find_first - assert_equal comments(:greetings), authors(:david).comments.find(:first, :order => 'comments.id') - end - - def test_has_many_through_has_many_find_conditions - options = { :conditions => "comments.#{QUOTED_TYPE}='SpecialComment'", :order => 'comments.id' } - assert_equal comments(:does_it_hurt), authors(:david).comments.find(:first, options) - end - - def test_has_many_through_has_many_find_by_id - assert_equal comments(:more_greetings), authors(:david).comments.find(2) - end - - def test_has_many_through_polymorphic_has_one - assert_raise(ActiveRecord::HasManyThroughSourceAssociationMacroError) { authors(:david).tagging } - end - - def test_has_many_through_polymorphic_has_many - assert_equal taggings(:welcome_general, :thinking_general), authors(:david).taggings.uniq.sort_by { |t| t.id } - end - - def test_include_has_many_through_polymorphic_has_many - author = Author.find_by_id(authors(:david).id, :include => :taggings) - expected_taggings = taggings(:welcome_general, :thinking_general) - assert_no_queries do - assert_equal expected_taggings, author.taggings.uniq.sort_by { |t| t.id } - end - end - - def test_has_many_through_has_many_through - assert_raise(ActiveRecord::HasManyThroughSourceAssociationMacroError) { authors(:david).tags } - end - - def test_has_many_through_habtm - assert_raise(ActiveRecord::HasManyThroughSourceAssociationMacroError) { authors(:david).post_categories } - end - - def test_eager_load_has_many_through_has_many - author = Author.find :first, :conditions => ['name = ?', 'David'], :include => :comments, :order => 'comments.id' - SpecialComment.new; VerySpecialComment.new - assert_no_queries do - assert_equal [1,2,3,5,6,7,8,9,10], author.comments.collect(&:id) - end - end - - def test_eager_load_has_many_through_has_many_with_conditions - post = Post.find(:first, :include => :invalid_tags) - assert_no_queries do - post.invalid_tags - end - end - - def test_eager_belongs_to_and_has_one_not_singularized - assert_nothing_raised do - Author.find(:first, :include => :author_address) - AuthorAddress.find(:first, :include => :author) - end - end - - def test_self_referential_has_many_through - assert_equal [authors(:mary)], authors(:david).favorite_authors - assert_equal [], authors(:mary).favorite_authors - end - - def test_add_to_self_referential_has_many_through - new_author = Author.create(:name => "Bob") - authors(:david).author_favorites.create :favorite_author => new_author - assert_equal new_author, authors(:david).reload.favorite_authors.first - end - - def test_has_many_through_uses_conditions_specified_on_the_has_many_association - author = Author.find(:first) - assert !author.comments.blank? - assert author.nonexistant_comments.blank? - end - - def test_has_many_through_uses_correct_attributes - assert_nil posts(:thinking).tags.find_by_name("General").attributes["tag_id"] - end - - def test_associating_unsaved_records_with_has_many_through - saved_post = posts(:thinking) - new_tag = Tag.new(:name => "new") - - saved_post.tags << new_tag - assert !new_tag.new_record? #consistent with habtm! - assert !saved_post.new_record? - assert saved_post.tags.include?(new_tag) - - assert !new_tag.new_record? - assert saved_post.reload.tags(true).include?(new_tag) - - - new_post = Post.new(:title => "Association replacmenet works!", :body => "You best believe it.") - saved_tag = tags(:general) - - new_post.tags << saved_tag - assert new_post.new_record? - assert !saved_tag.new_record? - assert new_post.tags.include?(saved_tag) - - new_post.save! - assert !new_post.new_record? - assert new_post.reload.tags(true).include?(saved_tag) - - assert posts(:thinking).tags.build.new_record? - assert posts(:thinking).tags.new.new_record? - end - - def test_create_associate_when_adding_to_has_many_through - count = posts(:thinking).tags.count - push = Tag.create!(:name => 'pushme') - post_thinking = posts(:thinking) - assert_nothing_raised { post_thinking.tags << push } - assert_nil( wrong = post_thinking.tags.detect { |t| t.class != Tag }, - message = "Expected a Tag in tags collection, got #{wrong.class}.") - assert_nil( wrong = post_thinking.taggings.detect { |t| t.class != Tagging }, - message = "Expected a Tagging in taggings collection, got #{wrong.class}.") - assert_equal(count + 1, post_thinking.tags.size) - assert_equal(count + 1, post_thinking.tags(true).size) - - assert_kind_of Tag, post_thinking.tags.create!(:name => 'foo') - assert_nil( wrong = post_thinking.tags.detect { |t| t.class != Tag }, - message = "Expected a Tag in tags collection, got #{wrong.class}.") - assert_nil( wrong = post_thinking.taggings.detect { |t| t.class != Tagging }, - message = "Expected a Tagging in taggings collection, got #{wrong.class}.") - assert_equal(count + 2, post_thinking.tags.size) - assert_equal(count + 2, post_thinking.tags(true).size) - - assert_nothing_raised { post_thinking.tags.concat(Tag.create!(:name => 'abc'), Tag.create!(:name => 'def')) } - assert_nil( wrong = post_thinking.tags.detect { |t| t.class != Tag }, - message = "Expected a Tag in tags collection, got #{wrong.class}.") - assert_nil( wrong = post_thinking.taggings.detect { |t| t.class != Tagging }, - message = "Expected a Tagging in taggings collection, got #{wrong.class}.") - assert_equal(count + 4, post_thinking.tags.size) - assert_equal(count + 4, post_thinking.tags(true).size) - - # Raises if the wrong reflection name is used to set the Edge belongs_to - assert_nothing_raised { vertices(:vertex_1).sinks << vertices(:vertex_5) } - end - - def test_has_many_through_collection_size_doesnt_load_target_if_not_loaded - author = authors(:david) - assert_equal 9, author.comments.size - assert !author.comments.loaded? - end - - def test_has_many_through_collection_size_uses_counter_cache_if_it_exists - author = authors(:david) - author.stubs(:read_attribute).with('comments_count').returns(100) - assert_equal 100, author.comments.size - assert !author.comments.loaded? - end - - def test_adding_junk_to_has_many_through_should_raise_type_mismatch - assert_raise(ActiveRecord::AssociationTypeMismatch) { posts(:thinking).tags << "Uhh what now?" } - end - - def test_adding_to_has_many_through_should_return_self - tags = posts(:thinking).tags - assert_equal tags, posts(:thinking).tags.push(tags(:general)) - end - - def test_delete_associate_when_deleting_from_has_many_through_with_nonstandard_id - count = books(:awdr).references.count - references_before = books(:awdr).references - book = Book.create!(:name => 'Getting Real') - book_awdr = books(:awdr) - book_awdr.references << book - assert_equal(count + 1, book_awdr.references(true).size) - - assert_nothing_raised { book_awdr.references.delete(book) } - assert_equal(count, book_awdr.references.size) - assert_equal(count, book_awdr.references(true).size) - assert_equal(references_before.sort, book_awdr.references.sort) - end - - def test_delete_associate_when_deleting_from_has_many_through - count = posts(:thinking).tags.count - tags_before = posts(:thinking).tags - tag = Tag.create!(:name => 'doomed') - post_thinking = posts(:thinking) - post_thinking.tags << tag - assert_equal(count + 1, post_thinking.taggings(true).size) - assert_equal(count + 1, post_thinking.tags(true).size) - - assert_nothing_raised { post_thinking.tags.delete(tag) } - assert_equal(count, post_thinking.tags.size) - assert_equal(count, post_thinking.tags(true).size) - assert_equal(count, post_thinking.taggings(true).size) - assert_equal(tags_before.sort, post_thinking.tags.sort) - end - - def test_delete_associate_when_deleting_from_has_many_through_with_multiple_tags - count = posts(:thinking).tags.count - tags_before = posts(:thinking).tags - doomed = Tag.create!(:name => 'doomed') - doomed2 = Tag.create!(:name => 'doomed2') - quaked = Tag.create!(:name => 'quaked') - post_thinking = posts(:thinking) - post_thinking.tags << doomed << doomed2 - assert_equal(count + 2, post_thinking.tags(true).size) - - assert_nothing_raised { post_thinking.tags.delete(doomed, doomed2, quaked) } - assert_equal(count, post_thinking.tags.size) - assert_equal(count, post_thinking.tags(true).size) - assert_equal(tags_before.sort, post_thinking.tags.sort) - end - - def test_deleting_junk_from_has_many_through_should_raise_type_mismatch - assert_raise(ActiveRecord::AssociationTypeMismatch) { posts(:thinking).tags.delete("Uhh what now?") } - end - - def test_has_many_through_sum_uses_calculations - assert_nothing_raised { authors(:david).comments.sum(:post_id) } - end - - def test_calculations_on_has_many_through_should_disambiguate_fields - assert_nothing_raised { authors(:david).categories.maximum(:id) } - end - - def test_calculations_on_has_many_through_should_not_disambiguate_fields_unless_necessary - assert_nothing_raised { authors(:david).categories.maximum("categories.id") } - end - - def test_has_many_through_has_many_with_sti - assert_equal [comments(:does_it_hurt)], authors(:david).special_post_comments - end - - def test_uniq_has_many_through_should_retain_order - comment_ids = authors(:david).comments.map(&:id) - assert_equal comment_ids.sort, authors(:david).ordered_uniq_comments.map(&:id) - assert_equal comment_ids.sort.reverse, authors(:david).ordered_uniq_comments_desc.map(&:id) - end - - def test_polymorphic_has_many - expected = taggings(:welcome_general) - p = Post.find(posts(:welcome).id, :include => :taggings) - assert_no_queries {assert p.taggings.include?(expected)} - assert posts(:welcome).taggings.include?(taggings(:welcome_general)) - end - - def test_polymorphic_has_one - expected = posts(:welcome) - - tagging = Tagging.find(taggings(:welcome_general).id, :include => :taggable) - assert_no_queries { assert_equal expected, tagging.taggable} - end - - def test_polymorphic_belongs_to - p = Post.find(posts(:welcome).id, :include => {:taggings => :taggable}) - assert_no_queries {assert_equal posts(:welcome), p.taggings.first.taggable} - end - - def test_preload_polymorphic_has_many_through - posts = Post.find(:all, :order => 'posts.id') - posts_with_tags = Post.find(:all, :include => :tags, :order => 'posts.id') - assert_equal posts.length, posts_with_tags.length - posts.length.times do |i| - assert_equal posts[i].tags.length, assert_no_queries { posts_with_tags[i].tags.length } - end - end - - def test_preload_polymorph_many_types - taggings = Tagging.find :all, :include => :taggable, :conditions => ['taggable_type != ?', 'FakeModel'] - assert_no_queries do - taggings.first.taggable.id - taggings[1].taggable.id - end - - taggables = taggings.map(&:taggable) - assert taggables.include?(items(:dvd)) - assert taggables.include?(posts(:welcome)) - end - - def test_preload_nil_polymorphic_belongs_to - assert_nothing_raised do - taggings = Tagging.find(:all, :include => :taggable, :conditions => ['taggable_type IS NULL']) - end - end - - def test_preload_polymorphic_has_many - posts = Post.find(:all, :order => 'posts.id') - posts_with_taggings = Post.find(:all, :include => :taggings, :order => 'posts.id') - assert_equal posts.length, posts_with_taggings.length - posts.length.times do |i| - assert_equal posts[i].taggings.length, assert_no_queries { posts_with_taggings[i].taggings.length } - end - end - - def test_belongs_to_shared_parent - comments = Comment.find(:all, :include => :post, :conditions => 'post_id = 1') - assert_no_queries do - assert_equal comments.first.post, comments[1].post - end - end - - def test_has_many_through_include_uses_array_include_after_loaded - david = authors(:david) - david.categories.class # force load target - - category = david.categories.first - - assert_no_queries do - assert david.categories.loaded? - assert david.categories.include?(category) - end - end - - def test_has_many_through_include_checks_if_record_exists_if_target_not_loaded - david = authors(:david) - category = david.categories.first - - david.reload - assert ! david.categories.loaded? - assert_queries(1) do - assert david.categories.include?(category) - end - assert ! david.categories.loaded? - end - - def test_has_many_through_include_returns_false_for_non_matching_record_to_verify_scoping - david = authors(:david) - category = Category.create!(:name => 'Not Associated') - - assert ! david.categories.loaded? - assert ! david.categories.include?(category) - end - - def test_has_many_through_goes_through_all_sti_classes - sub_sti_post = SubStiPost.create!(:title => 'test', :body => 'test', :author_id => 1) - new_comment = sub_sti_post.comments.create(:body => 'test') - - assert_equal [9, 10, new_comment.id], authors(:david).sti_post_comments.map(&:id).sort - end - - private - # create dynamic Post models to allow different dependency options - def find_post_with_dependency(post_id, association, association_name, dependency) - class_name = "PostWith#{association.to_s.classify}#{dependency.to_s.classify}" - Post.find(post_id).update_attribute :type, class_name - klass = Object.const_set(class_name, Class.new(ActiveRecord::Base)) - klass.set_table_name 'posts' - klass.send(association, association_name, :as => :taggable, :dependent => dependency) - klass.find(post_id) - end -end diff --git a/vendor/rails/activerecord/test/cases/associations_test.rb b/vendor/rails/activerecord/test/cases/associations_test.rb deleted file mode 100644 index 056a294..0000000 --- a/vendor/rails/activerecord/test/cases/associations_test.rb +++ /dev/null @@ -1,262 +0,0 @@ -require "cases/helper" -require 'models/developer' -require 'models/project' -require 'models/company' -require 'models/topic' -require 'models/reply' -require 'models/computer' -require 'models/customer' -require 'models/order' -require 'models/categorization' -require 'models/category' -require 'models/post' -require 'models/author' -require 'models/comment' -require 'models/tag' -require 'models/tagging' -require 'models/person' -require 'models/reader' -require 'models/parrot' -require 'models/pirate' -require 'models/treasure' -require 'models/price_estimate' -require 'models/club' -require 'models/member' -require 'models/membership' -require 'models/sponsor' - -class AssociationsTest < ActiveRecord::TestCase - fixtures :accounts, :companies, :developers, :projects, :developers_projects, - :computers, :people, :readers - - def test_include_with_order_works - assert_nothing_raised {Account.find(:first, :order => 'id', :include => :firm)} - assert_nothing_raised {Account.find(:first, :order => :id, :include => :firm)} - end - - def test_bad_collection_keys - assert_raise(ArgumentError, 'ActiveRecord should have barked on bad collection keys') do - Class.new(ActiveRecord::Base).has_many(:wheels, :name => 'wheels') - end - end - - def test_should_construct_new_finder_sql_after_create - person = Person.new :first_name => 'clark' - assert_equal [], person.readers.find(:all) - person.save! - reader = Reader.create! :person => person, :post => Post.new(:title => "foo", :body => "bar") - assert person.readers.find(reader.id) - end - - def test_force_reload - firm = Firm.new("name" => "A New Firm, Inc") - firm.save - firm.clients.each {|c|} # forcing to load all clients - assert firm.clients.empty?, "New firm shouldn't have client objects" - assert_equal 0, firm.clients.size, "New firm should have 0 clients" - - client = Client.new("name" => "TheClient.com", "firm_id" => firm.id) - client.save - - assert firm.clients.empty?, "New firm should have cached no client objects" - assert_equal 0, firm.clients.size, "New firm should have cached 0 clients count" - - assert !firm.clients(true).empty?, "New firm should have reloaded client objects" - assert_equal 1, firm.clients(true).size, "New firm should have reloaded clients count" - end - - def test_storing_in_pstore - require "tmpdir" - store_filename = File.join(Dir.tmpdir, "ar-pstore-association-test") - File.delete(store_filename) if File.exist?(store_filename) - require "pstore" - apple = Firm.create("name" => "Apple") - natural = Client.new("name" => "Natural Company") - apple.clients << natural - - db = PStore.new(store_filename) - db.transaction do - db["apple"] = apple - end - - db = PStore.new(store_filename) - db.transaction do - assert_equal "Natural Company", db["apple"].clients.first.name - end - end -end - -class AssociationProxyTest < ActiveRecord::TestCase - fixtures :authors, :posts, :categorizations, :categories, :developers, :projects, :developers_projects - - def test_proxy_accessors - welcome = posts(:welcome) - assert_equal welcome, welcome.author.proxy_owner - assert_equal welcome.class.reflect_on_association(:author), welcome.author.proxy_reflection - welcome.author.class # force load target - assert_equal welcome.author, welcome.author.proxy_target - - david = authors(:david) - assert_equal david, david.posts.proxy_owner - assert_equal david.class.reflect_on_association(:posts), david.posts.proxy_reflection - david.posts.class # force load target - assert_equal david.posts, david.posts.proxy_target - - assert_equal david, david.posts_with_extension.testing_proxy_owner - assert_equal david.class.reflect_on_association(:posts_with_extension), david.posts_with_extension.testing_proxy_reflection - david.posts_with_extension.class # force load target - assert_equal david.posts_with_extension, david.posts_with_extension.testing_proxy_target - end - - def test_push_does_not_load_target - david = authors(:david) - - david.posts << (post = Post.new(:title => "New on Edge", :body => "More cool stuff!")) - assert !david.posts.loaded? - assert david.posts.include?(post) - end - - def test_push_has_many_through_does_not_load_target - david = authors(:david) - - david.categories << categories(:technology) - assert !david.categories.loaded? - assert david.categories.include?(categories(:technology)) - end - - def test_push_followed_by_save_does_not_load_target - david = authors(:david) - - david.posts << (post = Post.new(:title => "New on Edge", :body => "More cool stuff!")) - assert !david.posts.loaded? - david.save - assert !david.posts.loaded? - assert david.posts.include?(post) - end - - def test_push_does_not_lose_additions_to_new_record - josh = Author.new(:name => "Josh") - josh.posts << Post.new(:title => "New on Edge", :body => "More cool stuff!") - assert josh.posts.loaded? - assert_equal 1, josh.posts.size - end - - def test_save_on_parent_does_not_load_target - david = developers(:david) - - assert !david.projects.loaded? - david.update_attribute(:created_at, Time.now) - assert !david.projects.loaded? - end - - def test_inspect_does_not_reload_a_not_yet_loaded_target - andreas = Developer.new :name => 'Andreas', :log => 'new developer added' - assert !andreas.audit_logs.loaded? - assert_match(/message: "new developer added"/, andreas.audit_logs.inspect) - end - - def test_save_on_parent_saves_children - developer = Developer.create :name => "Bryan", :salary => 50_000 - assert_equal 1, developer.reload.audit_logs.size - end - - def test_create_via_association_with_block - post = authors(:david).posts.create(:title => "New on Edge") {|p| p.body = "More cool stuff!"} - assert_equal post.title, "New on Edge" - assert_equal post.body, "More cool stuff!" - end - - def test_create_with_bang_via_association_with_block - post = authors(:david).posts.create!(:title => "New on Edge") {|p| p.body = "More cool stuff!"} - assert_equal post.title, "New on Edge" - assert_equal post.body, "More cool stuff!" - end - - def test_failed_reload_returns_nil - p = setup_dangling_association - assert_nil p.author.reload - end - - def test_failed_reset_returns_nil - p = setup_dangling_association - assert_nil p.author.reset - end - - def test_reload_returns_assocition - david = developers(:david) - assert_nothing_raised do - assert_equal david.projects, david.projects.reload.reload - end - end - - def setup_dangling_association - josh = Author.create(:name => "Josh") - p = Post.create(:title => "New on Edge", :body => "More cool stuff!", :author => josh) - josh.destroy - p - end -end - -class OverridingAssociationsTest < ActiveRecord::TestCase - class Person < ActiveRecord::Base; end - class DifferentPerson < ActiveRecord::Base; end - - class PeopleList < ActiveRecord::Base - has_and_belongs_to_many :has_and_belongs_to_many, :before_add => :enlist - has_many :has_many, :before_add => :enlist - belongs_to :belongs_to - has_one :has_one - end - - class DifferentPeopleList < PeopleList - # Different association with the same name, callbacks should be omitted here. - has_and_belongs_to_many :has_and_belongs_to_many, :class_name => 'DifferentPerson' - has_many :has_many, :class_name => 'DifferentPerson' - belongs_to :belongs_to, :class_name => 'DifferentPerson' - has_one :has_one, :class_name => 'DifferentPerson' - end - - def test_habtm_association_redefinition_callbacks_should_differ_and_not_inherited - # redeclared association on AR descendant should not inherit callbacks from superclass - callbacks = PeopleList.read_inheritable_attribute(:before_add_for_has_and_belongs_to_many) - assert_equal([:enlist], callbacks) - callbacks = DifferentPeopleList.read_inheritable_attribute(:before_add_for_has_and_belongs_to_many) - assert_equal([], callbacks) - end - - def test_has_many_association_redefinition_callbacks_should_differ_and_not_inherited - # redeclared association on AR descendant should not inherit callbacks from superclass - callbacks = PeopleList.read_inheritable_attribute(:before_add_for_has_many) - assert_equal([:enlist], callbacks) - callbacks = DifferentPeopleList.read_inheritable_attribute(:before_add_for_has_many) - assert_equal([], callbacks) - end - - def test_habtm_association_redefinition_reflections_should_differ_and_not_inherited - assert_not_equal( - PeopleList.reflect_on_association(:has_and_belongs_to_many), - DifferentPeopleList.reflect_on_association(:has_and_belongs_to_many) - ) - end - - def test_has_many_association_redefinition_reflections_should_differ_and_not_inherited - assert_not_equal( - PeopleList.reflect_on_association(:has_many), - DifferentPeopleList.reflect_on_association(:has_many) - ) - end - - def test_belongs_to_association_redefinition_reflections_should_differ_and_not_inherited - assert_not_equal( - PeopleList.reflect_on_association(:belongs_to), - DifferentPeopleList.reflect_on_association(:belongs_to) - ) - end - - def test_has_one_association_redefinition_reflections_should_differ_and_not_inherited - assert_not_equal( - PeopleList.reflect_on_association(:has_one), - DifferentPeopleList.reflect_on_association(:has_one) - ) - end -end diff --git a/vendor/rails/activerecord/test/cases/attribute_methods_test.rb b/vendor/rails/activerecord/test/cases/attribute_methods_test.rb deleted file mode 100644 index 17ed302..0000000 --- a/vendor/rails/activerecord/test/cases/attribute_methods_test.rb +++ /dev/null @@ -1,305 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/minimalistic' - -class AttributeMethodsTest < ActiveRecord::TestCase - fixtures :topics - def setup - @old_suffixes = ActiveRecord::Base.send(:attribute_method_suffixes).dup - @target = Class.new(ActiveRecord::Base) - @target.table_name = 'topics' - end - - def teardown - ActiveRecord::Base.send(:attribute_method_suffixes).clear - ActiveRecord::Base.attribute_method_suffix *@old_suffixes - end - - def test_match_attribute_method_query_returns_match_data - assert_not_nil md = @target.match_attribute_method?('title=') - assert_equal 'title', md.pre_match - assert_equal ['='], md.captures - - %w(_hello_world ist! _maybe?).each do |suffix| - @target.class_eval "def attribute#{suffix}(*args) args end" - @target.attribute_method_suffix suffix - - assert_not_nil md = @target.match_attribute_method?("title#{suffix}") - assert_equal 'title', md.pre_match - assert_equal [suffix], md.captures - end - end - - def test_declared_attribute_method_affects_respond_to_and_method_missing - topic = @target.new(:title => 'Budget') - assert topic.respond_to?('title') - assert_equal 'Budget', topic.title - assert !topic.respond_to?('title_hello_world') - assert_raise(NoMethodError) { topic.title_hello_world } - - %w(_hello_world _it! _candidate= able?).each do |suffix| - @target.class_eval "def attribute#{suffix}(*args) args end" - @target.attribute_method_suffix suffix - - meth = "title#{suffix}" - assert topic.respond_to?(meth) - assert_equal ['title'], topic.send(meth) - assert_equal ['title', 'a'], topic.send(meth, 'a') - assert_equal ['title', 1, 2, 3], topic.send(meth, 1, 2, 3) - end - end - - def test_should_unserialize_attributes_for_frozen_records - myobj = {:value1 => :value2} - topic = Topic.create("content" => myobj) - topic.freeze - assert_equal myobj, topic.content - end - - def test_typecast_attribute_from_select_to_false - topic = Topic.create(:title => 'Budget') - topic = Topic.find(:first, :select => "topics.*, 1=2 as is_test") - assert !topic.is_test? - end - - def test_typecast_attribute_from_select_to_true - topic = Topic.create(:title => 'Budget') - topic = Topic.find(:first, :select => "topics.*, 2=2 as is_test") - assert topic.is_test? - end - - def test_kernel_methods_not_implemented_in_activerecord - %w(test name display y).each do |method| - assert !ActiveRecord::Base.instance_method_already_implemented?(method), "##{method} is defined" - end - end - - def test_primary_key_implemented - assert Class.new(ActiveRecord::Base).instance_method_already_implemented?('id') - end - - def test_defined_kernel_methods_implemented_in_model - %w(test name display y).each do |method| - klass = Class.new ActiveRecord::Base - klass.class_eval "def #{method}() 'defined #{method}' end" - assert klass.instance_method_already_implemented?(method), "##{method} is not defined" - end - end - - def test_defined_kernel_methods_implemented_in_model_abstract_subclass - %w(test name display y).each do |method| - abstract = Class.new ActiveRecord::Base - abstract.class_eval "def #{method}() 'defined #{method}' end" - abstract.abstract_class = true - klass = Class.new abstract - assert klass.instance_method_already_implemented?(method), "##{method} is not defined" - end - end - - def test_raises_dangerous_attribute_error_when_defining_activerecord_method_in_model - %w(save create_or_update).each do |method| - klass = Class.new ActiveRecord::Base - klass.class_eval "def #{method}() 'defined #{method}' end" - assert_raise ActiveRecord::DangerousAttributeError do - klass.instance_method_already_implemented?(method) - end - end - end - - def test_only_time_related_columns_are_meant_to_be_cached_by_default - expected = %w(datetime timestamp time date).sort - assert_equal expected, ActiveRecord::Base.attribute_types_cached_by_default.map(&:to_s).sort - end - - def test_declaring_attributes_as_cached_adds_them_to_the_attributes_cached_by_default - default_attributes = Topic.cached_attributes - Topic.cache_attributes :replies_count - expected = default_attributes + ["replies_count"] - assert_equal expected.sort, Topic.cached_attributes.sort - Topic.instance_variable_set "@cached_attributes", nil - end - - def test_time_related_columns_are_actually_cached - column_types = %w(datetime timestamp time date).map(&:to_sym) - column_names = Topic.columns.select{|c| column_types.include?(c.type) }.map(&:name) - - assert_equal column_names.sort, Topic.cached_attributes.sort - assert_equal time_related_columns_on_topic.sort, Topic.cached_attributes.sort - end - - def test_accessing_cached_attributes_caches_the_converted_values_and_nothing_else - t = topics(:first) - cache = t.instance_variable_get "@attributes_cache" - - assert_not_nil cache - assert cache.empty? - - all_columns = Topic.columns.map(&:name) - cached_columns = time_related_columns_on_topic - uncached_columns = all_columns - cached_columns - - all_columns.each do |attr_name| - attribute_gets_cached = Topic.cache_attribute?(attr_name) - val = t.send attr_name unless attr_name == "type" - if attribute_gets_cached - assert cached_columns.include?(attr_name) - assert_equal val, cache[attr_name] - else - assert uncached_columns.include?(attr_name) - assert !cache.include?(attr_name) - end - end - end - - def test_time_attributes_are_retrieved_in_current_time_zone - in_time_zone "Pacific Time (US & Canada)" do - utc_time = Time.utc(2008, 1, 1) - record = @target.new - record[:written_on] = utc_time - assert_equal utc_time, record.written_on # record.written on is equal to (i.e., simultaneous with) utc_time - assert_kind_of ActiveSupport::TimeWithZone, record.written_on # but is a TimeWithZone - assert_equal ActiveSupport::TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone # and is in the current Time.zone - assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time # and represents time values adjusted accordingly - end - end - - def test_setting_time_zone_aware_attribute_to_utc - in_time_zone "Pacific Time (US & Canada)" do - utc_time = Time.utc(2008, 1, 1) - record = @target.new - record.written_on = utc_time - assert_equal utc_time, record.written_on - assert_equal ActiveSupport::TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone - assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time - end - end - - def test_setting_time_zone_aware_attribute_in_other_time_zone - utc_time = Time.utc(2008, 1, 1) - cst_time = utc_time.in_time_zone("Central Time (US & Canada)") - in_time_zone "Pacific Time (US & Canada)" do - record = @target.new - record.written_on = cst_time - assert_equal utc_time, record.written_on - assert_equal ActiveSupport::TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone - assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time - end - end - - def test_setting_time_zone_aware_attribute_with_string - utc_time = Time.utc(2008, 1, 1) - (-11..13).each do |timezone_offset| - time_string = utc_time.in_time_zone(timezone_offset).to_s - in_time_zone "Pacific Time (US & Canada)" do - record = @target.new - record.written_on = time_string - assert_equal Time.zone.parse(time_string), record.written_on - assert_equal ActiveSupport::TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone - assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time - end - end - end - - def test_setting_time_zone_aware_attribute_to_blank_string_returns_nil - in_time_zone "Pacific Time (US & Canada)" do - record = @target.new - record.written_on = ' ' - assert_nil record.written_on - end - end - - def test_setting_time_zone_aware_attribute_interprets_time_zone_unaware_string_in_time_zone - time_string = 'Tue Jan 01 00:00:00 2008' - (-11..13).each do |timezone_offset| - in_time_zone timezone_offset do - record = @target.new - record.written_on = time_string - assert_equal Time.zone.parse(time_string), record.written_on - assert_equal ActiveSupport::TimeZone[timezone_offset], record.written_on.time_zone - assert_equal Time.utc(2008, 1, 1), record.written_on.time - end - end - end - - def test_setting_time_zone_aware_attribute_in_current_time_zone - utc_time = Time.utc(2008, 1, 1) - in_time_zone "Pacific Time (US & Canada)" do - record = @target.new - record.written_on = utc_time.in_time_zone - assert_equal utc_time, record.written_on - assert_equal ActiveSupport::TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone - assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time - end - end - - def test_setting_time_zone_conversion_for_attributes_should_write_value_on_class_variable - Topic.skip_time_zone_conversion_for_attributes = [:field_a] - Minimalistic.skip_time_zone_conversion_for_attributes = [:field_b] - - assert_equal [:field_a], Topic.skip_time_zone_conversion_for_attributes - assert_equal [:field_b], Minimalistic.skip_time_zone_conversion_for_attributes - end - - def test_read_attributes_respect_access_control - privatize("title") - - topic = @target.new(:title => "The pros and cons of programming naked.") - assert !topic.respond_to?(:title) - exception = assert_raise(NoMethodError) { topic.title } - assert_equal "Attempt to call private method", exception.message - assert_equal "I'm private", topic.send(:title) - end - - def test_write_attributes_respect_access_control - privatize("title=(value)") - - topic = @target.new - assert !topic.respond_to?(:title=) - exception = assert_raise(NoMethodError) { topic.title = "Pants"} - assert_equal "Attempt to call private method", exception.message - topic.send(:title=, "Very large pants") - end - - def test_question_attributes_respect_access_control - privatize("title?") - - topic = @target.new(:title => "Isaac Newton's pants") - assert !topic.respond_to?(:title?) - exception = assert_raise(NoMethodError) { topic.title? } - assert_equal "Attempt to call private method", exception.message - assert topic.send(:title?) - end - - def test_bulk_update_respects_access_control - privatize("title=(value)") - - assert_raise(ActiveRecord::UnknownAttributeError) { topic = @target.new(:title => "Rants about pants") } - assert_raise(ActiveRecord::UnknownAttributeError) { @target.new.attributes = { :title => "Ants in pants" } } - end - - private - def time_related_columns_on_topic - Topic.columns.select{|c| [:time, :date, :datetime, :timestamp].include?(c.type)}.map(&:name) - end - - def in_time_zone(zone) - old_zone = Time.zone - old_tz = ActiveRecord::Base.time_zone_aware_attributes - - Time.zone = zone ? ActiveSupport::TimeZone[zone] : nil - ActiveRecord::Base.time_zone_aware_attributes = !zone.nil? - yield - ensure - Time.zone = old_zone - ActiveRecord::Base.time_zone_aware_attributes = old_tz - end - - def privatize(method_signature) - @target.class_eval <<-private_method - private - def #{method_signature} - "I'm private" - end - private_method - end -end diff --git a/vendor/rails/activerecord/test/cases/autosave_association_test.rb b/vendor/rails/activerecord/test/cases/autosave_association_test.rb deleted file mode 100644 index 436f50d..0000000 --- a/vendor/rails/activerecord/test/cases/autosave_association_test.rb +++ /dev/null @@ -1,901 +0,0 @@ -require 'cases/helper' -require 'models/bird' -require 'models/company' -require 'models/customer' -require 'models/developer' -require 'models/order' -require 'models/parrot' -require 'models/person' -require 'models/pirate' -require 'models/post' -require 'models/reader' -require 'models/ship' -require 'models/ship_part' -require 'models/treasure' - -class TestAutosaveAssociationsInGeneral < ActiveRecord::TestCase - def test_autosave_should_be_a_valid_option_for_has_one - assert base.valid_keys_for_has_one_association.include?(:autosave) - end - - def test_autosave_should_be_a_valid_option_for_belongs_to - assert base.valid_keys_for_belongs_to_association.include?(:autosave) - end - - def test_autosave_should_be_a_valid_option_for_has_many - assert base.valid_keys_for_has_many_association.include?(:autosave) - end - - def test_autosave_should_be_a_valid_option_for_has_and_belongs_to_many - assert base.valid_keys_for_has_and_belongs_to_many_association.include?(:autosave) - end - - private - - def base - ActiveRecord::Base - end -end - -class TestDefaultAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCase - def test_save_fails_for_invalid_has_one - firm = Firm.find(:first) - assert firm.valid? - - firm.account = Account.new - - assert !firm.account.valid? - assert !firm.valid? - assert !firm.save - assert_equal "is invalid", firm.errors.on("account") - end - - def test_save_succeeds_for_invalid_has_one_with_validate_false - firm = Firm.find(:first) - assert firm.valid? - - firm.unvalidated_account = Account.new - - assert !firm.unvalidated_account.valid? - assert firm.valid? - assert firm.save - end - - def test_build_before_child_saved - firm = Firm.find(1) - - account = firm.account.build("credit_limit" => 1000) - assert_equal account, firm.account - assert account.new_record? - assert firm.save - assert_equal account, firm.account - assert !account.new_record? - end - - def test_build_before_either_saved - firm = Firm.new("name" => "GlobalMegaCorp") - - firm.account = account = Account.new("credit_limit" => 1000) - assert_equal account, firm.account - assert account.new_record? - assert firm.save - assert_equal account, firm.account - assert !account.new_record? - end - - def test_assignment_before_parent_saved - firm = Firm.new("name" => "GlobalMegaCorp") - firm.account = a = Account.find(1) - assert firm.new_record? - assert_equal a, firm.account - assert firm.save - assert_equal a, firm.account - assert_equal a, firm.account(true) - end - - def test_assignment_before_either_saved - firm = Firm.new("name" => "GlobalMegaCorp") - firm.account = a = Account.new("credit_limit" => 1000) - assert firm.new_record? - assert a.new_record? - assert_equal a, firm.account - assert firm.save - assert !firm.new_record? - assert !a.new_record? - assert_equal a, firm.account - assert_equal a, firm.account(true) - end - - def test_not_resaved_when_unchanged - firm = Firm.find(:first, :include => :account) - firm.name += '-changed' - assert_queries(1) { firm.save! } - - firm = Firm.find(:first) - firm.account = Account.find(:first) - assert_queries(Firm.partial_updates? ? 0 : 1) { firm.save! } - - firm = Firm.find(:first).clone - firm.account = Account.find(:first) - assert_queries(2) { firm.save! } - - firm = Firm.find(:first).clone - firm.account = Account.find(:first).clone - assert_queries(2) { firm.save! } - end -end - -class TestDefaultAutosaveAssociationOnABelongsToAssociation < ActiveRecord::TestCase - def test_save_fails_for_invalid_belongs_to - assert log = AuditLog.create(:developer_id => 0, :message => "") - - log.developer = Developer.new - assert !log.developer.valid? - assert !log.valid? - assert !log.save - assert_equal "is invalid", log.errors.on("developer") - end - - def test_save_succeeds_for_invalid_belongs_to_with_validate_false - assert log = AuditLog.create(:developer_id => 0, :message=> "") - - log.unvalidated_developer = Developer.new - assert !log.unvalidated_developer.valid? - assert log.valid? - assert log.save - end - - def test_assignment_before_parent_saved - client = Client.find(:first) - apple = Firm.new("name" => "Apple") - client.firm = apple - assert_equal apple, client.firm - assert apple.new_record? - assert client.save - assert apple.save - assert !apple.new_record? - assert_equal apple, client.firm - assert_equal apple, client.firm(true) - end - - def test_assignment_before_either_saved - final_cut = Client.new("name" => "Final Cut") - apple = Firm.new("name" => "Apple") - final_cut.firm = apple - assert final_cut.new_record? - assert apple.new_record? - assert final_cut.save - assert !final_cut.new_record? - assert !apple.new_record? - assert_equal apple, final_cut.firm - assert_equal apple, final_cut.firm(true) - end - - def test_store_two_association_with_one_save - num_orders = Order.count - num_customers = Customer.count - order = Order.new - - customer1 = order.billing = Customer.new - customer2 = order.shipping = Customer.new - assert order.save - assert_equal customer1, order.billing - assert_equal customer2, order.shipping - - order.reload - - assert_equal customer1, order.billing - assert_equal customer2, order.shipping - - assert_equal num_orders +1, Order.count - assert_equal num_customers +2, Customer.count - end - - def test_store_association_in_two_relations_with_one_save - num_orders = Order.count - num_customers = Customer.count - order = Order.new - - customer = order.billing = order.shipping = Customer.new - assert order.save - assert_equal customer, order.billing - assert_equal customer, order.shipping - - order.reload - - assert_equal customer, order.billing - assert_equal customer, order.shipping - - assert_equal num_orders +1, Order.count - assert_equal num_customers +1, Customer.count - end - - def test_store_association_in_two_relations_with_one_save_in_existing_object - num_orders = Order.count - num_customers = Customer.count - order = Order.create - - customer = order.billing = order.shipping = Customer.new - assert order.save - assert_equal customer, order.billing - assert_equal customer, order.shipping - - order.reload - - assert_equal customer, order.billing - assert_equal customer, order.shipping - - assert_equal num_orders +1, Order.count - assert_equal num_customers +1, Customer.count - end - - def test_store_association_in_two_relations_with_one_save_in_existing_object_with_values - num_orders = Order.count - num_customers = Customer.count - order = Order.create - - customer = order.billing = order.shipping = Customer.new - assert order.save - assert_equal customer, order.billing - assert_equal customer, order.shipping - - order.reload - - customer = order.billing = order.shipping = Customer.new - - assert order.save - order.reload - - assert_equal customer, order.billing - assert_equal customer, order.shipping - - assert_equal num_orders +1, Order.count - assert_equal num_customers +2, Customer.count - end -end - -class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCase - fixtures :companies, :people - - def test_invalid_adding - firm = Firm.find(1) - assert !(firm.clients_of_firm << c = Client.new) - assert c.new_record? - assert !firm.valid? - assert !firm.save - assert c.new_record? - end - - def test_invalid_adding_before_save - no_of_firms = Firm.count - no_of_clients = Client.count - new_firm = Firm.new("name" => "A New Firm, Inc") - new_firm.clients_of_firm.concat([c = Client.new, Client.new("name" => "Apple")]) - assert c.new_record? - assert !c.valid? - assert !new_firm.valid? - assert !new_firm.save - assert c.new_record? - assert new_firm.new_record? - end - - def test_invalid_adding_with_validate_false - firm = Firm.find(:first) - client = Client.new - firm.unvalidated_clients_of_firm << client - - assert firm.valid? - assert !client.valid? - assert firm.save - assert client.new_record? - end - - def test_valid_adding_with_validate_false - no_of_clients = Client.count - - firm = Firm.find(:first) - client = Client.new("name" => "Apple") - - assert firm.valid? - assert client.valid? - assert client.new_record? - - firm.unvalidated_clients_of_firm << client - - assert firm.save - assert !client.new_record? - assert_equal no_of_clients+1, Client.count - end - - def test_invalid_build - new_client = companies(:first_firm).clients_of_firm.build - assert new_client.new_record? - assert !new_client.valid? - assert_equal new_client, companies(:first_firm).clients_of_firm.last - assert !companies(:first_firm).save - assert new_client.new_record? - assert_equal 1, companies(:first_firm).clients_of_firm(true).size - end - - def test_adding_before_save - no_of_firms = Firm.count - no_of_clients = Client.count - - new_firm = Firm.new("name" => "A New Firm, Inc") - c = Client.new("name" => "Apple") - - new_firm.clients_of_firm.push Client.new("name" => "Natural Company") - assert_equal 1, new_firm.clients_of_firm.size - new_firm.clients_of_firm << c - assert_equal 2, new_firm.clients_of_firm.size - - assert_equal no_of_firms, Firm.count # Firm was not saved to database. - assert_equal no_of_clients, Client.count # Clients were not saved to database. - assert new_firm.save - assert !new_firm.new_record? - assert !c.new_record? - assert_equal new_firm, c.firm - assert_equal no_of_firms+1, Firm.count # Firm was saved to database. - assert_equal no_of_clients+2, Client.count # Clients were saved to database. - - assert_equal 2, new_firm.clients_of_firm.size - assert_equal 2, new_firm.clients_of_firm(true).size - end - - def test_assign_ids - firm = Firm.new("name" => "Apple") - firm.client_ids = [companies(:first_client).id, companies(:second_client).id] - firm.save - firm.reload - assert_equal 2, firm.clients.length - assert firm.clients.include?(companies(:second_client)) - end - - def test_assign_ids_for_through_a_belongs_to - post = Post.new(:title => "Assigning IDs works!", :body => "You heared it here first, folks!") - post.person_ids = [people(:david).id, people(:michael).id] - post.save - post.reload - assert_equal 2, post.people.length - assert post.people.include?(people(:david)) - end - - def test_build_before_save - company = companies(:first_firm) - new_client = assert_no_queries { company.clients_of_firm.build("name" => "Another Client") } - assert !company.clients_of_firm.loaded? - - company.name += '-changed' - assert_queries(2) { assert company.save } - assert !new_client.new_record? - assert_equal 2, company.clients_of_firm(true).size - end - - def test_build_many_before_save - company = companies(:first_firm) - new_clients = assert_no_queries { company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) } - - company.name += '-changed' - assert_queries(3) { assert company.save } - assert_equal 3, company.clients_of_firm(true).size - end - - def test_build_via_block_before_save - company = companies(:first_firm) - new_client = assert_no_queries { company.clients_of_firm.build {|client| client.name = "Another Client" } } - assert !company.clients_of_firm.loaded? - - company.name += '-changed' - assert_queries(2) { assert company.save } - assert !new_client.new_record? - assert_equal 2, company.clients_of_firm(true).size - end - - def test_build_many_via_block_before_save - company = companies(:first_firm) - new_clients = assert_no_queries do - company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) do |client| - client.name = "changed" - end - end - - company.name += '-changed' - assert_queries(3) { assert company.save } - assert_equal 3, company.clients_of_firm(true).size - end - - def test_replace_on_new_object - firm = Firm.new("name" => "New Firm") - firm.clients = [companies(:second_client), Client.new("name" => "New Client")] - assert firm.save - firm.reload - assert_equal 2, firm.clients.length - assert firm.clients.include?(Client.find_by_name("New Client")) - end -end - -class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @pirate = Pirate.create(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @ship = @pirate.create_ship(:name => 'Nights Dirty Lightning') - end - - # reload - def test_a_marked_for_destruction_record_should_not_be_be_marked_after_reload - @pirate.mark_for_destruction - @pirate.ship.mark_for_destruction - - assert !@pirate.reload.marked_for_destruction? - assert !@pirate.ship.marked_for_destruction? - end - - # has_one - def test_should_destroy_a_child_association_as_part_of_the_save_transaction_if_it_was_marked_for_destroyal - assert !@pirate.ship.marked_for_destruction? - - @pirate.ship.mark_for_destruction - id = @pirate.ship.id - - assert @pirate.ship.marked_for_destruction? - assert Ship.find_by_id(id) - - @pirate.save - assert_nil @pirate.reload.ship - assert_nil Ship.find_by_id(id) - end - - def test_should_skip_validation_on_a_child_association_if_marked_for_destruction - @pirate.ship.name = '' - assert !@pirate.valid? - - @pirate.ship.mark_for_destruction - assert_difference('Ship.count', -1) { @pirate.save! } - end - - def test_should_rollback_destructions_if_an_exception_occurred_while_saving_a_child - # Stub the save method of the @pirate.ship instance to destroy and then raise an exception - class << @pirate.ship - def save(*args) - super - destroy - raise 'Oh noes!' - end - end - - assert_raise(RuntimeError) { assert !@pirate.save } - assert_not_nil @pirate.reload.ship - end - - # belongs_to - def test_should_destroy_a_parent_association_as_part_of_the_save_transaction_if_it_was_marked_for_destroyal - assert !@ship.pirate.marked_for_destruction? - - @ship.pirate.mark_for_destruction - id = @ship.pirate.id - - assert @ship.pirate.marked_for_destruction? - assert Pirate.find_by_id(id) - - @ship.save - assert_nil @ship.reload.pirate - assert_nil Pirate.find_by_id(id) - end - - def test_should_skip_validation_on_a_parent_association_if_marked_for_destruction - @ship.pirate.catchphrase = '' - assert !@ship.valid? - - @ship.pirate.mark_for_destruction - assert_difference('Pirate.count', -1) { @ship.save! } - end - - def test_should_rollback_destructions_if_an_exception_occurred_while_saving_a_parent - # Stub the save method of the @ship.pirate instance to destroy and then raise an exception - class << @ship.pirate - def save(*args) - super - destroy - raise 'Oh noes!' - end - end - - assert_raise(RuntimeError) { assert !@ship.save } - assert_not_nil @ship.reload.pirate - end - - # has_many & has_and_belongs_to - %w{ parrots birds }.each do |association_name| - define_method("test_should_destroy_#{association_name}_as_part_of_the_save_transaction_if_they_were_marked_for_destroyal") do - 2.times { |i| @pirate.send(association_name).create!(:name => "#{association_name}_#{i}") } - - assert !@pirate.send(association_name).any? { |child| child.marked_for_destruction? } - - @pirate.send(association_name).each { |child| child.mark_for_destruction } - klass = @pirate.send(association_name).first.class - ids = @pirate.send(association_name).map(&:id) - - assert @pirate.send(association_name).all? { |child| child.marked_for_destruction? } - ids.each { |id| assert klass.find_by_id(id) } - - @pirate.save - assert @pirate.reload.send(association_name).empty? - ids.each { |id| assert_nil klass.find_by_id(id) } - end - - define_method("test_should_skip_validation_on_the_#{association_name}_association_if_marked_for_destruction") do - 2.times { |i| @pirate.send(association_name).create!(:name => "#{association_name}_#{i}") } - children = @pirate.send(association_name) - - children.each { |child| child.name = '' } - assert !@pirate.valid? - - children.each { |child| child.mark_for_destruction } - assert_difference("#{association_name.classify}.count", -2) { @pirate.save! } - end - - define_method("test_should_rollback_destructions_if_an_exception_occurred_while_saving_#{association_name}") do - 2.times { |i| @pirate.send(association_name).create!(:name => "#{association_name}_#{i}") } - before = @pirate.send(association_name).map { |c| c } - - # Stub the save method of the first child to destroy and the second to raise an exception - class << before.first - def save(*args) - super - destroy - end - end - class << before.last - def save(*args) - super - raise 'Oh noes!' - end - end - - assert_raise(RuntimeError) { assert !@pirate.save } - assert_equal before, @pirate.reload.send(association_name) - end - - # Add and remove callbacks tests for association collections. - %w{ method proc }.each do |callback_type| - define_method("test_should_run_add_callback_#{callback_type}s_for_#{association_name}") do - association_name_with_callbacks = "#{association_name}_with_#{callback_type}_callbacks" - - pirate = Pirate.new(:catchphrase => "Arr") - pirate.send(association_name_with_callbacks).build(:name => "Crowe the One-Eyed") - - expected = [ - "before_adding_#{callback_type}_#{association_name.singularize}_<new>", - "after_adding_#{callback_type}_#{association_name.singularize}_<new>" - ] - - assert_equal expected, pirate.ship_log - end - - define_method("test_should_run_remove_callback_#{callback_type}s_for_#{association_name}") do - association_name_with_callbacks = "#{association_name}_with_#{callback_type}_callbacks" - - @pirate.send(association_name_with_callbacks).create!(:name => "Crowe the One-Eyed") - @pirate.send(association_name_with_callbacks).each { |c| c.mark_for_destruction } - child_id = @pirate.send(association_name_with_callbacks).first.id - - @pirate.ship_log.clear - @pirate.save - - expected = [ - "before_removing_#{callback_type}_#{association_name.singularize}_#{child_id}", - "after_removing_#{callback_type}_#{association_name.singularize}_#{child_id}" - ] - - assert_equal expected, @pirate.ship_log - end - end - end -end - -class TestAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @pirate = Pirate.create(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @ship = @pirate.create_ship(:name => 'Nights Dirty Lightning') - end - - def test_should_still_work_without_an_associated_model - @ship.destroy - @pirate.reload.catchphrase = "Arr" - @pirate.save - assert 'Arr', @pirate.reload.catchphrase - end - - def test_should_automatically_save_the_associated_model - @pirate.ship.name = 'The Vile Insanity' - @pirate.save - assert_equal 'The Vile Insanity', @pirate.reload.ship.name - end - - def test_should_automatically_save_bang_the_associated_model - @pirate.ship.name = 'The Vile Insanity' - @pirate.save! - assert_equal 'The Vile Insanity', @pirate.reload.ship.name - end - - def test_should_automatically_validate_the_associated_model - @pirate.ship.name = '' - assert !@pirate.valid? - assert !@pirate.errors.on(:ship_name).blank? - end - - def test_should_merge_errors_on_the_associated_models_onto_the_parent_even_if_it_is_not_valid - @pirate.ship.name = nil - @pirate.catchphrase = nil - assert !@pirate.valid? - assert !@pirate.errors.on(:ship_name).blank? - assert !@pirate.errors.on(:catchphrase).blank? - end - - def test_should_still_allow_to_bypass_validations_on_the_associated_model - @pirate.catchphrase = '' - @pirate.ship.name = '' - @pirate.save(false) - assert_equal ['', ''], [@pirate.reload.catchphrase, @pirate.ship.name] - end - - def test_should_allow_to_bypass_validations_on_associated_models_at_any_depth - 2.times { |i| @pirate.ship.parts.create!(:name => "part #{i}") } - - @pirate.catchphrase = '' - @pirate.ship.name = '' - @pirate.ship.parts.each { |part| part.name = '' } - @pirate.save(false) - - values = [@pirate.reload.catchphrase, @pirate.ship.name, *@pirate.ship.parts.map(&:name)] - assert_equal ['', '', '', ''], values - end - - def test_should_still_raise_an_ActiveRecordRecord_Invalid_exception_if_we_want_that - @pirate.ship.name = '' - assert_raise(ActiveRecord::RecordInvalid) do - @pirate.save! - end - end - - def test_should_rollback_any_changes_if_an_exception_occurred_while_saving - before = [@pirate.catchphrase, @pirate.ship.name] - - @pirate.catchphrase = 'Arr' - @pirate.ship.name = 'The Vile Insanity' - - # Stub the save method of the @pirate.ship instance to raise an exception - class << @pirate.ship - def save(*args) - super - raise 'Oh noes!' - end - end - - assert_raise(RuntimeError) { assert !@pirate.save } - assert_equal before, [@pirate.reload.catchphrase, @pirate.ship.name] - end - - def test_should_not_load_the_associated_model - assert_queries(1) { @pirate.catchphrase = 'Arr'; @pirate.save! } - end -end - -class TestAutosaveAssociationOnABelongsToAssociation < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @ship = Ship.create(:name => 'Nights Dirty Lightning') - @pirate = @ship.create_pirate(:catchphrase => "Don' botharrr talkin' like one, savvy?") - end - - def test_should_still_work_without_an_associated_model - @pirate.destroy - @ship.reload.name = "The Vile Insanity" - @ship.save - assert 'The Vile Insanity', @ship.reload.name - end - - def test_should_automatically_save_the_associated_model - @ship.pirate.catchphrase = 'Arr' - @ship.save - assert_equal 'Arr', @ship.reload.pirate.catchphrase - end - - def test_should_automatically_save_bang_the_associated_model - @ship.pirate.catchphrase = 'Arr' - @ship.save! - assert_equal 'Arr', @ship.reload.pirate.catchphrase - end - - def test_should_automatically_validate_the_associated_model - @ship.pirate.catchphrase = '' - assert !@ship.valid? - assert !@ship.errors.on(:pirate_catchphrase).blank? - end - - def test_should_merge_errors_on_the_associated_model_onto_the_parent_even_if_it_is_not_valid - @ship.name = nil - @ship.pirate.catchphrase = nil - assert !@ship.valid? - assert !@ship.errors.on(:name).blank? - assert !@ship.errors.on(:pirate_catchphrase).blank? - end - - def test_should_still_allow_to_bypass_validations_on_the_associated_model - @ship.pirate.catchphrase = '' - @ship.name = '' - @ship.save(false) - assert_equal ['', ''], [@ship.reload.name, @ship.pirate.catchphrase] - end - - def test_should_still_raise_an_ActiveRecordRecord_Invalid_exception_if_we_want_that - @ship.pirate.catchphrase = '' - assert_raise(ActiveRecord::RecordInvalid) do - @ship.save! - end - end - - def test_should_rollback_any_changes_if_an_exception_occurred_while_saving - before = [@ship.pirate.catchphrase, @ship.name] - - @ship.pirate.catchphrase = 'Arr' - @ship.name = 'The Vile Insanity' - - # Stub the save method of the @ship.pirate instance to raise an exception - class << @ship.pirate - def save(*args) - super - raise 'Oh noes!' - end - end - - assert_raise(RuntimeError) { assert !@ship.save } - # TODO: Why does using reload on @ship looses the associated pirate? - assert_equal before, [@ship.pirate.reload.catchphrase, @ship.reload.name] - end - - def test_should_not_load_the_associated_model - assert_queries(1) { @ship.name = 'The Vile Insanity'; @ship.save! } - end -end - -module AutosaveAssociationOnACollectionAssociationTests - def test_should_automatically_save_the_associated_models - new_names = ['Grace OMalley', 'Privateers Greed'] - @pirate.send(@association_name).each_with_index { |child, i| child.name = new_names[i] } - - @pirate.save - assert_equal new_names, @pirate.reload.send(@association_name).map(&:name) - end - - def test_should_automatically_save_bang_the_associated_models - new_names = ['Grace OMalley', 'Privateers Greed'] - @pirate.send(@association_name).each_with_index { |child, i| child.name = new_names[i] } - - @pirate.save! - assert_equal new_names, @pirate.reload.send(@association_name).map(&:name) - end - - def test_should_automatically_validate_the_associated_models - @pirate.send(@association_name).each { |child| child.name = '' } - - assert !@pirate.valid? - assert_equal "can't be blank", @pirate.errors.on("#{@association_name}_name") - assert @pirate.errors.on(@association_name).blank? - end - - def test_should_not_use_default_invalid_error_on_associated_models - @pirate.send(@association_name).build(:name => '') - - assert !@pirate.valid? - assert_equal "can't be blank", @pirate.errors.on("#{@association_name}_name") - assert @pirate.errors.on(@association_name).blank? - end - - def test_should_merge_errors_on_the_associated_models_onto_the_parent_even_if_it_is_not_valid - @pirate.send(@association_name).each { |child| child.name = '' } - @pirate.catchphrase = nil - - assert !@pirate.valid? - assert_equal "can't be blank", @pirate.errors.on("#{@association_name}_name") - assert !@pirate.errors.on(:catchphrase).blank? - end - - def test_should_allow_to_bypass_validations_on_the_associated_models_on_update - @pirate.catchphrase = '' - @pirate.send(@association_name).each { |child| child.name = '' } - - assert @pirate.save(false) - assert_equal ['', '', ''], [ - @pirate.reload.catchphrase, - @pirate.send(@association_name).first.name, - @pirate.send(@association_name).last.name - ] - end - - def test_should_validation_the_associated_models_on_create - assert_no_difference("#{ @association_name == :birds ? 'Bird' : 'Parrot' }.count") do - 2.times { @pirate.send(@association_name).build } - @pirate.save(true) - end - end - - def test_should_allow_to_bypass_validations_on_the_associated_models_on_create - assert_difference("#{ @association_name == :birds ? 'Bird' : 'Parrot' }.count", +2) do - 2.times { @pirate.send(@association_name).build } - @pirate.save(false) - end - end - - def test_should_rollback_any_changes_if_an_exception_occurred_while_saving - before = [@pirate.catchphrase, *@pirate.send(@association_name).map(&:name)] - new_names = ['Grace OMalley', 'Privateers Greed'] - - @pirate.catchphrase = 'Arr' - @pirate.send(@association_name).each_with_index { |child, i| child.name = new_names[i] } - - # Stub the save method of the first child instance to raise an exception - class << @pirate.send(@association_name).first - def save(*args) - super - raise 'Oh noes!' - end - end - - assert_raise(RuntimeError) { assert !@pirate.save } - assert_equal before, [@pirate.reload.catchphrase, *@pirate.send(@association_name).map(&:name)] - end - - def test_should_still_raise_an_ActiveRecordRecord_Invalid_exception_if_we_want_that - @pirate.send(@association_name).each { |child| child.name = '' } - assert_raise(ActiveRecord::RecordInvalid) do - @pirate.save! - end - end - - def test_should_not_load_the_associated_models_if_they_were_not_loaded_yet - assert_queries(1) { @pirate.catchphrase = 'Arr'; @pirate.save! } - - @pirate.send(@association_name).class # hack to load the target - - assert_queries(3) do - @pirate.catchphrase = 'Yarr' - new_names = ['Grace OMalley', 'Privateers Greed'] - @pirate.send(@association_name).each_with_index { |child, i| child.name = new_names[i] } - @pirate.save! - end - end -end - -class TestAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @association_name = :birds - - @pirate = Pirate.create(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @child_1 = @pirate.birds.create(:name => 'Posideons Killer') - @child_2 = @pirate.birds.create(:name => 'Killer bandita Dionne') - end - - include AutosaveAssociationOnACollectionAssociationTests -end - -class TestAutosaveAssociationOnAHasAndBelongsToManyAssociation < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @association_name = :parrots - @habtm = true - - @pirate = Pirate.create(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @child_1 = @pirate.parrots.create(:name => 'Posideons Killer') - @child_2 = @pirate.parrots.create(:name => 'Killer bandita Dionne') - end - - include AutosaveAssociationOnACollectionAssociationTests -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/cases/base_test.rb b/vendor/rails/activerecord/test/cases/base_test.rb deleted file mode 100755 index 99d7796..0000000 --- a/vendor/rails/activerecord/test/cases/base_test.rb +++ /dev/null @@ -1,2107 +0,0 @@ -require "cases/helper" -require 'models/author' -require 'models/topic' -require 'models/reply' -require 'models/category' -require 'models/company' -require 'models/customer' -require 'models/developer' -require 'models/project' -require 'models/default' -require 'models/auto_id' -require 'models/column_name' -require 'models/subscriber' -require 'models/keyboard' -require 'models/post' -require 'models/comment' -require 'models/minimalistic' -require 'models/warehouse_thing' -require 'models/parrot' -require 'rexml/document' - -class Category < ActiveRecord::Base; end -class Categorization < ActiveRecord::Base; end -class Smarts < ActiveRecord::Base; end -class CreditCard < ActiveRecord::Base - class PinNumber < ActiveRecord::Base - class CvvCode < ActiveRecord::Base; end - class SubCvvCode < CvvCode; end - end - class SubPinNumber < PinNumber; end - class Brand < Category; end -end -class MasterCreditCard < ActiveRecord::Base; end -class Post < ActiveRecord::Base; end -class Computer < ActiveRecord::Base; end -class NonExistentTable < ActiveRecord::Base; end -class TestOracleDefault < ActiveRecord::Base; end - -class LoosePerson < ActiveRecord::Base - self.table_name = 'people' - self.abstract_class = true - attr_protected :credit_rating, :administrator -end - -class LooseDescendant < LoosePerson - attr_protected :phone_number -end - -class LooseDescendantSecond< LoosePerson - attr_protected :phone_number - attr_protected :name -end - -class TightPerson < ActiveRecord::Base - self.table_name = 'people' - attr_accessible :name, :address -end - -class TightDescendant < TightPerson - attr_accessible :phone_number -end - -class ReadonlyTitlePost < Post - attr_readonly :title -end - -class Booleantest < ActiveRecord::Base; end - -class Task < ActiveRecord::Base - attr_protected :starting -end - -class TopicWithProtectedContentAndAccessibleAuthorName < ActiveRecord::Base - self.table_name = 'topics' - attr_accessible :author_name - attr_protected :content -end - -class BasicsTest < ActiveRecord::TestCase - fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse-things', :authors, :categorizations, :categories, :posts - - def test_table_exists - assert !NonExistentTable.table_exists? - assert Topic.table_exists? - end - - def test_set_attributes - topic = Topic.find(1) - topic.attributes = { "title" => "Budget", "author_name" => "Jason" } - topic.save - assert_equal("Budget", topic.title) - assert_equal("Jason", topic.author_name) - assert_equal(topics(:first).author_email_address, Topic.find(1).author_email_address) - end - - def test_integers_as_nil - test = AutoId.create('value' => '') - assert_nil AutoId.find(test.id).value - end - - def test_set_attributes_with_block - topic = Topic.new do |t| - t.title = "Budget" - t.author_name = "Jason" - end - - assert_equal("Budget", topic.title) - assert_equal("Jason", topic.author_name) - end - - def test_respond_to? - topic = Topic.find(1) - assert topic.respond_to?("title") - assert topic.respond_to?("title?") - assert topic.respond_to?("title=") - assert topic.respond_to?(:title) - assert topic.respond_to?(:title?) - assert topic.respond_to?(:title=) - assert topic.respond_to?("author_name") - assert topic.respond_to?("attribute_names") - assert !topic.respond_to?("nothingness") - assert !topic.respond_to?(:nothingness) - end - - def test_array_content - topic = Topic.new - topic.content = %w( one two three ) - topic.save - - assert_equal(%w( one two three ), Topic.find(topic.id).content) - end - - def test_read_attributes_before_type_cast - category = Category.new({:name=>"Test categoty", :type => nil}) - category_attrs = {"name"=>"Test categoty", "type" => nil, "categorizations_count" => nil} - assert_equal category_attrs , category.attributes_before_type_cast - end - - if current_adapter?(:MysqlAdapter) - def test_read_attributes_before_type_cast_on_boolean - bool = Booleantest.create({ "value" => false }) - assert_equal "0", bool.reload.attributes_before_type_cast["value"] - end - end - - def test_read_attributes_before_type_cast_on_datetime - developer = Developer.find(:first) - assert_equal developer.created_at.to_s(:db) , developer.attributes_before_type_cast["created_at"] - end - - def test_hash_content - topic = Topic.new - topic.content = { "one" => 1, "two" => 2 } - topic.save - - assert_equal 2, Topic.find(topic.id).content["two"] - - topic.content_will_change! - topic.content["three"] = 3 - topic.save - - assert_equal 3, Topic.find(topic.id).content["three"] - end - - def test_update_array_content - topic = Topic.new - topic.content = %w( one two three ) - - topic.content.push "four" - assert_equal(%w( one two three four ), topic.content) - - topic.save - - topic = Topic.find(topic.id) - topic.content << "five" - assert_equal(%w( one two three four five ), topic.content) - end - - def test_case_sensitive_attributes_hash - # DB2 is not case-sensitive - return true if current_adapter?(:DB2Adapter) - - assert_equal @loaded_fixtures['computers']['workstation'].to_hash, Computer.find(:first).attributes - end - - def test_create - topic = Topic.new - topic.title = "New Topic" - topic.save - topic_reloaded = Topic.find(topic.id) - assert_equal("New Topic", topic_reloaded.title) - end - - def test_save! - topic = Topic.new(:title => "New Topic") - assert topic.save! - - reply = Reply.new - assert_raise(ActiveRecord::RecordInvalid) { reply.save! } - end - - def test_save_null_string_attributes - topic = Topic.find(1) - topic.attributes = { "title" => "null", "author_name" => "null" } - topic.save! - topic.reload - assert_equal("null", topic.title) - assert_equal("null", topic.author_name) - end - - def test_save_nil_string_attributes - topic = Topic.find(1) - topic.title = nil - topic.save! - topic.reload - assert_nil topic.title - end - - def test_save_for_record_with_only_primary_key - minimalistic = Minimalistic.new - assert_nothing_raised { minimalistic.save } - end - - def test_save_for_record_with_only_primary_key_that_is_provided - assert_nothing_raised { Minimalistic.create!(:id => 2) } - end - - def test_hashes_not_mangled - new_topic = { :title => "New Topic" } - new_topic_values = { :title => "AnotherTopic" } - - topic = Topic.new(new_topic) - assert_equal new_topic[:title], topic.title - - topic.attributes= new_topic_values - assert_equal new_topic_values[:title], topic.title - end - - def test_create_many - topics = Topic.create([ { "title" => "first" }, { "title" => "second" }]) - assert_equal 2, topics.size - assert_equal "first", topics.first.title - end - - def test_create_columns_not_equal_attributes - topic = Topic.new - topic.title = 'Another New Topic' - topic.send :write_attribute, 'does_not_exist', 'test' - assert_nothing_raised { topic.save } - end - - def test_create_through_factory - topic = Topic.create("title" => "New Topic") - topicReloaded = Topic.find(topic.id) - assert_equal(topic, topicReloaded) - end - - def test_create_through_factory_with_block - topic = Topic.create("title" => "New Topic") do |t| - t.author_name = "David" - end - topicReloaded = Topic.find(topic.id) - assert_equal("New Topic", topic.title) - assert_equal("David", topic.author_name) - end - - def test_create_many_through_factory_with_block - topics = Topic.create([ { "title" => "first" }, { "title" => "second" }]) do |t| - t.author_name = "David" - end - assert_equal 2, topics.size - topic1, topic2 = Topic.find(topics[0].id), Topic.find(topics[1].id) - assert_equal "first", topic1.title - assert_equal "David", topic1.author_name - assert_equal "second", topic2.title - assert_equal "David", topic2.author_name - end - - def test_update - topic = Topic.new - topic.title = "Another New Topic" - topic.written_on = "2003-12-12 23:23:00" - topic.save - topicReloaded = Topic.find(topic.id) - assert_equal("Another New Topic", topicReloaded.title) - - topicReloaded.title = "Updated topic" - topicReloaded.save - - topicReloadedAgain = Topic.find(topic.id) - - assert_equal("Updated topic", topicReloadedAgain.title) - end - - def test_update_columns_not_equal_attributes - topic = Topic.new - topic.title = "Still another topic" - topic.save - - topicReloaded = Topic.find(topic.id) - topicReloaded.title = "A New Topic" - topicReloaded.send :write_attribute, 'does_not_exist', 'test' - assert_nothing_raised { topicReloaded.save } - end - - def test_update_for_record_with_only_primary_key - minimalistic = minimalistics(:first) - assert_nothing_raised { minimalistic.save } - end - - def test_write_attribute - topic = Topic.new - topic.send(:write_attribute, :title, "Still another topic") - assert_equal "Still another topic", topic.title - - topic.send(:write_attribute, "title", "Still another topic: part 2") - assert_equal "Still another topic: part 2", topic.title - end - - def test_read_attribute - topic = Topic.new - topic.title = "Don't change the topic" - assert_equal "Don't change the topic", topic.send(:read_attribute, "title") - assert_equal "Don't change the topic", topic["title"] - - assert_equal "Don't change the topic", topic.send(:read_attribute, :title) - assert_equal "Don't change the topic", topic[:title] - end - - def test_read_attribute_when_false - topic = topics(:first) - topic.approved = false - assert !topic.approved?, "approved should be false" - topic.approved = "false" - assert !topic.approved?, "approved should be false" - end - - def test_read_attribute_when_true - topic = topics(:first) - topic.approved = true - assert topic.approved?, "approved should be true" - topic.approved = "true" - assert topic.approved?, "approved should be true" - end - - def test_read_write_boolean_attribute - topic = Topic.new - # puts "" - # puts "New Topic" - # puts topic.inspect - topic.approved = "false" - # puts "Expecting false" - # puts topic.inspect - assert !topic.approved?, "approved should be false" - topic.approved = "false" - # puts "Expecting false" - # puts topic.inspect - assert !topic.approved?, "approved should be false" - topic.approved = "true" - # puts "Expecting true" - # puts topic.inspect - assert topic.approved?, "approved should be true" - topic.approved = "true" - # puts "Expecting true" - # puts topic.inspect - assert topic.approved?, "approved should be true" - # puts "" - end - - def test_query_attribute_string - [nil, "", " "].each do |value| - assert_equal false, Topic.new(:author_name => value).author_name? - end - - assert_equal true, Topic.new(:author_name => "Name").author_name? - end - - def test_query_attribute_number - [nil, 0, "0"].each do |value| - assert_equal false, Developer.new(:salary => value).salary? - end - - assert_equal true, Developer.new(:salary => 1).salary? - assert_equal true, Developer.new(:salary => "1").salary? - end - - def test_query_attribute_boolean - [nil, "", false, "false", "f", 0].each do |value| - assert_equal false, Topic.new(:approved => value).approved? - end - - [true, "true", "1", 1].each do |value| - assert_equal true, Topic.new(:approved => value).approved? - end - end - - def test_query_attribute_with_custom_fields - object = Company.find_by_sql(<<-SQL).first - SELECT c1.*, c2.ruby_type as string_value, c2.rating as int_value - FROM companies c1, companies c2 - WHERE c1.firm_id = c2.id - AND c1.id = 2 - SQL - - assert_equal "Firm", object.string_value - assert object.string_value? - - object.string_value = " " - assert !object.string_value? - - assert_equal 1, object.int_value.to_i - assert object.int_value? - - object.int_value = "0" - assert !object.int_value? - end - - - def test_reader_for_invalid_column_names - Topic.send(:define_read_method, "mumub-jumbo".to_sym, "mumub-jumbo", nil) - assert !Topic.generated_methods.include?("mumub-jumbo") - end - - def test_non_attribute_access_and_assignment - topic = Topic.new - assert !topic.respond_to?("mumbo") - assert_raise(NoMethodError) { topic.mumbo } - assert_raise(NoMethodError) { topic.mumbo = 5 } - end - - def test_preserving_date_objects - if current_adapter?(:SybaseAdapter, :OracleAdapter) - # Sybase ctlib does not (yet?) support the date type; use datetime instead. - # Oracle treats all dates/times as Time. - assert_kind_of( - Time, Topic.find(1).last_read, - "The last_read attribute should be of the Time class" - ) - else - assert_kind_of( - Date, Topic.find(1).last_read, - "The last_read attribute should be of the Date class" - ) - end - end - - def test_preserving_time_objects - assert_kind_of( - Time, Topic.find(1).bonus_time, - "The bonus_time attribute should be of the Time class" - ) - - assert_kind_of( - Time, Topic.find(1).written_on, - "The written_on attribute should be of the Time class" - ) - - # For adapters which support microsecond resolution. - if current_adapter?(:PostgreSQLAdapter) - assert_equal 11, Topic.find(1).written_on.sec - assert_equal 223300, Topic.find(1).written_on.usec - assert_equal 9900, Topic.find(2).written_on.usec - end - end - - def test_custom_mutator - topic = Topic.find(1) - # This mutator is protected in the class definition - topic.send(:approved=, true) - assert topic.instance_variable_get("@custom_approved") - end - - def test_delete - topic = Topic.find(1) - assert_equal topic, topic.delete, 'topic.delete did not return self' - assert topic.frozen?, 'topic not frozen after delete' - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(topic.id) } - end - - def test_delete_doesnt_run_callbacks - Topic.find(1).delete - assert_not_nil Topic.find(2) - end - - def test_destroy - topic = Topic.find(1) - assert_equal topic, topic.destroy, 'topic.destroy did not return self' - assert topic.frozen?, 'topic not frozen after destroy' - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(topic.id) } - end - - def test_record_not_found_exception - assert_raise(ActiveRecord::RecordNotFound) { topicReloaded = Topic.find(99999) } - end - - def test_initialize_with_attributes - topic = Topic.new({ - "title" => "initialized from attributes", "written_on" => "2003-12-12 23:23" - }) - - assert_equal("initialized from attributes", topic.title) - end - - def test_initialize_with_invalid_attribute - begin - topic = Topic.new({ "title" => "test", - "last_read(1i)" => "2005", "last_read(2i)" => "2", "last_read(3i)" => "31"}) - rescue ActiveRecord::MultiparameterAssignmentErrors => ex - assert_equal(1, ex.errors.size) - assert_equal("last_read", ex.errors[0].attribute) - end - end - - def test_load - topics = Topic.find(:all, :order => 'id') - assert_equal(4, topics.size) - assert_equal(topics(:first).title, topics.first.title) - end - - def test_load_with_condition - topics = Topic.find(:all, :conditions => "author_name = 'Mary'") - - assert_equal(1, topics.size) - assert_equal(topics(:second).title, topics.first.title) - end - - def test_table_name_guesses - classes = [Category, Smarts, CreditCard, CreditCard::PinNumber, CreditCard::PinNumber::CvvCode, CreditCard::SubPinNumber, CreditCard::Brand, MasterCreditCard] - - assert_equal "topics", Topic.table_name - - assert_equal "categories", Category.table_name - assert_equal "smarts", Smarts.table_name - assert_equal "credit_cards", CreditCard.table_name - assert_equal "credit_card_pin_numbers", CreditCard::PinNumber.table_name - assert_equal "credit_card_pin_number_cvv_codes", CreditCard::PinNumber::CvvCode.table_name - assert_equal "credit_card_pin_numbers", CreditCard::SubPinNumber.table_name - assert_equal "categories", CreditCard::Brand.table_name - assert_equal "master_credit_cards", MasterCreditCard.table_name - - ActiveRecord::Base.pluralize_table_names = false - classes.each(&:reset_table_name) - - assert_equal "category", Category.table_name - assert_equal "smarts", Smarts.table_name - assert_equal "credit_card", CreditCard.table_name - assert_equal "credit_card_pin_number", CreditCard::PinNumber.table_name - assert_equal "credit_card_pin_number_cvv_code", CreditCard::PinNumber::CvvCode.table_name - assert_equal "credit_card_pin_number", CreditCard::SubPinNumber.table_name - assert_equal "category", CreditCard::Brand.table_name - assert_equal "master_credit_card", MasterCreditCard.table_name - - ActiveRecord::Base.pluralize_table_names = true - classes.each(&:reset_table_name) - - ActiveRecord::Base.table_name_prefix = "test_" - Category.reset_table_name - assert_equal "test_categories", Category.table_name - ActiveRecord::Base.table_name_suffix = "_test" - Category.reset_table_name - assert_equal "test_categories_test", Category.table_name - ActiveRecord::Base.table_name_prefix = "" - Category.reset_table_name - assert_equal "categories_test", Category.table_name - ActiveRecord::Base.table_name_suffix = "" - Category.reset_table_name - assert_equal "categories", Category.table_name - - ActiveRecord::Base.pluralize_table_names = false - ActiveRecord::Base.table_name_prefix = "test_" - Category.reset_table_name - assert_equal "test_category", Category.table_name - ActiveRecord::Base.table_name_suffix = "_test" - Category.reset_table_name - assert_equal "test_category_test", Category.table_name - ActiveRecord::Base.table_name_prefix = "" - Category.reset_table_name - assert_equal "category_test", Category.table_name - ActiveRecord::Base.table_name_suffix = "" - Category.reset_table_name - assert_equal "category", Category.table_name - - ActiveRecord::Base.pluralize_table_names = true - classes.each(&:reset_table_name) - end - - def test_destroy_all - original_count = Topic.count - topics_by_mary = Topic.count(:conditions => mary = "author_name = 'Mary'") - - Topic.destroy_all mary - assert_equal original_count - topics_by_mary, Topic.count - end - - def test_destroy_many - assert_equal 3, Client.count - Client.destroy([2, 3]) - assert_equal 1, Client.count - end - - def test_delete_many - original_count = Topic.count - Topic.delete(deleting = [1, 2]) - assert_equal original_count - deleting.size, Topic.count - end - - def test_boolean_attributes - assert ! Topic.find(1).approved? - assert Topic.find(2).approved? - end - - def test_increment_counter - Topic.increment_counter("replies_count", 1) - assert_equal 2, Topic.find(1).replies_count - - Topic.increment_counter("replies_count", 1) - assert_equal 3, Topic.find(1).replies_count - end - - def test_decrement_counter - Topic.decrement_counter("replies_count", 2) - assert_equal -1, Topic.find(2).replies_count - - Topic.decrement_counter("replies_count", 2) - assert_equal -2, Topic.find(2).replies_count - end - - def test_update_counter - category = categories(:general) - assert_nil category.categorizations_count - assert_equal 2, category.categorizations.count - - Category.update_counters(category.id, "categorizations_count" => category.categorizations.count) - category.reload - assert_not_nil category.categorizations_count - assert_equal 2, category.categorizations_count - - Category.update_counters(category.id, "categorizations_count" => category.categorizations.count) - category.reload - assert_not_nil category.categorizations_count - assert_equal 4, category.categorizations_count - - category_2 = categories(:technology) - count_1, count_2 = (category.categorizations_count || 0), (category_2.categorizations_count || 0) - Category.update_counters([category.id, category_2.id], "categorizations_count" => 2) - category.reload; category_2.reload - assert_equal count_1 + 2, category.categorizations_count - assert_equal count_2 + 2, category_2.categorizations_count - end - - def test_update_all - assert_equal Topic.count, Topic.update_all("content = 'bulk updated!'") - assert_equal "bulk updated!", Topic.find(1).content - assert_equal "bulk updated!", Topic.find(2).content - - assert_equal Topic.count, Topic.update_all(['content = ?', 'bulk updated again!']) - assert_equal "bulk updated again!", Topic.find(1).content - assert_equal "bulk updated again!", Topic.find(2).content - - assert_equal Topic.count, Topic.update_all(['content = ?', nil]) - assert_nil Topic.find(1).content - end - - def test_update_all_with_hash - assert_not_nil Topic.find(1).last_read - assert_equal Topic.count, Topic.update_all(:content => 'bulk updated with hash!', :last_read => nil) - assert_equal "bulk updated with hash!", Topic.find(1).content - assert_equal "bulk updated with hash!", Topic.find(2).content - assert_nil Topic.find(1).last_read - assert_nil Topic.find(2).last_read - end - - def test_update_all_with_non_standard_table_name - assert_equal 1, WarehouseThing.update_all(['value = ?', 0], ['id = ?', 1]) - assert_equal 0, WarehouseThing.find(1).value - end - - if current_adapter?(:MysqlAdapter) - def test_update_all_with_order_and_limit - assert_equal 1, Topic.update_all("content = 'bulk updated!'", nil, :limit => 1, :order => 'id DESC') - end - end - - def test_update_all_ignores_order_without_limit_from_association - author = authors(:david) - assert_nothing_raised do - assert_equal author.posts_with_comments_and_categories.length, author.posts_with_comments_and_categories.update_all([ "body = ?", "bulk update!" ]) - end - end - - def test_update_all_with_order_and_limit_updates_subset_only - author = authors(:david) - assert_nothing_raised do - assert_equal 1, author.posts_sorted_by_id_limited.size - assert_equal 2, author.posts_sorted_by_id_limited.find(:all, :limit => 2).size - assert_equal 1, author.posts_sorted_by_id_limited.update_all([ "body = ?", "bulk update!" ]) - assert_equal "bulk update!", posts(:welcome).body - assert_not_equal "bulk update!", posts(:thinking).body - end - end - - def test_update_many - topic_data = { 1 => { "content" => "1 updated" }, 2 => { "content" => "2 updated" } } - updated = Topic.update(topic_data.keys, topic_data.values) - - assert_equal 2, updated.size - assert_equal "1 updated", Topic.find(1).content - assert_equal "2 updated", Topic.find(2).content - end - - def test_delete_all - assert Topic.count > 0 - - assert_equal Topic.count, Topic.delete_all - end - - def test_update_by_condition - Topic.update_all "content = 'bulk updated!'", ["approved = ?", true] - assert_equal "Have a nice day", Topic.find(1).content - assert_equal "bulk updated!", Topic.find(2).content - end - - def test_attribute_present - t = Topic.new - t.title = "hello there!" - t.written_on = Time.now - assert t.attribute_present?("title") - assert t.attribute_present?("written_on") - assert !t.attribute_present?("content") - end - - def test_attribute_keys_on_new_instance - t = Topic.new - assert_equal nil, t.title, "The topics table has a title column, so it should be nil" - assert_raise(NoMethodError) { t.title2 } - end - - def test_class_name - assert_equal "Firm", ActiveRecord::Base.class_name("firms") - assert_equal "Category", ActiveRecord::Base.class_name("categories") - assert_equal "AccountHolder", ActiveRecord::Base.class_name("account_holder") - - ActiveRecord::Base.pluralize_table_names = false - assert_equal "Firms", ActiveRecord::Base.class_name( "firms" ) - ActiveRecord::Base.pluralize_table_names = true - - ActiveRecord::Base.table_name_prefix = "test_" - assert_equal "Firm", ActiveRecord::Base.class_name( "test_firms" ) - ActiveRecord::Base.table_name_suffix = "_tests" - assert_equal "Firm", ActiveRecord::Base.class_name( "test_firms_tests" ) - ActiveRecord::Base.table_name_prefix = "" - assert_equal "Firm", ActiveRecord::Base.class_name( "firms_tests" ) - ActiveRecord::Base.table_name_suffix = "" - assert_equal "Firm", ActiveRecord::Base.class_name( "firms" ) - end - - def test_null_fields - assert_nil Topic.find(1).parent_id - assert_nil Topic.create("title" => "Hey you").parent_id - end - - def test_default_values - topic = Topic.new - assert topic.approved? - assert_nil topic.written_on - assert_nil topic.bonus_time - assert_nil topic.last_read - - topic.save - - topic = Topic.find(topic.id) - assert topic.approved? - assert_nil topic.last_read - - # Oracle has some funky default handling, so it requires a bit of - # extra testing. See ticket #2788. - if current_adapter?(:OracleAdapter) - test = TestOracleDefault.new - assert_equal "X", test.test_char - assert_equal "hello", test.test_string - assert_equal 3, test.test_int - end - end - - # Oracle, and Sybase do not have a TIME datatype. - unless current_adapter?(:OracleAdapter, :SybaseAdapter) - def test_utc_as_time_zone - Topic.default_timezone = :utc - attributes = { "bonus_time" => "5:42:00AM" } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.utc(2000, 1, 1, 5, 42, 0), topic.bonus_time - Topic.default_timezone = :local - end - - def test_utc_as_time_zone_and_new - Topic.default_timezone = :utc - attributes = { "bonus_time(1i)"=>"2000", - "bonus_time(2i)"=>"1", - "bonus_time(3i)"=>"1", - "bonus_time(4i)"=>"10", - "bonus_time(5i)"=>"35", - "bonus_time(6i)"=>"50" } - topic = Topic.new(attributes) - assert_equal Time.utc(2000, 1, 1, 10, 35, 50), topic.bonus_time - Topic.default_timezone = :local - end - end - - def test_default_values_on_empty_strings - topic = Topic.new - topic.approved = nil - topic.last_read = nil - - topic.save - - topic = Topic.find(topic.id) - assert_nil topic.last_read - - # Sybase adapter does not allow nulls in boolean columns - if current_adapter?(:SybaseAdapter) - assert topic.approved == false - else - assert_nil topic.approved - end - end - - def test_equality - assert_equal Topic.find(1), Topic.find(2).topic - end - - def test_equality_of_new_records - assert_not_equal Topic.new, Topic.new - end - - def test_hashing - assert_equal [ Topic.find(1) ], [ Topic.find(2).topic ] & [ Topic.find(1) ] - end - - def test_delete_new_record - client = Client.new - client.delete - assert client.frozen? - end - - def test_delete_record_with_associations - client = Client.find(3) - client.delete - assert client.frozen? - assert_kind_of Firm, client.firm - assert_raise(ActiveSupport::FrozenObjectError) { client.name = "something else" } - end - - def test_destroy_new_record - client = Client.new - client.destroy - assert client.frozen? - end - - def test_destroy_record_with_associations - client = Client.find(3) - client.destroy - assert client.frozen? - assert_kind_of Firm, client.firm - assert_raise(ActiveSupport::FrozenObjectError) { client.name = "something else" } - end - - def test_update_attribute - assert !Topic.find(1).approved? - Topic.find(1).update_attribute("approved", true) - assert Topic.find(1).approved? - - Topic.find(1).update_attribute(:approved, false) - assert !Topic.find(1).approved? - end - - def test_update_attributes - topic = Topic.find(1) - assert !topic.approved? - assert_equal "The First Topic", topic.title - - topic.update_attributes("approved" => true, "title" => "The First Topic Updated") - topic.reload - assert topic.approved? - assert_equal "The First Topic Updated", topic.title - - topic.update_attributes(:approved => false, :title => "The First Topic") - topic.reload - assert !topic.approved? - assert_equal "The First Topic", topic.title - end - - def test_update_attributes! - reply = Reply.find(2) - assert_equal "The Second Topic of the day", reply.title - assert_equal "Have a nice day", reply.content - - reply.update_attributes!("title" => "The Second Topic of the day updated", "content" => "Have a nice evening") - reply.reload - assert_equal "The Second Topic of the day updated", reply.title - assert_equal "Have a nice evening", reply.content - - reply.update_attributes!(:title => "The Second Topic of the day", :content => "Have a nice day") - reply.reload - assert_equal "The Second Topic of the day", reply.title - assert_equal "Have a nice day", reply.content - - assert_raise(ActiveRecord::RecordInvalid) { reply.update_attributes!(:title => nil, :content => "Have a nice evening") } - end - - def test_mass_assignment_should_raise_exception_if_accessible_and_protected_attribute_writers_are_both_used - topic = TopicWithProtectedContentAndAccessibleAuthorName.new - assert_raise(RuntimeError) { topic.attributes = { "author_name" => "me" } } - assert_raise(RuntimeError) { topic.attributes = { "content" => "stuff" } } - end - - def test_mass_assignment_protection - firm = Firm.new - firm.attributes = { "name" => "Next Angle", "rating" => 5 } - assert_equal 1, firm.rating - end - - def test_mass_assignment_protection_against_class_attribute_writers - [:logger, :configurations, :primary_key_prefix_type, :table_name_prefix, :table_name_suffix, :pluralize_table_names, :colorize_logging, - :default_timezone, :schema_format, :lock_optimistically, :record_timestamps].each do |method| - assert Task.respond_to?(method) - assert Task.respond_to?("#{method}=") - assert Task.new.respond_to?(method) - assert !Task.new.respond_to?("#{method}=") - end - end - - def test_customized_primary_key_remains_protected - subscriber = Subscriber.new(:nick => 'webster123', :name => 'nice try') - assert_nil subscriber.id - - keyboard = Keyboard.new(:key_number => 9, :name => 'nice try') - assert_nil keyboard.id - end - - def test_customized_primary_key_remains_protected_when_referred_to_as_id - subscriber = Subscriber.new(:id => 'webster123', :name => 'nice try') - assert_nil subscriber.id - - keyboard = Keyboard.new(:id => 9, :name => 'nice try') - assert_nil keyboard.id - end - - def test_mass_assigning_invalid_attribute - firm = Firm.new - - assert_raise(ActiveRecord::UnknownAttributeError) do - firm.attributes = { "id" => 5, "type" => "Client", "i_dont_even_exist" => 20 } - end - end - - def test_mass_assignment_protection_on_defaults - firm = Firm.new - firm.attributes = { "id" => 5, "type" => "Client" } - assert_nil firm.id - assert_equal "Firm", firm[:type] - end - - def test_mass_assignment_accessible - reply = Reply.new("title" => "hello", "content" => "world", "approved" => true) - reply.save - - assert reply.approved? - - reply.approved = false - reply.save - - assert !reply.approved? - end - - def test_mass_assignment_protection_inheritance - assert_nil LoosePerson.accessible_attributes - assert_equal Set.new([ 'credit_rating', 'administrator' ]), LoosePerson.protected_attributes - - assert_nil LooseDescendant.accessible_attributes - assert_equal Set.new([ 'credit_rating', 'administrator', 'phone_number' ]), LooseDescendant.protected_attributes - - assert_nil LooseDescendantSecond.accessible_attributes - assert_equal Set.new([ 'credit_rating', 'administrator', 'phone_number', 'name' ]), LooseDescendantSecond.protected_attributes, 'Running attr_protected twice in one class should merge the protections' - - assert_nil TightPerson.protected_attributes - assert_equal Set.new([ 'name', 'address' ]), TightPerson.accessible_attributes - - assert_nil TightDescendant.protected_attributes - assert_equal Set.new([ 'name', 'address', 'phone_number' ]), TightDescendant.accessible_attributes - end - - def test_readonly_attributes - assert_equal Set.new([ 'title' , 'comments_count' ]), ReadonlyTitlePost.readonly_attributes - - post = ReadonlyTitlePost.create(:title => "cannot change this", :body => "changeable") - post.reload - assert_equal "cannot change this", post.title - - post.update_attributes(:title => "try to change", :body => "changed") - post.reload - assert_equal "cannot change this", post.title - assert_equal "changed", post.body - end - - def test_multiparameter_attributes_on_date - attributes = { "last_read(1i)" => "2004", "last_read(2i)" => "6", "last_read(3i)" => "24" } - topic = Topic.find(1) - topic.attributes = attributes - # note that extra #to_date call allows test to pass for Oracle, which - # treats dates/times the same - assert_date_from_db Date.new(2004, 6, 24), topic.last_read.to_date - end - - def test_multiparameter_attributes_on_date_with_empty_date - attributes = { "last_read(1i)" => "2004", "last_read(2i)" => "6", "last_read(3i)" => "" } - topic = Topic.find(1) - topic.attributes = attributes - # note that extra #to_date call allows test to pass for Oracle, which - # treats dates/times the same - assert_date_from_db Date.new(2004, 6, 1), topic.last_read.to_date - end - - def test_multiparameter_attributes_on_date_with_all_empty - attributes = { "last_read(1i)" => "", "last_read(2i)" => "", "last_read(3i)" => "" } - topic = Topic.find(1) - topic.attributes = attributes - assert_nil topic.last_read - end - - def test_multiparameter_attributes_on_time - attributes = { - "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24", - "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.local(2004, 6, 24, 16, 24, 0), topic.written_on - end - - def test_multiparameter_attributes_on_time_with_old_date - attributes = { - "written_on(1i)" => "1850", "written_on(2i)" => "6", "written_on(3i)" => "24", - "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00" - } - topic = Topic.find(1) - topic.attributes = attributes - # testing against to_s(:db) representation because either a Time or a DateTime might be returned, depending on platform - assert_equal "1850-06-24 16:24:00", topic.written_on.to_s(:db) - end - - def test_multiparameter_attributes_on_time_with_utc - ActiveRecord::Base.default_timezone = :utc - attributes = { - "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24", - "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.utc(2004, 6, 24, 16, 24, 0), topic.written_on - ensure - ActiveRecord::Base.default_timezone = :local - end - - def test_multiparameter_attributes_on_time_with_time_zone_aware_attributes - ActiveRecord::Base.time_zone_aware_attributes = true - ActiveRecord::Base.default_timezone = :utc - Time.zone = ActiveSupport::TimeZone[-28800] - attributes = { - "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24", - "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.utc(2004, 6, 24, 23, 24, 0), topic.written_on - assert_equal Time.utc(2004, 6, 24, 16, 24, 0), topic.written_on.time - assert_equal Time.zone, topic.written_on.time_zone - ensure - ActiveRecord::Base.time_zone_aware_attributes = false - ActiveRecord::Base.default_timezone = :local - Time.zone = nil - end - - def test_multiparameter_attributes_on_time_with_time_zone_aware_attributes_false - ActiveRecord::Base.time_zone_aware_attributes = false - Time.zone = ActiveSupport::TimeZone[-28800] - attributes = { - "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24", - "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.local(2004, 6, 24, 16, 24, 0), topic.written_on - assert_equal false, topic.written_on.respond_to?(:time_zone) - ensure - Time.zone = nil - end - - def test_multiparameter_attributes_on_time_with_skip_time_zone_conversion_for_attributes - ActiveRecord::Base.time_zone_aware_attributes = true - ActiveRecord::Base.default_timezone = :utc - Time.zone = ActiveSupport::TimeZone[-28800] - Topic.skip_time_zone_conversion_for_attributes = [:written_on] - attributes = { - "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24", - "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.utc(2004, 6, 24, 16, 24, 0), topic.written_on - assert_equal false, topic.written_on.respond_to?(:time_zone) - ensure - ActiveRecord::Base.time_zone_aware_attributes = false - ActiveRecord::Base.default_timezone = :local - Time.zone = nil - Topic.skip_time_zone_conversion_for_attributes = [] - end - - def test_multiparameter_attributes_on_time_only_column_with_time_zone_aware_attributes_does_not_do_time_zone_conversion - ActiveRecord::Base.time_zone_aware_attributes = true - ActiveRecord::Base.default_timezone = :utc - Time.zone = ActiveSupport::TimeZone[-28800] - attributes = { - "bonus_time(1i)" => "2000", "bonus_time(2i)" => "1", "bonus_time(3i)" => "1", - "bonus_time(4i)" => "16", "bonus_time(5i)" => "24" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.utc(2000, 1, 1, 16, 24, 0), topic.bonus_time - assert topic.bonus_time.utc? - ensure - ActiveRecord::Base.time_zone_aware_attributes = false - ActiveRecord::Base.default_timezone = :local - Time.zone = nil - end - - def test_multiparameter_attributes_on_time_with_empty_seconds - attributes = { - "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24", - "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.local(2004, 6, 24, 16, 24, 0), topic.written_on - end - - def test_multiparameter_mass_assignment_protector - task = Task.new - time = Time.mktime(2000, 1, 1, 1) - task.starting = time - attributes = { "starting(1i)" => "2004", "starting(2i)" => "6", "starting(3i)" => "24" } - task.attributes = attributes - assert_equal time, task.starting - end - - def test_multiparameter_assignment_of_aggregation - customer = Customer.new - address = Address.new("The Street", "The City", "The Country") - attributes = { "address(1)" => address.street, "address(2)" => address.city, "address(3)" => address.country } - customer.attributes = attributes - assert_equal address, customer.address - end - - def test_attributes_on_dummy_time - # Oracle, and Sybase do not have a TIME datatype. - return true if current_adapter?(:OracleAdapter, :SybaseAdapter) - - attributes = { - "bonus_time" => "5:42:00AM" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.local(2000, 1, 1, 5, 42, 0), topic.bonus_time - end - - def test_boolean - b_nil = Booleantest.create({ "value" => nil }) - nil_id = b_nil.id - b_false = Booleantest.create({ "value" => false }) - false_id = b_false.id - b_true = Booleantest.create({ "value" => true }) - true_id = b_true.id - - b_nil = Booleantest.find(nil_id) - assert_nil b_nil.value - b_false = Booleantest.find(false_id) - assert !b_false.value? - b_true = Booleantest.find(true_id) - assert b_true.value? - end - - def test_boolean_cast_from_string - b_blank = Booleantest.create({ "value" => "" }) - blank_id = b_blank.id - b_false = Booleantest.create({ "value" => "0" }) - false_id = b_false.id - b_true = Booleantest.create({ "value" => "1" }) - true_id = b_true.id - - b_blank = Booleantest.find(blank_id) - assert_nil b_blank.value - b_false = Booleantest.find(false_id) - assert !b_false.value? - b_true = Booleantest.find(true_id) - assert b_true.value? - end - - def test_new_record_returns_boolean - assert_equal Topic.new.new_record?, true - assert_equal Topic.find(1).new_record?, false - end - - def test_clone - topic = Topic.find(1) - cloned_topic = nil - assert_nothing_raised { cloned_topic = topic.clone } - assert_equal topic.title, cloned_topic.title - assert cloned_topic.new_record? - - # test if the attributes have been cloned - topic.title = "a" - cloned_topic.title = "b" - assert_equal "a", topic.title - assert_equal "b", cloned_topic.title - - # test if the attribute values have been cloned - topic.title = {"a" => "b"} - cloned_topic = topic.clone - cloned_topic.title["a"] = "c" - assert_equal "b", topic.title["a"] - - #test if attributes set as part of after_initialize are cloned correctly - assert_equal topic.author_email_address, cloned_topic.author_email_address - - # test if saved clone object differs from original - cloned_topic.save - assert !cloned_topic.new_record? - assert cloned_topic.id != topic.id - end - - def test_clone_with_aggregate_of_same_name_as_attribute - dev = DeveloperWithAggregate.find(1) - assert_kind_of DeveloperSalary, dev.salary - - clone = nil - assert_nothing_raised { clone = dev.clone } - assert_kind_of DeveloperSalary, clone.salary - assert_equal dev.salary.amount, clone.salary.amount - assert clone.new_record? - - # test if the attributes have been cloned - original_amount = clone.salary.amount - dev.salary.amount = 1 - assert_equal original_amount, clone.salary.amount - - assert clone.save - assert !clone.new_record? - assert clone.id != dev.id - end - - def test_clone_preserves_subtype - clone = nil - assert_nothing_raised { clone = Company.find(3).clone } - assert_kind_of Client, clone - end - - def test_bignum - company = Company.find(1) - company.rating = 2147483647 - company.save - company = Company.find(1) - assert_equal 2147483647, company.rating - end - - # TODO: extend defaults tests to other databases! - if current_adapter?(:PostgreSQLAdapter) - def test_default - default = Default.new - - # fixed dates / times - assert_equal Date.new(2004, 1, 1), default.fixed_date - assert_equal Time.local(2004, 1,1,0,0,0,0), default.fixed_time - - # char types - assert_equal 'Y', default.char1 - assert_equal 'a varchar field', default.char2 - assert_equal 'a text field', default.char3 - end - - class Geometric < ActiveRecord::Base; end - def test_geometric_content - - # accepted format notes: - # ()'s aren't required - # values can be a mix of float or integer - - g = Geometric.new( - :a_point => '(5.0, 6.1)', - #:a_line => '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql - :a_line_segment => '(2.0, 3), (5.5, 7.0)', - :a_box => '2.0, 3, 5.5, 7.0', - :a_path => '[(2.0, 3), (5.5, 7.0), (8.5, 11.0)]', # [ ] is an open path - :a_polygon => '((2.0, 3), (5.5, 7.0), (8.5, 11.0))', - :a_circle => '<(5.3, 10.4), 2>' - ) - - assert g.save - - # Reload and check that we have all the geometric attributes. - h = Geometric.find(g.id) - - assert_equal '(5,6.1)', h.a_point - assert_equal '[(2,3),(5.5,7)]', h.a_line_segment - assert_equal '(5.5,7),(2,3)', h.a_box # reordered to store upper right corner then bottom left corner - assert_equal '[(2,3),(5.5,7),(8.5,11)]', h.a_path - assert_equal '((2,3),(5.5,7),(8.5,11))', h.a_polygon - assert_equal '<(5.3,10.4),2>', h.a_circle - - # use a geometric function to test for an open path - objs = Geometric.find_by_sql ["select isopen(a_path) from geometrics where id = ?", g.id] - assert_equal objs[0].isopen, 't' - - # test alternate formats when defining the geometric types - - g = Geometric.new( - :a_point => '5.0, 6.1', - #:a_line => '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql - :a_line_segment => '((2.0, 3), (5.5, 7.0))', - :a_box => '(2.0, 3), (5.5, 7.0)', - :a_path => '((2.0, 3), (5.5, 7.0), (8.5, 11.0))', # ( ) is a closed path - :a_polygon => '2.0, 3, 5.5, 7.0, 8.5, 11.0', - :a_circle => '((5.3, 10.4), 2)' - ) - - assert g.save - - # Reload and check that we have all the geometric attributes. - h = Geometric.find(g.id) - - assert_equal '(5,6.1)', h.a_point - assert_equal '[(2,3),(5.5,7)]', h.a_line_segment - assert_equal '(5.5,7),(2,3)', h.a_box # reordered to store upper right corner then bottom left corner - assert_equal '((2,3),(5.5,7),(8.5,11))', h.a_path - assert_equal '((2,3),(5.5,7),(8.5,11))', h.a_polygon - assert_equal '<(5.3,10.4),2>', h.a_circle - - # use a geometric function to test for an closed path - objs = Geometric.find_by_sql ["select isclosed(a_path) from geometrics where id = ?", g.id] - assert_equal objs[0].isclosed, 't' - end - end - - class NumericData < ActiveRecord::Base - self.table_name = 'numeric_data' - end - - def test_numeric_fields - m = NumericData.new( - :bank_balance => 1586.43, - :big_bank_balance => BigDecimal("1000234000567.95"), - :world_population => 6000000000, - :my_house_population => 3 - ) - assert m.save - - m1 = NumericData.find(m.id) - assert_not_nil m1 - - # As with migration_test.rb, we should make world_population >= 2**62 - # to cover 64-bit platforms and test it is a Bignum, but the main thing - # is that it's an Integer. - assert_kind_of Integer, m1.world_population - assert_equal 6000000000, m1.world_population - - assert_kind_of Fixnum, m1.my_house_population - assert_equal 3, m1.my_house_population - - assert_kind_of BigDecimal, m1.bank_balance - assert_equal BigDecimal("1586.43"), m1.bank_balance - - assert_kind_of BigDecimal, m1.big_bank_balance - assert_equal BigDecimal("1000234000567.95"), m1.big_bank_balance - end - - def test_auto_id - auto = AutoId.new - auto.save - assert (auto.id > 0) - end - - def quote_column_name(name) - "<#{name}>" - end - - def test_quote_keys - ar = AutoId.new - source = {"foo" => "bar", "baz" => "quux"} - actual = ar.send(:quote_columns, self, source) - inverted = actual.invert - assert_equal("<foo>", inverted["bar"]) - assert_equal("<baz>", inverted["quux"]) - end - - def test_sql_injection_via_find - assert_raise(ActiveRecord::RecordNotFound, ActiveRecord::StatementInvalid) do - Topic.find("123456 OR id > 0") - end - end - - def test_column_name_properly_quoted - col_record = ColumnName.new - col_record.references = 40 - assert col_record.save - col_record.references = 41 - assert col_record.save - assert_not_nil c2 = ColumnName.find(col_record.id) - assert_equal(41, c2.references) - end - - def test_quoting_arrays - replies = Reply.find(:all, :conditions => [ "id IN (?)", topics(:first).replies.collect(&:id) ]) - assert_equal topics(:first).replies.size, replies.size - - replies = Reply.find(:all, :conditions => [ "id IN (?)", [] ]) - assert_equal 0, replies.size - end - - MyObject = Struct.new :attribute1, :attribute2 - - def test_serialized_attribute - myobj = MyObject.new('value1', 'value2') - topic = Topic.create("content" => myobj) - Topic.serialize("content", MyObject) - assert_equal(myobj, topic.content) - end - - def test_serialized_time_attribute - myobj = Time.local(2008,1,1,1,0) - topic = Topic.create("content" => myobj).reload - assert_equal(myobj, topic.content) - end - - def test_serialized_string_attribute - myobj = "Yes" - topic = Topic.create("content" => myobj).reload - assert_equal(myobj, topic.content) - end - - def test_nil_serialized_attribute_with_class_constraint - myobj = MyObject.new('value1', 'value2') - topic = Topic.new - assert_nil topic.content - end - - def test_should_raise_exception_on_serialized_attribute_with_type_mismatch - myobj = MyObject.new('value1', 'value2') - topic = Topic.new(:content => myobj) - assert topic.save - Topic.serialize(:content, Hash) - assert_raise(ActiveRecord::SerializationTypeMismatch) { Topic.find(topic.id).content } - ensure - Topic.serialize(:content) - end - - def test_serialized_attribute_with_class_constraint - settings = { "color" => "blue" } - Topic.serialize(:content, Hash) - topic = Topic.new(:content => settings) - assert topic.save - assert_equal(settings, Topic.find(topic.id).content) - ensure - Topic.serialize(:content) - end - - def test_quote - author_name = "\\ \001 ' \n \\n \"" - topic = Topic.create('author_name' => author_name) - assert_equal author_name, Topic.find(topic.id).author_name - end - - if RUBY_VERSION < '1.9' - def test_quote_chars - with_kcode('UTF8') do - str = 'The Narrator' - topic = Topic.create(:author_name => str) - assert_equal str, topic.author_name - - assert_kind_of ActiveSupport::Multibyte.proxy_class, str.mb_chars - topic = Topic.find_by_author_name(str.mb_chars) - - assert_kind_of Topic, topic - assert_equal str, topic.author_name, "The right topic should have been found by name even with name passed as Chars" - end - end - end - - def test_class_level_destroy - should_be_destroyed_reply = Reply.create("title" => "hello", "content" => "world") - Topic.find(1).replies << should_be_destroyed_reply - - Topic.destroy(1) - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1) } - assert_raise(ActiveRecord::RecordNotFound) { Reply.find(should_be_destroyed_reply.id) } - end - - def test_class_level_delete - should_be_destroyed_reply = Reply.create("title" => "hello", "content" => "world") - Topic.find(1).replies << should_be_destroyed_reply - - Topic.delete(1) - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1) } - assert_nothing_raised { Reply.find(should_be_destroyed_reply.id) } - end - - def test_increment_attribute - assert_equal 50, accounts(:signals37).credit_limit - accounts(:signals37).increment! :credit_limit - assert_equal 51, accounts(:signals37, :reload).credit_limit - - accounts(:signals37).increment(:credit_limit).increment!(:credit_limit) - assert_equal 53, accounts(:signals37, :reload).credit_limit - end - - def test_increment_nil_attribute - assert_nil topics(:first).parent_id - topics(:first).increment! :parent_id - assert_equal 1, topics(:first).parent_id - end - - def test_increment_attribute_by - assert_equal 50, accounts(:signals37).credit_limit - accounts(:signals37).increment! :credit_limit, 5 - assert_equal 55, accounts(:signals37, :reload).credit_limit - - accounts(:signals37).increment(:credit_limit, 1).increment!(:credit_limit, 3) - assert_equal 59, accounts(:signals37, :reload).credit_limit - end - - def test_decrement_attribute - assert_equal 50, accounts(:signals37).credit_limit - - accounts(:signals37).decrement!(:credit_limit) - assert_equal 49, accounts(:signals37, :reload).credit_limit - - accounts(:signals37).decrement(:credit_limit).decrement!(:credit_limit) - assert_equal 47, accounts(:signals37, :reload).credit_limit - end - - def test_decrement_attribute_by - assert_equal 50, accounts(:signals37).credit_limit - accounts(:signals37).decrement! :credit_limit, 5 - assert_equal 45, accounts(:signals37, :reload).credit_limit - - accounts(:signals37).decrement(:credit_limit, 1).decrement!(:credit_limit, 3) - assert_equal 41, accounts(:signals37, :reload).credit_limit - end - - def test_toggle_attribute - assert !topics(:first).approved? - topics(:first).toggle!(:approved) - assert topics(:first).approved? - topic = topics(:first) - topic.toggle(:approved) - assert !topic.approved? - topic.reload - assert topic.approved? - end - - def test_reload - t1 = Topic.find(1) - t2 = Topic.find(1) - t1.title = "something else" - t1.save - t2.reload - assert_equal t1.title, t2.title - end - - def test_define_attr_method_with_value - k = Class.new( ActiveRecord::Base ) - k.send(:define_attr_method, :table_name, "foo") - assert_equal "foo", k.table_name - end - - def test_define_attr_method_with_block - k = Class.new( ActiveRecord::Base ) - k.send(:define_attr_method, :primary_key) { "sys_" + original_primary_key } - assert_equal "sys_id", k.primary_key - end - - def test_set_table_name_with_value - k = Class.new( ActiveRecord::Base ) - k.table_name = "foo" - assert_equal "foo", k.table_name - k.set_table_name "bar" - assert_equal "bar", k.table_name - end - - def test_set_table_name_with_block - k = Class.new( ActiveRecord::Base ) - k.set_table_name { "ks" } - assert_equal "ks", k.table_name - end - - def test_set_primary_key_with_value - k = Class.new( ActiveRecord::Base ) - k.primary_key = "foo" - assert_equal "foo", k.primary_key - k.set_primary_key "bar" - assert_equal "bar", k.primary_key - end - - def test_set_primary_key_with_block - k = Class.new( ActiveRecord::Base ) - k.set_primary_key { "sys_" + original_primary_key } - assert_equal "sys_id", k.primary_key - end - - def test_set_inheritance_column_with_value - k = Class.new( ActiveRecord::Base ) - k.inheritance_column = "foo" - assert_equal "foo", k.inheritance_column - k.set_inheritance_column "bar" - assert_equal "bar", k.inheritance_column - end - - def test_set_inheritance_column_with_block - k = Class.new( ActiveRecord::Base ) - k.set_inheritance_column { original_inheritance_column + "_id" } - assert_equal "type_id", k.inheritance_column - end - - def test_count_with_join - res = Post.count_by_sql "SELECT COUNT(*) FROM posts LEFT JOIN comments ON posts.id=comments.post_id WHERE posts.#{QUOTED_TYPE} = 'Post'" - - res2 = Post.count(:conditions => "posts.#{QUOTED_TYPE} = 'Post'", :joins => "LEFT JOIN comments ON posts.id=comments.post_id") - assert_equal res, res2 - - res3 = nil - assert_nothing_raised do - res3 = Post.count(:conditions => "posts.#{QUOTED_TYPE} = 'Post'", - :joins => "LEFT JOIN comments ON posts.id=comments.post_id") - end - assert_equal res, res3 - - res4 = Post.count_by_sql "SELECT COUNT(p.id) FROM posts p, comments co WHERE p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id" - res5 = nil - assert_nothing_raised do - res5 = Post.count(:conditions => "p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id", - :joins => "p, comments co", - :select => "p.id") - end - - assert_equal res4, res5 - - unless current_adapter?(:SQLite2Adapter, :DeprecatedSQLiteAdapter) - res6 = Post.count_by_sql "SELECT COUNT(DISTINCT p.id) FROM posts p, comments co WHERE p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id" - res7 = nil - assert_nothing_raised do - res7 = Post.count(:conditions => "p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id", - :joins => "p, comments co", - :select => "p.id", - :distinct => true) - end - assert_equal res6, res7 - end - end - - def test_clear_association_cache_stored - firm = Firm.find(1) - assert_kind_of Firm, firm - - firm.clear_association_cache - assert_equal Firm.find(1).clients.collect{ |x| x.name }.sort, firm.clients.collect{ |x| x.name }.sort - end - - def test_clear_association_cache_new_record - firm = Firm.new - client_stored = Client.find(3) - client_new = Client.new - client_new.name = "The Joneses" - clients = [ client_stored, client_new ] - - firm.clients << clients - assert_equal clients.map(&:name).to_set, firm.clients.map(&:name).to_set - - firm.clear_association_cache - assert_equal clients.map(&:name).to_set, firm.clients.map(&:name).to_set - end - - def test_interpolate_sql - assert_nothing_raised { Category.new.send(:interpolate_sql, 'foo@bar') } - assert_nothing_raised { Category.new.send(:interpolate_sql, 'foo bar) baz') } - assert_nothing_raised { Category.new.send(:interpolate_sql, 'foo bar} baz') } - end - - def test_scoped_find_conditions - scoped_developers = Developer.with_scope(:find => { :conditions => 'salary > 90000' }) do - Developer.find(:all, :conditions => 'id < 5') - end - assert !scoped_developers.include?(developers(:david)) # David's salary is less than 90,000 - assert_equal 3, scoped_developers.size - end - - def test_scoped_find_limit_offset - scoped_developers = Developer.with_scope(:find => { :limit => 3, :offset => 2 }) do - Developer.find(:all, :order => 'id') - end - assert !scoped_developers.include?(developers(:david)) - assert !scoped_developers.include?(developers(:jamis)) - assert_equal 3, scoped_developers.size - - # Test without scoped find conditions to ensure we get the whole thing - developers = Developer.find(:all, :order => 'id') - assert_equal Developer.count, developers.size - end - - def test_scoped_find_order - # Test order in scope - scoped_developers = Developer.with_scope(:find => { :limit => 1, :order => 'salary DESC' }) do - Developer.find(:all) - end - assert_equal 'Jamis', scoped_developers.first.name - assert scoped_developers.include?(developers(:jamis)) - # Test scope without order and order in find - scoped_developers = Developer.with_scope(:find => { :limit => 1 }) do - Developer.find(:all, :order => 'salary DESC') - end - # Test scope order + find order, find has priority - scoped_developers = Developer.with_scope(:find => { :limit => 3, :order => 'id DESC' }) do - Developer.find(:all, :order => 'salary ASC') - end - assert scoped_developers.include?(developers(:poor_jamis)) - assert scoped_developers.include?(developers(:david)) - assert scoped_developers.include?(developers(:dev_10)) - # Test without scoped find conditions to ensure we get the right thing - developers = Developer.find(:all, :order => 'id', :limit => 1) - assert scoped_developers.include?(developers(:david)) - end - - def test_scoped_find_limit_offset_including_has_many_association - topics = Topic.with_scope(:find => {:limit => 1, :offset => 1, :include => :replies}) do - Topic.find(:all, :order => "topics.id") - end - assert_equal 1, topics.size - assert_equal 2, topics.first.id - end - - def test_scoped_find_order_including_has_many_association - developers = Developer.with_scope(:find => { :order => 'developers.salary DESC', :include => :projects }) do - Developer.find(:all) - end - assert developers.size >= 2 - for i in 1...developers.size - assert developers[i-1].salary >= developers[i].salary - end - end - - def test_scoped_find_with_group_and_having - developers = Developer.with_scope(:find => { :group => 'salary', :having => "SUM(salary) > 10000", :select => "SUM(salary) as salary" }) do - Developer.find(:all) - end - assert_equal 3, developers.size - end - - def test_find_last - last = Developer.find :last - assert_equal last, Developer.find(:first, :order => 'id desc') - end - - def test_last - assert_equal Developer.find(:first, :order => 'id desc'), Developer.last - end - - def test_all_with_conditions - assert_equal Developer.find(:all, :order => 'id desc'), Developer.all(:order => 'id desc') - end - - def test_find_ordered_last - last = Developer.find :last, :order => 'developers.salary ASC' - assert_equal last, Developer.find(:all, :order => 'developers.salary ASC').last - end - - def test_find_reverse_ordered_last - last = Developer.find :last, :order => 'developers.salary DESC' - assert_equal last, Developer.find(:all, :order => 'developers.salary DESC').last - end - - def test_find_multiple_ordered_last - last = Developer.find :last, :order => 'developers.name, developers.salary DESC' - assert_equal last, Developer.find(:all, :order => 'developers.name, developers.salary DESC').last - end - - def test_find_symbol_ordered_last - last = Developer.find :last, :order => :salary - assert_equal last, Developer.find(:all, :order => :salary).last - end - - def test_find_scoped_ordered_last - last_developer = Developer.with_scope(:find => { :order => 'developers.salary ASC' }) do - Developer.find(:last) - end - assert_equal last_developer, Developer.find(:all, :order => 'developers.salary ASC').last - end - - def test_abstract_class - assert !ActiveRecord::Base.abstract_class? - assert LoosePerson.abstract_class? - assert !LooseDescendant.abstract_class? - end - - def test_base_class - assert_equal LoosePerson, LoosePerson.base_class - assert_equal LooseDescendant, LooseDescendant.base_class - assert_equal TightPerson, TightPerson.base_class - assert_equal TightPerson, TightDescendant.base_class - - assert_equal Post, Post.base_class - assert_equal Post, SpecialPost.base_class - assert_equal Post, StiPost.base_class - assert_equal SubStiPost, SubStiPost.base_class - end - - def test_descends_from_active_record - # Tries to call Object.abstract_class? - assert_raise(NoMethodError) do - ActiveRecord::Base.descends_from_active_record? - end - - # Abstract subclass of AR::Base. - assert LoosePerson.descends_from_active_record? - - # Concrete subclass of an abstract class. - assert LooseDescendant.descends_from_active_record? - - # Concrete subclass of AR::Base. - assert TightPerson.descends_from_active_record? - - # Concrete subclass of a concrete class but has no type column. - assert TightDescendant.descends_from_active_record? - - # Concrete subclass of AR::Base. - assert Post.descends_from_active_record? - - # Abstract subclass of a concrete class which has a type column. - # This is pathological, as you'll never have Sub < Abstract < Concrete. - assert !StiPost.descends_from_active_record? - - # Concrete subclasses an abstract class which has a type column. - assert !SubStiPost.descends_from_active_record? - end - - def test_find_on_abstract_base_class_doesnt_use_type_condition - old_class = LooseDescendant - Object.send :remove_const, :LooseDescendant - - descendant = old_class.create! :first_name => 'bob' - assert_not_nil LoosePerson.find(descendant.id), "Should have found instance of LooseDescendant when finding abstract LoosePerson: #{descendant.inspect}" - ensure - unless Object.const_defined?(:LooseDescendant) - Object.const_set :LooseDescendant, old_class - end - end - - def test_assert_queries - query = lambda { ActiveRecord::Base.connection.execute 'select count(*) from developers' } - assert_queries(2) { 2.times { query.call } } - assert_queries 1, &query - assert_no_queries { assert true } - end - - def test_to_xml - xml = REXML::Document.new(topics(:first).to_xml(:indent => 0)) - bonus_time_in_current_timezone = topics(:first).bonus_time.xmlschema - written_on_in_current_timezone = topics(:first).written_on.xmlschema - last_read_in_current_timezone = topics(:first).last_read.xmlschema - - assert_equal "topic", xml.root.name - assert_equal "The First Topic" , xml.elements["//title"].text - assert_equal "David" , xml.elements["//author-name"].text - - assert_equal "1", xml.elements["//id"].text - assert_equal "integer" , xml.elements["//id"].attributes['type'] - - assert_equal "1", xml.elements["//replies-count"].text - assert_equal "integer" , xml.elements["//replies-count"].attributes['type'] - - assert_equal written_on_in_current_timezone, xml.elements["//written-on"].text - assert_equal "datetime" , xml.elements["//written-on"].attributes['type'] - - assert_equal "--- Have a nice day\n" , xml.elements["//content"].text - assert_equal "yaml" , xml.elements["//content"].attributes['type'] - - assert_equal "david@loudthinking.com", xml.elements["//author-email-address"].text - - assert_equal nil, xml.elements["//parent-id"].text - assert_equal "integer", xml.elements["//parent-id"].attributes['type'] - assert_equal "true", xml.elements["//parent-id"].attributes['nil'] - - if current_adapter?(:SybaseAdapter, :OracleAdapter) - assert_equal last_read_in_current_timezone, xml.elements["//last-read"].text - assert_equal "datetime" , xml.elements["//last-read"].attributes['type'] - else - assert_equal "2004-04-15", xml.elements["//last-read"].text - assert_equal "date" , xml.elements["//last-read"].attributes['type'] - end - - # Oracle and DB2 don't have true boolean or time-only fields - unless current_adapter?(:OracleAdapter, :DB2Adapter) - assert_equal "false", xml.elements["//approved"].text - assert_equal "boolean" , xml.elements["//approved"].attributes['type'] - - assert_equal bonus_time_in_current_timezone, xml.elements["//bonus-time"].text - assert_equal "datetime" , xml.elements["//bonus-time"].attributes['type'] - end - end - - def test_to_xml_skipping_attributes - xml = topics(:first).to_xml(:indent => 0, :skip_instruct => true, :except => [:title, :replies_count]) - assert_equal "<topic>", xml.first(7) - assert !xml.include?(%(<title>The First Topic</title>)) - assert xml.include?(%(<author-name>David</author-name>)) - - xml = topics(:first).to_xml(:indent => 0, :skip_instruct => true, :except => [:title, :author_name, :replies_count]) - assert !xml.include?(%(<title>The First Topic</title>)) - assert !xml.include?(%(<author-name>David</author-name>)) - end - - def test_to_xml_including_has_many_association - xml = topics(:first).to_xml(:indent => 0, :skip_instruct => true, :include => :replies, :except => :replies_count) - assert_equal "<topic>", xml.first(7) - assert xml.include?(%(<replies type="array"><reply>)) - assert xml.include?(%(<title>The Second Topic of the day</title>)) - end - - def test_array_to_xml_including_has_many_association - xml = [ topics(:first), topics(:second) ].to_xml(:indent => 0, :skip_instruct => true, :include => :replies) - assert xml.include?(%(<replies type="array"><reply>)) - end - - def test_array_to_xml_including_methods - xml = [ topics(:first), topics(:second) ].to_xml(:indent => 0, :skip_instruct => true, :methods => [ :topic_id ]) - assert xml.include?(%(<topic-id type="integer">#{topics(:first).topic_id}</topic-id>)), xml - assert xml.include?(%(<topic-id type="integer">#{topics(:second).topic_id}</topic-id>)), xml - end - - def test_array_to_xml_including_has_one_association - xml = [ companies(:first_firm), companies(:rails_core) ].to_xml(:indent => 0, :skip_instruct => true, :include => :account) - assert xml.include?(companies(:first_firm).account.to_xml(:indent => 0, :skip_instruct => true)) - assert xml.include?(companies(:rails_core).account.to_xml(:indent => 0, :skip_instruct => true)) - end - - def test_array_to_xml_including_belongs_to_association - xml = [ companies(:first_client), companies(:second_client), companies(:another_client) ].to_xml(:indent => 0, :skip_instruct => true, :include => :firm) - assert xml.include?(companies(:first_client).to_xml(:indent => 0, :skip_instruct => true)) - assert xml.include?(companies(:second_client).firm.to_xml(:indent => 0, :skip_instruct => true)) - assert xml.include?(companies(:another_client).firm.to_xml(:indent => 0, :skip_instruct => true)) - end - - def test_to_xml_including_belongs_to_association - xml = companies(:first_client).to_xml(:indent => 0, :skip_instruct => true, :include => :firm) - assert !xml.include?("<firm>") - - xml = companies(:second_client).to_xml(:indent => 0, :skip_instruct => true, :include => :firm) - assert xml.include?("<firm>") - end - - def test_to_xml_including_multiple_associations - xml = companies(:first_firm).to_xml(:indent => 0, :skip_instruct => true, :include => [ :clients, :account ]) - assert_equal "<firm>", xml.first(6) - assert xml.include?(%(<account>)) - assert xml.include?(%(<clients type="array"><client>)) - end - - def test_to_xml_including_multiple_associations_with_options - xml = companies(:first_firm).to_xml( - :indent => 0, :skip_instruct => true, - :include => { :clients => { :only => :name } } - ) - - assert_equal "<firm>", xml.first(6) - assert xml.include?(%(<client><name>Summit</name></client>)) - assert xml.include?(%(<clients type="array"><client>)) - end - - def test_to_xml_including_methods - xml = Company.new.to_xml(:methods => :arbitrary_method, :skip_instruct => true) - assert_equal "<company>", xml.first(9) - assert xml.include?(%(<arbitrary-method>I am Jack's profound disappointment</arbitrary-method>)) - end - - def test_to_xml_with_block - value = "Rockin' the block" - xml = Company.new.to_xml(:skip_instruct => true) do |xml| - xml.tag! "arbitrary-element", value - end - assert_equal "<company>", xml.first(9) - assert xml.include?(%(<arbitrary-element>#{value}</arbitrary-element>)) - end - - def test_type_name_with_module_should_handle_beginning - assert_equal 'ActiveRecord::Person', ActiveRecord::Base.send(:type_name_with_module, 'Person') - assert_equal '::Person', ActiveRecord::Base.send(:type_name_with_module, '::Person') - end - - def test_to_param_should_return_string - assert_kind_of String, Client.find(:first).to_param - end - - def test_inspect_class - assert_equal 'ActiveRecord::Base', ActiveRecord::Base.inspect - assert_equal 'LoosePerson(abstract)', LoosePerson.inspect - assert_match(/^Topic\(id: integer, title: string/, Topic.inspect) - end - - def test_inspect_instance - topic = topics(:first) - assert_equal %(#<Topic id: 1, title: "The First Topic", author_name: "David", author_email_address: "david@loudthinking.com", written_on: "#{topic.written_on.to_s(:db)}", bonus_time: "#{topic.bonus_time.to_s(:db)}", last_read: "#{topic.last_read.to_s(:db)}", content: "Have a nice day", approved: false, replies_count: 1, parent_id: nil, type: nil>), topic.inspect - end - - def test_inspect_new_instance - assert_match /Topic id: nil/, Topic.new.inspect - end - - def test_inspect_limited_select_instance - assert_equal %(#<Topic id: 1>), Topic.find(:first, :select => 'id', :conditions => 'id = 1').inspect - assert_equal %(#<Topic id: 1, title: "The First Topic">), Topic.find(:first, :select => 'id, title', :conditions => 'id = 1').inspect - end - - def test_inspect_class_without_table - assert_equal "NonExistentTable(Table doesn't exist)", NonExistentTable.inspect - end - - def test_attribute_for_inspect - t = topics(:first) - t.title = "The First Topic Now Has A Title With\nNewlines And More Than 50 Characters" - - assert_equal %("#{t.written_on.to_s(:db)}"), t.attribute_for_inspect(:written_on) - assert_equal '"The First Topic Now Has A Title With\nNewlines And M..."', t.attribute_for_inspect(:title) - end - - def test_becomes - assert_kind_of Reply, topics(:first).becomes(Reply) - assert_equal "The First Topic", topics(:first).becomes(Reply).title - end - - def test_silence_sets_log_level_to_error_in_block - original_logger = ActiveRecord::Base.logger - log = StringIO.new - ActiveRecord::Base.logger = Logger.new(log) - ActiveRecord::Base.logger.level = Logger::DEBUG - ActiveRecord::Base.silence do - ActiveRecord::Base.logger.warn "warn" - ActiveRecord::Base.logger.error "error" - end - assert_equal "error\n", log.string - ensure - ActiveRecord::Base.logger = original_logger - end - - def test_silence_sets_log_level_back_to_level_before_yield - original_logger = ActiveRecord::Base.logger - log = StringIO.new - ActiveRecord::Base.logger = Logger.new(log) - ActiveRecord::Base.logger.level = Logger::WARN - ActiveRecord::Base.silence do - end - assert_equal Logger::WARN, ActiveRecord::Base.logger.level - ensure - ActiveRecord::Base.logger = original_logger - end - - def test_benchmark_with_log_level - original_logger = ActiveRecord::Base.logger - log = StringIO.new - ActiveRecord::Base.logger = Logger.new(log) - ActiveRecord::Base.logger.level = Logger::WARN - ActiveRecord::Base.benchmark("Debug Topic Count", Logger::DEBUG) { Topic.count } - ActiveRecord::Base.benchmark("Warn Topic Count", Logger::WARN) { Topic.count } - ActiveRecord::Base.benchmark("Error Topic Count", Logger::ERROR) { Topic.count } - assert_no_match /Debug Topic Count/, log.string - assert_match /Warn Topic Count/, log.string - assert_match /Error Topic Count/, log.string - ensure - ActiveRecord::Base.logger = original_logger - end - - def test_benchmark_with_use_silence - original_logger = ActiveRecord::Base.logger - log = StringIO.new - ActiveRecord::Base.logger = Logger.new(log) - ActiveRecord::Base.benchmark("Logging", Logger::DEBUG, true) { ActiveRecord::Base.logger.debug "Loud" } - ActiveRecord::Base.benchmark("Logging", Logger::DEBUG, false) { ActiveRecord::Base.logger.debug "Quiet" } - assert_no_match /Loud/, log.string - assert_match /Quiet/, log.string - ensure - ActiveRecord::Base.logger = original_logger - end - - def test_create_with_custom_timestamps - custom_datetime = 1.hour.ago.beginning_of_day - - %w(created_at created_on updated_at updated_on).each do |attribute| - parrot = LiveParrot.create(:name => "colombian", attribute => custom_datetime) - assert_equal custom_datetime, parrot[attribute] - end - end -end diff --git a/vendor/rails/activerecord/test/cases/batches_test.rb b/vendor/rails/activerecord/test/cases/batches_test.rb deleted file mode 100644 index 5009a90..0000000 --- a/vendor/rails/activerecord/test/cases/batches_test.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'cases/helper' -require 'models/post' - -class EachTest < ActiveRecord::TestCase - fixtures :posts - - def setup - @posts = Post.all(:order => "id asc") - @total = Post.count - end - - def test_each_should_excecute_one_query_per_batch - assert_queries(Post.count + 1) do - Post.find_each(:batch_size => 1) do |post| - assert_kind_of Post, post - end - end - end - - def test_each_should_raise_if_the_order_is_set - assert_raise(RuntimeError) do - Post.find_each(:order => "title") { |post| post } - end - end - - def test_each_should_raise_if_the_limit_is_set - assert_raise(RuntimeError) do - Post.find_each(:limit => 1) { |post| post } - end - end - - def test_find_in_batches_should_return_batches - assert_queries(Post.count + 1) do - Post.find_in_batches(:batch_size => 1) do |batch| - assert_kind_of Array, batch - assert_kind_of Post, batch.first - end - end - end - - def test_find_in_batches_should_start_from_the_start_option - assert_queries(Post.count) do - Post.find_in_batches(:batch_size => 1, :start => 2) do |batch| - assert_kind_of Array, batch - assert_kind_of Post, batch.first - end - end - end - - def test_find_in_batches_shouldnt_excute_query_unless_needed - post_count = Post.count - - assert_queries(2) do - Post.find_in_batches(:batch_size => post_count) {|batch| assert_kind_of Array, batch } - end - - assert_queries(1) do - Post.find_in_batches(:batch_size => post_count + 1) {|batch| assert_kind_of Array, batch } - end - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/cases/binary_test.rb b/vendor/rails/activerecord/test/cases/binary_test.rb deleted file mode 100644 index 8545ba9..0000000 --- a/vendor/rails/activerecord/test/cases/binary_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -require "cases/helper" - -# Without using prepared statements, it makes no sense to test -# BLOB data with DB2 or Firebird, because the length of a statement -# is limited to 32KB. -unless current_adapter?(:SybaseAdapter, :DB2Adapter, :FirebirdAdapter) - require 'models/binary' - - class BinaryTest < ActiveRecord::TestCase - FIXTURES = %w(flowers.jpg example.log) - - def test_load_save - Binary.delete_all - - FIXTURES.each do |filename| - data = File.read(ASSETS_ROOT + "/#{filename}") - data.force_encoding('ASCII-8BIT') if data.respond_to?(:force_encoding) - data.freeze - - bin = Binary.new(:data => data) - assert_equal data, bin.data, 'Newly assigned data differs from original' - - bin.save! - assert_equal data, bin.data, 'Data differs from original after save' - - assert_equal data, bin.reload.data, 'Reloaded data differs from original' - end - end - end -end diff --git a/vendor/rails/activerecord/test/cases/calculations_test.rb b/vendor/rails/activerecord/test/cases/calculations_test.rb deleted file mode 100644 index 56dcdea..0000000 --- a/vendor/rails/activerecord/test/cases/calculations_test.rb +++ /dev/null @@ -1,348 +0,0 @@ -require "cases/helper" -require 'models/company' -require 'models/topic' -require 'models/edge' - -Company.has_many :accounts - -class NumericData < ActiveRecord::Base - self.table_name = 'numeric_data' -end - -class CalculationsTest < ActiveRecord::TestCase - fixtures :companies, :accounts, :topics - - def test_should_sum_field - assert_equal 318, Account.sum(:credit_limit) - end - - def test_should_average_field - value = Account.average(:credit_limit) - assert_kind_of BigDecimal, value - assert_equal BigDecimal.new('53.0'), value - end - - def test_should_return_nil_as_average - assert_nil NumericData.average(:bank_balance) - end - - def test_type_cast_calculated_value_should_convert_db_averages_of_fixnum_class_to_decimal - assert_equal 0, NumericData.send(:type_cast_calculated_value, 0, nil, 'avg') - assert_equal 53.0, NumericData.send(:type_cast_calculated_value, 53, nil, 'avg') - end - - def test_should_get_maximum_of_field - assert_equal 60, Account.maximum(:credit_limit) - end - - def test_should_get_maximum_of_field_with_include - assert_equal 50, Account.maximum(:credit_limit, :include => :firm, :conditions => "companies.name != 'Summit'") - end - - def test_should_get_maximum_of_field_with_scoped_include - Account.with_scope :find => { :include => :firm, :conditions => "companies.name != 'Summit'" } do - assert_equal 50, Account.maximum(:credit_limit) - end - end - - def test_should_get_minimum_of_field - assert_equal 50, Account.minimum(:credit_limit) - end - - def test_should_group_by_field - c = Account.sum(:credit_limit, :group => :firm_id) - [1,6,2].each { |firm_id| assert c.keys.include?(firm_id) } - end - - def test_should_group_by_summed_field - c = Account.sum(:credit_limit, :group => :firm_id) - assert_equal 50, c[1] - assert_equal 105, c[6] - assert_equal 60, c[2] - end - - def test_should_order_by_grouped_field - c = Account.sum(:credit_limit, :group => :firm_id, :order => "firm_id") - assert_equal [1, 2, 6, 9], c.keys.compact - end - - def test_should_order_by_calculation - c = Account.sum(:credit_limit, :group => :firm_id, :order => "sum_credit_limit desc, firm_id") - assert_equal [105, 60, 53, 50, 50], c.keys.collect { |k| c[k] } - assert_equal [6, 2, 9, 1], c.keys.compact - end - - def test_should_limit_calculation - c = Account.sum(:credit_limit, :conditions => "firm_id IS NOT NULL", - :group => :firm_id, :order => "firm_id", :limit => 2) - assert_equal [1, 2], c.keys.compact - end - - def test_should_limit_calculation_with_offset - c = Account.sum(:credit_limit, :conditions => "firm_id IS NOT NULL", - :group => :firm_id, :order => "firm_id", :limit => 2, :offset => 1) - assert_equal [2, 6], c.keys.compact - end - - def test_should_group_by_summed_field_having_condition - c = Account.sum(:credit_limit, :group => :firm_id, - :having => 'sum(credit_limit) > 50') - assert_nil c[1] - assert_equal 105, c[6] - assert_equal 60, c[2] - end - - def test_should_group_by_summed_field_having_sanitized_condition - c = Account.sum(:credit_limit, :group => :firm_id, - :having => ['sum(credit_limit) > ?', 50]) - assert_nil c[1] - assert_equal 105, c[6] - assert_equal 60, c[2] - end - - def test_should_group_by_summed_association - c = Account.sum(:credit_limit, :group => :firm) - assert_equal 50, c[companies(:first_firm)] - assert_equal 105, c[companies(:rails_core)] - assert_equal 60, c[companies(:first_client)] - end - - def test_should_sum_field_with_conditions - assert_equal 105, Account.sum(:credit_limit, :conditions => 'firm_id = 6') - end - - def test_should_return_zero_if_sum_conditions_return_nothing - assert_equal 0, Account.sum(:credit_limit, :conditions => '1 = 2') - assert_equal 0, companies(:rails_core).companies.sum(:id, :conditions => '1 = 2') - end - - def test_sum_should_return_valid_values_for_decimals - NumericData.create(:bank_balance => 19.83) - assert_equal 19.83, NumericData.sum(:bank_balance) - end - - def test_should_group_by_summed_field_with_conditions - c = Account.sum(:credit_limit, :conditions => 'firm_id > 1', - :group => :firm_id) - assert_nil c[1] - assert_equal 105, c[6] - assert_equal 60, c[2] - end - - def test_should_group_by_summed_field_with_conditions_and_having - c = Account.sum(:credit_limit, :conditions => 'firm_id > 1', - :group => :firm_id, - :having => 'sum(credit_limit) > 60') - assert_nil c[1] - assert_equal 105, c[6] - assert_nil c[2] - end - - def test_should_group_by_fields_with_table_alias - c = Account.sum(:credit_limit, :group => 'accounts.firm_id') - assert_equal 50, c[1] - assert_equal 105, c[6] - assert_equal 60, c[2] - end - - def test_should_calculate_with_invalid_field - assert_equal 6, Account.calculate(:count, '*') - assert_equal 6, Account.calculate(:count, :all) - end - - def test_should_calculate_grouped_with_invalid_field - c = Account.count(:all, :group => 'accounts.firm_id') - assert_equal 1, c[1] - assert_equal 2, c[6] - assert_equal 1, c[2] - end - - def test_should_calculate_grouped_association_with_invalid_field - c = Account.count(:all, :group => :firm) - assert_equal 1, c[companies(:first_firm)] - assert_equal 2, c[companies(:rails_core)] - assert_equal 1, c[companies(:first_client)] - end - - def test_should_group_by_association_with_non_numeric_foreign_key - ActiveRecord::Base.connection.expects(:select_all).returns([{"count_all" => 1, "firm_id" => "ABC"}]) - - firm = mock() - firm.expects(:id).returns("ABC") - firm.expects(:class).returns(Firm) - Company.expects(:find).with(["ABC"]).returns([firm]) - - column = mock() - column.expects(:name).at_least_once.returns(:firm_id) - column.expects(:type_cast).with("ABC").returns("ABC") - Account.expects(:columns).at_least_once.returns([column]) - - c = Account.count(:all, :group => :firm) - first_key = c.keys.first - assert_equal Firm, first_key.class - assert_equal 1, c[first_key] - end - - def test_should_calculate_grouped_association_with_foreign_key_option - Account.belongs_to :another_firm, :class_name => 'Firm', :foreign_key => 'firm_id' - c = Account.count(:all, :group => :another_firm) - assert_equal 1, c[companies(:first_firm)] - assert_equal 2, c[companies(:rails_core)] - assert_equal 1, c[companies(:first_client)] - end - - def test_should_not_modify_options_when_using_includes - options = {:conditions => 'companies.id > 1', :include => :firm} - options_copy = options.dup - - Account.count(:all, options) - assert_equal options_copy, options - end - - def test_should_calculate_grouped_by_function - c = Company.count(:all, :group => "UPPER(#{QUOTED_TYPE})") - assert_equal 2, c[nil] - assert_equal 1, c['DEPENDENTFIRM'] - assert_equal 3, c['CLIENT'] - assert_equal 2, c['FIRM'] - end - - def test_should_calculate_grouped_by_function_with_table_alias - c = Company.count(:all, :group => "UPPER(companies.#{QUOTED_TYPE})") - assert_equal 2, c[nil] - assert_equal 1, c['DEPENDENTFIRM'] - assert_equal 3, c['CLIENT'] - assert_equal 2, c['FIRM'] - end - - def test_should_not_overshadow_enumerable_sum - assert_equal 6, [1, 2, 3].sum(&:abs) - end - - def test_should_sum_scoped_field - assert_equal 15, companies(:rails_core).companies.sum(:id) - end - - def test_should_sum_scoped_field_with_conditions - assert_equal 8, companies(:rails_core).companies.sum(:id, :conditions => 'id > 7') - end - - def test_should_group_by_scoped_field - c = companies(:rails_core).companies.sum(:id, :group => :name) - assert_equal 7, c['Leetsoft'] - assert_equal 8, c['Jadedpixel'] - end - - def test_should_group_by_summed_field_with_conditions_and_having - c = companies(:rails_core).companies.sum(:id, :group => :name, - :having => 'sum(id) > 7') - assert_nil c['Leetsoft'] - assert_equal 8, c['Jadedpixel'] - end - - def test_should_reject_invalid_options - assert_nothing_raised do - [:count, :sum].each do |func| - # empty options are valid - Company.send(:validate_calculation_options, func) - # these options are valid for all calculations - [:select, :conditions, :joins, :order, :group, :having, :distinct].each do |opt| - Company.send(:validate_calculation_options, func, opt => true) - end - end - - # :include is only valid on :count - Company.send(:validate_calculation_options, :count, :include => true) - end - - assert_raise(ArgumentError) { Company.send(:validate_calculation_options, :sum, :foo => :bar) } - assert_raise(ArgumentError) { Company.send(:validate_calculation_options, :count, :foo => :bar) } - end - - def test_should_count_selected_field_with_include - assert_equal 6, Account.count(:distinct => true, :include => :firm) - assert_equal 4, Account.count(:distinct => true, :include => :firm, :select => :credit_limit) - end - - def test_should_count_scoped_select - Account.update_all("credit_limit = NULL") - assert_equal 0, Account.scoped(:select => "credit_limit").count - end - - def test_should_count_scoped_select_with_options - Account.update_all("credit_limit = NULL") - Account.last.update_attribute('credit_limit', 49) - Account.first.update_attribute('credit_limit', 51) - - assert_equal 1, Account.scoped(:select => "credit_limit").count(:conditions => ['credit_limit >= 50']) - end - - def test_should_count_manual_select_with_include - assert_equal 6, Account.count(:select => "DISTINCT accounts.id", :include => :firm) - end - - def test_count_with_column_parameter - assert_equal 5, Account.count(:firm_id) - end - - def test_count_with_column_and_options_parameter - assert_equal 2, Account.count(:firm_id, :conditions => "credit_limit = 50") - end - - def test_count_with_no_parameters_isnt_deprecated - assert_not_deprecated { Account.count } - end - - def test_count_with_too_many_parameters_raises - assert_raise(ArgumentError) { Account.count(1, 2, 3) } - end - - def test_should_sum_expression - assert_equal '636', Account.sum("2 * credit_limit") - end - - def test_count_with_from_option - assert_equal Company.count(:all), Company.count(:all, :from => 'companies') - assert_equal Account.count(:all, :conditions => "credit_limit = 50"), - Account.count(:all, :from => 'accounts', :conditions => "credit_limit = 50") - assert_equal Company.count(:type, :conditions => {:type => "Firm"}), - Company.count(:type, :conditions => {:type => "Firm"}, :from => 'companies') - end - - def test_sum_with_from_option - assert_equal Account.sum(:credit_limit), Account.sum(:credit_limit, :from => 'accounts') - assert_equal Account.sum(:credit_limit, :conditions => "credit_limit > 50"), - Account.sum(:credit_limit, :from => 'accounts', :conditions => "credit_limit > 50") - end - - def test_average_with_from_option - assert_equal Account.average(:credit_limit), Account.average(:credit_limit, :from => 'accounts') - assert_equal Account.average(:credit_limit, :conditions => "credit_limit > 50"), - Account.average(:credit_limit, :from => 'accounts', :conditions => "credit_limit > 50") - end - - def test_minimum_with_from_option - assert_equal Account.minimum(:credit_limit), Account.minimum(:credit_limit, :from => 'accounts') - assert_equal Account.minimum(:credit_limit, :conditions => "credit_limit > 50"), - Account.minimum(:credit_limit, :from => 'accounts', :conditions => "credit_limit > 50") - end - - def test_maximum_with_from_option - assert_equal Account.maximum(:credit_limit), Account.maximum(:credit_limit, :from => 'accounts') - assert_equal Account.maximum(:credit_limit, :conditions => "credit_limit > 50"), - Account.maximum(:credit_limit, :from => 'accounts', :conditions => "credit_limit > 50") - end - - def test_from_option_with_specified_index - if Edge.connection.adapter_name == 'MySQL' - assert_equal Edge.count(:all), Edge.count(:all, :from => 'edges USE INDEX(unique_edge_index)') - assert_equal Edge.count(:all, :conditions => 'sink_id < 5'), - Edge.count(:all, :from => 'edges USE INDEX(unique_edge_index)', :conditions => 'sink_id < 5') - end - end - - def test_from_option_with_table_different_than_class - assert_equal Account.count(:all), Company.count(:all, :from => 'accounts') - end - -end diff --git a/vendor/rails/activerecord/test/cases/callbacks_observers_test.rb b/vendor/rails/activerecord/test/cases/callbacks_observers_test.rb deleted file mode 100644 index 87de524..0000000 --- a/vendor/rails/activerecord/test/cases/callbacks_observers_test.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "cases/helper" - -class Comment < ActiveRecord::Base - attr_accessor :callers - - before_validation :record_callers - - def after_validation - record_callers - end - - def record_callers - callers << self.class if callers - end -end - -class CommentObserver < ActiveRecord::Observer - attr_accessor :callers - - def after_validation(model) - callers << self.class if callers - end -end - -class CallbacksObserversTest < ActiveRecord::TestCase - def test_model_callbacks_fire_before_observers_are_notified - callers = [] - - comment = Comment.new - comment.callers = callers - - CommentObserver.instance.callers = callers - - comment.valid? - - assert_equal [Comment, Comment, CommentObserver], callers, "model callbacks did not fire before observers were notified" - end -end diff --git a/vendor/rails/activerecord/test/cases/callbacks_test.rb b/vendor/rails/activerecord/test/cases/callbacks_test.rb deleted file mode 100644 index 95fddae..0000000 --- a/vendor/rails/activerecord/test/cases/callbacks_test.rb +++ /dev/null @@ -1,438 +0,0 @@ -require "cases/helper" - -class CallbackDeveloper < ActiveRecord::Base - set_table_name 'developers' - - class << self - def callback_string(callback_method) - "history << [#{callback_method.to_sym.inspect}, :string]" - end - - def callback_proc(callback_method) - Proc.new { |model| model.history << [callback_method, :proc] } - end - - def define_callback_method(callback_method) - define_method("#{callback_method}_method") do |model| - model.history << [callback_method, :method] - end - end - - def callback_object(callback_method) - klass = Class.new - klass.send(:define_method, callback_method) do |model| - model.history << [callback_method, :object] - end - klass.new - end - end - - ActiveRecord::Callbacks::CALLBACKS.each do |callback_method| - callback_method_sym = callback_method.to_sym - define_callback_method(callback_method_sym) - send(callback_method, callback_method_sym) - send(callback_method, callback_string(callback_method_sym)) - send(callback_method, callback_proc(callback_method_sym)) - send(callback_method, callback_object(callback_method_sym)) - send(callback_method) { |model| model.history << [callback_method_sym, :block] } - end - - def history - @history ||= [] - end - - # after_initialize and after_find are invoked only if instance methods have been defined. - def after_initialize - end - - def after_find - end -end - -class ParentDeveloper < ActiveRecord::Base - set_table_name 'developers' - attr_accessor :after_save_called - before_validation {|record| record.after_save_called = true} -end - -class ChildDeveloper < ParentDeveloper - -end - -class RecursiveCallbackDeveloper < ActiveRecord::Base - set_table_name 'developers' - - before_save :on_before_save - after_save :on_after_save - - attr_reader :on_before_save_called, :on_after_save_called - - def on_before_save - @on_before_save_called ||= 0 - @on_before_save_called += 1 - save unless @on_before_save_called > 1 - end - - def on_after_save - @on_after_save_called ||= 0 - @on_after_save_called += 1 - save unless @on_after_save_called > 1 - end -end - -class ImmutableDeveloper < ActiveRecord::Base - set_table_name 'developers' - - validates_inclusion_of :salary, :in => 50000..200000 - - before_save :cancel - before_destroy :cancel - - def cancelled? - @cancelled == true - end - - private - def cancel - @cancelled = true - false - end -end - -class ImmutableMethodDeveloper < ActiveRecord::Base - set_table_name 'developers' - - validates_inclusion_of :salary, :in => 50000..200000 - - def cancelled? - @cancelled == true - end - - def before_save - @cancelled = true - false - end - - def before_destroy - @cancelled = true - false - end -end - -class CallbackCancellationDeveloper < ActiveRecord::Base - set_table_name 'developers' - - attr_reader :after_save_called, :after_create_called, :after_update_called, :after_destroy_called - attr_accessor :cancel_before_save, :cancel_before_create, :cancel_before_update, :cancel_before_destroy - - def before_save; !@cancel_before_save; end - def before_create; !@cancel_before_create; end - def before_update; !@cancel_before_update; end - def before_destroy; !@cancel_before_destroy; end - - def after_save; @after_save_called = true; end - def after_update; @after_update_called = true; end - def after_create; @after_create_called = true; end - def after_destroy; @after_destroy_called = true; end -end - -class CallbacksTest < ActiveRecord::TestCase - fixtures :developers - - def test_initialize - david = CallbackDeveloper.new - assert_equal [ - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - ], david.history - end - - def test_find - david = CallbackDeveloper.find(1) - assert_equal [ - [ :after_find, :string ], - [ :after_find, :proc ], - [ :after_find, :object ], - [ :after_find, :block ], - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - ], david.history - end - - def test_new_valid? - david = CallbackDeveloper.new - david.valid? - assert_equal [ - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - [ :before_validation, :string ], - [ :before_validation, :proc ], - [ :before_validation, :object ], - [ :before_validation, :block ], - [ :before_validation_on_create, :string ], - [ :before_validation_on_create, :proc ], - [ :before_validation_on_create, :object ], - [ :before_validation_on_create, :block ], - [ :after_validation, :string ], - [ :after_validation, :proc ], - [ :after_validation, :object ], - [ :after_validation, :block ], - [ :after_validation_on_create, :string ], - [ :after_validation_on_create, :proc ], - [ :after_validation_on_create, :object ], - [ :after_validation_on_create, :block ] - ], david.history - end - - def test_existing_valid? - david = CallbackDeveloper.find(1) - david.valid? - assert_equal [ - [ :after_find, :string ], - [ :after_find, :proc ], - [ :after_find, :object ], - [ :after_find, :block ], - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - [ :before_validation, :string ], - [ :before_validation, :proc ], - [ :before_validation, :object ], - [ :before_validation, :block ], - [ :before_validation_on_update, :string ], - [ :before_validation_on_update, :proc ], - [ :before_validation_on_update, :object ], - [ :before_validation_on_update, :block ], - [ :after_validation, :string ], - [ :after_validation, :proc ], - [ :after_validation, :object ], - [ :after_validation, :block ], - [ :after_validation_on_update, :string ], - [ :after_validation_on_update, :proc ], - [ :after_validation_on_update, :object ], - [ :after_validation_on_update, :block ] - ], david.history - end - - def test_create - david = CallbackDeveloper.create('name' => 'David', 'salary' => 1000000) - assert_equal [ - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - [ :before_validation, :string ], - [ :before_validation, :proc ], - [ :before_validation, :object ], - [ :before_validation, :block ], - [ :before_validation_on_create, :string ], - [ :before_validation_on_create, :proc ], - [ :before_validation_on_create, :object ], - [ :before_validation_on_create, :block ], - [ :after_validation, :string ], - [ :after_validation, :proc ], - [ :after_validation, :object ], - [ :after_validation, :block ], - [ :after_validation_on_create, :string ], - [ :after_validation_on_create, :proc ], - [ :after_validation_on_create, :object ], - [ :after_validation_on_create, :block ], - [ :before_save, :string ], - [ :before_save, :proc ], - [ :before_save, :object ], - [ :before_save, :block ], - [ :before_create, :string ], - [ :before_create, :proc ], - [ :before_create, :object ], - [ :before_create, :block ], - [ :after_create, :string ], - [ :after_create, :proc ], - [ :after_create, :object ], - [ :after_create, :block ], - [ :after_save, :string ], - [ :after_save, :proc ], - [ :after_save, :object ], - [ :after_save, :block ] - ], david.history - end - - def test_save - david = CallbackDeveloper.find(1) - david.save - assert_equal [ - [ :after_find, :string ], - [ :after_find, :proc ], - [ :after_find, :object ], - [ :after_find, :block ], - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - [ :before_validation, :string ], - [ :before_validation, :proc ], - [ :before_validation, :object ], - [ :before_validation, :block ], - [ :before_validation_on_update, :string ], - [ :before_validation_on_update, :proc ], - [ :before_validation_on_update, :object ], - [ :before_validation_on_update, :block ], - [ :after_validation, :string ], - [ :after_validation, :proc ], - [ :after_validation, :object ], - [ :after_validation, :block ], - [ :after_validation_on_update, :string ], - [ :after_validation_on_update, :proc ], - [ :after_validation_on_update, :object ], - [ :after_validation_on_update, :block ], - [ :before_save, :string ], - [ :before_save, :proc ], - [ :before_save, :object ], - [ :before_save, :block ], - [ :before_update, :string ], - [ :before_update, :proc ], - [ :before_update, :object ], - [ :before_update, :block ], - [ :after_update, :string ], - [ :after_update, :proc ], - [ :after_update, :object ], - [ :after_update, :block ], - [ :after_save, :string ], - [ :after_save, :proc ], - [ :after_save, :object ], - [ :after_save, :block ] - ], david.history - end - - def test_destroy - david = CallbackDeveloper.find(1) - david.destroy - assert_equal [ - [ :after_find, :string ], - [ :after_find, :proc ], - [ :after_find, :object ], - [ :after_find, :block ], - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - [ :before_destroy, :string ], - [ :before_destroy, :proc ], - [ :before_destroy, :object ], - [ :before_destroy, :block ], - [ :after_destroy, :string ], - [ :after_destroy, :proc ], - [ :after_destroy, :object ], - [ :after_destroy, :block ] - ], david.history - end - - def test_delete - david = CallbackDeveloper.find(1) - CallbackDeveloper.delete(david.id) - assert_equal [ - [ :after_find, :string ], - [ :after_find, :proc ], - [ :after_find, :object ], - [ :after_find, :block ], - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - ], david.history - end - - def test_before_save_returning_false - david = ImmutableDeveloper.find(1) - assert david.valid? - assert !david.save - assert_raise(ActiveRecord::RecordNotSaved) { david.save! } - - david = ImmutableDeveloper.find(1) - david.salary = 10_000_000 - assert !david.valid? - assert !david.save - assert_raise(ActiveRecord::RecordInvalid) { david.save! } - - someone = CallbackCancellationDeveloper.find(1) - someone.cancel_before_save = true - assert someone.valid? - assert !someone.save - assert_save_callbacks_not_called(someone) - end - - def test_before_create_returning_false - someone = CallbackCancellationDeveloper.new - someone.cancel_before_create = true - assert someone.valid? - assert !someone.save - assert_save_callbacks_not_called(someone) - end - - def test_before_update_returning_false - someone = CallbackCancellationDeveloper.find(1) - someone.cancel_before_update = true - assert someone.valid? - assert !someone.save - assert_save_callbacks_not_called(someone) - end - - def test_before_destroy_returning_false - david = ImmutableDeveloper.find(1) - assert !david.destroy - assert_not_nil ImmutableDeveloper.find_by_id(1) - - someone = CallbackCancellationDeveloper.find(1) - someone.cancel_before_destroy = true - assert !someone.destroy - assert !someone.after_destroy_called - end - - def assert_save_callbacks_not_called(someone) - assert !someone.after_save_called - assert !someone.after_create_called - assert !someone.after_update_called - end - private :assert_save_callbacks_not_called - - def test_zzz_callback_returning_false # must be run last since we modify CallbackDeveloper - david = CallbackDeveloper.find(1) - CallbackDeveloper.before_validation proc { |model| model.history << [:before_validation, :returning_false]; return false } - CallbackDeveloper.before_validation proc { |model| model.history << [:before_validation, :should_never_get_here] } - david.save - assert_equal [ - [ :after_find, :string ], - [ :after_find, :proc ], - [ :after_find, :object ], - [ :after_find, :block ], - [ :after_initialize, :string ], - [ :after_initialize, :proc ], - [ :after_initialize, :object ], - [ :after_initialize, :block ], - [ :before_validation, :string ], - [ :before_validation, :proc ], - [ :before_validation, :object ], - [ :before_validation, :block ], - [ :before_validation, :returning_false ] - ], david.history - end - - def test_inheritence_of_callbacks - parent = ParentDeveloper.new - assert !parent.after_save_called - parent.save - assert parent.after_save_called - - child = ChildDeveloper.new - assert !child.after_save_called - child.save - assert child.after_save_called - end - -end diff --git a/vendor/rails/activerecord/test/cases/class_inheritable_attributes_test.rb b/vendor/rails/activerecord/test/cases/class_inheritable_attributes_test.rb deleted file mode 100644 index abeb63c..0000000 --- a/vendor/rails/activerecord/test/cases/class_inheritable_attributes_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'test/unit' -require "cases/helper" -require 'active_support/core_ext/class/inheritable_attributes' - -class A - include ClassInheritableAttributes -end - -class B < A - write_inheritable_array "first", [ :one, :two ] -end - -class C < A - write_inheritable_array "first", [ :three ] -end - -class D < B - write_inheritable_array "first", [ :four ] -end - - -class ClassInheritableAttributesTest < ActiveRecord::TestCase - def test_first_level - assert_equal [ :one, :two ], B.read_inheritable_attribute("first") - assert_equal [ :three ], C.read_inheritable_attribute("first") - end - - def test_second_level - assert_equal [ :one, :two, :four ], D.read_inheritable_attribute("first") - assert_equal [ :one, :two ], B.read_inheritable_attribute("first") - end -end diff --git a/vendor/rails/activerecord/test/cases/column_alias_test.rb b/vendor/rails/activerecord/test/cases/column_alias_test.rb deleted file mode 100644 index 40707d9..0000000 --- a/vendor/rails/activerecord/test/cases/column_alias_test.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "cases/helper" -require 'models/topic' - -class TestColumnAlias < ActiveRecord::TestCase - fixtures :topics - - QUERY = if 'Oracle' == ActiveRecord::Base.connection.adapter_name - 'SELECT id AS pk FROM topics WHERE ROWNUM < 2' - else - 'SELECT id AS pk FROM topics' - end - - def test_column_alias - records = Topic.connection.select_all(QUERY) - assert_equal 'pk', records[0].keys[0] - end -end diff --git a/vendor/rails/activerecord/test/cases/column_definition_test.rb b/vendor/rails/activerecord/test/cases/column_definition_test.rb deleted file mode 100644 index 98abc8e..0000000 --- a/vendor/rails/activerecord/test/cases/column_definition_test.rb +++ /dev/null @@ -1,36 +0,0 @@ -require "cases/helper" - -class ColumnDefinitionTest < ActiveRecord::TestCase - def setup - @adapter = ActiveRecord::ConnectionAdapters::AbstractAdapter.new(nil) - def @adapter.native_database_types - {:string => "varchar"} - end - end - - # Avoid column definitions in create table statements like: - # `title` varchar(255) DEFAULT NULL - def test_should_not_include_default_clause_when_default_is_null - column = ActiveRecord::ConnectionAdapters::Column.new("title", nil, "varchar(20)") - column_def = ActiveRecord::ConnectionAdapters::ColumnDefinition.new( - @adapter, column.name, "string", - column.limit, column.precision, column.scale, column.default, column.null) - assert_equal "title varchar(20)", column_def.to_sql - end - - def test_should_include_default_clause_when_default_is_present - column = ActiveRecord::ConnectionAdapters::Column.new("title", "Hello", "varchar(20)") - column_def = ActiveRecord::ConnectionAdapters::ColumnDefinition.new( - @adapter, column.name, "string", - column.limit, column.precision, column.scale, column.default, column.null) - assert_equal %Q{title varchar(20) DEFAULT 'Hello'}, column_def.to_sql - end - - def test_should_specify_not_null_if_null_option_is_false - column = ActiveRecord::ConnectionAdapters::Column.new("title", "Hello", "varchar(20)", false) - column_def = ActiveRecord::ConnectionAdapters::ColumnDefinition.new( - @adapter, column.name, "string", - column.limit, column.precision, column.scale, column.default, column.null) - assert_equal %Q{title varchar(20) DEFAULT 'Hello' NOT NULL}, column_def.to_sql - end -end diff --git a/vendor/rails/activerecord/test/cases/connection_pool_test.rb b/vendor/rails/activerecord/test/cases/connection_pool_test.rb deleted file mode 100644 index cc9b2a4..0000000 --- a/vendor/rails/activerecord/test/cases/connection_pool_test.rb +++ /dev/null @@ -1,25 +0,0 @@ -require "cases/helper" - -class ConnectionManagementTest < ActiveRecord::TestCase - def setup - @env = {} - @app = stub('App') - @management = ActiveRecord::ConnectionAdapters::ConnectionManagement.new(@app) - - @connections_cleared = false - ActiveRecord::Base.stubs(:clear_active_connections!).with { @connections_cleared = true } - end - - test "clears active connections after each call" do - @app.expects(:call).with(@env) - @management.call(@env) - assert @connections_cleared - end - - test "doesn't clear active connections when running in a test case" do - @env['rack.test'] = true - @app.expects(:call).with(@env) - @management.call(@env) - assert !@connections_cleared - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/cases/connection_test_firebird.rb b/vendor/rails/activerecord/test/cases/connection_test_firebird.rb deleted file mode 100644 index f57ea68..0000000 --- a/vendor/rails/activerecord/test/cases/connection_test_firebird.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "cases/helper" - -class FirebirdConnectionTest < ActiveRecord::TestCase - def test_charset_properly_set - fb_conn = ActiveRecord::Base.connection.instance_variable_get(:@connection) - assert_equal 'UTF8', fb_conn.database.character_set - end -end diff --git a/vendor/rails/activerecord/test/cases/connection_test_mysql.rb b/vendor/rails/activerecord/test/cases/connection_test_mysql.rb deleted file mode 100644 index f79ee2f..0000000 --- a/vendor/rails/activerecord/test/cases/connection_test_mysql.rb +++ /dev/null @@ -1,56 +0,0 @@ -require "cases/helper" - -class MysqlConnectionTest < ActiveRecord::TestCase - def setup - super - @connection = ActiveRecord::Base.connection - end - - def test_mysql_reconnect_attribute_after_connection_with_reconnect_true - run_without_connection do |orig_connection| - ActiveRecord::Base.establish_connection(orig_connection.merge({:reconnect => true})) - assert ActiveRecord::Base.connection.raw_connection.reconnect - end - end - - def test_mysql_reconnect_attribute_after_connection_with_reconnect_false - run_without_connection do |orig_connection| - ActiveRecord::Base.establish_connection(orig_connection.merge({:reconnect => false})) - assert !ActiveRecord::Base.connection.raw_connection.reconnect - end - end - - def test_no_automatic_reconnection_after_timeout - assert @connection.active? - @connection.update('set @@wait_timeout=1') - sleep 2 - assert !@connection.active? - end - - def test_successful_reconnection_after_timeout_with_manual_reconnect - assert @connection.active? - @connection.update('set @@wait_timeout=1') - sleep 2 - @connection.reconnect! - assert @connection.active? - end - - def test_successful_reconnection_after_timeout_with_verify - assert @connection.active? - @connection.update('set @@wait_timeout=1') - sleep 2 - @connection.verify! - assert @connection.active? - end - - private - - def run_without_connection - original_connection = ActiveRecord::Base.remove_connection - begin - yield original_connection - ensure - ActiveRecord::Base.establish_connection(original_connection) - end - end -end diff --git a/vendor/rails/activerecord/test/cases/copy_table_test_sqlite.rb b/vendor/rails/activerecord/test/cases/copy_table_test_sqlite.rb deleted file mode 100644 index 72bd7e2..0000000 --- a/vendor/rails/activerecord/test/cases/copy_table_test_sqlite.rb +++ /dev/null @@ -1,80 +0,0 @@ -require "cases/helper" - -class CopyTableTest < ActiveRecord::TestCase - fixtures :companies, :comments - - def setup - @connection = ActiveRecord::Base.connection - class << @connection - public :copy_table, :table_structure, :indexes - end - end - - def test_copy_table(from = 'companies', to = 'companies2', options = {}) - assert_nothing_raised {copy_table(from, to, options)} - assert_equal row_count(from), row_count(to) - - if block_given? - yield from, to, options - else - assert_equal column_names(from), column_names(to) - end - - @connection.drop_table(to) rescue nil - end - - def test_copy_table_renaming_column - test_copy_table('companies', 'companies2', - :rename => {'client_of' => 'fan_of'}) do |from, to, options| - expected = column_values(from, 'client_of') - assert expected.any?, 'only nils in resultset; real values are needed' - assert_equal expected, column_values(to, 'fan_of') - end - end - - def test_copy_table_with_index - test_copy_table('comments', 'comments_with_index') do - @connection.add_index('comments_with_index', ['post_id', 'type']) - test_copy_table('comments_with_index', 'comments_with_index2') do - assert_equal table_indexes_without_name('comments_with_index'), - table_indexes_without_name('comments_with_index2') - end - end - end - - def test_copy_table_without_primary_key - test_copy_table('developers_projects', 'programmers_projects') - end - - def test_copy_table_with_id_col_that_is_not_primary_key - test_copy_table('goofy_string_id', 'goofy_string_id2') do |from, to, options| - original_id = @connection.columns('goofy_string_id').detect{|col| col.name == 'id' } - copied_id = @connection.columns('goofy_string_id2').detect{|col| col.name == 'id' } - assert_equal original_id.type, copied_id.type - assert_equal original_id.sql_type, copied_id.sql_type - assert_equal original_id.limit, copied_id.limit - assert_equal original_id.primary, copied_id.primary - end - end - -protected - def copy_table(from, to, options = {}) - @connection.copy_table(from, to, {:temporary => true}.merge(options)) - end - - def column_names(table) - @connection.table_structure(table).map {|column| column['name']} - end - - def column_values(table, column) - @connection.select_all("SELECT #{column} FROM #{table} ORDER BY id").map {|row| row[column]} - end - - def table_indexes_without_name(table) - @connection.indexes('comments_with_index').delete(:name) - end - - def row_count(table) - @connection.select_one("SELECT COUNT(*) AS count FROM #{table}")['count'] - end -end diff --git a/vendor/rails/activerecord/test/cases/database_statements_test.rb b/vendor/rails/activerecord/test/cases/database_statements_test.rb deleted file mode 100644 index 6274d52..0000000 --- a/vendor/rails/activerecord/test/cases/database_statements_test.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "cases/helper" - -class DatabaseStatementsTest < ActiveRecord::TestCase - def setup - @connection = ActiveRecord::Base.connection - end - - def test_insert_should_return_the_inserted_id - id = @connection.insert("INSERT INTO accounts (firm_id,credit_limit) VALUES (42,5000)") - assert_not_nil id - end -end diff --git a/vendor/rails/activerecord/test/cases/datatype_test_postgresql.rb b/vendor/rails/activerecord/test/cases/datatype_test_postgresql.rb deleted file mode 100644 index 88fb6f7..0000000 --- a/vendor/rails/activerecord/test/cases/datatype_test_postgresql.rb +++ /dev/null @@ -1,204 +0,0 @@ -require "cases/helper" - -class PostgresqlArray < ActiveRecord::Base -end - -class PostgresqlMoney < ActiveRecord::Base -end - -class PostgresqlNumber < ActiveRecord::Base -end - -class PostgresqlTime < ActiveRecord::Base -end - -class PostgresqlNetworkAddress < ActiveRecord::Base -end - -class PostgresqlBitString < ActiveRecord::Base -end - -class PostgresqlOid < ActiveRecord::Base -end - -class PostgresqlDataTypeTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @connection = ActiveRecord::Base.connection - @connection.execute("set lc_monetary = 'C'") - - @connection.execute("INSERT INTO postgresql_arrays (commission_by_quarter, nicknames) VALUES ( '{35000,21000,18000,17000}', '{foo,bar,baz}' )") - @first_array = PostgresqlArray.find(1) - - @connection.execute("INSERT INTO postgresql_moneys (wealth) VALUES ('567.89'::money)") - @connection.execute("INSERT INTO postgresql_moneys (wealth) VALUES ('-567.89'::money)") - @first_money = PostgresqlMoney.find(1) - @second_money = PostgresqlMoney.find(2) - - @connection.execute("INSERT INTO postgresql_numbers (single, double) VALUES (123.456, 123456.789)") - @first_number = PostgresqlNumber.find(1) - - @connection.execute("INSERT INTO postgresql_times (time_interval) VALUES ('1 year 2 days ago')") - @first_time = PostgresqlTime.find(1) - - @connection.execute("INSERT INTO postgresql_network_addresses (cidr_address, inet_address, mac_address) VALUES('192.168.0/24', '172.16.1.254/32', '01:23:45:67:89:0a')") - @first_network_address = PostgresqlNetworkAddress.find(1) - - @connection.execute("INSERT INTO postgresql_bit_strings (bit_string, bit_string_varying) VALUES (B'00010101', X'15')") - @first_bit_string = PostgresqlBitString.find(1) - - @connection.execute("INSERT INTO postgresql_oids (obj_id) VALUES (1234)") - @first_oid = PostgresqlOid.find(1) - end - - def test_data_type_of_array_types - assert_equal :string, @first_array.column_for_attribute(:commission_by_quarter).type - assert_equal :string, @first_array.column_for_attribute(:nicknames).type - end - - def test_data_type_of_money_types - assert_equal :decimal, @first_money.column_for_attribute(:wealth).type - end - - def test_data_type_of_number_types - assert_equal :float, @first_number.column_for_attribute(:single).type - assert_equal :float, @first_number.column_for_attribute(:double).type - end - - def test_data_type_of_time_types - assert_equal :string, @first_time.column_for_attribute(:time_interval).type - end - - def test_data_type_of_network_address_types - assert_equal :string, @first_network_address.column_for_attribute(:cidr_address).type - assert_equal :string, @first_network_address.column_for_attribute(:inet_address).type - assert_equal :string, @first_network_address.column_for_attribute(:mac_address).type - end - - def test_data_type_of_bit_string_types - assert_equal :string, @first_bit_string.column_for_attribute(:bit_string).type - assert_equal :string, @first_bit_string.column_for_attribute(:bit_string_varying).type - end - - def test_data_type_of_oid_types - assert_equal :integer, @first_oid.column_for_attribute(:obj_id).type - end - - def test_array_values - assert_equal '{35000,21000,18000,17000}', @first_array.commission_by_quarter - assert_equal '{foo,bar,baz}', @first_array.nicknames - end - - def test_money_values - assert_equal 567.89, @first_money.wealth - assert_equal -567.89, @second_money.wealth - end - - def test_number_values - assert_equal 123.456, @first_number.single - assert_equal 123456.789, @first_number.double - end - - def test_time_values - assert_equal '-1 years -2 days', @first_time.time_interval - end - - def test_network_address_values - assert_equal '192.168.0.0/24', @first_network_address.cidr_address - assert_equal '172.16.1.254', @first_network_address.inet_address - assert_equal '01:23:45:67:89:0a', @first_network_address.mac_address - end - - def test_bit_string_values - assert_equal '00010101', @first_bit_string.bit_string - assert_equal '00010101', @first_bit_string.bit_string_varying - end - - def test_oid_values - assert_equal 1234, @first_oid.obj_id - end - - def test_update_integer_array - new_value = '{32800,95000,29350,17000}' - assert @first_array.commission_by_quarter = new_value - assert @first_array.save - assert @first_array.reload - assert_equal @first_array.commission_by_quarter, new_value - assert @first_array.commission_by_quarter = new_value - assert @first_array.save - assert @first_array.reload - assert_equal @first_array.commission_by_quarter, new_value - end - - def test_update_text_array - new_value = '{robby,robert,rob,robbie}' - assert @first_array.nicknames = new_value - assert @first_array.save - assert @first_array.reload - assert_equal @first_array.nicknames, new_value - assert @first_array.nicknames = new_value - assert @first_array.save - assert @first_array.reload - assert_equal @first_array.nicknames, new_value - end - - def test_update_money - new_value = BigDecimal.new('123.45') - assert @first_money.wealth = new_value - assert @first_money.save - assert @first_money.reload - assert_equal new_value, @first_money.wealth - end - - def test_update_number - new_single = 789.012 - new_double = 789012.345 - assert @first_number.single = new_single - assert @first_number.double = new_double - assert @first_number.save - assert @first_number.reload - assert_equal @first_number.single, new_single - assert_equal @first_number.double, new_double - end - - def test_update_time - assert @first_time.time_interval = '2 years 3 minutes' - assert @first_time.save - assert @first_time.reload - assert_equal @first_time.time_interval, '2 years 00:03:00' - end - - def test_update_network_address - new_cidr_address = '10.1.2.3/32' - new_inet_address = '10.0.0.0/8' - new_mac_address = 'bc:de:f0:12:34:56' - assert @first_network_address.cidr_address = new_cidr_address - assert @first_network_address.inet_address = new_inet_address - assert @first_network_address.mac_address = new_mac_address - assert @first_network_address.save - assert @first_network_address.reload - assert_equal @first_network_address.cidr_address, new_cidr_address - assert_equal @first_network_address.inet_address, new_inet_address - assert_equal @first_network_address.mac_address, new_mac_address - end - - def test_update_bit_string - new_bit_string = '11111111' - new_bit_string_varying = 'FF' - assert @first_bit_string.bit_string = new_bit_string - assert @first_bit_string.bit_string_varying = new_bit_string_varying - assert @first_bit_string.save - assert @first_bit_string.reload - assert_equal @first_bit_string.bit_string, new_bit_string - assert_equal @first_bit_string.bit_string, @first_bit_string.bit_string_varying - end - - def test_update_oid - new_value = 567890 - assert @first_oid.obj_id = new_value - assert @first_oid.save - assert @first_oid.reload - assert_equal @first_oid.obj_id, new_value - end -end diff --git a/vendor/rails/activerecord/test/cases/date_time_test.rb b/vendor/rails/activerecord/test/cases/date_time_test.rb deleted file mode 100644 index 36e1caa..0000000 --- a/vendor/rails/activerecord/test/cases/date_time_test.rb +++ /dev/null @@ -1,37 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/task' - -class DateTimeTest < ActiveRecord::TestCase - def test_saves_both_date_and_time - time_values = [1807, 2, 10, 15, 30, 45] - now = DateTime.civil(*time_values) - - task = Task.new - task.starting = now - task.save! - - # check against Time.local_time, since some platforms will return a Time instead of a DateTime - assert_equal Time.local_time(*time_values), Task.find(task.id).starting - end - - def test_assign_empty_date_time - task = Task.new - task.starting = '' - task.ending = nil - assert_nil task.starting - assert_nil task.ending - end - - def test_assign_empty_date - topic = Topic.new - topic.last_read = '' - assert_nil topic.last_read - end - - def test_assign_empty_time - topic = Topic.new - topic.bonus_time = '' - assert_nil topic.bonus_time - end -end diff --git a/vendor/rails/activerecord/test/cases/default_test_firebird.rb b/vendor/rails/activerecord/test/cases/default_test_firebird.rb deleted file mode 100644 index 713c7e1..0000000 --- a/vendor/rails/activerecord/test/cases/default_test_firebird.rb +++ /dev/null @@ -1,16 +0,0 @@ -require "cases/helper" -require 'models/default' - -class DefaultTest < ActiveRecord::TestCase - def test_default_timestamp - default = Default.new - assert_instance_of(Time, default.default_timestamp) - assert_equal(:datetime, default.column_for_attribute(:default_timestamp).type) - - # Variance should be small; increase if required -- e.g., if test db is on - # remote host and clocks aren't synchronized. - t1 = Time.new - accepted_variance = 1.0 - assert_in_delta(t1.to_f, default.default_timestamp.to_f, accepted_variance) - end -end diff --git a/vendor/rails/activerecord/test/cases/defaults_test.rb b/vendor/rails/activerecord/test/cases/defaults_test.rb deleted file mode 100644 index b4032c2..0000000 --- a/vendor/rails/activerecord/test/cases/defaults_test.rb +++ /dev/null @@ -1,111 +0,0 @@ -require "cases/helper" -require 'models/default' -require 'models/entrant' - -class DefaultTest < ActiveRecord::TestCase - def test_nil_defaults_for_not_null_columns - column_defaults = - if current_adapter?(:MysqlAdapter) && (Mysql.client_version < 50051 || (50100..50122).include?(Mysql.client_version)) - { 'id' => nil, 'name' => '', 'course_id' => nil } - else - { 'id' => nil, 'name' => nil, 'course_id' => nil } - end - - column_defaults.each do |name, default| - column = Entrant.columns_hash[name] - assert !column.null, "#{name} column should be NOT NULL" - assert_equal default, column.default, "#{name} column should be DEFAULT #{default.inspect}" - end - end - - if current_adapter?(:PostgreSQLAdapter, :FirebirdAdapter, :OpenBaseAdapter, :OracleAdapter) - def test_default_integers - default = Default.new - assert_instance_of Fixnum, default.positive_integer - assert_equal 1, default.positive_integer - assert_instance_of Fixnum, default.negative_integer - assert_equal -1, default.negative_integer - assert_instance_of BigDecimal, default.decimal_number - assert_equal BigDecimal.new("2.78"), default.decimal_number - end - end - - if current_adapter?(:PostgreSQLAdapter) - def test_multiline_default_text - # older postgres versions represent the default with escapes ("\\012" for a newline) - assert ( "--- []\n\n" == Default.columns_hash['multiline_default'].default || - "--- []\\012\\012" == Default.columns_hash['multiline_default'].default) - end - end -end - -if current_adapter?(:MysqlAdapter) - class DefaultsTestWithoutTransactionalFixtures < ActiveRecord::TestCase - # ActiveRecord::Base#create! (and #save and other related methods) will - # open a new transaction. When in transactional fixtures mode, this will - # cause ActiveRecord to create a new savepoint. However, since MySQL doesn't - # support DDL transactions, creating a table will result in any created - # savepoints to be automatically released. This in turn causes the savepoint - # release code in AbstractAdapter#transaction to fail. - # - # We don't want that to happen, so we disable transactional fixtures here. - self.use_transactional_fixtures = false - - # MySQL 5 and higher is quirky with not null text/blob columns. - # With MySQL Text/blob columns cannot have defaults. If the column is not - # null MySQL will report that the column has a null default - # but it behaves as though the column had a default of '' - def test_mysql_text_not_null_defaults - klass = Class.new(ActiveRecord::Base) - klass.table_name = 'test_mysql_text_not_null_defaults' - klass.connection.create_table klass.table_name do |t| - t.column :non_null_text, :text, :null => false - t.column :non_null_blob, :blob, :null => false - t.column :null_text, :text, :null => true - t.column :null_blob, :blob, :null => true - end - assert_equal '', klass.columns_hash['non_null_blob'].default - assert_equal '', klass.columns_hash['non_null_text'].default - - assert_equal nil, klass.columns_hash['null_blob'].default - assert_equal nil, klass.columns_hash['null_text'].default - - assert_nothing_raised do - instance = klass.create! - assert_equal '', instance.non_null_text - assert_equal '', instance.non_null_blob - assert_nil instance.null_text - assert_nil instance.null_blob - end - ensure - klass.connection.drop_table(klass.table_name) rescue nil - end - - # MySQL uses an implicit default 0 rather than NULL unless in strict mode. - # We use an implicit NULL so schema.rb is compatible with other databases. - def test_mysql_integer_not_null_defaults - klass = Class.new(ActiveRecord::Base) - klass.table_name = 'test_integer_not_null_default_zero' - klass.connection.create_table klass.table_name do |t| - t.column :zero, :integer, :null => false, :default => 0 - t.column :omit, :integer, :null => false - end - - assert_equal 0, klass.columns_hash['zero'].default - assert !klass.columns_hash['zero'].null - # 0 in MySQL 4, nil in 5. - assert [0, nil].include?(klass.columns_hash['omit'].default) - assert !klass.columns_hash['omit'].null - - assert_raise(ActiveRecord::StatementInvalid) { klass.create! } - - assert_nothing_raised do - instance = klass.create!(:omit => 1) - assert_equal 0, instance.zero - assert_equal 1, instance.omit - end - ensure - klass.connection.drop_table(klass.table_name) rescue nil - end - end -end diff --git a/vendor/rails/activerecord/test/cases/deprecated_finder_test.rb b/vendor/rails/activerecord/test/cases/deprecated_finder_test.rb deleted file mode 100644 index 2afc91b..0000000 --- a/vendor/rails/activerecord/test/cases/deprecated_finder_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -require "cases/helper" -require 'models/entrant' - -class DeprecatedFinderTest < ActiveRecord::TestCase - fixtures :entrants - - def test_deprecated_find_all_was_removed - assert_raise(NoMethodError) { Entrant.find_all } - end - - def test_deprecated_find_first_was_removed - assert_raise(NoMethodError) { Entrant.find_first } - end - - def test_deprecated_find_on_conditions_was_removed - assert_raise(NoMethodError) { Entrant.find_on_conditions } - end - - def test_count - assert_equal(0, Entrant.count(:conditions => "id > 3")) - assert_equal(1, Entrant.count(:conditions => ["id > ?", 2])) - assert_equal(2, Entrant.count(:conditions => ["id > ?", 1])) - end - - def test_count_by_sql - assert_equal(0, Entrant.count_by_sql("SELECT COUNT(*) FROM entrants WHERE id > 3")) - assert_equal(1, Entrant.count_by_sql(["SELECT COUNT(*) FROM entrants WHERE id > ?", 2])) - assert_equal(2, Entrant.count_by_sql(["SELECT COUNT(*) FROM entrants WHERE id > ?", 1])) - end -end diff --git a/vendor/rails/activerecord/test/cases/dirty_test.rb b/vendor/rails/activerecord/test/cases/dirty_test.rb deleted file mode 100644 index ac95bac..0000000 --- a/vendor/rails/activerecord/test/cases/dirty_test.rb +++ /dev/null @@ -1,306 +0,0 @@ -require 'cases/helper' -require 'models/topic' # For booleans -require 'models/pirate' # For timestamps -require 'models/parrot' -require 'models/person' # For optimistic locking - -class Pirate # Just reopening it, not defining it - attr_accessor :detected_changes_in_after_update # Boolean for if changes are detected - attr_accessor :changes_detected_in_after_update # Actual changes - - after_update :check_changes - -private - # after_save/update in sweepers, observers, and the model itself - # can end up checking dirty status and acting on the results - def check_changes - if self.changed? - self.detected_changes_in_after_update = true - self.changes_detected_in_after_update = self.changes - end - end -end - -class NumericData < ActiveRecord::Base - self.table_name = 'numeric_data' -end - -class DirtyTest < ActiveRecord::TestCase - def test_attribute_changes - # New record - no changes. - pirate = Pirate.new - assert !pirate.catchphrase_changed? - assert_nil pirate.catchphrase_change - - # Change catchphrase. - pirate.catchphrase = 'arrr' - assert pirate.catchphrase_changed? - assert_nil pirate.catchphrase_was - assert_equal [nil, 'arrr'], pirate.catchphrase_change - - # Saved - no changes. - pirate.save! - assert !pirate.catchphrase_changed? - assert_nil pirate.catchphrase_change - - # Same value - no changes. - pirate.catchphrase = 'arrr' - assert !pirate.catchphrase_changed? - assert_nil pirate.catchphrase_change - end - - def test_aliased_attribute_changes - # the actual attribute here is name, title is an - # alias setup via alias_attribute - parrot = Parrot.new - assert !parrot.title_changed? - assert_nil parrot.title_change - - parrot.name = 'Sam' - assert parrot.title_changed? - assert_nil parrot.title_was - assert_equal parrot.name_change, parrot.title_change - end - - def test_nullable_number_not_marked_as_changed_if_new_value_is_blank - pirate = Pirate.new - - ["", nil].each do |value| - pirate.parrot_id = value - assert !pirate.parrot_id_changed? - assert_nil pirate.parrot_id_change - end - end - - def test_nullable_decimal_not_marked_as_changed_if_new_value_is_blank - numeric_data = NumericData.new - - ["", nil].each do |value| - numeric_data.bank_balance = value - assert !numeric_data.bank_balance_changed? - assert_nil numeric_data.bank_balance_change - end - end - - def test_nullable_float_not_marked_as_changed_if_new_value_is_blank - numeric_data = NumericData.new - - ["", nil].each do |value| - numeric_data.temperature = value - assert !numeric_data.temperature_changed? - assert_nil numeric_data.temperature_change - end - end - - def test_nullable_integer_zero_to_string_zero_not_marked_as_changed - pirate = Pirate.new - pirate.parrot_id = 0 - pirate.catchphrase = 'arrr' - assert pirate.save! - - assert !pirate.changed? - - pirate.parrot_id = '0' - assert !pirate.changed? - end - - def test_zero_to_blank_marked_as_changed - pirate = Pirate.new - pirate.catchphrase = "Yarrrr, me hearties" - pirate.parrot_id = 1 - pirate.save - - # check the change from 1 to '' - pirate = Pirate.find_by_catchphrase("Yarrrr, me hearties") - pirate.parrot_id = '' - assert pirate.parrot_id_changed? - assert_equal([1, nil], pirate.parrot_id_change) - pirate.save - - # check the change from nil to 0 - pirate = Pirate.find_by_catchphrase("Yarrrr, me hearties") - pirate.parrot_id = 0 - assert pirate.parrot_id_changed? - assert_equal([nil, 0], pirate.parrot_id_change) - pirate.save - - # check the change from 0 to '' - pirate = Pirate.find_by_catchphrase("Yarrrr, me hearties") - pirate.parrot_id = '' - assert pirate.parrot_id_changed? - assert_equal([0, nil], pirate.parrot_id_change) - end - - def test_object_should_be_changed_if_any_attribute_is_changed - pirate = Pirate.new - assert !pirate.changed? - assert_equal [], pirate.changed - assert_equal Hash.new, pirate.changes - - pirate.catchphrase = 'arrr' - assert pirate.changed? - assert_nil pirate.catchphrase_was - assert_equal %w(catchphrase), pirate.changed - assert_equal({'catchphrase' => [nil, 'arrr']}, pirate.changes) - - pirate.save - assert !pirate.changed? - assert_equal [], pirate.changed - assert_equal Hash.new, pirate.changes - end - - def test_attribute_will_change! - pirate = Pirate.create!(:catchphrase => 'arr') - - pirate.catchphrase << ' matey' - assert !pirate.catchphrase_changed? - - assert pirate.catchphrase_will_change! - assert pirate.catchphrase_changed? - assert_equal ['arr matey', 'arr matey'], pirate.catchphrase_change - - pirate.catchphrase << '!' - assert pirate.catchphrase_changed? - assert_equal ['arr matey', 'arr matey!'], pirate.catchphrase_change - end - - def test_association_assignment_changes_foreign_key - pirate = Pirate.create!(:catchphrase => 'jarl') - pirate.parrot = Parrot.create!(:name => 'Lorre') - assert pirate.changed? - assert_equal %w(parrot_id), pirate.changed - end - - def test_attribute_should_be_compared_with_type_cast - topic = Topic.new - assert topic.approved? - assert !topic.approved_changed? - - # Coming from web form. - params = {:topic => {:approved => 1}} - # In the controller. - topic.attributes = params[:topic] - assert topic.approved? - assert !topic.approved_changed? - end - - def test_partial_update - pirate = Pirate.new(:catchphrase => 'foo') - old_updated_on = 1.hour.ago.beginning_of_day - - with_partial_updates Pirate, false do - assert_queries(2) { 2.times { pirate.save! } } - Pirate.update_all({ :updated_on => old_updated_on }, :id => pirate.id) - end - - with_partial_updates Pirate, true do - assert_queries(0) { 2.times { pirate.save! } } - assert_equal old_updated_on, pirate.reload.updated_on - - assert_queries(1) { pirate.catchphrase = 'bar'; pirate.save! } - assert_not_equal old_updated_on, pirate.reload.updated_on - end - end - - def test_partial_update_with_optimistic_locking - person = Person.new(:first_name => 'foo') - old_lock_version = 1 - - with_partial_updates Person, false do - assert_queries(2) { 2.times { person.save! } } - Person.update_all({ :first_name => 'baz' }, :id => person.id) - end - - with_partial_updates Person, true do - assert_queries(0) { 2.times { person.save! } } - assert_equal old_lock_version, person.reload.lock_version - - assert_queries(1) { person.first_name = 'bar'; person.save! } - assert_not_equal old_lock_version, person.reload.lock_version - end - end - - def test_changed_attributes_should_be_preserved_if_save_failure - pirate = Pirate.new - pirate.parrot_id = 1 - assert !pirate.save - check_pirate_after_save_failure(pirate) - - pirate = Pirate.new - pirate.parrot_id = 1 - assert_raise(ActiveRecord::RecordInvalid) { pirate.save! } - check_pirate_after_save_failure(pirate) - end - - def test_reload_should_clear_changed_attributes - pirate = Pirate.create!(:catchphrase => "shiver me timbers") - pirate.catchphrase = "*hic*" - assert pirate.changed? - pirate.reload - assert !pirate.changed? - end - - def test_reverted_changes_are_not_dirty - phrase = "shiver me timbers" - pirate = Pirate.create!(:catchphrase => phrase) - pirate.catchphrase = "*hic*" - assert pirate.changed? - pirate.catchphrase = phrase - assert !pirate.changed? - end - - def test_reverted_changes_are_not_dirty_after_multiple_changes - phrase = "shiver me timbers" - pirate = Pirate.create!(:catchphrase => phrase) - 10.times do |i| - pirate.catchphrase = "*hic*" * i - assert pirate.changed? - end - assert pirate.changed? - pirate.catchphrase = phrase - assert !pirate.changed? - end - - - def test_reverted_changes_are_not_dirty_going_from_nil_to_value_and_back - pirate = Pirate.create!(:catchphrase => "Yar!") - - pirate.parrot_id = 1 - assert pirate.changed? - assert pirate.parrot_id_changed? - assert !pirate.catchphrase_changed? - - pirate.parrot_id = nil - assert !pirate.changed? - assert !pirate.parrot_id_changed? - assert !pirate.catchphrase_changed? - end - - def test_save_should_store_serialized_attributes_even_with_partial_updates - with_partial_updates(Topic) do - topic = Topic.create!(:content => {:a => "a"}) - topic.content[:b] = "b" - #assert topic.changed? # Known bug, will fail - topic.save! - assert_equal "b", topic.content[:b] - topic.reload - assert_equal "b", topic.content[:b] - end - end - - private - def with_partial_updates(klass, on = true) - old = klass.partial_updates? - klass.partial_updates = on - yield - ensure - klass.partial_updates = old - end - - def check_pirate_after_save_failure(pirate) - assert pirate.changed? - assert pirate.parrot_id_changed? - assert_equal %w(parrot_id), pirate.changed - assert_nil pirate.parrot_id_was - end -end diff --git a/vendor/rails/activerecord/test/cases/finder_respond_to_test.rb b/vendor/rails/activerecord/test/cases/finder_respond_to_test.rb deleted file mode 100644 index 4e6fecf..0000000 --- a/vendor/rails/activerecord/test/cases/finder_respond_to_test.rb +++ /dev/null @@ -1,76 +0,0 @@ -require "cases/helper" -require 'models/topic' - -class FinderRespondToTest < ActiveRecord::TestCase - - fixtures :topics - - def test_should_preserve_normal_respond_to_behaviour_and_respond_to_newly_added_method - class << Topic; self; end.send(:define_method, :method_added_for_finder_respond_to_test) { } - assert Topic.respond_to?(:method_added_for_finder_respond_to_test) - ensure - class << Topic; self; end.send(:remove_method, :method_added_for_finder_respond_to_test) - end - - def test_should_preserve_normal_respond_to_behaviour_and_respond_to_standard_object_method - assert Topic.respond_to?(:to_s) - end - - def test_should_respond_to_find_by_one_attribute_before_caching - ensure_topic_method_is_not_cached(:find_by_title) - assert Topic.respond_to?(:find_by_title) - end - - def test_should_respond_to_find_all_by_one_attribute - ensure_topic_method_is_not_cached(:find_all_by_title) - assert Topic.respond_to?(:find_all_by_title) - end - - def test_should_respond_to_find_all_by_two_attributes - ensure_topic_method_is_not_cached(:find_all_by_title_and_author_name) - assert Topic.respond_to?(:find_all_by_title_and_author_name) - end - - def test_should_respond_to_find_by_two_attributes - ensure_topic_method_is_not_cached(:find_by_title_and_author_name) - assert Topic.respond_to?(:find_by_title_and_author_name) - end - - def test_should_respond_to_find_or_initialize_from_one_attribute - ensure_topic_method_is_not_cached(:find_or_initialize_by_title) - assert Topic.respond_to?(:find_or_initialize_by_title) - end - - def test_should_respond_to_find_or_initialize_from_two_attributes - ensure_topic_method_is_not_cached(:find_or_initialize_by_title_and_author_name) - assert Topic.respond_to?(:find_or_initialize_by_title_and_author_name) - end - - def test_should_respond_to_find_or_create_from_one_attribute - ensure_topic_method_is_not_cached(:find_or_create_by_title) - assert Topic.respond_to?(:find_or_create_by_title) - end - - def test_should_respond_to_find_or_create_from_two_attributes - ensure_topic_method_is_not_cached(:find_or_create_by_title_and_author_name) - assert Topic.respond_to?(:find_or_create_by_title_and_author_name) - end - - def test_should_not_respond_to_find_by_one_missing_attribute - assert !Topic.respond_to?(:find_by_undertitle) - end - - def test_should_not_respond_to_find_by_invalid_method_syntax - assert !Topic.respond_to?(:fail_to_find_by_title) - assert !Topic.respond_to?(:find_by_title?) - assert !Topic.respond_to?(:fail_to_find_or_create_by_title) - assert !Topic.respond_to?(:find_or_create_by_title?) - end - - private - - def ensure_topic_method_is_not_cached(method_id) - class << Topic; self; end.send(:remove_method, method_id) if Topic.public_methods.any? { |m| m.to_s == method_id.to_s } - end - -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/cases/finder_test.rb b/vendor/rails/activerecord/test/cases/finder_test.rb deleted file mode 100644 index d877895..0000000 --- a/vendor/rails/activerecord/test/cases/finder_test.rb +++ /dev/null @@ -1,1083 +0,0 @@ -require "cases/helper" -require 'models/author' -require 'models/categorization' -require 'models/comment' -require 'models/company' -require 'models/topic' -require 'models/reply' -require 'models/entrant' -require 'models/developer' -require 'models/post' -require 'models/customer' -require 'models/job' -require 'models/categorization' - -class DynamicFinderMatchTest < ActiveRecord::TestCase - def test_find_no_match - assert_nil ActiveRecord::DynamicFinderMatch.match("not_a_finder") - end - - def test_find_by - match = ActiveRecord::DynamicFinderMatch.match("find_by_age_and_sex_and_location") - assert_not_nil match - assert match.finder? - assert_equal :first, match.finder - assert_equal %w(age sex location), match.attribute_names - end - - def find_by_bang - match = ActiveRecord::DynamicFinderMatch.match("find_by_age_and_sex_and_location!") - assert_not_nil match - assert match.finder? - assert match.bang? - assert_equal :first, match.finder - assert_equal %w(age sex location), match.attribute_names - end - - def test_find_all_by - match = ActiveRecord::DynamicFinderMatch.match("find_all_by_age_and_sex_and_location") - assert_not_nil match - assert match.finder? - assert_equal :all, match.finder - assert_equal %w(age sex location), match.attribute_names - end - - def test_find_or_initialize_by - match = ActiveRecord::DynamicFinderMatch.match("find_or_initialize_by_age_and_sex_and_location") - assert_not_nil match - assert !match.finder? - assert match.instantiator? - assert_equal :first, match.finder - assert_equal :new, match.instantiator - assert_equal %w(age sex location), match.attribute_names - end - - def test_find_or_create_by - match = ActiveRecord::DynamicFinderMatch.match("find_or_create_by_age_and_sex_and_location") - assert_not_nil match - assert !match.finder? - assert match.instantiator? - assert_equal :first, match.finder - assert_equal :create, match.instantiator - assert_equal %w(age sex location), match.attribute_names - end -end - -class FinderTest < ActiveRecord::TestCase - fixtures :companies, :topics, :entrants, :developers, :developers_projects, :posts, :comments, :accounts, :authors, :customers - - def test_find - assert_equal(topics(:first).title, Topic.find(1).title) - end - - # find should handle strings that come from URLs - # (example: Category.find(params[:id])) - def test_find_with_string - assert_equal(Topic.find(1).title,Topic.find("1").title) - end - - def test_exists - assert Topic.exists?(1) - assert Topic.exists?("1") - assert Topic.exists?(:author_name => "David") - assert Topic.exists?(:author_name => "Mary", :approved => true) - assert Topic.exists?(["parent_id = ?", 1]) - assert !Topic.exists?(45) - - begin - assert !Topic.exists?("foo") - rescue ActiveRecord::StatementInvalid - # PostgreSQL complains about string comparison with integer field - rescue Exception - flunk - end - - assert_raise(NoMethodError) { Topic.exists?([1,2]) } - end - - def test_exists_returns_true_with_one_record_and_no_args - assert Topic.exists? - end - - def test_does_not_exist_with_empty_table_and_no_args_given - Topic.delete_all - assert !Topic.exists? - end - - def test_exists_with_aggregate_having_three_mappings - existing_address = customers(:david).address - assert Customer.exists?(:address => existing_address) - end - - def test_exists_with_aggregate_having_three_mappings_with_one_difference - existing_address = customers(:david).address - assert !Customer.exists?(:address => - Address.new(existing_address.street, existing_address.city, existing_address.country + "1")) - assert !Customer.exists?(:address => - Address.new(existing_address.street, existing_address.city + "1", existing_address.country)) - assert !Customer.exists?(:address => - Address.new(existing_address.street + "1", existing_address.city, existing_address.country)) - end - - def test_find_by_array_of_one_id - assert_kind_of(Array, Topic.find([ 1 ])) - assert_equal(1, Topic.find([ 1 ]).length) - end - - def test_find_by_ids - assert_equal 2, Topic.find(1, 2).size - assert_equal topics(:second).title, Topic.find([2]).first.title - end - - def test_find_by_ids_with_limit_and_offset - assert_equal 2, Entrant.find([1,3,2], :limit => 2).size - assert_equal 1, Entrant.find([1,3,2], :limit => 3, :offset => 2).size - - # Also test an edge case: If you have 11 results, and you set a - # limit of 3 and offset of 9, then you should find that there - # will be only 2 results, regardless of the limit. - devs = Developer.find :all - last_devs = Developer.find devs.map(&:id), :limit => 3, :offset => 9 - assert_equal 2, last_devs.size - end - - def test_find_an_empty_array - assert_equal [], Topic.find([]) - end - - def test_find_by_ids_missing_one - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, 2, 45) } - end - - def test_find_all_with_limit - entrants = Entrant.find(:all, :order => "id ASC", :limit => 2) - - assert_equal(2, entrants.size) - assert_equal(entrants(:first).name, entrants.first.name) - end - - def test_find_all_with_prepared_limit_and_offset - entrants = Entrant.find(:all, :order => "id ASC", :limit => 2, :offset => 1) - - assert_equal(2, entrants.size) - assert_equal(entrants(:second).name, entrants.first.name) - - entrants = Entrant.find(:all, :order => "id ASC", :limit => 2, :offset => 2) - assert_equal(1, entrants.size) - assert_equal(entrants(:third).name, entrants.first.name) - end - - def test_find_all_with_limit_and_offset_and_multiple_orderings - developers = Developer.find(:all, :order => "salary ASC, id DESC", :limit => 3, :offset => 1) - assert_equal ["David", "fixture_10", "fixture_9"], developers.collect {|d| d.name} - end - - def test_find_with_limit_and_condition - developers = Developer.find(:all, :order => "id DESC", :conditions => "salary = 100000", :limit => 3, :offset =>7) - assert_equal(1, developers.size) - assert_equal("fixture_3", developers.first.name) - end - - def test_find_with_group - developers = Developer.find(:all, :group => "salary", :select => "salary") - assert_equal 4, developers.size - assert_equal 4, developers.map(&:salary).uniq.size - end - - def test_find_with_group_and_having - developers = Developer.find(:all, :group => "salary", :having => "sum(salary) > 10000", :select => "salary") - assert_equal 3, developers.size - assert_equal 3, developers.map(&:salary).uniq.size - assert developers.all? { |developer| developer.salary > 10000 } - end - - def test_find_with_group_and_sanitized_having - developers = Developer.find(:all, :group => "salary", :having => ["sum(salary) > ?", 10000], :select => "salary") - assert_equal 3, developers.size - assert_equal 3, developers.map(&:salary).uniq.size - assert developers.all? { |developer| developer.salary > 10000 } - end - - def test_find_with_entire_select_statement - topics = Topic.find_by_sql "SELECT * FROM topics WHERE author_name = 'Mary'" - - assert_equal(1, topics.size) - assert_equal(topics(:second).title, topics.first.title) - end - - def test_find_with_prepared_select_statement - topics = Topic.find_by_sql ["SELECT * FROM topics WHERE author_name = ?", "Mary"] - - assert_equal(1, topics.size) - assert_equal(topics(:second).title, topics.first.title) - end - - def test_find_by_sql_with_sti_on_joined_table - accounts = Account.find_by_sql("SELECT * FROM accounts INNER JOIN companies ON companies.id = accounts.firm_id") - assert_equal [Account], accounts.collect(&:class).uniq - end - - def test_find_first - first = Topic.find(:first, :conditions => "title = 'The First Topic'") - assert_equal(topics(:first).title, first.title) - end - - def test_find_first_failing - first = Topic.find(:first, :conditions => "title = 'The First Topic!'") - assert_nil(first) - end - - def test_first - assert_equal topics(:second).title, Topic.first(:conditions => "title = 'The Second Topic of the day'").title - end - - def test_first_failing - assert_nil Topic.first(:conditions => "title = 'The Second Topic of the day!'") - end - - def test_unexisting_record_exception_handling - assert_raise(ActiveRecord::RecordNotFound) { - Topic.find(1).parent - } - - Topic.find(2).topic - end - - def test_find_only_some_columns - topic = Topic.find(1, :select => "author_name") - assert_raise(ActiveRecord::MissingAttributeError) {topic.title} - assert_equal "David", topic.author_name - assert !topic.attribute_present?("title") - #assert !topic.respond_to?("title") - assert topic.attribute_present?("author_name") - assert topic.respond_to?("author_name") - end - - def test_find_on_blank_conditions - [nil, " ", [], {}].each do |blank| - assert_nothing_raised { Topic.find(:first, :conditions => blank) } - end - end - - def test_find_on_blank_bind_conditions - [ [""], ["",{}] ].each do |blank| - assert_nothing_raised { Topic.find(:first, :conditions => blank) } - end - end - - def test_find_on_array_conditions - assert Topic.find(1, :conditions => ["approved = ?", false]) - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => ["approved = ?", true]) } - end - - def test_find_on_hash_conditions - assert Topic.find(1, :conditions => { :approved => false }) - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :approved => true }) } - end - - def test_find_on_hash_conditions_with_explicit_table_name - assert Topic.find(1, :conditions => { 'topics.approved' => false }) - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { 'topics.approved' => true }) } - end - - def test_find_on_hash_conditions_with_hashed_table_name - assert Topic.find(1, :conditions => {:topics => { :approved => false }}) - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => {:topics => { :approved => true }}) } - end - - def test_find_with_hash_conditions_on_joined_table - firms = Firm.all :joins => :account, :conditions => {:accounts => { :credit_limit => 50 }} - assert_equal 1, firms.size - assert_equal companies(:first_firm), firms.first - end - - def test_find_with_hash_conditions_on_joined_table_and_with_range - firms = DependentFirm.all :joins => :account, :conditions => {:name => 'RailsCore', :accounts => { :credit_limit => 55..60 }} - assert_equal 1, firms.size - assert_equal companies(:rails_core), firms.first - end - - def test_find_on_hash_conditions_with_explicit_table_name_and_aggregate - david = customers(:david) - assert Customer.find(david.id, :conditions => { 'customers.name' => david.name, :address => david.address }) - assert_raise(ActiveRecord::RecordNotFound) { - Customer.find(david.id, :conditions => { 'customers.name' => david.name + "1", :address => david.address }) - } - end - - def test_find_on_association_proxy_conditions - assert_equal [1, 2, 3, 5, 6, 7, 8, 9, 10], Comment.find_all_by_post_id(authors(:david).posts).map(&:id).sort - end - - def test_find_on_hash_conditions_with_range - assert_equal [1,2], Topic.find(:all, :conditions => { :id => 1..2 }).map(&:id).sort - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :id => 2..3 }) } - end - - def test_find_on_hash_conditions_with_end_exclusive_range - assert_equal [1,2,3], Topic.find(:all, :conditions => { :id => 1..3 }).map(&:id).sort - assert_equal [1,2], Topic.find(:all, :conditions => { :id => 1...3 }).map(&:id).sort - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(3, :conditions => { :id => 2...3 }) } - end - - def test_find_on_hash_conditions_with_multiple_ranges - assert_equal [1,2,3], Comment.find(:all, :conditions => { :id => 1..3, :post_id => 1..2 }).map(&:id).sort - assert_equal [1], Comment.find(:all, :conditions => { :id => 1..1, :post_id => 1..10 }).map(&:id).sort - end - - def test_find_on_multiple_hash_conditions - assert Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => false }) - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => true }) } - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "HHC", :replies_count => 1, :approved => false }) } - assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => true }) } - end - - def test_condition_interpolation - assert_kind_of Firm, Company.find(:first, :conditions => ["name = '%s'", "37signals"]) - assert_nil Company.find(:first, :conditions => ["name = '%s'", "37signals!"]) - assert_nil Company.find(:first, :conditions => ["name = '%s'", "37signals!' OR 1=1"]) - assert_kind_of Time, Topic.find(:first, :conditions => ["id = %d", 1]).written_on - end - - def test_condition_array_interpolation - assert_kind_of Firm, Company.find(:first, :conditions => ["name = '%s'", "37signals"]) - assert_nil Company.find(:first, :conditions => ["name = '%s'", "37signals!"]) - assert_nil Company.find(:first, :conditions => ["name = '%s'", "37signals!' OR 1=1"]) - assert_kind_of Time, Topic.find(:first, :conditions => ["id = %d", 1]).written_on - end - - def test_condition_hash_interpolation - assert_kind_of Firm, Company.find(:first, :conditions => { :name => "37signals"}) - assert_nil Company.find(:first, :conditions => { :name => "37signals!"}) - assert_kind_of Time, Topic.find(:first, :conditions => {:id => 1}).written_on - end - - def test_hash_condition_find_malformed - assert_raise(ActiveRecord::StatementInvalid) { - Company.find(:first, :conditions => { :id => 2, :dhh => true }) - } - end - - def test_hash_condition_find_with_escaped_characters - Company.create("name" => "Ain't noth'n like' \#stuff") - assert Company.find(:first, :conditions => { :name => "Ain't noth'n like' \#stuff" }) - end - - def test_hash_condition_find_with_array - p1, p2 = Post.find(:all, :limit => 2, :order => 'id asc') - assert_equal [p1, p2], Post.find(:all, :conditions => { :id => [p1, p2] }, :order => 'id asc') - assert_equal [p1, p2], Post.find(:all, :conditions => { :id => [p1, p2.id] }, :order => 'id asc') - end - - def test_hash_condition_find_with_nil - topic = Topic.find(:first, :conditions => { :last_read => nil } ) - assert_not_nil topic - assert_nil topic.last_read - end - - def test_hash_condition_find_with_aggregate_having_one_mapping - balance = customers(:david).balance - assert_kind_of Money, balance - found_customer = Customer.find(:first, :conditions => {:balance => balance}) - assert_equal customers(:david), found_customer - end - - def test_hash_condition_find_with_aggregate_attribute_having_same_name_as_field_and_key_value_being_aggregate - gps_location = customers(:david).gps_location - assert_kind_of GpsLocation, gps_location - found_customer = Customer.find(:first, :conditions => {:gps_location => gps_location}) - assert_equal customers(:david), found_customer - end - - def test_hash_condition_find_with_aggregate_having_one_mapping_and_key_value_being_attribute_value - balance = customers(:david).balance - assert_kind_of Money, balance - found_customer = Customer.find(:first, :conditions => {:balance => balance.amount}) - assert_equal customers(:david), found_customer - end - - def test_hash_condition_find_with_aggregate_attribute_having_same_name_as_field_and_key_value_being_attribute_value - gps_location = customers(:david).gps_location - assert_kind_of GpsLocation, gps_location - found_customer = Customer.find(:first, :conditions => {:gps_location => gps_location.gps_location}) - assert_equal customers(:david), found_customer - end - - def test_hash_condition_find_with_aggregate_having_three_mappings - address = customers(:david).address - assert_kind_of Address, address - found_customer = Customer.find(:first, :conditions => {:address => address}) - assert_equal customers(:david), found_customer - end - - def test_hash_condition_find_with_one_condition_being_aggregate_and_another_not - address = customers(:david).address - assert_kind_of Address, address - found_customer = Customer.find(:first, :conditions => {:address => address, :name => customers(:david).name}) - assert_equal customers(:david), found_customer - end - - def test_bind_variables - assert_kind_of Firm, Company.find(:first, :conditions => ["name = ?", "37signals"]) - assert_nil Company.find(:first, :conditions => ["name = ?", "37signals!"]) - assert_nil Company.find(:first, :conditions => ["name = ?", "37signals!' OR 1=1"]) - assert_kind_of Time, Topic.find(:first, :conditions => ["id = ?", 1]).written_on - assert_raise(ActiveRecord::PreparedStatementInvalid) { - Company.find(:first, :conditions => ["id=? AND name = ?", 2]) - } - assert_raise(ActiveRecord::PreparedStatementInvalid) { - Company.find(:first, :conditions => ["id=?", 2, 3, 4]) - } - end - - def test_bind_variables_with_quotes - Company.create("name" => "37signals' go'es agains") - assert Company.find(:first, :conditions => ["name = ?", "37signals' go'es agains"]) - end - - def test_named_bind_variables_with_quotes - Company.create("name" => "37signals' go'es agains") - assert Company.find(:first, :conditions => ["name = :name", {:name => "37signals' go'es agains"}]) - end - - def test_bind_arity - assert_nothing_raised { bind '' } - assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '', 1 } - - assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '?' } - assert_nothing_raised { bind '?', 1 } - assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '?', 1, 1 } - end - - def test_named_bind_variables - assert_equal '1', bind(':a', :a => 1) # ' ruby-mode - assert_equal '1 1', bind(':a :a', :a => 1) # ' ruby-mode - - assert_nothing_raised { bind("'+00:00'", :foo => "bar") } - - assert_kind_of Firm, Company.find(:first, :conditions => ["name = :name", { :name => "37signals" }]) - assert_nil Company.find(:first, :conditions => ["name = :name", { :name => "37signals!" }]) - assert_nil Company.find(:first, :conditions => ["name = :name", { :name => "37signals!' OR 1=1" }]) - assert_kind_of Time, Topic.find(:first, :conditions => ["id = :id", { :id => 1 }]).written_on - end - - def test_bind_enumerable - quoted_abc = %(#{ActiveRecord::Base.connection.quote('a')},#{ActiveRecord::Base.connection.quote('b')},#{ActiveRecord::Base.connection.quote('c')}) - - assert_equal '1,2,3', bind('?', [1, 2, 3]) - assert_equal quoted_abc, bind('?', %w(a b c)) - - assert_equal '1,2,3', bind(':a', :a => [1, 2, 3]) - assert_equal quoted_abc, bind(':a', :a => %w(a b c)) # ' - - require 'set' - assert_equal '1,2,3', bind('?', Set.new([1, 2, 3])) - assert_equal quoted_abc, bind('?', Set.new(%w(a b c))) - - assert_equal '1,2,3', bind(':a', :a => Set.new([1, 2, 3])) - assert_equal quoted_abc, bind(':a', :a => Set.new(%w(a b c))) # ' - end - - def test_bind_empty_enumerable - quoted_nil = ActiveRecord::Base.connection.quote(nil) - assert_equal quoted_nil, bind('?', []) - assert_equal " in (#{quoted_nil})", bind(' in (?)', []) - assert_equal "foo in (#{quoted_nil})", bind('foo in (?)', []) - end - - def test_bind_string - assert_equal ActiveRecord::Base.connection.quote(''), bind('?', '') - end - - def test_bind_chars - quoted_bambi = ActiveRecord::Base.connection.quote("Bambi") - quoted_bambi_and_thumper = ActiveRecord::Base.connection.quote("Bambi\nand\nThumper") - assert_equal "name=#{quoted_bambi}", bind('name=?', "Bambi") - assert_equal "name=#{quoted_bambi_and_thumper}", bind('name=?', "Bambi\nand\nThumper") - assert_equal "name=#{quoted_bambi}", bind('name=?', "Bambi".mb_chars) - assert_equal "name=#{quoted_bambi_and_thumper}", bind('name=?', "Bambi\nand\nThumper".mb_chars) - end - - def test_bind_record - o = Struct.new(:quoted_id).new(1) - assert_equal '1', bind('?', o) - - os = [o] * 3 - assert_equal '1,1,1', bind('?', os) - end - - def test_named_bind_with_postgresql_type_casts - l = Proc.new { bind(":a::integer '2009-01-01'::date", :a => '10') } - assert_nothing_raised(&l) - assert_equal "#{ActiveRecord::Base.quote_value('10')}::integer '2009-01-01'::date", l.call - end - - def test_string_sanitation - assert_not_equal "#{ActiveRecord::Base.connection.quoted_string_prefix}'something ' 1=1'", ActiveRecord::Base.sanitize("something ' 1=1") - assert_equal "#{ActiveRecord::Base.connection.quoted_string_prefix}'something; select table'", ActiveRecord::Base.sanitize("something; select table") - end - - def test_count - assert_equal(0, Entrant.count(:conditions => "id > 3")) - assert_equal(1, Entrant.count(:conditions => ["id > ?", 2])) - assert_equal(2, Entrant.count(:conditions => ["id > ?", 1])) - end - - def test_count_by_sql - assert_equal(0, Entrant.count_by_sql("SELECT COUNT(*) FROM entrants WHERE id > 3")) - assert_equal(1, Entrant.count_by_sql(["SELECT COUNT(*) FROM entrants WHERE id > ?", 2])) - assert_equal(2, Entrant.count_by_sql(["SELECT COUNT(*) FROM entrants WHERE id > ?", 1])) - end - - def test_dynamic_finders_should_go_through_the_find_class_method - Topic.expects(:find).with(:first, :conditions => { :title => 'The First Topic!' }) - Topic.find_by_title("The First Topic!") - - Topic.expects(:find).with(:last, :conditions => { :title => 'The Last Topic!' }) - Topic.find_last_by_title("The Last Topic!") - - Topic.expects(:find).with(:all, :conditions => { :title => 'A Topic.' }) - Topic.find_all_by_title("A Topic.") - - Topic.expects(:find).with(:first, :conditions => { :title => 'Does not exist yet for sure!' }).times(2) - Topic.find_or_initialize_by_title('Does not exist yet for sure!') - Topic.find_or_create_by_title('Does not exist yet for sure!') - end - - def test_find_by_one_attribute - assert_equal topics(:first), Topic.find_by_title("The First Topic") - assert_nil Topic.find_by_title("The First Topic!") - end - - def test_find_by_one_attribute_bang - assert_equal topics(:first), Topic.find_by_title!("The First Topic") - assert_raise(ActiveRecord::RecordNotFound) { Topic.find_by_title!("The First Topic!") } - end - - def test_find_by_one_attribute_caches_dynamic_finder - # ensure this test can run independently of order - class << Topic; self; end.send(:remove_method, :find_by_title) if Topic.public_methods.any? { |m| m.to_s == 'find_by_title' } - assert !Topic.public_methods.any? { |m| m.to_s == 'find_by_title' } - t = Topic.find_by_title("The First Topic") - assert Topic.public_methods.any? { |m| m.to_s == 'find_by_title' } - end - - def test_dynamic_finder_returns_same_results_after_caching - # ensure this test can run independently of order - class << Topic; self; end.send(:remove_method, :find_by_title) if Topic.public_method_defined?(:find_by_title) - t = Topic.find_by_title("The First Topic") - assert_equal t, Topic.find_by_title("The First Topic") # find_by_title has been cached - end - - def test_find_by_one_attribute_with_order_option - assert_equal accounts(:signals37), Account.find_by_credit_limit(50, :order => 'id') - assert_equal accounts(:rails_core_account), Account.find_by_credit_limit(50, :order => 'id DESC') - end - - def test_find_by_one_attribute_with_conditions - assert_equal accounts(:rails_core_account), Account.find_by_credit_limit(50, :conditions => ['firm_id = ?', 6]) - end - - def test_find_by_one_attribute_that_is_an_aggregate - address = customers(:david).address - assert_kind_of Address, address - found_customer = Customer.find_by_address(address) - assert_equal customers(:david), found_customer - end - - def test_find_by_one_attribute_that_is_an_aggregate_with_one_attribute_difference - address = customers(:david).address - assert_kind_of Address, address - missing_address = Address.new(address.street, address.city, address.country + "1") - assert_nil Customer.find_by_address(missing_address) - missing_address = Address.new(address.street, address.city + "1", address.country) - assert_nil Customer.find_by_address(missing_address) - missing_address = Address.new(address.street + "1", address.city, address.country) - assert_nil Customer.find_by_address(missing_address) - end - - def test_find_by_two_attributes_that_are_both_aggregates - balance = customers(:david).balance - address = customers(:david).address - assert_kind_of Money, balance - assert_kind_of Address, address - found_customer = Customer.find_by_balance_and_address(balance, address) - assert_equal customers(:david), found_customer - end - - def test_find_by_two_attributes_with_one_being_an_aggregate - balance = customers(:david).balance - assert_kind_of Money, balance - found_customer = Customer.find_by_balance_and_name(balance, customers(:david).name) - assert_equal customers(:david), found_customer - end - - def test_dynamic_finder_on_one_attribute_with_conditions_caches_method - # ensure this test can run independently of order - class << Account; self; end.send(:remove_method, :find_by_credit_limit) if Account.public_methods.any? { |m| m.to_s == 'find_by_credit_limit' } - assert !Account.public_methods.any? { |m| m.to_s == 'find_by_credit_limit' } - a = Account.find_by_credit_limit(50, :conditions => ['firm_id = ?', 6]) - assert Account.public_methods.any? { |m| m.to_s == 'find_by_credit_limit' } - end - - def test_dynamic_finder_on_one_attribute_with_conditions_returns_same_results_after_caching - # ensure this test can run independently of order - class << Account; self; end.send(:remove_method, :find_by_credit_limit) if Account.public_methods.any? { |m| m.to_s == 'find_by_credit_limit' } - a = Account.find_by_credit_limit(50, :conditions => ['firm_id = ?', 6]) - assert_equal a, Account.find_by_credit_limit(50, :conditions => ['firm_id = ?', 6]) # find_by_credit_limit has been cached - end - - def test_find_by_one_attribute_with_several_options - assert_equal accounts(:unknown), Account.find_by_credit_limit(50, :order => 'id DESC', :conditions => ['id != ?', 3]) - end - - def test_find_by_one_missing_attribute - assert_raise(NoMethodError) { Topic.find_by_undertitle("The First Topic!") } - end - - def test_find_by_invalid_method_syntax - assert_raise(NoMethodError) { Topic.fail_to_find_by_title("The First Topic") } - assert_raise(NoMethodError) { Topic.find_by_title?("The First Topic") } - assert_raise(NoMethodError) { Topic.fail_to_find_or_create_by_title("Nonexistent Title") } - assert_raise(NoMethodError) { Topic.find_or_create_by_title?("Nonexistent Title") } - end - - def test_find_by_two_attributes - assert_equal topics(:first), Topic.find_by_title_and_author_name("The First Topic", "David") - assert_nil Topic.find_by_title_and_author_name("The First Topic", "Mary") - end - - def test_find_last_by_one_attribute - assert_equal Topic.last, Topic.find_last_by_title(Topic.last.title) - assert_nil Topic.find_last_by_title("A title with no matches") - end - - def test_find_last_by_one_attribute_caches_dynamic_finder - # ensure this test can run independently of order - class << Topic; self; end.send(:remove_method, :find_last_by_title) if Topic.public_methods.any? { |m| m.to_s == 'find_last_by_title' } - assert !Topic.public_methods.any? { |m| m.to_s == 'find_last_by_title' } - t = Topic.find_last_by_title(Topic.last.title) - assert Topic.public_methods.any? { |m| m.to_s == 'find_last_by_title' } - end - - def test_find_last_by_invalid_method_syntax - assert_raise(NoMethodError) { Topic.fail_to_find_last_by_title("The First Topic") } - assert_raise(NoMethodError) { Topic.find_last_by_title?("The First Topic") } - end - - def test_find_last_by_one_attribute_with_several_options - assert_equal accounts(:signals37), Account.find_last_by_credit_limit(50, :order => 'id DESC', :conditions => ['id != ?', 3]) - end - - def test_find_last_by_one_missing_attribute - assert_raise(NoMethodError) { Topic.find_last_by_undertitle("The Last Topic!") } - end - - def test_find_last_by_two_attributes - topic = Topic.last - assert_equal topic, Topic.find_last_by_title_and_author_name(topic.title, topic.author_name) - assert_nil Topic.find_last_by_title_and_author_name(topic.title, "Anonymous") - end - - def test_find_all_by_one_attribute - topics = Topic.find_all_by_content("Have a nice day") - assert_equal 2, topics.size - assert topics.include?(topics(:first)) - - assert_equal [], Topic.find_all_by_title("The First Topic!!") - end - - def test_find_all_by_one_attribute_that_is_an_aggregate - balance = customers(:david).balance - assert_kind_of Money, balance - found_customers = Customer.find_all_by_balance(balance) - assert_equal 1, found_customers.size - assert_equal customers(:david), found_customers.first - end - - def test_find_all_by_two_attributes_that_are_both_aggregates - balance = customers(:david).balance - address = customers(:david).address - assert_kind_of Money, balance - assert_kind_of Address, address - found_customers = Customer.find_all_by_balance_and_address(balance, address) - assert_equal 1, found_customers.size - assert_equal customers(:david), found_customers.first - end - - def test_find_all_by_two_attributes_with_one_being_an_aggregate - balance = customers(:david).balance - assert_kind_of Money, balance - found_customers = Customer.find_all_by_balance_and_name(balance, customers(:david).name) - assert_equal 1, found_customers.size - assert_equal customers(:david), found_customers.first - end - - def test_find_all_by_one_attribute_with_options - topics = Topic.find_all_by_content("Have a nice day", :order => "id DESC") - assert topics(:first), topics.last - - topics = Topic.find_all_by_content("Have a nice day", :order => "id") - assert topics(:first), topics.first - end - - def test_find_all_by_array_attribute - assert_equal 2, Topic.find_all_by_title(["The First Topic", "The Second Topic of the day"]).size - end - - def test_find_all_by_boolean_attribute - topics = Topic.find_all_by_approved(false) - assert_equal 1, topics.size - assert topics.include?(topics(:first)) - - topics = Topic.find_all_by_approved(true) - assert_equal 3, topics.size - assert topics.include?(topics(:second)) - end - - def test_find_by_nil_attribute - topic = Topic.find_by_last_read nil - assert_not_nil topic - assert_nil topic.last_read - end - - def test_find_all_by_nil_attribute - topics = Topic.find_all_by_last_read nil - assert_equal 3, topics.size - assert topics.collect(&:last_read).all?(&:nil?) - end - - def test_find_by_nil_and_not_nil_attributes - topic = Topic.find_by_last_read_and_author_name nil, "Mary" - assert_equal "Mary", topic.author_name - end - - def test_find_all_by_nil_and_not_nil_attributes - topics = Topic.find_all_by_last_read_and_author_name nil, "Mary" - assert_equal 1, topics.size - assert_equal "Mary", topics[0].author_name - end - - def test_find_or_create_from_one_attribute - number_of_companies = Company.count - sig38 = Company.find_or_create_by_name("38signals") - assert_equal number_of_companies + 1, Company.count - assert_equal sig38, Company.find_or_create_by_name("38signals") - assert !sig38.new_record? - end - - def test_find_or_create_from_two_attributes - number_of_topics = Topic.count - another = Topic.find_or_create_by_title_and_author_name("Another topic","John") - assert_equal number_of_topics + 1, Topic.count - assert_equal another, Topic.find_or_create_by_title_and_author_name("Another topic", "John") - assert !another.new_record? - end - - def test_find_or_create_from_two_attributes_with_one_being_an_aggregate - number_of_customers = Customer.count - created_customer = Customer.find_or_create_by_balance_and_name(Money.new(123), "Elizabeth") - assert_equal number_of_customers + 1, Customer.count - assert_equal created_customer, Customer.find_or_create_by_balance(Money.new(123), "Elizabeth") - assert !created_customer.new_record? - end - - def test_find_or_create_from_one_attribute_and_hash - number_of_companies = Company.count - sig38 = Company.find_or_create_by_name({:name => "38signals", :firm_id => 17, :client_of => 23}) - assert_equal number_of_companies + 1, Company.count - assert_equal sig38, Company.find_or_create_by_name({:name => "38signals", :firm_id => 17, :client_of => 23}) - assert !sig38.new_record? - assert_equal "38signals", sig38.name - assert_equal 17, sig38.firm_id - assert_equal 23, sig38.client_of - end - - def test_find_or_create_from_one_aggregate_attribute - number_of_customers = Customer.count - created_customer = Customer.find_or_create_by_balance(Money.new(123)) - assert_equal number_of_customers + 1, Customer.count - assert_equal created_customer, Customer.find_or_create_by_balance(Money.new(123)) - assert !created_customer.new_record? - end - - def test_find_or_create_from_one_aggregate_attribute_and_hash - number_of_customers = Customer.count - balance = Money.new(123) - name = "Elizabeth" - created_customer = Customer.find_or_create_by_balance({:balance => balance, :name => name}) - assert_equal number_of_customers + 1, Customer.count - assert_equal created_customer, Customer.find_or_create_by_balance({:balance => balance, :name => name}) - assert !created_customer.new_record? - assert_equal balance, created_customer.balance - assert_equal name, created_customer.name - end - - def test_find_or_initialize_from_one_attribute - sig38 = Company.find_or_initialize_by_name("38signals") - assert_equal "38signals", sig38.name - assert sig38.new_record? - end - - def test_find_or_initialize_from_one_aggregate_attribute - new_customer = Customer.find_or_initialize_by_balance(Money.new(123)) - assert_equal 123, new_customer.balance.amount - assert new_customer.new_record? - end - - def test_find_or_initialize_from_one_attribute_should_not_set_attribute_even_when_protected - c = Company.find_or_initialize_by_name({:name => "Fortune 1000", :rating => 1000}) - assert_equal "Fortune 1000", c.name - assert_not_equal 1000, c.rating - assert c.valid? - assert c.new_record? - end - - def test_find_or_create_from_one_attribute_should_set_not_attribute_even_when_protected - c = Company.find_or_create_by_name({:name => "Fortune 1000", :rating => 1000}) - assert_equal "Fortune 1000", c.name - assert_not_equal 1000, c.rating - assert c.valid? - assert !c.new_record? - end - - def test_find_or_initialize_from_one_attribute_should_set_attribute_even_when_protected - c = Company.find_or_initialize_by_name_and_rating("Fortune 1000", 1000) - assert_equal "Fortune 1000", c.name - assert_equal 1000, c.rating - assert c.valid? - assert c.new_record? - end - - def test_find_or_create_from_one_attribute_should_set_attribute_even_when_protected - c = Company.find_or_create_by_name_and_rating("Fortune 1000", 1000) - assert_equal "Fortune 1000", c.name - assert_equal 1000, c.rating - assert c.valid? - assert !c.new_record? - end - - def test_find_or_initialize_should_set_protected_attributes_if_given_as_block - c = Company.find_or_initialize_by_name(:name => "Fortune 1000") { |f| f.rating = 1000 } - assert_equal "Fortune 1000", c.name - assert_equal 1000.to_f, c.rating.to_f - assert c.valid? - assert c.new_record? - end - - def test_find_or_create_should_set_protected_attributes_if_given_as_block - c = Company.find_or_create_by_name(:name => "Fortune 1000") { |f| f.rating = 1000 } - assert_equal "Fortune 1000", c.name - assert_equal 1000.to_f, c.rating.to_f - assert c.valid? - assert !c.new_record? - end - - def test_find_or_create_should_work_with_block_on_first_call - class << Company - undef_method(:find_or_create_by_name) if method_defined?(:find_or_create_by_name) - end - c = Company.find_or_create_by_name(:name => "Fortune 1000") { |f| f.rating = 1000 } - assert_equal "Fortune 1000", c.name - assert_equal 1000.to_f, c.rating.to_f - assert c.valid? - assert !c.new_record? - end - - def test_dynamic_find_or_initialize_from_one_attribute_caches_method - class << Company; self; end.send(:remove_method, :find_or_initialize_by_name) if Company.public_methods.any? { |m| m.to_s == 'find_or_initialize_by_name' } - assert !Company.public_methods.any? { |m| m.to_s == 'find_or_initialize_by_name' } - sig38 = Company.find_or_initialize_by_name("38signals") - assert Company.public_methods.any? { |m| m.to_s == 'find_or_initialize_by_name' } - end - - def test_find_or_initialize_from_two_attributes - another = Topic.find_or_initialize_by_title_and_author_name("Another topic","John") - assert_equal "Another topic", another.title - assert_equal "John", another.author_name - assert another.new_record? - end - - def test_find_or_initialize_from_one_aggregate_attribute_and_one_not - new_customer = Customer.find_or_initialize_by_balance_and_name(Money.new(123), "Elizabeth") - assert_equal 123, new_customer.balance.amount - assert_equal "Elizabeth", new_customer.name - assert new_customer.new_record? - end - - def test_find_or_initialize_from_one_attribute_and_hash - sig38 = Company.find_or_initialize_by_name({:name => "38signals", :firm_id => 17, :client_of => 23}) - assert_equal "38signals", sig38.name - assert_equal 17, sig38.firm_id - assert_equal 23, sig38.client_of - assert sig38.new_record? - end - - def test_find_or_initialize_from_one_aggregate_attribute_and_hash - balance = Money.new(123) - name = "Elizabeth" - new_customer = Customer.find_or_initialize_by_balance({:balance => balance, :name => name}) - assert_equal balance, new_customer.balance - assert_equal name, new_customer.name - assert new_customer.new_record? - end - - def test_find_with_bad_sql - assert_raise(ActiveRecord::StatementInvalid) { Topic.find_by_sql "select 1 from badtable" } - end - - def test_find_with_invalid_params - assert_raise(ArgumentError) { Topic.find :first, :join => "It should be `joins'" } - assert_raise(ArgumentError) { Topic.find :first, :conditions => '1 = 1', :join => "It should be `joins'" } - end - - def test_dynamic_finder_with_invalid_params - assert_raise(ArgumentError) { Topic.find_by_title 'No Title', :join => "It should be `joins'" } - end - - def test_find_all_with_limit - first_five_developers = Developer.find :all, :order => 'id ASC', :limit => 5 - assert_equal 5, first_five_developers.length - assert_equal 'David', first_five_developers.first.name - assert_equal 'fixture_5', first_five_developers.last.name - - no_developers = Developer.find :all, :order => 'id ASC', :limit => 0 - assert_equal 0, no_developers.length - end - - def test_find_all_with_limit_and_offset - first_three_developers = Developer.find :all, :order => 'id ASC', :limit => 3, :offset => 0 - second_three_developers = Developer.find :all, :order => 'id ASC', :limit => 3, :offset => 3 - last_two_developers = Developer.find :all, :order => 'id ASC', :limit => 2, :offset => 8 - - assert_equal 3, first_three_developers.length - assert_equal 3, second_three_developers.length - assert_equal 2, last_two_developers.length - - assert_equal 'David', first_three_developers.first.name - assert_equal 'fixture_4', second_three_developers.first.name - assert_equal 'fixture_9', last_two_developers.first.name - end - - def test_find_all_with_limit_and_offset_and_multiple_order_clauses - first_three_posts = Post.find :all, :order => 'author_id, id', :limit => 3, :offset => 0 - second_three_posts = Post.find :all, :order => ' author_id,id ', :limit => 3, :offset => 3 - last_posts = Post.find :all, :order => ' author_id, id ', :limit => 3, :offset => 6 - - assert_equal [[0,3],[1,1],[1,2]], first_three_posts.map { |p| [p.author_id, p.id] } - assert_equal [[1,4],[1,5],[1,6]], second_three_posts.map { |p| [p.author_id, p.id] } - assert_equal [[2,7]], last_posts.map { |p| [p.author_id, p.id] } - end - - def test_find_all_with_join - developers_on_project_one = Developer.find( - :all, - :joins => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id', - :conditions => 'project_id=1' - ) - assert_equal 3, developers_on_project_one.length - developer_names = developers_on_project_one.map { |d| d.name } - assert developer_names.include?('David') - assert developer_names.include?('Jamis') - end - - def test_joins_dont_clobber_id - first = Firm.find( - :first, - :joins => 'INNER JOIN companies AS clients ON clients.firm_id = companies.id', - :conditions => 'companies.id = 1' - ) - assert_equal 1, first.id - end - - def test_joins_with_string_array - person_with_reader_and_post = Post.find( - :all, - :joins => [ - "INNER JOIN categorizations ON categorizations.post_id = posts.id", - "INNER JOIN categories ON categories.id = categorizations.category_id AND categories.type = 'SpecialCategory'" - ] - ) - assert_equal 1, person_with_reader_and_post.size - end - - def test_find_by_id_with_conditions_with_or - assert_nothing_raised do - Post.find([1,2,3], - :conditions => "posts.id <= 3 OR posts.#{QUOTED_TYPE} = 'Post'") - end - end - - # http://dev.rubyonrails.org/ticket/6778 - def test_find_ignores_previously_inserted_record - post = Post.create!(:title => 'test', :body => 'it out') - assert_equal [], Post.find_all_by_id(nil) - end - - def test_find_by_empty_ids - assert_equal [], Post.find([]) - end - - def test_find_by_empty_in_condition - assert_equal [], Post.find(:all, :conditions => ['id in (?)', []]) - end - - def test_find_by_records - p1, p2 = Post.find(:all, :limit => 2, :order => 'id asc') - assert_equal [p1, p2], Post.find(:all, :conditions => ['id in (?)', [p1, p2]], :order => 'id asc') - assert_equal [p1, p2], Post.find(:all, :conditions => ['id in (?)', [p1, p2.id]], :order => 'id asc') - end - - def test_select_value - assert_equal "37signals", Company.connection.select_value("SELECT name FROM companies WHERE id = 1") - assert_nil Company.connection.select_value("SELECT name FROM companies WHERE id = -1") - # make sure we didn't break count... - assert_equal 0, Company.count_by_sql("SELECT COUNT(*) FROM companies WHERE name = 'Halliburton'") - assert_equal 1, Company.count_by_sql("SELECT COUNT(*) FROM companies WHERE name = '37signals'") - end - - def test_select_values - assert_equal ["1","2","3","4","5","6","7","8","9"], Company.connection.select_values("SELECT id FROM companies ORDER BY id").map! { |i| i.to_s } - assert_equal ["37signals","Summit","Microsoft", "Flamboyant Software", "Ex Nihilo", "RailsCore", "Leetsoft", "Jadedpixel", "Odegy"], Company.connection.select_values("SELECT name FROM companies ORDER BY id") - end - - def test_select_rows - assert_equal( - [["1", nil, nil, "37signals"], - ["2", "1", "2", "Summit"], - ["3", "1", "1", "Microsoft"]], - Company.connection.select_rows("SELECT id, firm_id, client_of, name FROM companies WHERE id IN (1,2,3) ORDER BY id").map! {|i| i.map! {|j| j.to_s unless j.nil?}}) - assert_equal [["1", "37signals"], ["2", "Summit"], ["3", "Microsoft"]], - Company.connection.select_rows("SELECT id, name FROM companies WHERE id IN (1,2,3) ORDER BY id").map! {|i| i.map! {|j| j.to_s unless j.nil?}} - end - - def test_find_with_order_on_included_associations_with_construct_finder_sql_for_association_limiting_and_is_distinct - assert_equal 2, Post.find(:all, :include => { :authors => :author_address }, :order => ' author_addresses.id DESC ', :limit => 2).size - - assert_equal 3, Post.find(:all, :include => { :author => :author_address, :authors => :author_address}, - :order => ' author_addresses_authors.id DESC ', :limit => 3).size - end - - def test_with_limiting_with_custom_select - posts = Post.find(:all, :include => :author, :select => ' posts.*, authors.id as "author_id"', :limit => 3, :order => 'posts.id') - assert_equal 3, posts.size - assert_equal [0, 1, 1], posts.map(&:author_id).sort - end - - def test_finder_with_scoped_from - all_topics = Topic.all - - Topic.with_scope(:find => { :from => 'fake_topics' }) do - assert_equal all_topics, Topic.all(:from => 'topics') - end - end - - protected - def bind(statement, *vars) - if vars.first.is_a?(Hash) - ActiveRecord::Base.send(:replace_named_bind_variables, statement, vars.first) - else - ActiveRecord::Base.send(:replace_bind_variables, statement, vars) - end - end -end diff --git a/vendor/rails/activerecord/test/cases/fixtures_test.rb b/vendor/rails/activerecord/test/cases/fixtures_test.rb deleted file mode 100644 index 252bf4f..0000000 --- a/vendor/rails/activerecord/test/cases/fixtures_test.rb +++ /dev/null @@ -1,651 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/binary' -require 'models/topic' -require 'models/computer' -require 'models/developer' -require 'models/company' -require 'models/task' -require 'models/reply' -require 'models/joke' -require 'models/course' -require 'models/category' -require 'models/parrot' -require 'models/pirate' -require 'models/treasure' -require 'models/matey' -require 'models/ship' -require 'models/book' - -class FixturesTest < ActiveRecord::TestCase - self.use_instantiated_fixtures = true - self.use_transactional_fixtures = false - - fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes, :binaries - - FIXTURES = %w( accounts binaries companies customers - developers developers_projects entrants - movies projects subscribers topics tasks ) - MATCH_ATTRIBUTE_NAME = /[a-zA-Z][-_\w]*/ - - def test_clean_fixtures - FIXTURES.each do |name| - fixtures = nil - assert_nothing_raised { fixtures = create_fixtures(name) } - assert_kind_of(Fixtures, fixtures) - fixtures.each { |name, fixture| - fixture.each { |key, value| - assert_match(MATCH_ATTRIBUTE_NAME, key) - } - } - end - end - - def test_multiple_clean_fixtures - fixtures_array = nil - assert_nothing_raised { fixtures_array = create_fixtures(*FIXTURES) } - assert_kind_of(Array, fixtures_array) - fixtures_array.each { |fixtures| assert_kind_of(Fixtures, fixtures) } - end - - def test_attributes - topics = create_fixtures("topics") - assert_equal("The First Topic", topics["first"]["title"]) - assert_nil(topics["second"]["author_email_address"]) - end - - def test_inserts - topics = create_fixtures("topics") - first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'David'") - assert_equal("The First Topic", first_row["title"]) - - second_row = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'Mary'") - assert_nil(second_row["author_email_address"]) - end - - if ActiveRecord::Base.connection.supports_migrations? - def test_inserts_with_pre_and_suffix - # Reset cache to make finds on the new table work - Fixtures.reset_cache - - ActiveRecord::Base.connection.create_table :prefix_topics_suffix do |t| - t.column :title, :string - t.column :author_name, :string - t.column :author_email_address, :string - t.column :written_on, :datetime - t.column :bonus_time, :time - t.column :last_read, :date - t.column :content, :string - t.column :approved, :boolean, :default => true - t.column :replies_count, :integer, :default => 0 - t.column :parent_id, :integer - t.column :type, :string, :limit => 50 - end - - # Store existing prefix/suffix - old_prefix = ActiveRecord::Base.table_name_prefix - old_suffix = ActiveRecord::Base.table_name_suffix - - # Set a prefix/suffix we can test against - ActiveRecord::Base.table_name_prefix = 'prefix_' - ActiveRecord::Base.table_name_suffix = '_suffix' - - topics = create_fixtures("topics") - - first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'David'") - assert_equal("The First Topic", first_row["title"]) - - second_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'Mary'") - assert_nil(second_row["author_email_address"]) - - # This checks for a caching problem which causes a bug in the fixtures - # class-level configuration helper. - assert_not_nil topics, "Fixture data inserted, but fixture objects not returned from create" - ensure - # Restore prefix/suffix to its previous values - ActiveRecord::Base.table_name_prefix = old_prefix - ActiveRecord::Base.table_name_suffix = old_suffix - - ActiveRecord::Base.connection.drop_table :prefix_topics_suffix rescue nil - end - end - - def test_insert_with_datetime - topics = create_fixtures("tasks") - first = Task.find(1) - assert first - end - - def test_logger_level_invariant - level = ActiveRecord::Base.logger.level - create_fixtures('topics') - assert_equal level, ActiveRecord::Base.logger.level - end - - def test_instantiation - topics = create_fixtures("topics") - assert_kind_of Topic, topics["first"].find - end - - def test_complete_instantiation - assert_equal 4, @topics.size - assert_equal "The First Topic", @first.title - end - - def test_fixtures_from_root_yml_with_instantiation - # assert_equal 2, @accounts.size - assert_equal 50, @unknown.credit_limit - end - - def test_erb_in_fixtures - assert_equal 11, @developers.size - assert_equal "fixture_5", @dev_5.name - end - - def test_empty_yaml_fixture - assert_not_nil Fixtures.new( Account.connection, "accounts", 'Account', FIXTURES_ROOT + "/naked/yml/accounts") - end - - def test_empty_yaml_fixture_with_a_comment_in_it - assert_not_nil Fixtures.new( Account.connection, "companies", 'Company', FIXTURES_ROOT + "/naked/yml/companies") - end - - def test_dirty_dirty_yaml_file - assert_raise(Fixture::FormatError) do - Fixtures.new( Account.connection, "courses", 'Course', FIXTURES_ROOT + "/naked/yml/courses") - end - end - - def test_empty_csv_fixtures - assert_not_nil Fixtures.new( Account.connection, "accounts", 'Account', FIXTURES_ROOT + "/naked/csv/accounts") - end - - def test_omap_fixtures - assert_nothing_raised do - fixtures = Fixtures.new(Account.connection, 'categories', 'Category', FIXTURES_ROOT + "/categories_ordered") - - i = 0 - fixtures.each do |name, fixture| - assert_equal "fixture_no_#{i}", name - assert_equal "Category #{i}", fixture['name'] - i += 1 - end - end - end - - def test_yml_file_in_subdirectory - assert_equal(categories(:sub_special_1).name, "A special category in a subdir file") - assert_equal(categories(:sub_special_1).class, SpecialCategory) - end - - def test_subsubdir_file_with_arbitrary_name - assert_equal(categories(:sub_special_3).name, "A special category in an arbitrarily named subsubdir file") - assert_equal(categories(:sub_special_3).class, SpecialCategory) - end - - def test_binary_in_fixtures - assert_equal 1, @binaries.size - data = File.read(ASSETS_ROOT + "/flowers.jpg") - data.force_encoding('ASCII-8BIT') if data.respond_to?(:force_encoding) - data.freeze - assert_equal data, @flowers.data - end -end - -if Account.connection.respond_to?(:reset_pk_sequence!) - class FixturesResetPkSequenceTest < ActiveRecord::TestCase - fixtures :accounts - fixtures :companies - - def setup - @instances = [Account.new(:credit_limit => 50), Company.new(:name => 'RoR Consulting')] - Fixtures.reset_cache # make sure tables get reinitialized - end - - def test_resets_to_min_pk_with_specified_pk_and_sequence - @instances.each do |instance| - model = instance.class - model.delete_all - model.connection.reset_pk_sequence!(model.table_name, model.primary_key, model.sequence_name) - - instance.save! - assert_equal 1, instance.id, "Sequence reset for #{model.table_name} failed." - end - end - - def test_resets_to_min_pk_with_default_pk_and_sequence - @instances.each do |instance| - model = instance.class - model.delete_all - model.connection.reset_pk_sequence!(model.table_name) - - instance.save! - assert_equal 1, instance.id, "Sequence reset for #{model.table_name} failed." - end - end - - def test_create_fixtures_resets_sequences_when_not_cached - @instances.each do |instance| - max_id = create_fixtures(instance.class.table_name).inject(0) do |max_id, (name, fixture)| - fixture_id = fixture['id'].to_i - fixture_id > max_id ? fixture_id : max_id - end - - # Clone the last fixture to check that it gets the next greatest id. - instance.save! - assert_equal max_id + 1, instance.id, "Sequence reset for #{instance.class.table_name} failed." - end - end - end -end - -class FixturesWithoutInstantiationTest < ActiveRecord::TestCase - self.use_instantiated_fixtures = false - fixtures :topics, :developers, :accounts - - def test_without_complete_instantiation - assert_nil @first - assert_nil @topics - assert_nil @developers - assert_nil @accounts - end - - def test_fixtures_from_root_yml_without_instantiation - assert_nil @unknown - end - - def test_accessor_methods - assert_equal "The First Topic", topics(:first).title - assert_equal "Jamis", developers(:jamis).name - assert_equal 50, accounts(:signals37).credit_limit - end - - def test_accessor_methods_with_multiple_args - assert_equal 2, topics(:first, :second).size - assert_raise(StandardError) { topics([:first, :second]) } - end - - def test_reloading_fixtures_through_accessor_methods - assert_equal "The First Topic", topics(:first).title - @loaded_fixtures['topics']['first'].expects(:find).returns(stub(:title => "Fresh Topic!")) - assert_equal "Fresh Topic!", topics(:first, true).title - end -end - -class FixturesWithoutInstanceInstantiationTest < ActiveRecord::TestCase - self.use_instantiated_fixtures = true - self.use_instantiated_fixtures = :no_instances - - fixtures :topics, :developers, :accounts - - def test_without_instance_instantiation - assert_nil @first - assert_not_nil @topics - assert_not_nil @developers - assert_not_nil @accounts - end -end - -class TransactionalFixturesTest < ActiveRecord::TestCase - self.use_instantiated_fixtures = true - self.use_transactional_fixtures = true - - fixtures :topics - - def test_destroy - assert_not_nil @first - @first.destroy - end - - def test_destroy_just_kidding - assert_not_nil @first - end -end - -class MultipleFixturesTest < ActiveRecord::TestCase - fixtures :topics - fixtures :developers, :accounts - - def test_fixture_table_names - assert_equal %w(topics developers accounts), fixture_table_names - end -end - -class SetupTest < ActiveRecord::TestCase - # fixtures :topics - - def setup - @first = true - end - - def test_nothing - end -end - -class SetupSubclassTest < SetupTest - def setup - super - @second = true - end - - def test_subclassing_should_preserve_setups - assert @first - assert @second - end -end - - -class OverlappingFixturesTest < ActiveRecord::TestCase - fixtures :topics, :developers - fixtures :developers, :accounts - - def test_fixture_table_names - assert_equal %w(topics developers accounts), fixture_table_names - end -end - -class ForeignKeyFixturesTest < ActiveRecord::TestCase - fixtures :fk_test_has_pk, :fk_test_has_fk - - # if foreign keys are implemented and fixtures - # are not deleted in reverse order then this test - # case will raise StatementInvalid - - def test_number1 - assert true - end - - def test_number2 - assert true - end -end - -class CheckSetTableNameFixturesTest < ActiveRecord::TestCase - set_fixture_class :funny_jokes => 'Joke' - fixtures :funny_jokes - # Set to false to blow away fixtures cache and ensure our fixtures are loaded - # and thus takes into account our set_fixture_class - self.use_transactional_fixtures = false - - def test_table_method - assert_kind_of Joke, funny_jokes(:a_joke) - end -end - -class FixtureNameIsNotTableNameFixturesTest < ActiveRecord::TestCase - set_fixture_class :items => Book - fixtures :items - # Set to false to blow away fixtures cache and ensure our fixtures are loaded - # and thus takes into account our set_fixture_class - self.use_transactional_fixtures = false - - def test_named_accessor - assert_kind_of Book, items(:dvd) - end -end - -class FixtureNameIsNotTableNameMultipleFixturesTest < ActiveRecord::TestCase - set_fixture_class :items => Book, :funny_jokes => Joke - fixtures :items, :funny_jokes - # Set to false to blow away fixtures cache and ensure our fixtures are loaded - # and thus takes into account our set_fixture_class - self.use_transactional_fixtures = false - - def test_named_accessor_of_differently_named_fixture - assert_kind_of Book, items(:dvd) - end - - def test_named_accessor_of_same_named_fixture - assert_kind_of Joke, funny_jokes(:a_joke) - end -end - -class CustomConnectionFixturesTest < ActiveRecord::TestCase - set_fixture_class :courses => Course - fixtures :courses - # Set to false to blow away fixtures cache and ensure our fixtures are loaded - # and thus takes into account our set_fixture_class - self.use_transactional_fixtures = false - - def test_connection - assert_kind_of Course, courses(:ruby) - assert_equal Course.connection, courses(:ruby).connection - end -end - -class InvalidTableNameFixturesTest < ActiveRecord::TestCase - fixtures :funny_jokes - # Set to false to blow away fixtures cache and ensure our fixtures are loaded - # and thus takes into account our lack of set_fixture_class - self.use_transactional_fixtures = false - - def test_raises_error - assert_raise FixtureClassNotFound do - funny_jokes(:a_joke) - end - end -end - -class CheckEscapedYamlFixturesTest < ActiveRecord::TestCase - set_fixture_class :funny_jokes => 'Joke' - fixtures :funny_jokes - # Set to false to blow away fixtures cache and ensure our fixtures are loaded - # and thus takes into account our set_fixture_class - self.use_transactional_fixtures = false - - def test_proper_escaped_fixture - assert_equal "The \\n Aristocrats\nAte the candy\n", funny_jokes(:another_joke).name - end -end - -class DevelopersProject; end -class ManyToManyFixturesWithClassDefined < ActiveRecord::TestCase - fixtures :developers_projects - - def test_this_should_run_cleanly - assert true - end -end - -class FixturesBrokenRollbackTest < ActiveRecord::TestCase - def blank_setup; end - alias_method :ar_setup_fixtures, :setup_fixtures - alias_method :setup_fixtures, :blank_setup - alias_method :setup, :blank_setup - - def blank_teardown; end - alias_method :ar_teardown_fixtures, :teardown_fixtures - alias_method :teardown_fixtures, :blank_teardown - alias_method :teardown, :blank_teardown - - def test_no_rollback_in_teardown_unless_transaction_active - assert_equal 0, ActiveRecord::Base.connection.open_transactions - assert_raise(RuntimeError) { ar_setup_fixtures } - assert_equal 0, ActiveRecord::Base.connection.open_transactions - assert_nothing_raised { ar_teardown_fixtures } - assert_equal 0, ActiveRecord::Base.connection.open_transactions - end - - private - def load_fixtures - raise 'argh' - end -end - -class LoadAllFixturesTest < ActiveRecord::TestCase - self.fixture_path = FIXTURES_ROOT + "/all" - fixtures :all - - def test_all_there - assert_equal %w(developers people tasks), fixture_table_names.sort - end -end - -class FasterFixturesTest < ActiveRecord::TestCase - fixtures :categories, :authors - - def load_extra_fixture(name) - fixture = create_fixtures(name) - assert fixture.is_a?(Fixtures) - @loaded_fixtures[fixture.table_name] = fixture - end - - def test_cache - assert Fixtures.fixture_is_cached?(ActiveRecord::Base.connection, 'categories') - assert Fixtures.fixture_is_cached?(ActiveRecord::Base.connection, 'authors') - - assert_no_queries do - create_fixtures('categories') - create_fixtures('authors') - end - - load_extra_fixture('posts') - assert Fixtures.fixture_is_cached?(ActiveRecord::Base.connection, 'posts') - self.class.setup_fixture_accessors('posts') - assert_equal 'Welcome to the weblog', posts(:welcome).title - end -end - -class FoxyFixturesTest < ActiveRecord::TestCase - fixtures :parrots, :parrots_pirates, :pirates, :treasures, :mateys, :ships, :computers, :developers - - def test_identifies_strings - assert_equal(Fixtures.identify("foo"), Fixtures.identify("foo")) - assert_not_equal(Fixtures.identify("foo"), Fixtures.identify("FOO")) - end - - def test_identifies_symbols - assert_equal(Fixtures.identify(:foo), Fixtures.identify(:foo)) - end - - TIMESTAMP_COLUMNS = %w(created_at created_on updated_at updated_on) - - def test_populates_timestamp_columns - TIMESTAMP_COLUMNS.each do |property| - assert_not_nil(parrots(:george).send(property), "should set #{property}") - end - end - - def test_does_not_populate_timestamp_columns_if_model_has_set_record_timestamps_to_false - TIMESTAMP_COLUMNS.each do |property| - assert_nil(ships(:black_pearl).send(property), "should not set #{property}") - end - end - - def test_populates_all_columns_with_the_same_time - last = nil - - TIMESTAMP_COLUMNS.each do |property| - current = parrots(:george).send(property) - last ||= current - - assert_equal(last, current) - last = current - end - end - - def test_only_populates_columns_that_exist - assert_not_nil(pirates(:blackbeard).created_on) - assert_not_nil(pirates(:blackbeard).updated_on) - end - - def test_preserves_existing_fixture_data - assert_equal(2.weeks.ago.to_date, pirates(:redbeard).created_on.to_date) - assert_equal(2.weeks.ago.to_date, pirates(:redbeard).updated_on.to_date) - end - - def test_generates_unique_ids - assert_not_nil(parrots(:george).id) - assert_not_equal(parrots(:george).id, parrots(:louis).id) - end - - def test_automatically_sets_primary_key - assert_not_nil(ships(:black_pearl)) - end - - def test_preserves_existing_primary_key - assert_equal(2, ships(:interceptor).id) - end - - def test_resolves_belongs_to_symbols - assert_equal(parrots(:george), pirates(:blackbeard).parrot) - end - - def test_ignores_belongs_to_symbols_if_association_and_foreign_key_are_named_the_same - assert_equal(developers(:david), computers(:workstation).developer) - end - - def test_supports_join_tables - assert(pirates(:blackbeard).parrots.include?(parrots(:george))) - assert(pirates(:blackbeard).parrots.include?(parrots(:louis))) - assert(parrots(:george).pirates.include?(pirates(:blackbeard))) - end - - def test_supports_inline_habtm - assert(parrots(:george).treasures.include?(treasures(:diamond))) - assert(parrots(:george).treasures.include?(treasures(:sapphire))) - assert(!parrots(:george).treasures.include?(treasures(:ruby))) - end - - def test_supports_inline_habtm_with_specified_id - assert(parrots(:polly).treasures.include?(treasures(:ruby))) - assert(parrots(:polly).treasures.include?(treasures(:sapphire))) - assert(!parrots(:polly).treasures.include?(treasures(:diamond))) - end - - def test_supports_yaml_arrays - assert(parrots(:louis).treasures.include?(treasures(:diamond))) - assert(parrots(:louis).treasures.include?(treasures(:sapphire))) - end - - def test_strips_DEFAULTS_key - assert_raise(StandardError) { parrots(:DEFAULTS) } - - # this lets us do YAML defaults and not have an extra fixture entry - %w(sapphire ruby).each { |t| assert(parrots(:davey).treasures.include?(treasures(t))) } - end - - def test_supports_label_interpolation - assert_equal("frederick", parrots(:frederick).name) - end - - def test_supports_polymorphic_belongs_to - assert_equal(pirates(:redbeard), treasures(:sapphire).looter) - assert_equal(parrots(:louis), treasures(:ruby).looter) - end - - def test_only_generates_a_pk_if_necessary - m = Matey.find(:first) - m.pirate = pirates(:blackbeard) - m.target = pirates(:redbeard) - end - - def test_supports_sti - assert_kind_of DeadParrot, parrots(:polly) - assert_equal pirates(:blackbeard), parrots(:polly).killer - end -end - -class ActiveSupportSubclassWithFixturesTest < ActiveRecord::TestCase - fixtures :parrots - - # This seemingly useless assertion catches a bug that caused the fixtures - # setup code call nil[] - def test_foo - assert_equal parrots(:louis), Parrot.find_by_name("King Louis") - end -end - -class FixtureLoadingTest < ActiveRecord::TestCase - def test_logs_message_for_failed_dependency_load - ActiveRecord::TestCase.expects(:require_dependency).with(:does_not_exist).raises(LoadError) - ActiveRecord::Base.logger.expects(:warn) - ActiveRecord::TestCase.try_to_load_dependency(:does_not_exist) - end - - def test_does_not_logs_message_for_successful_dependency_load - ActiveRecord::TestCase.expects(:require_dependency).with(:works_out_fine) - ActiveRecord::Base.logger.expects(:warn).never - ActiveRecord::TestCase.try_to_load_dependency(:works_out_fine) - end -end diff --git a/vendor/rails/activerecord/test/cases/helper.rb b/vendor/rails/activerecord/test/cases/helper.rb deleted file mode 100644 index 1ec52ac..0000000 --- a/vendor/rails/activerecord/test/cases/helper.rb +++ /dev/null @@ -1,69 +0,0 @@ -$:.unshift(File.dirname(__FILE__) + '/../../lib') -$:.unshift(File.dirname(__FILE__) + '/../../../activesupport/lib') - -require 'config' - -require 'rubygems' -require 'test/unit' -gem 'mocha', '>= 0.9.5' -require 'mocha' - -require 'active_record' -require 'active_record/test_case' -require 'active_record/fixtures' -require 'connection' - -require 'cases/repair_helper' - -# Show backtraces for deprecated behavior for quicker cleanup. -ActiveSupport::Deprecation.debug = true - -# Quote "type" if it's a reserved word for the current connection. -QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name('type') - -def current_adapter?(*types) - types.any? do |type| - ActiveRecord::ConnectionAdapters.const_defined?(type) && - ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters.const_get(type)) - end -end - -ActiveRecord::Base.connection.class.class_eval do - IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /SHOW FIELDS/] - - def execute_with_query_record(sql, name = nil, &block) - $queries_executed ||= [] - $queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r } - execute_without_query_record(sql, name, &block) - end - - alias_method_chain :execute, :query_record -end - -# Make with_scope public for tests -class << ActiveRecord::Base - public :with_scope, :with_exclusive_scope -end - -unless ENV['FIXTURE_DEBUG'] - module ActiveRecord::TestFixtures::ClassMethods - def try_to_load_dependency_with_silence(*args) - ActiveRecord::Base.logger.silence { try_to_load_dependency_without_silence(*args)} - end - - alias_method_chain :try_to_load_dependency, :silence - end -end - -class ActiveSupport::TestCase - include ActiveRecord::TestFixtures - include ActiveRecord::Testing::RepairHelper - - self.fixture_path = FIXTURES_ROOT - self.use_instantiated_fixtures = false - self.use_transactional_fixtures = true - - def create_fixtures(*table_names, &block) - Fixtures.create_fixtures(ActiveSupport::TestCase.fixture_path, table_names, {}, &block) - end -end diff --git a/vendor/rails/activerecord/test/cases/i18n_test.rb b/vendor/rails/activerecord/test/cases/i18n_test.rb deleted file mode 100644 index b1db662..0000000 --- a/vendor/rails/activerecord/test/cases/i18n_test.rb +++ /dev/null @@ -1,41 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/reply' - -class ActiveRecordI18nTests < Test::Unit::TestCase - - def setup - I18n.backend = I18n::Backend::Simple.new - end - - def test_translated_model_attributes - I18n.backend.store_translations 'en', :activerecord => {:attributes => {:topic => {:title => 'topic title attribute'} } } - assert_equal 'topic title attribute', Topic.human_attribute_name('title') - end - - def test_translated_model_attributes_with_sti - I18n.backend.store_translations 'en', :activerecord => {:attributes => {:reply => {:title => 'reply title attribute'} } } - assert_equal 'reply title attribute', Reply.human_attribute_name('title') - end - - def test_translated_model_attributes_with_sti_fallback - I18n.backend.store_translations 'en', :activerecord => {:attributes => {:topic => {:title => 'topic title attribute'} } } - assert_equal 'topic title attribute', Reply.human_attribute_name('title') - end - - def test_translated_model_names - I18n.backend.store_translations 'en', :activerecord => {:models => {:topic => 'topic model'} } - assert_equal 'topic model', Topic.human_name - end - - def test_translated_model_names_with_sti - I18n.backend.store_translations 'en', :activerecord => {:models => {:reply => 'reply model'} } - assert_equal 'reply model', Reply.human_name - end - - def test_translated_model_names_with_sti_fallback - I18n.backend.store_translations 'en', :activerecord => {:models => {:topic => 'topic model'} } - assert_equal 'topic model', Reply.human_name - end -end - diff --git a/vendor/rails/activerecord/test/cases/inheritance_test.rb b/vendor/rails/activerecord/test/cases/inheritance_test.rb deleted file mode 100644 index eae5a60..0000000 --- a/vendor/rails/activerecord/test/cases/inheritance_test.rb +++ /dev/null @@ -1,262 +0,0 @@ -require "cases/helper" -require 'models/company' -require 'models/project' -require 'models/subscriber' - -class InheritanceTest < ActiveRecord::TestCase - fixtures :companies, :projects, :subscribers, :accounts - - def test_class_with_store_full_sti_class_returns_full_name - old = ActiveRecord::Base.store_full_sti_class - ActiveRecord::Base.store_full_sti_class = true - assert_equal 'Namespaced::Company', Namespaced::Company.sti_name - ensure - ActiveRecord::Base.store_full_sti_class = old - end - - def test_class_without_store_full_sti_class_returns_demodulized_name - old = ActiveRecord::Base.store_full_sti_class - ActiveRecord::Base.store_full_sti_class = false - assert_equal 'Company', Namespaced::Company.sti_name - ensure - ActiveRecord::Base.store_full_sti_class = old - end - - def test_should_store_demodulized_class_name_with_store_full_sti_class_option_disabled - old = ActiveRecord::Base.store_full_sti_class - ActiveRecord::Base.store_full_sti_class = false - item = Namespaced::Company.new - assert_equal 'Company', item[:type] - ensure - ActiveRecord::Base.store_full_sti_class = old - end - - def test_should_store_full_class_name_with_store_full_sti_class_option_enabled - old = ActiveRecord::Base.store_full_sti_class - ActiveRecord::Base.store_full_sti_class = true - item = Namespaced::Company.new - assert_equal 'Namespaced::Company', item[:type] - ensure - ActiveRecord::Base.store_full_sti_class = old - end - - def test_different_namespace_subclass_should_load_correctly_with_store_full_sti_class_option - old = ActiveRecord::Base.store_full_sti_class - ActiveRecord::Base.store_full_sti_class = true - item = Namespaced::Company.create :name => "Wolverine 2" - assert_not_nil Company.find(item.id) - assert_not_nil Namespaced::Company.find(item.id) - ensure - ActiveRecord::Base.store_full_sti_class = old - end - - def test_company_descends_from_active_record - assert_raise(NoMethodError) { ActiveRecord::Base.descends_from_active_record? } - assert AbstractCompany.descends_from_active_record?, 'AbstractCompany should descend from ActiveRecord::Base' - assert Company.descends_from_active_record?, 'Company should descend from ActiveRecord::Base' - assert !Class.new(Company).descends_from_active_record?, 'Company subclass should not descend from ActiveRecord::Base' - end - - def test_a_bad_type_column - #SQLServer need to turn Identity Insert On before manually inserting into the Identity column - if current_adapter?(:SybaseAdapter) - Company.connection.execute "SET IDENTITY_INSERT companies ON" - end - Company.connection.insert "INSERT INTO companies (id, #{QUOTED_TYPE}, name) VALUES(100, 'bad_class!', 'Not happening')" - - #We then need to turn it back Off before continuing. - if current_adapter?(:SybaseAdapter) - Company.connection.execute "SET IDENTITY_INSERT companies OFF" - end - assert_raise(ActiveRecord::SubclassNotFound) { Company.find(100) } - end - - def test_inheritance_find - assert Company.find(1).kind_of?(Firm), "37signals should be a firm" - assert Firm.find(1).kind_of?(Firm), "37signals should be a firm" - assert Company.find(2).kind_of?(Client), "Summit should be a client" - assert Client.find(2).kind_of?(Client), "Summit should be a client" - end - - def test_alt_inheritance_find - switch_to_alt_inheritance_column - test_inheritance_find - switch_to_default_inheritance_column - end - - def test_inheritance_find_all - companies = Company.find(:all, :order => 'id') - assert companies[0].kind_of?(Firm), "37signals should be a firm" - assert companies[1].kind_of?(Client), "Summit should be a client" - end - - def test_alt_inheritance_find_all - switch_to_alt_inheritance_column - test_inheritance_find_all - switch_to_default_inheritance_column - end - - def test_inheritance_save - firm = Firm.new - firm.name = "Next Angle" - firm.save - - next_angle = Company.find(firm.id) - assert next_angle.kind_of?(Firm), "Next Angle should be a firm" - end - - def test_alt_inheritance_save - switch_to_alt_inheritance_column - test_inheritance_save - switch_to_default_inheritance_column - end - - def test_inheritance_condition - assert_equal 9, Company.count - assert_equal 2, Firm.count - assert_equal 3, Client.count - end - - def test_alt_inheritance_condition - switch_to_alt_inheritance_column - test_inheritance_condition - switch_to_default_inheritance_column - end - - def test_finding_incorrect_type_data - assert_raise(ActiveRecord::RecordNotFound) { Firm.find(2) } - assert_nothing_raised { Firm.find(1) } - end - - def test_alt_finding_incorrect_type_data - switch_to_alt_inheritance_column - test_finding_incorrect_type_data - switch_to_default_inheritance_column - end - - def test_update_all_within_inheritance - Client.update_all "name = 'I am a client'" - assert_equal "I am a client", Client.find(:all).first.name - assert_equal "37signals", Firm.find(:all).first.name - end - - def test_alt_update_all_within_inheritance - switch_to_alt_inheritance_column - test_update_all_within_inheritance - switch_to_default_inheritance_column - end - - def test_destroy_all_within_inheritance - Client.destroy_all - assert_equal 0, Client.count - assert_equal 2, Firm.count - end - - def test_alt_destroy_all_within_inheritance - switch_to_alt_inheritance_column - test_destroy_all_within_inheritance - switch_to_default_inheritance_column - end - - def test_find_first_within_inheritance - assert_kind_of Firm, Company.find(:first, :conditions => "name = '37signals'") - assert_kind_of Firm, Firm.find(:first, :conditions => "name = '37signals'") - assert_nil Client.find(:first, :conditions => "name = '37signals'") - end - - def test_alt_find_first_within_inheritance - switch_to_alt_inheritance_column - test_find_first_within_inheritance - switch_to_default_inheritance_column - end - - def test_complex_inheritance - very_special_client = VerySpecialClient.create("name" => "veryspecial") - assert_equal very_special_client, VerySpecialClient.find(:first, :conditions => "name = 'veryspecial'") - assert_equal very_special_client, SpecialClient.find(:first, :conditions => "name = 'veryspecial'") - assert_equal very_special_client, Company.find(:first, :conditions => "name = 'veryspecial'") - assert_equal very_special_client, Client.find(:first, :conditions => "name = 'veryspecial'") - assert_equal 1, Client.find(:all, :conditions => "name = 'Summit'").size - assert_equal very_special_client, Client.find(very_special_client.id) - end - - def test_alt_complex_inheritance - switch_to_alt_inheritance_column - test_complex_inheritance - switch_to_default_inheritance_column - end - - def test_eager_load_belongs_to_something_inherited - account = Account.find(1, :include => :firm) - assert_not_nil account.instance_variable_get("@firm"), "nil proves eager load failed" - end - - def test_eager_load_belongs_to_primary_key_quoting - con = Account.connection - assert_sql(/\(#{con.quote_table_name('companies')}.#{con.quote_column_name('id')} = 1\)/) do - Account.find(1, :include => :firm) - end - end - - def test_alt_eager_loading - switch_to_alt_inheritance_column - test_eager_load_belongs_to_something_inherited - switch_to_default_inheritance_column - end - - def test_inheritance_without_mapping - assert_kind_of SpecialSubscriber, SpecialSubscriber.find("webster132") - assert_nothing_raised { s = SpecialSubscriber.new("name" => "And breaaaaathe!"); s.id = 'roger'; s.save } - end - - private - def switch_to_alt_inheritance_column - # we don't want misleading test results, so get rid of the values in the type column - Company.find(:all, :order => 'id').each do |c| - c['type'] = nil - c.save - end - [ Company, Firm, Client].each { |klass| klass.reset_column_information } - Company.set_inheritance_column('ruby_type') - end - def switch_to_default_inheritance_column - [ Company, Firm, Client].each { |klass| klass.reset_column_information } - Company.set_inheritance_column('type') - end -end - - -class InheritanceComputeTypeTest < ActiveRecord::TestCase - fixtures :companies - - def setup - ActiveSupport::Dependencies.log_activity = true - end - - def teardown - ActiveSupport::Dependencies.log_activity = false - self.class.const_remove :FirmOnTheFly rescue nil - Firm.const_remove :FirmOnTheFly rescue nil - end - - def test_instantiation_doesnt_try_to_require_corresponding_file - foo = Firm.find(:first).clone - foo.ruby_type = foo.type = 'FirmOnTheFly' - foo.save! - - # Should fail without FirmOnTheFly in the type condition. - assert_raise(ActiveRecord::RecordNotFound) { Firm.find(foo.id) } - - # Nest FirmOnTheFly in the test case where Dependencies won't see it. - self.class.const_set :FirmOnTheFly, Class.new(Firm) - assert_raise(ActiveRecord::SubclassNotFound) { Firm.find(foo.id) } - - # Nest FirmOnTheFly in Firm where Dependencies will see it. - # This is analogous to nesting models in a migration. - Firm.const_set :FirmOnTheFly, Class.new(Firm) - - # And instantiate will find the existing constant rather than trying - # to require firm_on_the_fly. - assert_nothing_raised { assert_kind_of Firm::FirmOnTheFly, Firm.find(foo.id) } - end -end diff --git a/vendor/rails/activerecord/test/cases/invalid_date_test.rb b/vendor/rails/activerecord/test/cases/invalid_date_test.rb deleted file mode 100644 index e2bb17c..0000000 --- a/vendor/rails/activerecord/test/cases/invalid_date_test.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'cases/helper' -require 'models/topic' - -class InvalidDateTest < Test::Unit::TestCase - def test_assign_valid_dates - valid_dates = [[2007, 11, 30], [1993, 2, 28], [2008, 2, 29]] - - invalid_dates = [[2007, 11, 31], [1993, 2, 29], [2007, 2, 29]] - - topic = Topic.new - - valid_dates.each do |date_src| - topic = Topic.new("last_read(1i)" => date_src[0].to_s, "last_read(2i)" => date_src[1].to_s, "last_read(3i)" => date_src[2].to_s) - assert_equal(topic.last_read, Date.new(*date_src)) - end - - invalid_dates.each do |date_src| - assert_nothing_raised do - topic = Topic.new({"last_read(1i)" => date_src[0].to_s, "last_read(2i)" => date_src[1].to_s, "last_read(3i)" => date_src[2].to_s}) - assert_equal(topic.last_read, Time.local(*date_src).to_date, "The date should be modified according to the behaviour of the Time object") - end - end - end -end diff --git a/vendor/rails/activerecord/test/cases/json_serialization_test.rb b/vendor/rails/activerecord/test/cases/json_serialization_test.rb deleted file mode 100644 index 975acde..0000000 --- a/vendor/rails/activerecord/test/cases/json_serialization_test.rb +++ /dev/null @@ -1,205 +0,0 @@ -require "cases/helper" -require 'models/contact' -require 'models/post' -require 'models/author' -require 'models/tagging' -require 'models/tag' -require 'models/comment' - -class JsonSerializationTest < ActiveRecord::TestCase - class NamespacedContact < Contact - column :name, :string - end - - def setup - @contact = Contact.new( - :name => 'Konata Izumi', - :age => 16, - :avatar => 'binarydata', - :created_at => Time.utc(2006, 8, 1), - :awesome => true, - :preferences => { :shows => 'anime' } - ) - end - - def test_should_demodulize_root_in_json - NamespacedContact.include_root_in_json = true - @contact = NamespacedContact.new :name => 'whatever' - json = @contact.to_json - assert_match %r{^\{"namespaced_contact": \{}, json - end - - def test_should_include_root_in_json - Contact.include_root_in_json = true - json = @contact.to_json - - assert_match %r{^\{"contact": \{}, json - assert_match %r{"name": "Konata Izumi"}, json - assert_match %r{"age": 16}, json - assert json.include?(%("created_at": #{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) - assert_match %r{"awesome": true}, json - assert_match %r{"preferences": \{"shows": "anime"\}}, json - ensure - Contact.include_root_in_json = false - end - - def test_should_encode_all_encodable_attributes - json = @contact.to_json - - assert_match %r{"name": "Konata Izumi"}, json - assert_match %r{"age": 16}, json - assert json.include?(%("created_at": #{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) - assert_match %r{"awesome": true}, json - assert_match %r{"preferences": \{"shows": "anime"\}}, json - end - - def test_should_allow_attribute_filtering_with_only - json = @contact.to_json(:only => [:name, :age]) - - assert_match %r{"name": "Konata Izumi"}, json - assert_match %r{"age": 16}, json - assert_no_match %r{"awesome": true}, json - assert !json.include?(%("created_at": #{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) - assert_no_match %r{"preferences": \{"shows": "anime"\}}, json - end - - def test_should_allow_attribute_filtering_with_except - json = @contact.to_json(:except => [:name, :age]) - - assert_no_match %r{"name": "Konata Izumi"}, json - assert_no_match %r{"age": 16}, json - assert_match %r{"awesome": true}, json - assert json.include?(%("created_at": #{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) - assert_match %r{"preferences": \{"shows": "anime"\}}, json - end - - def test_methods_are_called_on_object - # Define methods on fixture. - def @contact.label; "Has cheezburger"; end - def @contact.favorite_quote; "Constraints are liberating"; end - - # Single method. - assert_match %r{"label": "Has cheezburger"}, @contact.to_json(:only => :name, :methods => :label) - - # Both methods. - methods_json = @contact.to_json(:only => :name, :methods => [:label, :favorite_quote]) - assert_match %r{"label": "Has cheezburger"}, methods_json - assert_match %r{"favorite_quote": "Constraints are liberating"}, methods_json - end -end - -class DatabaseConnectedJsonEncodingTest < ActiveRecord::TestCase - fixtures :authors, :posts, :comments, :tags, :taggings - - def setup - @david = authors(:david) - @mary = authors(:mary) - end - - def test_includes_uses_association_name - json = @david.to_json(:include => :posts) - - assert_match %r{"posts": \[}, json - - assert_match %r{"id": 1}, json - assert_match %r{"name": "David"}, json - - assert_match %r{"author_id": 1}, json - assert_match %r{"title": "Welcome to the weblog"}, json - assert_match %r{"body": "Such a lovely day"}, json - - assert_match %r{"title": "So I was thinking"}, json - assert_match %r{"body": "Like I hopefully always am"}, json - end - - def test_includes_uses_association_name_and_applies_attribute_filters - json = @david.to_json(:include => { :posts => { :only => :title } }) - - assert_match %r{"name": "David"}, json - assert_match %r{"posts": \[}, json - - assert_match %r{"title": "Welcome to the weblog"}, json - assert_no_match %r{"body": "Such a lovely day"}, json - - assert_match %r{"title": "So I was thinking"}, json - assert_no_match %r{"body": "Like I hopefully always am"}, json - end - - def test_includes_fetches_second_level_associations - json = @david.to_json(:include => { :posts => { :include => { :comments => { :only => :body } } } }) - - assert_match %r{"name": "David"}, json - assert_match %r{"posts": \[}, json - - assert_match %r{"comments": \[}, json - assert_match %r{\{"body": "Thank you again for the welcome"\}}, json - assert_match %r{\{"body": "Don't think too hard"\}}, json - assert_no_match %r{"post_id": }, json - end - - def test_includes_fetches_nth_level_associations - json = @david.to_json( - :include => { - :posts => { - :include => { - :taggings => { - :include => { - :tag => { :only => :name } - } - } - } - } - }) - - assert_match %r{"name": "David"}, json - assert_match %r{"posts": \[}, json - - assert_match %r{"taggings": \[}, json - assert_match %r{"tag": \{"name": "General"\}}, json - end - - def test_should_not_call_methods_on_associations_that_dont_respond - def @david.favorite_quote; "Constraints are liberating"; end - json = @david.to_json(:include => :posts, :methods => :favorite_quote) - - assert !@david.posts.first.respond_to?(:favorite_quote) - assert_match %r{"favorite_quote": "Constraints are liberating"}, json - assert_equal %r{"favorite_quote": }.match(json).size, 1 - end - - def test_should_allow_only_option_for_list_of_authors - authors = [@david, @mary] - - assert_equal %([{"name": "David"}, {"name": "Mary"}]), authors.to_json(:only => :name) - end - - def test_should_allow_except_option_for_list_of_authors - authors = [@david, @mary] - - assert_equal %([{"id": 1}, {"id": 2}]), authors.to_json(:except => [:name, :author_address_id, :author_address_extra_id]) - end - - def test_should_allow_includes_for_list_of_authors - authors = [@david, @mary] - json = authors.to_json( - :only => :name, - :include => { - :posts => { :only => :id } - } - ) - - ['"name": "David"', '"posts": [', '{"id": 1}', '{"id": 2}', '{"id": 4}', - '{"id": 5}', '{"id": 6}', '"name": "Mary"', '"posts": [{"id": 7}]'].each do |fragment| - assert json.include?(fragment), json - end - end - - def test_should_allow_options_for_hash_of_authors - authors_hash = { - 1 => @david, - 2 => @mary - } - - assert_equal %({"1": {"name": "David"}}), authors_hash.to_json(:only => [1, :name]) - end -end diff --git a/vendor/rails/activerecord/test/cases/lifecycle_test.rb b/vendor/rails/activerecord/test/cases/lifecycle_test.rb deleted file mode 100644 index 54fb3d8..0000000 --- a/vendor/rails/activerecord/test/cases/lifecycle_test.rb +++ /dev/null @@ -1,193 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/developer' -require 'models/reply' -require 'models/minimalistic' - -class Topic; def after_find() end end -class Developer; def after_find() end end -class SpecialDeveloper < Developer; end - -class TopicManualObserver - include Singleton - - attr_reader :action, :object, :callbacks - - def initialize - Topic.add_observer(self) - @callbacks = [] - end - - def update(callback_method, object) - @callbacks << { "callback_method" => callback_method, "object" => object } - end - - def has_been_notified? - !@callbacks.empty? - end -end - -class TopicaAuditor < ActiveRecord::Observer - observe :topic - - attr_reader :topic - - def after_find(topic) - @topic = topic - end -end - -class TopicObserver < ActiveRecord::Observer - attr_reader :topic - - def after_find(topic) - @topic = topic - end -end - -class MinimalisticObserver < ActiveRecord::Observer - attr_reader :minimalistic - - def after_find(minimalistic) - @minimalistic = minimalistic - end -end - -class MultiObserver < ActiveRecord::Observer - attr_reader :record - - def self.observed_class() [ Topic, Developer ] end - - cattr_reader :last_inherited - @@last_inherited = nil - - def observed_class_inherited_with_testing(subclass) - observed_class_inherited_without_testing(subclass) - @@last_inherited = subclass - end - - alias_method_chain :observed_class_inherited, :testing - - def after_find(record) - @record = record - end -end - -class LifecycleTest < ActiveRecord::TestCase - fixtures :topics, :developers, :minimalistics - - def test_before_destroy - original_count = Topic.count - (topic_to_be_destroyed = Topic.find(1)).destroy - assert_equal original_count - (1 + topic_to_be_destroyed.replies.size), Topic.count - end - - def test_after_save - ActiveRecord::Base.observers = :topic_manual_observer - ActiveRecord::Base.instantiate_observers - - topic = Topic.find(1) - topic.title = "hello" - topic.save - - assert TopicManualObserver.instance.has_been_notified? - assert_equal :after_save, TopicManualObserver.instance.callbacks.last["callback_method"] - end - - def test_observer_update_on_save - ActiveRecord::Base.observers = TopicManualObserver - ActiveRecord::Base.instantiate_observers - - topic = Topic.find(1) - assert TopicManualObserver.instance.has_been_notified? - assert_equal :after_find, TopicManualObserver.instance.callbacks.first["callback_method"] - end - - def test_auto_observer - topic_observer = TopicaAuditor.instance - assert_nil TopicaAuditor.observed_class - assert_equal [Topic], TopicaAuditor.instance.observed_classes.to_a - - topic = Topic.find(1) - assert_equal topic.title, topic_observer.topic.title - end - - def test_inferred_auto_observer - topic_observer = TopicObserver.instance - assert_equal Topic, TopicObserver.observed_class - - topic = Topic.find(1) - assert_equal topic.title, topic_observer.topic.title - end - - def test_observing_two_classes - multi_observer = MultiObserver.instance - - topic = Topic.find(1) - assert_equal topic.title, multi_observer.record.title - - developer = Developer.find(1) - assert_equal developer.name, multi_observer.record.name - end - - def test_observing_subclasses - multi_observer = MultiObserver.instance - - developer = SpecialDeveloper.find(1) - assert_equal developer.name, multi_observer.record.name - - klass = Class.new(Developer) - assert_equal klass, multi_observer.last_inherited - - developer = klass.find(1) - assert_equal developer.name, multi_observer.record.name - end - - def test_after_find_can_be_observed_when_its_not_defined_on_the_model - observer = MinimalisticObserver.instance - assert_equal Minimalistic, MinimalisticObserver.observed_class - - minimalistic = Minimalistic.find(1) - assert_equal minimalistic, observer.minimalistic - end - - def test_after_find_can_be_observed_when_its_defined_on_the_model - observer = TopicObserver.instance - assert_equal Topic, TopicObserver.observed_class - - topic = Topic.find(1) - assert_equal topic, observer.topic - end - - def test_after_find_is_not_created_if_its_not_used - # use a fresh class so an observer can't have defined an - # after_find on it - model_class = Class.new(ActiveRecord::Base) - observer_class = Class.new(ActiveRecord::Observer) - observer_class.observe(model_class) - - observer = observer_class.instance - - assert !model_class.method_defined?(:after_find) - end - - def test_after_find_is_not_clobbered_if_it_already_exists - # use a fresh observer class so we can instantiate it (Observer is - # a Singleton) - model_class = Class.new(ActiveRecord::Base) do - def after_find; end - end - original_method = model_class.instance_method(:after_find) - observer_class = Class.new(ActiveRecord::Observer) do - def after_find; end - end - observer_class.observe(model_class) - - observer = observer_class.instance - assert_equal original_method, model_class.instance_method(:after_find) - end - - def test_invalid_observer - assert_raise(ArgumentError) { Topic.observers = Object.new; Topic.instantiate_observers } - end -end diff --git a/vendor/rails/activerecord/test/cases/locking_test.rb b/vendor/rails/activerecord/test/cases/locking_test.rb deleted file mode 100644 index e177235..0000000 --- a/vendor/rails/activerecord/test/cases/locking_test.rb +++ /dev/null @@ -1,322 +0,0 @@ -require "cases/helper" -require 'models/person' -require 'models/reader' -require 'models/legacy_thing' -require 'models/reference' - -class LockWithoutDefault < ActiveRecord::Base; end - -class LockWithCustomColumnWithoutDefault < ActiveRecord::Base - set_table_name :lock_without_defaults_cust - set_locking_column :custom_lock_version -end - -class ReadonlyFirstNamePerson < Person - attr_readonly :first_name -end - -class OptimisticLockingTest < ActiveRecord::TestCase - fixtures :people, :legacy_things, :references - - # need to disable transactional fixtures, because otherwise the sqlite3 - # adapter (at least) chokes when we try and change the schema in the middle - # of a test (see test_increment_counter_*). - self.use_transactional_fixtures = false - - def test_lock_existing - p1 = Person.find(1) - p2 = Person.find(1) - assert_equal 0, p1.lock_version - assert_equal 0, p2.lock_version - - p1.first_name = 'stu' - p1.save! - assert_equal 1, p1.lock_version - assert_equal 0, p2.lock_version - - p2.first_name = 'sue' - assert_raise(ActiveRecord::StaleObjectError) { p2.save! } - end - - def test_lock_destroy - p1 = Person.find(1) - p2 = Person.find(1) - assert_equal 0, p1.lock_version - assert_equal 0, p2.lock_version - - p1.first_name = 'stu' - p1.save! - assert_equal 1, p1.lock_version - assert_equal 0, p2.lock_version - - assert_raises(ActiveRecord::StaleObjectError) { p2.destroy } - - assert p1.destroy - assert_equal true, p1.frozen? - assert_raises(ActiveRecord::RecordNotFound) { Person.find(1) } - end - - def test_lock_repeating - p1 = Person.find(1) - p2 = Person.find(1) - assert_equal 0, p1.lock_version - assert_equal 0, p2.lock_version - - p1.first_name = 'stu' - p1.save! - assert_equal 1, p1.lock_version - assert_equal 0, p2.lock_version - - p2.first_name = 'sue' - assert_raise(ActiveRecord::StaleObjectError) { p2.save! } - p2.first_name = 'sue2' - assert_raise(ActiveRecord::StaleObjectError) { p2.save! } - end - - def test_lock_new - p1 = Person.new(:first_name => 'anika') - assert_equal 0, p1.lock_version - - p1.first_name = 'anika2' - p1.save! - p2 = Person.find(p1.id) - assert_equal 0, p1.lock_version - assert_equal 0, p2.lock_version - - p1.first_name = 'anika3' - p1.save! - assert_equal 1, p1.lock_version - assert_equal 0, p2.lock_version - - p2.first_name = 'sue' - assert_raise(ActiveRecord::StaleObjectError) { p2.save! } - end - - def test_lock_new_with_nil - p1 = Person.new(:first_name => 'anika') - p1.save! - p1.lock_version = nil # simulate bad fixture or column with no default - p1.save! - assert_equal 1, p1.lock_version - end - - - def test_lock_column_name_existing - t1 = LegacyThing.find(1) - t2 = LegacyThing.find(1) - assert_equal 0, t1.version - assert_equal 0, t2.version - - t1.tps_report_number = 700 - t1.save! - assert_equal 1, t1.version - assert_equal 0, t2.version - - t2.tps_report_number = 800 - assert_raise(ActiveRecord::StaleObjectError) { t2.save! } - end - - def test_lock_column_is_mass_assignable - p1 = Person.create(:first_name => 'bianca') - assert_equal 0, p1.lock_version - assert_equal p1.lock_version, Person.new(p1.attributes).lock_version - - p1.first_name = 'bianca2' - p1.save! - assert_equal 1, p1.lock_version - assert_equal p1.lock_version, Person.new(p1.attributes).lock_version - end - - def test_lock_without_default_sets_version_to_zero - t1 = LockWithoutDefault.new - assert_equal 0, t1.lock_version - end - - def test_lock_with_custom_column_without_default_sets_version_to_zero - t1 = LockWithCustomColumnWithoutDefault.new - assert_equal 0, t1.custom_lock_version - end - - def test_readonly_attributes - assert_equal Set.new([ 'first_name' ]), ReadonlyFirstNamePerson.readonly_attributes - - p = ReadonlyFirstNamePerson.create(:first_name => "unchangeable name") - p.reload - assert_equal "unchangeable name", p.first_name - - p.update_attributes(:first_name => "changed name") - p.reload - assert_equal "unchangeable name", p.first_name - end - - { :lock_version => Person, :custom_lock_version => LegacyThing }.each do |name, model| - define_method("test_increment_counter_updates_#{name}") do - counter_test model, 1 do |id| - model.increment_counter :test_count, id - end - end - - define_method("test_decrement_counter_updates_#{name}") do - counter_test model, -1 do |id| - model.decrement_counter :test_count, id - end - end - - define_method("test_update_counters_updates_#{name}") do - counter_test model, 1 do |id| - model.update_counters id, :test_count => 1 - end - end - end - - def test_quote_table_name - ref = references(:michael_magician) - ref.favourite = !ref.favourite - assert ref.save - end - - # Useful for partial updates, don't only update the lock_version if there - # is nothing else being updated. - def test_update_without_attributes_does_not_only_update_lock_version - assert_nothing_raised do - p1 = Person.new(:first_name => 'anika') - p1.send(:update_with_lock, []) - end - end - - private - - def add_counter_column_to(model) - model.connection.add_column model.table_name, :test_count, :integer, :null => false, :default => 0 - model.reset_column_information - # OpenBase does not set a value to existing rows when adding a not null default column - model.update_all(:test_count => 0) if current_adapter?(:OpenBaseAdapter) - end - - def remove_counter_column_from(model) - model.connection.remove_column model.table_name, :test_count - model.reset_column_information - end - - def counter_test(model, expected_count) - add_counter_column_to(model) - object = model.find(:first) - assert_equal 0, object.test_count - assert_equal 0, object.send(model.locking_column) - yield object.id - object.reload - assert_equal expected_count, object.test_count - assert_equal 1, object.send(model.locking_column) - ensure - remove_counter_column_from(model) - end -end - - -# TODO: test against the generated SQL since testing locking behavior itself -# is so cumbersome. Will deadlock Ruby threads if the underlying db.execute -# blocks, so separate script called by Kernel#system is needed. -# (See exec vs. async_exec in the PostgreSQL adapter.) - -# TODO: The Sybase, and OpenBase adapters currently have no support for pessimistic locking - -unless current_adapter?(:SybaseAdapter, :OpenBaseAdapter) - class PessimisticLockingTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - fixtures :people, :readers - - def setup - # Avoid introspection queries during tests. - Person.columns; Reader.columns - end - - # Test typical find. - def test_sane_find_with_lock - assert_nothing_raised do - Person.transaction do - Person.find 1, :lock => true - end - end - end - - # Test scoped lock. - def test_sane_find_with_scoped_lock - assert_nothing_raised do - Person.transaction do - Person.with_scope(:find => { :lock => true }) do - Person.find 1 - end - end - end - end - - # PostgreSQL protests SELECT ... FOR UPDATE on an outer join. - unless current_adapter?(:PostgreSQLAdapter) - # Test locked eager find. - def test_eager_find_with_lock - assert_nothing_raised do - Person.transaction do - Person.find 1, :include => :readers, :lock => true - end - end - end - end - - # Locking a record reloads it. - def test_sane_lock_method - assert_nothing_raised do - Person.transaction do - person = Person.find 1 - old, person.first_name = person.first_name, 'fooman' - person.lock! - assert_equal old, person.first_name - end - end - end - - if current_adapter?(:PostgreSQLAdapter, :OracleAdapter) - use_concurrent_connections - - def test_no_locks_no_wait - first, second = duel { Person.find 1 } - assert first.end > second.end - end - - def test_second_lock_waits - assert [0.2, 1, 5].any? { |zzz| - first, second = duel(zzz) { Person.find 1, :lock => true } - second.end > first.end - } - end - - protected - def duel(zzz = 5) - t0, t1, t2, t3 = nil, nil, nil, nil - - a = Thread.new do - t0 = Time.now - Person.transaction do - yield - sleep zzz # block thread 2 for zzz seconds - end - t1 = Time.now - end - - b = Thread.new do - sleep zzz / 2.0 # ensure thread 1 tx starts first - t2 = Time.now - Person.transaction { yield } - t3 = Time.now - end - - a.join - b.join - - assert t1 > t0 + zzz - assert t2 > t0 - assert t3 > t2 - [t0.to_f..t1.to_f, t2.to_f..t3.to_f] - end - end - end -end diff --git a/vendor/rails/activerecord/test/cases/method_scoping_test.rb b/vendor/rails/activerecord/test/cases/method_scoping_test.rb deleted file mode 100644 index 3c34cde..0000000 --- a/vendor/rails/activerecord/test/cases/method_scoping_test.rb +++ /dev/null @@ -1,694 +0,0 @@ -require "cases/helper" -require 'models/author' -require 'models/developer' -require 'models/project' -require 'models/comment' -require 'models/post' -require 'models/category' - -class MethodScopingTest < ActiveRecord::TestCase - fixtures :authors, :developers, :projects, :comments, :posts, :developers_projects - - def test_set_conditions - Developer.with_scope(:find => { :conditions => 'just a test...' }) do - assert_equal 'just a test...', Developer.send(:current_scoped_methods)[:find][:conditions] - end - end - - def test_scoped_find - Developer.with_scope(:find => { :conditions => "name = 'David'" }) do - assert_nothing_raised { Developer.find(1) } - end - end - - def test_scoped_find_first - Developer.with_scope(:find => { :conditions => "salary = 100000" }) do - assert_equal Developer.find(10), Developer.find(:first, :order => 'name') - end - end - - def test_scoped_find_last - highest_salary = Developer.find(:first, :order => "salary DESC") - - Developer.with_scope(:find => { :order => "salary" }) do - assert_equal highest_salary, Developer.last - end - end - - def test_scoped_find_last_preserves_scope - lowest_salary = Developer.find(:first, :order => "salary ASC") - highest_salary = Developer.find(:first, :order => "salary DESC") - - Developer.with_scope(:find => { :order => "salary" }) do - assert_equal highest_salary, Developer.last - assert_equal lowest_salary, Developer.first - end - end - - def test_scoped_find_combines_conditions - Developer.with_scope(:find => { :conditions => "salary = 9000" }) do - assert_equal developers(:poor_jamis), Developer.find(:first, :conditions => "name = 'Jamis'") - end - end - - def test_scoped_find_sanitizes_conditions - Developer.with_scope(:find => { :conditions => ['salary = ?', 9000] }) do - assert_equal developers(:poor_jamis), Developer.find(:first) - end - end - - def test_scoped_find_combines_and_sanitizes_conditions - Developer.with_scope(:find => { :conditions => ['salary = ?', 9000] }) do - assert_equal developers(:poor_jamis), Developer.find(:first, :conditions => ['name = ?', 'Jamis']) - end - end - - def test_scoped_find_all - Developer.with_scope(:find => { :conditions => "name = 'David'" }) do - assert_equal [developers(:david)], Developer.find(:all) - end - end - - def test_scoped_find_select - Developer.with_scope(:find => { :select => "id, name" }) do - developer = Developer.find(:first, :conditions => "name = 'David'") - assert_equal "David", developer.name - assert !developer.has_attribute?(:salary) - end - end - - def test_options_select_replaces_scope_select - Developer.with_scope(:find => { :select => "id, name" }) do - developer = Developer.find(:first, :select => 'id, salary', :conditions => "name = 'David'") - assert_equal 80000, developer.salary - assert !developer.has_attribute?(:name) - end - end - - def test_scoped_count - Developer.with_scope(:find => { :conditions => "name = 'David'" }) do - assert_equal 1, Developer.count - end - - Developer.with_scope(:find => { :conditions => 'salary = 100000' }) do - assert_equal 8, Developer.count - assert_equal 1, Developer.count(:conditions => "name LIKE 'fixture_1%'") - end - end - - def test_scoped_find_include - # with the include, will retrieve only developers for the given project - scoped_developers = Developer.with_scope(:find => { :include => :projects }) do - Developer.find(:all, :conditions => 'projects.id = 2') - end - assert scoped_developers.include?(developers(:david)) - assert !scoped_developers.include?(developers(:jamis)) - assert_equal 1, scoped_developers.size - end - - def test_scoped_find_joins - scoped_developers = Developer.with_scope(:find => { :joins => 'JOIN developers_projects ON id = developer_id' } ) do - Developer.find(:all, :conditions => 'developers_projects.project_id = 2') - end - assert scoped_developers.include?(developers(:david)) - assert !scoped_developers.include?(developers(:jamis)) - assert_equal 1, scoped_developers.size - assert_equal developers(:david).attributes, scoped_developers.first.attributes - end - - def test_scoped_find_using_new_style_joins - scoped_developers = Developer.with_scope(:find => { :joins => :projects }) do - Developer.find(:all, :conditions => 'projects.id = 2') - end - assert scoped_developers.include?(developers(:david)) - assert !scoped_developers.include?(developers(:jamis)) - assert_equal 1, scoped_developers.size - assert_equal developers(:david).attributes, scoped_developers.first.attributes - end - - def test_scoped_find_merges_old_style_joins - scoped_authors = Author.with_scope(:find => { :joins => 'INNER JOIN posts ON authors.id = posts.author_id ' }) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => 'INNER JOIN comments ON posts.id = comments.post_id', :conditions => 'comments.id = 1') - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_scoped_find_merges_new_style_joins - scoped_authors = Author.with_scope(:find => { :joins => :posts }) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => :comments, :conditions => 'comments.id = 1') - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_scoped_find_merges_new_and_old_style_joins - scoped_authors = Author.with_scope(:find => { :joins => :posts }) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => 'JOIN comments ON posts.id = comments.post_id', :conditions => 'comments.id = 1') - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_scoped_find_merges_string_array_style_and_string_style_joins - scoped_authors = Author.with_scope(:find => { :joins => ["INNER JOIN posts ON posts.author_id = authors.id"]}) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => 'INNER JOIN comments ON posts.id = comments.post_id', :conditions => 'comments.id = 1') - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_scoped_find_merges_string_array_style_and_hash_style_joins - scoped_authors = Author.with_scope(:find => { :joins => :posts}) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => ['INNER JOIN comments ON posts.id = comments.post_id'], :conditions => 'comments.id = 1') - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_scoped_find_merges_joins_and_eliminates_duplicate_string_joins - scoped_authors = Author.with_scope(:find => { :joins => 'INNER JOIN posts ON posts.author_id = authors.id'}) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => ["INNER JOIN posts ON posts.author_id = authors.id", "INNER JOIN comments ON posts.id = comments.post_id"], :conditions => 'comments.id = 1') - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_scoped_find_strips_spaces_from_string_joins_and_eliminates_duplicate_string_joins - scoped_authors = Author.with_scope(:find => { :joins => ' INNER JOIN posts ON posts.author_id = authors.id '}) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => ['INNER JOIN posts ON posts.author_id = authors.id'], :conditions => 'posts.id = 1') - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_scoped_count_include - # with the include, will retrieve only developers for the given project - Developer.with_scope(:find => { :include => :projects }) do - assert_equal 1, Developer.count(:conditions => 'projects.id = 2') - end - end - - def test_scoped_create - new_comment = nil - - VerySpecialComment.with_scope(:create => { :post_id => 1 }) do - assert_equal({ :post_id => 1 }, VerySpecialComment.send(:current_scoped_methods)[:create]) - new_comment = VerySpecialComment.create :body => "Wonderful world" - end - - assert Post.find(1).comments.include?(new_comment) - end - - def test_immutable_scope - options = { :conditions => "name = 'David'" } - Developer.with_scope(:find => options) do - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - options[:conditions] = "name != 'David'" - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - end - - scope = { :find => { :conditions => "name = 'David'" }} - Developer.with_scope(scope) do - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - scope[:find][:conditions] = "name != 'David'" - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - end - end - - def test_scoped_with_duck_typing - scoping = Struct.new(:method_scoping).new(:find => { :conditions => ["name = ?", 'David'] }) - Developer.with_scope(scoping) do - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - end - end - - def test_ensure_that_method_scoping_is_correctly_restored - scoped_methods = Developer.instance_eval('current_scoped_methods') - - begin - Developer.with_scope(:find => { :conditions => "name = 'Jamis'" }) do - raise "an exception" - end - rescue - end - assert_equal scoped_methods, Developer.instance_eval('current_scoped_methods') - end -end - -class NestedScopingTest < ActiveRecord::TestCase - fixtures :authors, :developers, :projects, :comments, :posts - - def test_merge_options - Developer.with_scope(:find => { :conditions => 'salary = 80000' }) do - Developer.with_scope(:find => { :limit => 10 }) do - merged_option = Developer.instance_eval('current_scoped_methods')[:find] - assert_equal({ :conditions => 'salary = 80000', :limit => 10 }, merged_option) - end - end - end - - def test_merge_inner_scope_has_priority - Developer.with_scope(:find => { :limit => 5 }) do - Developer.with_scope(:find => { :limit => 10 }) do - merged_option = Developer.instance_eval('current_scoped_methods')[:find] - assert_equal({ :limit => 10 }, merged_option) - end - end - end - - def test_replace_options - Developer.with_scope(:find => { :conditions => "name = 'David'" }) do - Developer.with_exclusive_scope(:find => { :conditions => "name = 'Jamis'" }) do - assert_equal({:find => { :conditions => "name = 'Jamis'" }}, Developer.instance_eval('current_scoped_methods')) - assert_equal({:find => { :conditions => "name = 'Jamis'" }}, Developer.send(:scoped_methods)[-1]) - end - end - end - - def test_append_conditions - Developer.with_scope(:find => { :conditions => "name = 'David'" }) do - Developer.with_scope(:find => { :conditions => 'salary = 80000' }) do - appended_condition = Developer.instance_eval('current_scoped_methods')[:find][:conditions] - assert_equal("(name = 'David') AND (salary = 80000)", appended_condition) - assert_equal(1, Developer.count) - end - Developer.with_scope(:find => { :conditions => "name = 'Maiha'" }) do - assert_equal(0, Developer.count) - end - end - end - - def test_merge_and_append_options - Developer.with_scope(:find => { :conditions => 'salary = 80000', :limit => 10 }) do - Developer.with_scope(:find => { :conditions => "name = 'David'" }) do - merged_option = Developer.instance_eval('current_scoped_methods')[:find] - assert_equal({ :conditions => "(salary = 80000) AND (name = 'David')", :limit => 10 }, merged_option) - end - end - end - - def test_nested_scoped_find - Developer.with_scope(:find => { :conditions => "name = 'Jamis'" }) do - Developer.with_exclusive_scope(:find => { :conditions => "name = 'David'" }) do - assert_nothing_raised { Developer.find(1) } - assert_equal('David', Developer.find(:first).name) - end - assert_equal('Jamis', Developer.find(:first).name) - end - end - - def test_nested_scoped_find_include - Developer.with_scope(:find => { :include => :projects }) do - Developer.with_scope(:find => { :conditions => "projects.id = 2" }) do - assert_nothing_raised { Developer.find(1) } - assert_equal('David', Developer.find(:first).name) - end - end - end - - def test_nested_scoped_find_merged_include - # :include's remain unique and don't "double up" when merging - Developer.with_scope(:find => { :include => :projects, :conditions => "projects.id = 2" }) do - Developer.with_scope(:find => { :include => :projects }) do - assert_equal 1, Developer.instance_eval('current_scoped_methods')[:find][:include].length - assert_equal('David', Developer.find(:first).name) - end - end - - # the nested scope doesn't remove the first :include - Developer.with_scope(:find => { :include => :projects, :conditions => "projects.id = 2" }) do - Developer.with_scope(:find => { :include => [] }) do - assert_equal 1, Developer.instance_eval('current_scoped_methods')[:find][:include].length - assert_equal('David', Developer.find(:first).name) - end - end - - # mixing array and symbol include's will merge correctly - Developer.with_scope(:find => { :include => [:projects], :conditions => "projects.id = 2" }) do - Developer.with_scope(:find => { :include => :projects }) do - assert_equal 1, Developer.instance_eval('current_scoped_methods')[:find][:include].length - assert_equal('David', Developer.find(:first).name) - end - end - end - - def test_nested_scoped_find_replace_include - Developer.with_scope(:find => { :include => :projects }) do - Developer.with_exclusive_scope(:find => { :include => [] }) do - assert_equal 0, Developer.instance_eval('current_scoped_methods')[:find][:include].length - end - end - end - - def test_three_level_nested_exclusive_scoped_find - Developer.with_scope(:find => { :conditions => "name = 'Jamis'" }) do - assert_equal('Jamis', Developer.find(:first).name) - - Developer.with_exclusive_scope(:find => { :conditions => "name = 'David'" }) do - assert_equal('David', Developer.find(:first).name) - - Developer.with_exclusive_scope(:find => { :conditions => "name = 'Maiha'" }) do - assert_equal(nil, Developer.find(:first)) - end - - # ensure that scoping is restored - assert_equal('David', Developer.find(:first).name) - end - - # ensure that scoping is restored - assert_equal('Jamis', Developer.find(:first).name) - end - end - - def test_merged_scoped_find - poor_jamis = developers(:poor_jamis) - Developer.with_scope(:find => { :conditions => "salary < 100000" }) do - Developer.with_scope(:find => { :offset => 1, :order => 'id asc' }) do - assert_sql /ORDER BY id asc / do - assert_equal(poor_jamis, Developer.find(:first, :order => 'id asc')) - end - end - end - end - - def test_merged_scoped_find_sanitizes_conditions - Developer.with_scope(:find => { :conditions => ["name = ?", 'David'] }) do - Developer.with_scope(:find => { :conditions => ['salary = ?', 9000] }) do - assert_raise(ActiveRecord::RecordNotFound) { developers(:poor_jamis) } - end - end - end - - def test_nested_scoped_find_combines_and_sanitizes_conditions - Developer.with_scope(:find => { :conditions => ["name = ?", 'David'] }) do - Developer.with_exclusive_scope(:find => { :conditions => ['salary = ?', 9000] }) do - assert_equal developers(:poor_jamis), Developer.find(:first) - assert_equal developers(:poor_jamis), Developer.find(:first, :conditions => ['name = ?', 'Jamis']) - end - end - end - - def test_merged_scoped_find_combines_and_sanitizes_conditions - Developer.with_scope(:find => { :conditions => ["name = ?", 'David'] }) do - Developer.with_scope(:find => { :conditions => ['salary > ?', 9000] }) do - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - end - end - end - - def test_nested_scoped_create - comment = nil - Comment.with_scope(:create => { :post_id => 1}) do - Comment.with_scope(:create => { :post_id => 2}) do - assert_equal({ :post_id => 2 }, Comment.send(:current_scoped_methods)[:create]) - comment = Comment.create :body => "Hey guys, nested scopes are broken. Please fix!" - end - end - assert_equal 2, comment.post_id - end - - def test_nested_exclusive_scope_for_create - comment = nil - Comment.with_scope(:create => { :body => "Hey guys, nested scopes are broken. Please fix!" }) do - Comment.with_exclusive_scope(:create => { :post_id => 1 }) do - assert_equal({ :post_id => 1 }, Comment.send(:current_scoped_methods)[:create]) - comment = Comment.create :body => "Hey guys" - end - end - assert_equal 1, comment.post_id - assert_equal 'Hey guys', comment.body - end - - def test_merged_scoped_find_on_blank_conditions - [nil, " ", [], {}].each do |blank| - Developer.with_scope(:find => {:conditions => blank}) do - Developer.with_scope(:find => {:conditions => blank}) do - assert_nothing_raised { Developer.find(:first) } - end - end - end - end - - def test_merged_scoped_find_on_blank_bind_conditions - [ [""], ["",{}] ].each do |blank| - Developer.with_scope(:find => {:conditions => blank}) do - Developer.with_scope(:find => {:conditions => blank}) do - assert_nothing_raised { Developer.find(:first) } - end - end - end - end - - def test_immutable_nested_scope - options1 = { :conditions => "name = 'Jamis'" } - options2 = { :conditions => "name = 'David'" } - Developer.with_scope(:find => options1) do - Developer.with_exclusive_scope(:find => options2) do - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - options1[:conditions] = options2[:conditions] = nil - assert_equal %w(David), Developer.find(:all).map { |d| d.name } - end - end - end - - def test_immutable_merged_scope - options1 = { :conditions => "name = 'Jamis'" } - options2 = { :conditions => "salary > 10000" } - Developer.with_scope(:find => options1) do - Developer.with_scope(:find => options2) do - assert_equal %w(Jamis), Developer.find(:all).map { |d| d.name } - options1[:conditions] = options2[:conditions] = nil - assert_equal %w(Jamis), Developer.find(:all).map { |d| d.name } - end - end - end - - def test_ensure_that_method_scoping_is_correctly_restored - Developer.with_scope(:find => { :conditions => "name = 'David'" }) do - scoped_methods = Developer.instance_eval('current_scoped_methods') - begin - Developer.with_scope(:find => { :conditions => "name = 'Maiha'" }) do - raise "an exception" - end - rescue - end - assert_equal scoped_methods, Developer.instance_eval('current_scoped_methods') - end - end - - def test_nested_scoped_find_merges_old_style_joins - scoped_authors = Author.with_scope(:find => { :joins => 'INNER JOIN posts ON authors.id = posts.author_id' }) do - Author.with_scope(:find => { :joins => 'INNER JOIN comments ON posts.id = comments.post_id' }) do - Author.find(:all, :select => 'DISTINCT authors.*', :conditions => 'comments.id = 1') - end - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_nested_scoped_find_merges_new_style_joins - scoped_authors = Author.with_scope(:find => { :joins => :posts }) do - Author.with_scope(:find => { :joins => :comments }) do - Author.find(:all, :select => 'DISTINCT authors.*', :conditions => 'comments.id = 1') - end - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end - - def test_nested_scoped_find_merges_new_and_old_style_joins - scoped_authors = Author.with_scope(:find => { :joins => :posts }) do - Author.with_scope(:find => { :joins => 'INNER JOIN comments ON posts.id = comments.post_id' }) do - Author.find(:all, :select => 'DISTINCT authors.*', :joins => '', :conditions => 'comments.id = 1') - end - end - assert scoped_authors.include?(authors(:david)) - assert !scoped_authors.include?(authors(:mary)) - assert_equal 1, scoped_authors.size - assert_equal authors(:david).attributes, scoped_authors.first.attributes - end -end - -class HasManyScopingTest< ActiveRecord::TestCase - fixtures :comments, :posts - - def setup - @welcome = Post.find(1) - end - - def test_forwarding_of_static_methods - assert_equal 'a comment...', Comment.what_are_you - assert_equal 'a comment...', @welcome.comments.what_are_you - end - - def test_forwarding_to_scoped - assert_equal 4, Comment.search_by_type('Comment').size - assert_equal 2, @welcome.comments.search_by_type('Comment').size - end - - def test_forwarding_to_dynamic_finders - assert_equal 4, Comment.find_all_by_type('Comment').size - assert_equal 2, @welcome.comments.find_all_by_type('Comment').size - end - - def test_nested_scope - Comment.with_scope(:find => { :conditions => '1=1' }) do - assert_equal 'a comment...', @welcome.comments.what_are_you - end - end -end - -class HasAndBelongsToManyScopingTest< ActiveRecord::TestCase - fixtures :posts, :categories, :categories_posts - - def setup - @welcome = Post.find(1) - end - - def test_forwarding_of_static_methods - assert_equal 'a category...', Category.what_are_you - assert_equal 'a category...', @welcome.categories.what_are_you - end - - def test_forwarding_to_dynamic_finders - assert_equal 4, Category.find_all_by_type('SpecialCategory').size - assert_equal 0, @welcome.categories.find_all_by_type('SpecialCategory').size - assert_equal 2, @welcome.categories.find_all_by_type('Category').size - end - - def test_nested_scope - Category.with_scope(:find => { :conditions => '1=1' }) do - assert_equal 'a comment...', @welcome.comments.what_are_you - end - end -end - -class DefaultScopingTest < ActiveRecord::TestCase - fixtures :developers - - def test_default_scope - expected = Developer.find(:all, :order => 'salary DESC').collect { |dev| dev.salary } - received = DeveloperOrderedBySalary.find(:all).collect { |dev| dev.salary } - assert_equal expected, received - end - - def test_default_scoping_with_threads - scope = [{ :create => {}, :find => { :order => 'salary DESC' } }] - - 2.times do - Thread.new { assert_equal scope, DeveloperOrderedBySalary.send(:scoped_methods) }.join - end - end - - def test_default_scoping_with_inheritance - scope = [{ :create => {}, :find => { :order => 'salary DESC' } }] - - # Inherit a class having a default scope and define a new default scope - klass = Class.new(DeveloperOrderedBySalary) - klass.send :default_scope, {} - - # Scopes added on children should append to parent scope - expected_klass_scope = [{ :create => {}, :find => { :order => 'salary DESC' }}, { :create => {}, :find => {} }] - assert_equal expected_klass_scope, klass.send(:scoped_methods) - - # Parent should still have the original scope - assert_equal scope, DeveloperOrderedBySalary.send(:scoped_methods) - end - - def test_method_scope - expected = Developer.find(:all, :order => 'name DESC').collect { |dev| dev.salary } - received = DeveloperOrderedBySalary.all_ordered_by_name.collect { |dev| dev.salary } - assert_equal expected, received - end - - def test_nested_scope - expected = Developer.find(:all, :order => 'name DESC').collect { |dev| dev.salary } - received = DeveloperOrderedBySalary.with_scope(:find => { :order => 'name DESC'}) do - DeveloperOrderedBySalary.find(:all).collect { |dev| dev.salary } - end - assert_equal expected, received - end - - def test_named_scope - expected = Developer.find(:all, :order => 'salary DESC, name DESC').collect { |dev| dev.salary } - received = DeveloperOrderedBySalary.by_name.find(:all).collect { |dev| dev.salary } - assert_equal expected, received - end - - def test_nested_exclusive_scope - expected = Developer.find(:all, :limit => 100).collect { |dev| dev.salary } - received = DeveloperOrderedBySalary.with_exclusive_scope(:find => { :limit => 100 }) do - DeveloperOrderedBySalary.find(:all).collect { |dev| dev.salary } - end - assert_equal expected, received - end - - def test_overwriting_default_scope - expected = Developer.find(:all, :order => 'salary').collect { |dev| dev.salary } - received = DeveloperOrderedBySalary.find(:all, :order => 'salary').collect { |dev| dev.salary } - assert_equal expected, received - end -end - -=begin -# We disabled the scoping for has_one and belongs_to as we can't think of a proper use case - -class BelongsToScopingTest< ActiveRecord::TestCase - fixtures :comments, :posts - - def setup - @greetings = Comment.find(1) - end - - def test_forwarding_of_static_method - assert_equal 'a post...', Post.what_are_you - assert_equal 'a post...', @greetings.post.what_are_you - end - - def test_forwarding_to_dynamic_finders - assert_equal 4, Post.find_all_by_type('Post').size - assert_equal 1, @greetings.post.find_all_by_type('Post').size - end - -end - -class HasOneScopingTest< ActiveRecord::TestCase - fixtures :comments, :posts - - def setup - @sti_comments = Post.find(4) - end - - def test_forwarding_of_static_methods - assert_equal 'a comment...', Comment.what_are_you - assert_equal 'a very special comment...', @sti_comments.very_special_comment.what_are_you - end - - def test_forwarding_to_dynamic_finders - assert_equal 1, Comment.find_all_by_type('VerySpecialComment').size - assert_equal 1, @sti_comments.very_special_comment.find_all_by_type('VerySpecialComment').size - assert_equal 0, @sti_comments.very_special_comment.find_all_by_type('Comment').size - end - -end - -=end diff --git a/vendor/rails/activerecord/test/cases/migration_test.rb b/vendor/rails/activerecord/test/cases/migration_test.rb deleted file mode 100644 index 16861f2..0000000 --- a/vendor/rails/activerecord/test/cases/migration_test.rb +++ /dev/null @@ -1,1495 +0,0 @@ -require "cases/helper" -require 'bigdecimal/util' - -require 'models/person' -require 'models/topic' -require 'models/developer' - -require MIGRATIONS_ROOT + "/valid/1_people_have_last_names" -require MIGRATIONS_ROOT + "/valid/2_we_need_reminders" -require MIGRATIONS_ROOT + "/decimal/1_give_me_big_numbers" -require MIGRATIONS_ROOT + "/interleaved/pass_3/2_i_raise_on_down" - -if ActiveRecord::Base.connection.supports_migrations? - class BigNumber < ActiveRecord::Base; end - - class Reminder < ActiveRecord::Base; end - - class ActiveRecord::Migration - class <<self - attr_accessor :message_count - def puts(text="") - self.message_count ||= 0 - self.message_count += 1 - end - end - end - - class MigrationTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - fixtures :people - - def setup - ActiveRecord::Migration.verbose = true - PeopleHaveLastNames.message_count = 0 - end - - def teardown - ActiveRecord::Base.connection.initialize_schema_migrations_table - ActiveRecord::Base.connection.execute "DELETE FROM #{ActiveRecord::Migrator.schema_migrations_table_name}" - - %w(reminders people_reminders prefix_reminders_suffix).each do |table| - Reminder.connection.drop_table(table) rescue nil - end - Reminder.reset_column_information - - %w(last_name key bio age height wealth birthday favorite_day - moment_of_truth male administrator funny).each do |column| - Person.connection.remove_column('people', column) rescue nil - end - Person.connection.remove_column("people", "first_name") rescue nil - Person.connection.remove_column("people", "middle_name") rescue nil - Person.connection.add_column("people", "first_name", :string, :limit => 40) - Person.reset_column_information - end - - def test_add_index - # Limit size of last_name and key columns to support Firebird index limitations - Person.connection.add_column "people", "last_name", :string, :limit => 100 - Person.connection.add_column "people", "key", :string, :limit => 100 - Person.connection.add_column "people", "administrator", :boolean - - assert_nothing_raised { Person.connection.add_index("people", "last_name") } - assert_nothing_raised { Person.connection.remove_index("people", "last_name") } - - # Orcl nds shrt indx nms. Sybs 2. - # OpenBase does not have named indexes. You must specify a single column name - unless current_adapter?(:OracleAdapter, :SybaseAdapter, :OpenBaseAdapter) - assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } - assert_nothing_raised { Person.connection.remove_index("people", :column => ["last_name", "first_name"]) } - assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } - assert_nothing_raised { Person.connection.remove_index("people", :name => "index_people_on_last_name_and_first_name") } - assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } - assert_nothing_raised { Person.connection.remove_index("people", "last_name_and_first_name") } - assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } - assert_nothing_raised { Person.connection.remove_index("people", ["last_name", "first_name"]) } - end - - # quoting - # Note: changed index name from "key" to "key_idx" since "key" is a Firebird reserved word - # OpenBase does not have named indexes. You must specify a single column name - unless current_adapter?(:OpenBaseAdapter) - Person.update_all "#{Person.connection.quote_column_name 'key'}=#{Person.connection.quote_column_name 'id'}" #some databases (including sqlite2 won't add a unique index if existing data non unique) - assert_nothing_raised { Person.connection.add_index("people", ["key"], :name => "key_idx", :unique => true) } - assert_nothing_raised { Person.connection.remove_index("people", :name => "key_idx", :unique => true) } - end - - # Sybase adapter does not support indexes on :boolean columns - # OpenBase does not have named indexes. You must specify a single column - unless current_adapter?(:SybaseAdapter, :OpenBaseAdapter) - assert_nothing_raised { Person.connection.add_index("people", %w(last_name first_name administrator), :name => "named_admin") } - assert_nothing_raised { Person.connection.remove_index("people", :name => "named_admin") } - end - end - - def testing_table_with_only_foo_attribute - Person.connection.create_table :testings, :id => false do |t| - t.column :foo, :string - end - - yield Person.connection - ensure - Person.connection.drop_table :testings rescue nil - end - protected :testing_table_with_only_foo_attribute - - def test_create_table_without_id - testing_table_with_only_foo_attribute do |connection| - assert_equal connection.columns(:testings).size, 1 - end - end - - def test_add_column_with_primary_key_attribute - testing_table_with_only_foo_attribute do |connection| - assert_nothing_raised { connection.add_column :testings, :id, :primary_key } - assert_equal connection.columns(:testings).size, 2 - end - end - - def test_create_table_adds_id - Person.connection.create_table :testings do |t| - t.column :foo, :string - end - - assert_equal %w(foo id), - Person.connection.columns(:testings).map { |c| c.name }.sort - ensure - Person.connection.drop_table :testings rescue nil - end - - def test_create_table_with_not_null_column - assert_nothing_raised do - Person.connection.create_table :testings do |t| - t.column :foo, :string, :null => false - end - end - - assert_raise(ActiveRecord::StatementInvalid) do - Person.connection.execute "insert into testings (foo) values (NULL)" - end - ensure - Person.connection.drop_table :testings rescue nil - end - - def test_create_table_with_defaults - # MySQL doesn't allow defaults on TEXT or BLOB columns. - mysql = current_adapter?(:MysqlAdapter) - - Person.connection.create_table :testings do |t| - t.column :one, :string, :default => "hello" - t.column :two, :boolean, :default => true - t.column :three, :boolean, :default => false - t.column :four, :integer, :default => 1 - t.column :five, :text, :default => "hello" unless mysql - end - - columns = Person.connection.columns(:testings) - one = columns.detect { |c| c.name == "one" } - two = columns.detect { |c| c.name == "two" } - three = columns.detect { |c| c.name == "three" } - four = columns.detect { |c| c.name == "four" } - five = columns.detect { |c| c.name == "five" } unless mysql - - assert_equal "hello", one.default - assert_equal true, two.default - assert_equal false, three.default - assert_equal 1, four.default - assert_equal "hello", five.default unless mysql - - ensure - Person.connection.drop_table :testings rescue nil - end - - def test_create_table_with_limits - assert_nothing_raised do - Person.connection.create_table :testings do |t| - t.column :foo, :string, :limit => 255 - - t.column :default_int, :integer - - t.column :one_int, :integer, :limit => 1 - t.column :four_int, :integer, :limit => 4 - t.column :eight_int, :integer, :limit => 8 - t.column :eleven_int, :integer, :limit => 11 - end - end - - columns = Person.connection.columns(:testings) - foo = columns.detect { |c| c.name == "foo" } - assert_equal 255, foo.limit - - default = columns.detect { |c| c.name == "default_int" } - one = columns.detect { |c| c.name == "one_int" } - four = columns.detect { |c| c.name == "four_int" } - eight = columns.detect { |c| c.name == "eight_int" } - eleven = columns.detect { |c| c.name == "eleven_int" } - - if current_adapter?(:PostgreSQLAdapter) - assert_equal 'integer', default.sql_type - assert_equal 'smallint', one.sql_type - assert_equal 'integer', four.sql_type - assert_equal 'bigint', eight.sql_type - assert_equal 'integer', eleven.sql_type - elsif current_adapter?(:MysqlAdapter) - assert_match 'int(11)', default.sql_type - assert_match 'tinyint', one.sql_type - assert_match 'int', four.sql_type - assert_match 'bigint', eight.sql_type - assert_match 'int(11)', eleven.sql_type - elsif current_adapter?(:OracleAdapter) - assert_equal 'NUMBER(38)', default.sql_type - assert_equal 'NUMBER(1)', one.sql_type - assert_equal 'NUMBER(4)', four.sql_type - assert_equal 'NUMBER(8)', eight.sql_type - end - ensure - Person.connection.drop_table :testings rescue nil - end - - def test_create_table_with_primary_key_prefix_as_table_name_with_underscore - ActiveRecord::Base.primary_key_prefix_type = :table_name_with_underscore - - Person.connection.create_table :testings do |t| - t.column :foo, :string - end - - assert_equal %w(foo testings_id), Person.connection.columns(:testings).map { |c| c.name }.sort - ensure - Person.connection.drop_table :testings rescue nil - ActiveRecord::Base.primary_key_prefix_type = nil - end - - def test_create_table_with_primary_key_prefix_as_table_name - ActiveRecord::Base.primary_key_prefix_type = :table_name - - Person.connection.create_table :testings do |t| - t.column :foo, :string - end - - assert_equal %w(foo testingsid), Person.connection.columns(:testings).map { |c| c.name }.sort - ensure - Person.connection.drop_table :testings rescue nil - ActiveRecord::Base.primary_key_prefix_type = nil - end - - def test_create_table_with_force_true_does_not_drop_nonexisting_table - if Person.connection.table_exists?(:testings2) - Person.connection.drop_table :testings2 - end - - # using a copy as we need the drop_table method to - # continue to work for the ensure block of the test - temp_conn = Person.connection.dup - temp_conn.expects(:drop_table).never - temp_conn.create_table :testings2, :force => true do |t| - t.column :foo, :string - end - ensure - Person.connection.drop_table :testings2 rescue nil - end - - def test_create_table_with_timestamps_should_create_datetime_columns - table_name = :testings - - Person.connection.create_table table_name do |t| - t.timestamps - end - created_columns = Person.connection.columns(table_name) - - created_at_column = created_columns.detect {|c| c.name == 'created_at' } - updated_at_column = created_columns.detect {|c| c.name == 'updated_at' } - - assert created_at_column.null - assert updated_at_column.null - ensure - Person.connection.drop_table table_name rescue nil - end - - def test_create_table_with_timestamps_should_create_datetime_columns_with_options - table_name = :testings - - Person.connection.create_table table_name do |t| - t.timestamps :null => false - end - created_columns = Person.connection.columns(table_name) - - created_at_column = created_columns.detect {|c| c.name == 'created_at' } - updated_at_column = created_columns.detect {|c| c.name == 'updated_at' } - - assert !created_at_column.null - assert !updated_at_column.null - ensure - Person.connection.drop_table table_name rescue nil - end - - # Sybase, and SQLite3 will not allow you to add a NOT NULL - # column to a table without a default value. - unless current_adapter?(:SybaseAdapter, :SQLiteAdapter) - def test_add_column_not_null_without_default - Person.connection.create_table :testings do |t| - t.column :foo, :string - end - Person.connection.add_column :testings, :bar, :string, :null => false - - assert_raise(ActiveRecord::StatementInvalid) do - Person.connection.execute "insert into testings (foo, bar) values ('hello', NULL)" - end - ensure - Person.connection.drop_table :testings rescue nil - end - end - - def test_add_column_not_null_with_default - Person.connection.create_table :testings do |t| - t.column :foo, :string - end - - con = Person.connection - Person.connection.enable_identity_insert("testings", true) if current_adapter?(:SybaseAdapter) - Person.connection.execute "insert into testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}) values (1, 'hello')" - Person.connection.enable_identity_insert("testings", false) if current_adapter?(:SybaseAdapter) - assert_nothing_raised {Person.connection.add_column :testings, :bar, :string, :null => false, :default => "default" } - - assert_raise(ActiveRecord::StatementInvalid) do - unless current_adapter?(:OpenBaseAdapter) - Person.connection.execute "insert into testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}, #{con.quote_column_name('bar')}) values (2, 'hello', NULL)" - else - Person.connection.insert("INSERT INTO testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}, #{con.quote_column_name('bar')}) VALUES (2, 'hello', NULL)", - "Testing Insert","id",2) - end - end - ensure - Person.connection.drop_table :testings rescue nil - end - - # We specifically do a manual INSERT here, and then test only the SELECT - # functionality. This allows us to more easily catch INSERT being broken, - # but SELECT actually working fine. - def test_native_decimal_insert_manual_vs_automatic - correct_value = '0012345678901234567890.0123456789'.to_d - - Person.delete_all - Person.connection.add_column "people", "wealth", :decimal, :precision => '30', :scale => '10' - Person.reset_column_information - - # Do a manual insertion - if current_adapter?(:OracleAdapter) - Person.connection.execute "insert into people (id, wealth) values (people_seq.nextval, 12345678901234567890.0123456789)" - elsif current_adapter?(:OpenBaseAdapter) || (current_adapter?(:MysqlAdapter) && Mysql.client_version < 50003) #before mysql 5.0.3 decimals stored as strings - Person.connection.execute "insert into people (wealth) values ('12345678901234567890.0123456789')" - else - Person.connection.execute "insert into people (wealth) values (12345678901234567890.0123456789)" - end - - # SELECT - row = Person.find(:first) - assert_kind_of BigDecimal, row.wealth - - # If this assert fails, that means the SELECT is broken! - unless current_adapter?(:SQLite3Adapter) - assert_equal correct_value, row.wealth - end - - # Reset to old state - Person.delete_all - - # Now use the Rails insertion - assert_nothing_raised { Person.create :wealth => BigDecimal.new("12345678901234567890.0123456789") } - - # SELECT - row = Person.find(:first) - assert_kind_of BigDecimal, row.wealth - - # If these asserts fail, that means the INSERT (create function, or cast to SQL) is broken! - unless current_adapter?(:SQLite3Adapter) - assert_equal correct_value, row.wealth - end - - # Reset to old state - Person.connection.del_column "people", "wealth" rescue nil - Person.reset_column_information - end - - def test_add_column_with_precision_and_scale - Person.connection.add_column 'people', 'wealth', :decimal, :precision => 9, :scale => 7 - Person.reset_column_information - - wealth_column = Person.columns_hash['wealth'] - assert_equal 9, wealth_column.precision - assert_equal 7, wealth_column.scale - end - - def test_native_types - Person.delete_all - Person.connection.add_column "people", "last_name", :string - Person.connection.add_column "people", "bio", :text - Person.connection.add_column "people", "age", :integer - Person.connection.add_column "people", "height", :float - Person.connection.add_column "people", "wealth", :decimal, :precision => '30', :scale => '10' - Person.connection.add_column "people", "birthday", :datetime - Person.connection.add_column "people", "favorite_day", :date - Person.connection.add_column "people", "moment_of_truth", :datetime - Person.connection.add_column "people", "male", :boolean - Person.reset_column_information - - assert_nothing_raised do - Person.create :first_name => 'bob', :last_name => 'bobsen', - :bio => "I was born ....", :age => 18, :height => 1.78, - :wealth => BigDecimal.new("12345678901234567890.0123456789"), - :birthday => 18.years.ago, :favorite_day => 10.days.ago, - :moment_of_truth => "1782-10-10 21:40:18", :male => true - end - - bob = Person.find(:first) - assert_equal 'bob', bob.first_name - assert_equal 'bobsen', bob.last_name - assert_equal "I was born ....", bob.bio - assert_equal 18, bob.age - - # Test for 30 significent digits (beyond the 16 of float), 10 of them - # after the decimal place. - - unless current_adapter?(:SQLite3Adapter) - assert_equal BigDecimal.new("0012345678901234567890.0123456789"), bob.wealth - end - - assert_equal true, bob.male? - - assert_equal String, bob.first_name.class - assert_equal String, bob.last_name.class - assert_equal String, bob.bio.class - assert_equal Fixnum, bob.age.class - assert_equal Time, bob.birthday.class - - if current_adapter?(:OracleAdapter, :SybaseAdapter) - # Sybase, and Oracle don't differentiate between date/time - assert_equal Time, bob.favorite_day.class - else - assert_equal Date, bob.favorite_day.class - end - - # Test DateTime column and defaults, including timezone. - # FIXME: moment of truth may be Time on 64-bit platforms. - if bob.moment_of_truth.is_a?(DateTime) - - with_env_tz 'US/Eastern' do - assert_equal DateTime.local_offset, bob.moment_of_truth.offset - assert_not_equal 0, bob.moment_of_truth.offset - assert_not_equal "Z", bob.moment_of_truth.zone - # US/Eastern is -5 hours from GMT - assert_equal Rational(-5, 24), bob.moment_of_truth.offset - assert_match /\A-05:?00\Z/, bob.moment_of_truth.zone #ruby 1.8.6 uses HH:MM, prior versions use HHMM - assert_equal DateTime::ITALY, bob.moment_of_truth.start - end - end - - assert_equal TrueClass, bob.male?.class - assert_kind_of BigDecimal, bob.wealth - end - - if current_adapter?(:MysqlAdapter) - def test_unabstracted_database_dependent_types - Person.delete_all - - ActiveRecord::Migration.add_column :people, :intelligence_quotient, :tinyint - Person.reset_column_information - assert_match /tinyint/, Person.columns_hash['intelligence_quotient'].sql_type - ensure - ActiveRecord::Migration.remove_column :people, :intelligence_quotient rescue nil - end - end - - def test_add_remove_single_field_using_string_arguments - assert !Person.column_methods_hash.include?(:last_name) - - ActiveRecord::Migration.add_column 'people', 'last_name', :string - - Person.reset_column_information - assert Person.column_methods_hash.include?(:last_name) - - ActiveRecord::Migration.remove_column 'people', 'last_name' - - Person.reset_column_information - assert !Person.column_methods_hash.include?(:last_name) - end - - def test_add_remove_single_field_using_symbol_arguments - assert !Person.column_methods_hash.include?(:last_name) - - ActiveRecord::Migration.add_column :people, :last_name, :string - - Person.reset_column_information - assert Person.column_methods_hash.include?(:last_name) - - ActiveRecord::Migration.remove_column :people, :last_name - - Person.reset_column_information - assert !Person.column_methods_hash.include?(:last_name) - end - - def test_add_rename - Person.delete_all - - begin - Person.connection.add_column "people", "girlfriend", :string - Person.reset_column_information - Person.create :girlfriend => 'bobette' - - Person.connection.rename_column "people", "girlfriend", "exgirlfriend" - - Person.reset_column_information - bob = Person.find(:first) - - assert_equal "bobette", bob.exgirlfriend - ensure - Person.connection.remove_column("people", "girlfriend") rescue nil - Person.connection.remove_column("people", "exgirlfriend") rescue nil - end - - end - - def test_rename_column_using_symbol_arguments - begin - names_before = Person.find(:all).map(&:first_name) - Person.connection.rename_column :people, :first_name, :nick_name - Person.reset_column_information - assert Person.column_names.include?("nick_name") - assert_equal names_before, Person.find(:all).map(&:nick_name) - ensure - Person.connection.remove_column("people","nick_name") - Person.connection.add_column("people","first_name", :string) - end - end - - def test_rename_column - begin - names_before = Person.find(:all).map(&:first_name) - Person.connection.rename_column "people", "first_name", "nick_name" - Person.reset_column_information - assert Person.column_names.include?("nick_name") - assert_equal names_before, Person.find(:all).map(&:nick_name) - ensure - Person.connection.remove_column("people","nick_name") - Person.connection.add_column("people","first_name", :string) - end - end - - def test_rename_column_preserves_default_value_not_null - begin - default_before = Developer.connection.columns("developers").find { |c| c.name == "salary" }.default - assert_equal 70000, default_before - Developer.connection.rename_column "developers", "salary", "anual_salary" - Developer.reset_column_information - assert Developer.column_names.include?("anual_salary") - default_after = Developer.connection.columns("developers").find { |c| c.name == "anual_salary" }.default - assert_equal 70000, default_after - ensure - Developer.connection.rename_column "developers", "anual_salary", "salary" - Developer.reset_column_information - end - end - - def test_rename_nonexistent_column - ActiveRecord::Base.connection.create_table(:hats) do |table| - table.column :hat_name, :string, :default => nil - end - exception = if current_adapter?(:PostgreSQLAdapter) - ActiveRecord::StatementInvalid - else - ActiveRecord::ActiveRecordError - end - assert_raise(exception) do - Person.connection.rename_column "hats", "nonexistent", "should_fail" - end - ensure - ActiveRecord::Base.connection.drop_table(:hats) - end - - def test_rename_column_with_sql_reserved_word - begin - assert_nothing_raised { Person.connection.rename_column "people", "first_name", "group" } - Person.reset_column_information - assert Person.column_names.include?("group") - ensure - Person.connection.remove_column("people", "group") rescue nil - Person.connection.add_column("people", "first_name", :string) rescue nil - end - end - - def test_rename_column_with_an_index - ActiveRecord::Base.connection.create_table(:hats) do |table| - table.column :hat_name, :string, :limit => 100 - table.column :hat_size, :integer - end - Person.connection.add_index :hats, :hat_name - assert_nothing_raised do - Person.connection.rename_column "hats", "hat_name", "name" - end - ensure - ActiveRecord::Base.connection.drop_table(:hats) - end - - def test_remove_column_with_index - ActiveRecord::Base.connection.create_table(:hats) do |table| - table.column :hat_name, :string, :limit => 100 - table.column :hat_size, :integer - end - ActiveRecord::Base.connection.add_index "hats", "hat_size" - - assert_nothing_raised { Person.connection.remove_column("hats", "hat_size") } - ensure - ActiveRecord::Base.connection.drop_table(:hats) - end - - def test_remove_column_with_multi_column_index - ActiveRecord::Base.connection.create_table(:hats) do |table| - table.column :hat_name, :string, :limit => 100 - table.column :hat_size, :integer - table.column :hat_style, :string, :limit => 100 - end - ActiveRecord::Base.connection.add_index "hats", ["hat_style", "hat_size"], :unique => true - - assert_nothing_raised { Person.connection.remove_column("hats", "hat_size") } - ensure - ActiveRecord::Base.connection.drop_table(:hats) - end - - def test_change_type_of_not_null_column - assert_nothing_raised do - Topic.connection.change_column "topics", "written_on", :datetime, :null => false - Topic.reset_column_information - - Topic.connection.change_column "topics", "written_on", :datetime, :null => false - Topic.reset_column_information - end - end - - def test_rename_table - begin - ActiveRecord::Base.connection.create_table :octopuses do |t| - t.column :url, :string - end - ActiveRecord::Base.connection.rename_table :octopuses, :octopi - - # Using explicit id in insert for compatibility across all databases - con = ActiveRecord::Base.connection - con.enable_identity_insert("octopi", true) if current_adapter?(:SybaseAdapter) - assert_nothing_raised { con.execute "INSERT INTO octopi (#{con.quote_column_name('id')}, #{con.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')" } - con.enable_identity_insert("octopi", false) if current_adapter?(:SybaseAdapter) - - assert_equal 'http://www.foreverflying.com/octopus-black7.jpg', ActiveRecord::Base.connection.select_value("SELECT url FROM octopi WHERE id=1") - - ensure - ActiveRecord::Base.connection.drop_table :octopuses rescue nil - ActiveRecord::Base.connection.drop_table :octopi rescue nil - end - end - - def test_change_column_nullability - Person.delete_all - Person.connection.add_column "people", "funny", :boolean - Person.reset_column_information - assert Person.columns_hash["funny"].null, "Column 'funny' must initially allow nulls" - Person.connection.change_column "people", "funny", :boolean, :null => false, :default => true - Person.reset_column_information - assert !Person.columns_hash["funny"].null, "Column 'funny' must *not* allow nulls at this point" - Person.connection.change_column "people", "funny", :boolean, :null => true - Person.reset_column_information - assert Person.columns_hash["funny"].null, "Column 'funny' must allow nulls again at this point" - end - - def test_rename_table_with_an_index - begin - ActiveRecord::Base.connection.create_table :octopuses do |t| - t.column :url, :string - end - ActiveRecord::Base.connection.add_index :octopuses, :url - - ActiveRecord::Base.connection.rename_table :octopuses, :octopi - - # Using explicit id in insert for compatibility across all databases - con = ActiveRecord::Base.connection - con.enable_identity_insert("octopi", true) if current_adapter?(:SybaseAdapter) - assert_nothing_raised { con.execute "INSERT INTO octopi (#{con.quote_column_name('id')}, #{con.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')" } - con.enable_identity_insert("octopi", false) if current_adapter?(:SybaseAdapter) - - assert_equal 'http://www.foreverflying.com/octopus-black7.jpg', ActiveRecord::Base.connection.select_value("SELECT url FROM octopi WHERE id=1") - assert ActiveRecord::Base.connection.indexes(:octopi).first.columns.include?("url") - ensure - ActiveRecord::Base.connection.drop_table :octopuses rescue nil - ActiveRecord::Base.connection.drop_table :octopi rescue nil - end - end - - def test_change_column - Person.connection.add_column 'people', 'age', :integer - old_columns = Person.connection.columns(Person.table_name, "#{name} Columns") - assert old_columns.find { |c| c.name == 'age' and c.type == :integer } - - assert_nothing_raised { Person.connection.change_column "people", "age", :string } - - new_columns = Person.connection.columns(Person.table_name, "#{name} Columns") - assert_nil new_columns.find { |c| c.name == 'age' and c.type == :integer } - assert new_columns.find { |c| c.name == 'age' and c.type == :string } - - old_columns = Topic.connection.columns(Topic.table_name, "#{name} Columns") - assert old_columns.find { |c| c.name == 'approved' and c.type == :boolean and c.default == true } - assert_nothing_raised { Topic.connection.change_column :topics, :approved, :boolean, :default => false } - new_columns = Topic.connection.columns(Topic.table_name, "#{name} Columns") - assert_nil new_columns.find { |c| c.name == 'approved' and c.type == :boolean and c.default == true } - assert new_columns.find { |c| c.name == 'approved' and c.type == :boolean and c.default == false } - assert_nothing_raised { Topic.connection.change_column :topics, :approved, :boolean, :default => true } - end - - def test_change_column_with_nil_default - Person.connection.add_column "people", "contributor", :boolean, :default => true - Person.reset_column_information - assert Person.new.contributor? - - assert_nothing_raised { Person.connection.change_column "people", "contributor", :boolean, :default => nil } - Person.reset_column_information - assert !Person.new.contributor? - assert_nil Person.new.contributor - ensure - Person.connection.remove_column("people", "contributor") rescue nil - end - - def test_change_column_with_new_default - Person.connection.add_column "people", "administrator", :boolean, :default => true - Person.reset_column_information - assert Person.new.administrator? - - assert_nothing_raised { Person.connection.change_column "people", "administrator", :boolean, :default => false } - Person.reset_column_information - assert !Person.new.administrator? - ensure - Person.connection.remove_column("people", "administrator") rescue nil - end - - def test_change_column_default - Person.connection.change_column_default "people", "first_name", "Tester" - Person.reset_column_information - assert_equal "Tester", Person.new.first_name - end - - def test_change_column_quotes_column_names - Person.connection.create_table :testings do |t| - t.column :select, :string - end - - assert_nothing_raised { Person.connection.change_column :testings, :select, :string, :limit => 10 } - - assert_nothing_raised { Person.connection.execute "insert into testings (#{Person.connection.quote_column_name('select')}) values ('7 chars')" } - ensure - Person.connection.drop_table :testings rescue nil - end - - def test_keeping_default_and_notnull_constaint_on_change - Person.connection.create_table :testings do |t| - t.column :title, :string - end - person_klass = Class.new(Person) - person_klass.set_table_name 'testings' - - person_klass.connection.add_column "testings", "wealth", :integer, :null => false, :default => 99 - person_klass.reset_column_information - assert_equal 99, person_klass.columns_hash["wealth"].default - assert_equal false, person_klass.columns_hash["wealth"].null - assert_nothing_raised {person_klass.connection.execute("insert into testings (title) values ('tester')")} - - # change column default to see that column doesn't lose its not null definition - person_klass.connection.change_column_default "testings", "wealth", 100 - person_klass.reset_column_information - assert_equal 100, person_klass.columns_hash["wealth"].default - assert_equal false, person_klass.columns_hash["wealth"].null - - # rename column to see that column doesn't lose its not null and/or default definition - person_klass.connection.rename_column "testings", "wealth", "money" - person_klass.reset_column_information - assert_nil person_klass.columns_hash["wealth"] - assert_equal 100, person_klass.columns_hash["money"].default - assert_equal false, person_klass.columns_hash["money"].null - - # change column - person_klass.connection.change_column "testings", "money", :integer, :null => false, :default => 1000 - person_klass.reset_column_information - assert_equal 1000, person_klass.columns_hash["money"].default - assert_equal false, person_klass.columns_hash["money"].null - - # change column, make it nullable and clear default - person_klass.connection.change_column "testings", "money", :integer, :null => true, :default => nil - person_klass.reset_column_information - assert_nil person_klass.columns_hash["money"].default - assert_equal true, person_klass.columns_hash["money"].null - - # change_column_null, make it not nullable and set null values to a default value - person_klass.connection.execute('UPDATE testings SET money = NULL') - person_klass.connection.change_column_null "testings", "money", false, 2000 - person_klass.reset_column_information - assert_nil person_klass.columns_hash["money"].default - assert_equal false, person_klass.columns_hash["money"].null - assert_equal [2000], Person.connection.select_values("SELECT money FROM testings").map { |s| s.to_i }.sort - ensure - Person.connection.drop_table :testings rescue nil - end - - def test_change_column_default_to_null - Person.connection.change_column_default "people", "first_name", nil - Person.reset_column_information - assert_nil Person.new.first_name - end - - def test_add_table - assert !Reminder.table_exists? - - WeNeedReminders.up - - assert Reminder.create("content" => "hello world", "remind_at" => Time.now) - assert_equal "hello world", Reminder.find(:first).content - - WeNeedReminders.down - assert_raise(ActiveRecord::StatementInvalid) { Reminder.find(:first) } - end - - def test_add_table_with_decimals - Person.connection.drop_table :big_numbers rescue nil - - assert !BigNumber.table_exists? - GiveMeBigNumbers.up - - assert BigNumber.create( - :bank_balance => 1586.43, - :big_bank_balance => BigDecimal("1000234000567.95"), - :world_population => 6000000000, - :my_house_population => 3, - :value_of_e => BigDecimal("2.7182818284590452353602875") - ) - - b = BigNumber.find(:first) - assert_not_nil b - - assert_not_nil b.bank_balance - assert_not_nil b.big_bank_balance - assert_not_nil b.world_population - assert_not_nil b.my_house_population - assert_not_nil b.value_of_e - - # TODO: set world_population >= 2**62 to cover 64-bit platforms and test - # is_a?(Bignum) - assert_kind_of Integer, b.world_population - assert_equal 6000000000, b.world_population - assert_kind_of Fixnum, b.my_house_population - assert_equal 3, b.my_house_population - assert_kind_of BigDecimal, b.bank_balance - assert_equal BigDecimal("1586.43"), b.bank_balance - assert_kind_of BigDecimal, b.big_bank_balance - assert_equal BigDecimal("1000234000567.95"), b.big_bank_balance - - # This one is fun. The 'value_of_e' field is defined as 'DECIMAL' with - # precision/scale explicitly left out. By the SQL standard, numbers - # assigned to this field should be truncated but that's seldom respected. - if current_adapter?(:PostgreSQLAdapter, :SQLite2Adapter) - # - PostgreSQL changes the SQL spec on columns declared simply as - # "decimal" to something more useful: instead of being given a scale - # of 0, they take on the compile-time limit for precision and scale, - # so the following should succeed unless you have used really wacky - # compilation options - # - SQLite2 has the default behavior of preserving all data sent in, - # so this happens there too - assert_kind_of BigDecimal, b.value_of_e - assert_equal BigDecimal("2.7182818284590452353602875"), b.value_of_e - elsif current_adapter?(:SQLiteAdapter) - # - SQLite3 stores a float, in violation of SQL - assert_kind_of BigDecimal, b.value_of_e - assert_equal BigDecimal("2.71828182845905"), b.value_of_e - else - # - SQL standard is an integer - assert_kind_of Fixnum, b.value_of_e - assert_equal 2, b.value_of_e - end - - GiveMeBigNumbers.down - assert_raise(ActiveRecord::StatementInvalid) { BigNumber.find(:first) } - end - - def test_migrator - assert !Person.column_methods_hash.include?(:last_name) - assert !Reminder.table_exists? - - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid") - - assert_equal 3, ActiveRecord::Migrator.current_version - Person.reset_column_information - assert Person.column_methods_hash.include?(:last_name) - assert Reminder.create("content" => "hello world", "remind_at" => Time.now) - assert_equal "hello world", Reminder.find(:first).content - - ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid") - - assert_equal 0, ActiveRecord::Migrator.current_version - Person.reset_column_information - assert !Person.column_methods_hash.include?(:last_name) - assert_raise(ActiveRecord::StatementInvalid) { Reminder.find(:first) } - end - - def test_migrator_one_up - assert !Person.column_methods_hash.include?(:last_name) - assert !Reminder.table_exists? - - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) - - Person.reset_column_information - assert Person.column_methods_hash.include?(:last_name) - assert !Reminder.table_exists? - - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 2) - - assert Reminder.create("content" => "hello world", "remind_at" => Time.now) - assert_equal "hello world", Reminder.find(:first).content - end - - def test_migrator_one_down - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid") - - ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid", 1) - - Person.reset_column_information - assert Person.column_methods_hash.include?(:last_name) - assert !Reminder.table_exists? - end - - def test_migrator_one_up_one_down - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) - ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid", 0) - - assert !Person.column_methods_hash.include?(:last_name) - assert !Reminder.table_exists? - end - - def test_migrator_double_up - assert_equal(0, ActiveRecord::Migrator.current_version) - ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT + "/valid", 1) - assert_nothing_raised { ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT + "/valid", 1) } - assert_equal(1, ActiveRecord::Migrator.current_version) - end - - def test_migrator_double_down - assert_equal(0, ActiveRecord::Migrator.current_version) - ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT + "/valid", 1) - ActiveRecord::Migrator.run(:down, MIGRATIONS_ROOT + "/valid", 1) - assert_nothing_raised { ActiveRecord::Migrator.run(:down, MIGRATIONS_ROOT + "/valid", 1) } - assert_equal(0, ActiveRecord::Migrator.current_version) - end - - if ActiveRecord::Base.connection.supports_ddl_transactions? - def test_migrator_one_up_with_exception_and_rollback - assert !Person.column_methods_hash.include?(:last_name) - - e = assert_raise(StandardError) do - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/broken", 100) - end - - assert_equal "An error has occurred, this and all later migrations canceled:\n\nSomething broke", e.message - - Person.reset_column_information - assert !Person.column_methods_hash.include?(:last_name) - end - end - - def test_finds_migrations - migrations = ActiveRecord::Migrator.new(:up, MIGRATIONS_ROOT + "/valid").migrations - - [[1, 'PeopleHaveLastNames'], [2, 'WeNeedReminders'], [3, 'InnocentJointable']].each_with_index do |pair, i| - assert_equal migrations[i].version, pair.first - assert_equal migrations[i].name, pair.last - end - end - - def test_finds_pending_migrations - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/interleaved/pass_2", 1) - migrations = ActiveRecord::Migrator.new(:up, MIGRATIONS_ROOT + "/interleaved/pass_2").pending_migrations - - assert_equal 1, migrations.size - assert_equal migrations[0].version, 3 - assert_equal migrations[0].name, 'InnocentJointable' - end - - def test_only_loads_pending_migrations - # migrate up to 1 - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) - - # now unload the migrations that have been defined - PeopleHaveLastNames.unloadable - ActiveSupport::Dependencies.remove_unloadable_constants! - - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", nil) - - assert !defined? PeopleHaveLastNames - - %w(WeNeedReminders, InnocentJointable).each do |migration| - assert defined? migration - end - - ensure - load(MIGRATIONS_ROOT + "/valid/1_people_have_last_names.rb") - end - - def test_migrator_interleaved_migrations - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/interleaved/pass_1") - - assert_nothing_raised do - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/interleaved/pass_2") - end - - Person.reset_column_information - assert Person.column_methods_hash.include?(:last_name) - - assert_nothing_raised do - ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/interleaved/pass_3") - end - end - - def test_migrator_db_has_no_schema_migrations_table - ActiveRecord::Base.connection.execute("DROP TABLE schema_migrations;") - assert_nothing_raised do - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 1) - end - end - - def test_migrator_verbosity - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) - assert PeopleHaveLastNames.message_count > 0 - PeopleHaveLastNames.message_count = 0 - - ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid", 0) - assert PeopleHaveLastNames.message_count > 0 - PeopleHaveLastNames.message_count = 0 - end - - def test_migrator_verbosity_off - PeopleHaveLastNames.verbose = false - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) - assert PeopleHaveLastNames.message_count.zero? - ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid", 0) - assert PeopleHaveLastNames.message_count.zero? - end - - def test_migrator_going_down_due_to_version_target - ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 0) - - assert !Person.column_methods_hash.include?(:last_name) - assert !Reminder.table_exists? - - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid") - - Person.reset_column_information - assert Person.column_methods_hash.include?(:last_name) - assert Reminder.create("content" => "hello world", "remind_at" => Time.now) - assert_equal "hello world", Reminder.find(:first).content - end - - def test_migrator_rollback - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid") - assert_equal(3, ActiveRecord::Migrator.current_version) - - ActiveRecord::Migrator.rollback(MIGRATIONS_ROOT + "/valid") - assert_equal(2, ActiveRecord::Migrator.current_version) - - ActiveRecord::Migrator.rollback(MIGRATIONS_ROOT + "/valid") - assert_equal(1, ActiveRecord::Migrator.current_version) - - ActiveRecord::Migrator.rollback(MIGRATIONS_ROOT + "/valid") - assert_equal(0, ActiveRecord::Migrator.current_version) - - ActiveRecord::Migrator.rollback(MIGRATIONS_ROOT + "/valid") - assert_equal(0, ActiveRecord::Migrator.current_version) - end - - def test_schema_migrations_table_name - ActiveRecord::Base.table_name_prefix = "prefix_" - ActiveRecord::Base.table_name_suffix = "_suffix" - Reminder.reset_table_name - assert_equal "prefix_schema_migrations_suffix", ActiveRecord::Migrator.schema_migrations_table_name - ActiveRecord::Base.table_name_prefix = "" - ActiveRecord::Base.table_name_suffix = "" - Reminder.reset_table_name - assert_equal "schema_migrations", ActiveRecord::Migrator.schema_migrations_table_name - ensure - ActiveRecord::Base.table_name_prefix = "" - ActiveRecord::Base.table_name_suffix = "" - end - - def test_proper_table_name - assert_equal "table", ActiveRecord::Migrator.proper_table_name('table') - assert_equal "table", ActiveRecord::Migrator.proper_table_name(:table) - assert_equal "reminders", ActiveRecord::Migrator.proper_table_name(Reminder) - Reminder.reset_table_name - assert_equal Reminder.table_name, ActiveRecord::Migrator.proper_table_name(Reminder) - - # Use the model's own prefix/suffix if a model is given - ActiveRecord::Base.table_name_prefix = "ARprefix_" - ActiveRecord::Base.table_name_suffix = "_ARsuffix" - Reminder.table_name_prefix = 'prefix_' - Reminder.table_name_suffix = '_suffix' - Reminder.reset_table_name - assert_equal "prefix_reminders_suffix", ActiveRecord::Migrator.proper_table_name(Reminder) - Reminder.table_name_prefix = '' - Reminder.table_name_suffix = '' - Reminder.reset_table_name - - # Use AR::Base's prefix/suffix if string or symbol is given - ActiveRecord::Base.table_name_prefix = "prefix_" - ActiveRecord::Base.table_name_suffix = "_suffix" - Reminder.reset_table_name - assert_equal "prefix_table_suffix", ActiveRecord::Migrator.proper_table_name('table') - assert_equal "prefix_table_suffix", ActiveRecord::Migrator.proper_table_name(:table) - ActiveRecord::Base.table_name_prefix = "" - ActiveRecord::Base.table_name_suffix = "" - Reminder.reset_table_name - end - - def test_add_drop_table_with_prefix_and_suffix - assert !Reminder.table_exists? - ActiveRecord::Base.table_name_prefix = 'prefix_' - ActiveRecord::Base.table_name_suffix = '_suffix' - Reminder.reset_table_name - Reminder.reset_sequence_name - WeNeedReminders.up - assert Reminder.create("content" => "hello world", "remind_at" => Time.now) - assert_equal "hello world", Reminder.find(:first).content - - WeNeedReminders.down - assert_raise(ActiveRecord::StatementInvalid) { Reminder.find(:first) } - ensure - ActiveRecord::Base.table_name_prefix = '' - ActiveRecord::Base.table_name_suffix = '' - Reminder.reset_table_name - Reminder.reset_sequence_name - end - - def test_create_table_with_binary_column - Person.connection.drop_table :binary_testings rescue nil - - assert_nothing_raised { - Person.connection.create_table :binary_testings do |t| - t.column "data", :binary, :null => false - end - } - - columns = Person.connection.columns(:binary_testings) - data_column = columns.detect { |c| c.name == "data" } - - if current_adapter?(:MysqlAdapter) - assert_equal '', data_column.default - else - assert_nil data_column.default - end - - Person.connection.drop_table :binary_testings rescue nil - end - - def test_migrator_with_duplicates - assert_raise(ActiveRecord::DuplicateMigrationVersionError) do - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/duplicate", nil) - end - end - - def test_migrator_with_duplicate_names - assert_raise(ActiveRecord::DuplicateMigrationNameError, "Multiple migrations have the name Chunky") do - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/duplicate_names", nil) - end - end - - def test_migrator_with_missing_version_numbers - assert_raise(ActiveRecord::UnknownMigrationVersionError) do - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/missing", 500) - end - end - - def test_create_table_with_custom_sequence_name - return unless current_adapter? :OracleAdapter - - # table name is 29 chars, the standard sequence name will - # be 33 chars and fail - assert_raise(ActiveRecord::StatementInvalid) do - begin - Person.connection.create_table :table_with_name_thats_just_ok do |t| - t.column :foo, :string, :null => false - end - ensure - Person.connection.drop_table :table_with_name_thats_just_ok rescue nil - end - end - - # should be all good w/ a custom sequence name - assert_nothing_raised do - begin - Person.connection.create_table :table_with_name_thats_just_ok, - :sequence_name => 'suitably_short_seq' do |t| - t.column :foo, :string, :null => false - end - - Person.connection.execute("select suitably_short_seq.nextval from dual") - - ensure - Person.connection.drop_table :table_with_name_thats_just_ok, - :sequence_name => 'suitably_short_seq' rescue nil - end - end - - # confirm the custom sequence got dropped - assert_raise(ActiveRecord::StatementInvalid) do - Person.connection.execute("select suitably_short_seq.nextval from dual") - end - end - - protected - def with_env_tz(new_tz = 'US/Eastern') - old_tz, ENV['TZ'] = ENV['TZ'], new_tz - yield - ensure - old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ') - end - - end - - class SexyMigrationsTest < ActiveRecord::TestCase - def test_references_column_type_adds_id - with_new_table do |t| - t.expects(:column).with('customer_id', :integer, {}) - t.references :customer - end - end - - def test_references_column_type_with_polymorphic_adds_type - with_new_table do |t| - t.expects(:column).with('taggable_type', :string, {}) - t.expects(:column).with('taggable_id', :integer, {}) - t.references :taggable, :polymorphic => true - end - end - - def test_references_column_type_with_polymorphic_and_options_null_is_false_adds_table_flag - with_new_table do |t| - t.expects(:column).with('taggable_type', :string, {:null => false}) - t.expects(:column).with('taggable_id', :integer, {:null => false}) - t.references :taggable, :polymorphic => true, :null => false - end - end - - def test_belongs_to_works_like_references - with_new_table do |t| - t.expects(:column).with('customer_id', :integer, {}) - t.belongs_to :customer - end - end - - def test_timestamps_creates_updated_at_and_created_at - with_new_table do |t| - t.expects(:column).with(:created_at, :datetime, kind_of(Hash)) - t.expects(:column).with(:updated_at, :datetime, kind_of(Hash)) - t.timestamps - end - end - - def test_integer_creates_integer_column - with_new_table do |t| - t.expects(:column).with(:foo, 'integer', {}) - t.expects(:column).with(:bar, 'integer', {}) - t.integer :foo, :bar - end - end - - def test_string_creates_string_column - with_new_table do |t| - t.expects(:column).with(:foo, 'string', {}) - t.expects(:column).with(:bar, 'string', {}) - t.string :foo, :bar - end - end - - protected - def with_new_table - Person.connection.create_table :delete_me, :force => true do |t| - yield t - end - ensure - Person.connection.drop_table :delete_me rescue nil - end - - end # SexyMigrationsTest - - class ChangeTableMigrationsTest < ActiveRecord::TestCase - def setup - @connection = Person.connection - @connection.create_table :delete_me, :force => true do |t| - end - end - - def teardown - Person.connection.drop_table :delete_me rescue nil - end - - def test_references_column_type_adds_id - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, 'customer_id', :integer, {}) - t.references :customer - end - end - - def test_remove_references_column_type_removes_id - with_change_table do |t| - @connection.expects(:remove_column).with(:delete_me, 'customer_id') - t.remove_references :customer - end - end - - def test_add_belongs_to_works_like_add_references - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, 'customer_id', :integer, {}) - t.belongs_to :customer - end - end - - def test_remove_belongs_to_works_like_remove_references - with_change_table do |t| - @connection.expects(:remove_column).with(:delete_me, 'customer_id') - t.remove_belongs_to :customer - end - end - - def test_references_column_type_with_polymorphic_adds_type - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, 'taggable_type', :string, {}) - @connection.expects(:add_column).with(:delete_me, 'taggable_id', :integer, {}) - t.references :taggable, :polymorphic => true - end - end - - def test_remove_references_column_type_with_polymorphic_removes_type - with_change_table do |t| - @connection.expects(:remove_column).with(:delete_me, 'taggable_type') - @connection.expects(:remove_column).with(:delete_me, 'taggable_id') - t.remove_references :taggable, :polymorphic => true - end - end - - def test_references_column_type_with_polymorphic_and_options_null_is_false_adds_table_flag - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, 'taggable_type', :string, {:null => false}) - @connection.expects(:add_column).with(:delete_me, 'taggable_id', :integer, {:null => false}) - t.references :taggable, :polymorphic => true, :null => false - end - end - - def test_remove_references_column_type_with_polymorphic_and_options_null_is_false_removes_table_flag - with_change_table do |t| - @connection.expects(:remove_column).with(:delete_me, 'taggable_type') - @connection.expects(:remove_column).with(:delete_me, 'taggable_id') - t.remove_references :taggable, :polymorphic => true, :null => false - end - end - - def test_timestamps_creates_updated_at_and_created_at - with_change_table do |t| - @connection.expects(:add_timestamps).with(:delete_me) - t.timestamps - end - end - - def test_remove_timestamps_creates_updated_at_and_created_at - with_change_table do |t| - @connection.expects(:remove_timestamps).with(:delete_me) - t.remove_timestamps - end - end - - def string_column - if current_adapter?(:PostgreSQLAdapter) - "character varying(255)" - else - 'varchar(255)' - end - end - - def integer_column - if current_adapter?(:MysqlAdapter) - 'int(11)' - else - 'integer' - end - end - - def test_integer_creates_integer_column - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, :foo, integer_column, {}) - @connection.expects(:add_column).with(:delete_me, :bar, integer_column, {}) - t.integer :foo, :bar - end - end - - def test_string_creates_string_column - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, :foo, string_column, {}) - @connection.expects(:add_column).with(:delete_me, :bar, string_column, {}) - t.string :foo, :bar - end - end - - def test_column_creates_column - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, :bar, :integer, {}) - t.column :bar, :integer - end - end - - def test_column_creates_column_with_options - with_change_table do |t| - @connection.expects(:add_column).with(:delete_me, :bar, :integer, {:null => false}) - t.column :bar, :integer, :null => false - end - end - - def test_index_creates_index - with_change_table do |t| - @connection.expects(:add_index).with(:delete_me, :bar, {}) - t.index :bar - end - end - - def test_index_creates_index_with_options - with_change_table do |t| - @connection.expects(:add_index).with(:delete_me, :bar, {:unique => true}) - t.index :bar, :unique => true - end - end - - def test_change_changes_column - with_change_table do |t| - @connection.expects(:change_column).with(:delete_me, :bar, :string, {}) - t.change :bar, :string - end - end - - def test_change_changes_column_with_options - with_change_table do |t| - @connection.expects(:change_column).with(:delete_me, :bar, :string, {:null => true}) - t.change :bar, :string, :null => true - end - end - - def test_change_default_changes_column - with_change_table do |t| - @connection.expects(:change_column_default).with(:delete_me, :bar, :string) - t.change_default :bar, :string - end - end - - def test_remove_drops_single_column - with_change_table do |t| - @connection.expects(:remove_column).with(:delete_me, [:bar]) - t.remove :bar - end - end - - def test_remove_drops_multiple_columns - with_change_table do |t| - @connection.expects(:remove_column).with(:delete_me, [:bar, :baz]) - t.remove :bar, :baz - end - end - - def test_remove_index_removes_index_with_options - with_change_table do |t| - @connection.expects(:remove_index).with(:delete_me, {:unique => true}) - t.remove_index :unique => true - end - end - - def test_rename_renames_column - with_change_table do |t| - @connection.expects(:rename_column).with(:delete_me, :bar, :baz) - t.rename :bar, :baz - end - end - - protected - def with_change_table - Person.connection.change_table :delete_me do |t| - yield t - end - end - end -end diff --git a/vendor/rails/activerecord/test/cases/migration_test_firebird.rb b/vendor/rails/activerecord/test/cases/migration_test_firebird.rb deleted file mode 100644 index 710661b..0000000 --- a/vendor/rails/activerecord/test/cases/migration_test_firebird.rb +++ /dev/null @@ -1,124 +0,0 @@ -require "cases/helper" -require 'models/course' - -class FirebirdMigrationTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - # using Course connection for tests -- need a db that doesn't already have a BOOLEAN domain - @connection = Course.connection - @fireruby_connection = @connection.instance_variable_get(:@connection) - end - - def teardown - @connection.drop_table :foo rescue nil - @connection.execute("DROP DOMAIN D_BOOLEAN") rescue nil - end - - def test_create_table_with_custom_sequence_name - assert_nothing_raised do - @connection.create_table(:foo, :sequence => 'foo_custom_seq') do |f| - f.column :bar, :string - end - end - assert !sequence_exists?('foo_seq') - assert sequence_exists?('foo_custom_seq') - - assert_nothing_raised { @connection.drop_table(:foo, :sequence => 'foo_custom_seq') } - assert !sequence_exists?('foo_custom_seq') - ensure - FireRuby::Generator.new('foo_custom_seq', @fireruby_connection).drop rescue nil - end - - def test_create_table_without_sequence - assert_nothing_raised do - @connection.create_table(:foo, :sequence => false) do |f| - f.column :bar, :string - end - end - assert !sequence_exists?('foo_seq') - assert_nothing_raised { @connection.drop_table :foo } - - assert_nothing_raised do - @connection.create_table(:foo, :id => false) do |f| - f.column :bar, :string - end - end - assert !sequence_exists?('foo_seq') - assert_nothing_raised { @connection.drop_table :foo } - end - - def test_create_table_with_boolean_column - assert !boolean_domain_exists? - assert_nothing_raised do - @connection.create_table :foo do |f| - f.column :bar, :string - f.column :baz, :boolean - end - end - assert boolean_domain_exists? - end - - def test_add_boolean_column - assert !boolean_domain_exists? - @connection.create_table :foo do |f| - f.column :bar, :string - end - - assert_nothing_raised { @connection.add_column :foo, :baz, :boolean } - assert boolean_domain_exists? - assert_equal :boolean, @connection.columns(:foo).find { |c| c.name == "baz" }.type - end - - def test_change_column_to_boolean - assert !boolean_domain_exists? - # Manually create table with a SMALLINT column, which can be changed to a BOOLEAN - @connection.execute "CREATE TABLE foo (bar SMALLINT)" - assert_equal :integer, @connection.columns(:foo).find { |c| c.name == "bar" }.type - - assert_nothing_raised { @connection.change_column :foo, :bar, :boolean } - assert boolean_domain_exists? - assert_equal :boolean, @connection.columns(:foo).find { |c| c.name == "bar" }.type - end - - def test_rename_table_with_data_and_index - @connection.create_table :foo do |f| - f.column :baz, :string, :limit => 50 - end - 100.times { |i| @connection.execute "INSERT INTO foo VALUES (GEN_ID(foo_seq, 1), 'record #{i+1}')" } - @connection.add_index :foo, :baz - - assert_nothing_raised { @connection.rename_table :foo, :bar } - assert !@connection.tables.include?("foo") - assert @connection.tables.include?("bar") - assert_equal "index_bar_on_baz", @connection.indexes("bar").first.name - assert_equal 100, FireRuby::Generator.new("bar_seq", @fireruby_connection).last - assert_equal 100, @connection.select_one("SELECT COUNT(*) FROM bar")["count"] - ensure - @connection.drop_table :bar rescue nil - end - - def test_renaming_table_with_fk_constraint_raises_error - @connection.create_table :parent do |p| - p.column :name, :string - end - @connection.create_table :child do |c| - c.column :parent_id, :integer - end - @connection.execute "ALTER TABLE child ADD CONSTRAINT fk_child_parent FOREIGN KEY(parent_id) REFERENCES parent(id)" - assert_raise(ActiveRecord::ActiveRecordError) { @connection.rename_table :child, :descendant } - ensure - @connection.drop_table :child rescue nil - @connection.drop_table :descendant rescue nil - @connection.drop_table :parent rescue nil - end - - private - def boolean_domain_exists? - !@connection.select_one("SELECT 1 FROM rdb$fields WHERE rdb$field_name = 'D_BOOLEAN'").nil? - end - - def sequence_exists?(sequence_name) - FireRuby::Generator.exists?(sequence_name, @fireruby_connection) - end -end diff --git a/vendor/rails/activerecord/test/cases/mixin_test.rb b/vendor/rails/activerecord/test/cases/mixin_test.rb deleted file mode 100644 index f927c13..0000000 --- a/vendor/rails/activerecord/test/cases/mixin_test.rb +++ /dev/null @@ -1,96 +0,0 @@ -require "cases/helper" - -class Mixin < ActiveRecord::Base -end - -# Let us control what Time.now returns for the TouchTest suite -class Time - @@forced_now_time = nil - cattr_accessor :forced_now_time - - class << self - def now_with_forcing - if @@forced_now_time - @@forced_now_time - else - now_without_forcing - end - end - alias_method_chain :now, :forcing - end -end - - -class TouchTest < ActiveRecord::TestCase - fixtures :mixins - - def setup - Time.forced_now_time = Time.now - end - - def teardown - Time.forced_now_time = nil - end - - def test_time_mocking - five_minutes_ago = 5.minutes.ago - Time.forced_now_time = five_minutes_ago - assert_equal five_minutes_ago, Time.now - - Time.forced_now_time = nil - assert_not_equal five_minutes_ago, Time.now - end - - def test_update - stamped = Mixin.new - - assert_nil stamped.updated_at - assert_nil stamped.created_at - stamped.save - assert_equal Time.now, stamped.updated_at - assert_equal Time.now, stamped.created_at - end - - def test_create - obj = Mixin.create - assert_equal Time.now, obj.updated_at - assert_equal Time.now, obj.created_at - end - - def test_many_updates - stamped = Mixin.new - - assert_nil stamped.updated_at - assert_nil stamped.created_at - stamped.save - assert_equal Time.now, stamped.created_at - assert_equal Time.now, stamped.updated_at - - old_updated_at = stamped.updated_at - - Time.forced_now_time = 5.minutes.from_now - stamped.lft_will_change! - stamped.save - - assert_equal Time.now, stamped.updated_at - assert_equal old_updated_at, stamped.created_at - end - - def test_create_turned_off - Mixin.record_timestamps = false - - mixin = Mixin.new - - assert_nil mixin.updated_at - mixin.save - assert_nil mixin.updated_at - - # Make sure Mixin.record_timestamps gets reset, even if this test fails, - # so that other tests do not fail because Mixin.record_timestamps == false - rescue Exception => e - raise e - ensure - Mixin.record_timestamps = true - end - -end diff --git a/vendor/rails/activerecord/test/cases/modules_test.rb b/vendor/rails/activerecord/test/cases/modules_test.rb deleted file mode 100644 index 283333f..0000000 --- a/vendor/rails/activerecord/test/cases/modules_test.rb +++ /dev/null @@ -1,39 +0,0 @@ -require "cases/helper" -require 'models/company_in_module' - -class ModulesTest < ActiveRecord::TestCase - fixtures :accounts, :companies, :projects, :developers - - def test_module_spanning_associations - firm = MyApplication::Business::Firm.find(:first) - assert !firm.clients.empty?, "Firm should have clients" - assert_nil firm.class.table_name.match('::'), "Firm shouldn't have the module appear in its table name" - end - - def test_module_spanning_has_and_belongs_to_many_associations - project = MyApplication::Business::Project.find(:first) - project.developers << MyApplication::Business::Developer.create("name" => "John") - assert "John", project.developers.last.name - end - - def test_associations_spanning_cross_modules - account = MyApplication::Billing::Account.find(:first, :order => 'id') - assert_kind_of MyApplication::Business::Firm, account.firm - assert_kind_of MyApplication::Billing::Firm, account.qualified_billing_firm - assert_kind_of MyApplication::Billing::Firm, account.unqualified_billing_firm - assert_kind_of MyApplication::Billing::Nested::Firm, account.nested_qualified_billing_firm - assert_kind_of MyApplication::Billing::Nested::Firm, account.nested_unqualified_billing_firm - end - - def test_find_account_and_include_company - account = MyApplication::Billing::Account.find(1, :include => :firm) - assert_kind_of MyApplication::Business::Firm, account.instance_variable_get('@firm') - assert_kind_of MyApplication::Business::Firm, account.firm - end - - def test_table_name - assert_equal 'accounts', MyApplication::Billing::Account.table_name, 'table_name for ActiveRecord model in module' - assert_equal 'companies', MyApplication::Business::Client.table_name, 'table_name for ActiveRecord model subclass' - assert_equal 'company_contacts', MyApplication::Business::Client::Contact.table_name, 'table_name for ActiveRecord model enclosed by another ActiveRecord model' - end -end diff --git a/vendor/rails/activerecord/test/cases/multiple_db_test.rb b/vendor/rails/activerecord/test/cases/multiple_db_test.rb deleted file mode 100644 index 7c3e0f2..0000000 --- a/vendor/rails/activerecord/test/cases/multiple_db_test.rb +++ /dev/null @@ -1,85 +0,0 @@ -require "cases/helper" -require 'models/entrant' - -# So we can test whether Course.connection survives a reload. -require_dependency 'models/course' - -class MultipleDbTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @courses = create_fixtures("courses") { Course.retrieve_connection } - @entrants = create_fixtures("entrants") - end - - def test_connected - assert_not_nil Entrant.connection - assert_not_nil Course.connection - end - - def test_proper_connection - assert_not_equal(Entrant.connection, Course.connection) - assert_equal(Entrant.connection, Entrant.retrieve_connection) - assert_equal(Course.connection, Course.retrieve_connection) - assert_equal(ActiveRecord::Base.connection, Entrant.connection) - end - - def test_find - c1 = Course.find(1) - assert_equal "Ruby Development", c1.name - c2 = Course.find(2) - assert_equal "Java Development", c2.name - e1 = Entrant.find(1) - assert_equal "Ruby Developer", e1.name - e2 = Entrant.find(2) - assert_equal "Ruby Guru", e2.name - e3 = Entrant.find(3) - assert_equal "Java Lover", e3.name - end - - def test_associations - c1 = Course.find(1) - assert_equal 2, c1.entrants.count - e1 = Entrant.find(1) - assert_equal e1.course.id, c1.id - c2 = Course.find(2) - assert_equal 1, c2.entrants.count - e3 = Entrant.find(3) - assert_equal e3.course.id, c2.id - end - - def test_course_connection_should_survive_dependency_reload - assert Course.connection - - ActiveSupport::Dependencies.clear - Object.send(:remove_const, :Course) - require_dependency 'models/course' - - assert Course.connection - end - - def test_transactions_across_databases - c1 = Course.find(1) - e1 = Entrant.find(1) - - begin - Course.transaction do - Entrant.transaction do - c1.name = "Typo" - e1.name = "Typo" - c1.save - e1.save - raise "No I messed up." - end - end - rescue - # Yup caught it - end - - assert_equal "Typo", c1.name - assert_equal "Typo", e1.name - - assert_equal "Ruby Development", Course.find(1).name - assert_equal "Ruby Developer", Entrant.find(1).name - end -end diff --git a/vendor/rails/activerecord/test/cases/named_scope_test.rb b/vendor/rails/activerecord/test/cases/named_scope_test.rb deleted file mode 100644 index ae6a54a..0000000 --- a/vendor/rails/activerecord/test/cases/named_scope_test.rb +++ /dev/null @@ -1,359 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/topic' -require 'models/comment' -require 'models/reply' -require 'models/author' -require 'models/developer' - -class NamedScopeTest < ActiveRecord::TestCase - fixtures :posts, :authors, :topics, :comments, :author_addresses - - def test_implements_enumerable - assert !Topic.find(:all).empty? - - assert_equal Topic.find(:all), Topic.base - assert_equal Topic.find(:all), Topic.base.to_a - assert_equal Topic.find(:first), Topic.base.first - assert_equal Topic.find(:all), Topic.base.map { |i| i } - end - - def test_found_items_are_cached - Topic.columns - all_posts = Topic.base - - assert_queries(1) do - all_posts.collect - all_posts.collect - end - end - - def test_reload_expires_cache_of_found_items - all_posts = Topic.base - all_posts.inspect - - new_post = Topic.create! - assert !all_posts.include?(new_post) - assert all_posts.reload.include?(new_post) - end - - def test_delegates_finds_and_calculations_to_the_base_class - assert !Topic.find(:all).empty? - - assert_equal Topic.find(:all), Topic.base.find(:all) - assert_equal Topic.find(:first), Topic.base.find(:first) - assert_equal Topic.count, Topic.base.count - assert_equal Topic.average(:replies_count), Topic.base.average(:replies_count) - end - - def test_scope_should_respond_to_own_methods_and_methods_of_the_proxy - assert Topic.approved.respond_to?(:proxy_found) - assert Topic.approved.respond_to?(:count) - assert Topic.approved.respond_to?(:length) - end - - def test_respond_to_respects_include_private_parameter - assert !Topic.approved.respond_to?(:load_found) - assert Topic.approved.respond_to?(:load_found, true) - end - - def test_subclasses_inherit_scopes - assert Topic.scopes.include?(:base) - - assert Reply.scopes.include?(:base) - assert_equal Reply.find(:all), Reply.base - end - - def test_scopes_with_options_limit_finds_to_those_matching_the_criteria_specified - assert !Topic.find(:all, :conditions => {:approved => true}).empty? - - assert_equal Topic.find(:all, :conditions => {:approved => true}), Topic.approved - assert_equal Topic.count(:conditions => {:approved => true}), Topic.approved.count - end - - def test_scopes_with_string_name_can_be_composed - # NOTE that scopes defined with a string as a name worked on their own - # but when called on another scope the other scope was completely replaced - assert_equal Topic.replied.approved, Topic.replied.approved_as_string - end - - def test_scopes_can_be_specified_with_deep_hash_conditions - assert_equal Topic.replied.approved, Topic.replied.approved_as_hash_condition - end - - def test_scopes_are_composable - assert_equal (approved = Topic.find(:all, :conditions => {:approved => true})), Topic.approved - assert_equal (replied = Topic.find(:all, :conditions => 'replies_count > 0')), Topic.replied - assert !(approved == replied) - assert !(approved & replied).empty? - - assert_equal approved & replied, Topic.approved.replied - end - - def test_procedural_scopes - topics_written_before_the_third = Topic.find(:all, :conditions => ['written_on < ?', topics(:third).written_on]) - topics_written_before_the_second = Topic.find(:all, :conditions => ['written_on < ?', topics(:second).written_on]) - assert_not_equal topics_written_before_the_second, topics_written_before_the_third - - assert_equal topics_written_before_the_third, Topic.written_before(topics(:third).written_on) - assert_equal topics_written_before_the_second, Topic.written_before(topics(:second).written_on) - end - - def test_procedural_scopes_returning_nil - all_topics = Topic.find(:all) - - assert_equal all_topics, Topic.written_before(nil) - end - - def test_scopes_with_joins - address = author_addresses(:david_address) - posts_with_authors_at_address = Post.find( - :all, :joins => 'JOIN authors ON authors.id = posts.author_id', - :conditions => [ 'authors.author_address_id = ?', address.id ] - ) - assert_equal posts_with_authors_at_address, Post.with_authors_at_address(address) - end - - def test_scopes_with_joins_respects_custom_select - address = author_addresses(:david_address) - posts_with_authors_at_address_titles = Post.find(:all, - :select => 'title', - :joins => 'JOIN authors ON authors.id = posts.author_id', - :conditions => [ 'authors.author_address_id = ?', address.id ] - ) - assert_equal posts_with_authors_at_address_titles, Post.with_authors_at_address(address).find(:all, :select => 'title') - end - - def test_extensions - assert_equal 1, Topic.anonymous_extension.one - assert_equal 2, Topic.named_extension.two - end - - def test_multiple_extensions - assert_equal 2, Topic.multiple_extensions.extension_two - assert_equal 1, Topic.multiple_extensions.extension_one - end - - def test_has_many_associations_have_access_to_named_scopes - assert_not_equal Post.containing_the_letter_a, authors(:david).posts - assert !Post.containing_the_letter_a.empty? - - assert_equal authors(:david).posts & Post.containing_the_letter_a, authors(:david).posts.containing_the_letter_a - end - - def test_has_many_through_associations_have_access_to_named_scopes - assert_not_equal Comment.containing_the_letter_e, authors(:david).comments - assert !Comment.containing_the_letter_e.empty? - - assert_equal authors(:david).comments & Comment.containing_the_letter_e, authors(:david).comments.containing_the_letter_e - end - - def test_named_scopes_honor_current_scopes_from_when_defined - assert !Post.ranked_by_comments.limit(5).empty? - assert !authors(:david).posts.ranked_by_comments.limit(5).empty? - assert_not_equal Post.ranked_by_comments.limit(5), authors(:david).posts.ranked_by_comments.limit(5) - assert_not_equal Post.top(5), authors(:david).posts.top(5) - assert_equal authors(:david).posts.ranked_by_comments.limit(5), authors(:david).posts.top(5) - assert_equal Post.ranked_by_comments.limit(5), Post.top(5) - end - - def test_active_records_have_scope_named__all__ - assert !Topic.find(:all).empty? - - assert_equal Topic.find(:all), Topic.base - end - - def test_active_records_have_scope_named__scoped__ - assert !Topic.find(:all, scope = {:conditions => "content LIKE '%Have%'"}).empty? - - assert_equal Topic.find(:all, scope), Topic.scoped(scope) - end - - def test_proxy_options - expected_proxy_options = { :conditions => { :approved => true } } - assert_equal expected_proxy_options, Topic.approved.proxy_options - end - - def test_first_and_last_should_support_find_options - assert_equal Topic.base.first(:order => 'title'), Topic.base.find(:first, :order => 'title') - assert_equal Topic.base.last(:order => 'title'), Topic.base.find(:last, :order => 'title') - end - - def test_first_and_last_should_allow_integers_for_limit - assert_equal Topic.base.first(2), Topic.base.to_a.first(2) - assert_equal Topic.base.last(2), Topic.base.to_a.last(2) - end - - def test_first_and_last_should_not_use_query_when_results_are_loaded - topics = Topic.base - topics.reload # force load - assert_no_queries do - topics.first - topics.last - end - end - - def test_first_and_last_find_options_should_use_query_when_results_are_loaded - topics = Topic.base - topics.reload # force load - assert_queries(2) do - topics.first(:order => 'title') - topics.last(:order => 'title') - end - end - - def test_empty_should_not_load_results - topics = Topic.base - assert_queries(2) do - topics.empty? # use count query - topics.collect # force load - topics.empty? # use loaded (no query) - end - end - - def test_any_should_not_load_results - topics = Topic.base - assert_queries(2) do - topics.any? # use count query - topics.collect # force load - topics.any? # use loaded (no query) - end - end - - def test_any_should_call_proxy_found_if_using_a_block - topics = Topic.base - assert_queries(1) do - topics.expects(:empty?).never - topics.any? { true } - end - end - - def test_any_should_not_fire_query_if_named_scope_loaded - topics = Topic.base - topics.collect # force load - assert_no_queries { assert topics.any? } - end - - def test_should_build_with_proxy_options - topic = Topic.approved.build({}) - assert topic.approved - end - - def test_should_build_new_with_proxy_options - topic = Topic.approved.new - assert topic.approved - end - - def test_should_create_with_proxy_options - topic = Topic.approved.create({}) - assert topic.approved - end - - def test_should_create_with_bang_with_proxy_options - topic = Topic.approved.create!({}) - assert topic.approved - end - - def test_should_build_with_proxy_options_chained - topic = Topic.approved.by_lifo.build({}) - assert topic.approved - assert_equal 'lifo', topic.author_name - end - - def test_find_all_should_behave_like_select - assert_equal Topic.base.select(&:approved), Topic.base.find_all(&:approved) - end - - def test_rand_should_select_a_random_object_from_proxy - assert Topic.approved.rand.is_a?(Topic) - end - - def test_should_use_where_in_query_for_named_scope - assert_equal Developer.find_all_by_name('Jamis').to_set, Developer.find_all_by_id(Developer.jamises).to_set - end - - def test_size_should_use_count_when_results_are_not_loaded - topics = Topic.base - assert_queries(1) do - assert_sql(/COUNT/i) { topics.size } - end - end - - def test_size_should_use_length_when_results_are_loaded - topics = Topic.base - topics.reload # force load - assert_no_queries do - topics.size # use loaded (no query) - end - end - - def test_chaining_with_duplicate_joins - join = "INNER JOIN comments ON comments.post_id = posts.id" - post = Post.find(1) - assert_equal post.comments.size, Post.scoped(:joins => join).scoped(:joins => join, :conditions => "posts.id = #{post.id}").size - end - - def test_chaining_should_use_latest_conditions_when_creating - post = Topic.rejected.new - assert !post.approved? - - post = Topic.rejected.approved.new - assert post.approved? - - post = Topic.approved.rejected.new - assert !post.approved? - - post = Topic.approved.rejected.approved.new - assert post.approved? - end - - def test_chaining_should_use_latest_conditions_when_searching - # Normal hash conditions - assert_equal Topic.all(:conditions => {:approved => true}), Topic.rejected.approved.all - assert_equal Topic.all(:conditions => {:approved => false}), Topic.approved.rejected.all - - # Nested hash conditions with same keys - assert_equal [posts(:sti_comments)], Post.with_special_comments.with_very_special_comments.all - - # Nested hash conditions with different keys - assert_equal [posts(:sti_comments)], Post.with_special_comments.with_post(4).all.uniq - end - - def test_methods_invoked_within_scopes_should_respect_scope - assert_equal [], Topic.approved.by_rejected_ids.proxy_options[:conditions][:id] - end - - def test_named_scopes_batch_finders - assert_equal 3, Topic.approved.count - - assert_queries(4) do - Topic.approved.find_each(:batch_size => 1) {|t| assert t.approved? } - end - - assert_queries(2) do - Topic.approved.find_in_batches(:batch_size => 2) do |group| - group.each {|t| assert t.approved? } - end - end - end -end - -class DynamicScopeMatchTest < ActiveRecord::TestCase - def test_scoped_by_no_match - assert_nil ActiveRecord::DynamicScopeMatch.match("not_scoped_at_all") - end - - def test_scoped_by - match = ActiveRecord::DynamicScopeMatch.match("scoped_by_age_and_sex_and_location") - assert_not_nil match - assert match.scope? - assert_equal %w(age sex location), match.attribute_names - end -end - -class DynamicScopeTest < ActiveRecord::TestCase - def test_dynamic_scope - assert_equal Post.scoped_by_author_id(1).find(1), Post.find(1) - assert_equal Post.scoped_by_author_id_and_title(1, "Welcome to the weblog").first, Post.find(:first, :conditions => { :author_id => 1, :title => "Welcome to the weblog"}) - end -end diff --git a/vendor/rails/activerecord/test/cases/nested_attributes_test.rb b/vendor/rails/activerecord/test/cases/nested_attributes_test.rb deleted file mode 100644 index cd6277c..0000000 --- a/vendor/rails/activerecord/test/cases/nested_attributes_test.rb +++ /dev/null @@ -1,509 +0,0 @@ -require "cases/helper" -require "models/pirate" -require "models/ship" -require "models/bird" -require "models/parrot" -require "models/treasure" - -module AssertRaiseWithMessage - def assert_raise_with_message(expected_exception, expected_message) - begin - error_raised = false - yield - rescue expected_exception => error - error_raised = true - actual_message = error.message - end - assert error_raised - assert_equal expected_message, actual_message - end -end - -class TestNestedAttributesInGeneral < ActiveRecord::TestCase - include AssertRaiseWithMessage - - def teardown - Pirate.accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } - end - - def test_base_should_have_an_empty_reject_new_nested_attributes_procs - assert_equal Hash.new, ActiveRecord::Base.reject_new_nested_attributes_procs - end - - def test_should_add_a_proc_to_reject_new_nested_attributes_procs - [:parrots, :birds].each do |name| - assert_instance_of Proc, Pirate.reject_new_nested_attributes_procs[name] - end - end - - def test_should_raise_an_ArgumentError_for_non_existing_associations - assert_raise_with_message ArgumentError, "No association found for name `honesty'. Has it been defined yet?" do - Pirate.accepts_nested_attributes_for :honesty - end - end - - def test_should_disable_allow_destroy_by_default - Pirate.accepts_nested_attributes_for :ship - - pirate = Pirate.create!(:catchphrase => "Don' botharrr talkin' like one, savvy?") - ship = pirate.create_ship(:name => 'Nights Dirty Lightning') - - assert_no_difference('Ship.count') do - pirate.update_attributes(:ship_attributes => { '_delete' => true }) - end - end - - def test_a_model_should_respond_to_underscore_delete_and_return_if_it_is_marked_for_destruction - ship = Ship.create!(:name => 'Nights Dirty Lightning') - assert !ship._delete - ship.mark_for_destruction - assert ship._delete - end -end - -class TestNestedAttributesOnAHasOneAssociation < ActiveRecord::TestCase - def setup - @pirate = Pirate.create!(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @ship = @pirate.create_ship(:name => 'Nights Dirty Lightning') - end - - def test_should_define_an_attribute_writer_method_for_the_association - assert_respond_to @pirate, :ship_attributes= - end - - def test_should_build_a_new_record_if_there_is_no_id - @ship.destroy - @pirate.reload.ship_attributes = { :name => 'Davy Jones Gold Dagger' } - - assert @pirate.ship.new_record? - assert_equal 'Davy Jones Gold Dagger', @pirate.ship.name - end - - def test_should_not_build_a_new_record_if_there_is_no_id_and_delete_is_truthy - @ship.destroy - @pirate.reload.ship_attributes = { :name => 'Davy Jones Gold Dagger', :_delete => '1' } - - assert_nil @pirate.ship - end - - def test_should_not_build_a_new_record_if_a_reject_if_proc_returns_false - @ship.destroy - @pirate.reload.ship_attributes = {} - - assert_nil @pirate.ship - end - - def test_should_replace_an_existing_record_if_there_is_no_id - @pirate.reload.ship_attributes = { :name => 'Davy Jones Gold Dagger' } - - assert @pirate.ship.new_record? - assert_equal 'Davy Jones Gold Dagger', @pirate.ship.name - assert_equal 'Nights Dirty Lightning', @ship.name - end - - def test_should_not_replace_an_existing_record_if_there_is_no_id_and_delete_is_truthy - @pirate.reload.ship_attributes = { :name => 'Davy Jones Gold Dagger', :_delete => '1' } - - assert_equal @ship, @pirate.ship - assert_equal 'Nights Dirty Lightning', @pirate.ship.name - end - - def test_should_modify_an_existing_record_if_there_is_a_matching_id - @pirate.reload.ship_attributes = { :id => @ship.id, :name => 'Davy Jones Gold Dagger' } - - assert_equal @ship, @pirate.ship - assert_equal 'Davy Jones Gold Dagger', @pirate.ship.name - end - - def test_should_take_a_hash_with_string_keys_and_update_the_associated_model - @pirate.reload.ship_attributes = { 'id' => @ship.id, 'name' => 'Davy Jones Gold Dagger' } - - assert_equal @ship, @pirate.ship - assert_equal 'Davy Jones Gold Dagger', @pirate.ship.name - end - - def test_should_modify_an_existing_record_if_there_is_a_matching_composite_id - @ship.stubs(:id).returns('ABC1X') - @pirate.ship_attributes = { :id => @ship.id, :name => 'Davy Jones Gold Dagger' } - - assert_equal 'Davy Jones Gold Dagger', @pirate.ship.name - end - - def test_should_delete_an_existing_record_if_there_is_a_matching_id_and_delete_is_truthy - @pirate.ship.destroy - [1, '1', true, 'true'].each do |truth| - @pirate.reload.create_ship(:name => 'Mister Pablo') - assert_difference('Ship.count', -1) do - @pirate.update_attribute(:ship_attributes, { :id => @pirate.ship.id, :_delete => truth }) - end - end - end - - def test_should_not_delete_an_existing_record_if_delete_is_not_truthy - [nil, '0', 0, 'false', false].each do |not_truth| - assert_no_difference('Ship.count') do - @pirate.update_attribute(:ship_attributes, { :id => @pirate.ship.id, :_delete => not_truth }) - end - end - end - - def test_should_not_delete_an_existing_record_if_allow_destroy_is_false - Pirate.accepts_nested_attributes_for :ship, :allow_destroy => false, :reject_if => proc { |attributes| attributes.empty? } - - assert_no_difference('Ship.count') do - @pirate.update_attribute(:ship_attributes, { :id => @pirate.ship.id, :_delete => '1' }) - end - - Pirate.accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } - end - - def test_should_also_work_with_a_HashWithIndifferentAccess - @pirate.ship_attributes = HashWithIndifferentAccess.new(:id => @ship.id, :name => 'Davy Jones Gold Dagger') - - assert !@pirate.ship.new_record? - assert_equal 'Davy Jones Gold Dagger', @pirate.ship.name - end - - def test_should_work_with_update_attributes_as_well - @pirate.update_attributes({ :catchphrase => 'Arr', :ship_attributes => { :id => @ship.id, :name => 'Mister Pablo' } }) - @pirate.reload - - assert_equal 'Arr', @pirate.catchphrase - assert_equal 'Mister Pablo', @pirate.ship.name - end - - def test_should_not_destroy_the_associated_model_until_the_parent_is_saved - assert_no_difference('Ship.count') do - @pirate.attributes = { :ship_attributes => { :id => @ship.id, :_delete => '1' } } - end - assert_difference('Ship.count', -1) do - @pirate.save - end - end - - def test_should_automatically_enable_autosave_on_the_association - assert Pirate.reflect_on_association(:ship).options[:autosave] - end -end - -class TestNestedAttributesOnABelongsToAssociation < ActiveRecord::TestCase - def setup - @ship = Ship.new(:name => 'Nights Dirty Lightning') - @pirate = @ship.build_pirate(:catchphrase => 'Aye') - @ship.save! - end - - def test_should_define_an_attribute_writer_method_for_the_association - assert_respond_to @ship, :pirate_attributes= - end - - def test_should_build_a_new_record_if_there_is_no_id - @pirate.destroy - @ship.reload.pirate_attributes = { :catchphrase => 'Arr' } - - assert @ship.pirate.new_record? - assert_equal 'Arr', @ship.pirate.catchphrase - end - - def test_should_not_build_a_new_record_if_there_is_no_id_and_delete_is_truthy - @pirate.destroy - @ship.reload.pirate_attributes = { :catchphrase => 'Arr', :_delete => '1' } - - assert_nil @ship.pirate - end - - def test_should_not_build_a_new_record_if_a_reject_if_proc_returns_false - @pirate.destroy - @ship.reload.pirate_attributes = {} - - assert_nil @ship.pirate - end - - def test_should_replace_an_existing_record_if_there_is_no_id - @ship.reload.pirate_attributes = { :catchphrase => 'Arr' } - - assert @ship.pirate.new_record? - assert_equal 'Arr', @ship.pirate.catchphrase - assert_equal 'Aye', @pirate.catchphrase - end - - def test_should_not_replace_an_existing_record_if_there_is_no_id_and_delete_is_truthy - @ship.reload.pirate_attributes = { :catchphrase => 'Arr', :_delete => '1' } - - assert_equal @pirate, @ship.pirate - assert_equal 'Aye', @ship.pirate.catchphrase - end - - def test_should_modify_an_existing_record_if_there_is_a_matching_id - @ship.reload.pirate_attributes = { :id => @pirate.id, :catchphrase => 'Arr' } - - assert_equal @pirate, @ship.pirate - assert_equal 'Arr', @ship.pirate.catchphrase - end - - def test_should_take_a_hash_with_string_keys_and_update_the_associated_model - @ship.reload.pirate_attributes = { 'id' => @pirate.id, 'catchphrase' => 'Arr' } - - assert_equal @pirate, @ship.pirate - assert_equal 'Arr', @ship.pirate.catchphrase - end - - def test_should_modify_an_existing_record_if_there_is_a_matching_composite_id - @pirate.stubs(:id).returns('ABC1X') - @ship.pirate_attributes = { :id => @pirate.id, :catchphrase => 'Arr' } - - assert_equal 'Arr', @ship.pirate.catchphrase - end - - def test_should_delete_an_existing_record_if_there_is_a_matching_id_and_delete_is_truthy - @ship.pirate.destroy - [1, '1', true, 'true'].each do |truth| - @ship.reload.create_pirate(:catchphrase => 'Arr') - assert_difference('Pirate.count', -1) do - @ship.update_attribute(:pirate_attributes, { :id => @ship.pirate.id, :_delete => truth }) - end - end - end - - def test_should_not_delete_an_existing_record_if_delete_is_not_truthy - [nil, '0', 0, 'false', false].each do |not_truth| - assert_no_difference('Pirate.count') do - @ship.update_attribute(:pirate_attributes, { :id => @ship.pirate.id, :_delete => not_truth }) - end - end - end - - def test_should_not_delete_an_existing_record_if_allow_destroy_is_false - Ship.accepts_nested_attributes_for :pirate, :allow_destroy => false, :reject_if => proc { |attributes| attributes.empty? } - - assert_no_difference('Pirate.count') do - @ship.update_attribute(:pirate_attributes, { :id => @ship.pirate.id, :_delete => '1' }) - end - - Ship.accepts_nested_attributes_for :pirate, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } - end - - def test_should_work_with_update_attributes_as_well - @ship.update_attributes({ :name => 'Mister Pablo', :pirate_attributes => { :catchphrase => 'Arr' } }) - @ship.reload - - assert_equal 'Mister Pablo', @ship.name - assert_equal 'Arr', @ship.pirate.catchphrase - end - - def test_should_not_destroy_the_associated_model_until_the_parent_is_saved - assert_no_difference('Pirate.count') do - @ship.attributes = { :pirate_attributes => { :id => @ship.pirate.id, '_delete' => true } } - end - assert_difference('Pirate.count', -1) { @ship.save } - end - - def test_should_automatically_enable_autosave_on_the_association - assert Ship.reflect_on_association(:pirate).options[:autosave] - end -end - -module NestedAttributesOnACollectionAssociationTests - include AssertRaiseWithMessage - - def test_should_define_an_attribute_writer_method_for_the_association - assert_respond_to @pirate, association_setter - end - - def test_should_take_a_hash_with_string_keys_and_assign_the_attributes_to_the_associated_models - @alternate_params[association_getter].stringify_keys! - @pirate.update_attributes @alternate_params - assert_equal ['Grace OMalley', 'Privateers Greed'], [@child_1.reload.name, @child_2.reload.name] - end - - def test_should_take_an_array_and_assign_the_attributes_to_the_associated_models - @pirate.send(association_setter, @alternate_params[association_getter].values) - @pirate.save - assert_equal ['Grace OMalley', 'Privateers Greed'], [@child_1.reload.name, @child_2.reload.name] - end - - def test_should_also_work_with_a_HashWithIndifferentAccess - @pirate.send(association_setter, HashWithIndifferentAccess.new('foo' => HashWithIndifferentAccess.new(:id => @child_1.id, :name => 'Grace OMalley'))) - @pirate.save - assert_equal 'Grace OMalley', @child_1.reload.name - end - - def test_should_take_a_hash_and_assign_the_attributes_to_the_associated_models - @pirate.attributes = @alternate_params - assert_equal 'Grace OMalley', @pirate.send(@association_name).first.name - assert_equal 'Privateers Greed', @pirate.send(@association_name).last.name - end - - def test_should_take_a_hash_with_composite_id_keys_and_assign_the_attributes_to_the_associated_models - @child_1.stubs(:id).returns('ABC1X') - @child_2.stubs(:id).returns('ABC2X') - - @pirate.attributes = { - association_getter => [ - { :id => @child_1.id, :name => 'Grace OMalley' }, - { :id => @child_2.id, :name => 'Privateers Greed' } - ] - } - - assert_equal ['Grace OMalley', 'Privateers Greed'], [@child_1.name, @child_2.name] - end - - def test_should_automatically_build_new_associated_models_for_each_entry_in_a_hash_where_the_id_is_missing - @pirate.send(@association_name).destroy_all - @pirate.reload.attributes = { - association_getter => { 'foo' => { :name => 'Grace OMalley' }, 'bar' => { :name => 'Privateers Greed' }} - } - - assert @pirate.send(@association_name).first.new_record? - assert_equal 'Grace OMalley', @pirate.send(@association_name).first.name - - assert @pirate.send(@association_name).last.new_record? - assert_equal 'Privateers Greed', @pirate.send(@association_name).last.name - end - - def test_should_not_assign_delete_key_to_a_record - assert_nothing_raised ActiveRecord::UnknownAttributeError do - @pirate.send(association_setter, { 'foo' => { '_delete' => '0' }}) - end - end - - def test_should_ignore_new_associated_records_with_truthy_delete_attribute - @pirate.send(@association_name).destroy_all - @pirate.reload.attributes = { - association_getter => { - 'foo' => { :name => 'Grace OMalley' }, - 'bar' => { :name => 'Privateers Greed', '_delete' => '1' } - } - } - - assert_equal 1, @pirate.send(@association_name).length - assert_equal 'Grace OMalley', @pirate.send(@association_name).first.name - end - - def test_should_ignore_new_associated_records_if_a_reject_if_proc_returns_false - @alternate_params[association_getter]['baz'] = {} - assert_no_difference("@pirate.send(@association_name).length") do - @pirate.attributes = @alternate_params - end - end - - def test_should_sort_the_hash_by_the_keys_before_building_new_associated_models - attributes = ActiveSupport::OrderedHash.new - attributes['123726353'] = { :name => 'Grace OMalley' } - attributes['2'] = { :name => 'Privateers Greed' } # 2 is lower then 123726353 - @pirate.send(association_setter, attributes) - - assert_equal ['Posideons Killer', 'Killer bandita Dionne', 'Privateers Greed', 'Grace OMalley'].to_set, @pirate.send(@association_name).map(&:name).to_set - end - - def test_should_raise_an_argument_error_if_something_else_than_a_hash_is_passed - assert_nothing_raised(ArgumentError) { @pirate.send(association_setter, {}) } - assert_nothing_raised(ArgumentError) { @pirate.send(association_setter, ActiveSupport::OrderedHash.new) } - - assert_raise_with_message ArgumentError, 'Hash or Array expected, got String ("foo")' do - @pirate.send(association_setter, "foo") - end - end - - def test_should_work_with_update_attributes_as_well - @pirate.update_attributes(:catchphrase => 'Arr', - association_getter => { 'foo' => { :id => @child_1.id, :name => 'Grace OMalley' }}) - - assert_equal 'Grace OMalley', @child_1.reload.name - end - - def test_should_update_existing_records_and_add_new_ones_that_have_no_id - @alternate_params[association_getter]['baz'] = { :name => 'Buccaneers Servant' } - assert_difference('@pirate.send(@association_name).count', +1) do - @pirate.update_attributes @alternate_params - end - assert_equal ['Grace OMalley', 'Privateers Greed', 'Buccaneers Servant'].to_set, @pirate.reload.send(@association_name).map(&:name).to_set - end - - def test_should_be_possible_to_destroy_a_record - ['1', 1, 'true', true].each do |true_variable| - record = @pirate.reload.send(@association_name).create!(:name => 'Grace OMalley') - @pirate.send(association_setter, - @alternate_params[association_getter].merge('baz' => { :id => record.id, '_delete' => true_variable }) - ) - - assert_difference('@pirate.send(@association_name).count', -1) do - @pirate.save - end - end - end - - def test_should_not_destroy_the_associated_model_with_a_non_truthy_argument - [nil, '', '0', 0, 'false', false].each do |false_variable| - @alternate_params[association_getter]['foo']['_delete'] = false_variable - assert_no_difference('@pirate.send(@association_name).count') do - @pirate.update_attributes(@alternate_params) - end - end - end - - def test_should_not_destroy_the_associated_model_until_the_parent_is_saved - assert_no_difference('@pirate.send(@association_name).count') do - @pirate.send(association_setter, @alternate_params[association_getter].merge('baz' => { :id => @child_1.id, '_delete' => true })) - end - assert_difference('@pirate.send(@association_name).count', -1) { @pirate.save } - end - - def test_should_automatically_enable_autosave_on_the_association - assert Pirate.reflect_on_association(@association_name).options[:autosave] - end - - private - - def association_setter - @association_setter ||= "#{@association_name}_attributes=".to_sym - end - - def association_getter - @association_getter ||= "#{@association_name}_attributes".to_sym - end -end - -class TestNestedAttributesOnAHasManyAssociation < ActiveRecord::TestCase - def setup - @association_type = :has_many - @association_name = :birds - - @pirate = Pirate.create!(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @pirate.birds.create!(:name => 'Posideons Killer') - @pirate.birds.create!(:name => 'Killer bandita Dionne') - - @child_1, @child_2 = @pirate.birds - - @alternate_params = { - :birds_attributes => { - 'foo' => { :id => @child_1.id, :name => 'Grace OMalley' }, - 'bar' => { :id => @child_2.id, :name => 'Privateers Greed' } - } - } - end - - include NestedAttributesOnACollectionAssociationTests -end - -class TestNestedAttributesOnAHasAndBelongsToManyAssociation < ActiveRecord::TestCase - def setup - @association_type = :has_and_belongs_to_many - @association_name = :parrots - - @pirate = Pirate.create!(:catchphrase => "Don' botharrr talkin' like one, savvy?") - @pirate.parrots.create!(:name => 'Posideons Killer') - @pirate.parrots.create!(:name => 'Killer bandita Dionne') - - @child_1, @child_2 = @pirate.parrots - - @alternate_params = { - :parrots_attributes => { - 'foo' => { :id => @child_1.id, :name => 'Grace OMalley' }, - 'bar' => { :id => @child_2.id, :name => 'Privateers Greed' } - } - } - end - - include NestedAttributesOnACollectionAssociationTests -end diff --git a/vendor/rails/activerecord/test/cases/pk_test.rb b/vendor/rails/activerecord/test/cases/pk_test.rb deleted file mode 100644 index 948a570..0000000 --- a/vendor/rails/activerecord/test/cases/pk_test.rb +++ /dev/null @@ -1,101 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/reply' -require 'models/subscriber' -require 'models/movie' -require 'models/keyboard' -require 'models/mixed_case_monkey' - -class PrimaryKeysTest < ActiveRecord::TestCase - fixtures :topics, :subscribers, :movies, :mixed_case_monkeys - - def test_integer_key - topic = Topic.find(1) - assert_equal(topics(:first).author_name, topic.author_name) - topic = Topic.find(2) - assert_equal(topics(:second).author_name, topic.author_name) - - topic = Topic.new - topic.title = "New Topic" - assert_equal(nil, topic.id) - assert_nothing_raised { topic.save! } - id = topic.id - - topicReloaded = Topic.find(id) - assert_equal("New Topic", topicReloaded.title) - end - - def test_customized_primary_key_auto_assigns_on_save - Keyboard.delete_all - keyboard = Keyboard.new(:name => 'HHKB') - assert_nothing_raised { keyboard.save! } - assert_equal keyboard.id, Keyboard.find_by_name('HHKB').id - end - - def test_customized_primary_key_can_be_get_before_saving - keyboard = Keyboard.new - assert_nil keyboard.id - assert_nothing_raised { assert_nil keyboard.key_number } - end - - def test_customized_string_primary_key_settable_before_save - subscriber = Subscriber.new - assert_nothing_raised { subscriber.id = 'webster123' } - assert_equal 'webster123', subscriber.id - assert_equal 'webster123', subscriber.nick - end - - def test_string_key - subscriber = Subscriber.find(subscribers(:first).nick) - assert_equal(subscribers(:first).name, subscriber.name) - subscriber = Subscriber.find(subscribers(:second).nick) - assert_equal(subscribers(:second).name, subscriber.name) - - subscriber = Subscriber.new - subscriber.id = "jdoe" - assert_equal("jdoe", subscriber.id) - subscriber.name = "John Doe" - assert_nothing_raised { subscriber.save! } - assert_equal("jdoe", subscriber.id) - - subscriberReloaded = Subscriber.find("jdoe") - assert_equal("John Doe", subscriberReloaded.name) - end - - def test_find_with_more_than_one_string_key - assert_equal 2, Subscriber.find(subscribers(:first).nick, subscribers(:second).nick).length - end - - def test_primary_key_prefix - ActiveRecord::Base.primary_key_prefix_type = :table_name - Topic.reset_primary_key - assert_equal "topicid", Topic.primary_key - - ActiveRecord::Base.primary_key_prefix_type = :table_name_with_underscore - Topic.reset_primary_key - assert_equal "topic_id", Topic.primary_key - - ActiveRecord::Base.primary_key_prefix_type = nil - Topic.reset_primary_key - assert_equal "id", Topic.primary_key - end - - def test_delete_should_quote_pkey - assert_nothing_raised { MixedCaseMonkey.delete(1) } - end - def test_update_counters_should_quote_pkey_and_quote_counter_columns - assert_nothing_raised { MixedCaseMonkey.update_counters(1, :fleaCount => 99) } - end - def test_find_with_one_id_should_quote_pkey - assert_nothing_raised { MixedCaseMonkey.find(1) } - end - def test_find_with_multiple_ids_should_quote_pkey - assert_nothing_raised { MixedCaseMonkey.find([1,2]) } - end - def test_instance_update_should_quote_pkey - assert_nothing_raised { MixedCaseMonkey.find(1).save } - end - def test_instance_destroy_should_quote_pkey - assert_nothing_raised { MixedCaseMonkey.find(1).destroy } - end -end diff --git a/vendor/rails/activerecord/test/cases/pooled_connections_test.rb b/vendor/rails/activerecord/test/cases/pooled_connections_test.rb deleted file mode 100644 index 2649a93..0000000 --- a/vendor/rails/activerecord/test/cases/pooled_connections_test.rb +++ /dev/null @@ -1,103 +0,0 @@ -require "cases/helper" - -class PooledConnectionsTest < ActiveRecord::TestCase - def setup - super - @connection = ActiveRecord::Base.remove_connection - end - - def teardown - ActiveRecord::Base.clear_all_connections! - ActiveRecord::Base.establish_connection(@connection) - super - end - - def checkout_connections - ActiveRecord::Base.establish_connection(@connection.merge({:pool => 2, :wait_timeout => 0.3})) - @connections = [] - @timed_out = 0 - - 4.times do - Thread.new do - begin - @connections << ActiveRecord::Base.connection_pool.checkout - rescue ActiveRecord::ConnectionTimeoutError - @timed_out += 1 - end - end.join - end - end - - # Will deadlock due to lack of Monitor timeouts in 1.9 - if RUBY_VERSION < '1.9' - def test_pooled_connection_checkout - checkout_connections - assert_equal @connections.length, 2 - assert_equal @timed_out, 2 - end - end - - def checkout_checkin_connections(pool_size, threads) - ActiveRecord::Base.establish_connection(@connection.merge({:pool => pool_size, :wait_timeout => 0.5})) - @connection_count = 0 - @timed_out = 0 - threads.times do - Thread.new do - begin - conn = ActiveRecord::Base.connection_pool.checkout - sleep 0.1 - ActiveRecord::Base.connection_pool.checkin conn - @connection_count += 1 - rescue ActiveRecord::ConnectionTimeoutError - @timed_out += 1 - end - end.join - end - end - - def test_pooled_connection_checkin_one - checkout_checkin_connections 1, 2 - assert_equal 2, @connection_count - assert_equal 0, @timed_out - end - - def test_pooled_connection_checkin_two - checkout_checkin_connections 2, 3 - assert_equal 3, @connection_count - assert_equal 0, @timed_out - end - - def test_pooled_connection_checkout_existing_first - ActiveRecord::Base.establish_connection(@connection.merge({:pool => 1})) - conn_pool = ActiveRecord::Base.connection_pool - conn = conn_pool.checkout - conn_pool.checkin(conn) - conn = conn_pool.checkout - assert ActiveRecord::ConnectionAdapters::AbstractAdapter === conn - conn_pool.checkin(conn) - end - - def test_not_connected_defined_connection_returns_false - ActiveRecord::Base.establish_connection(@connection) - assert ! ActiveRecord::Base.connected? - end - - def test_undefined_connection_returns_false - old_handler = ActiveRecord::Base.connection_handler - ActiveRecord::Base.connection_handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new - assert_equal false, ActiveRecord::Base.connected? - ensure - ActiveRecord::Base.connection_handler = old_handler - end -end unless %w(FrontBase).include? ActiveRecord::Base.connection.adapter_name - -class AllowConcurrencyDeprecatedTest < ActiveRecord::TestCase - def test_allow_concurrency_is_deprecated - assert_deprecated('ActiveRecord::Base.allow_concurrency') do - ActiveRecord::Base.allow_concurrency - end - assert_deprecated('ActiveRecord::Base.allow_concurrency=') do - ActiveRecord::Base.allow_concurrency = true - end - end -end diff --git a/vendor/rails/activerecord/test/cases/query_cache_test.rb b/vendor/rails/activerecord/test/cases/query_cache_test.rb deleted file mode 100644 index f90a66d..0000000 --- a/vendor/rails/activerecord/test/cases/query_cache_test.rb +++ /dev/null @@ -1,123 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/reply' -require 'models/task' -require 'models/course' -require 'models/category' -require 'models/post' - - -class QueryCacheTest < ActiveRecord::TestCase - fixtures :tasks, :topics, :categories, :posts, :categories_posts - - def test_find_queries - assert_queries(2) { Task.find(1); Task.find(1) } - end - - def test_find_queries_with_cache - Task.cache do - assert_queries(1) { Task.find(1); Task.find(1) } - end - end - - def test_count_queries_with_cache - Task.cache do - assert_queries(1) { Task.count; Task.count } - end - end - - def test_query_cache_dups_results_correctly - Task.cache do - now = Time.now.utc - task = Task.find 1 - assert_not_equal now, task.starting - task.starting = now - task.reload - assert_not_equal now, task.starting - end - end - - def test_cache_is_flat - Task.cache do - Topic.columns # don't count this query - assert_queries(1) { Topic.find(1); Topic.find(1); } - end - - ActiveRecord::Base.cache do - assert_queries(1) { Task.find(1); Task.find(1) } - end - end - - def test_cache_does_not_wrap_string_results_in_arrays - Task.cache do - assert_instance_of String, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks") - end - end -end - -class QueryCacheExpiryTest < ActiveRecord::TestCase - fixtures :tasks, :posts, :categories, :categories_posts - - def test_find - Task.connection.expects(:clear_query_cache).times(1) - - assert !Task.connection.query_cache_enabled - Task.cache do - assert Task.connection.query_cache_enabled - Task.find(1) - - Task.uncached do - assert !Task.connection.query_cache_enabled - Task.find(1) - end - - assert Task.connection.query_cache_enabled - end - assert !Task.connection.query_cache_enabled - end - - def test_update - Task.connection.expects(:clear_query_cache).times(2) - - Task.cache do - task = Task.find(1) - task.starting = Time.now.utc - task.save! - end - end - - def test_destroy - Task.connection.expects(:clear_query_cache).times(2) - - Task.cache do - Task.find(1).destroy - end - end - - def test_insert - ActiveRecord::Base.connection.expects(:clear_query_cache).times(2) - - Task.cache do - Task.create! - end - end - - def test_cache_is_expired_by_habtm_update - ActiveRecord::Base.connection.expects(:clear_query_cache).times(2) - ActiveRecord::Base.cache do - c = Category.find(:first) - p = Post.find(:first) - p.categories << c - end - end - - def test_cache_is_expired_by_habtm_delete - ActiveRecord::Base.connection.expects(:clear_query_cache).times(2) - ActiveRecord::Base.cache do - c = Category.find(1) - p = Post.find(1) - assert p.categories.any? - p.categories.delete_all - end - end -end diff --git a/vendor/rails/activerecord/test/cases/readonly_test.rb b/vendor/rails/activerecord/test/cases/readonly_test.rb deleted file mode 100644 index b921cbd..0000000 --- a/vendor/rails/activerecord/test/cases/readonly_test.rb +++ /dev/null @@ -1,107 +0,0 @@ -require "cases/helper" -require 'models/post' -require 'models/comment' -require 'models/developer' -require 'models/project' -require 'models/reader' -require 'models/person' - -# Dummy class methods to test implicit association scoping. -def Comment.foo() find :first end -def Project.foo() find :first end - - -class ReadOnlyTest < ActiveRecord::TestCase - fixtures :posts, :comments, :developers, :projects, :developers_projects - - def test_cant_save_readonly_record - dev = Developer.find(1) - assert !dev.readonly? - - dev.readonly! - assert dev.readonly? - - assert_nothing_raised do - dev.name = 'Luscious forbidden fruit.' - assert !dev.save - dev.name = 'Forbidden.' - end - assert_raise(ActiveRecord::ReadOnlyRecord) { dev.save } - assert_raise(ActiveRecord::ReadOnlyRecord) { dev.save! } - end - - - def test_find_with_readonly_option - Developer.find(:all).each { |d| assert !d.readonly? } - Developer.find(:all, :readonly => false).each { |d| assert !d.readonly? } - Developer.find(:all, :readonly => true).each { |d| assert d.readonly? } - end - - - def test_find_with_joins_option_implies_readonly - # Blank joins don't count. - Developer.find(:all, :joins => ' ').each { |d| assert !d.readonly? } - Developer.find(:all, :joins => ' ', :readonly => false).each { |d| assert !d.readonly? } - - # Others do. - Developer.find(:all, :joins => ', projects').each { |d| assert d.readonly? } - Developer.find(:all, :joins => ', projects', :readonly => false).each { |d| assert !d.readonly? } - end - - - def test_habtm_find_readonly - dev = Developer.find(1) - assert !dev.projects.empty? - assert dev.projects.all?(&:readonly?) - assert dev.projects.find(:all).all?(&:readonly?) - assert dev.projects.find(:all, :readonly => true).all?(&:readonly?) - end - - def test_has_many_find_readonly - post = Post.find(1) - assert !post.comments.empty? - assert !post.comments.any?(&:readonly?) - assert !post.comments.find(:all).any?(&:readonly?) - assert post.comments.find(:all, :readonly => true).all?(&:readonly?) - end - - def test_has_many_with_through_is_not_implicitly_marked_readonly - assert people = Post.find(1).people - assert !people.any?(&:readonly?) - end - - def test_readonly_scoping - Post.with_scope(:find => { :conditions => '1=1' }) do - assert !Post.find(1).readonly? - assert Post.find(1, :readonly => true).readonly? - assert !Post.find(1, :readonly => false).readonly? - end - - Post.with_scope(:find => { :joins => ' ' }) do - assert !Post.find(1).readonly? - assert Post.find(1, :readonly => true).readonly? - assert !Post.find(1, :readonly => false).readonly? - end - - # Oracle barfs on this because the join includes unqualified and - # conflicting column names - unless current_adapter?(:OracleAdapter) - Post.with_scope(:find => { :joins => ', developers' }) do - assert Post.find(1).readonly? - assert Post.find(1, :readonly => true).readonly? - assert !Post.find(1, :readonly => false).readonly? - end - end - - Post.with_scope(:find => { :readonly => true }) do - assert Post.find(1).readonly? - assert Post.find(1, :readonly => true).readonly? - assert !Post.find(1, :readonly => false).readonly? - end - end - - def test_association_collection_method_missing_scoping_not_readonly - assert !Developer.find(1).projects.foo.readonly? - assert !Post.find(1).comments.foo.readonly? - end -end diff --git a/vendor/rails/activerecord/test/cases/reflection_test.rb b/vendor/rails/activerecord/test/cases/reflection_test.rb deleted file mode 100644 index db64bbb..0000000 --- a/vendor/rails/activerecord/test/cases/reflection_test.rb +++ /dev/null @@ -1,194 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/customer' -require 'models/company' -require 'models/company_in_module' -require 'models/subscriber' -require 'models/pirate' - -class ReflectionTest < ActiveRecord::TestCase - fixtures :topics, :customers, :companies, :subscribers - - def setup - @first = Topic.find(1) - end - - def test_column_null_not_null - subscriber = Subscriber.find(:first) - assert subscriber.column_for_attribute("name").null - assert !subscriber.column_for_attribute("nick").null - end - - def test_read_attribute_names - assert_equal( - %w( id title author_name author_email_address bonus_time written_on last_read content approved replies_count parent_id type ).sort, - @first.attribute_names - ) - end - - def test_columns - assert_equal 12, Topic.columns.length - end - - def test_columns_are_returned_in_the_order_they_were_declared - column_names = Topic.columns.map { |column| column.name } - assert_equal %w(id title author_name author_email_address written_on bonus_time last_read content approved replies_count parent_id type), column_names - end - - def test_content_columns - content_columns = Topic.content_columns - content_column_names = content_columns.map {|column| column.name} - assert_equal 8, content_columns.length - assert_equal %w(title author_name author_email_address written_on bonus_time last_read content approved).sort, content_column_names.sort - end - - def test_column_string_type_and_limit - assert_equal :string, @first.column_for_attribute("title").type - assert_equal 255, @first.column_for_attribute("title").limit - end - - def test_column_null_not_null - subscriber = Subscriber.find(:first) - assert subscriber.column_for_attribute("name").null - assert !subscriber.column_for_attribute("nick").null - end - - def test_human_name_for_column - assert_equal "Author name", @first.column_for_attribute("author_name").human_name - end - - def test_integer_columns - assert_equal :integer, @first.column_for_attribute("id").type - end - - def test_reflection_klass_for_nested_class_name - reflection = ActiveRecord::Reflection::MacroReflection.new(nil, nil, { :class_name => 'MyApplication::Business::Company' }, nil) - assert_nothing_raised do - assert_equal MyApplication::Business::Company, reflection.klass - end - end - - def test_aggregation_reflection - reflection_for_address = ActiveRecord::Reflection::AggregateReflection.new( - :composed_of, :address, { :mapping => [ %w(address_street street), %w(address_city city), %w(address_country country) ] }, Customer - ) - - reflection_for_balance = ActiveRecord::Reflection::AggregateReflection.new( - :composed_of, :balance, { :class_name => "Money", :mapping => %w(balance amount) }, Customer - ) - - reflection_for_gps_location = ActiveRecord::Reflection::AggregateReflection.new( - :composed_of, :gps_location, { }, Customer - ) - - assert Customer.reflect_on_all_aggregations.include?(reflection_for_gps_location) - assert Customer.reflect_on_all_aggregations.include?(reflection_for_balance) - assert Customer.reflect_on_all_aggregations.include?(reflection_for_address) - - assert_equal reflection_for_address, Customer.reflect_on_aggregation(:address) - - assert_equal Address, Customer.reflect_on_aggregation(:address).klass - - assert_equal Money, Customer.reflect_on_aggregation(:balance).klass - end - - def test_reflect_on_all_autosave_associations - expected = Pirate.reflect_on_all_associations.select { |r| r.options[:autosave] } - received = Pirate.reflect_on_all_autosave_associations - - assert !received.empty? - assert_not_equal Pirate.reflect_on_all_associations.length, received.length - assert_equal expected, received - end - - def test_has_many_reflection - reflection_for_clients = ActiveRecord::Reflection::AssociationReflection.new(:has_many, :clients, { :order => "id", :dependent => :destroy }, Firm) - - assert_equal reflection_for_clients, Firm.reflect_on_association(:clients) - - assert_equal Client, Firm.reflect_on_association(:clients).klass - assert_equal 'companies', Firm.reflect_on_association(:clients).table_name - - assert_equal Client, Firm.reflect_on_association(:clients_of_firm).klass - assert_equal 'companies', Firm.reflect_on_association(:clients_of_firm).table_name - end - - def test_has_one_reflection - reflection_for_account = ActiveRecord::Reflection::AssociationReflection.new(:has_one, :account, { :foreign_key => "firm_id", :dependent => :destroy }, Firm) - assert_equal reflection_for_account, Firm.reflect_on_association(:account) - - assert_equal Account, Firm.reflect_on_association(:account).klass - assert_equal 'accounts', Firm.reflect_on_association(:account).table_name - end - - def test_belongs_to_inferred_foreign_key_from_assoc_name - Company.belongs_to :foo - assert_equal "foo_id", Company.reflect_on_association(:foo).primary_key_name - Company.belongs_to :bar, :class_name => "Xyzzy" - assert_equal "bar_id", Company.reflect_on_association(:bar).primary_key_name - Company.belongs_to :baz, :class_name => "Xyzzy", :foreign_key => "xyzzy_id" - assert_equal "xyzzy_id", Company.reflect_on_association(:baz).primary_key_name - end - - def test_association_reflection_in_modules - assert_reflection MyApplication::Business::Firm, - :clients_of_firm, - :klass => MyApplication::Business::Client, - :class_name => 'Client', - :table_name => 'companies' - - assert_reflection MyApplication::Billing::Account, - :firm, - :klass => MyApplication::Business::Firm, - :class_name => 'MyApplication::Business::Firm', - :table_name => 'companies' - - assert_reflection MyApplication::Billing::Account, - :qualified_billing_firm, - :klass => MyApplication::Billing::Firm, - :class_name => 'MyApplication::Billing::Firm', - :table_name => 'companies' - - assert_reflection MyApplication::Billing::Account, - :unqualified_billing_firm, - :klass => MyApplication::Billing::Firm, - :class_name => 'Firm', - :table_name => 'companies' - - assert_reflection MyApplication::Billing::Account, - :nested_qualified_billing_firm, - :klass => MyApplication::Billing::Nested::Firm, - :class_name => 'MyApplication::Billing::Nested::Firm', - :table_name => 'companies' - - assert_reflection MyApplication::Billing::Account, - :nested_unqualified_billing_firm, - :klass => MyApplication::Billing::Nested::Firm, - :class_name => 'Nested::Firm', - :table_name => 'companies' - end - - def test_reflection_of_all_associations - # FIXME these assertions bust a lot - assert_equal 28, Firm.reflect_on_all_associations.size - assert_equal 21, Firm.reflect_on_all_associations(:has_many).size - assert_equal 7, Firm.reflect_on_all_associations(:has_one).size - assert_equal 0, Firm.reflect_on_all_associations(:belongs_to).size - end - - def test_reflection_should_not_raise_error_when_compared_to_other_object - assert_nothing_raised { Firm.reflections[:clients] == Object.new } - end - - def test_has_many_through_reflection - assert_kind_of ActiveRecord::Reflection::ThroughReflection, Subscriber.reflect_on_association(:books) - end - - private - def assert_reflection(klass, association, options) - assert reflection = klass.reflect_on_association(association) - options.each do |method, value| - assert_equal(value, reflection.send(method)) - end - end -end diff --git a/vendor/rails/activerecord/test/cases/reload_models_test.rb b/vendor/rails/activerecord/test/cases/reload_models_test.rb deleted file mode 100644 index 0d16a35..0000000 --- a/vendor/rails/activerecord/test/cases/reload_models_test.rb +++ /dev/null @@ -1,22 +0,0 @@ -require "cases/helper" -require 'models/owner' -require 'models/pet' - -class ReloadModelsTest < ActiveRecord::TestCase - fixtures :pets - - def test_has_one_with_reload - pet = Pet.find_by_name('parrot') - pet.owner = Owner.find_by_name('ashley') - - # Reload the class Owner, simulating auto-reloading of model classes in a - # development environment. Note that meanwhile the class Pet is not - # reloaded, simulating a class that is present in a plugin. - Object.class_eval { remove_const :Owner } - Kernel.load(File.expand_path(File.join(File.dirname(__FILE__), "../models/owner.rb"))) - - pet = Pet.find_by_name('parrot') - pet.owner = Owner.find_by_name('ashley') - assert_equal pet.owner, Owner.find_by_name('ashley') - end -end diff --git a/vendor/rails/activerecord/test/cases/repair_helper.rb b/vendor/rails/activerecord/test/cases/repair_helper.rb deleted file mode 100644 index 0155668..0000000 --- a/vendor/rails/activerecord/test/cases/repair_helper.rb +++ /dev/null @@ -1,50 +0,0 @@ -module ActiveRecord - module Testing - module RepairHelper - def self.included(base) - base.class_eval do - extend ClassMethods - end - end - - module Toolbox - def self.record_validations(*model_classes) - model_classes.inject({}) do |repair, klass| - repair[klass] ||= {} - [:validate, :validate_on_create, :validate_on_update].each do |callback| - the_callback = klass.instance_variable_get("@#{callback.to_s}_callbacks") - repair[klass][callback] = (the_callback.nil? ? nil : the_callback.dup) - end - repair - end - end - - def self.reset_validations(recorded) - recorded.each do |klass, repairs| - [:validate, :validate_on_create, :validate_on_update].each do |callback| - klass.instance_variable_set("@#{callback.to_s}_callbacks", repairs[callback]) - end - end - end - end - - module ClassMethods - def repair_validations(*model_classes) - setup do - @validation_repairs = ActiveRecord::Testing::RepairHelper::Toolbox.record_validations(*model_classes) - end - teardown do - ActiveRecord::Testing::RepairHelper::Toolbox.reset_validations(@validation_repairs) - end - end - end - - def repair_validations(*model_classes, &block) - validation_repairs = ActiveRecord::Testing::RepairHelper::Toolbox.record_validations(*model_classes) - return block.call - ensure - ActiveRecord::Testing::RepairHelper::Toolbox.reset_validations(validation_repairs) - end - end - end -end diff --git a/vendor/rails/activerecord/test/cases/reserved_word_test_mysql.rb b/vendor/rails/activerecord/test/cases/reserved_word_test_mysql.rb deleted file mode 100644 index ce1622b..0000000 --- a/vendor/rails/activerecord/test/cases/reserved_word_test_mysql.rb +++ /dev/null @@ -1,176 +0,0 @@ -require "cases/helper" - -class Group < ActiveRecord::Base - Group.table_name = 'group' - belongs_to :select, :class_name => 'Select' - has_one :values -end - -class Select < ActiveRecord::Base - Select.table_name = 'select' - has_many :groups -end - -class Values < ActiveRecord::Base - Values.table_name = 'values' -end - -class Distinct < ActiveRecord::Base - Distinct.table_name = 'distinct' - has_and_belongs_to_many :selects - has_many :values, :through => :groups -end - -# a suite of tests to ensure the ConnectionAdapters#MysqlAdapter can handle tables with -# reserved word names (ie: group, order, values, etc...) -class MysqlReservedWordTest < ActiveRecord::TestCase - def setup - @connection = ActiveRecord::Base.connection - - # we call execute directly here (and do similar below) because ActiveRecord::Base#create_table() - # will fail with these table names if these test cases fail - - create_tables_directly 'group'=>'id int auto_increment primary key, `order` varchar(255), select_id int', - 'select'=>'id int auto_increment primary key', - 'values'=>'id int auto_increment primary key, group_id int', - 'distinct'=>'id int auto_increment primary key', - 'distincts_selects'=>'distinct_id int, select_id int' - end - - def teardown - drop_tables_directly ['group', 'select', 'values', 'distinct', 'distincts_selects', 'order'] - end - - # create tables with reserved-word names and columns - def test_create_tables - assert_nothing_raised { - @connection.create_table :order do |t| - t.column :group, :string - end - } - end - - # rename tables with reserved-word names - def test_rename_tables - assert_nothing_raised { @connection.rename_table(:group, :order) } - end - - # alter column with a reserved-word name in a table with a reserved-word name - def test_change_columns - assert_nothing_raised { @connection.change_column_default(:group, :order, 'whatever') } - #the quoting here will reveal any double quoting issues in change_column's interaction with the column method in the adapter - assert_nothing_raised { @connection.change_column('group', 'order', :Int, :default => 0) } - assert_nothing_raised { @connection.rename_column(:group, :order, :values) } - end - - # dump structure of table with reserved word name - def test_structure_dump - assert_nothing_raised { @connection.structure_dump } - end - - # introspect table with reserved word name - def test_introspect - assert_nothing_raised { @connection.columns(:group) } - assert_nothing_raised { @connection.indexes(:group) } - end - - #fixtures - self.use_instantiated_fixtures = true - self.use_transactional_fixtures = false - - #fixtures :group - - def test_fixtures - f = create_test_fixtures :select, :distinct, :group, :values, :distincts_selects - - assert_nothing_raised { - f.each do |x| - x.delete_existing_fixtures - end - } - - assert_nothing_raised { - f.each do |x| - x.insert_fixtures - end - } - end - - #activerecord model class with reserved-word table name - def test_activerecord_model - create_test_fixtures :select, :distinct, :group, :values, :distincts_selects - x = nil - assert_nothing_raised { x = Group.new } - x.order = 'x' - assert_nothing_raised { x.save } - x.order = 'y' - assert_nothing_raised { x.save } - assert_nothing_raised { y = Group.find_by_order('y') } - assert_nothing_raised { y = Group.find(1) } - x = Group.find(1) - end - - # has_one association with reserved-word table name - def test_has_one_associations - create_test_fixtures :select, :distinct, :group, :values, :distincts_selects - v = nil - assert_nothing_raised { v = Group.find(1).values } - assert_equal v.id, 2 - end - - # belongs_to association with reserved-word table name - def test_belongs_to_associations - create_test_fixtures :select, :distinct, :group, :values, :distincts_selects - gs = nil - assert_nothing_raised { gs = Select.find(2).groups } - assert_equal gs.length, 2 - assert(gs.collect{|x| x.id}.sort == [2, 3]) - end - - # has_and_belongs_to_many with reserved-word table name - def test_has_and_belongs_to_many - create_test_fixtures :select, :distinct, :group, :values, :distincts_selects - s = nil - assert_nothing_raised { s = Distinct.find(1).selects } - assert_equal s.length, 2 - assert(s.collect{|x|x.id}.sort == [1, 2]) - end - - # activerecord model introspection with reserved-word table and column names - def test_activerecord_introspection - assert_nothing_raised { Group.table_exists? } - assert_nothing_raised { Group.columns } - end - - # Calculations - def test_calculations_work_with_reserved_words - assert_nothing_raised { Group.count } - end - - def test_associations_work_with_reserved_words - assert_nothing_raised { Select.find(:all, :include => [:groups]) } - end - - #the following functions were added to DRY test cases - - private - # custom fixture loader, uses Fixtures#create_fixtures and appends base_path to the current file's path - def create_test_fixtures(*fixture_names) - Fixtures.create_fixtures(FIXTURES_ROOT + "/reserved_words", fixture_names) - end - - # custom drop table, uses execute on connection to drop a table if it exists. note: escapes table_name - def drop_tables_directly(table_names, connection = @connection) - table_names.each do |name| - connection.execute("DROP TABLE IF EXISTS `#{name}`") - end - end - - # custom create table, uses execute on connection to create a table, note: escapes table_name, does NOT escape columns - def create_tables_directly (tables, connection = @connection) - tables.each do |table_name, column_properties| - connection.execute("CREATE TABLE `#{table_name}` ( #{column_properties} )") - end - end - -end diff --git a/vendor/rails/activerecord/test/cases/sanitize_test.rb b/vendor/rails/activerecord/test/cases/sanitize_test.rb deleted file mode 100644 index 817897c..0000000 --- a/vendor/rails/activerecord/test/cases/sanitize_test.rb +++ /dev/null @@ -1,25 +0,0 @@ -require "cases/helper" -require 'models/binary' - -class SanitizeTest < ActiveRecord::TestCase - def setup - end - - def test_sanitize_sql_array_handles_string_interpolation - quoted_bambi = ActiveRecord::Base.connection.quote_string("Bambi") - assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=%s", "Bambi"]) - assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=%s", "Bambi".mb_chars]) - quoted_bambi_and_thumper = ActiveRecord::Base.connection.quote_string("Bambi\nand\nThumper") - assert_equal "name=#{quoted_bambi_and_thumper}",Binary.send(:sanitize_sql_array, ["name=%s", "Bambi\nand\nThumper"]) - assert_equal "name=#{quoted_bambi_and_thumper}",Binary.send(:sanitize_sql_array, ["name=%s", "Bambi\nand\nThumper".mb_chars]) - end - - def test_sanitize_sql_array_handles_bind_variables - quoted_bambi = ActiveRecord::Base.connection.quote("Bambi") - assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi"]) - assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi".mb_chars]) - quoted_bambi_and_thumper = ActiveRecord::Base.connection.quote("Bambi\nand\nThumper") - assert_equal "name=#{quoted_bambi_and_thumper}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi\nand\nThumper"]) - assert_equal "name=#{quoted_bambi_and_thumper}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi\nand\nThumper".mb_chars]) - end -end diff --git a/vendor/rails/activerecord/test/cases/schema_authorization_test_postgresql.rb b/vendor/rails/activerecord/test/cases/schema_authorization_test_postgresql.rb deleted file mode 100644 index ba77545..0000000 --- a/vendor/rails/activerecord/test/cases/schema_authorization_test_postgresql.rb +++ /dev/null @@ -1,75 +0,0 @@ -require "cases/helper" - -class SchemaThing < ActiveRecord::Base -end - -class SchemaAuthorizationTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - TABLE_NAME = 'schema_things' - COLUMNS = [ - 'id serial primary key', - 'name character varying(50)' - ] - USERS = ['rails_pg_schema_user1', 'rails_pg_schema_user2'] - - def setup - @connection = ActiveRecord::Base.connection - @connection.execute "SET search_path TO '$user',public" - set_session_auth - USERS.each do |u| - @connection.execute "CREATE USER #{u}" rescue nil - @connection.execute "CREATE SCHEMA AUTHORIZATION #{u}" rescue nil - set_session_auth u - @connection.execute "CREATE TABLE #{TABLE_NAME} (#{COLUMNS.join(',')})" - @connection.execute "INSERT INTO #{TABLE_NAME} (name) VALUES ('#{u}')" - set_session_auth - end - end - - def teardown - set_session_auth - @connection.execute "RESET search_path" - USERS.each do |u| - @connection.execute "DROP SCHEMA #{u} CASCADE" - @connection.execute "DROP USER #{u}" - end - end - - def test_schema_invisible - assert_raise(ActiveRecord::StatementInvalid) do - set_session_auth - @connection.execute "SELECT * FROM #{TABLE_NAME}" - end - end - - def test_schema_uniqueness - assert_nothing_raised do - set_session_auth - USERS.each do |u| - set_session_auth u - assert_equal u, @connection.select_value("SELECT name FROM #{TABLE_NAME} WHERE id = 1") - set_session_auth - end - end - end - - def test_sequence_schema_caching - assert_nothing_raised do - USERS.each do |u| - set_session_auth u - st = SchemaThing.new :name => 'TEST1' - st.save! - st = SchemaThing.new :id => 5, :name => 'TEST2' - st.save! - set_session_auth - end - end - end - - private - def set_session_auth auth = nil - @connection.execute "SET SESSION AUTHORIZATION #{auth || 'default'}" - end - -end diff --git a/vendor/rails/activerecord/test/cases/schema_dumper_test.rb b/vendor/rails/activerecord/test/cases/schema_dumper_test.rb deleted file mode 100644 index 17e4c75..0000000 --- a/vendor/rails/activerecord/test/cases/schema_dumper_test.rb +++ /dev/null @@ -1,183 +0,0 @@ -require "cases/helper" -require 'stringio' - - -class SchemaDumperTest < ActiveRecord::TestCase - def standard_dump - stream = StringIO.new - ActiveRecord::SchemaDumper.ignore_tables = [] - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) - stream.string - end - - def test_schema_dump - output = standard_dump - assert_match %r{create_table "accounts"}, output - assert_match %r{create_table "authors"}, output - assert_no_match %r{create_table "schema_migrations"}, output - end - - def test_schema_dump_excludes_sqlite_sequence - output = standard_dump - assert_no_match %r{create_table "sqlite_sequence"}, output - end - - def assert_line_up(lines, pattern, required = false) - return assert(true) if lines.empty? - matches = lines.map { |line| line.match(pattern) } - assert matches.all? if required - matches.compact! - return assert(true) if matches.empty? - assert_equal 1, matches.map{ |match| match.offset(0).first }.uniq.length - end - - def column_definition_lines(output = standard_dump) - output.scan(/^( *)create_table.*?\n(.*?)^\1end/m).map{ |m| m.last.split(/\n/) } - end - - def test_types_line_up - column_definition_lines.each do |column_set| - next if column_set.empty? - - lengths = column_set.map do |column| - if match = column.match(/t\.(?:integer|decimal|float|datetime|timestamp|time|date|text|binary|string|boolean)\s+"/) - match[0].length - end - end - - assert_equal 1, lengths.uniq.length - end - end - - def test_arguments_line_up - column_definition_lines.each do |column_set| - assert_line_up(column_set, /:default => /) - assert_line_up(column_set, /:limit => /) - assert_line_up(column_set, /:null => /) - end - end - - def test_no_dump_errors - output = standard_dump - assert_no_match %r{\# Could not dump table}, output - end - - def test_schema_dump_includes_not_null_columns - stream = StringIO.new - - ActiveRecord::SchemaDumper.ignore_tables = [/^[^r]/] - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) - output = stream.string - assert_match %r{:null => false}, output - end - - def test_schema_dump_includes_limit_constraint_for_integer_columns - stream = StringIO.new - - ActiveRecord::SchemaDumper.ignore_tables = [/^(?!integer_limits)/] - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) - output = stream.string - - if current_adapter?(:PostgreSQLAdapter) - assert_match %r{c_int_1.*:limit => 2}, output - assert_match %r{c_int_2.*:limit => 2}, output - - # int 3 is 4 bytes in postgresql - assert_match %r{c_int_3.*}, output - assert_no_match %r{c_int_3.*:limit}, output - - assert_match %r{c_int_4.*}, output - assert_no_match %r{c_int_4.*:limit}, output - elsif current_adapter?(:MysqlAdapter) - assert_match %r{c_int_1.*:limit => 1}, output - assert_match %r{c_int_2.*:limit => 2}, output - assert_match %r{c_int_3.*:limit => 3}, output - - assert_match %r{c_int_4.*}, output - assert_no_match %r{c_int_4.*:limit}, output - elsif current_adapter?(:SQLiteAdapter) - assert_match %r{c_int_1.*:limit => 1}, output - assert_match %r{c_int_2.*:limit => 2}, output - assert_match %r{c_int_3.*:limit => 3}, output - assert_match %r{c_int_4.*:limit => 4}, output - end - assert_match %r{c_int_without_limit.*}, output - assert_no_match %r{c_int_without_limit.*:limit}, output - - if current_adapter?(:SQLiteAdapter) - assert_match %r{c_int_5.*:limit => 5}, output - assert_match %r{c_int_6.*:limit => 6}, output - assert_match %r{c_int_7.*:limit => 7}, output - assert_match %r{c_int_8.*:limit => 8}, output - else - assert_match %r{c_int_5.*:limit => 8}, output - assert_match %r{c_int_6.*:limit => 8}, output - assert_match %r{c_int_7.*:limit => 8}, output - assert_match %r{c_int_8.*:limit => 8}, output - end - end - - def test_schema_dump_with_string_ignored_table - stream = StringIO.new - - ActiveRecord::SchemaDumper.ignore_tables = ['accounts'] - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) - output = stream.string - assert_no_match %r{create_table "accounts"}, output - assert_match %r{create_table "authors"}, output - assert_no_match %r{create_table "schema_migrations"}, output - end - - def test_schema_dump_with_regexp_ignored_table - stream = StringIO.new - - ActiveRecord::SchemaDumper.ignore_tables = [/^account/] - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) - output = stream.string - assert_no_match %r{create_table "accounts"}, output - assert_match %r{create_table "authors"}, output - assert_no_match %r{create_table "schema_migrations"}, output - end - - def test_schema_dump_illegal_ignored_table_value - stream = StringIO.new - ActiveRecord::SchemaDumper.ignore_tables = [5] - assert_raise(StandardError) do - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) - end - end - - if current_adapter?(:MysqlAdapter) - def test_schema_dump_should_not_add_default_value_for_mysql_text_field - output = standard_dump - assert_match %r{t.text\s+"body",\s+:null => false$}, output - end - - def test_mysql_schema_dump_should_honor_nonstandard_primary_keys - output = standard_dump - match = output.match(%r{create_table "movies"(.*)do}) - assert_not_nil(match, "nonstandardpk table not found") - assert_match %r(:primary_key => "movieid"), match[1], "non-standard primary key not preserved" - end - - def test_schema_dump_includes_length_for_mysql_blob_and_text_fields - output = standard_dump - assert_match %r{t.binary\s+"tiny_blob",\s+:limit => 255$}, output - assert_match %r{t.binary\s+"normal_blob"$}, output - assert_match %r{t.binary\s+"medium_blob",\s+:limit => 16777215$}, output - assert_match %r{t.binary\s+"long_blob",\s+:limit => 2147483647$}, output - assert_match %r{t.text\s+"tiny_text",\s+:limit => 255$}, output - assert_match %r{t.text\s+"normal_text"$}, output - assert_match %r{t.text\s+"medium_text",\s+:limit => 16777215$}, output - assert_match %r{t.text\s+"long_text",\s+:limit => 2147483647$}, output - end - end - - def test_schema_dump_includes_decimal_options - stream = StringIO.new - ActiveRecord::SchemaDumper.ignore_tables = [/^[^n]/] - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) - output = stream.string - assert_match %r{:precision => 3,[[:space:]]+:scale => 2,[[:space:]]+:default => 2.78}, output - end -end diff --git a/vendor/rails/activerecord/test/cases/schema_test_postgresql.rb b/vendor/rails/activerecord/test/cases/schema_test_postgresql.rb deleted file mode 100644 index 336a387..0000000 --- a/vendor/rails/activerecord/test/cases/schema_test_postgresql.rb +++ /dev/null @@ -1,102 +0,0 @@ -require "cases/helper" - -class SchemaTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - SCHEMA_NAME = 'test_schema' - SCHEMA2_NAME = 'test_schema2' - TABLE_NAME = 'things' - INDEX_A_NAME = 'a_index_things_on_name' - INDEX_B_NAME = 'b_index_things_on_different_columns_in_each_schema' - INDEX_A_COLUMN = 'name' - INDEX_B_COLUMN_S1 = 'email' - INDEX_B_COLUMN_S2 = 'moment' - COLUMNS = [ - 'id integer', - 'name character varying(50)', - 'email character varying(50)', - 'moment timestamp without time zone default now()' - ] - - def setup - @connection = ActiveRecord::Base.connection - @connection.execute "CREATE SCHEMA #{SCHEMA_NAME} CREATE TABLE #{TABLE_NAME} (#{COLUMNS.join(',')})" - @connection.execute "CREATE SCHEMA #{SCHEMA2_NAME} CREATE TABLE #{TABLE_NAME} (#{COLUMNS.join(',')})" - @connection.execute "CREATE INDEX #{INDEX_A_NAME} ON #{SCHEMA_NAME}.#{TABLE_NAME} USING btree (#{INDEX_A_COLUMN});" - @connection.execute "CREATE INDEX #{INDEX_A_NAME} ON #{SCHEMA2_NAME}.#{TABLE_NAME} USING btree (#{INDEX_A_COLUMN});" - @connection.execute "CREATE INDEX #{INDEX_B_NAME} ON #{SCHEMA_NAME}.#{TABLE_NAME} USING btree (#{INDEX_B_COLUMN_S1});" - @connection.execute "CREATE INDEX #{INDEX_B_NAME} ON #{SCHEMA2_NAME}.#{TABLE_NAME} USING btree (#{INDEX_B_COLUMN_S2});" - end - - def teardown - @connection.execute "DROP SCHEMA #{SCHEMA2_NAME} CASCADE" - @connection.execute "DROP SCHEMA #{SCHEMA_NAME} CASCADE" - end - - def test_with_schema_prefixed_table_name - assert_nothing_raised do - assert_equal COLUMNS, columns("#{SCHEMA_NAME}.#{TABLE_NAME}") - end - end - - def test_with_schema_search_path - assert_nothing_raised do - with_schema_search_path(SCHEMA_NAME) do - assert_equal COLUMNS, columns(TABLE_NAME) - end - end - end - - def test_raise_on_unquoted_schema_name - assert_raise(ActiveRecord::StatementInvalid) do - with_schema_search_path '$user,public' - end - end - - def test_without_schema_search_path - assert_raise(ActiveRecord::StatementInvalid) { columns(TABLE_NAME) } - end - - def test_ignore_nil_schema_search_path - assert_nothing_raised { with_schema_search_path nil } - end - - def test_dump_indexes_for_schema_one - do_dump_index_tests_for_schema(SCHEMA_NAME, INDEX_A_COLUMN, INDEX_B_COLUMN_S1) - end - - def test_dump_indexes_for_schema_two - do_dump_index_tests_for_schema(SCHEMA2_NAME, INDEX_A_COLUMN, INDEX_B_COLUMN_S2) - end - - private - def columns(table_name) - @connection.send(:column_definitions, table_name).map do |name, type, default| - "#{name} #{type}" + (default ? " default #{default}" : '') - end - end - - def with_schema_search_path(schema_search_path) - @connection.schema_search_path = schema_search_path - yield if block_given? - ensure - @connection.schema_search_path = "'$user', public" - end - - def do_dump_index_tests_for_schema(this_schema_name, first_index_column_name, second_index_column_name) - with_schema_search_path(this_schema_name) do - indexes = @connection.indexes(TABLE_NAME).sort_by {|i| i.name} - assert_equal 2,indexes.size - - do_dump_index_assertions_for_one_index(indexes[0], INDEX_A_NAME, first_index_column_name) - do_dump_index_assertions_for_one_index(indexes[1], INDEX_B_NAME, second_index_column_name) - end - end - - def do_dump_index_assertions_for_one_index(this_index, this_index_name, this_index_column) - assert_equal TABLE_NAME, this_index.table - assert_equal 1, this_index.columns.size - assert_equal this_index_column, this_index.columns[0] - assert_equal this_index_name, this_index.name - end -end diff --git a/vendor/rails/activerecord/test/cases/serialization_test.rb b/vendor/rails/activerecord/test/cases/serialization_test.rb deleted file mode 100644 index 8841694..0000000 --- a/vendor/rails/activerecord/test/cases/serialization_test.rb +++ /dev/null @@ -1,47 +0,0 @@ -require "cases/helper" -require 'models/contact' - -class SerializationTest < ActiveRecord::TestCase - FORMATS = [ :xml, :json ] - - def setup - @contact_attributes = { - :name => 'aaron stack', - :age => 25, - :avatar => 'binarydata', - :created_at => Time.utc(2006, 8, 1), - :awesome => false, - :preferences => { :gem => '<strong>ruby</strong>' } - } - - @contact = Contact.new(@contact_attributes) - end - - def test_serialize_should_be_reversible - for format in FORMATS - @serialized = Contact.new.send("to_#{format}") - contact = Contact.new.send("from_#{format}", @serialized) - - assert_equal @contact_attributes.keys.collect(&:to_s).sort, contact.attributes.keys.collect(&:to_s).sort, "For #{format}" - end - end - - def test_serialize_should_allow_attribute_only_filtering - for format in FORMATS - @serialized = Contact.new(@contact_attributes).send("to_#{format}", :only => [ :age, :name ]) - contact = Contact.new.send("from_#{format}", @serialized) - assert_equal @contact_attributes[:name], contact.name, "For #{format}" - assert_nil contact.avatar, "For #{format}" - end - end - - def test_serialize_should_allow_attribute_except_filtering - for format in FORMATS - @serialized = Contact.new(@contact_attributes).send("to_#{format}", :except => [ :age, :name ]) - contact = Contact.new.send("from_#{format}", @serialized) - assert_nil contact.name, "For #{format}" - assert_nil contact.age, "For #{format}" - assert_equal @contact_attributes[:awesome], contact.awesome, "For #{format}" - end - end -end diff --git a/vendor/rails/activerecord/test/cases/synonym_test_oracle.rb b/vendor/rails/activerecord/test/cases/synonym_test_oracle.rb deleted file mode 100644 index b9a422a..0000000 --- a/vendor/rails/activerecord/test/cases/synonym_test_oracle.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/subject' - -# confirm that synonyms work just like tables; in this case -# the "subjects" table in Oracle (defined in oci.sql) is just -# a synonym to the "topics" table - -class TestOracleSynonym < ActiveRecord::TestCase - - def test_oracle_synonym - topic = Topic.new - subject = Subject.new - assert_equal(topic.attributes, subject.attributes) - end - -end diff --git a/vendor/rails/activerecord/test/cases/transactions_test.rb b/vendor/rails/activerecord/test/cases/transactions_test.rb deleted file mode 100644 index f6533b5..0000000 --- a/vendor/rails/activerecord/test/cases/transactions_test.rb +++ /dev/null @@ -1,522 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/reply' -require 'models/developer' -require 'models/book' - -class TransactionTest < ActiveRecord::TestCase - self.use_transactional_fixtures = false - fixtures :topics, :developers - - def setup - @first, @second = Topic.find(1, 2).sort_by { |t| t.id } - end - - def test_successful - Topic.transaction do - @first.approved = true - @second.approved = false - @first.save - @second.save - end - - assert Topic.find(1).approved?, "First should have been approved" - assert !Topic.find(2).approved?, "Second should have been unapproved" - end - - def transaction_with_return - Topic.transaction do - @first.approved = true - @second.approved = false - @first.save - @second.save - return - end - end - - def test_successful_with_return - class << Topic.connection - alias :real_commit_db_transaction :commit_db_transaction - def commit_db_transaction - $committed = true - real_commit_db_transaction - end - end - - $committed = false - transaction_with_return - assert $committed - - assert Topic.find(1).approved?, "First should have been approved" - assert !Topic.find(2).approved?, "Second should have been unapproved" - ensure - class << Topic.connection - alias :commit_db_transaction :real_commit_db_transaction rescue nil - end - end - - def test_successful_with_instance_method - @first.transaction do - @first.approved = true - @second.approved = false - @first.save - @second.save - end - - assert Topic.find(1).approved?, "First should have been approved" - assert !Topic.find(2).approved?, "Second should have been unapproved" - end - - def test_failing_on_exception - begin - Topic.transaction do - @first.approved = true - @second.approved = false - @first.save - @second.save - raise "Bad things!" - end - rescue - # caught it - end - - assert @first.approved?, "First should still be changed in the objects" - assert !@second.approved?, "Second should still be changed in the objects" - - assert !Topic.find(1).approved?, "First shouldn't have been approved" - assert Topic.find(2).approved?, "Second should still be approved" - end - - def test_raising_exception_in_callback_rollbacks_in_save - add_exception_raising_after_save_callback_to_topic - - begin - @first.approved = true - @first.save - flunk - rescue => e - assert_equal "Make the transaction rollback", e.message - assert !Topic.find(1).approved? - ensure - remove_exception_raising_after_save_callback_to_topic - end - end - - def test_cancellation_from_before_destroy_rollbacks_in_destroy - add_cancelling_before_destroy_with_db_side_effect_to_topic - begin - nbooks_before_destroy = Book.count - status = @first.destroy - assert !status - assert_nothing_raised(ActiveRecord::RecordNotFound) { @first.reload } - assert_equal nbooks_before_destroy, Book.count - ensure - remove_cancelling_before_destroy_with_db_side_effect_to_topic - end - end - - def test_cancellation_from_before_filters_rollbacks_in_save - %w(validation save).each do |filter| - send("add_cancelling_before_#{filter}_with_db_side_effect_to_topic") - begin - nbooks_before_save = Book.count - original_author_name = @first.author_name - @first.author_name += '_this_should_not_end_up_in_the_db' - status = @first.save - assert !status - assert_equal original_author_name, @first.reload.author_name - assert_equal nbooks_before_save, Book.count - ensure - send("remove_cancelling_before_#{filter}_with_db_side_effect_to_topic") - end - end - end - - def test_cancellation_from_before_filters_rollbacks_in_save! - %w(validation save).each do |filter| - send("add_cancelling_before_#{filter}_with_db_side_effect_to_topic") - begin - nbooks_before_save = Book.count - original_author_name = @first.author_name - @first.author_name += '_this_should_not_end_up_in_the_db' - @first.save! - flunk - rescue => e - assert_equal original_author_name, @first.reload.author_name - assert_equal nbooks_before_save, Book.count - ensure - send("remove_cancelling_before_#{filter}_with_db_side_effect_to_topic") - end - end - end - - def test_callback_rollback_in_create - new_topic = Topic.new( - :title => "A new topic", - :author_name => "Ben", - :author_email_address => "ben@example.com", - :written_on => "2003-07-16t15:28:11.2233+01:00", - :last_read => "2004-04-15", - :bonus_time => "2005-01-30t15:28:00.00+01:00", - :content => "Have a nice day", - :approved => false) - new_record_snapshot = new_topic.new_record? - id_present = new_topic.has_attribute?(Topic.primary_key) - id_snapshot = new_topic.id - - # Make sure the second save gets the after_create callback called. - 2.times do - begin - add_exception_raising_after_create_callback_to_topic - new_topic.approved = true - new_topic.save - flunk - rescue => e - assert_equal "Make the transaction rollback", e.message - assert_equal new_record_snapshot, new_topic.new_record?, "The topic should have its old new_record value" - assert_equal id_snapshot, new_topic.id, "The topic should have its old id" - assert_equal id_present, new_topic.has_attribute?(Topic.primary_key) - ensure - remove_exception_raising_after_create_callback_to_topic - end - end - end - - def test_nested_explicit_transactions - Topic.transaction do - Topic.transaction do - @first.approved = true - @second.approved = false - @first.save - @second.save - end - end - - assert Topic.find(1).approved?, "First should have been approved" - assert !Topic.find(2).approved?, "Second should have been unapproved" - end - - def test_manually_rolling_back_a_transaction - Topic.transaction do - @first.approved = true - @second.approved = false - @first.save - @second.save - - raise ActiveRecord::Rollback - end - - assert @first.approved?, "First should still be changed in the objects" - assert !@second.approved?, "Second should still be changed in the objects" - - assert !Topic.find(1).approved?, "First shouldn't have been approved" - assert Topic.find(2).approved?, "Second should still be approved" - end - - def test_invalid_keys_for_transaction - assert_raise ArgumentError do - Topic.transaction :nested => true do - end - end - end - - def test_force_savepoint_in_nested_transaction - Topic.transaction do - @first.approved = true - @second.approved = false - @first.save! - @second.save! - - begin - Topic.transaction :requires_new => true do - @first.happy = false - @first.save! - raise - end - rescue - end - end - - assert @first.reload.approved? - assert !@second.reload.approved? - end if Topic.connection.supports_savepoints? - - def test_no_savepoint_in_nested_transaction_without_force - Topic.transaction do - @first.approved = true - @second.approved = false - @first.save! - @second.save! - - begin - Topic.transaction do - @first.approved = false - @first.save! - raise - end - rescue - end - end - - assert !@first.reload.approved? - assert !@second.reload.approved? - end if Topic.connection.supports_savepoints? - - def test_many_savepoints - Topic.transaction do - @first.content = "One" - @first.save! - - begin - Topic.transaction :requires_new => true do - @first.content = "Two" - @first.save! - - begin - Topic.transaction :requires_new => true do - @first.content = "Three" - @first.save! - - begin - Topic.transaction :requires_new => true do - @first.content = "Four" - @first.save! - raise - end - rescue - end - - @three = @first.reload.content - raise - end - rescue - end - - @two = @first.reload.content - raise - end - rescue - end - - @one = @first.reload.content - end - - assert_equal "One", @one - assert_equal "Two", @two - assert_equal "Three", @three - end if Topic.connection.supports_savepoints? - - def test_rollback_when_commit_raises - Topic.connection.expects(:begin_db_transaction) - Topic.connection.expects(:commit_db_transaction).raises('OH NOES') - Topic.connection.expects(:outside_transaction?).returns(false) - Topic.connection.expects(:rollback_db_transaction) - - assert_raise RuntimeError do - Topic.transaction do - # do nothing - end - end - end - - if current_adapter?(:PostgreSQLAdapter) && defined?(PGconn::PQTRANS_IDLE) - def test_outside_transaction_works - assert Topic.connection.outside_transaction? - Topic.connection.begin_db_transaction - assert !Topic.connection.outside_transaction? - Topic.connection.rollback_db_transaction - assert Topic.connection.outside_transaction? - end - - def test_rollback_wont_be_executed_if_no_transaction_active - assert_raise RuntimeError do - Topic.transaction do - Topic.connection.rollback_db_transaction - Topic.connection.expects(:rollback_db_transaction).never - raise "Rails doesn't scale!" - end - end - end - - def test_open_transactions_count_is_reset_to_zero_if_no_transaction_active - Topic.transaction do - Topic.transaction do - Topic.connection.rollback_db_transaction - end - assert_equal 0, Topic.connection.open_transactions - end - assert_equal 0, Topic.connection.open_transactions - end - end - - def test_sqlite_add_column_in_transaction - return true unless current_adapter?(:SQLite3Adapter, :SQLiteAdapter) - - # Test first if column creation/deletion works correctly when no - # transaction is in place. - # - # We go back to the connection for the column queries because - # Topic.columns is cached and won't report changes to the DB - - assert_nothing_raised do - Topic.reset_column_information - Topic.connection.add_column('topics', 'stuff', :string) - assert Topic.column_names.include?('stuff') - - Topic.reset_column_information - Topic.connection.remove_column('topics', 'stuff') - assert !Topic.column_names.include?('stuff') - end - - if Topic.connection.supports_ddl_transactions? - assert_nothing_raised do - Topic.transaction { Topic.connection.add_column('topics', 'stuff', :string) } - end - else - Topic.transaction do - assert_raise(ActiveRecord::StatementInvalid) { Topic.connection.add_column('topics', 'stuff', :string) } - raise ActiveRecord::Rollback - end - end - end - - private - def add_exception_raising_after_save_callback_to_topic - Topic.class_eval { def after_save() raise "Make the transaction rollback" end } - end - - def remove_exception_raising_after_save_callback_to_topic - Topic.class_eval { remove_method :after_save } - end - - def add_exception_raising_after_create_callback_to_topic - Topic.class_eval { def after_create() raise "Make the transaction rollback" end } - end - - def remove_exception_raising_after_create_callback_to_topic - Topic.class_eval { remove_method :after_create } - end - - %w(validation save destroy).each do |filter| - define_method("add_cancelling_before_#{filter}_with_db_side_effect_to_topic") do - Topic.class_eval "def before_#{filter}() Book.create; false end" - end - - define_method("remove_cancelling_before_#{filter}_with_db_side_effect_to_topic") do - Topic.class_eval "remove_method :before_#{filter}" - end - end -end - -class TransactionsWithTransactionalFixturesTest < ActiveRecord::TestCase - self.use_transactional_fixtures = true - fixtures :topics - - def test_automatic_savepoint_in_outer_transaction - @first = Topic.find(1) - - begin - Topic.transaction do - @first.approved = true - @first.save! - raise - end - rescue - assert !@first.reload.approved? - end - end - - def test_no_automatic_savepoint_for_inner_transaction - @first = Topic.find(1) - - Topic.transaction do - @first.approved = true - @first.save! - - begin - Topic.transaction do - @first.approved = false - @first.save! - raise - end - rescue - end - end - - assert !@first.reload.approved? - end -end if Topic.connection.supports_savepoints? - -if current_adapter?(:PostgreSQLAdapter) - class ConcurrentTransactionTest < TransactionTest - use_concurrent_connections - - # This will cause transactions to overlap and fail unless they are performed on - # separate database connections. - def test_transaction_per_thread - assert_nothing_raised do - threads = (1..3).map do - Thread.new do - Topic.transaction do - topic = Topic.find(1) - topic.approved = !topic.approved? - topic.save! - topic.approved = !topic.approved? - topic.save! - end - end - end - - threads.each { |t| t.join } - end - end - - # Test for dirty reads among simultaneous transactions. - def test_transaction_isolation__read_committed - # Should be invariant. - original_salary = Developer.find(1).salary - temporary_salary = 200000 - - assert_nothing_raised do - threads = (1..3).map do - Thread.new do - Developer.transaction do - # Expect original salary. - dev = Developer.find(1) - assert_equal original_salary, dev.salary - - dev.salary = temporary_salary - dev.save! - - # Expect temporary salary. - dev = Developer.find(1) - assert_equal temporary_salary, dev.salary - - dev.salary = original_salary - dev.save! - - # Expect original salary. - dev = Developer.find(1) - assert_equal original_salary, dev.salary - end - end - end - - # Keep our eyes peeled. - threads << Thread.new do - 10.times do - sleep 0.05 - Developer.transaction do - # Always expect original salary. - assert_equal original_salary, Developer.find(1).salary - end - end - end - - threads.each { |t| t.join } - end - - assert_equal original_salary, Developer.find(1).salary - end - end -end diff --git a/vendor/rails/activerecord/test/cases/unconnected_test.rb b/vendor/rails/activerecord/test/cases/unconnected_test.rb deleted file mode 100644 index 23ad10f..0000000 --- a/vendor/rails/activerecord/test/cases/unconnected_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require "cases/helper" - -class TestRecord < ActiveRecord::Base -end - -class TestUnconnectedAdapter < ActiveRecord::TestCase - self.use_transactional_fixtures = false - - def setup - @underlying = ActiveRecord::Base.connection - @specification = ActiveRecord::Base.remove_connection - end - - def teardown - @underlying = nil - ActiveRecord::Base.establish_connection(@specification) - end - - def test_connection_no_longer_established - assert_raise(ActiveRecord::ConnectionNotEstablished) do - TestRecord.find(1) - end - - assert_raise(ActiveRecord::ConnectionNotEstablished) do - TestRecord.new.save - end - end - - def test_underlying_adapter_no_longer_active - assert !@underlying.active?, "Removed adapter should no longer be active" - end -end diff --git a/vendor/rails/activerecord/test/cases/validations_i18n_test.rb b/vendor/rails/activerecord/test/cases/validations_i18n_test.rb deleted file mode 100644 index 6698234..0000000 --- a/vendor/rails/activerecord/test/cases/validations_i18n_test.rb +++ /dev/null @@ -1,915 +0,0 @@ -require "cases/helper" -require 'models/topic' -require 'models/reply' - -class ActiveRecordValidationsI18nTests < ActiveSupport::TestCase - def setup - reset_callbacks Topic - @topic = Topic.new - @old_load_path, @old_backend = I18n.load_path, I18n.backend - I18n.load_path.clear - I18n.backend = I18n::Backend::Simple.new - I18n.backend.store_translations('en', :activerecord => {:errors => {:messages => {:custom => nil}}}) - end - - def teardown - reset_callbacks Topic - I18n.load_path.replace @old_load_path - I18n.backend = @old_backend - end - - def unique_topic - @unique ||= Topic.create :title => 'unique!' - end - - def replied_topic - @replied_topic ||= begin - topic = Topic.create(:title => "topic") - topic.replies << Reply.new - topic - end - end - - def reset_callbacks(*models) - models.each do |model| - model.instance_variable_set("@validate_callbacks", ActiveSupport::Callbacks::CallbackChain.new) - model.instance_variable_set("@validate_on_create_callbacks", ActiveSupport::Callbacks::CallbackChain.new) - model.instance_variable_set("@validate_on_update_callbacks", ActiveSupport::Callbacks::CallbackChain.new) - end - end - - def test_default_error_messages_is_deprecated - assert_deprecated('ActiveRecord::Errors.default_error_messages') do - ActiveRecord::Errors.default_error_messages - end - end - - def test_percent_s_interpolation_syntax_in_error_messages_still_works - ActiveSupport::Deprecation.silence do - result = I18n.t :does_not_exist, :default => "%s interpolation syntax is deprecated", :value => 'this' - assert_equal result, "this interpolation syntax is deprecated" - end - end - - def test_percent_s_interpolation_syntax_in_error_messages_is_deprecated - assert_deprecated('using %s in messages') do - I18n.t :does_not_exist, :default => "%s interpolation syntax is deprected", :value => 'this' - end - end - - def test_percent_d_interpolation_syntax_in_error_messages_still_works - ActiveSupport::Deprecation.silence do - result = I18n.t :does_not_exist, :default => "%d interpolation syntaxes are deprecated", :count => 2 - assert_equal result, "2 interpolation syntaxes are deprecated" - end - end - - def test_percent_d_interpolation_syntax_in_error_messages_is_deprecated - assert_deprecated('using %d in messages') do - I18n.t :does_not_exist, :default => "%d interpolation syntaxes are deprected", :count => 2 - end - end - - # ActiveRecord::Errors - def test_errors_generate_message_translates_custom_model_attribute_key - - I18n.expects(:translate).with( - :topic, - { :count => 1, - :default => ['Topic'], - :scope => [:activerecord, :models] - } - ).returns('Topic') - - I18n.expects(:translate).with( - :"topic.title", - { :count => 1, - :default => ['Title'], - :scope => [:activerecord, :attributes] - } - ).returns('Title') - - I18n.expects(:translate).with( - :"models.topic.attributes.title.invalid", - :value => nil, - :scope => [:activerecord, :errors], - :default => [ - :"models.topic.invalid", - 'default from class def error 1', - :"messages.invalid"], - :attribute => "Title", - :model => "Topic" - ).returns('default from class def error 1') - - @topic.errors.generate_message :title, :invalid, :default => 'default from class def error 1' - end - - def test_errors_generate_message_translates_custom_model_attribute_keys_with_sti - - I18n.expects(:translate).with( - :reply, - { :count => 1, - :default => [:topic, 'Reply'], - :scope => [:activerecord, :models] - } - ).returns('Reply') - - I18n.expects(:translate).with( - :"reply.title", - { :count => 1, - :default => [:'topic.title', 'Title'], - :scope => [:activerecord, :attributes] - } - ).returns('Title') - - I18n.expects(:translate).with( - :"models.reply.attributes.title.invalid", - :value => nil, - :scope => [:activerecord, :errors], - :default => [ - :"models.reply.invalid", - :"models.topic.attributes.title.invalid", - :"models.topic.invalid", - 'default from class def', - :"messages.invalid"], - :model => 'Reply', - :attribute => 'Title' - ).returns("default from class def") - - Reply.new.errors.generate_message :title, :invalid, :default => 'default from class def' - - end - - def test_errors_add_on_empty_generates_message - @topic.errors.expects(:generate_message).with(:title, :empty, {:default => nil}) - @topic.errors.add_on_empty :title - end - - def test_errors_add_on_empty_generates_message_with_custom_default_message - @topic.errors.expects(:generate_message).with(:title, :empty, {:default => 'custom'}) - @topic.errors.add_on_empty :title, 'custom' - end - - def test_errors_add_on_blank_generates_message - @topic.errors.expects(:generate_message).with(:title, :blank, {:default => nil}) - @topic.errors.add_on_blank :title - end - - def test_errors_add_on_blank_generates_message_with_custom_default_message - @topic.errors.expects(:generate_message).with(:title, :blank, {:default => 'custom'}) - @topic.errors.add_on_blank :title, 'custom' - end - - def test_errors_full_messages_translates_human_attribute_name_for_model_attributes - @topic.errors.instance_variable_set :@errors, { 'title' => ['empty'] } - I18n.expects(:translate).with(:"topic.title", :default => ['Title'], :scope => [:activerecord, :attributes], :count => 1).returns('Title') - @topic.errors.full_messages :locale => 'en' - end - - # ActiveRecord::Validations - # validates_confirmation_of w/ mocha - def test_validates_confirmation_of_generates_message - Topic.validates_confirmation_of :title - @topic.title_confirmation = 'foo' - @topic.errors.expects(:generate_message).with(:title, :confirmation, {:default => nil}) - @topic.valid? - end - - def test_validates_confirmation_of_generates_message_with_custom_default_message - Topic.validates_confirmation_of :title, :message => 'custom' - @topic.title_confirmation = 'foo' - @topic.errors.expects(:generate_message).with(:title, :confirmation, {:default => 'custom'}) - @topic.valid? - end - - # validates_acceptance_of w/ mocha - - def test_validates_acceptance_of_generates_message - Topic.validates_acceptance_of :title, :allow_nil => false - @topic.errors.expects(:generate_message).with(:title, :accepted, {:default => nil}) - @topic.valid? - end - - def test_validates_acceptance_of_generates_message_with_custom_default_message - Topic.validates_acceptance_of :title, :message => 'custom', :allow_nil => false - @topic.errors.expects(:generate_message).with(:title, :accepted, {:default => 'custom'}) - @topic.valid? - end - - # validates_presence_of w/ mocha - - def test_validates_presence_of_generates_message - Topic.validates_presence_of :title - @topic.errors.expects(:generate_message).with(:title, :blank, {:default => nil}) - @topic.valid? - end - - def test_validates_presence_of_generates_message_with_custom_default_message - Topic.validates_presence_of :title, :message => 'custom' - @topic.errors.expects(:generate_message).with(:title, :blank, {:default => 'custom'}) - @topic.valid? - end - - def test_validates_length_of_within_generates_message_with_title_too_short - Topic.validates_length_of :title, :within => 3..5 - @topic.errors.expects(:generate_message).with(:title, :too_short, {:count => 3, :default => nil}) - @topic.valid? - end - - def test_validates_length_of_within_generates_message_with_title_too_short_and_custom_default_message - Topic.validates_length_of :title, :within => 3..5, :too_short => 'custom' - @topic.errors.expects(:generate_message).with(:title, :too_short, {:count => 3, :default => 'custom'}) - @topic.valid? - end - - def test_validates_length_of_within_generates_message_with_title_too_long - Topic.validates_length_of :title, :within => 3..5 - @topic.title = 'this title is too long' - @topic.errors.expects(:generate_message).with(:title, :too_long, {:count => 5, :default => nil}) - @topic.valid? - end - - def test_validates_length_of_within_generates_message_with_title_too_long_and_custom_default_message - Topic.validates_length_of :title, :within => 3..5, :too_long => 'custom' - @topic.title = 'this title is too long' - @topic.errors.expects(:generate_message).with(:title, :too_long, {:count => 5, :default => 'custom'}) - @topic.valid? - end - - # validates_length_of :within w/ mocha - - def test_validates_length_of_within_generates_message_with_title_too_short - Topic.validates_length_of :title, :within => 3..5 - @topic.errors.expects(:generate_message).with(:title, :too_short, {:count => 3, :default => nil}) - @topic.valid? - end - - def test_validates_length_of_within_generates_message_with_title_too_short_and_custom_default_message - Topic.validates_length_of :title, :within => 3..5, :too_short => 'custom' - @topic.errors.expects(:generate_message).with(:title, :too_short, {:count => 3, :default => 'custom'}) - @topic.valid? - end - - def test_validates_length_of_within_generates_message_with_title_too_long - Topic.validates_length_of :title, :within => 3..5 - @topic.title = 'this title is too long' - @topic.errors.expects(:generate_message).with(:title, :too_long, {:count => 5, :default => nil}) - @topic.valid? - end - - def test_validates_length_of_within_generates_message_with_title_too_long_and_custom_default_message - Topic.validates_length_of :title, :within => 3..5, :too_long => 'custom' - @topic.title = 'this title is too long' - @topic.errors.expects(:generate_message).with(:title, :too_long, {:count => 5, :default => 'custom'}) - @topic.valid? - end - - # validates_length_of :is w/ mocha - - def test_validates_length_of_is_generates_message - Topic.validates_length_of :title, :is => 5 - @topic.errors.expects(:generate_message).with(:title, :wrong_length, {:count => 5, :default => nil}) - @topic.valid? - end - - def test_validates_length_of_is_generates_message_with_custom_default_message - Topic.validates_length_of :title, :is => 5, :message => 'custom' - @topic.errors.expects(:generate_message).with(:title, :wrong_length, {:count => 5, :default => 'custom'}) - @topic.valid? - end - - # validates_uniqueness_of w/ mocha - - def test_validates_uniqueness_of_generates_message - Topic.validates_uniqueness_of :title - @topic.title = unique_topic.title - @topic.errors.expects(:generate_message).with(:title, :taken, {:default => nil, :value => 'unique!'}) - @topic.valid? - end - - def test_validates_uniqueness_of_generates_message_with_custom_default_message - Topic.validates_uniqueness_of :title, :message => 'custom' - @topic.title = unique_topic.title - @topic.errors.expects(:generate_message).with(:title, :taken, {:default => 'custom', :value => 'unique!'}) - @topic.valid? - end - - # validates_format_of w/ mocha - - def test_validates_format_of_generates_message - Topic.validates_format_of :title, :with => /^[1-9][0-9]*$/ - @topic.title = '72x' - @topic.errors.expects(:generate_message).with(:title, :invalid, {:value => '72x', :default => nil}) - @topic.valid? - end - - def test_validates_format_of_generates_message_with_custom_default_message - Topic.validates_format_of :title, :with => /^[1-9][0-9]*$/, :message => 'custom' - @topic.title = '72x' - @topic.errors.expects(:generate_message).with(:title, :invalid, {:value => '72x', :default => 'custom'}) - @topic.valid? - end - - # validates_inclusion_of w/ mocha - - def test_validates_inclusion_of_generates_message - Topic.validates_inclusion_of :title, :in => %w(a b c) - @topic.title = 'z' - @topic.errors.expects(:generate_message).with(:title, :inclusion, {:value => 'z', :default => nil}) - @topic.valid? - end - - def test_validates_inclusion_of_generates_message_with_custom_default_message - Topic.validates_inclusion_of :title, :in => %w(a b c), :message => 'custom' - @topic.title = 'z' - @topic.errors.expects(:generate_message).with(:title, :inclusion, {:value => 'z', :default => 'custom'}) - @topic.valid? - end - - # validates_exclusion_of w/ mocha - - def test_validates_exclusion_of_generates_message - Topic.validates_exclusion_of :title, :in => %w(a b c) - @topic.title = 'a' - @topic.errors.expects(:generate_message).with(:title, :exclusion, {:value => 'a', :default => nil}) - @topic.valid? - end - - def test_validates_exclusion_of_generates_message_with_custom_default_message - Topic.validates_exclusion_of :title, :in => %w(a b c), :message => 'custom' - @topic.title = 'a' - @topic.errors.expects(:generate_message).with(:title, :exclusion, {:value => 'a', :default => 'custom'}) - @topic.valid? - end - - # validates_numericality_of without :only_integer w/ mocha - - def test_validates_numericality_of_generates_message - Topic.validates_numericality_of :title - @topic.title = 'a' - @topic.errors.expects(:generate_message).with(:title, :not_a_number, {:value => 'a', :default => nil}) - @topic.valid? - end - - def test_validates_numericality_of_generates_message_with_custom_default_message - Topic.validates_numericality_of :title, :message => 'custom' - @topic.title = 'a' - @topic.errors.expects(:generate_message).with(:title, :not_a_number, {:value => 'a', :default => 'custom'}) - @topic.valid? - end - - # validates_numericality_of with :only_integer w/ mocha - - def test_validates_numericality_of_only_integer_generates_message - Topic.validates_numericality_of :title, :only_integer => true - @topic.title = 'a' - @topic.errors.expects(:generate_message).with(:title, :not_a_number, {:value => 'a', :default => nil}) - @topic.valid? - end - - def test_validates_numericality_of_only_integer_generates_message_with_custom_default_message - Topic.validates_numericality_of :title, :only_integer => true, :message => 'custom' - @topic.title = 'a' - @topic.errors.expects(:generate_message).with(:title, :not_a_number, {:value => 'a', :default => 'custom'}) - @topic.valid? - end - - # validates_numericality_of :odd w/ mocha - - def test_validates_numericality_of_odd_generates_message - Topic.validates_numericality_of :title, :only_integer => true, :odd => true - @topic.title = 0 - @topic.errors.expects(:generate_message).with(:title, :odd, {:value => 0, :default => nil}) - @topic.valid? - end - - def test_validates_numericality_of_odd_generates_message_with_custom_default_message - Topic.validates_numericality_of :title, :only_integer => true, :odd => true, :message => 'custom' - @topic.title = 0 - @topic.errors.expects(:generate_message).with(:title, :odd, {:value => 0, :default => 'custom'}) - @topic.valid? - end - - # validates_numericality_of :less_than w/ mocha - - def test_validates_numericality_of_less_than_generates_message - Topic.validates_numericality_of :title, :only_integer => true, :less_than => 0 - @topic.title = 1 - @topic.errors.expects(:generate_message).with(:title, :less_than, {:value => 1, :count => 0, :default => nil}) - @topic.valid? - end - - def test_validates_numericality_of_odd_generates_message_with_custom_default_message - Topic.validates_numericality_of :title, :only_integer => true, :less_than => 0, :message => 'custom' - @topic.title = 1 - @topic.errors.expects(:generate_message).with(:title, :less_than, {:value => 1, :count => 0, :default => 'custom'}) - @topic.valid? - end - - # validates_associated w/ mocha - - def test_validates_associated_generates_message - Topic.validates_associated :replies - replied_topic.errors.expects(:generate_message).with(:replies, :invalid, {:value => replied_topic.replies, :default => nil}) - replied_topic.valid? - end - - def test_validates_associated_generates_message_with_custom_default_message - Topic.validates_associated :replies - replied_topic.errors.expects(:generate_message).with(:replies, :invalid, {:value => replied_topic.replies, :default => nil}) - replied_topic.valid? - end - - # validates_confirmation_of w/o mocha - - def test_validates_confirmation_of_finds_custom_model_key_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:title => {:confirmation => 'custom message'}}}}}} - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:confirmation => 'global message'}}} - - Topic.validates_confirmation_of :title - @topic.title_confirmation = 'foo' - @topic.valid? - assert_equal 'custom message', @topic.errors.on(:title) - end - - def test_validates_confirmation_of_finds_global_default_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:confirmation => 'global message'}}} - - Topic.validates_confirmation_of :title - @topic.title_confirmation = 'foo' - @topic.valid? - assert_equal 'global message', @topic.errors.on(:title) - end - - # validates_acceptance_of w/o mocha - - def test_validates_acceptance_of_finds_custom_model_key_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:title => {:accepted => 'custom message'}}}}}} - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:accepted => 'global message'}}} - - Topic.validates_acceptance_of :title, :allow_nil => false - @topic.valid? - assert_equal 'custom message', @topic.errors.on(:title) - end - - def test_validates_acceptance_of_finds_global_default_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:accepted => 'global message'}}} - - Topic.validates_acceptance_of :title, :allow_nil => false - @topic.valid? - assert_equal 'global message', @topic.errors.on(:title) - end - - # validates_presence_of w/o mocha - - def test_validates_presence_of_finds_custom_model_key_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:title => {:blank => 'custom message'}}}}}} - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:blank => 'global message'}}} - - Topic.validates_presence_of :title - @topic.valid? - assert_equal 'custom message', @topic.errors.on(:title) - end - - def test_validates_presence_of_finds_global_default_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:blank => 'global message'}}} - - Topic.validates_presence_of :title - @topic.valid? - assert_equal 'global message', @topic.errors.on(:title) - end - - # validates_length_of :within w/o mocha - - def test_validates_length_of_within_finds_custom_model_key_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:title => {:too_short => 'custom message'}}}}}} - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:too_short => 'global message'}}} - - Topic.validates_length_of :title, :within => 3..5 - @topic.valid? - assert_equal 'custom message', @topic.errors.on(:title) - end - - def test_validates_length_of_within_finds_global_default_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:too_short => 'global message'}}} - - Topic.validates_length_of :title, :within => 3..5 - @topic.valid? - assert_equal 'global message', @topic.errors.on(:title) - end - - # validates_length_of :is w/o mocha - - def test_validates_length_of_is_finds_custom_model_key_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:title => {:wrong_length => 'custom message'}}}}}} - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:wrong_length => 'global message'}}} - - Topic.validates_length_of :title, :is => 5 - @topic.valid? - assert_equal 'custom message', @topic.errors.on(:title) - end - - def test_validates_length_of_is_finds_global_default_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:wrong_length => 'global message'}}} - - Topic.validates_length_of :title, :is => 5 - @topic.valid? - assert_equal 'global message', @topic.errors.on(:title) - end - - # validates_uniqueness_of w/o mocha - - def test_validates_length_of_is_finds_custom_model_key_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:title => {:wrong_length => 'custom message'}}}}}} - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:wrong_length => 'global message'}}} - - Topic.validates_length_of :title, :is => 5 - @topic.valid? - assert_equal 'custom message', @topic.errors.on(:title) - end - - def test_validates_length_of_is_finds_global_default_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:wrong_length => 'global message'}}} - - Topic.validates_length_of :title, :is => 5 - @topic.valid? - assert_equal 'global message', @topic.errors.on(:title) - end - - - # validates_format_of w/o mocha - - def test_validates_format_of_finds_custom_model_key_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:title => {:invalid => 'custom message'}}}}}} - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:invalid => 'global message'}}} - - Topic.validates_format_of :title, :with => /^[1-9][0-9]*$/ - @topic.valid? - assert_equal 'custom message', @topic.errors.on(:title) - end - - def test_validates_format_of_finds_global_default_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:invalid => 'global message'}}} - - Topic.validates_format_of :title, :with => /^[1-9][0-9]*$/ - @topic.valid? - assert_equal 'global message', @topic.errors.on(:title) - end - - # validates_inclusion_of w/o mocha - - def test_validates_inclusion_of_finds_custom_model_key_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:title => {:inclusion => 'custom message'}}}}}} - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:inclusion => 'global message'}}} - - Topic.validates_inclusion_of :title, :in => %w(a b c) - @topic.valid? - assert_equal 'custom message', @topic.errors.on(:title) - end - - def test_validates_inclusion_of_finds_global_default_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:inclusion => 'global message'}}} - - Topic.validates_inclusion_of :title, :in => %w(a b c) - @topic.valid? - assert_equal 'global message', @topic.errors.on(:title) - end - - # validates_exclusion_of w/o mocha - - def test_validates_exclusion_of_finds_custom_model_key_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:title => {:exclusion => 'custom message'}}}}}} - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:exclusion => 'global message'}}} - - Topic.validates_exclusion_of :title, :in => %w(a b c) - @topic.title = 'a' - @topic.valid? - assert_equal 'custom message', @topic.errors.on(:title) - end - - def test_validates_exclusion_of_finds_global_default_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:exclusion => 'global message'}}} - - Topic.validates_exclusion_of :title, :in => %w(a b c) - @topic.title = 'a' - @topic.valid? - assert_equal 'global message', @topic.errors.on(:title) - end - - # validates_numericality_of without :only_integer w/o mocha - - def test_validates_numericality_of_finds_custom_model_key_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:title => {:not_a_number => 'custom message'}}}}}} - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:not_a_number => 'global message'}}} - - Topic.validates_numericality_of :title - @topic.title = 'a' - @topic.valid? - assert_equal 'custom message', @topic.errors.on(:title) - end - - def test_validates_numericality_of_finds_global_default_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:not_a_number => 'global message'}}} - - Topic.validates_numericality_of :title, :only_integer => true - @topic.title = 'a' - @topic.valid? - assert_equal 'global message', @topic.errors.on(:title) - end - - # validates_numericality_of with :only_integer w/o mocha - - def test_validates_numericality_of_only_integer_finds_custom_model_key_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:title => {:not_a_number => 'custom message'}}}}}} - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:not_a_number => 'global message'}}} - - Topic.validates_numericality_of :title, :only_integer => true - @topic.title = 'a' - @topic.valid? - assert_equal 'custom message', @topic.errors.on(:title) - end - - def test_validates_numericality_of_only_integer_finds_global_default_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:not_a_number => 'global message'}}} - - Topic.validates_numericality_of :title, :only_integer => true - @topic.title = 'a' - @topic.valid? - assert_equal 'global message', @topic.errors.on(:title) - end - - # validates_numericality_of :odd w/o mocha - - def test_validates_numericality_of_odd_finds_custom_model_key_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:title => {:odd => 'custom message'}}}}}} - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:odd => 'global message'}}} - - Topic.validates_numericality_of :title, :only_integer => true, :odd => true - @topic.title = 0 - @topic.valid? - assert_equal 'custom message', @topic.errors.on(:title) - end - - def test_validates_numericality_of_odd_finds_global_default_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:odd => 'global message'}}} - - Topic.validates_numericality_of :title, :only_integer => true, :odd => true - @topic.title = 0 - @topic.valid? - assert_equal 'global message', @topic.errors.on(:title) - end - - # validates_numericality_of :less_than w/o mocha - - def test_validates_numericality_of_less_than_finds_custom_model_key_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:title => {:less_than => 'custom message'}}}}}} - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:less_than => 'global message'}}} - - Topic.validates_numericality_of :title, :only_integer => true, :less_than => 0 - @topic.title = 1 - @topic.valid? - assert_equal 'custom message', @topic.errors.on(:title) - end - - def test_validates_numericality_of_less_than_finds_global_default_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:less_than => 'global message'}}} - - Topic.validates_numericality_of :title, :only_integer => true, :less_than => 0 - @topic.title = 1 - @topic.valid? - assert_equal 'global message', @topic.errors.on(:title) - end - - - # validates_associated w/o mocha - - def test_validates_associated_finds_custom_model_key_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:replies => {:invalid => 'custom message'}}}}}} - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:invalid => 'global message'}}} - - Topic.validates_associated :replies - replied_topic.valid? - assert_equal 'custom message', replied_topic.errors.on(:replies) - end - - def test_validates_associated_finds_global_default_translation - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:invalid => 'global message'}}} - - Topic.validates_associated :replies - replied_topic.valid? - assert_equal 'global message', replied_topic.errors.on(:replies) - end - - def test_validations_with_message_symbol_must_translate - I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:custom_error => "I am a custom error"}}} - Topic.validates_presence_of :title, :message => :custom_error - @topic.title = nil - @topic.valid? - assert_equal "I am a custom error", @topic.errors.on(:title) - end - - def test_validates_with_message_symbol_must_translate_per_attribute - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:title => {:custom_error => "I am a custom error"}}}}}} - Topic.validates_presence_of :title, :message => :custom_error - @topic.title = nil - @topic.valid? - assert_equal "I am a custom error", @topic.errors.on(:title) - end - - def test_validates_with_message_symbol_must_translate_per_model - I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:custom_error => "I am a custom error"}}}} - Topic.validates_presence_of :title, :message => :custom_error - @topic.title = nil - @topic.valid? - assert_equal "I am a custom error", @topic.errors.on(:title) - end - - def test_validates_with_message_string - Topic.validates_presence_of :title, :message => "I am a custom error" - @topic.title = nil - @topic.valid? - assert_equal "I am a custom error", @topic.errors.on(:title) - end - -end - -class ActiveRecordValidationsGenerateMessageI18nTests < Test::Unit::TestCase - def setup - reset_callbacks Topic - @topic = Topic.new - I18n.backend.store_translations :'en', { - :activerecord => { - :errors => { - :messages => { - :inclusion => "is not included in the list", - :exclusion => "is reserved", - :invalid => "is invalid", - :confirmation => "doesn't match confirmation", - :accepted => "must be accepted", - :empty => "can't be empty", - :blank => "can't be blank", - :too_long => "is too long (maximum is {{count}} characters)", - :too_short => "is too short (minimum is {{count}} characters)", - :wrong_length => "is the wrong length (should be {{count}} characters)", - :taken => "has already been taken", - :not_a_number => "is not a number", - :greater_than => "must be greater than {{count}}", - :greater_than_or_equal_to => "must be greater than or equal to {{count}}", - :equal_to => "must be equal to {{count}}", - :less_than => "must be less than {{count}}", - :less_than_or_equal_to => "must be less than or equal to {{count}}", - :odd => "must be odd", - :even => "must be even" - } - } - } - } - end - - def reset_callbacks(*models) - models.each do |model| - model.instance_variable_set("@validate_callbacks", ActiveSupport::Callbacks::CallbackChain.new) - model.instance_variable_set("@validate_on_create_callbacks", ActiveSupport::Callbacks::CallbackChain.new) - model.instance_variable_set("@validate_on_update_callbacks", ActiveSupport::Callbacks::CallbackChain.new) - end - end - - # validates_inclusion_of: generate_message(attr_name, :inclusion, :default => configuration[:message], :value => value) - def test_generate_message_inclusion_with_default_message - assert_equal 'is not included in the list', @topic.errors.generate_message(:title, :inclusion, :default => nil, :value => 'title') - end - - def test_generate_message_inclusion_with_custom_message - assert_equal 'custom message title', @topic.errors.generate_message(:title, :inclusion, :default => 'custom message {{value}}', :value => 'title') - end - - # validates_exclusion_of: generate_message(attr_name, :exclusion, :default => configuration[:message], :value => value) - def test_generate_message_exclusion_with_default_message - assert_equal 'is reserved', @topic.errors.generate_message(:title, :exclusion, :default => nil, :value => 'title') - end - - def test_generate_message_exclusion_with_custom_message - assert_equal 'custom message title', @topic.errors.generate_message(:title, :exclusion, :default => 'custom message {{value}}', :value => 'title') - end - - # validates_associated: generate_message(attr_name, :invalid, :default => configuration[:message], :value => value) - # validates_format_of: generate_message(attr_name, :invalid, :default => configuration[:message], :value => value) - def test_generate_message_invalid_with_default_message - assert_equal 'is invalid', @topic.errors.generate_message(:title, :invalid, :default => nil, :value => 'title') - end - - def test_generate_message_invalid_with_custom_message - assert_equal 'custom message title', @topic.errors.generate_message(:title, :invalid, :default => 'custom message {{value}}', :value => 'title') - end - - # validates_confirmation_of: generate_message(attr_name, :confirmation, :default => configuration[:message]) - def test_generate_message_confirmation_with_default_message - assert_equal "doesn't match confirmation", @topic.errors.generate_message(:title, :confirmation, :default => nil) - end - - def test_generate_message_confirmation_with_custom_message - assert_equal 'custom message', @topic.errors.generate_message(:title, :confirmation, :default => 'custom message') - end - - # validates_acceptance_of: generate_message(attr_name, :accepted, :default => configuration[:message]) - def test_generate_message_accepted_with_default_message - assert_equal "must be accepted", @topic.errors.generate_message(:title, :accepted, :default => nil) - end - - def test_generate_message_accepted_with_custom_message - assert_equal 'custom message', @topic.errors.generate_message(:title, :accepted, :default => 'custom message') - end - - # add_on_empty: generate_message(attr, :empty, :default => custom_message) - def test_generate_message_empty_with_default_message - assert_equal "can't be empty", @topic.errors.generate_message(:title, :empty, :default => nil) - end - - def test_generate_message_empty_with_custom_message - assert_equal 'custom message', @topic.errors.generate_message(:title, :empty, :default => 'custom message') - end - - # add_on_blank: generate_message(attr, :blank, :default => custom_message) - def test_generate_message_blank_with_default_message - assert_equal "can't be blank", @topic.errors.generate_message(:title, :blank, :default => nil) - end - - def test_generate_message_blank_with_custom_message - assert_equal 'custom message', @topic.errors.generate_message(:title, :blank, :default => 'custom message') - end - - # validates_length_of: generate_message(attr, :too_long, :default => options[:too_long], :count => option_value.end) - def test_generate_message_too_long_with_default_message - assert_equal "is too long (maximum is 10 characters)", @topic.errors.generate_message(:title, :too_long, :default => nil, :count => 10) - end - - def test_generate_message_too_long_with_custom_message - assert_equal 'custom message 10', @topic.errors.generate_message(:title, :too_long, :default => 'custom message {{count}}', :count => 10) - end - - # validates_length_of: generate_message(attr, :too_short, :default => options[:too_short], :count => option_value.begin) - def test_generate_message_too_short_with_default_message - assert_equal "is too short (minimum is 10 characters)", @topic.errors.generate_message(:title, :too_short, :default => nil, :count => 10) - end - - def test_generate_message_too_short_with_custom_message - assert_equal 'custom message 10', @topic.errors.generate_message(:title, :too_short, :default => 'custom message {{count}}', :count => 10) - end - - # validates_length_of: generate_message(attr, key, :default => custom_message, :count => option_value) - def test_generate_message_wrong_length_with_default_message - assert_equal "is the wrong length (should be 10 characters)", @topic.errors.generate_message(:title, :wrong_length, :default => nil, :count => 10) - end - - def test_generate_message_wrong_length_with_custom_message - assert_equal 'custom message 10', @topic.errors.generate_message(:title, :wrong_length, :default => 'custom message {{count}}', :count => 10) - end - - # validates_uniqueness_of: generate_message(attr_name, :taken, :default => configuration[:message]) - def test_generate_message_taken_with_default_message - assert_equal "has already been taken", @topic.errors.generate_message(:title, :taken, :default => nil, :value => 'title') - end - - def test_generate_message_taken_with_custom_message - assert_equal 'custom message title', @topic.errors.generate_message(:title, :taken, :default => 'custom message {{value}}', :value => 'title') - end - - # validates_numericality_of: generate_message(attr_name, :not_a_number, :value => raw_value, :default => configuration[:message]) - def test_generate_message_not_a_number_with_default_message - assert_equal "is not a number", @topic.errors.generate_message(:title, :not_a_number, :default => nil, :value => 'title') - end - - def test_generate_message_not_a_number_with_custom_message - assert_equal 'custom message title', @topic.errors.generate_message(:title, :not_a_number, :default => 'custom message {{value}}', :value => 'title') - end - - # validates_numericality_of: generate_message(attr_name, option, :value => raw_value, :default => configuration[:message]) - def test_generate_message_greater_than_with_default_message - assert_equal "must be greater than 10", @topic.errors.generate_message(:title, :greater_than, :default => nil, :value => 'title', :count => 10) - end - - def test_generate_message_greater_than_or_equal_to_with_default_message - assert_equal "must be greater than or equal to 10", @topic.errors.generate_message(:title, :greater_than_or_equal_to, :default => nil, :value => 'title', :count => 10) - end - - def test_generate_message_equal_to_with_default_message - assert_equal "must be equal to 10", @topic.errors.generate_message(:title, :equal_to, :default => nil, :value => 'title', :count => 10) - end - - def test_generate_message_less_than_with_default_message - assert_equal "must be less than 10", @topic.errors.generate_message(:title, :less_than, :default => nil, :value => 'title', :count => 10) - end - - def test_generate_message_less_than_or_equal_to_with_default_message - assert_equal "must be less than or equal to 10", @topic.errors.generate_message(:title, :less_than_or_equal_to, :default => nil, :value => 'title', :count => 10) - end - - def test_generate_message_odd_with_default_message - assert_equal "must be odd", @topic.errors.generate_message(:title, :odd, :default => nil, :value => 'title', :count => 10) - end - - def test_generate_message_even_with_default_message - assert_equal "must be even", @topic.errors.generate_message(:title, :even, :default => nil, :value => 'title', :count => 10) - end - -end diff --git a/vendor/rails/activerecord/test/cases/validations_test.rb b/vendor/rails/activerecord/test/cases/validations_test.rb deleted file mode 100644 index c20f5ae..0000000 --- a/vendor/rails/activerecord/test/cases/validations_test.rb +++ /dev/null @@ -1,1602 +0,0 @@ -# encoding: utf-8 -require "cases/helper" -require 'models/topic' -require 'models/reply' -require 'models/person' -require 'models/developer' -require 'models/warehouse_thing' -require 'models/guid' -require 'models/owner' -require 'models/pet' -require 'models/event' - -# The following methods in Topic are used in test_conditional_validation_* -class Topic - has_many :unique_replies, :dependent => :destroy, :foreign_key => "parent_id" - has_many :silly_unique_replies, :dependent => :destroy, :foreign_key => "parent_id" - - def condition_is_true - true - end - - def condition_is_true_but_its_not - false - end -end - -class ProtectedPerson < ActiveRecord::Base - set_table_name 'people' - attr_accessor :addon - attr_protected :first_name -end - -class UniqueReply < Reply - validates_uniqueness_of :content, :scope => 'parent_id' -end - -class SillyUniqueReply < UniqueReply -end - -class Wizard < ActiveRecord::Base - self.abstract_class = true - - validates_uniqueness_of :name -end - -class IneptWizard < Wizard - validates_uniqueness_of :city -end - -class Conjurer < IneptWizard -end - -class Thaumaturgist < IneptWizard -end - - -class ValidationsTest < ActiveRecord::TestCase - fixtures :topics, :developers, 'warehouse-things' - - # Most of the tests mess with the validations of Topic, so lets repair it all the time. - # Other classes we mess with will be dealt with in the specific tests - repair_validations(Topic) - - def test_single_field_validation - r = Reply.new - r.title = "There's no content!" - assert !r.valid?, "A reply without content shouldn't be saveable" - - r.content = "Messa content!" - assert r.valid?, "A reply with content should be saveable" - end - - def test_single_attr_validation_and_error_msg - r = Reply.new - r.title = "There's no content!" - assert !r.valid? - assert r.errors.invalid?("content"), "A reply without content should mark that attribute as invalid" - assert_equal "Empty", r.errors.on("content"), "A reply without content should contain an error" - assert_equal 1, r.errors.count - end - - def test_double_attr_validation_and_error_msg - r = Reply.new - assert !r.valid? - - assert r.errors.invalid?("title"), "A reply without title should mark that attribute as invalid" - assert_equal "Empty", r.errors.on("title"), "A reply without title should contain an error" - - assert r.errors.invalid?("content"), "A reply without content should mark that attribute as invalid" - assert_equal "Empty", r.errors.on("content"), "A reply without content should contain an error" - - assert_equal 2, r.errors.count - end - - def test_error_on_create - r = Reply.new - r.title = "Wrong Create" - assert !r.valid? - assert r.errors.invalid?("title"), "A reply with a bad title should mark that attribute as invalid" - assert_equal "is Wrong Create", r.errors.on("title"), "A reply with a bad content should contain an error" - end - - def test_error_on_update - r = Reply.new - r.title = "Bad" - r.content = "Good" - assert r.save, "First save should be successful" - - r.title = "Wrong Update" - assert !r.save, "Second save should fail" - - assert r.errors.invalid?("title"), "A reply with a bad title should mark that attribute as invalid" - assert_equal "is Wrong Update", r.errors.on("title"), "A reply with a bad content should contain an error" - end - - def test_invalid_record_exception - assert_raise(ActiveRecord::RecordInvalid) { Reply.create! } - assert_raise(ActiveRecord::RecordInvalid) { Reply.new.save! } - - begin - r = Reply.new - r.save! - flunk - rescue ActiveRecord::RecordInvalid => invalid - assert_equal r, invalid.record - end - end - - def test_exception_on_create_bang_many - assert_raise(ActiveRecord::RecordInvalid) do - Reply.create!([ { "title" => "OK" }, { "title" => "Wrong Create" }]) - end - end - - def test_exception_on_create_bang_with_block - assert_raise(ActiveRecord::RecordInvalid) do - Reply.create!({ "title" => "OK" }) do |r| - r.content = nil - end - end - end - - def test_exception_on_create_bang_many_with_block - assert_raise(ActiveRecord::RecordInvalid) do - Reply.create!([{ "title" => "OK" }, { "title" => "Wrong Create" }]) do |r| - r.content = nil - end - end - end - - def test_scoped_create_without_attributes - Reply.with_scope(:create => {}) do - assert_raise(ActiveRecord::RecordInvalid) { Reply.create! } - end - end - - def test_create_with_exceptions_using_scope_for_protected_attributes - assert_nothing_raised do - ProtectedPerson.with_scope( :create => { :first_name => "Mary" } ) do - person = ProtectedPerson.create! :addon => "Addon" - assert_equal person.first_name, "Mary", "scope should ignore attr_protected" - end - end - end - - def test_create_with_exceptions_using_scope_and_empty_attributes - assert_nothing_raised do - ProtectedPerson.with_scope( :create => { :first_name => "Mary" } ) do - person = ProtectedPerson.create! - assert_equal person.first_name, "Mary", "should be ok when no attributes are passed to create!" - end - end - end - - def test_single_error_per_attr_iteration - r = Reply.new - r.save - - errors = [] - r.errors.each { |attr, msg| errors << [attr, msg] } - - assert errors.include?(["title", "Empty"]) - assert errors.include?(["content", "Empty"]) - end - - def test_multiple_errors_per_attr_iteration_with_full_error_composition - r = Reply.new - r.title = "Wrong Create" - r.content = "Mismatch" - r.save - - errors = [] - r.errors.each_full { |error| errors << error } - - assert_equal "Title is Wrong Create", errors[0] - assert_equal "Title is Content Mismatch", errors[1] - assert_equal 2, r.errors.count - end - - def test_errors_on_base - r = Reply.new - r.content = "Mismatch" - r.save - r.errors.add_to_base "Reply is not dignifying" - - errors = [] - r.errors.each_full { |error| errors << error } - - assert_equal "Reply is not dignifying", r.errors.on_base - - assert errors.include?("Title Empty") - assert errors.include?("Reply is not dignifying") - assert_equal 2, r.errors.count - end - - def test_create_without_validation - reply = Reply.new - assert !reply.save - assert reply.save(false) - end - - def test_create_without_validation_bang - count = Reply.count - assert_nothing_raised { Reply.new.save_without_validation! } - assert count+1, Reply.count - end - - def test_validates_each - hits = 0 - Topic.validates_each(:title, :content, [:title, :content]) do |record, attr| - record.errors.add attr, 'gotcha' - hits += 1 - end - t = Topic.new("title" => "valid", "content" => "whatever") - assert !t.save - assert_equal 4, hits - assert_equal %w(gotcha gotcha), t.errors.on(:title) - assert_equal %w(gotcha gotcha), t.errors.on(:content) - end - - def test_no_title_confirmation - Topic.validates_confirmation_of(:title) - - t = Topic.new(:author_name => "Plutarch") - assert t.valid? - - t.title_confirmation = "Parallel Lives" - assert !t.valid? - - t.title_confirmation = nil - t.title = "Parallel Lives" - assert t.valid? - - t.title_confirmation = "Parallel Lives" - assert t.valid? - end - - def test_title_confirmation - Topic.validates_confirmation_of(:title) - - t = Topic.create("title" => "We should be confirmed","title_confirmation" => "") - assert !t.save - - t.title_confirmation = "We should be confirmed" - assert t.save - end - - def test_terms_of_service_agreement_no_acceptance - Topic.validates_acceptance_of(:terms_of_service, :on => :create) - - t = Topic.create("title" => "We should not be confirmed") - assert t.save - end - - def test_terms_of_service_agreement - Topic.validates_acceptance_of(:terms_of_service, :on => :create) - - t = Topic.create("title" => "We should be confirmed","terms_of_service" => "") - assert !t.save - assert_equal "must be accepted", t.errors.on(:terms_of_service) - - t.terms_of_service = "1" - assert t.save - end - - - def test_eula - Topic.validates_acceptance_of(:eula, :message => "must be abided", :on => :create) - - t = Topic.create("title" => "We should be confirmed","eula" => "") - assert !t.save - assert_equal "must be abided", t.errors.on(:eula) - - t.eula = "1" - assert t.save - end - - def test_terms_of_service_agreement_with_accept_value - Topic.validates_acceptance_of(:terms_of_service, :on => :create, :accept => "I agree.") - - t = Topic.create("title" => "We should be confirmed", "terms_of_service" => "") - assert !t.save - assert_equal "must be accepted", t.errors.on(:terms_of_service) - - t.terms_of_service = "I agree." - assert t.save - end - - def test_validates_acceptance_of_as_database_column - repair_validations(Reply) do - Reply.validates_acceptance_of(:author_name) - - reply = Reply.create("author_name" => "Dan Brown") - assert_equal "Dan Brown", reply["author_name"] - end - end - - def test_validates_acceptance_of_with_non_existant_table - Object.const_set :IncorporealModel, Class.new(ActiveRecord::Base) - - assert_nothing_raised ActiveRecord::StatementInvalid do - IncorporealModel.validates_acceptance_of(:incorporeal_column) - end - end - - def test_validate_presences - Topic.validates_presence_of(:title, :content) - - t = Topic.create - assert !t.save - assert_equal "can't be blank", t.errors.on(:title) - assert_equal "can't be blank", t.errors.on(:content) - - t.title = "something" - t.content = " " - - assert !t.save - assert_equal "can't be blank", t.errors.on(:content) - - t.content = "like stuff" - - assert t.save - end - - def test_validate_uniqueness - Topic.validates_uniqueness_of(:title) - - t = Topic.new("title" => "I'm unique!") - assert t.save, "Should save t as unique" - - t.content = "Remaining unique" - assert t.save, "Should still save t as unique" - - t2 = Topic.new("title" => "I'm unique!") - assert !t2.valid?, "Shouldn't be valid" - assert !t2.save, "Shouldn't save t2 as unique" - assert_equal "has already been taken", t2.errors.on(:title) - - t2.title = "Now Im really also unique" - assert t2.save, "Should now save t2 as unique" - end - - def test_validates_uniquness_with_newline_chars - Topic.validates_uniqueness_of(:title, :case_sensitive => false) - - t = Topic.new("title" => "new\nline") - assert t.save, "Should save t as unique" - end - - def test_validate_uniqueness_with_scope - repair_validations(Reply) do - Reply.validates_uniqueness_of(:content, :scope => "parent_id") - - t = Topic.create("title" => "I'm unique!") - - r1 = t.replies.create "title" => "r1", "content" => "hello world" - assert r1.valid?, "Saving r1" - - r2 = t.replies.create "title" => "r2", "content" => "hello world" - assert !r2.valid?, "Saving r2 first time" - - r2.content = "something else" - assert r2.save, "Saving r2 second time" - - t2 = Topic.create("title" => "I'm unique too!") - r3 = t2.replies.create "title" => "r3", "content" => "hello world" - assert r3.valid?, "Saving r3" - end - end - - def test_validate_uniqueness_scoped_to_defining_class - t = Topic.create("title" => "What, me worry?") - - r1 = t.unique_replies.create "title" => "r1", "content" => "a barrel of fun" - assert r1.valid?, "Saving r1" - - r2 = t.silly_unique_replies.create "title" => "r2", "content" => "a barrel of fun" - assert !r2.valid?, "Saving r2" - - # Should succeed as validates_uniqueness_of only applies to - # UniqueReply and its subclasses - r3 = t.replies.create "title" => "r2", "content" => "a barrel of fun" - assert r3.valid?, "Saving r3" - end - - def test_validate_uniqueness_with_scope_array - repair_validations(Reply) do - Reply.validates_uniqueness_of(:author_name, :scope => [:author_email_address, :parent_id]) - - t = Topic.create("title" => "The earth is actually flat!") - - r1 = t.replies.create "author_name" => "jeremy", "author_email_address" => "jeremy@rubyonrails.com", "title" => "You're crazy!", "content" => "Crazy reply" - assert r1.valid?, "Saving r1" - - r2 = t.replies.create "author_name" => "jeremy", "author_email_address" => "jeremy@rubyonrails.com", "title" => "You're crazy!", "content" => "Crazy reply again..." - assert !r2.valid?, "Saving r2. Double reply by same author." - - r2.author_email_address = "jeremy_alt_email@rubyonrails.com" - assert r2.save, "Saving r2 the second time." - - r3 = t.replies.create "author_name" => "jeremy", "author_email_address" => "jeremy_alt_email@rubyonrails.com", "title" => "You're wrong", "content" => "It's cubic" - assert !r3.valid?, "Saving r3" - - r3.author_name = "jj" - assert r3.save, "Saving r3 the second time." - - r3.author_name = "jeremy" - assert !r3.save, "Saving r3 the third time." - end - end - - def test_validate_case_insensitive_uniqueness - Topic.validates_uniqueness_of(:title, :parent_id, :case_sensitive => false, :allow_nil => true) - - t = Topic.new("title" => "I'm unique!", :parent_id => 2) - assert t.save, "Should save t as unique" - - t.content = "Remaining unique" - assert t.save, "Should still save t as unique" - - t2 = Topic.new("title" => "I'm UNIQUE!", :parent_id => 1) - assert !t2.valid?, "Shouldn't be valid" - assert !t2.save, "Shouldn't save t2 as unique" - assert t2.errors.on(:title) - assert t2.errors.on(:parent_id) - assert_equal "has already been taken", t2.errors.on(:title) - - t2.title = "I'm truly UNIQUE!" - assert !t2.valid?, "Shouldn't be valid" - assert !t2.save, "Shouldn't save t2 as unique" - assert_nil t2.errors.on(:title) - assert t2.errors.on(:parent_id) - - t2.parent_id = 4 - assert t2.save, "Should now save t2 as unique" - - t2.parent_id = nil - t2.title = nil - assert t2.valid?, "should validate with nil" - assert t2.save, "should save with nil" - - with_kcode('UTF8') do - t_utf8 = Topic.new("title" => "Я тоже уникальный!") - assert t_utf8.save, "Should save t_utf8 as unique" - - # If database hasn't UTF-8 character set, this test fails - if Topic.find(t_utf8, :select => 'LOWER(title) AS title').title == "я тоже уникальный!" - t2_utf8 = Topic.new("title" => "я тоже УНИКАЛЬНЫЙ!") - assert !t2_utf8.valid?, "Shouldn't be valid" - assert !t2_utf8.save, "Shouldn't save t2_utf8 as unique" - end - end - end - - def test_validate_case_sensitive_uniqueness - Topic.validates_uniqueness_of(:title, :case_sensitive => true, :allow_nil => true) - - t = Topic.new("title" => "I'm unique!") - assert t.save, "Should save t as unique" - - t.content = "Remaining unique" - assert t.save, "Should still save t as unique" - - t2 = Topic.new("title" => "I'M UNIQUE!") - assert t2.valid?, "Should be valid" - assert t2.save, "Should save t2 as unique" - assert !t2.errors.on(:title) - assert !t2.errors.on(:parent_id) - assert_not_equal "has already been taken", t2.errors.on(:title) - - t3 = Topic.new("title" => "I'M uNiQUe!") - assert t3.valid?, "Should be valid" - assert t3.save, "Should save t2 as unique" - assert !t3.errors.on(:title) - assert !t3.errors.on(:parent_id) - assert_not_equal "has already been taken", t3.errors.on(:title) - end - - def test_validate_case_sensitive_uniqueness_with_attribute_passed_as_integer - Topic.validates_uniqueness_of(:title, :case_sensitve => true) - t = Topic.create!('title' => 101) - - t2 = Topic.new('title' => 101) - assert !t2.valid? - assert t2.errors.on(:title) - end - - def test_validate_uniqueness_with_non_standard_table_names - i1 = WarehouseThing.create(:value => 1000) - assert !i1.valid?, "i1 should not be valid" - assert i1.errors.on(:value), "Should not be empty" - end - - def test_validates_uniqueness_inside_with_scope - Topic.validates_uniqueness_of(:title) - - Topic.with_scope(:find => { :conditions => { :author_name => "David" } }) do - t1 = Topic.new("title" => "I'm unique!", "author_name" => "Mary") - assert t1.save - t2 = Topic.new("title" => "I'm unique!", "author_name" => "David") - assert !t2.valid? - end - end - - def test_validate_uniqueness_with_columns_which_are_sql_keywords - repair_validations(Guid) do - Guid.validates_uniqueness_of :key - g = Guid.new - g.key = "foo" - assert_nothing_raised { !g.valid? } - end - end - - def test_validate_uniqueness_with_limit - # Event.title is limited to 5 characters - e1 = Event.create(:title => "abcde") - assert e1.valid?, "Could not create an event with a unique, 5 character title" - e2 = Event.create(:title => "abcdefgh") - assert !e2.valid?, "Created an event whose title, with limit taken into account, is not unique" - end - - def test_validate_straight_inheritance_uniqueness - w1 = IneptWizard.create(:name => "Rincewind", :city => "Ankh-Morpork") - assert w1.valid?, "Saving w1" - - # Should use validation from base class (which is abstract) - w2 = IneptWizard.new(:name => "Rincewind", :city => "Quirm") - assert !w2.valid?, "w2 shouldn't be valid" - assert w2.errors.on(:name), "Should have errors for name" - assert_equal "has already been taken", w2.errors.on(:name), "Should have uniqueness message for name" - - w3 = Conjurer.new(:name => "Rincewind", :city => "Quirm") - assert !w3.valid?, "w3 shouldn't be valid" - assert w3.errors.on(:name), "Should have errors for name" - assert_equal "has already been taken", w3.errors.on(:name), "Should have uniqueness message for name" - - w4 = Conjurer.create(:name => "The Amazing Bonko", :city => "Quirm") - assert w4.valid?, "Saving w4" - - w5 = Thaumaturgist.new(:name => "The Amazing Bonko", :city => "Lancre") - assert !w5.valid?, "w5 shouldn't be valid" - assert w5.errors.on(:name), "Should have errors for name" - assert_equal "has already been taken", w5.errors.on(:name), "Should have uniqueness message for name" - - w6 = Thaumaturgist.new(:name => "Mustrum Ridcully", :city => "Quirm") - assert !w6.valid?, "w6 shouldn't be valid" - assert w6.errors.on(:city), "Should have errors for city" - assert_equal "has already been taken", w6.errors.on(:city), "Should have uniqueness message for city" - end - - def test_validate_format - Topic.validates_format_of(:title, :content, :with => /^Validation\smacros \w+!$/, :message => "is bad data") - - t = Topic.create("title" => "i'm incorrect", "content" => "Validation macros rule!") - assert !t.valid?, "Shouldn't be valid" - assert !t.save, "Shouldn't save because it's invalid" - assert_equal "is bad data", t.errors.on(:title) - assert_nil t.errors.on(:content) - - t.title = "Validation macros rule!" - - assert t.save - assert_nil t.errors.on(:title) - - assert_raise(ArgumentError) { Topic.validates_format_of(:title, :content) } - end - - def test_validate_format_with_allow_blank - Topic.validates_format_of(:title, :with => /^Validation\smacros \w+!$/, :allow_blank=>true) - assert !Topic.create("title" => "Shouldn't be valid").valid? - assert Topic.create("title" => "").valid? - assert Topic.create("title" => nil).valid? - assert Topic.create("title" => "Validation macros rule!").valid? - end - - # testing ticket #3142 - def test_validate_format_numeric - Topic.validates_format_of(:title, :content, :with => /^[1-9][0-9]*$/, :message => "is bad data") - - t = Topic.create("title" => "72x", "content" => "6789") - assert !t.valid?, "Shouldn't be valid" - assert !t.save, "Shouldn't save because it's invalid" - assert_equal "is bad data", t.errors.on(:title) - assert_nil t.errors.on(:content) - - t.title = "-11" - assert !t.valid?, "Shouldn't be valid" - - t.title = "03" - assert !t.valid?, "Shouldn't be valid" - - t.title = "z44" - assert !t.valid?, "Shouldn't be valid" - - t.title = "5v7" - assert !t.valid?, "Shouldn't be valid" - - t.title = "1" - - assert t.save - assert_nil t.errors.on(:title) - end - - def test_validate_format_with_formatted_message - Topic.validates_format_of(:title, :with => /^Valid Title$/, :message => "can't be {{value}}") - t = Topic.create(:title => 'Invalid title') - assert_equal "can't be Invalid title", t.errors.on(:title) - end - - def test_validates_inclusion_of - Topic.validates_inclusion_of( :title, :in => %w( a b c d e f g ) ) - - assert !Topic.create("title" => "a!", "content" => "abc").valid? - assert !Topic.create("title" => "a b", "content" => "abc").valid? - assert !Topic.create("title" => nil, "content" => "def").valid? - - t = Topic.create("title" => "a", "content" => "I know you are but what am I?") - assert t.valid? - t.title = "uhoh" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is not included in the list", t.errors["title"] - - assert_raise(ArgumentError) { Topic.validates_inclusion_of( :title, :in => nil ) } - assert_raise(ArgumentError) { Topic.validates_inclusion_of( :title, :in => 0) } - - assert_nothing_raised(ArgumentError) { Topic.validates_inclusion_of( :title, :in => "hi!" ) } - assert_nothing_raised(ArgumentError) { Topic.validates_inclusion_of( :title, :in => {} ) } - assert_nothing_raised(ArgumentError) { Topic.validates_inclusion_of( :title, :in => [] ) } - end - - def test_validates_inclusion_of_with_allow_nil - Topic.validates_inclusion_of( :title, :in => %w( a b c d e f g ), :allow_nil=>true ) - - assert !Topic.create("title" => "a!", "content" => "abc").valid? - assert !Topic.create("title" => "", "content" => "abc").valid? - assert Topic.create("title" => nil, "content" => "abc").valid? - end - - def test_numericality_with_getter_method - repair_validations(Developer) do - Developer.validates_numericality_of( :salary ) - developer = Developer.new("name" => "michael", "salary" => nil) - developer.instance_eval("def salary; read_attribute('salary') ? read_attribute('salary') : 100000; end") - assert developer.valid? - end - end - - def test_validates_length_of_with_allow_nil - Topic.validates_length_of( :title, :is => 5, :allow_nil=>true ) - - assert !Topic.create("title" => "ab").valid? - assert !Topic.create("title" => "").valid? - assert Topic.create("title" => nil).valid? - assert Topic.create("title" => "abcde").valid? - end - - def test_validates_length_of_with_allow_blank - Topic.validates_length_of( :title, :is => 5, :allow_blank=>true ) - - assert !Topic.create("title" => "ab").valid? - assert Topic.create("title" => "").valid? - assert Topic.create("title" => nil).valid? - assert Topic.create("title" => "abcde").valid? - end - - def test_validates_inclusion_of_with_formatted_message - Topic.validates_inclusion_of( :title, :in => %w( a b c d e f g ), :message => "option {{value}} is not in the list" ) - - assert Topic.create("title" => "a", "content" => "abc").valid? - - t = Topic.create("title" => "uhoh", "content" => "abc") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "option uhoh is not in the list", t.errors["title"] - end - - def test_numericality_with_allow_nil_and_getter_method - repair_validations(Developer) do - Developer.validates_numericality_of( :salary, :allow_nil => true) - developer = Developer.new("name" => "michael", "salary" => nil) - developer.instance_eval("def salary; read_attribute('salary') ? read_attribute('salary') : 100000; end") - assert developer.valid? - end - end - - def test_validates_exclusion_of - Topic.validates_exclusion_of( :title, :in => %w( abe monkey ) ) - - assert Topic.create("title" => "something", "content" => "abc").valid? - assert !Topic.create("title" => "monkey", "content" => "abc").valid? - end - - def test_validates_exclusion_of_with_formatted_message - Topic.validates_exclusion_of( :title, :in => %w( abe monkey ), :message => "option {{value}} is restricted" ) - - assert Topic.create("title" => "something", "content" => "abc") - - t = Topic.create("title" => "monkey") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "option monkey is restricted", t.errors["title"] - end - - def test_validates_length_of_using_minimum - Topic.validates_length_of :title, :minimum => 5 - - t = Topic.create("title" => "valid", "content" => "whatever") - assert t.valid? - - t.title = "not" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is too short (minimum is 5 characters)", t.errors["title"] - - t.title = "" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is too short (minimum is 5 characters)", t.errors["title"] - - t.title = nil - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is too short (minimum is 5 characters)", t.errors["title"] - end - - def test_optionally_validates_length_of_using_minimum - Topic.validates_length_of :title, :minimum => 5, :allow_nil => true - - t = Topic.create("title" => "valid", "content" => "whatever") - assert t.valid? - - t.title = nil - assert t.valid? - end - - def test_validates_length_of_using_maximum - Topic.validates_length_of :title, :maximum => 5 - - t = Topic.create("title" => "valid", "content" => "whatever") - assert t.valid? - - t.title = "notvalid" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is too long (maximum is 5 characters)", t.errors["title"] - - t.title = "" - assert t.valid? - - t.title = nil - assert !t.valid? - end - - def test_optionally_validates_length_of_using_maximum - Topic.validates_length_of :title, :maximum => 5, :allow_nil => true - - t = Topic.create("title" => "valid", "content" => "whatever") - assert t.valid? - - t.title = nil - assert t.valid? - end - - def test_validates_length_of_using_within - Topic.validates_length_of(:title, :content, :within => 3..5) - - t = Topic.new("title" => "a!", "content" => "I'm ooooooooh so very long") - assert !t.valid? - assert_equal "is too short (minimum is 3 characters)", t.errors.on(:title) - assert_equal "is too long (maximum is 5 characters)", t.errors.on(:content) - - t.title = nil - t.content = nil - assert !t.valid? - assert_equal "is too short (minimum is 3 characters)", t.errors.on(:title) - assert_equal "is too short (minimum is 3 characters)", t.errors.on(:content) - - t.title = "abe" - t.content = "mad" - assert t.valid? - end - - def test_optionally_validates_length_of_using_within - Topic.validates_length_of :title, :content, :within => 3..5, :allow_nil => true - - t = Topic.create('title' => 'abc', 'content' => 'abcd') - assert t.valid? - - t.title = nil - assert t.valid? - end - - def test_optionally_validates_length_of_using_within_on_create - Topic.validates_length_of :title, :content, :within => 5..10, :on => :create, :too_long => "my string is too long: {{count}}" - - t = Topic.create("title" => "thisisnotvalid", "content" => "whatever") - assert !t.save - assert t.errors.on(:title) - assert_equal "my string is too long: 10", t.errors[:title] - - t.title = "butthisis" - assert t.save - - t.title = "few" - assert t.save - - t.content = "andthisislong" - assert t.save - - t.content = t.title = "iamfine" - assert t.save - end - - def test_optionally_validates_length_of_using_within_on_update - Topic.validates_length_of :title, :content, :within => 5..10, :on => :update, :too_short => "my string is too short: {{count}}" - - t = Topic.create("title" => "vali", "content" => "whatever") - assert !t.save - assert t.errors.on(:title) - - t.title = "not" - assert !t.save - assert t.errors.on(:title) - assert_equal "my string is too short: 5", t.errors[:title] - - t.title = "valid" - t.content = "andthisistoolong" - assert !t.save - assert t.errors.on(:content) - - t.content = "iamfine" - assert t.save - end - - def test_validates_length_of_using_is - Topic.validates_length_of :title, :is => 5 - - t = Topic.create("title" => "valid", "content" => "whatever") - assert t.valid? - - t.title = "notvalid" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is the wrong length (should be 5 characters)", t.errors["title"] - - t.title = "" - assert !t.valid? - - t.title = nil - assert !t.valid? - end - - def test_optionally_validates_length_of_using_is - Topic.validates_length_of :title, :is => 5, :allow_nil => true - - t = Topic.create("title" => "valid", "content" => "whatever") - assert t.valid? - - t.title = nil - assert t.valid? - end - - def test_validates_length_of_using_bignum - bigmin = 2 ** 30 - bigmax = 2 ** 32 - bigrange = bigmin...bigmax - assert_nothing_raised do - Topic.validates_length_of :title, :is => bigmin + 5 - Topic.validates_length_of :title, :within => bigrange - Topic.validates_length_of :title, :in => bigrange - Topic.validates_length_of :title, :minimum => bigmin - Topic.validates_length_of :title, :maximum => bigmax - end - end - - def test_validates_length_with_globally_modified_error_message - ActiveSupport::Deprecation.silence do - ActiveRecord::Errors.default_error_messages[:too_short] = 'tu est trops petit hombre {{count}}' - end - Topic.validates_length_of :title, :minimum => 10 - t = Topic.create(:title => 'too short') - assert !t.valid? - - assert_equal 'tu est trops petit hombre 10', t.errors['title'] - end - - def test_validates_size_of_association - repair_validations(Owner) do - assert_nothing_raised { Owner.validates_size_of :pets, :minimum => 1 } - o = Owner.new('name' => 'nopets') - assert !o.save - assert o.errors.on(:pets) - pet = o.pets.build('name' => 'apet') - assert o.valid? - end - end - - def test_validates_size_of_association_using_within - repair_validations(Owner) do - assert_nothing_raised { Owner.validates_size_of :pets, :within => 1..2 } - o = Owner.new('name' => 'nopets') - assert !o.save - assert o.errors.on(:pets) - - pet = o.pets.build('name' => 'apet') - assert o.valid? - - 2.times { o.pets.build('name' => 'apet') } - assert !o.save - assert o.errors.on(:pets) - end - end - - def test_validates_length_of_nasty_params - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :minimum=>6, :maximum=>9) } - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :within=>6, :maximum=>9) } - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :within=>6, :minimum=>9) } - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :within=>6, :is=>9) } - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :minimum=>"a") } - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :maximum=>"a") } - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :within=>"a") } - assert_raise(ArgumentError) { Topic.validates_length_of(:title, :is=>"a") } - end - - def test_validates_length_of_custom_errors_for_minimum_with_message - Topic.validates_length_of( :title, :minimum=>5, :message=>"boo {{count}}" ) - t = Topic.create("title" => "uhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "boo 5", t.errors["title"] - end - - def test_validates_length_of_custom_errors_for_minimum_with_too_short - Topic.validates_length_of( :title, :minimum=>5, :too_short=>"hoo {{count}}" ) - t = Topic.create("title" => "uhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_validates_length_of_custom_errors_for_maximum_with_message - Topic.validates_length_of( :title, :maximum=>5, :message=>"boo {{count}}" ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "boo 5", t.errors["title"] - end - - def test_validates_length_of_custom_errors_for_in - Topic.validates_length_of(:title, :in => 10..20, :message => "hoo {{count}}") - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 10", t.errors["title"] - - t = Topic.create("title" => "uhohuhohuhohuhohuhohuhohuhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 20", t.errors["title"] - end - - def test_validates_length_of_custom_errors_for_maximum_with_too_long - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}" ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_validates_length_of_custom_errors_for_is_with_message - Topic.validates_length_of( :title, :is=>5, :message=>"boo {{count}}" ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "boo 5", t.errors["title"] - end - - def test_validates_length_of_custom_errors_for_is_with_wrong_length - Topic.validates_length_of( :title, :is=>5, :wrong_length=>"hoo {{count}}" ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_validates_length_of_using_minimum_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :minimum => 5 - - t = Topic.create("title" => "一二三四五", "content" => "whatever") - assert t.valid? - - t.title = "一二三四" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is too short (minimum is 5 characters)", t.errors["title"] - end - end - - def test_validates_length_of_using_maximum_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :maximum => 5 - - t = Topic.create("title" => "一二三四五", "content" => "whatever") - assert t.valid? - - t.title = "一二34五六" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is too long (maximum is 5 characters)", t.errors["title"] - end - end - - def test_validates_length_of_using_within_utf8 - with_kcode('UTF8') do - Topic.validates_length_of(:title, :content, :within => 3..5) - - t = Topic.new("title" => "一二", "content" => "12三四五六七") - assert !t.valid? - assert_equal "is too short (minimum is 3 characters)", t.errors.on(:title) - assert_equal "is too long (maximum is 5 characters)", t.errors.on(:content) - t.title = "一二三" - t.content = "12三" - assert t.valid? - end - end - - def test_optionally_validates_length_of_using_within_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :within => 3..5, :allow_nil => true - - t = Topic.create(:title => "一二三四五") - assert t.valid?, t.errors.inspect - - t = Topic.create(:title => "一二三") - assert t.valid?, t.errors.inspect - - t.title = nil - assert t.valid?, t.errors.inspect - end - end - - def test_optionally_validates_length_of_using_within_on_create_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :within => 5..10, :on => :create, :too_long => "長すぎます: {{count}}" - - t = Topic.create("title" => "一二三四五六七八九十A", "content" => "whatever") - assert !t.save - assert t.errors.on(:title) - assert_equal "長すぎます: 10", t.errors[:title] - - t.title = "一二三四五六七八九" - assert t.save - - t.title = "一二3" - assert t.save - - t.content = "一二三四五六七八九十" - assert t.save - - t.content = t.title = "一二三四五六" - assert t.save - end - end - - def test_optionally_validates_length_of_using_within_on_update_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :within => 5..10, :on => :update, :too_short => "短すぎます: {{count}}" - - t = Topic.create("title" => "一二三4", "content" => "whatever") - assert !t.save - assert t.errors.on(:title) - - t.title = "1二三4" - assert !t.save - assert t.errors.on(:title) - assert_equal "短すぎます: 5", t.errors[:title] - - t.title = "一二三四五六七八九十A" - assert !t.save - assert t.errors.on(:title) - - t.title = "一二345" - assert t.save - end - end - - def test_validates_length_of_using_is_utf8 - with_kcode('UTF8') do - Topic.validates_length_of :title, :is => 5 - - t = Topic.create("title" => "一二345", "content" => "whatever") - assert t.valid? - - t.title = "一二345六" - assert !t.valid? - assert t.errors.on(:title) - assert_equal "is the wrong length (should be 5 characters)", t.errors["title"] - end - end - - def test_validates_length_of_with_block - Topic.validates_length_of :content, :minimum => 5, :too_short=>"Your essay must be at least {{count}} words.", - :tokenizer => lambda {|str| str.scan(/\w+/) } - t = Topic.create!(:content => "this content should be long enough") - assert t.valid? - - t.content = "not long enough" - assert !t.valid? - assert t.errors.on(:content) - assert_equal "Your essay must be at least 5 words.", t.errors[:content] - end - - def test_validates_size_of_association_utf8 - repair_validations(Owner) do - with_kcode('UTF8') do - assert_nothing_raised { Owner.validates_size_of :pets, :minimum => 1 } - o = Owner.new('name' => 'あいうえおかきくけこ') - assert !o.save - assert o.errors.on(:pets) - o.pets.build('name' => 'あいうえおかきくけこ') - assert o.valid? - end - end - end - - def test_validates_associated_many - Topic.validates_associated( :replies ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - t.replies << [r = Reply.new("title" => "A reply"), r2 = Reply.new("title" => "Another reply", "content" => "non-empty"), r3 = Reply.new("title" => "Yet another reply"), r4 = Reply.new("title" => "The last reply", "content" => "non-empty")] - assert !t.valid? - assert t.errors.on(:replies) - assert_equal 1, r.errors.count # make sure all associated objects have been validated - assert_equal 0, r2.errors.count - assert_equal 1, r3.errors.count - assert_equal 0, r4.errors.count - r.content = r3.content = "non-empty" - assert t.valid? - end - - def test_validates_associated_one - repair_validations(Reply) do - Reply.validates_associated( :topic ) - Topic.validates_presence_of( :content ) - r = Reply.new("title" => "A reply", "content" => "with content!") - r.topic = Topic.create("title" => "uhohuhoh") - assert !r.valid? - assert r.errors.on(:topic) - r.topic.content = "non-empty" - assert r.valid? - end - end - - def test_validate_block - Topic.validate { |topic| topic.errors.add("title", "will never be valid") } - t = Topic.create("title" => "Title", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "will never be valid", t.errors["title"] - end - - def test_invalid_validator - Topic.validate 3 - assert_raise(ArgumentError) { t = Topic.create } - end - - def test_throw_away_typing - d = Developer.new("name" => "David", "salary" => "100,000") - assert !d.valid? - assert_equal 100, d.salary - assert_equal "100,000", d.salary_before_type_cast - end - - def test_validates_acceptance_of_with_custom_error_using_quotes - repair_validations(Developer) do - Developer.validates_acceptance_of :salary, :message=> "This string contains 'single' and \"double\" quotes" - d = Developer.new - d.salary = "0" - assert !d.valid? - assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:salary).last - end - end - - def test_validates_confirmation_of_with_custom_error_using_quotes - repair_validations(Developer) do - Developer.validates_confirmation_of :name, :message=> "confirm 'single' and \"double\" quotes" - d = Developer.new - d.name = "John" - d.name_confirmation = "Johnny" - assert !d.valid? - assert_equal "confirm 'single' and \"double\" quotes", d.errors.on(:name) - end - end - - def test_validates_format_of_with_custom_error_using_quotes - repair_validations(Developer) do - Developer.validates_format_of :name, :with => /^(A-Z*)$/, :message=> "format 'single' and \"double\" quotes" - d = Developer.new - d.name = d.name_confirmation = "John 32" - assert !d.valid? - assert_equal "format 'single' and \"double\" quotes", d.errors.on(:name) - end - end - - def test_validates_inclusion_of_with_custom_error_using_quotes - repair_validations(Developer) do - Developer.validates_inclusion_of :salary, :in => 1000..80000, :message=> "This string contains 'single' and \"double\" quotes" - d = Developer.new - d.salary = "90,000" - assert !d.valid? - assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:salary).last - end - end - - def test_validates_length_of_with_custom_too_long_using_quotes - repair_validations(Developer) do - Developer.validates_length_of :name, :maximum => 4, :too_long=> "This string contains 'single' and \"double\" quotes" - d = Developer.new - d.name = "Jeffrey" - assert !d.valid? - assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) - end - end - - def test_validates_length_of_with_custom_too_short_using_quotes - repair_validations(Developer) do - Developer.validates_length_of :name, :minimum => 4, :too_short=> "This string contains 'single' and \"double\" quotes" - d = Developer.new - d.name = "Joe" - assert !d.valid? - assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) - end - end - - def test_validates_length_of_with_custom_message_using_quotes - repair_validations(Developer) do - Developer.validates_length_of :name, :minimum => 4, :message=> "This string contains 'single' and \"double\" quotes" - d = Developer.new - d.name = "Joe" - assert !d.valid? - assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) - end - end - - def test_validates_presence_of_with_custom_message_using_quotes - repair_validations(Developer) do - Developer.validates_presence_of :non_existent, :message=> "This string contains 'single' and \"double\" quotes" - d = Developer.new - d.name = "Joe" - assert !d.valid? - assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:non_existent) - end - end - - def test_validates_uniqueness_of_with_custom_message_using_quotes - repair_validations(Developer) do - Developer.validates_uniqueness_of :name, :message=> "This string contains 'single' and \"double\" quotes" - d = Developer.new - d.name = "David" - assert !d.valid? - assert_equal "This string contains 'single' and \"double\" quotes", d.errors.on(:name) - end - end - - def test_validates_associated_with_custom_message_using_quotes - repair_validations(Reply) do - Reply.validates_associated :topic, :message=> "This string contains 'single' and \"double\" quotes" - Topic.validates_presence_of :content - r = Reply.create("title" => "A reply", "content" => "with content!") - r.topic = Topic.create("title" => "uhohuhoh") - assert !r.valid? - assert_equal "This string contains 'single' and \"double\" quotes", r.errors.on(:topic) - end - end - - def test_if_validation_using_method_true - # When the method returns true - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :if => :condition_is_true ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_unless_validation_using_method_true - # When the method returns true - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :unless => :condition_is_true ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert t.valid? - assert !t.errors.on(:title) - end - - def test_if_validation_using_method_false - # When the method returns false - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :if => :condition_is_true_but_its_not ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert t.valid? - assert !t.errors.on(:title) - end - - def test_unless_validation_using_method_false - # When the method returns false - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :unless => :condition_is_true_but_its_not ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_if_validation_using_string_true - # When the evaluated string returns true - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :if => "a = 1; a == 1" ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_unless_validation_using_string_true - # When the evaluated string returns true - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :unless => "a = 1; a == 1" ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert t.valid? - assert !t.errors.on(:title) - end - - def test_if_validation_using_string_false - # When the evaluated string returns false - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :if => "false") - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert t.valid? - assert !t.errors.on(:title) - end - - def test_unless_validation_using_string_false - # When the evaluated string returns false - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :unless => "false") - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_if_validation_using_block_true - # When the block returns true - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", - :if => Proc.new { |r| r.content.size > 4 } ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_unless_validation_using_block_true - # When the block returns true - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", - :unless => Proc.new { |r| r.content.size > 4 } ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert t.valid? - assert !t.errors.on(:title) - end - - def test_if_validation_using_block_false - # When the block returns false - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", - :if => Proc.new { |r| r.title != "uhohuhoh"} ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert t.valid? - assert !t.errors.on(:title) - end - - def test_unless_validation_using_block_false - # When the block returns false - Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", - :unless => Proc.new { |r| r.title != "uhohuhoh"} ) - t = Topic.create("title" => "uhohuhoh", "content" => "whatever") - assert !t.valid? - assert t.errors.on(:title) - assert_equal "hoo 5", t.errors["title"] - end - - def test_validates_associated_missing - repair_validations(Reply) do - Reply.validates_presence_of(:topic) - r = Reply.create("title" => "A reply", "content" => "with content!") - assert !r.valid? - assert r.errors.on(:topic) - - r.topic = Topic.find :first - assert r.valid? - end - end - - def test_errors_to_xml - r = Reply.new :title => "Wrong Create" - assert !r.valid? - xml = r.errors.to_xml(:skip_instruct => true) - assert_equal "<errors>", xml.first(8) - assert xml.include?("<error>Title is Wrong Create</error>") - assert xml.include?("<error>Content Empty</error>") - end - - def test_validation_order - Topic.validates_presence_of :title - Topic.validates_length_of :title, :minimum => 2 - - t = Topic.new("title" => "") - assert !t.valid? - assert_equal "can't be blank", t.errors.on("title").first - end - - def test_invalid_should_be_the_opposite_of_valid - Topic.validates_presence_of :title - - t = Topic.new - assert t.invalid? - assert t.errors.invalid?(:title) - - t.title = 'Things are going to change' - assert !t.invalid? - end - - # previous implementation of validates_presence_of eval'd the - # string with the wrong binding, this regression test is to - # ensure that it works correctly - def test_validation_with_if_as_string - Topic.validates_presence_of(:title) - Topic.validates_presence_of(:author_name, :if => "title.to_s.match('important')") - - t = Topic.new - assert !t.valid?, "A topic without a title should not be valid" - assert !t.errors.invalid?("author_name"), "A topic without an 'important' title should not require an author" - - t.title = "Just a title" - assert t.valid?, "A topic with a basic title should be valid" - - t.title = "A very important title" - assert !t.valid?, "A topic with an important title, but without an author, should not be valid" - assert t.errors.invalid?("author_name"), "A topic with an 'important' title should require an author" - - t.author_name = "Hubert J. Farnsworth" - assert t.valid?, "A topic with an important title and author should be valid" - end -end - - -class ValidatesNumericalityTest < ActiveRecord::TestCase - NIL = [nil] - BLANK = ["", " ", " \t \r \n"] - BIGDECIMAL_STRINGS = %w(12345678901234567890.1234567890) # 30 significent digits - FLOAT_STRINGS = %w(0.0 +0.0 -0.0 10.0 10.5 -10.5 -0.0001 -090.1 90.1e1 -90.1e5 -90.1e-5 90e-5) - INTEGER_STRINGS = %w(0 +0 -0 10 +10 -10 0090 -090) - FLOATS = [0.0, 10.0, 10.5, -10.5, -0.0001] + FLOAT_STRINGS - INTEGERS = [0, 10, -10] + INTEGER_STRINGS - BIGDECIMAL = BIGDECIMAL_STRINGS.collect! { |bd| BigDecimal.new(bd) } - JUNK = ["not a number", "42 not a number", "0xdeadbeef", "00-1", "--3", "+-3", "+3-1", "-+019.0", "12.12.13.12", "123\nnot a number"] - INFINITY = [1.0/0.0] - - repair_validations(Topic) - - def test_default_validates_numericality_of - Topic.validates_numericality_of :approved - - invalid!(NIL + BLANK + JUNK) - valid!(FLOATS + INTEGERS + BIGDECIMAL + INFINITY) - end - - def test_validates_numericality_of_with_nil_allowed - Topic.validates_numericality_of :approved, :allow_nil => true - - invalid!(JUNK) - valid!(NIL + BLANK + FLOATS + INTEGERS + BIGDECIMAL + INFINITY) - end - - def test_validates_numericality_of_with_integer_only - Topic.validates_numericality_of :approved, :only_integer => true - - invalid!(NIL + BLANK + JUNK + FLOATS + BIGDECIMAL + INFINITY) - valid!(INTEGERS) - end - - def test_validates_numericality_of_with_integer_only_and_nil_allowed - Topic.validates_numericality_of :approved, :only_integer => true, :allow_nil => true - - invalid!(JUNK + FLOATS + BIGDECIMAL + INFINITY) - valid!(NIL + BLANK + INTEGERS) - end - - def test_validates_numericality_with_greater_than - Topic.validates_numericality_of :approved, :greater_than => 10 - - invalid!([-10, 10], 'must be greater than 10') - valid!([11]) - end - - def test_validates_numericality_with_greater_than_or_equal - Topic.validates_numericality_of :approved, :greater_than_or_equal_to => 10 - - invalid!([-9, 9], 'must be greater than or equal to 10') - valid!([10]) - end - - def test_validates_numericality_with_equal_to - Topic.validates_numericality_of :approved, :equal_to => 10 - - invalid!([-10, 11] + INFINITY, 'must be equal to 10') - valid!([10]) - end - - def test_validates_numericality_with_less_than - Topic.validates_numericality_of :approved, :less_than => 10 - - invalid!([10], 'must be less than 10') - valid!([-9, 9]) - end - - def test_validates_numericality_with_less_than_or_equal_to - Topic.validates_numericality_of :approved, :less_than_or_equal_to => 10 - - invalid!([11], 'must be less than or equal to 10') - valid!([-10, 10]) - end - - def test_validates_numericality_with_odd - Topic.validates_numericality_of :approved, :odd => true - - invalid!([-2, 2], 'must be odd') - valid!([-1, 1]) - end - - def test_validates_numericality_with_even - Topic.validates_numericality_of :approved, :even => true - - invalid!([-1, 1], 'must be even') - valid!([-2, 2]) - end - - def test_validates_numericality_with_greater_than_less_than_and_even - Topic.validates_numericality_of :approved, :greater_than => 1, :less_than => 4, :even => true - - invalid!([1, 3, 4]) - valid!([2]) - end - - def test_validates_numericality_with_numeric_message - Topic.validates_numericality_of :approved, :less_than => 4, :message => "smaller than {{count}}" - topic = Topic.new("title" => "numeric test", "approved" => 10) - - assert !topic.valid? - assert_equal "smaller than 4", topic.errors.on(:approved) - - Topic.validates_numericality_of :approved, :greater_than => 4, :message => "greater than {{count}}" - topic = Topic.new("title" => "numeric test", "approved" => 1) - - assert !topic.valid? - assert_equal "greater than 4", topic.errors.on(:approved) - end - - private - def invalid!(values, error=nil) - with_each_topic_approved_value(values) do |topic, value| - assert !topic.valid?, "#{value.inspect} not rejected as a number" - assert topic.errors.on(:approved) - assert_equal error, topic.errors.on(:approved) if error - end - end - - def valid!(values) - with_each_topic_approved_value(values) do |topic, value| - assert topic.valid?, "#{value.inspect} not accepted as a number" - end - end - - def with_each_topic_approved_value(values) - topic = Topic.new("title" => "numeric test", "content" => "whatever") - values.each do |value| - topic.approved = value - yield topic, value - end - end -end diff --git a/vendor/rails/activerecord/test/cases/xml_serialization_test.rb b/vendor/rails/activerecord/test/cases/xml_serialization_test.rb deleted file mode 100644 index b499976..0000000 --- a/vendor/rails/activerecord/test/cases/xml_serialization_test.rb +++ /dev/null @@ -1,220 +0,0 @@ -require "cases/helper" -require 'models/contact' -require 'models/post' -require 'models/author' -require 'models/tagging' -require 'models/comment' - -class XmlSerializationTest < ActiveRecord::TestCase - def test_should_serialize_default_root - @xml = Contact.new.to_xml - assert_match %r{^<contact>}, @xml - assert_match %r{</contact>$}, @xml - end - - def test_should_serialize_default_root_with_namespace - @xml = Contact.new.to_xml :namespace=>"http://xml.rubyonrails.org/contact" - assert_match %r{^<contact xmlns="http://xml.rubyonrails.org/contact">}, @xml - assert_match %r{</contact>$}, @xml - end - - def test_should_serialize_custom_root - @xml = Contact.new.to_xml :root => 'xml_contact' - assert_match %r{^<xml-contact>}, @xml - assert_match %r{</xml-contact>$}, @xml - end - - def test_should_allow_undasherized_tags - @xml = Contact.new.to_xml :root => 'xml_contact', :dasherize => false - assert_match %r{^<xml_contact>}, @xml - assert_match %r{</xml_contact>$}, @xml - assert_match %r{<created_at}, @xml - end - - def test_should_allow_camelized_tags - @xml = Contact.new.to_xml :root => 'xml_contact', :camelize => true - assert_match %r{^<XmlContact>}, @xml - assert_match %r{</XmlContact>$}, @xml - assert_match %r{<CreatedAt}, @xml - end - - def test_should_allow_skipped_types - @xml = Contact.new(:age => 25).to_xml :skip_types => true - assert %r{<age>25</age>}.match(@xml) - end - - def test_should_include_yielded_additions - @xml = Contact.new.to_xml do |xml| - xml.creator "David" - end - assert_match %r{<creator>David</creator>}, @xml - end -end - -class DefaultXmlSerializationTest < ActiveRecord::TestCase - def setup - @xml = Contact.new(:name => 'aaron stack', :age => 25, :avatar => 'binarydata', :created_at => Time.utc(2006, 8, 1), :awesome => false, :preferences => { :gem => 'ruby' }).to_xml - end - - def test_should_serialize_string - assert_match %r{<name>aaron stack</name>}, @xml - end - - def test_should_serialize_integer - assert_match %r{<age type="integer">25</age>}, @xml - end - - def test_should_serialize_binary - assert_match %r{YmluYXJ5ZGF0YQ==\n</avatar>}, @xml - assert_match %r{<avatar(.*)(type="binary")}, @xml - assert_match %r{<avatar(.*)(encoding="base64")}, @xml - end - - def test_should_serialize_datetime - assert_match %r{<created-at type=\"datetime\">2006-08-01T00:00:00Z</created-at>}, @xml - end - - def test_should_serialize_boolean - assert_match %r{<awesome type=\"boolean\">false</awesome>}, @xml - end - - def test_should_serialize_yaml - assert_match %r{<preferences type=\"yaml\">--- \n:gem: ruby\n</preferences>}, @xml - end -end - -class NilXmlSerializationTest < ActiveRecord::TestCase - def setup - @xml = Contact.new.to_xml(:root => 'xml_contact') - end - - def test_should_serialize_string - assert_match %r{<name nil="true"></name>}, @xml - end - - def test_should_serialize_integer - assert %r{<age (.*)></age>}.match(@xml) - attributes = $1 - assert_match %r{nil="true"}, attributes - assert_match %r{type="integer"}, attributes - end - - def test_should_serialize_binary - assert %r{<avatar (.*)></avatar>}.match(@xml) - attributes = $1 - assert_match %r{type="binary"}, attributes - assert_match %r{encoding="base64"}, attributes - assert_match %r{nil="true"}, attributes - end - - def test_should_serialize_datetime - assert %r{<created-at (.*)></created-at>}.match(@xml) - attributes = $1 - assert_match %r{nil="true"}, attributes - assert_match %r{type="datetime"}, attributes - end - - def test_should_serialize_boolean - assert %r{<awesome (.*)></awesome>}.match(@xml) - attributes = $1 - assert_match %r{type="boolean"}, attributes - assert_match %r{nil="true"}, attributes - end - - def test_should_serialize_yaml - assert %r{<preferences(.*)></preferences>}.match(@xml) - attributes = $1 - assert_match %r{type="yaml"}, attributes - assert_match %r{nil="true"}, attributes - end -end - -class DatabaseConnectedXmlSerializationTest < ActiveRecord::TestCase - fixtures :authors, :posts - # to_xml used to mess with the hash the user provided which - # caused the builder to be reused. This meant the document kept - # getting appended to. - def test_passing_hash_shouldnt_reuse_builder - options = {:include=>:posts} - david = authors(:david) - first_xml_size = david.to_xml(options).size - second_xml_size = david.to_xml(options).size - assert_equal first_xml_size, second_xml_size - end - - def test_include_uses_association_name - xml = authors(:david).to_xml :include=>:hello_posts, :indent => 0 - assert_match %r{<hello-posts type="array">}, xml - assert_match %r{<hello-post type="Post">}, xml - assert_match %r{<hello-post type="StiPost">}, xml - end - - def test_included_associations_should_skip_types - xml = authors(:david).to_xml :include=>:hello_posts, :indent => 0, :skip_types => true - assert_match %r{<hello-posts>}, xml - assert_match %r{<hello-post>}, xml - assert_match %r{<hello-post>}, xml - end - - def test_methods_are_called_on_object - xml = authors(:david).to_xml :methods => :label, :indent => 0 - assert_match %r{<label>.*</label>}, xml - end - - def test_should_not_call_methods_on_associations_that_dont_respond - xml = authors(:david).to_xml :include=>:hello_posts, :methods => :label, :indent => 2 - assert !authors(:david).hello_posts.first.respond_to?(:label) - assert_match %r{^ <label>.*</label>}, xml - assert_no_match %r{^ <label>}, xml - end - - def test_procs_are_called_on_object - proc = Proc.new { |options| options[:builder].tag!('nationality', 'Danish') } - xml = authors(:david).to_xml(:procs => [ proc ]) - assert_match %r{<nationality>Danish</nationality>}, xml - end - - def test_top_level_procs_arent_applied_to_associations - author_proc = Proc.new { |options| options[:builder].tag!('nationality', 'Danish') } - xml = authors(:david).to_xml(:procs => [ author_proc ], :include => :posts, :indent => 2) - - assert_match %r{^ <nationality>Danish</nationality>}, xml - assert_no_match %r{^ {6}<nationality>Danish</nationality>}, xml - end - - def test_procs_on_included_associations_are_called - posts_proc = Proc.new { |options| options[:builder].tag!('copyright', 'DHH') } - xml = authors(:david).to_xml( - :indent => 2, - :include => { - :posts => { :procs => [ posts_proc ] } - } - ) - - assert_no_match %r{^ <copyright>DHH</copyright>}, xml - assert_match %r{^ {6}<copyright>DHH</copyright>}, xml - end - - def test_should_include_empty_has_many_as_empty_array - authors(:david).posts.delete_all - xml = authors(:david).to_xml :include=>:posts, :indent => 2 - - assert_equal [], Hash.from_xml(xml)['author']['posts'] - assert_match %r{^ <posts type="array"/>}, xml - end - - def test_should_has_many_array_elements_should_include_type_when_different_from_guessed_value - xml = authors(:david).to_xml :include=>:posts_with_comments, :indent => 2 - - assert Hash.from_xml(xml) - assert_match %r{^ <posts-with-comments type="array">}, xml - assert_match %r{^ <posts-with-comment type="Post">}, xml - assert_match %r{^ <posts-with-comment type="StiPost">}, xml - - types = Hash.from_xml(xml)['author']['posts_with_comments'].collect {|t| t['type'] } - assert types.include?('SpecialPost') - assert types.include?('Post') - assert types.include?('StiPost') - end - -end diff --git a/vendor/rails/activerecord/test/config.rb b/vendor/rails/activerecord/test/config.rb deleted file mode 100644 index 6e2e8b2..0000000 --- a/vendor/rails/activerecord/test/config.rb +++ /dev/null @@ -1,5 +0,0 @@ -TEST_ROOT = File.expand_path(File.dirname(__FILE__)) -ASSETS_ROOT = TEST_ROOT + "/assets" -FIXTURES_ROOT = TEST_ROOT + "/fixtures" -MIGRATIONS_ROOT = TEST_ROOT + "/migrations" -SCHEMA_ROOT = TEST_ROOT + "/schema" diff --git a/vendor/rails/activerecord/test/connections/jdbc_jdbcderby/connection.rb b/vendor/rails/activerecord/test/connections/jdbc_jdbcderby/connection.rb deleted file mode 100644 index 222ef5d..0000000 --- a/vendor/rails/activerecord/test/connections/jdbc_jdbcderby/connection.rb +++ /dev/null @@ -1,18 +0,0 @@ -print "Using Derby via JRuby, activerecord-jdbc-adapter and activerecord-jdbcderby-adapter\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'jdbcderby', - :database => 'activerecord_unittest' - }, - 'arunit2' => { - :adapter => 'jdbcderby', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/jdbc_jdbch2/connection.rb b/vendor/rails/activerecord/test/connections/jdbc_jdbch2/connection.rb deleted file mode 100644 index 9d2875e..0000000 --- a/vendor/rails/activerecord/test/connections/jdbc_jdbch2/connection.rb +++ /dev/null @@ -1,18 +0,0 @@ -print "Using H2 via JRuby, activerecord-jdbc-adapter and activerecord-jdbch2-adapter\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'jdbch2', - :database => 'activerecord_unittest' - }, - 'arunit2' => { - :adapter => 'jdbch2', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/jdbc_jdbchsqldb/connection.rb b/vendor/rails/activerecord/test/connections/jdbc_jdbchsqldb/connection.rb deleted file mode 100644 index fa943c2..0000000 --- a/vendor/rails/activerecord/test/connections/jdbc_jdbchsqldb/connection.rb +++ /dev/null @@ -1,18 +0,0 @@ -print "Using HSQLDB via JRuby, activerecord-jdbc-adapter and activerecord-jdbchsqldb-adapter\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'jdbchsqldb', - :database => 'activerecord_unittest' - }, - 'arunit2' => { - :adapter => 'jdbchsqldb', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/jdbc_jdbcmysql/connection.rb b/vendor/rails/activerecord/test/connections/jdbc_jdbcmysql/connection.rb deleted file mode 100644 index e2517a5..0000000 --- a/vendor/rails/activerecord/test/connections/jdbc_jdbcmysql/connection.rb +++ /dev/null @@ -1,26 +0,0 @@ -print "Using MySQL via JRuby, activerecord-jdbc-adapter and activerecord-jdbcmysql-adapter\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -# GRANT ALL PRIVILEGES ON activerecord_unittest.* to 'rails'@'localhost'; -# GRANT ALL PRIVILEGES ON activerecord_unittest2.* to 'rails'@'localhost'; - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'jdbcmysql', - :username => 'rails', - :encoding => 'utf8', - :database => 'activerecord_unittest', - }, - 'arunit2' => { - :adapter => 'jdbcmysql', - :username => 'rails', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' - diff --git a/vendor/rails/activerecord/test/connections/jdbc_jdbcpostgresql/connection.rb b/vendor/rails/activerecord/test/connections/jdbc_jdbcpostgresql/connection.rb deleted file mode 100644 index 0685da4..0000000 --- a/vendor/rails/activerecord/test/connections/jdbc_jdbcpostgresql/connection.rb +++ /dev/null @@ -1,26 +0,0 @@ -print "Using Postgrsql via JRuby, activerecord-jdbc-adapter and activerecord-postgresql-adapter\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -# createuser rails --createdb --no-superuser --no-createrole -# createdb -O rails activerecord_unittest -# createdb -O rails activerecord_unittest2 - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'jdbcpostgresql', - :username => ENV['USER'] || 'rails', - :database => 'activerecord_unittest' - }, - 'arunit2' => { - :adapter => 'jdbcpostgresql', - :username => ENV['USER'] || 'rails', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' - diff --git a/vendor/rails/activerecord/test/connections/jdbc_jdbcsqlite3/connection.rb b/vendor/rails/activerecord/test/connections/jdbc_jdbcsqlite3/connection.rb deleted file mode 100644 index 26d4676..0000000 --- a/vendor/rails/activerecord/test/connections/jdbc_jdbcsqlite3/connection.rb +++ /dev/null @@ -1,25 +0,0 @@ -print "Using SQLite3 via JRuby, activerecord-jdbc-adapter and activerecord-jdbcsqlite3-adapter\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -class SqliteError < StandardError -end - -BASE_DIR = FIXTURES_ROOT -sqlite_test_db = "#{BASE_DIR}/fixture_database.sqlite3" -sqlite_test_db2 = "#{BASE_DIR}/fixture_database_2.sqlite3" - -def make_connection(clazz, db_file) - ActiveRecord::Base.configurations = { clazz.name => { :adapter => 'jdbcsqlite3', :database => db_file, :timeout => 5000 } } - unless File.exist?(db_file) - puts "SQLite3 database not found at #{db_file}. Rebuilding it." - sqlite_command = %Q{sqlite3 "#{db_file}" "create table a (a integer); drop table a;"} - puts "Executing '#{sqlite_command}'" - raise SqliteError.new("Seems that there is no sqlite3 executable available") unless system(sqlite_command) - end - clazz.establish_connection(clazz.name) -end - -make_connection(ActiveRecord::Base, sqlite_test_db) -make_connection(Course, sqlite_test_db2) diff --git a/vendor/rails/activerecord/test/connections/native_db2/connection.rb b/vendor/rails/activerecord/test/connections/native_db2/connection.rb deleted file mode 100644 index 324315d..0000000 --- a/vendor/rails/activerecord/test/connections/native_db2/connection.rb +++ /dev/null @@ -1,25 +0,0 @@ -print "Using native DB2\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'db2', - :host => 'localhost', - :username => 'arunit', - :password => 'arunit', - :database => 'arunit' - }, - 'arunit2' => { - :adapter => 'db2', - :host => 'localhost', - :username => 'arunit', - :password => 'arunit', - :database => 'arunit2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/native_firebird/connection.rb b/vendor/rails/activerecord/test/connections/native_firebird/connection.rb deleted file mode 100644 index 67a936c..0000000 --- a/vendor/rails/activerecord/test/connections/native_firebird/connection.rb +++ /dev/null @@ -1,26 +0,0 @@ -print "Using native Firebird\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'firebird', - :host => 'localhost', - :username => 'rails', - :password => 'rails', - :database => 'activerecord_unittest', - :charset => 'UTF8' - }, - 'arunit2' => { - :adapter => 'firebird', - :host => 'localhost', - :username => 'rails', - :password => 'rails', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/native_frontbase/connection.rb b/vendor/rails/activerecord/test/connections/native_frontbase/connection.rb deleted file mode 100644 index c01d864..0000000 --- a/vendor/rails/activerecord/test/connections/native_frontbase/connection.rb +++ /dev/null @@ -1,27 +0,0 @@ -puts 'Using native Frontbase' -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'frontbase', - :host => 'localhost', - :username => 'rails', - :password => '', - :database => 'activerecord_unittest', - :session_name => "unittest-#{$$}" - }, - 'arunit2' => { - :adapter => 'frontbase', - :host => 'localhost', - :username => 'rails', - :password => '', - :database => 'activerecord_unittest2', - :session_name => "unittest-#{$$}" - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/native_mysql/connection.rb b/vendor/rails/activerecord/test/connections/native_mysql/connection.rb deleted file mode 100644 index 140e06d..0000000 --- a/vendor/rails/activerecord/test/connections/native_mysql/connection.rb +++ /dev/null @@ -1,25 +0,0 @@ -print "Using native MySQL\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -# GRANT ALL PRIVILEGES ON activerecord_unittest.* to 'rails'@'localhost'; -# GRANT ALL PRIVILEGES ON activerecord_unittest2.* to 'rails'@'localhost'; - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'mysql', - :username => 'rails', - :encoding => 'utf8', - :database => 'activerecord_unittest', - }, - 'arunit2' => { - :adapter => 'mysql', - :username => 'rails', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/native_openbase/connection.rb b/vendor/rails/activerecord/test/connections/native_openbase/connection.rb deleted file mode 100644 index 655cb9c..0000000 --- a/vendor/rails/activerecord/test/connections/native_openbase/connection.rb +++ /dev/null @@ -1,21 +0,0 @@ -print "Using native OpenBase\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'openbase', - :username => 'admin', - :database => 'activerecord_unittest', - }, - 'arunit2' => { - :adapter => 'openbase', - :username => 'admin', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/native_oracle/connection.rb b/vendor/rails/activerecord/test/connections/native_oracle/connection.rb deleted file mode 100644 index 0954b27..0000000 --- a/vendor/rails/activerecord/test/connections/native_oracle/connection.rb +++ /dev/null @@ -1,27 +0,0 @@ -print "Using Oracle\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new STDOUT -ActiveRecord::Base.logger.level = Logger::WARN - -# Set these to your database connection strings -db = ENV['ARUNIT_DB'] || 'activerecord_unittest' - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'oracle', - :username => 'arunit', - :password => 'arunit', - :database => db, - }, - 'arunit2' => { - :adapter => 'oracle', - :username => 'arunit2', - :password => 'arunit2', - :database => db - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/native_postgresql/connection.rb b/vendor/rails/activerecord/test/connections/native_postgresql/connection.rb deleted file mode 100644 index 3b5ff90..0000000 --- a/vendor/rails/activerecord/test/connections/native_postgresql/connection.rb +++ /dev/null @@ -1,21 +0,0 @@ -print "Using native PostgreSQL\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'postgresql', - :database => 'activerecord_unittest', - :min_messages => 'warning' - }, - 'arunit2' => { - :adapter => 'postgresql', - :database => 'activerecord_unittest2', - :min_messages => 'warning' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/connections/native_sqlite/connection.rb b/vendor/rails/activerecord/test/connections/native_sqlite/connection.rb deleted file mode 100644 index fea985d..0000000 --- a/vendor/rails/activerecord/test/connections/native_sqlite/connection.rb +++ /dev/null @@ -1,25 +0,0 @@ -print "Using native SQlite\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -class SqliteError < StandardError -end - -BASE_DIR = FIXTURES_ROOT -sqlite_test_db = "#{BASE_DIR}/fixture_database.sqlite" -sqlite_test_db2 = "#{BASE_DIR}/fixture_database_2.sqlite" - -def make_connection(clazz, db_file) - ActiveRecord::Base.configurations = { clazz.name => { :adapter => 'sqlite', :database => db_file } } - unless File.exist?(db_file) - puts "SQLite database not found at #{db_file}. Rebuilding it." - sqlite_command = %Q{sqlite "#{db_file}" "create table a (a integer); drop table a;"} - puts "Executing '#{sqlite_command}'" - raise SqliteError.new("Seems that there is no sqlite executable available") unless system(sqlite_command) - end - clazz.establish_connection(clazz.name) -end - -make_connection(ActiveRecord::Base, sqlite_test_db) -make_connection(Course, sqlite_test_db2) diff --git a/vendor/rails/activerecord/test/connections/native_sqlite3/connection.rb b/vendor/rails/activerecord/test/connections/native_sqlite3/connection.rb deleted file mode 100644 index c517c23..0000000 --- a/vendor/rails/activerecord/test/connections/native_sqlite3/connection.rb +++ /dev/null @@ -1,25 +0,0 @@ -print "Using native SQLite3\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -class SqliteError < StandardError -end - -BASE_DIR = FIXTURES_ROOT -sqlite_test_db = "#{BASE_DIR}/fixture_database.sqlite3" -sqlite_test_db2 = "#{BASE_DIR}/fixture_database_2.sqlite3" - -def make_connection(clazz, db_file) - ActiveRecord::Base.configurations = { clazz.name => { :adapter => 'sqlite3', :database => db_file, :timeout => 5000 } } - unless File.exist?(db_file) - puts "SQLite3 database not found at #{db_file}. Rebuilding it." - sqlite_command = %Q{sqlite3 "#{db_file}" "create table a (a integer); drop table a;"} - puts "Executing '#{sqlite_command}'" - raise SqliteError.new("Seems that there is no sqlite3 executable available") unless system(sqlite_command) - end - clazz.establish_connection(clazz.name) -end - -make_connection(ActiveRecord::Base, sqlite_test_db) -make_connection(Course, sqlite_test_db2) diff --git a/vendor/rails/activerecord/test/connections/native_sqlite3/in_memory_connection.rb b/vendor/rails/activerecord/test/connections/native_sqlite3/in_memory_connection.rb deleted file mode 100644 index 6aba971..0000000 --- a/vendor/rails/activerecord/test/connections/native_sqlite3/in_memory_connection.rb +++ /dev/null @@ -1,18 +0,0 @@ -print "Using native SQLite3\n" -require_dependency 'models/course' -require 'logger' -ActiveRecord::Base.logger = Logger.new("debug.log") - -class SqliteError < StandardError -end - -def make_connection(clazz, db_definitions_file) - clazz.establish_connection(:adapter => 'sqlite3', :database => ':memory:') - File.read(SCHEMA_ROOT + "/#{db_definitions_file}").split(';').each do |command| - clazz.connection.execute(command) unless command.strip.empty? - end -end - -make_connection(ActiveRecord::Base, 'sqlite.sql') -make_connection(Course, 'sqlite2.sql') -load(SCHEMA_ROOT + "/schema.rb") diff --git a/vendor/rails/activerecord/test/connections/native_sybase/connection.rb b/vendor/rails/activerecord/test/connections/native_sybase/connection.rb deleted file mode 100644 index 3282d26..0000000 --- a/vendor/rails/activerecord/test/connections/native_sybase/connection.rb +++ /dev/null @@ -1,23 +0,0 @@ -print "Using native Sybase Open Client\n" -require_dependency 'models/course' -require 'logger' - -ActiveRecord::Base.logger = Logger.new("debug.log") - -ActiveRecord::Base.configurations = { - 'arunit' => { - :adapter => 'sybase', - :host => 'database_ASE', - :username => 'sa', - :database => 'activerecord_unittest' - }, - 'arunit2' => { - :adapter => 'sybase', - :host => 'database_ASE', - :username => 'sa', - :database => 'activerecord_unittest2' - } -} - -ActiveRecord::Base.establish_connection 'arunit' -Course.establish_connection 'arunit2' diff --git a/vendor/rails/activerecord/test/fixtures/accounts.yml b/vendor/rails/activerecord/test/fixtures/accounts.yml deleted file mode 100644 index b2d0191..0000000 --- a/vendor/rails/activerecord/test/fixtures/accounts.yml +++ /dev/null @@ -1,28 +0,0 @@ -signals37: - id: 1 - firm_id: 1 - credit_limit: 50 - -unknown: - id: 2 - credit_limit: 50 - -rails_core_account: - id: 3 - firm_id: 6 - credit_limit: 50 - -last_account: - id: 4 - firm_id: 2 - credit_limit: 60 - -rails_core_account_2: - id: 5 - firm_id: 6 - credit_limit: 55 - -odegy_account: - id: 6 - firm_id: 9 - credit_limit: 53 diff --git a/vendor/rails/activerecord/test/fixtures/all/developers.yml b/vendor/rails/activerecord/test/fixtures/all/developers.yml deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/rails/activerecord/test/fixtures/all/people.csv b/vendor/rails/activerecord/test/fixtures/all/people.csv deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/rails/activerecord/test/fixtures/all/tasks.yml b/vendor/rails/activerecord/test/fixtures/all/tasks.yml deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/rails/activerecord/test/fixtures/author_addresses.yml b/vendor/rails/activerecord/test/fixtures/author_addresses.yml deleted file mode 100644 index 7b90572..0000000 --- a/vendor/rails/activerecord/test/fixtures/author_addresses.yml +++ /dev/null @@ -1,5 +0,0 @@ -david_address: - id: 1 - -david_address_extra: - id: 2 diff --git a/vendor/rails/activerecord/test/fixtures/author_favorites.yml b/vendor/rails/activerecord/test/fixtures/author_favorites.yml deleted file mode 100644 index e81fdac..0000000 --- a/vendor/rails/activerecord/test/fixtures/author_favorites.yml +++ /dev/null @@ -1,4 +0,0 @@ -david_mary: - id: 1 - author_id: 1 - favorite_author_id: 2 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/authors.yml b/vendor/rails/activerecord/test/fixtures/authors.yml deleted file mode 100644 index de2ec7d..0000000 --- a/vendor/rails/activerecord/test/fixtures/authors.yml +++ /dev/null @@ -1,9 +0,0 @@ -david: - id: 1 - name: David - author_address_id: 1 - author_address_extra_id: 2 - -mary: - id: 2 - name: Mary diff --git a/vendor/rails/activerecord/test/fixtures/binaries.yml b/vendor/rails/activerecord/test/fixtures/binaries.yml deleted file mode 100644 index d150c57..0000000 --- a/vendor/rails/activerecord/test/fixtures/binaries.yml +++ /dev/null @@ -1,132 +0,0 @@ -flowers: - id: 1 - data: !binary | /9j/4AAQSkZJRgABAQEASABIAAD/2wBDAA0JCQoKCg4LCw4UDQsNFBcRDg4R - FxsVFRUVFRsbFRcXFxcVGxoeICEgHhonJyoqJyc1NTU1NTY2NjY2NjY2Njb/ - 2wBDAQ4NDRERERcRERcXExQTFx0ZGhoZHSYdHR4dHSYsJCAgICAkLCgrJiYm - KygvLywsLy82NjY2NjY2NjY2NjY2Njb/wAARCACvAIMDAREAAhEBAxEB/8QA - GwAAAgMBAQEAAAAAAAAAAAAABAUAAwYCAQf/xABAEAACAQMCBAMFBwMBBQkA - AAABAgMABBESIQUTMUEiUWEUMnGBkQYjQlKxwdEzYqGSFSRD4fAlNUVyc4Ki - svH/xAAZAQADAQEBAAAAAAAAAAAAAAAAAQIDBAX/xAAqEQACAgEEAQQCAgID - AAAAAAAAAQIRAxIhMUFRBBMiYTJxgaFCUpGxwf/aAAwDAQACEQMRAD8A+nUA - SgCUASgDxmCjJ2A6k0ADe3QumqFhID7rA+E/OgBNLecbWcCVoRA2f6Wcj/Vv - USvyNHDtI5y7s3zqCgWR2S7gjiy0koZQM4Axg5+NC+hkHFr8WcjpIYriL3kf - xAMp8S+KnbQqHEHGXG06Z/uT+KpT8icRnBcwzjMTBvMdx8RVkltAEoAlAEoA - lAEoAlAEoArmmSBNbnb9aAEtxdG7bTKP927x9Q3ofOp1DoTwCSy4okMAK2TB - pY4z2/Og+ZyKm9yqD2bVO594NupO2M/h+VJgjmWPmIVyyZ7r1pDJw9Iku44V - Yu8Ebl+Zu+XK75/xVRJZXxzh8WmS7ErRM2kMgAIdiQo+dOaHB7nMCFECMzNj - 8T7k/SoGEBuURIjaXXcMD+tCYmh7bXetE52EkbHwJ8hWpAVTAlAEoAlAEoAl - AFc0ywxl26D/ADQAjurlpW5khwOw8hWTZSQMLiAn3x/18aQwTi03s8UV0oyI - ZAzEdkPhfb4GgaDgV2ZTqB3B86BFVwCQGV9Dr7rfh+DVEl/DAGt7qJLiKULm - 5cOknpnBwfhp2pwyL+Q8l97O72+ZUEpR1ZFG2fEBg7+tW3YkW/HY0iiMB086 - SAsYM7623Pb0+FVZI2sL3mfdSf1B0P5v+dXGVioOqhEoAlAEoA8JxuelAGNu - ftDeX1/7Na2x5eWEJfbVp6t8+1RzwVQXDwtrkcziO7fhgU4VfiV61SQr8Hb8 - E4eR4UMZ7FHYH9TRSCxfDYXEuoQzAJpAZJBqDasg7j+KiKstsEtzfWlxdZjV - wjBCAdtlDArnsQaTQfYf7RxEdbGT5Ff5o0sNvIvEgF8sxhdZnDKsW27dBsPS - s6qV9gXXd5ccnBtpIiWXS5G2QwP12q2OIQvEZ239jm33zpPf5U6Yie2Xsp0w - 2uG6EOQCMeeaVAR4+KgBpGjjUnBAOo/oP1p6aJs7g4bNIqzG8kVveXQo28uu - acY9hfRqbSbmxDJy42f4+fzrQkvoAlAEoAV8cuWjhECdZfeOcYUdd/Wom9hx - EFhHjiMTYO2r8QONjUwLlwP61Mzk0AAWGxYeg/eoh2VLoC4iUteIrPM3+7Xa - cps7BZI/d+qk0pFR4/QzkuFiVGOcMQNgT1rTolLkSSpJJc61KIBLpjYn3ve2 - +O/asq1PYsae1WsdseYA7QeNde+SncD0rSqKhjbkl5Flp9qPapFXkMZG1agp - 8K4G2TjvSTO+fpNHYfDe25lRWOJZAdJII6dck4p/Zz5fTtptdFl2fCo9c/QU - pnEi2DaJB6CnHoT5CbaflSBvwnZvhTAcUASgCUAZ/i6e0SK222eozttUTKiL - 7WEJexMWX3vygHofKpiUx3Wpmck0AL7Q4kb/AMv71EOypcIB+0EkLRpE5wUc - SasZC4OdwO2KT8eCsf0WT36sXXK+AqkZ8R+9xq+80dh5VZajQseaWVI5IHCR - MwZkIHhckAOPyrkdKlPnoNqdLdkml9mI0za0VtAjCr/VOWLMRjrTGpNU2BSH - lxy3HD5dAClZYG6nR4QQcYI3+NJb7o9DDnWaPyj8r5DC9w0cVsYyyrCGUrjU - 8vhJ0b48PlT+hKUVJ773/Q4kLmGMPq5nLOvVjVnGN9O1KfR52SnOTXAWmyge - lX0YnuaAGfCrkzwMGxqiYrt+X8JpAHUwKrltMZ8ztQAg4mhJXwlgwK4H1qJF - RFqQyNd240MMON8Y6bmpiyn2aA1qZlRkUSCPPjIyB6ClfQAMBxK3wP61OPk1 - q6Qn4pJcyXeI49UUiaZCPy1r7bt/cTphh0WvKPeCS+02oZtTSkYYquBkbAlt - qK+KtkyT0pbJFV/dSxW8kZBLNEq83w6HcnG4x1rOXZnJbbeQO9RrSKKMnW6t - 45Nj4hjYbZ6GufMpbU+DBthXBrG61ZeZo4bZtXs4B0bjOGzse1XhHGTXAebZ - b/dzh4yrow/Cd+nyq49minpYXMfHj+0D6miXKIXYXWhBKAOOBTSxXZidTpbK - E42yNxWa5KfBpa0JBLxt1X50AKOKe5Gdup66vL+2omVHkVxY9rg2QeMdpM1E - eS3wNrq/htQzSnSFGf8A8rY0xencv5FnD76PiN61xETohBU5HXsNPp5+tZ6L - nqsnNg9trfkF4rfrbRvp8cm66B6nbP8AFbQhTbuzpw4qpsVT3XD3n5d1cttE - MFchAxzkeHoR5GtHOG5eTPDeIJFx8w2/Kt5Gj8eU22GWydq5jgk+PsvueJST - BeeBIi7YAwSD3x50tW+5pKq2e5JZ2uFS3c/dBmKsBuc+dZzfSMn8ugi3llsp - fBI0nNULIr+bdCPlWduMkl2QuRvDOLTVzPTVjfSPXFdscdJts6vYcld0WwTx - XcjGM5Axg/ChQU02gWH4Nh5IAyeg6mkcp6hJAJGn41NgBWsgSUuCMq+fecdD - UdmlbGuVtQBHQ7itTMAuDmVvTagBfxCUxquBnrUTKiK2upDLEFAXUwGc+tRH - ktAvFkubZpI5NUyTKyjIz4z00/Stj1MUoNKtmgHhd+bSRrd9UK8soW/EvcN8 - DWCk1N2rPOnqlle1/IW8QnnwfEdW5yPI9cfKqlq1N3syvUxyY5PfkVQ8oSa5 - TshB0fm9KaOWP2X35iuZOZbJ4QMyaBgAeZA6U0VL8VRdaSxkYmy6Lkjpnby1 - VlKO4vDHFhcw+EIcsQS6YBchd8IfM5p49q8mi/tlF8US45aKwyOcS/hZQ2+N - O9LJ8XZD5aBH4s7HlP8A0s+IrsxX1qpSlJVexXvSez4HlrcQq5e3O0gAx0C4 - 863nmhFLQehKcdCSDBfXEsZCqAc+HUwHw8Jx0/WuaTnJPT/ZwSxveQRBE4TU - +qSRRnfGB323OanHjfMm2zI8trqXHbT8d60NDT8Pn5tnE7bMRv8ALatUzMGk - OXY+ppgA8UH+7Z6EHYk4/WoycDRnVvUjViyDndE1HYefn9a5sOR63GS/Rv6f - 8qmWcFuGmnHtPVieSzncjyz3O1dn7Ov1cYxinF7+DvjEltcXSK7qlvb+BmA8 - z4lb08qIuLel8h6OaipLnI/J3NwuEqDbeDBXWPe1Rjqu/wCYV0PGmazcskdL - Kr37OcOuHWSNeTkqSE93HcaexIp+xBmD9NB/TOG+zdnCJmtQUeVWRIycp4hp - 3zk+tKWBdCl6ZU62A2+y0VtbLqLTyKCZCh07/wBoINYyxUYS9PVFdnAIIo8R - bFG9paUeMdT91q2Bx9ajSTpSsFDR3Gow6pvDp5jDEjd/EMnp0rly25KkZP5P - gEdIYyBpyw643GfM57071JdCrpIbcrRJaCI632MrdUC+WO9dkcKSS/5PRji2 - j/Y2iWGS4eGNkDLh1wPCenu5zWkMSi3XBosaiuORlDcxgmJ2CuOgI05/mpyQ - o5M2Ct0B2yQ6D4Vzuerj9q5aMR9w9glpGoG2P39atGbPasQNf7wYzjJ8gf1q - ZcDjyZjjNr9ykyyeOLvjr8umP1qFR2YpxpxmrAU4YdpGkC3Kf6D5fCn7eqPN - DXptcdeoJ4ct887TcyCNR4csQdQ7rpP61p6aNdhg7Td/9jb2hh+TI2+7YEf6 - etdp2RRwbiViREpbT72O1cmT1Si6FKUV3R6t+Op2PTftW+PIpqy1G9wKbjCS - utvCGdnb7x12wnfSehNKcujmyvpFL3DBy64a3CFnGC+wbJKE/pWL5OeSr9Ir - jis7hG9mHLlc6o2IwXGdye/eolBTT68EabVoL4TwlJpi08XQEddjj8461msT - tXVIUYb2MWtYLxHMOiO4hfSM+4WXorY3x8K3U6Ov5w47QktmntzpuAIry2zE - yY2zksuCeqsp6+Vaavjd7hHNcN+UH3V3rg1toFzEA2gHOdW3gz19Ky9x72Rj - z03e6KeHz3CSK12GUxnVGrZJPVTo8t6y35ZjPz5NDbXDNCpVCR500c4bViBe - IIWtyR1Xfy9KiXA0Zu+R1hbEYJ8iwz8t6xst/QFPy2iRYoWhf/ian15P6CsM - mR1pWyRPuyrTewTwuZVK2zJHpc+++c+gFb+jzfJQdb/5dm3pslOhoPYJWZYQ - khT3yuCF+JG1esqZ6MZ32VgTQKTHjSxzgiuXJ6GMnY5YoyOBaId5xqDdc9M+ - tb48KxqiuFR5d20FtDI+eTgasjAJ076ct50pr7OfL58Gdu5IeIrG0UmZzsFi - BAC4911Pr5Vzs43Ut+w7hHtNvbkOhTUwKnGl8HqwDb9qUXzsPEjQcLmymVyx - zplkI0sxHmKLNdKdlHE/ub1buFFMGwkRAch+xYLQaY8lQcH+XkRcavFuLyK6 - 3PKTl4PQjuNt+hxuaiUjz55PlsW8znWjzxwgLFiMBcHAG++odKV2my7uOoL4 - bMjW2F0q+nGnfVqPUnPb0HrQpXF+Rt6kWiK7xtJPj00gfLBqorYnY1FwwiLk - gkKeijJ+gpvbczEfFOLAjkhBo/FzMgj4qP3rly5b2/8ABGflu87xx/dxnOvG - AfXVuTUJP9DPfazO5d/eY5b4msZ3bsRxc40nPQg/pRDlMa2GHCOI8Lg4ZDFH - IMJpWRejyTP1AXvv3r24TVI78WSOlbjXUs4wv9IEgsdskdhmtdR0KQDHfxQX - Pss7aucmuINtqUErpGe9S59ClkV1wxZxy/itrf2csJTINLQtvjyOe1ZzmjHP - ljTXkF4HPwzh8trcysA4fSTk5GrwuSOmBnY+VYnJcUl5Hl6sE105X75cAmWN - vmACDRaOiLDLS7UHMhA7KuQNvTOKRbXAp+0ExS5SSJuXzFOtVbr2ye24rnzN - pqjlzPfkzzylpWxvj/raj8kmznHfApFS1uhJup/4R6Nt3+taRquTbF+Dst4d - JHaJonZR+UqPwnz071OuK7FexsrBoZ7WOWLdG6eEjvitVJEF12CJWx33FUBk - +MWXFOYzuRNbA6gVwgGe5Xz9azd8ktMUuPDg4YfHIqHJeBaGTaVyxOmYBUEW - n38bD5j/ADUThrX2NffJzejl2zPICOX4WHffp1rmjF60ijOgCNo3R8nZsjqp - 8jnuPSvQuhJ1wHzz390BJLNoVGDKo93I74pvP/LNfdm+yrifEpL2USEjIAVf - T4UtTk7kRPI5MHt7d7iQIvXclv3p0wSbouktOSjcwb7fLPSs2pahSjRbacbn - srRrRUR0bOJCMMurr0OD6VoVGdD3iH2i4W9nCLLLXsWATIh93GD6Ghmksol5 - rSku8hLMe46fSuWTMXueezg+IOMkjbfejVs1RNfYdHbyhdTKQvn28utRpl/A - 1fAwtOGyP4mU47Yx9Sa0hj8l15PodlFybWGP8qAV1USU3y7q3ypgAXKh4XU9 - MGpl2Bl723iMMoCqpKnGFK+tYmj4YDaW91I0fO2B3EmMkY33P7mhJmSvkb3t - vBPaj7tvZiMs2Nyo6Y1uSd+m9VJdlGOveGCE5WTVEc6fCc/x/mlHI/8AUWkY - 8AurKAv7eNOpcQM4OnQOoHXeqpcmkWhdeexy3MrW33dv6/sKndGUudgeJnjc - GFipHQjbHwqtbBNnsvN0qskjOoJxk567nNGpvrcLb5OhbpJgINR2AGd/lUW1 - yBwLaXSZhGdKEAt8a05Q6DH+5VNSNkjbbqeprmS1N7gN+C21tcoJllTnr1jf - dRnoD339K2hjXkSGl/NKIbi2dTq0rJ5hl1AZDdznber+ike8OTmvFGFbxsB7 - n75qVyU+Dd4rYgquk1xHzG4+VACxsaTnpijoDN3kC8s+JjnqMmudmoQvD/b7 - O1YYVdAWXG2dOV7Vt0QnyNXijePlsoKYxj4dKdEmV43ZJaYDkurKTk7+n6Vn - LYtdiyLhVxeWYuWAECjRGPxNjPTemkSlqYm0EOQDgjbI6fKhiregm3tlOkyS - feO+APLHeplfXRMgmaCK5i0qzFwckbduuKmGz3Bc7hElhZ5ieNgjkZAyR7oD - Z7jI771tJKnwzZxj0VtfzItxa4xLlgrZ93OOnbfvU6tG3NE66tFllwDiE9rG - I7kLG+S8erKgfhbbz8utSop7rkzD7fgt3Zyq8kSXMfuycv39PoD+1Dj53Aa8 - RSKGxRYwQGdQNWScbtjxb9qp0o8FxGH2bi5s+v8ADCM/+47ClBFSNRWpBKAF - NzHy2dO2+PhR0Blblm5ZBbY1zmo24If+zYvTUP8A5GtlwjNhpqhCT7RQiSOI - noGIP6/tWeToqIN/4CiqMkb48vGaTfxFwzOPb4dv7jt/ArGMrlSJ7PBGyb9h - 512JFHrtoGfd9cUUn0Kgq0iadrf8hfUMjv2NTJdLgfRxdWfst1ytWuVgGd/N - m3OK5skWuyDVwW/IxygNJ6r0+JFbxjVFBQqwAuNDMEX/AKoP0BqZ8DjyaPgN - mbWxXUPvZfG/z6D6URWwMZVQiUADXsOtNQ95f070AYi5wMr+Un9aw7NehpwT - /u+P4v8A/Y1rHhGbDqoQs41g22M76gcd6znwVHkWx3kX+zfZ9LM+46bDxZ61 - Mn8K8g+RfPExboCcZz6+Qq4YUqFR5GpVgwzpO5U7q3xBrUVFrmX3kiAC9gMf - SqCjt2bSHxpc/wCKUr4oEcjl3d4zS+5lQfkB0rnmvluVWw9W5hHc1epE0WLc - w/mp6kFBENkvEpoRkGGF+ZL8gcL8zRyBpaYEoAlAEoAx/wBobBrWcyqMwTEk - H8rdSv8AFZTXZafQutOJSxwLBHhQhbfGTuSe9NS2Bota6lb3nJ+dTYUgaZiw - 60mMF3UEb77mhAeI+kjX3z8q3TAJiuo4gRpGr1rTUQ4lct5IeunHlijULSBc - ySRyMjbqDsR/NS5F0Fwx/XzrnfIwxM0AXRxSSuI0XLscAetArNhw2xWxtxEN - 3O8jebVqiAumBKAJQBKAKbm2iuoWhmGqNxgikBirngsvDZWV/HGxJjkx7w8j - 61k40aJlWnekByy0wB3U0ADTLgnoNXVjVxYFPNDjDdvP9iN6sD1iMfi2/vH7 - 0WBLePXINI2+v+TUyYDaOLA6VmIvSMswUdT7oHegDUcJ4WLRebLvcMP9I8hW - iRDGdUBKAJQBKAJQBKAK54IriMxyrqQ9qQGZ4jwaW1JeMGWDz7r8R+9Q4lJi - rH9tSM5ZCR0/xQBXLbcwYxin+gF83D7nV4Vz/dmrUh2epw+7OxGB6n/nRqDY - YW9qkA3bxd6ixB9rayXL6IFLHv5D4mnQjS8O4TFZ+NvHP+fy9Fq0ibGFMCUA - SgCUASgCUASgCUASgAC74PbXOTvE5/En7jpSoLE8/wBn7uPJjKyj46T9D/NT - pKsXyQzxNpdNP0/akB5484WkMKh4RfXG4UafNmH7b0UxWMrb7Nxg6rl9Z/Im - w+vWq0iscQwxQroiUIvkKsRZQBKAJQBKAJQB/9k= diff --git a/vendor/rails/activerecord/test/fixtures/books.yml b/vendor/rails/activerecord/test/fixtures/books.yml deleted file mode 100644 index 473663f..0000000 --- a/vendor/rails/activerecord/test/fixtures/books.yml +++ /dev/null @@ -1,7 +0,0 @@ -awdr: - id: 1 - name: "Agile Web Development with Rails" - -rfr: - id: 2 - name: "Ruby for Rails" diff --git a/vendor/rails/activerecord/test/fixtures/categories.yml b/vendor/rails/activerecord/test/fixtures/categories.yml deleted file mode 100644 index b0770a0..0000000 --- a/vendor/rails/activerecord/test/fixtures/categories.yml +++ /dev/null @@ -1,14 +0,0 @@ -general: - id: 1 - name: General - type: Category - -technology: - id: 2 - name: Technology - type: Category - -sti_test: - id: 3 - name: Special category - type: SpecialCategory diff --git a/vendor/rails/activerecord/test/fixtures/categories/special_categories.yml b/vendor/rails/activerecord/test/fixtures/categories/special_categories.yml deleted file mode 100644 index 517fc8f..0000000 --- a/vendor/rails/activerecord/test/fixtures/categories/special_categories.yml +++ /dev/null @@ -1,9 +0,0 @@ -sub_special_1: - id: 100 - name: A special category in a subdir file - type: SpecialCategory - -sub_special_2: - id: 101 - name: Another special category - type: SpecialCategory diff --git a/vendor/rails/activerecord/test/fixtures/categories/subsubdir/arbitrary_filename.yml b/vendor/rails/activerecord/test/fixtures/categories/subsubdir/arbitrary_filename.yml deleted file mode 100644 index 389a04a..0000000 --- a/vendor/rails/activerecord/test/fixtures/categories/subsubdir/arbitrary_filename.yml +++ /dev/null @@ -1,4 +0,0 @@ -sub_special_3: - id: 102 - name: A special category in an arbitrarily named subsubdir file - type: SpecialCategory diff --git a/vendor/rails/activerecord/test/fixtures/categories_ordered.yml b/vendor/rails/activerecord/test/fixtures/categories_ordered.yml deleted file mode 100644 index 2afc6cb..0000000 --- a/vendor/rails/activerecord/test/fixtures/categories_ordered.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- !!omap -<% 100.times do |i| %> -- fixture_no_<%= i %>: - id: <%= i %> - name: <%= "Category #{i}" %> - type: Category -<% end %> diff --git a/vendor/rails/activerecord/test/fixtures/categories_posts.yml b/vendor/rails/activerecord/test/fixtures/categories_posts.yml deleted file mode 100644 index 9b67ab4..0000000 --- a/vendor/rails/activerecord/test/fixtures/categories_posts.yml +++ /dev/null @@ -1,23 +0,0 @@ -general_welcome: - category_id: 1 - post_id: 1 - -technology_welcome: - category_id: 2 - post_id: 1 - -general_thinking: - category_id: 1 - post_id: 2 - -general_sti_habtm: - category_id: 1 - post_id: 6 - -sti_test_sti_habtm: - category_id: 3 - post_id: 6 - -general_hello: - category_id: 1 - post_id: 4 diff --git a/vendor/rails/activerecord/test/fixtures/categorizations.yml b/vendor/rails/activerecord/test/fixtures/categorizations.yml deleted file mode 100644 index c5b6fc9..0000000 --- a/vendor/rails/activerecord/test/fixtures/categorizations.yml +++ /dev/null @@ -1,17 +0,0 @@ -david_welcome_general: - id: 1 - author_id: 1 - post_id: 1 - category_id: 1 - -mary_thinking_sti: - id: 2 - author_id: 2 - post_id: 2 - category_id: 3 - -mary_thinking_general: - id: 3 - author_id: 2 - post_id: 2 - category_id: 1 diff --git a/vendor/rails/activerecord/test/fixtures/clubs.yml b/vendor/rails/activerecord/test/fixtures/clubs.yml deleted file mode 100644 index 1986d28..0000000 --- a/vendor/rails/activerecord/test/fixtures/clubs.yml +++ /dev/null @@ -1,6 +0,0 @@ -boring_club: - name: Banana appreciation society -moustache_club: - name: Moustache and Eyebrow Fancier Club -crazy_club: - name: Skull and bones \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/comments.yml b/vendor/rails/activerecord/test/fixtures/comments.yml deleted file mode 100644 index 236bdb2..0000000 --- a/vendor/rails/activerecord/test/fixtures/comments.yml +++ /dev/null @@ -1,59 +0,0 @@ -greetings: - id: 1 - post_id: 1 - body: Thank you for the welcome - type: Comment - -more_greetings: - id: 2 - post_id: 1 - body: Thank you again for the welcome - type: Comment - -does_it_hurt: - id: 3 - post_id: 2 - body: Don't think too hard - type: SpecialComment - -eager_sti_on_associations_vs_comment: - id: 5 - post_id: 4 - body: Very Special type - type: VerySpecialComment - -eager_sti_on_associations_s_comment1: - id: 6 - post_id: 4 - body: Special type - type: SpecialComment - -eager_sti_on_associations_s_comment2: - id: 7 - post_id: 4 - body: Special type 2 - type: SpecialComment - -eager_sti_on_associations_comment: - id: 8 - post_id: 4 - body: Normal type - type: Comment - -check_eager_sti_on_associations: - id: 9 - post_id: 5 - body: Normal type - type: Comment - -check_eager_sti_on_associations2: - id: 10 - post_id: 5 - body: Special Type - type: SpecialComment - -eager_other_comment1: - id: 11 - post_id: 7 - body: go crazy - type: SpecialComment diff --git a/vendor/rails/activerecord/test/fixtures/companies.yml b/vendor/rails/activerecord/test/fixtures/companies.yml deleted file mode 100644 index e7691fd..0000000 --- a/vendor/rails/activerecord/test/fixtures/companies.yml +++ /dev/null @@ -1,56 +0,0 @@ -first_client: - id: 2 - type: Client - firm_id: 1 - client_of: 2 - name: Summit - ruby_type: Client - firm_name: 37signals - -first_firm: - id: 1 - type: Firm - name: 37signals - ruby_type: Firm - -second_client: - id: 3 - type: Client - firm_id: 1 - client_of: 1 - name: Microsoft - ruby_type: Client - -another_firm: - id: 4 - type: Firm - name: Flamboyant Software - ruby_type: Firm - -another_client: - id: 5 - type: Client - firm_id: 4 - client_of: 4 - name: Ex Nihilo - ruby_type: Client - -rails_core: - id: 6 - name: RailsCore - type: DependentFirm - -leetsoft: - id: 7 - name: Leetsoft - client_of: 6 - -jadedpixel: - id: 8 - name: Jadedpixel - client_of: 6 - -odegy: - id: 9 - name: Odegy - type: ExclusivelyDependentFirm diff --git a/vendor/rails/activerecord/test/fixtures/computers.yml b/vendor/rails/activerecord/test/fixtures/computers.yml deleted file mode 100644 index daf969d..0000000 --- a/vendor/rails/activerecord/test/fixtures/computers.yml +++ /dev/null @@ -1,4 +0,0 @@ -workstation: - id: 1 - developer: 1 - extendedWarranty: 1 diff --git a/vendor/rails/activerecord/test/fixtures/courses.yml b/vendor/rails/activerecord/test/fixtures/courses.yml deleted file mode 100644 index 5ee1916..0000000 --- a/vendor/rails/activerecord/test/fixtures/courses.yml +++ /dev/null @@ -1,7 +0,0 @@ -ruby: - id: 1 - name: Ruby Development - -java: - id: 2 - name: Java Development diff --git a/vendor/rails/activerecord/test/fixtures/customers.yml b/vendor/rails/activerecord/test/fixtures/customers.yml deleted file mode 100644 index 0399ff8..0000000 --- a/vendor/rails/activerecord/test/fixtures/customers.yml +++ /dev/null @@ -1,26 +0,0 @@ -david: - id: 1 - name: David - balance: 50 - address_street: Funny Street - address_city: Scary Town - address_country: Loony Land - gps_location: 35.544623640962634x-105.9309951055148 - -zaphod: - id: 2 - name: Zaphod - balance: 62 - address_street: Avenue Road - address_city: Hamlet Town - address_country: Nation Land - gps_location: NULL - -barney: - id: 3 - name: Barney Gumble - balance: 1 - address_street: Quiet Road - address_city: Peaceful Town - address_country: Tranquil Land - gps_location: NULL \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/developers.yml b/vendor/rails/activerecord/test/fixtures/developers.yml deleted file mode 100644 index 308bf75..0000000 --- a/vendor/rails/activerecord/test/fixtures/developers.yml +++ /dev/null @@ -1,21 +0,0 @@ -david: - id: 1 - name: David - salary: 80000 - -jamis: - id: 2 - name: Jamis - salary: 150000 - -<% for digit in 3..10 %> -dev_<%= digit %>: - id: <%= digit %> - name: fixture_<%= digit %> - salary: 100000 -<% end %> - -poor_jamis: - id: 11 - name: Jamis - salary: 9000 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/developers_projects.yml b/vendor/rails/activerecord/test/fixtures/developers_projects.yml deleted file mode 100644 index 5729587..0000000 --- a/vendor/rails/activerecord/test/fixtures/developers_projects.yml +++ /dev/null @@ -1,17 +0,0 @@ -david_action_controller: - developer_id: 1 - project_id: 2 - joined_on: 2004-10-10 - -david_active_record: - developer_id: 1 - project_id: 1 - joined_on: 2004-10-10 - -jamis_active_record: - developer_id: 2 - project_id: 1 - -poor_jamis_active_record: - developer_id: 11 - project_id: 1 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/edges.yml b/vendor/rails/activerecord/test/fixtures/edges.yml deleted file mode 100644 index c16c70d..0000000 --- a/vendor/rails/activerecord/test/fixtures/edges.yml +++ /dev/null @@ -1,6 +0,0 @@ -<% (1..4).each do |id| %> -edge_<%= id %>: - id: <%= id %> - source_id: <%= id %> - sink_id: <%= id + 1 %> -<% end %> \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/entrants.yml b/vendor/rails/activerecord/test/fixtures/entrants.yml deleted file mode 100644 index 86f0108..0000000 --- a/vendor/rails/activerecord/test/fixtures/entrants.yml +++ /dev/null @@ -1,14 +0,0 @@ -first: - id: 1 - course_id: 1 - name: Ruby Developer - -second: - id: 2 - course_id: 1 - name: Ruby Guru - -third: - id: 3 - course_id: 2 - name: Java Lover diff --git a/vendor/rails/activerecord/test/fixtures/fixture_database.sqlite3 b/vendor/rails/activerecord/test/fixtures/fixture_database.sqlite3 deleted file mode 100644 index 6b84459..0000000 Binary files a/vendor/rails/activerecord/test/fixtures/fixture_database.sqlite3 and /dev/null differ diff --git a/vendor/rails/activerecord/test/fixtures/fixture_database_2.sqlite3 b/vendor/rails/activerecord/test/fixtures/fixture_database_2.sqlite3 deleted file mode 100644 index 40955d2..0000000 Binary files a/vendor/rails/activerecord/test/fixtures/fixture_database_2.sqlite3 and /dev/null differ diff --git a/vendor/rails/activerecord/test/fixtures/fk_test_has_fk.yml b/vendor/rails/activerecord/test/fixtures/fk_test_has_fk.yml deleted file mode 100644 index 67d914e..0000000 --- a/vendor/rails/activerecord/test/fixtures/fk_test_has_fk.yml +++ /dev/null @@ -1,3 +0,0 @@ -first: - id: 1 - fk_id: 1 diff --git a/vendor/rails/activerecord/test/fixtures/fk_test_has_pk.yml b/vendor/rails/activerecord/test/fixtures/fk_test_has_pk.yml deleted file mode 100644 index c939521..0000000 --- a/vendor/rails/activerecord/test/fixtures/fk_test_has_pk.yml +++ /dev/null @@ -1,2 +0,0 @@ -first: - id: 1 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/funny_jokes.yml b/vendor/rails/activerecord/test/fixtures/funny_jokes.yml deleted file mode 100644 index d47c4a6..0000000 --- a/vendor/rails/activerecord/test/fixtures/funny_jokes.yml +++ /dev/null @@ -1,10 +0,0 @@ -a_joke: - id: 1 - name: Knock knock - -another_joke: - id: 2 - name: | - The \n Aristocrats - Ate the candy - diff --git a/vendor/rails/activerecord/test/fixtures/items.yml b/vendor/rails/activerecord/test/fixtures/items.yml deleted file mode 100644 index 31fd657..0000000 --- a/vendor/rails/activerecord/test/fixtures/items.yml +++ /dev/null @@ -1,4 +0,0 @@ -dvd: - id: 1 - name: Godfather - \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/jobs.yml b/vendor/rails/activerecord/test/fixtures/jobs.yml deleted file mode 100644 index f5775d2..0000000 --- a/vendor/rails/activerecord/test/fixtures/jobs.yml +++ /dev/null @@ -1,7 +0,0 @@ -unicyclist: - id: 1 - ideal_reference_id: 2 -clown: - id: 2 -magician: - id: 3 diff --git a/vendor/rails/activerecord/test/fixtures/legacy_things.yml b/vendor/rails/activerecord/test/fixtures/legacy_things.yml deleted file mode 100644 index a6d42aa..0000000 --- a/vendor/rails/activerecord/test/fixtures/legacy_things.yml +++ /dev/null @@ -1,3 +0,0 @@ -obtuse: - id: 1 - tps_report_number: 500 diff --git a/vendor/rails/activerecord/test/fixtures/mateys.yml b/vendor/rails/activerecord/test/fixtures/mateys.yml deleted file mode 100644 index 9ecdd4e..0000000 --- a/vendor/rails/activerecord/test/fixtures/mateys.yml +++ /dev/null @@ -1,4 +0,0 @@ -blackbeard_to_redbeard: - pirate_id: <%= Fixtures.identify(:blackbeard) %> - target_id: <%= Fixtures.identify(:redbeard) %> - weight: 10 diff --git a/vendor/rails/activerecord/test/fixtures/member_types.yml b/vendor/rails/activerecord/test/fixtures/member_types.yml deleted file mode 100644 index 797a574..0000000 --- a/vendor/rails/activerecord/test/fixtures/member_types.yml +++ /dev/null @@ -1,6 +0,0 @@ -founding: - id: 1 - name: Founding -provisional: - id: 2 - name: Provisional diff --git a/vendor/rails/activerecord/test/fixtures/members.yml b/vendor/rails/activerecord/test/fixtures/members.yml deleted file mode 100644 index 6db945e..0000000 --- a/vendor/rails/activerecord/test/fixtures/members.yml +++ /dev/null @@ -1,6 +0,0 @@ -groucho: - name: Groucho Marx - member_type_id: 1 -some_other_guy: - name: Englebert Humperdink - member_type_id: 2 diff --git a/vendor/rails/activerecord/test/fixtures/memberships.yml b/vendor/rails/activerecord/test/fixtures/memberships.yml deleted file mode 100644 index 99fbe46..0000000 --- a/vendor/rails/activerecord/test/fixtures/memberships.yml +++ /dev/null @@ -1,20 +0,0 @@ -membership_of_boring_club: - joined_on: <%= 3.weeks.ago.to_s(:db) %> - club: boring_club - member: groucho - favourite: false - type: CurrentMembership - -membership_of_favourite_club: - joined_on: <%= 3.weeks.ago.to_s(:db) %> - club: moustache_club - member: groucho - favourite: true - type: Membership - -other_guys_membership: - joined_on: <%= 4.weeks.ago.to_s(:db) %> - club: boring_club - member: some_other_guy - favourite: false - type: CurrentMembership diff --git a/vendor/rails/activerecord/test/fixtures/minimalistics.yml b/vendor/rails/activerecord/test/fixtures/minimalistics.yml deleted file mode 100644 index c3ec546..0000000 --- a/vendor/rails/activerecord/test/fixtures/minimalistics.yml +++ /dev/null @@ -1,2 +0,0 @@ -first: - id: 1 diff --git a/vendor/rails/activerecord/test/fixtures/mixed_case_monkeys.yml b/vendor/rails/activerecord/test/fixtures/mixed_case_monkeys.yml deleted file mode 100644 index eecd448..0000000 --- a/vendor/rails/activerecord/test/fixtures/mixed_case_monkeys.yml +++ /dev/null @@ -1,6 +0,0 @@ -first: - monkeyID: 1 - fleaCount: 42 -second: - monkeyID: 2 - fleaCount: 43 diff --git a/vendor/rails/activerecord/test/fixtures/mixins.yml b/vendor/rails/activerecord/test/fixtures/mixins.yml deleted file mode 100644 index 0f60e92..0000000 --- a/vendor/rails/activerecord/test/fixtures/mixins.yml +++ /dev/null @@ -1,29 +0,0 @@ -# Nested set mixins - -<% (1..10).each do |counter| %> -set_<%= counter %>: - id: <%= counter+3000 %> -<% end %> - -# Big old set -<% -[[4001, 0, 1, 20], - [4002, 4001, 2, 7], - [4003, 4002, 3, 4], - [4004, 4002, 5, 6], - [4005, 4001, 14, 13], - [4006, 4005, 9, 10], - [4007, 4005, 11, 12], - [4008, 4001, 8, 19], - [4009, 4008, 15, 16], - [4010, 4008, 17, 18]].each do |set| %> -tree_<%= set[0] %>: - id: <%= set[0]%> - parent_id: <%= set[1]%> - type: NestedSetWithStringScope - lft: <%= set[2]%> - rgt: <%= set[3]%> - root_id: 42 - -<% end %> - diff --git a/vendor/rails/activerecord/test/fixtures/movies.yml b/vendor/rails/activerecord/test/fixtures/movies.yml deleted file mode 100644 index 2e9154f..0000000 --- a/vendor/rails/activerecord/test/fixtures/movies.yml +++ /dev/null @@ -1,7 +0,0 @@ -first: - movieid: 1 - name: Terminator - -second: - movieid: 2 - name: Gladiator diff --git a/vendor/rails/activerecord/test/fixtures/naked/csv/accounts.csv b/vendor/rails/activerecord/test/fixtures/naked/csv/accounts.csv deleted file mode 100644 index 8b13789..0000000 --- a/vendor/rails/activerecord/test/fixtures/naked/csv/accounts.csv +++ /dev/null @@ -1 +0,0 @@ - diff --git a/vendor/rails/activerecord/test/fixtures/naked/yml/accounts.yml b/vendor/rails/activerecord/test/fixtures/naked/yml/accounts.yml deleted file mode 100644 index 8b13789..0000000 --- a/vendor/rails/activerecord/test/fixtures/naked/yml/accounts.yml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/vendor/rails/activerecord/test/fixtures/naked/yml/companies.yml b/vendor/rails/activerecord/test/fixtures/naked/yml/companies.yml deleted file mode 100644 index 2c151c2..0000000 --- a/vendor/rails/activerecord/test/fixtures/naked/yml/companies.yml +++ /dev/null @@ -1 +0,0 @@ -# i wonder what will happen here diff --git a/vendor/rails/activerecord/test/fixtures/naked/yml/courses.yml b/vendor/rails/activerecord/test/fixtures/naked/yml/courses.yml deleted file mode 100644 index 19f0805..0000000 --- a/vendor/rails/activerecord/test/fixtures/naked/yml/courses.yml +++ /dev/null @@ -1 +0,0 @@ -qwerty diff --git a/vendor/rails/activerecord/test/fixtures/organizations.yml b/vendor/rails/activerecord/test/fixtures/organizations.yml deleted file mode 100644 index 25295bf..0000000 --- a/vendor/rails/activerecord/test/fixtures/organizations.yml +++ /dev/null @@ -1,5 +0,0 @@ -nsa: - name: No Such Agency -discordians: - name: Discordians - diff --git a/vendor/rails/activerecord/test/fixtures/owners.yml b/vendor/rails/activerecord/test/fixtures/owners.yml deleted file mode 100644 index d5493a8..0000000 --- a/vendor/rails/activerecord/test/fixtures/owners.yml +++ /dev/null @@ -1,7 +0,0 @@ -blackbeard: - owner_id: 1 - name: blackbeard - -ashley: - owner_id: 2 - name: ashley diff --git a/vendor/rails/activerecord/test/fixtures/parrots.yml b/vendor/rails/activerecord/test/fixtures/parrots.yml deleted file mode 100644 index 8b73b8c..0000000 --- a/vendor/rails/activerecord/test/fixtures/parrots.yml +++ /dev/null @@ -1,27 +0,0 @@ -george: - name: "Curious George" - treasures: diamond, sapphire - parrot_sti_class: LiveParrot - -louis: - name: "King Louis" - treasures: [diamond, sapphire] - parrot_sti_class: LiveParrot - -frederick: - name: $LABEL - parrot_sti_class: LiveParrot - -polly: - id: 4 - name: $LABEL - killer: blackbeard - treasures: sapphire, ruby - parrot_sti_class: DeadParrot - -DEFAULTS: &DEFAULTS - treasures: sapphire, ruby - parrot_sti_class: LiveParrot - -davey: - <<: *DEFAULTS diff --git a/vendor/rails/activerecord/test/fixtures/parrots_pirates.yml b/vendor/rails/activerecord/test/fixtures/parrots_pirates.yml deleted file mode 100644 index 6b17a37..0000000 --- a/vendor/rails/activerecord/test/fixtures/parrots_pirates.yml +++ /dev/null @@ -1,7 +0,0 @@ -george_blackbeard: - parrot_id: <%= Fixtures.identify(:george) %> - pirate_id: <%= Fixtures.identify(:blackbeard) %> - -louis_blackbeard: - parrot_id: <%= Fixtures.identify(:louis) %> - pirate_id: <%= Fixtures.identify(:blackbeard) %> diff --git a/vendor/rails/activerecord/test/fixtures/people.yml b/vendor/rails/activerecord/test/fixtures/people.yml deleted file mode 100644 index 3babb1f..0000000 --- a/vendor/rails/activerecord/test/fixtures/people.yml +++ /dev/null @@ -1,15 +0,0 @@ -michael: - id: 1 - first_name: Michael - primary_contact_id: 2 - gender: M -david: - id: 2 - first_name: David - primary_contact_id: 3 - gender: M -susan: - id: 3 - first_name: Susan - primary_contact_id: 2 - gender: F \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/pets.yml b/vendor/rails/activerecord/test/fixtures/pets.yml deleted file mode 100644 index a1601a5..0000000 --- a/vendor/rails/activerecord/test/fixtures/pets.yml +++ /dev/null @@ -1,14 +0,0 @@ -parrot: - pet_id: 1 - name: parrot - owner_id: 1 - -chew: - pet_id: 2 - name: chew - owner_id: 2 - -mochi: - pet_id: 3 - name: mochi - owner_id: 2 diff --git a/vendor/rails/activerecord/test/fixtures/pirates.yml b/vendor/rails/activerecord/test/fixtures/pirates.yml deleted file mode 100644 index abb9110..0000000 --- a/vendor/rails/activerecord/test/fixtures/pirates.yml +++ /dev/null @@ -1,9 +0,0 @@ -blackbeard: - catchphrase: "Yar." - parrot: george - -redbeard: - catchphrase: "Avast!" - parrot: louis - created_on: <%= 2.weeks.ago.to_s(:db) %> - updated_on: <%= 2.weeks.ago.to_s(:db) %> diff --git a/vendor/rails/activerecord/test/fixtures/posts.yml b/vendor/rails/activerecord/test/fixtures/posts.yml deleted file mode 100644 index 92e5d19..0000000 --- a/vendor/rails/activerecord/test/fixtures/posts.yml +++ /dev/null @@ -1,49 +0,0 @@ -welcome: - id: 1 - author_id: 1 - title: Welcome to the weblog - body: Such a lovely day - comments_count: 2 - type: Post - -thinking: - id: 2 - author_id: 1 - title: So I was thinking - body: Like I hopefully always am - type: SpecialPost - -authorless: - id: 3 - author_id: 0 - title: I don't have any comments - body: I just don't want to - type: Post - -sti_comments: - id: 4 - author_id: 1 - title: sti comments - body: hello - type: Post - -sti_post_and_comments: - id: 5 - author_id: 1 - title: sti me - body: hello - type: StiPost - -sti_habtm: - id: 6 - author_id: 1 - title: habtm sti test - body: hello - type: Post - -eager_other: - id: 7 - author_id: 2 - title: eager loading with OR'd conditions - body: hello - type: Post diff --git a/vendor/rails/activerecord/test/fixtures/price_estimates.yml b/vendor/rails/activerecord/test/fixtures/price_estimates.yml deleted file mode 100644 index 1149ab1..0000000 --- a/vendor/rails/activerecord/test/fixtures/price_estimates.yml +++ /dev/null @@ -1,7 +0,0 @@ -saphire_1: - price: 10 - estimate_of: sapphire (Treasure) - -sapphire_2: - price: 20 - estimate_of: sapphire (Treasure) diff --git a/vendor/rails/activerecord/test/fixtures/projects.yml b/vendor/rails/activerecord/test/fixtures/projects.yml deleted file mode 100644 index 02800c7..0000000 --- a/vendor/rails/activerecord/test/fixtures/projects.yml +++ /dev/null @@ -1,7 +0,0 @@ -action_controller: - id: 2 - name: Active Controller - -active_record: - id: 1 - name: Active Record diff --git a/vendor/rails/activerecord/test/fixtures/readers.yml b/vendor/rails/activerecord/test/fixtures/readers.yml deleted file mode 100644 index 8a60766..0000000 --- a/vendor/rails/activerecord/test/fixtures/readers.yml +++ /dev/null @@ -1,9 +0,0 @@ -michael_welcome: - id: 1 - post_id: 1 - person_id: 1 - -michael_authorless: - id: 2 - post_id: 3 - person_id: 1 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/references.yml b/vendor/rails/activerecord/test/fixtures/references.yml deleted file mode 100644 index 8e3953e..0000000 --- a/vendor/rails/activerecord/test/fixtures/references.yml +++ /dev/null @@ -1,17 +0,0 @@ -michael_magician: - id: 1 - person_id: 1 - job_id: 3 - favourite: false - -michael_unicyclist: - id: 2 - person_id: 1 - job_id: 1 - favourite: true - -david_unicyclist: - id: 3 - person_id: 2 - job_id: 1 - favourite: false diff --git a/vendor/rails/activerecord/test/fixtures/reserved_words/distinct.yml b/vendor/rails/activerecord/test/fixtures/reserved_words/distinct.yml deleted file mode 100644 index 0988f89..0000000 --- a/vendor/rails/activerecord/test/fixtures/reserved_words/distinct.yml +++ /dev/null @@ -1,5 +0,0 @@ -distinct1: - id: 1 - -distinct2: - id: 2 diff --git a/vendor/rails/activerecord/test/fixtures/reserved_words/distincts_selects.yml b/vendor/rails/activerecord/test/fixtures/reserved_words/distincts_selects.yml deleted file mode 100644 index 90e8c95..0000000 --- a/vendor/rails/activerecord/test/fixtures/reserved_words/distincts_selects.yml +++ /dev/null @@ -1,11 +0,0 @@ -distincts_selects1: - distinct_id: 1 - select_id: 1 - -distincts_selects2: - distinct_id: 1 - select_id: 2 - -distincts_selects3: - distinct_id: 2 - select_id: 3 diff --git a/vendor/rails/activerecord/test/fixtures/reserved_words/group.yml b/vendor/rails/activerecord/test/fixtures/reserved_words/group.yml deleted file mode 100644 index 39abea7..0000000 --- a/vendor/rails/activerecord/test/fixtures/reserved_words/group.yml +++ /dev/null @@ -1,14 +0,0 @@ -group1: - id: 1 - select_id: 1 - order: x - -group2: - id: 2 - select_id: 2 - order: y - -group3: - id: 3 - select_id: 2 - order: z diff --git a/vendor/rails/activerecord/test/fixtures/reserved_words/select.yml b/vendor/rails/activerecord/test/fixtures/reserved_words/select.yml deleted file mode 100644 index a4c35a2..0000000 --- a/vendor/rails/activerecord/test/fixtures/reserved_words/select.yml +++ /dev/null @@ -1,8 +0,0 @@ -select1: - id: 1 - -select2: - id: 2 - -select3: - id: 3 diff --git a/vendor/rails/activerecord/test/fixtures/reserved_words/values.yml b/vendor/rails/activerecord/test/fixtures/reserved_words/values.yml deleted file mode 100644 index 7d10960..0000000 --- a/vendor/rails/activerecord/test/fixtures/reserved_words/values.yml +++ /dev/null @@ -1,7 +0,0 @@ -values1: - id: 1 - group_id: 2 - -values2: - id: 2 - group_id: 1 diff --git a/vendor/rails/activerecord/test/fixtures/ships.yml b/vendor/rails/activerecord/test/fixtures/ships.yml deleted file mode 100644 index 137055a..0000000 --- a/vendor/rails/activerecord/test/fixtures/ships.yml +++ /dev/null @@ -1,5 +0,0 @@ -black_pearl: - name: "Black Pearl" -interceptor: - id: 2 - name: "Interceptor" diff --git a/vendor/rails/activerecord/test/fixtures/sponsors.yml b/vendor/rails/activerecord/test/fixtures/sponsors.yml deleted file mode 100644 index 42df895..0000000 --- a/vendor/rails/activerecord/test/fixtures/sponsors.yml +++ /dev/null @@ -1,9 +0,0 @@ -moustache_club_sponsor_for_groucho: - sponsor_club: moustache_club - sponsorable: groucho (Member) -boring_club_sponsor_for_groucho: - sponsor_club: boring_club - sponsorable: some_other_guy (Member) -crazy_club_sponsor_for_groucho: - sponsor_club: crazy_club - sponsorable: some_other_guy (Member) \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/subscribers.yml b/vendor/rails/activerecord/test/fixtures/subscribers.yml deleted file mode 100644 index 9ffb4a1..0000000 --- a/vendor/rails/activerecord/test/fixtures/subscribers.yml +++ /dev/null @@ -1,7 +0,0 @@ -first: - nick: alterself - name: Luke Holden - -second: - nick: webster132 - name: David Heinemeier Hansson diff --git a/vendor/rails/activerecord/test/fixtures/subscriptions.yml b/vendor/rails/activerecord/test/fixtures/subscriptions.yml deleted file mode 100644 index 371bfd3..0000000 --- a/vendor/rails/activerecord/test/fixtures/subscriptions.yml +++ /dev/null @@ -1,12 +0,0 @@ -webster_awdr: - id: 1 - subscriber_id: webster132 - book_id: 1 -webster_rfr: - id: 2 - subscriber_id: webster132 - book_id: 2 -alterself_awdr: - id: 3 - subscriber_id: alterself - book_id: 3 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/taggings.yml b/vendor/rails/activerecord/test/fixtures/taggings.yml deleted file mode 100644 index 1e3d596..0000000 --- a/vendor/rails/activerecord/test/fixtures/taggings.yml +++ /dev/null @@ -1,28 +0,0 @@ -welcome_general: - id: 1 - tag_id: 1 - super_tag_id: 2 - taggable_id: 1 - taggable_type: Post - -thinking_general: - id: 2 - tag_id: 1 - taggable_id: 2 - taggable_type: Post - -fake: - id: 3 - tag_id: 1 - taggable_id: 1 - taggable_type: FakeModel - -godfather: - id: 4 - tag_id: 1 - taggable_id: 1 - taggable_type: Item - -orphaned: - id: 5 - tag_id: 1 diff --git a/vendor/rails/activerecord/test/fixtures/tags.yml b/vendor/rails/activerecord/test/fixtures/tags.yml deleted file mode 100644 index 471b96f..0000000 --- a/vendor/rails/activerecord/test/fixtures/tags.yml +++ /dev/null @@ -1,7 +0,0 @@ -general: - id: 1 - name: General - -misc: - id: 2 - name: Misc \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/tasks.yml b/vendor/rails/activerecord/test/fixtures/tasks.yml deleted file mode 100644 index 1e6a061..0000000 --- a/vendor/rails/activerecord/test/fixtures/tasks.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html -first_task: - id: 1 - starting: 2005-03-30t06:30:00.00+01:00 - ending: 2005-03-30t08:30:00.00+01:00 -another_task: - id: 2 diff --git a/vendor/rails/activerecord/test/fixtures/topics.yml b/vendor/rails/activerecord/test/fixtures/topics.yml deleted file mode 100644 index 1769152..0000000 --- a/vendor/rails/activerecord/test/fixtures/topics.yml +++ /dev/null @@ -1,42 +0,0 @@ -first: - id: 1 - title: The First Topic - author_name: David - author_email_address: david@loudthinking.com - written_on: 2003-07-16t15:28:11.2233+01:00 - last_read: 2004-04-15 - bonus_time: 2005-01-30t15:28:00.00+01:00 - content: Have a nice day - approved: false - replies_count: 1 - -second: - id: 2 - title: The Second Topic of the day - author_name: Mary - written_on: 2004-07-15t15:28:00.0099+01:00 - content: Have a nice day - approved: true - replies_count: 0 - parent_id: 1 - type: Reply - -third: - id: 3 - title: The Third Topic of the day - author_name: Nick - written_on: 2005-07-15t15:28:00.0099+01:00 - content: I'm a troll - approved: true - replies_count: 1 - -fourth: - id: 4 - title: The Fourth Topic of the day - author_name: Carl - written_on: 2006-07-15t15:28:00.0099+01:00 - content: Why not? - approved: true - type: Reply - parent_id: 3 - diff --git a/vendor/rails/activerecord/test/fixtures/toys.yml b/vendor/rails/activerecord/test/fixtures/toys.yml deleted file mode 100644 index 037e335..0000000 --- a/vendor/rails/activerecord/test/fixtures/toys.yml +++ /dev/null @@ -1,4 +0,0 @@ -bone: - toy_id: 1 - name: Bone - pet_id: 1 diff --git a/vendor/rails/activerecord/test/fixtures/treasures.yml b/vendor/rails/activerecord/test/fixtures/treasures.yml deleted file mode 100644 index 9db1579..0000000 --- a/vendor/rails/activerecord/test/fixtures/treasures.yml +++ /dev/null @@ -1,10 +0,0 @@ -diamond: - name: $LABEL - -sapphire: - name: $LABEL - looter: redbeard (Pirate) - -ruby: - name: $LABEL - looter: louis (Parrot) diff --git a/vendor/rails/activerecord/test/fixtures/vertices.yml b/vendor/rails/activerecord/test/fixtures/vertices.yml deleted file mode 100644 index 8af0593..0000000 --- a/vendor/rails/activerecord/test/fixtures/vertices.yml +++ /dev/null @@ -1,4 +0,0 @@ -<% (1..5).each do |id| %> -vertex_<%= id %>: - id: <%= id %> -<% end %> \ No newline at end of file diff --git a/vendor/rails/activerecord/test/fixtures/warehouse-things.yml b/vendor/rails/activerecord/test/fixtures/warehouse-things.yml deleted file mode 100644 index 9e07ba7..0000000 --- a/vendor/rails/activerecord/test/fixtures/warehouse-things.yml +++ /dev/null @@ -1,3 +0,0 @@ -one: - id: 1 - value: 1000 \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/broken/100_migration_that_raises_exception.rb b/vendor/rails/activerecord/test/migrations/broken/100_migration_that_raises_exception.rb deleted file mode 100644 index ffb224d..0000000 --- a/vendor/rails/activerecord/test/migrations/broken/100_migration_that_raises_exception.rb +++ /dev/null @@ -1,10 +0,0 @@ -class MigrationThatRaisesException < ActiveRecord::Migration - def self.up - add_column "people", "last_name", :string - raise 'Something broke' - end - - def self.down - remove_column "people", "last_name" - end -end diff --git a/vendor/rails/activerecord/test/migrations/decimal/1_give_me_big_numbers.rb b/vendor/rails/activerecord/test/migrations/decimal/1_give_me_big_numbers.rb deleted file mode 100644 index 0aed7cb..0000000 --- a/vendor/rails/activerecord/test/migrations/decimal/1_give_me_big_numbers.rb +++ /dev/null @@ -1,15 +0,0 @@ -class GiveMeBigNumbers < ActiveRecord::Migration - def self.up - create_table :big_numbers do |table| - table.column :bank_balance, :decimal, :precision => 10, :scale => 2 - table.column :big_bank_balance, :decimal, :precision => 15, :scale => 2 - table.column :world_population, :decimal, :precision => 10 - table.column :my_house_population, :decimal, :precision => 2 - table.column :value_of_e, :decimal - end - end - - def self.down - drop_table :big_numbers - end -end diff --git a/vendor/rails/activerecord/test/migrations/duplicate/1_people_have_last_names.rb b/vendor/rails/activerecord/test/migrations/duplicate/1_people_have_last_names.rb deleted file mode 100644 index 81af5fe..0000000 --- a/vendor/rails/activerecord/test/migrations/duplicate/1_people_have_last_names.rb +++ /dev/null @@ -1,9 +0,0 @@ -class PeopleHaveLastNames < ActiveRecord::Migration - def self.up - add_column "people", "last_name", :string - end - - def self.down - remove_column "people", "last_name" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/duplicate/2_we_need_reminders.rb b/vendor/rails/activerecord/test/migrations/duplicate/2_we_need_reminders.rb deleted file mode 100644 index d5e71ce..0000000 --- a/vendor/rails/activerecord/test/migrations/duplicate/2_we_need_reminders.rb +++ /dev/null @@ -1,12 +0,0 @@ -class WeNeedReminders < ActiveRecord::Migration - def self.up - create_table("reminders") do |t| - t.column :content, :text - t.column :remind_at, :datetime - end - end - - def self.down - drop_table "reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/duplicate/3_foo.rb b/vendor/rails/activerecord/test/migrations/duplicate/3_foo.rb deleted file mode 100644 index 916fe58..0000000 --- a/vendor/rails/activerecord/test/migrations/duplicate/3_foo.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Foo < ActiveRecord::Migration - def self.up - end - - def self.down - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/duplicate/3_innocent_jointable.rb b/vendor/rails/activerecord/test/migrations/duplicate/3_innocent_jointable.rb deleted file mode 100644 index 21c9ca5..0000000 --- a/vendor/rails/activerecord/test/migrations/duplicate/3_innocent_jointable.rb +++ /dev/null @@ -1,12 +0,0 @@ -class InnocentJointable < ActiveRecord::Migration - def self.up - create_table("people_reminders", :id => false) do |t| - t.column :reminder_id, :integer - t.column :person_id, :integer - end - end - - def self.down - drop_table "people_reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/duplicate_names/20080507052938_chunky.rb b/vendor/rails/activerecord/test/migrations/duplicate_names/20080507052938_chunky.rb deleted file mode 100644 index 5fe5089..0000000 --- a/vendor/rails/activerecord/test/migrations/duplicate_names/20080507052938_chunky.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Chunky < ActiveRecord::Migration - def self.up - end - - def self.down - end -end diff --git a/vendor/rails/activerecord/test/migrations/duplicate_names/20080507053028_chunky.rb b/vendor/rails/activerecord/test/migrations/duplicate_names/20080507053028_chunky.rb deleted file mode 100644 index 5fe5089..0000000 --- a/vendor/rails/activerecord/test/migrations/duplicate_names/20080507053028_chunky.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Chunky < ActiveRecord::Migration - def self.up - end - - def self.down - end -end diff --git a/vendor/rails/activerecord/test/migrations/interleaved/pass_1/3_innocent_jointable.rb b/vendor/rails/activerecord/test/migrations/interleaved/pass_1/3_innocent_jointable.rb deleted file mode 100644 index 21c9ca5..0000000 --- a/vendor/rails/activerecord/test/migrations/interleaved/pass_1/3_innocent_jointable.rb +++ /dev/null @@ -1,12 +0,0 @@ -class InnocentJointable < ActiveRecord::Migration - def self.up - create_table("people_reminders", :id => false) do |t| - t.column :reminder_id, :integer - t.column :person_id, :integer - end - end - - def self.down - drop_table "people_reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/interleaved/pass_2/1_people_have_last_names.rb b/vendor/rails/activerecord/test/migrations/interleaved/pass_2/1_people_have_last_names.rb deleted file mode 100644 index 81af5fe..0000000 --- a/vendor/rails/activerecord/test/migrations/interleaved/pass_2/1_people_have_last_names.rb +++ /dev/null @@ -1,9 +0,0 @@ -class PeopleHaveLastNames < ActiveRecord::Migration - def self.up - add_column "people", "last_name", :string - end - - def self.down - remove_column "people", "last_name" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/interleaved/pass_2/3_innocent_jointable.rb b/vendor/rails/activerecord/test/migrations/interleaved/pass_2/3_innocent_jointable.rb deleted file mode 100644 index 21c9ca5..0000000 --- a/vendor/rails/activerecord/test/migrations/interleaved/pass_2/3_innocent_jointable.rb +++ /dev/null @@ -1,12 +0,0 @@ -class InnocentJointable < ActiveRecord::Migration - def self.up - create_table("people_reminders", :id => false) do |t| - t.column :reminder_id, :integer - t.column :person_id, :integer - end - end - - def self.down - drop_table "people_reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/interleaved/pass_3/1_people_have_last_names.rb b/vendor/rails/activerecord/test/migrations/interleaved/pass_3/1_people_have_last_names.rb deleted file mode 100644 index 81af5fe..0000000 --- a/vendor/rails/activerecord/test/migrations/interleaved/pass_3/1_people_have_last_names.rb +++ /dev/null @@ -1,9 +0,0 @@ -class PeopleHaveLastNames < ActiveRecord::Migration - def self.up - add_column "people", "last_name", :string - end - - def self.down - remove_column "people", "last_name" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/interleaved/pass_3/2_i_raise_on_down.rb b/vendor/rails/activerecord/test/migrations/interleaved/pass_3/2_i_raise_on_down.rb deleted file mode 100644 index 9b1ce9f..0000000 --- a/vendor/rails/activerecord/test/migrations/interleaved/pass_3/2_i_raise_on_down.rb +++ /dev/null @@ -1,8 +0,0 @@ -class IRaiseOnDown < ActiveRecord::Migration - def self.up - end - - def self.down - raise - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/interleaved/pass_3/3_innocent_jointable.rb b/vendor/rails/activerecord/test/migrations/interleaved/pass_3/3_innocent_jointable.rb deleted file mode 100644 index 21c9ca5..0000000 --- a/vendor/rails/activerecord/test/migrations/interleaved/pass_3/3_innocent_jointable.rb +++ /dev/null @@ -1,12 +0,0 @@ -class InnocentJointable < ActiveRecord::Migration - def self.up - create_table("people_reminders", :id => false) do |t| - t.column :reminder_id, :integer - t.column :person_id, :integer - end - end - - def self.down - drop_table "people_reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/missing/1000_people_have_middle_names.rb b/vendor/rails/activerecord/test/migrations/missing/1000_people_have_middle_names.rb deleted file mode 100644 index 9fd495b..0000000 --- a/vendor/rails/activerecord/test/migrations/missing/1000_people_have_middle_names.rb +++ /dev/null @@ -1,9 +0,0 @@ -class PeopleHaveMiddleNames < ActiveRecord::Migration - def self.up - add_column "people", "middle_name", :string - end - - def self.down - remove_column "people", "middle_name" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/missing/1_people_have_last_names.rb b/vendor/rails/activerecord/test/migrations/missing/1_people_have_last_names.rb deleted file mode 100644 index 81af5fe..0000000 --- a/vendor/rails/activerecord/test/migrations/missing/1_people_have_last_names.rb +++ /dev/null @@ -1,9 +0,0 @@ -class PeopleHaveLastNames < ActiveRecord::Migration - def self.up - add_column "people", "last_name", :string - end - - def self.down - remove_column "people", "last_name" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/missing/3_we_need_reminders.rb b/vendor/rails/activerecord/test/migrations/missing/3_we_need_reminders.rb deleted file mode 100644 index d5e71ce..0000000 --- a/vendor/rails/activerecord/test/migrations/missing/3_we_need_reminders.rb +++ /dev/null @@ -1,12 +0,0 @@ -class WeNeedReminders < ActiveRecord::Migration - def self.up - create_table("reminders") do |t| - t.column :content, :text - t.column :remind_at, :datetime - end - end - - def self.down - drop_table "reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/missing/4_innocent_jointable.rb b/vendor/rails/activerecord/test/migrations/missing/4_innocent_jointable.rb deleted file mode 100644 index 21c9ca5..0000000 --- a/vendor/rails/activerecord/test/migrations/missing/4_innocent_jointable.rb +++ /dev/null @@ -1,12 +0,0 @@ -class InnocentJointable < ActiveRecord::Migration - def self.up - create_table("people_reminders", :id => false) do |t| - t.column :reminder_id, :integer - t.column :person_id, :integer - end - end - - def self.down - drop_table "people_reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/valid/1_people_have_last_names.rb b/vendor/rails/activerecord/test/migrations/valid/1_people_have_last_names.rb deleted file mode 100644 index 81af5fe..0000000 --- a/vendor/rails/activerecord/test/migrations/valid/1_people_have_last_names.rb +++ /dev/null @@ -1,9 +0,0 @@ -class PeopleHaveLastNames < ActiveRecord::Migration - def self.up - add_column "people", "last_name", :string - end - - def self.down - remove_column "people", "last_name" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/valid/2_we_need_reminders.rb b/vendor/rails/activerecord/test/migrations/valid/2_we_need_reminders.rb deleted file mode 100644 index d5e71ce..0000000 --- a/vendor/rails/activerecord/test/migrations/valid/2_we_need_reminders.rb +++ /dev/null @@ -1,12 +0,0 @@ -class WeNeedReminders < ActiveRecord::Migration - def self.up - create_table("reminders") do |t| - t.column :content, :text - t.column :remind_at, :datetime - end - end - - def self.down - drop_table "reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/migrations/valid/3_innocent_jointable.rb b/vendor/rails/activerecord/test/migrations/valid/3_innocent_jointable.rb deleted file mode 100644 index 21c9ca5..0000000 --- a/vendor/rails/activerecord/test/migrations/valid/3_innocent_jointable.rb +++ /dev/null @@ -1,12 +0,0 @@ -class InnocentJointable < ActiveRecord::Migration - def self.up - create_table("people_reminders", :id => false) do |t| - t.column :reminder_id, :integer - t.column :person_id, :integer - end - end - - def self.down - drop_table "people_reminders" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/author.rb b/vendor/rails/activerecord/test/models/author.rb deleted file mode 100644 index 4ffac4f..0000000 --- a/vendor/rails/activerecord/test/models/author.rb +++ /dev/null @@ -1,141 +0,0 @@ -class Author < ActiveRecord::Base - has_many :posts - has_many :posts_with_comments, :include => :comments, :class_name => "Post" - has_many :popular_grouped_posts, :include => :comments, :class_name => "Post", :group => "type", :having => "SUM(comments_count) > 1", :select => "type" - has_many :posts_with_comments_sorted_by_comment_id, :include => :comments, :class_name => "Post", :order => 'comments.id' - has_many :posts_sorted_by_id_limited, :class_name => "Post", :order => 'posts.id', :limit => 1 - has_many :posts_with_categories, :include => :categories, :class_name => "Post" - has_many :posts_with_comments_and_categories, :include => [ :comments, :categories ], :order => "posts.id", :class_name => "Post" - has_many :posts_containing_the_letter_a, :class_name => "Post" - has_many :posts_with_extension, :class_name => "Post" do #, :extend => ProxyTestExtension - def testing_proxy_owner - proxy_owner - end - def testing_proxy_reflection - proxy_reflection - end - def testing_proxy_target - proxy_target - end - end - has_one :post_about_thinking, :class_name => 'Post', :conditions => "posts.title like '%thinking%'" - has_one :post_about_thinking_with_last_comment, :class_name => 'Post', :conditions => "posts.title like '%thinking%'", :include => :last_comment - has_many :comments, :through => :posts - has_many :comments_containing_the_letter_e, :through => :posts, :source => :comments - has_many :comments_with_order_and_conditions, :through => :posts, :source => :comments, :order => 'comments.body', :conditions => "comments.body like 'Thank%'" - has_many :comments_with_include, :through => :posts, :source => :comments, :include => :post - - - has_many :comments_desc, :through => :posts, :source => :comments, :order => 'comments.id DESC' - has_many :limited_comments, :through => :posts, :source => :comments, :limit => 1 - has_many :funky_comments, :through => :posts, :source => :comments - has_many :ordered_uniq_comments, :through => :posts, :source => :comments, :uniq => true, :order => 'comments.id' - has_many :ordered_uniq_comments_desc, :through => :posts, :source => :comments, :uniq => true, :order => 'comments.id DESC' - has_many :readonly_comments, :through => :posts, :source => :comments, :readonly => true - - has_many :special_posts - has_many :special_post_comments, :through => :special_posts, :source => :comments - - has_many :sti_posts, :class_name => 'StiPost' - has_many :sti_post_comments, :through => :sti_posts, :source => :comments - - has_many :special_nonexistant_posts, :class_name => "SpecialPost", :conditions => "posts.body = 'nonexistant'" - has_many :special_nonexistant_post_comments, :through => :special_nonexistant_posts, :source => :comments, :conditions => "comments.post_id = 0" - has_many :nonexistant_comments, :through => :posts - - has_many :hello_posts, :class_name => "Post", :conditions => "posts.body = 'hello'" - has_many :hello_post_comments, :through => :hello_posts, :source => :comments - has_many :posts_with_no_comments, :class_name => 'Post', :conditions => 'comments.id is null', :include => :comments - - has_many :hello_posts_with_hash_conditions, :class_name => "Post", -:conditions => {:body => 'hello'} - has_many :hello_post_comments_with_hash_conditions, :through => -:hello_posts_with_hash_conditions, :source => :comments - - has_many :other_posts, :class_name => "Post" - has_many :posts_with_callbacks, :class_name => "Post", :before_add => :log_before_adding, - :after_add => :log_after_adding, - :before_remove => :log_before_removing, - :after_remove => :log_after_removing - has_many :posts_with_proc_callbacks, :class_name => "Post", - :before_add => Proc.new {|o, r| o.post_log << "before_adding#{r.id || '<new>'}"}, - :after_add => Proc.new {|o, r| o.post_log << "after_adding#{r.id || '<new>'}"}, - :before_remove => Proc.new {|o, r| o.post_log << "before_removing#{r.id}"}, - :after_remove => Proc.new {|o, r| o.post_log << "after_removing#{r.id}"} - has_many :posts_with_multiple_callbacks, :class_name => "Post", - :before_add => [:log_before_adding, Proc.new {|o, r| o.post_log << "before_adding_proc#{r.id || '<new>'}"}], - :after_add => [:log_after_adding, Proc.new {|o, r| o.post_log << "after_adding_proc#{r.id || '<new>'}"}] - has_many :unchangable_posts, :class_name => "Post", :before_add => :raise_exception, :after_add => :log_after_adding - - has_many :categorizations - has_many :categories, :through => :categorizations - - has_many :categories_like_general, :through => :categorizations, :source => :category, :class_name => 'Category', :conditions => { :name => 'General' } - - has_many :categorized_posts, :through => :categorizations, :source => :post - has_many :unique_categorized_posts, :through => :categorizations, :source => :post, :uniq => true - - has_many :nothings, :through => :kateggorisatons, :class_name => 'Category' - - has_many :author_favorites - has_many :favorite_authors, :through => :author_favorites, :order => 'name' - - has_many :tagging, :through => :posts # through polymorphic has_one - has_many :taggings, :through => :posts, :source => :taggings # through polymorphic has_many - has_many :tags, :through => :posts # through has_many :through - has_many :post_categories, :through => :posts, :source => :categories - - belongs_to :author_address, :dependent => :destroy - belongs_to :author_address_extra, :dependent => :delete, :class_name => "AuthorAddress" - - attr_accessor :post_log - - def after_initialize - @post_log = [] - end - - def label - "#{id}-#{name}" - end - - private - def log_before_adding(object) - @post_log << "before_adding#{object.id || '<new>'}" - end - - def log_after_adding(object) - @post_log << "after_adding#{object.id}" - end - - def log_before_removing(object) - @post_log << "before_removing#{object.id}" - end - - def log_after_removing(object) - @post_log << "after_removing#{object.id}" - end - - def raise_exception(object) - raise Exception.new("You can't add a post") - end -end - -class AuthorAddress < ActiveRecord::Base - has_one :author - - def self.destroyed_author_address_ids - @destroyed_author_address_ids ||= Hash.new { |h,k| h[k] = [] } - end - - before_destroy do |author_address| - if author_address.author - AuthorAddress.destroyed_author_address_ids[author_address.author.id] << author_address.id - end - true - end -end - -class AuthorFavorite < ActiveRecord::Base - belongs_to :author - belongs_to :favorite_author, :class_name => "Author" -end diff --git a/vendor/rails/activerecord/test/models/auto_id.rb b/vendor/rails/activerecord/test/models/auto_id.rb deleted file mode 100644 index d720e2b..0000000 --- a/vendor/rails/activerecord/test/models/auto_id.rb +++ /dev/null @@ -1,4 +0,0 @@ -class AutoId < ActiveRecord::Base - def self.table_name () "auto_id_tests" end - def self.primary_key () "auto_id" end -end diff --git a/vendor/rails/activerecord/test/models/binary.rb b/vendor/rails/activerecord/test/models/binary.rb deleted file mode 100644 index 950c459..0000000 --- a/vendor/rails/activerecord/test/models/binary.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Binary < ActiveRecord::Base -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/bird.rb b/vendor/rails/activerecord/test/models/bird.rb deleted file mode 100644 index 341d2ee..0000000 --- a/vendor/rails/activerecord/test/models/bird.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Bird < ActiveRecord::Base - validates_presence_of :name -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/book.rb b/vendor/rails/activerecord/test/models/book.rb deleted file mode 100644 index cfd07ab..0000000 --- a/vendor/rails/activerecord/test/models/book.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Book < ActiveRecord::Base - has_many :citations, :foreign_key => 'book1_id' - has_many :references, :through => :citations, :source => :reference_of, :uniq => true -end diff --git a/vendor/rails/activerecord/test/models/categorization.rb b/vendor/rails/activerecord/test/models/categorization.rb deleted file mode 100644 index 1059432..0000000 --- a/vendor/rails/activerecord/test/models/categorization.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Categorization < ActiveRecord::Base - belongs_to :post - belongs_to :category - belongs_to :author -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/category.rb b/vendor/rails/activerecord/test/models/category.rb deleted file mode 100644 index 5efce6a..0000000 --- a/vendor/rails/activerecord/test/models/category.rb +++ /dev/null @@ -1,34 +0,0 @@ -class Category < ActiveRecord::Base - has_and_belongs_to_many :posts - has_and_belongs_to_many :special_posts, :class_name => "Post" - has_and_belongs_to_many :other_posts, :class_name => "Post" - has_and_belongs_to_many :posts_with_authors_sorted_by_author_id, :class_name => "Post", :include => :authors, :order => "authors.id" - - has_and_belongs_to_many(:select_testing_posts, - :class_name => 'Post', - :foreign_key => 'category_id', - :association_foreign_key => 'post_id', - :select => 'posts.*, 1 as correctness_marker') - - has_and_belongs_to_many :post_with_conditions, - :class_name => 'Post', - :conditions => { :title => 'Yet Another Testing Title' } - - has_and_belongs_to_many :popular_grouped_posts, :class_name => "Post", :group => "posts.type", :having => "sum(comments.post_id) > 2", :include => :comments - has_and_belongs_to_many :posts_gruoped_by_title, :class_name => "Post", :group => "title", :select => "title" - - def self.what_are_you - 'a category...' - end - - has_many :categorizations - has_many :authors, :through => :categorizations, :select => 'authors.*, categorizations.post_id' -end - -class SpecialCategory < Category - - def self.what_are_you - 'a special category...' - end - -end diff --git a/vendor/rails/activerecord/test/models/citation.rb b/vendor/rails/activerecord/test/models/citation.rb deleted file mode 100644 index 545aa81..0000000 --- a/vendor/rails/activerecord/test/models/citation.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Citation < ActiveRecord::Base - belongs_to :reference_of, :class_name => "Book", :foreign_key => :book2_id - - belongs_to :book1, :class_name => "Book", :foreign_key => :book1_id - belongs_to :book2, :class_name => "Book", :foreign_key => :book2_id -end diff --git a/vendor/rails/activerecord/test/models/club.rb b/vendor/rails/activerecord/test/models/club.rb deleted file mode 100644 index 6e7cdd6..0000000 --- a/vendor/rails/activerecord/test/models/club.rb +++ /dev/null @@ -1,13 +0,0 @@ -class Club < ActiveRecord::Base - has_many :memberships - has_many :members, :through => :memberships - has_many :current_memberships - has_one :sponsor - has_one :sponsored_member, :through => :sponsor, :source => :sponsorable, :source_type => "Member" - - private - - def private_method - "I'm sorry sir, this is a *private* club, not a *pirate* club" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/column_name.rb b/vendor/rails/activerecord/test/models/column_name.rb deleted file mode 100644 index ec07205..0000000 --- a/vendor/rails/activerecord/test/models/column_name.rb +++ /dev/null @@ -1,3 +0,0 @@ -class ColumnName < ActiveRecord::Base - def self.table_name () "colnametests" end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/comment.rb b/vendor/rails/activerecord/test/models/comment.rb deleted file mode 100644 index f7f07c1..0000000 --- a/vendor/rails/activerecord/test/models/comment.rb +++ /dev/null @@ -1,25 +0,0 @@ -class Comment < ActiveRecord::Base - named_scope :containing_the_letter_e, :conditions => "comments.body LIKE '%e%'" - - belongs_to :post, :counter_cache => true - - def self.what_are_you - 'a comment...' - end - - def self.search_by_type(q) - self.find(:all, :conditions => ["#{QUOTED_TYPE} = ?", q]) - end -end - -class SpecialComment < Comment - def self.what_are_you - 'a special comment...' - end -end - -class VerySpecialComment < Comment - def self.what_are_you - 'a very special comment...' - end -end diff --git a/vendor/rails/activerecord/test/models/company.rb b/vendor/rails/activerecord/test/models/company.rb deleted file mode 100644 index 02a775f..0000000 --- a/vendor/rails/activerecord/test/models/company.rb +++ /dev/null @@ -1,159 +0,0 @@ -class AbstractCompany < ActiveRecord::Base - self.abstract_class = true -end - -class Company < AbstractCompany - attr_protected :rating - set_sequence_name :companies_nonstd_seq - - validates_presence_of :name - - has_one :dummy_account, :foreign_key => "firm_id", :class_name => "Account" - - def arbitrary_method - "I am Jack's profound disappointment" - end - - private - - def private_method - "I am Jack's innermost fears and aspirations" - end -end - -module Namespaced - class Company < ::Company - end - - class Firm < ::Company - has_many :clients, :class_name => 'Namespaced::Client' - end - - class Client < ::Company - end -end - -class Firm < Company - has_many :clients, :order => "id", :dependent => :destroy, :counter_sql => - "SELECT COUNT(*) FROM companies WHERE firm_id = 1 " + - "AND (#{QUOTED_TYPE} = 'Client' OR #{QUOTED_TYPE} = 'SpecialClient' OR #{QUOTED_TYPE} = 'VerySpecialClient' )" - has_many :unsorted_clients, :class_name => "Client" - has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC" - has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id" - has_many :unvalidated_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :validate => false - has_many :dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :destroy - has_many :exclusively_dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all - has_many :limited_clients, :class_name => "Client", :order => "id", :limit => 1 - has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id" - has_many :clients_with_interpolated_conditions, :class_name => "Client", :conditions => 'rating > #{rating}' - has_many :clients_like_ms_with_hash_conditions, :conditions => { :name => 'Microsoft' }, :class_name => "Client", :order => "id" - has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}' - has_many :clients_using_counter_sql, :class_name => "Client", - :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}', - :counter_sql => 'SELECT COUNT(*) FROM companies WHERE client_of = #{id}' - has_many :clients_using_zero_counter_sql, :class_name => "Client", - :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}', - :counter_sql => 'SELECT 0 FROM companies WHERE client_of = #{id}' - has_many :no_clients_using_counter_sql, :class_name => "Client", - :finder_sql => 'SELECT * FROM companies WHERE client_of = 1000', - :counter_sql => 'SELECT COUNT(*) FROM companies WHERE client_of = 1000' - has_many :clients_using_finder_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE 1=1' - has_many :plain_clients, :class_name => 'Client' - has_many :readonly_clients, :class_name => 'Client', :readonly => true - has_many :clients_using_primary_key, :class_name => 'Client', - :primary_key => 'name', :foreign_key => 'firm_name' - has_many :clients_grouped_by_firm_id, :class_name => "Client", :group => "firm_id", :select => "firm_id" - has_many :clients_grouped_by_name, :class_name => "Client", :group => "name", :select => "name" - - has_one :account, :foreign_key => "firm_id", :dependent => :destroy, :validate => true - has_one :unvalidated_account, :foreign_key => "firm_id", :class_name => 'Account', :validate => false - has_one :account_with_select, :foreign_key => "firm_id", :select => "id, firm_id", :class_name=>'Account' - has_one :readonly_account, :foreign_key => "firm_id", :class_name => "Account", :readonly => true - has_one :account_using_primary_key, :primary_key => "firm_id", :class_name => "Account" - has_one :deletable_account, :foreign_key => "firm_id", :class_name => "Account", :dependent => :delete -end - -class DependentFirm < Company - has_one :account, :foreign_key => "firm_id", :dependent => :nullify - has_many :companies, :foreign_key => 'client_of', :order => "id", :dependent => :nullify -end - -class ExclusivelyDependentFirm < Company - has_one :account, :foreign_key => "firm_id", :dependent => :delete - has_many :dependent_sanitized_conditional_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all, :conditions => "name = 'BigShot Inc.'" - has_many :dependent_conditional_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all, :conditions => ["name = ?", 'BigShot Inc.'] - has_many :dependent_hash_conditional_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all, :conditions => {:name => 'BigShot Inc.'} -end - -class Client < Company - belongs_to :firm, :foreign_key => "client_of" - belongs_to :firm_with_basic_id, :class_name => "Firm", :foreign_key => "firm_id" - belongs_to :firm_with_select, :class_name => "Firm", :foreign_key => "firm_id", :select => "id" - belongs_to :firm_with_other_name, :class_name => "Firm", :foreign_key => "client_of" - belongs_to :firm_with_condition, :class_name => "Firm", :foreign_key => "client_of", :conditions => ["1 = ?", 1] - belongs_to :readonly_firm, :class_name => "Firm", :foreign_key => "firm_id", :readonly => true - - # Record destruction so we can test whether firm.clients.clear has - # is calling client.destroy, deleting from the database, or setting - # foreign keys to NULL. - def self.destroyed_client_ids - @destroyed_client_ids ||= Hash.new { |h,k| h[k] = [] } - end - - before_destroy do |client| - if client.firm - Client.destroyed_client_ids[client.firm.id] << client.id - end - true - end - - # Used to test that read and question methods are not generated for these attributes - def ruby_type - read_attribute :ruby_type - end - - def rating? - query_attribute :rating - end - - class << self - private - - def private_method - "darkness" - end - end -end - - -class SpecialClient < Client -end - -class VerySpecialClient < SpecialClient -end - -class Account < ActiveRecord::Base - belongs_to :firm - - def self.destroyed_account_ids - @destroyed_account_ids ||= Hash.new { |h,k| h[k] = [] } - end - - before_destroy do |account| - if account.firm - Account.destroyed_account_ids[account.firm.id] << account.id - end - true - end - - protected - def validate - errors.add_on_empty "credit_limit" - end - - private - - def private_method - "Sir, yes sir!" - end -end diff --git a/vendor/rails/activerecord/test/models/company_in_module.rb b/vendor/rails/activerecord/test/models/company_in_module.rb deleted file mode 100644 index 7f02403..0000000 --- a/vendor/rails/activerecord/test/models/company_in_module.rb +++ /dev/null @@ -1,61 +0,0 @@ -module MyApplication - module Business - class Company < ActiveRecord::Base - attr_protected :rating - end - - class Firm < Company - has_many :clients, :order => "id", :dependent => :destroy - has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC" - has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id" - has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id" - has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}' - - has_one :account, :dependent => :destroy - end - - class Client < Company - belongs_to :firm, :foreign_key => "client_of" - belongs_to :firm_with_other_name, :class_name => "Firm", :foreign_key => "client_of" - - class Contact < ActiveRecord::Base; end - end - - class Developer < ActiveRecord::Base - has_and_belongs_to_many :projects - validates_length_of :name, :within => (3..20) - end - - class Project < ActiveRecord::Base - has_and_belongs_to_many :developers - end - - end - - module Billing - class Firm < ActiveRecord::Base - self.table_name = 'companies' - end - - module Nested - class Firm < ActiveRecord::Base - self.table_name = 'companies' - end - end - - class Account < ActiveRecord::Base - with_options(:foreign_key => :firm_id) do |i| - i.belongs_to :firm, :class_name => 'MyApplication::Business::Firm' - i.belongs_to :qualified_billing_firm, :class_name => 'MyApplication::Billing::Firm' - i.belongs_to :unqualified_billing_firm, :class_name => 'Firm' - i.belongs_to :nested_qualified_billing_firm, :class_name => 'MyApplication::Billing::Nested::Firm' - i.belongs_to :nested_unqualified_billing_firm, :class_name => 'Nested::Firm' - end - - protected - def validate - errors.add_on_empty "credit_limit" - end - end - end -end diff --git a/vendor/rails/activerecord/test/models/computer.rb b/vendor/rails/activerecord/test/models/computer.rb deleted file mode 100644 index cc8deb1..0000000 --- a/vendor/rails/activerecord/test/models/computer.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Computer < ActiveRecord::Base - belongs_to :developer, :foreign_key=>'developer' -end diff --git a/vendor/rails/activerecord/test/models/contact.rb b/vendor/rails/activerecord/test/models/contact.rb deleted file mode 100644 index dbfa57b..0000000 --- a/vendor/rails/activerecord/test/models/contact.rb +++ /dev/null @@ -1,16 +0,0 @@ -class Contact < ActiveRecord::Base - # mock out self.columns so no pesky db is needed for these tests - def self.column(name, sql_type = nil, options = {}) - @columns ||= [] - @columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, options[:default], sql_type.to_s, options[:null]) - end - - column :name, :string - column :age, :integer - column :avatar, :binary - column :created_at, :datetime - column :awesome, :boolean - column :preferences, :string - - serialize :preferences -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/course.rb b/vendor/rails/activerecord/test/models/course.rb deleted file mode 100644 index 8a40fa7..0000000 --- a/vendor/rails/activerecord/test/models/course.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Course < ActiveRecord::Base - has_many :entrants -end diff --git a/vendor/rails/activerecord/test/models/customer.rb b/vendor/rails/activerecord/test/models/customer.rb deleted file mode 100644 index e258ccd..0000000 --- a/vendor/rails/activerecord/test/models/customer.rb +++ /dev/null @@ -1,73 +0,0 @@ -class Customer < ActiveRecord::Base - composed_of :address, :mapping => [ %w(address_street street), %w(address_city city), %w(address_country country) ], :allow_nil => true - composed_of :balance, :class_name => "Money", :mapping => %w(balance amount), :converter => Proc.new { |balance| balance.to_money } - composed_of :gps_location, :allow_nil => true - composed_of :fullname, :mapping => %w(name to_s), :constructor => Proc.new { |name| Fullname.parse(name) }, :converter => :parse -end - -class Address - attr_reader :street, :city, :country - - def initialize(street, city, country) - @street, @city, @country = street, city, country - end - - def close_to?(other_address) - city == other_address.city && country == other_address.country - end - - def ==(other) - other.is_a?(self.class) && other.street == street && other.city == city && other.country == country - end -end - -class Money - attr_reader :amount, :currency - - EXCHANGE_RATES = { "USD_TO_DKK" => 6, "DKK_TO_USD" => 0.6 } - - def initialize(amount, currency = "USD") - @amount, @currency = amount, currency - end - - def exchange_to(other_currency) - Money.new((amount * EXCHANGE_RATES["#{currency}_TO_#{other_currency}"]).floor, other_currency) - end -end - -class GpsLocation - attr_reader :gps_location - - def initialize(gps_location) - @gps_location = gps_location - end - - def latitude - gps_location.split("x").first - end - - def longitude - gps_location.split("x").last - end - - def ==(other) - self.latitude == other.latitude && self.longitude == other.longitude - end -end - -class Fullname - attr_reader :first, :last - - def self.parse(str) - return nil unless str - new(*str.to_s.split) - end - - def initialize(first, last = nil) - @first, @last = first, last - end - - def to_s - "#{first} #{last.upcase}" - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/default.rb b/vendor/rails/activerecord/test/models/default.rb deleted file mode 100644 index 887e9cc..0000000 --- a/vendor/rails/activerecord/test/models/default.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Default < ActiveRecord::Base -end diff --git a/vendor/rails/activerecord/test/models/developer.rb b/vendor/rails/activerecord/test/models/developer.rb deleted file mode 100644 index 92039a4..0000000 --- a/vendor/rails/activerecord/test/models/developer.rb +++ /dev/null @@ -1,91 +0,0 @@ -module DeveloperProjectsAssociationExtension - def find_most_recent - find(:first, :order => "id DESC") - end -end - -module DeveloperProjectsAssociationExtension2 - def find_least_recent - find(:first, :order => "id ASC") - end -end - -class Developer < ActiveRecord::Base - has_and_belongs_to_many :projects do - def find_most_recent - find(:first, :order => "id DESC") - end - end - - has_and_belongs_to_many :projects_extended_by_name, - :class_name => "Project", - :join_table => "developers_projects", - :association_foreign_key => "project_id", - :extend => DeveloperProjectsAssociationExtension - - has_and_belongs_to_many :projects_extended_by_name_twice, - :class_name => "Project", - :join_table => "developers_projects", - :association_foreign_key => "project_id", - :extend => [DeveloperProjectsAssociationExtension, DeveloperProjectsAssociationExtension2] - - has_and_belongs_to_many :projects_extended_by_name_and_block, - :class_name => "Project", - :join_table => "developers_projects", - :association_foreign_key => "project_id", - :extend => DeveloperProjectsAssociationExtension do - def find_least_recent - find(:first, :order => "id ASC") - end - end - - has_and_belongs_to_many :special_projects, :join_table => 'developers_projects', :association_foreign_key => 'project_id' - - has_many :audit_logs - - named_scope :jamises, :conditions => {:name => 'Jamis'} - - validates_inclusion_of :salary, :in => 50000..200000 - validates_length_of :name, :within => 3..20 - - before_create do |developer| - developer.audit_logs.build :message => "Computer created" - end - - def log=(message) - audit_logs.build :message => message - end -end - -class AuditLog < ActiveRecord::Base - belongs_to :developer, :validate => true - belongs_to :unvalidated_developer, :class_name => 'Developer' -end - -DeveloperSalary = Struct.new(:amount) -class DeveloperWithAggregate < ActiveRecord::Base - self.table_name = 'developers' - composed_of :salary, :class_name => 'DeveloperSalary', :mapping => [%w(salary amount)] -end - -class DeveloperWithBeforeDestroyRaise < ActiveRecord::Base - self.table_name = 'developers' - has_and_belongs_to_many :projects, :join_table => 'developers_projects', :foreign_key => 'developer_id' - before_destroy :raise_if_projects_empty! - - def raise_if_projects_empty! - raise if projects.empty? - end -end - -class DeveloperOrderedBySalary < ActiveRecord::Base - self.table_name = 'developers' - default_scope :order => 'salary DESC' - named_scope :by_name, :order => 'name DESC' - - def self.all_ordered_by_name - with_scope(:find => { :order => 'name DESC' }) do - find(:all) - end - end -end diff --git a/vendor/rails/activerecord/test/models/edge.rb b/vendor/rails/activerecord/test/models/edge.rb deleted file mode 100644 index 55e0c31..0000000 --- a/vendor/rails/activerecord/test/models/edge.rb +++ /dev/null @@ -1,5 +0,0 @@ -# This class models an edge in a directed graph. -class Edge < ActiveRecord::Base - belongs_to :source, :class_name => 'Vertex', :foreign_key => 'source_id' - belongs_to :sink, :class_name => 'Vertex', :foreign_key => 'sink_id' -end diff --git a/vendor/rails/activerecord/test/models/entrant.rb b/vendor/rails/activerecord/test/models/entrant.rb deleted file mode 100644 index 4682ce4..0000000 --- a/vendor/rails/activerecord/test/models/entrant.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Entrant < ActiveRecord::Base - belongs_to :course -end diff --git a/vendor/rails/activerecord/test/models/event.rb b/vendor/rails/activerecord/test/models/event.rb deleted file mode 100644 index 99fa0fe..0000000 --- a/vendor/rails/activerecord/test/models/event.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Event < ActiveRecord::Base - validates_uniqueness_of :title -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/guid.rb b/vendor/rails/activerecord/test/models/guid.rb deleted file mode 100644 index 9208dc2..0000000 --- a/vendor/rails/activerecord/test/models/guid.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Guid < ActiveRecord::Base -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/item.rb b/vendor/rails/activerecord/test/models/item.rb deleted file mode 100644 index c2571dd..0000000 --- a/vendor/rails/activerecord/test/models/item.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AbstractItem < ActiveRecord::Base - self.abstract_class = true - has_one :tagging, :as => :taggable -end - -class Item < AbstractItem -end diff --git a/vendor/rails/activerecord/test/models/job.rb b/vendor/rails/activerecord/test/models/job.rb deleted file mode 100644 index 3333a02..0000000 --- a/vendor/rails/activerecord/test/models/job.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Job < ActiveRecord::Base - has_many :references - has_many :people, :through => :references - belongs_to :ideal_reference, :class_name => 'Reference' -end diff --git a/vendor/rails/activerecord/test/models/joke.rb b/vendor/rails/activerecord/test/models/joke.rb deleted file mode 100644 index 3978abc..0000000 --- a/vendor/rails/activerecord/test/models/joke.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Joke < ActiveRecord::Base - set_table_name 'funny_jokes' -end diff --git a/vendor/rails/activerecord/test/models/keyboard.rb b/vendor/rails/activerecord/test/models/keyboard.rb deleted file mode 100644 index 32a4a7f..0000000 --- a/vendor/rails/activerecord/test/models/keyboard.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Keyboard < ActiveRecord::Base - set_primary_key 'key_number' -end diff --git a/vendor/rails/activerecord/test/models/legacy_thing.rb b/vendor/rails/activerecord/test/models/legacy_thing.rb deleted file mode 100644 index eaeb642..0000000 --- a/vendor/rails/activerecord/test/models/legacy_thing.rb +++ /dev/null @@ -1,3 +0,0 @@ -class LegacyThing < ActiveRecord::Base - set_locking_column :version -end diff --git a/vendor/rails/activerecord/test/models/matey.rb b/vendor/rails/activerecord/test/models/matey.rb deleted file mode 100644 index 47b0baa..0000000 --- a/vendor/rails/activerecord/test/models/matey.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Matey < ActiveRecord::Base - belongs_to :pirate - belongs_to :target, :class_name => 'Pirate' -end diff --git a/vendor/rails/activerecord/test/models/member.rb b/vendor/rails/activerecord/test/models/member.rb deleted file mode 100644 index 255fb56..0000000 --- a/vendor/rails/activerecord/test/models/member.rb +++ /dev/null @@ -1,12 +0,0 @@ -class Member < ActiveRecord::Base - has_one :current_membership - has_many :memberships - has_many :fellow_members, :through => :club, :source => :members - has_one :club, :through => :current_membership - has_one :favourite_club, :through => :memberships, :conditions => ["memberships.favourite = ?", true], :source => :club - has_one :sponsor, :as => :sponsorable - has_one :sponsor_club, :through => :sponsor - has_one :member_detail - has_one :organization, :through => :member_detail - belongs_to :member_type -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/member_detail.rb b/vendor/rails/activerecord/test/models/member_detail.rb deleted file mode 100644 index 94f59e5..0000000 --- a/vendor/rails/activerecord/test/models/member_detail.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MemberDetail < ActiveRecord::Base - belongs_to :member - belongs_to :organization - has_one :member_type, :through => :member -end diff --git a/vendor/rails/activerecord/test/models/member_type.rb b/vendor/rails/activerecord/test/models/member_type.rb deleted file mode 100644 index a13561c..0000000 --- a/vendor/rails/activerecord/test/models/member_type.rb +++ /dev/null @@ -1,3 +0,0 @@ -class MemberType < ActiveRecord::Base - has_many :members -end diff --git a/vendor/rails/activerecord/test/models/membership.rb b/vendor/rails/activerecord/test/models/membership.rb deleted file mode 100644 index 905f948..0000000 --- a/vendor/rails/activerecord/test/models/membership.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Membership < ActiveRecord::Base - belongs_to :member - belongs_to :club -end - -class CurrentMembership < Membership - belongs_to :member - belongs_to :club -end diff --git a/vendor/rails/activerecord/test/models/minimalistic.rb b/vendor/rails/activerecord/test/models/minimalistic.rb deleted file mode 100644 index 2e3f8e0..0000000 --- a/vendor/rails/activerecord/test/models/minimalistic.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Minimalistic < ActiveRecord::Base -end diff --git a/vendor/rails/activerecord/test/models/mixed_case_monkey.rb b/vendor/rails/activerecord/test/models/mixed_case_monkey.rb deleted file mode 100644 index 853f268..0000000 --- a/vendor/rails/activerecord/test/models/mixed_case_monkey.rb +++ /dev/null @@ -1,3 +0,0 @@ -class MixedCaseMonkey < ActiveRecord::Base - set_primary_key 'monkeyID' -end diff --git a/vendor/rails/activerecord/test/models/movie.rb b/vendor/rails/activerecord/test/models/movie.rb deleted file mode 100644 index 6384b4c..0000000 --- a/vendor/rails/activerecord/test/models/movie.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Movie < ActiveRecord::Base - def self.primary_key - "movieid" - end -end diff --git a/vendor/rails/activerecord/test/models/order.rb b/vendor/rails/activerecord/test/models/order.rb deleted file mode 100644 index e838c0b..0000000 --- a/vendor/rails/activerecord/test/models/order.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Order < ActiveRecord::Base - belongs_to :billing, :class_name => 'Customer', :foreign_key => 'billing_customer_id' - belongs_to :shipping, :class_name => 'Customer', :foreign_key => 'shipping_customer_id' -end diff --git a/vendor/rails/activerecord/test/models/organization.rb b/vendor/rails/activerecord/test/models/organization.rb deleted file mode 100644 index d79d503..0000000 --- a/vendor/rails/activerecord/test/models/organization.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Organization < ActiveRecord::Base - has_many :member_details - has_many :members, :through => :member_details -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/owner.rb b/vendor/rails/activerecord/test/models/owner.rb deleted file mode 100644 index 5760b99..0000000 --- a/vendor/rails/activerecord/test/models/owner.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Owner < ActiveRecord::Base - set_primary_key :owner_id - has_many :pets - has_many :toys, :through => :pets -end diff --git a/vendor/rails/activerecord/test/models/parrot.rb b/vendor/rails/activerecord/test/models/parrot.rb deleted file mode 100644 index 4a7ed52..0000000 --- a/vendor/rails/activerecord/test/models/parrot.rb +++ /dev/null @@ -1,16 +0,0 @@ -class Parrot < ActiveRecord::Base - set_inheritance_column :parrot_sti_class - has_and_belongs_to_many :pirates - has_and_belongs_to_many :treasures - has_many :loots, :as => :looter - alias_attribute :title, :name - - validates_presence_of :name -end - -class LiveParrot < Parrot -end - -class DeadParrot < Parrot - belongs_to :killer, :class_name => 'Pirate' -end diff --git a/vendor/rails/activerecord/test/models/person.rb b/vendor/rails/activerecord/test/models/person.rb deleted file mode 100644 index ec2f684..0000000 --- a/vendor/rails/activerecord/test/models/person.rb +++ /dev/null @@ -1,16 +0,0 @@ -class Person < ActiveRecord::Base - has_many :readers - has_many :posts, :through => :readers - has_many :posts_with_no_comments, :through => :readers, :source => :post, :include => :comments, :conditions => 'comments.id is null' - - has_many :references - has_many :jobs, :through => :references - has_one :favourite_reference, :class_name => 'Reference', :conditions => ['favourite=?', true] - has_many :posts_with_comments_sorted_by_comment_id, :through => :readers, :source => :post, :include => :comments, :order => 'comments.id' - - belongs_to :primary_contact, :class_name => 'Person' - has_many :agents, :class_name => 'Person', :foreign_key => 'primary_contact_id' - - named_scope :males, :conditions => { :gender => 'M' } - named_scope :females, :conditions => { :gender => 'F' } -end diff --git a/vendor/rails/activerecord/test/models/pet.rb b/vendor/rails/activerecord/test/models/pet.rb deleted file mode 100644 index dc1a3c5..0000000 --- a/vendor/rails/activerecord/test/models/pet.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Pet < ActiveRecord::Base - set_primary_key :pet_id - belongs_to :owner - has_many :toys -end diff --git a/vendor/rails/activerecord/test/models/pirate.rb b/vendor/rails/activerecord/test/models/pirate.rb deleted file mode 100644 index 238917b..0000000 --- a/vendor/rails/activerecord/test/models/pirate.rb +++ /dev/null @@ -1,63 +0,0 @@ -class Pirate < ActiveRecord::Base - belongs_to :parrot - has_and_belongs_to_many :parrots - has_and_belongs_to_many :parrots_with_method_callbacks, :class_name => "Parrot", - :before_add => :log_before_add, - :after_add => :log_after_add, - :before_remove => :log_before_remove, - :after_remove => :log_after_remove - has_and_belongs_to_many :parrots_with_proc_callbacks, :class_name => "Parrot", - :before_add => proc {|p,pa| p.ship_log << "before_adding_proc_parrot_#{pa.id || '<new>'}"}, - :after_add => proc {|p,pa| p.ship_log << "after_adding_proc_parrot_#{pa.id || '<new>'}"}, - :before_remove => proc {|p,pa| p.ship_log << "before_removing_proc_parrot_#{pa.id}"}, - :after_remove => proc {|p,pa| p.ship_log << "after_removing_proc_parrot_#{pa.id}"} - - has_many :treasures, :as => :looter - has_many :treasure_estimates, :through => :treasures, :source => :price_estimates - - # These both have :autosave enabled because accepts_nested_attributes_for is used on them. - has_one :ship - has_many :birds - has_many :birds_with_method_callbacks, :class_name => "Bird", - :before_add => :log_before_add, - :after_add => :log_after_add, - :before_remove => :log_before_remove, - :after_remove => :log_after_remove - has_many :birds_with_proc_callbacks, :class_name => "Bird", - :before_add => proc {|p,b| p.ship_log << "before_adding_proc_bird_#{b.id || '<new>'}"}, - :after_add => proc {|p,b| p.ship_log << "after_adding_proc_bird_#{b.id || '<new>'}"}, - :before_remove => proc {|p,b| p.ship_log << "before_removing_proc_bird_#{b.id}"}, - :after_remove => proc {|p,b| p.ship_log << "after_removing_proc_bird_#{b.id}"} - - accepts_nested_attributes_for :parrots, :birds, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } - accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } - accepts_nested_attributes_for :parrots_with_method_callbacks, :parrots_with_proc_callbacks, - :birds_with_method_callbacks, :birds_with_proc_callbacks, :allow_destroy => true - - validates_presence_of :catchphrase - - def ship_log - @ship_log ||= [] - end - - private - def log_before_add(record) - log(record, "before_adding_method") - end - - def log_after_add(record) - log(record, "after_adding_method") - end - - def log_before_remove(record) - log(record, "before_removing_method") - end - - def log_after_remove(record) - log(record, "after_removing_method") - end - - def log(record, callback) - ship_log << "#{callback}_#{record.class.name.downcase}_#{record.id || '<new>'}" - end -end diff --git a/vendor/rails/activerecord/test/models/post.rb b/vendor/rails/activerecord/test/models/post.rb deleted file mode 100644 index 374e536..0000000 --- a/vendor/rails/activerecord/test/models/post.rb +++ /dev/null @@ -1,100 +0,0 @@ -class Post < ActiveRecord::Base - named_scope :containing_the_letter_a, :conditions => "body LIKE '%a%'" - named_scope :ranked_by_comments, :order => "comments_count DESC" - named_scope :limit, lambda {|limit| {:limit => limit} } - named_scope :with_authors_at_address, lambda { |address| { - :conditions => [ 'authors.author_address_id = ?', address.id ], - :joins => 'JOIN authors ON authors.id = posts.author_id' - } - } - - belongs_to :author do - def greeting - "hello" - end - end - - belongs_to :author_with_posts, :class_name => "Author", :foreign_key => :author_id, :include => :posts - belongs_to :author_with_address, :class_name => "Author", :foreign_key => :author_id, :include => :author_address - - has_one :last_comment, :class_name => 'Comment', :order => 'id desc' - - named_scope :with_special_comments, :joins => :comments, :conditions => {:comments => {:type => 'SpecialComment'} } - named_scope :with_very_special_comments, :joins => :comments, :conditions => {:comments => {:type => 'VerySpecialComment'} } - named_scope :with_post, lambda {|post_id| - { :joins => :comments, :conditions => {:comments => {:post_id => post_id} } } - } - - has_many :comments, :order => "body" do - def find_most_recent - find(:first, :order => "id DESC") - end - end - - has_many :author_favorites, :through => :author - - has_many :comments_with_interpolated_conditions, :class_name => 'Comment', - :conditions => ['#{"#{aliased_table_name}." rescue ""}body = ?', 'Thank you for the welcome'] - - has_one :very_special_comment - has_one :very_special_comment_with_post, :class_name => "VerySpecialComment", :include => :post - has_many :special_comments - has_many :nonexistant_comments, :class_name => 'Comment', :conditions => 'comments.id < 0' - - has_and_belongs_to_many :categories - has_and_belongs_to_many :special_categories, :join_table => "categories_posts", :association_foreign_key => 'category_id' - - has_many :taggings, :as => :taggable - has_many :tags, :through => :taggings do - def add_joins_and_select - find :all, :select => 'tags.*, authors.id as author_id', :include => false, - :joins => 'left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id' - end - end - - has_many :funky_tags, :through => :taggings, :source => :tag - has_many :super_tags, :through => :taggings - has_one :tagging, :as => :taggable - - has_many :invalid_taggings, :as => :taggable, :class_name => "Tagging", :conditions => 'taggings.id < 0' - has_many :invalid_tags, :through => :invalid_taggings, :source => :tag - - has_many :categorizations, :foreign_key => :category_id - has_many :authors, :through => :categorizations - - has_many :readers - has_many :people, :through => :readers - has_many :people_with_callbacks, :source=>:person, :through => :readers, - :before_add => lambda {|owner, reader| log(:added, :before, reader.first_name) }, - :after_add => lambda {|owner, reader| log(:added, :after, reader.first_name) }, - :before_remove => lambda {|owner, reader| log(:removed, :before, reader.first_name) }, - :after_remove => lambda {|owner, reader| log(:removed, :after, reader.first_name) } - - def self.top(limit) - ranked_by_comments.limit(limit) - end - - def self.reset_log - @log = [] - end - - def self.log(message=nil, side=nil, new_record=nil) - return @log if message.nil? - @log << [message, side, new_record] - end - - def self.what_are_you - 'a post...' - end -end - -class SpecialPost < Post; end - -class StiPost < Post - self.abstract_class = true - has_one :special_comment, :class_name => "SpecialComment" -end - -class SubStiPost < StiPost - self.table_name = Post.table_name -end diff --git a/vendor/rails/activerecord/test/models/price_estimate.rb b/vendor/rails/activerecord/test/models/price_estimate.rb deleted file mode 100644 index ef3bba3..0000000 --- a/vendor/rails/activerecord/test/models/price_estimate.rb +++ /dev/null @@ -1,3 +0,0 @@ -class PriceEstimate < ActiveRecord::Base - belongs_to :estimate_of, :polymorphic => true -end diff --git a/vendor/rails/activerecord/test/models/project.rb b/vendor/rails/activerecord/test/models/project.rb deleted file mode 100644 index 550d4ae..0000000 --- a/vendor/rails/activerecord/test/models/project.rb +++ /dev/null @@ -1,30 +0,0 @@ -class Project < ActiveRecord::Base - has_and_belongs_to_many :developers, :uniq => true, :order => 'developers.name desc, developers.id desc' - has_and_belongs_to_many :readonly_developers, :class_name => "Developer", :readonly => true - has_and_belongs_to_many :selected_developers, :class_name => "Developer", :select => "developers.*", :uniq => true - has_and_belongs_to_many :non_unique_developers, :order => 'developers.name desc, developers.id desc', :class_name => 'Developer' - has_and_belongs_to_many :limited_developers, :class_name => "Developer", :limit => 1 - has_and_belongs_to_many :developers_named_david, :class_name => "Developer", :conditions => "name = 'David'", :uniq => true - has_and_belongs_to_many :developers_named_david_with_hash_conditions, :class_name => "Developer", :conditions => { :name => 'David' }, :uniq => true - has_and_belongs_to_many :salaried_developers, :class_name => "Developer", :conditions => "salary > 0" - has_and_belongs_to_many :developers_with_finder_sql, :class_name => "Developer", :finder_sql => 'SELECT t.*, j.* FROM developers_projects j, developers t WHERE t.id = j.developer_id AND j.project_id = #{id} ORDER BY t.id' - has_and_belongs_to_many :developers_by_sql, :class_name => "Developer", :delete_sql => "DELETE FROM developers_projects WHERE project_id = \#{id} AND developer_id = \#{record.id}" - has_and_belongs_to_many :developers_with_callbacks, :class_name => "Developer", :before_add => Proc.new {|o, r| o.developers_log << "before_adding#{r.id || '<new>'}"}, - :after_add => Proc.new {|o, r| o.developers_log << "after_adding#{r.id || '<new>'}"}, - :before_remove => Proc.new {|o, r| o.developers_log << "before_removing#{r.id}"}, - :after_remove => Proc.new {|o, r| o.developers_log << "after_removing#{r.id}"} - has_and_belongs_to_many :well_payed_salary_groups, :class_name => "Developer", :group => "salary", :having => "SUM(salary) > 10000", :select => "SUM(salary) as salary" - - attr_accessor :developers_log - - def after_initialize - @developers_log = [] - end - -end - -class SpecialProject < Project - def hello_world - "hello there!" - end -end diff --git a/vendor/rails/activerecord/test/models/reader.rb b/vendor/rails/activerecord/test/models/reader.rb deleted file mode 100644 index 27527bf..0000000 --- a/vendor/rails/activerecord/test/models/reader.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Reader < ActiveRecord::Base - belongs_to :post - belongs_to :person -end diff --git a/vendor/rails/activerecord/test/models/reference.rb b/vendor/rails/activerecord/test/models/reference.rb deleted file mode 100644 index 479e8b7..0000000 --- a/vendor/rails/activerecord/test/models/reference.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Reference < ActiveRecord::Base - belongs_to :person - belongs_to :job -end diff --git a/vendor/rails/activerecord/test/models/reply.rb b/vendor/rails/activerecord/test/models/reply.rb deleted file mode 100644 index 1c990ac..0000000 --- a/vendor/rails/activerecord/test/models/reply.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'models/topic' - -class Reply < Topic - named_scope :base - - belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true - has_many :replies, :class_name => "SillyReply", :dependent => :destroy, :foreign_key => "parent_id" - - validate :errors_on_empty_content - validate_on_create :title_is_wrong_create - - attr_accessible :title, :author_name, :author_email_address, :written_on, :content, :last_read - - def validate - errors.add("title", "Empty") unless attribute_present? "title" - end - - def errors_on_empty_content - errors.add("content", "Empty") unless attribute_present? "content" - end - - def validate_on_create - if attribute_present?("title") && attribute_present?("content") && content == "Mismatch" - errors.add("title", "is Content Mismatch") - end - end - - def title_is_wrong_create - errors.add("title", "is Wrong Create") if attribute_present?("title") && title == "Wrong Create" - end - - def validate_on_update - errors.add("title", "is Wrong Update") if attribute_present?("title") && title == "Wrong Update" - end -end - -class SillyReply < Reply - belongs_to :reply, :foreign_key => "parent_id", :counter_cache => :replies_count -end - -module Web - class Reply < Web::Topic - belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true, :class_name => 'Web::Topic' - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/ship.rb b/vendor/rails/activerecord/test/models/ship.rb deleted file mode 100644 index 06759d6..0000000 --- a/vendor/rails/activerecord/test/models/ship.rb +++ /dev/null @@ -1,10 +0,0 @@ -class Ship < ActiveRecord::Base - self.record_timestamps = false - - belongs_to :pirate - has_many :parts, :class_name => 'ShipPart', :autosave => true - - accepts_nested_attributes_for :pirate, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } - - validates_presence_of :name -end diff --git a/vendor/rails/activerecord/test/models/ship_part.rb b/vendor/rails/activerecord/test/models/ship_part.rb deleted file mode 100644 index 0a606db..0000000 --- a/vendor/rails/activerecord/test/models/ship_part.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ShipPart < ActiveRecord::Base - belongs_to :ship - - validates_presence_of :name -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/sponsor.rb b/vendor/rails/activerecord/test/models/sponsor.rb deleted file mode 100644 index 50c2c2d..0000000 --- a/vendor/rails/activerecord/test/models/sponsor.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Sponsor < ActiveRecord::Base - belongs_to :sponsor_club, :class_name => "Club", :foreign_key => "club_id" - belongs_to :sponsorable, :polymorphic => true -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/subject.rb b/vendor/rails/activerecord/test/models/subject.rb deleted file mode 100644 index 3502943..0000000 --- a/vendor/rails/activerecord/test/models/subject.rb +++ /dev/null @@ -1,4 +0,0 @@ -# used for OracleSynonymTest, see test/synonym_test_oci.rb -# -class Subject < ActiveRecord::Base -end diff --git a/vendor/rails/activerecord/test/models/subscriber.rb b/vendor/rails/activerecord/test/models/subscriber.rb deleted file mode 100644 index 5b78014..0000000 --- a/vendor/rails/activerecord/test/models/subscriber.rb +++ /dev/null @@ -1,8 +0,0 @@ -class Subscriber < ActiveRecord::Base - set_primary_key 'nick' - has_many :subscriptions - has_many :books, :through => :subscriptions -end - -class SpecialSubscriber < Subscriber -end diff --git a/vendor/rails/activerecord/test/models/subscription.rb b/vendor/rails/activerecord/test/models/subscription.rb deleted file mode 100644 index 4bdb36e..0000000 --- a/vendor/rails/activerecord/test/models/subscription.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Subscription < ActiveRecord::Base - belongs_to :subscriber - belongs_to :book -end diff --git a/vendor/rails/activerecord/test/models/tag.rb b/vendor/rails/activerecord/test/models/tag.rb deleted file mode 100644 index a581b38..0000000 --- a/vendor/rails/activerecord/test/models/tag.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Tag < ActiveRecord::Base - has_many :taggings - has_many :taggables, :through => :taggings - has_one :tagging - - has_many :tagged_posts, :through => :taggings, :source => :taggable, :source_type => 'Post' -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/tagging.rb b/vendor/rails/activerecord/test/models/tagging.rb deleted file mode 100644 index a1fa1a9..0000000 --- a/vendor/rails/activerecord/test/models/tagging.rb +++ /dev/null @@ -1,10 +0,0 @@ -# test that attr_readonly isn't called on the :taggable polymorphic association -module Taggable -end - -class Tagging < ActiveRecord::Base - belongs_to :tag, :include => :tagging - belongs_to :super_tag, :class_name => 'Tag', :foreign_key => 'super_tag_id' - belongs_to :invalid_tag, :class_name => 'Tag', :foreign_key => 'tag_id' - belongs_to :taggable, :polymorphic => true, :counter_cache => true -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/task.rb b/vendor/rails/activerecord/test/models/task.rb deleted file mode 100644 index ee0282c..0000000 --- a/vendor/rails/activerecord/test/models/task.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Task < ActiveRecord::Base - -end diff --git a/vendor/rails/activerecord/test/models/topic.rb b/vendor/rails/activerecord/test/models/topic.rb deleted file mode 100644 index 51012d2..0000000 --- a/vendor/rails/activerecord/test/models/topic.rb +++ /dev/null @@ -1,81 +0,0 @@ -class Topic < ActiveRecord::Base - named_scope :base - named_scope :written_before, lambda { |time| - if time - { :conditions => ['written_on < ?', time] } - end - } - named_scope :approved, :conditions => {:approved => true} - named_scope :rejected, :conditions => {:approved => false} - - named_scope :by_lifo, :conditions => {:author_name => 'lifo'} - - named_scope :approved_as_hash_condition, :conditions => {:topics => {:approved => true}} - named_scope 'approved_as_string', :conditions => {:approved => true} - named_scope :replied, :conditions => ['replies_count > 0'] - named_scope :anonymous_extension do - def one - 1 - end - end - module NamedExtension - def two - 2 - end - end - module MultipleExtensionOne - def extension_one - 1 - end - end - module MultipleExtensionTwo - def extension_two - 2 - end - end - named_scope :named_extension, :extend => NamedExtension - named_scope :multiple_extensions, :extend => [MultipleExtensionTwo, MultipleExtensionOne] - - named_scope :by_rejected_ids, lambda {{ :conditions => { :id => all(:conditions => {:approved => false}).map(&:id) } }} - - has_many :replies, :dependent => :destroy, :foreign_key => "parent_id" - serialize :content - - before_create :default_written_on - before_destroy :destroy_children - - def parent - Topic.find(parent_id) - end - - # trivial method for testing Array#to_xml with :methods - def topic_id - id - end - - protected - def approved=(val) - @custom_approved = val - write_attribute(:approved, val) - end - - def default_written_on - self.written_on = Time.now unless attribute_present?("written_on") - end - - def destroy_children - self.class.delete_all "parent_id = #{id}" - end - - def after_initialize - if self.new_record? - self.author_email_address = 'test@test.com' - end - end -end - -module Web - class Topic < ActiveRecord::Base - has_many :replies, :dependent => :destroy, :foreign_key => "parent_id", :class_name => 'Web::Reply' - end -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/models/toy.rb b/vendor/rails/activerecord/test/models/toy.rb deleted file mode 100644 index 79a88db..0000000 --- a/vendor/rails/activerecord/test/models/toy.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Toy < ActiveRecord::Base - set_primary_key :toy_id - belongs_to :pet -end diff --git a/vendor/rails/activerecord/test/models/treasure.rb b/vendor/rails/activerecord/test/models/treasure.rb deleted file mode 100644 index 97c690c..0000000 --- a/vendor/rails/activerecord/test/models/treasure.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Treasure < ActiveRecord::Base - has_and_belongs_to_many :parrots - belongs_to :looter, :polymorphic => true - - has_many :price_estimates, :as => :estimate_of -end diff --git a/vendor/rails/activerecord/test/models/vertex.rb b/vendor/rails/activerecord/test/models/vertex.rb deleted file mode 100644 index 48bb851..0000000 --- a/vendor/rails/activerecord/test/models/vertex.rb +++ /dev/null @@ -1,9 +0,0 @@ -# This class models a vertex in a directed graph. -class Vertex < ActiveRecord::Base - has_many :sink_edges, :class_name => 'Edge', :foreign_key => 'source_id' - has_many :sinks, :through => :sink_edges - - has_and_belongs_to_many :sources, - :class_name => 'Vertex', :join_table => 'edges', - :foreign_key => 'sink_id', :association_foreign_key => 'source_id' -end diff --git a/vendor/rails/activerecord/test/models/warehouse_thing.rb b/vendor/rails/activerecord/test/models/warehouse_thing.rb deleted file mode 100644 index 6ace118..0000000 --- a/vendor/rails/activerecord/test/models/warehouse_thing.rb +++ /dev/null @@ -1,5 +0,0 @@ -class WarehouseThing < ActiveRecord::Base - set_table_name "warehouse-things" - - validates_uniqueness_of :value -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/schema/mysql_specific_schema.rb b/vendor/rails/activerecord/test/schema/mysql_specific_schema.rb deleted file mode 100644 index f44c33a..0000000 --- a/vendor/rails/activerecord/test/schema/mysql_specific_schema.rb +++ /dev/null @@ -1,12 +0,0 @@ -ActiveRecord::Schema.define do - create_table :binary_fields, :force => true, :options => 'CHARACTER SET latin1' do |t| - t.binary :tiny_blob, :limit => 255 - t.binary :normal_blob, :limit => 65535 - t.binary :medium_blob, :limit => 16777215 - t.binary :long_blob, :limit => 2147483647 - t.text :tiny_text, :limit => 255 - t.text :normal_text, :limit => 65535 - t.text :medium_text, :limit => 16777215 - t.text :long_text, :limit => 2147483647 - end -end diff --git a/vendor/rails/activerecord/test/schema/postgresql_specific_schema.rb b/vendor/rails/activerecord/test/schema/postgresql_specific_schema.rb deleted file mode 100644 index 576a4d0..0000000 --- a/vendor/rails/activerecord/test/schema/postgresql_specific_schema.rb +++ /dev/null @@ -1,103 +0,0 @@ -ActiveRecord::Schema.define do - - %w(postgresql_arrays postgresql_moneys postgresql_numbers postgresql_times postgresql_network_addresses postgresql_bit_strings - postgresql_oids defaults geometrics).each do |table_name| - execute "DROP TABLE IF EXISTS #{quote_table_name table_name}" - end - - execute 'DROP SEQUENCE IF EXISTS companies_nonstd_seq CASCADE' - execute 'CREATE SEQUENCE companies_nonstd_seq START 101 OWNED BY companies.id' - execute "ALTER TABLE companies ALTER COLUMN id SET DEFAULT nextval('companies_nonstd_seq')" - execute 'DROP SEQUENCE IF EXISTS companies_id_seq' - - %w(accounts_id_seq developers_id_seq projects_id_seq topics_id_seq customers_id_seq orders_id_seq).each do |seq_name| - execute "SELECT setval('#{seq_name}', 100)" - end - - execute <<_SQL - CREATE TABLE defaults ( - id serial primary key, - modified_date date default CURRENT_DATE, - modified_date_function date default now(), - fixed_date date default '2004-01-01', - modified_time timestamp default CURRENT_TIMESTAMP, - modified_time_function timestamp default now(), - fixed_time timestamp default '2004-01-01 00:00:00.000000-00', - char1 char(1) default 'Y', - char2 character varying(50) default 'a varchar field', - char3 text default 'a text field', - positive_integer integer default 1, - negative_integer integer default -1, - decimal_number decimal(3,2) default 2.78, - multiline_default text DEFAULT '--- [] - -'::text -); -_SQL - - execute <<_SQL - CREATE TABLE geometrics ( - id serial primary key, - a_point point, - -- a_line line, (the line type is currently not implemented in postgresql) - a_line_segment lseg, - a_box box, - a_path path, - a_polygon polygon, - a_circle circle - ); -_SQL - - execute <<_SQL - CREATE TABLE postgresql_arrays ( - id SERIAL PRIMARY KEY, - commission_by_quarter INTEGER[], - nicknames TEXT[] - ); -_SQL - execute <<_SQL - CREATE TABLE postgresql_moneys ( - id SERIAL PRIMARY KEY, - wealth MONEY - ); -_SQL - - execute <<_SQL - CREATE TABLE postgresql_numbers ( - id SERIAL PRIMARY KEY, - single REAL, - double DOUBLE PRECISION - ); -_SQL - - execute <<_SQL - CREATE TABLE postgresql_times ( - id SERIAL PRIMARY KEY, - time_interval INTERVAL - ); -_SQL - - execute <<_SQL - CREATE TABLE postgresql_network_addresses ( - id SERIAL PRIMARY KEY, - cidr_address CIDR, - inet_address INET, - mac_address MACADDR - ); -_SQL - - execute <<_SQL - CREATE TABLE postgresql_bit_strings ( - id SERIAL PRIMARY KEY, - bit_string BIT(8), - bit_string_varying BIT VARYING(8) - ); -_SQL - - execute <<_SQL - CREATE TABLE postgresql_oids ( - id SERIAL PRIMARY KEY, - obj_id OID - ); -_SQL -end \ No newline at end of file diff --git a/vendor/rails/activerecord/test/schema/schema.rb b/vendor/rails/activerecord/test/schema/schema.rb deleted file mode 100644 index ea848a2..0000000 --- a/vendor/rails/activerecord/test/schema/schema.rb +++ /dev/null @@ -1,473 +0,0 @@ - -ActiveRecord::Schema.define do - def except(adapter_names_to_exclude) - unless [adapter_names_to_exclude].flatten.include?(adapter_name) - yield - end - end - - #put adapter specific setup here - case adapter_name - # For Firebird, set the sequence values 10000 when create_table is called; - # this prevents primary key collisions between "normally" created records - # and fixture-based (YAML) records. - when "Firebird" - def create_table(*args, &block) - ActiveRecord::Base.connection.create_table(*args, &block) - ActiveRecord::Base.connection.execute "SET GENERATOR #{args.first}_seq TO 10000" - end - end - - - # Please keep these create table statements in alphabetical order - # unless the ordering matters. In which case, define them below - create_table :accounts, :force => true do |t| - t.integer :firm_id - t.integer :credit_limit - end - - create_table :audit_logs, :force => true do |t| - t.column :message, :string, :null=>false - t.column :developer_id, :integer, :null=>false - end - - create_table :authors, :force => true do |t| - t.string :name, :null => false - t.integer :author_address_id - t.integer :author_address_extra_id - end - - create_table :author_addresses, :force => true do |t| - end - - create_table :author_favorites, :force => true do |t| - t.column :author_id, :integer - t.column :favorite_author_id, :integer - end - - - create_table :auto_id_tests, :force => true, :id => false do |t| - t.primary_key :auto_id - t.integer :value - end - - create_table :binaries, :force => true do |t| - t.binary :data - end - - create_table :birds, :force => true do |t| - t.string :name - t.integer :pirate_id - end - - create_table :books, :force => true do |t| - t.column :name, :string - end - - create_table :booleantests, :force => true do |t| - t.boolean :value - end - - create_table :categories, :force => true do |t| - t.string :name, :null => false - t.string :type - t.integer :categorizations_count - end - - create_table :categories_posts, :force => true, :id => false do |t| - t.integer :category_id, :null => false - t.integer :post_id, :null => false - end - - create_table :categorizations, :force => true do |t| - t.column :category_id, :integer - t.column :post_id, :integer - t.column :author_id, :integer - end - - create_table :citations, :force => true do |t| - t.column :book1_id, :integer - t.column :book2_id, :integer - end - - create_table :clubs, :force => true do |t| - t.string :name - end - - create_table :colnametests, :force => true do |t| - t.integer :references, :null => false - end - - create_table :comments, :force => true do |t| - t.integer :post_id, :null => false - t.text :body, :null => false - t.string :type - end - - create_table :companies, :force => true do |t| - t.string :type - t.string :ruby_type - t.integer :firm_id - t.string :firm_name - t.string :name - t.integer :client_of - t.integer :rating, :default => 1 - end - - create_table :computers, :force => true do |t| - t.integer :developer, :null => false - t.integer :extendedWarranty, :null => false - end - - - create_table :customers, :force => true do |t| - t.string :name - t.integer :balance, :default => 0 - t.string :address_street - t.string :address_city - t.string :address_country - t.string :gps_location - end - - create_table :developers, :force => true do |t| - t.string :name - t.integer :salary, :default => 70000 - t.datetime :created_at - t.datetime :updated_at - end - - create_table :developers_projects, :force => true, :id => false do |t| - t.integer :developer_id, :null => false - t.integer :project_id, :null => false - t.date :joined_on - t.integer :access_level, :default => 1 - end - - create_table :edges, :force => true do |t| - t.column :source_id, :integer, :null => false - t.column :sink_id, :integer, :null => false - end - add_index :edges, [:source_id, :sink_id], :unique => true, :name => 'unique_edge_index' - - - create_table :entrants, :force => true do |t| - t.string :name, :null => false - t.integer :course_id, :null => false - end - - create_table :events, :force => true do |t| - t.string :title, :limit => 5 - end - - create_table :funny_jokes, :force => true do |t| - t.string :name - end - - create_table :goofy_string_id, :force => true, :id => false do |t| - t.string :id, :null => false - t.string :info - end - - create_table :items, :force => true do |t| - t.column :name, :integer - end - - create_table :inept_wizards, :force => true do |t| - t.column :name, :string, :null => false - t.column :city, :string, :null => false - t.column :type, :string - end - - - create_table :jobs, :force => true do |t| - t.integer :ideal_reference_id - end - - create_table :keyboards, :force => true, :id => false do |t| - t.primary_key :key_number - t.string :name - end - - create_table :legacy_things, :force => true do |t| - t.integer :tps_report_number - t.integer :version, :null => false, :default => 0 - end - - create_table :lock_without_defaults, :force => true do |t| - t.column :lock_version, :integer - end - - create_table :lock_without_defaults_cust, :force => true do |t| - t.column :custom_lock_version, :integer - end - - create_table :mateys, :id => false, :force => true do |t| - t.column :pirate_id, :integer - t.column :target_id, :integer - t.column :weight, :integer - end - - create_table :members, :force => true do |t| - t.string :name - t.integer :member_type_id - end - - create_table :member_details, :force => true do |t| - t.integer :member_id - t.integer :organization_id - t.string :extra_data - end - - create_table :memberships, :force => true do |t| - t.datetime :joined_on - t.integer :club_id, :member_id - t.boolean :favourite, :default => false - t.string :type - end - - create_table :member_types, :force => true do |t| - t.string :name - end - - create_table :references, :force => true do |t| - t.integer :person_id - t.integer :job_id - t.boolean :favourite - t.integer :lock_version, :default => 0 - end - - create_table :minimalistics, :force => true do |t| - end - - create_table :mixed_case_monkeys, :force => true, :id => false do |t| - t.primary_key :monkeyID - t.integer :fleaCount - end - - create_table :mixins, :force => true do |t| - t.integer :parent_id - t.integer :pos - t.datetime :created_at - t.datetime :updated_at - t.integer :lft - t.integer :rgt - t.integer :root_id - t.string :type - end - - create_table :movies, :force => true, :id => false do |t| - t.primary_key :movieid - t.string :name - end - - create_table :numeric_data, :force => true do |t| - t.decimal :bank_balance, :precision => 10, :scale => 2 - t.decimal :big_bank_balance, :precision => 15, :scale => 2 - t.decimal :world_population, :precision => 10, :scale => 0 - t.decimal :my_house_population, :precision => 2, :scale => 0 - t.decimal :decimal_number_with_default, :precision => 3, :scale => 2, :default => 2.78 - t.float :temperature - end - - create_table :orders, :force => true do |t| - t.string :name - t.integer :billing_customer_id - t.integer :shipping_customer_id - end - - create_table :organizations, :force => true do |t| - t.string :name - end - - create_table :owners, :primary_key => :owner_id ,:force => true do |t| - t.string :name - end - - - create_table :paint_colors, :force => true do |t| - t.integer :non_poly_one_id - end - - create_table :paint_textures, :force => true do |t| - t.integer :non_poly_two_id - end - - create_table :parrots, :force => true do |t| - t.column :name, :string - t.column :parrot_sti_class, :string - t.column :killer_id, :integer - t.column :created_at, :datetime - t.column :created_on, :datetime - t.column :updated_at, :datetime - t.column :updated_on, :datetime - end - - create_table :parrots_pirates, :id => false, :force => true do |t| - t.column :parrot_id, :integer - t.column :pirate_id, :integer - end - - create_table :parrots_treasures, :id => false, :force => true do |t| - t.column :parrot_id, :integer - t.column :treasure_id, :integer - end - - create_table :people, :force => true do |t| - t.string :first_name, :null => false - t.references :primary_contact - t.string :gender, :limit => 1 - t.integer :lock_version, :null => false, :default => 0 - end - - create_table :pets, :primary_key => :pet_id ,:force => true do |t| - t.string :name - t.integer :owner_id, :integer - end - - create_table :pirates, :force => true do |t| - t.column :catchphrase, :string - t.column :parrot_id, :integer - t.column :created_on, :datetime - t.column :updated_on, :datetime - end - - create_table :posts, :force => true do |t| - t.integer :author_id - t.string :title, :null => false - t.text :body, :null => false - t.string :type - t.integer :comments_count, :default => 0 - t.integer :taggings_count, :default => 0 - end - - create_table :price_estimates, :force => true do |t| - t.string :estimate_of_type - t.integer :estimate_of_id - t.integer :price - end - - create_table :projects, :force => true do |t| - t.string :name - t.string :type - end - - create_table :readers, :force => true do |t| - t.integer :post_id, :null => false - t.integer :person_id, :null => false - end - - create_table :shape_expressions, :force => true do |t| - t.string :paint_type - t.integer :paint_id - t.string :shape_type - t.integer :shape_id - end - - create_table :ships, :force => true do |t| - t.string :name - t.integer :pirate_id - t.datetime :created_at - t.datetime :created_on - t.datetime :updated_at - t.datetime :updated_on - end - - create_table :ship_parts, :force => true do |t| - t.string :name - t.integer :ship_id - end - - create_table :sponsors, :force => true do |t| - t.integer :club_id - t.integer :sponsorable_id - t.string :sponsorable_type - end - - create_table :subscribers, :force => true, :id => false do |t| - t.string :nick, :null => false - t.string :name - end - add_index :subscribers, :nick, :unique => true - - create_table :subscriptions, :force => true do |t| - t.string :subscriber_id - t.integer :book_id - end - - create_table :tasks, :force => true do |t| - t.datetime :starting - t.datetime :ending - end - - create_table :topics, :force => true do |t| - t.string :title - t.string :author_name - t.string :author_email_address - t.datetime :written_on - t.time :bonus_time - t.date :last_read - t.text :content - t.boolean :approved, :default => true - t.integer :replies_count, :default => 0 - t.integer :parent_id - t.string :type - end - - create_table :taggings, :force => true do |t| - t.column :tag_id, :integer - t.column :super_tag_id, :integer - t.column :taggable_type, :string - t.column :taggable_id, :integer - end - - create_table :tags, :force => true do |t| - t.column :name, :string - t.column :taggings_count, :integer, :default => 0 - end - - create_table :toys, :primary_key => :toy_id ,:force => true do |t| - t.string :name - t.integer :pet_id, :integer - end - - create_table :treasures, :force => true do |t| - t.column :name, :string - t.column :looter_id, :integer - t.column :looter_type, :string - end - - create_table :vertices, :force => true do |t| - t.column :label, :string - end - - create_table 'warehouse-things', :force => true do |t| - t.integer :value - end - - [:circles, :squares, :triangles, :non_poly_ones, :non_poly_twos].each do |t| - create_table(t, :force => true) { } - end - - create_table :guids, :force => true do |t| - t.column :key, :string - end - - create_table :integer_limits, :force => true do |t| - t.integer :"c_int_without_limit" - (1..8).each do |i| - t.integer :"c_int_#{i}", :limit => i - end - end - - except 'SQLite' do - # fk_test_has_fk should be before fk_test_has_pk - create_table :fk_test_has_fk, :force => true do |t| - t.integer :fk_id, :null => false - end - - create_table :fk_test_has_pk, :force => true do |t| - end - - execute "ALTER TABLE fk_test_has_fk ADD CONSTRAINT fk_name FOREIGN KEY (#{quote_column_name 'fk_id'}) REFERENCES #{quote_table_name 'fk_test_has_pk'} (#{quote_column_name 'id'})" - end -end diff --git a/vendor/rails/activerecord/test/schema/schema2.rb b/vendor/rails/activerecord/test/schema/schema2.rb deleted file mode 100644 index 8527f7b..0000000 --- a/vendor/rails/activerecord/test/schema/schema2.rb +++ /dev/null @@ -1,6 +0,0 @@ -ActiveRecord::Schema.define do - - Course.connection.create_table :courses, :force => true do |t| - t.column :name, :string, :null => false - end -end diff --git a/vendor/rails/activerecord/test/schema/sqlite_specific_schema.rb b/vendor/rails/activerecord/test/schema/sqlite_specific_schema.rb deleted file mode 100644 index ea05b35..0000000 --- a/vendor/rails/activerecord/test/schema/sqlite_specific_schema.rb +++ /dev/null @@ -1,25 +0,0 @@ -ActiveRecord::Schema.define do - # For sqlite 3.1.0+, make a table with a autoincrement column - if supports_autoincrement? - create_table :table_with_autoincrement, :force => true do |t| - t.column :name, :string - end - end - - execute "DROP TABLE fk_test_has_fk" rescue nil - execute "DROP TABLE fk_test_has_pk" rescue nil - execute <<_SQL - CREATE TABLE 'fk_test_has_pk' ( - 'id' INTEGER NOT NULL PRIMARY KEY - ); -_SQL - - execute <<_SQL - CREATE TABLE 'fk_test_has_fk' ( - 'id' INTEGER NOT NULL PRIMARY KEY, - 'fk_id' INTEGER NOT NULL, - - FOREIGN KEY ('fk_id') REFERENCES 'fk_test_has_pk'('id') - ); -_SQL -end \ No newline at end of file diff --git a/vendor/rails/activeresource/CHANGELOG b/vendor/rails/activeresource/CHANGELOG deleted file mode 100644 index 6572934..0000000 --- a/vendor/rails/activeresource/CHANGELOG +++ /dev/null @@ -1,267 +0,0 @@ -*2.3.2 [Final] (March 15, 2009)* - -* Nothing new, just included in 2.3.2 - - -*2.2.1 [RC2] (November 14th, 2008)* - -* Fixed that ActiveResource#post would post an empty string when it shouldn't be posting anything #525 [Paolo Angelini] - - -*2.2.0 [RC1] (October 24th, 2008)* - -* Add ActiveResource::Base#to_xml and ActiveResource::Base#to_json. #1011 [Rasik Pandey, Cody Fauser] - -* Add ActiveResource::Base.find(:last). [#754 state:resolved] (Adrian Mugnolo) - -* Fixed problems with the logger used if the logging string included %'s [#840 state:resolved] (Jamis Buck) - -* Fixed Base#exists? to check status code as integer [#299 state:resolved] (Wes Oldenbeuving) - - -*2.1.0 (May 31st, 2008)* - -* Fixed response logging to use length instead of the entire thing (seangeo) [#27] - -* Fixed that to_param should be used and honored instead of hardcoding the id #11406 [gspiers] - -* Improve documentation. [Ryan Bigg, Jan De Poorter, Cheah Chu Yeow, Xavier Shay, Jack Danger Canty, Emilio Tagua, Xavier Noria, Sunny Ripert] - -* Use HEAD instead of GET in exists? [bscofield] - -* Fix small documentation typo. Closes #10670 [Luca Guidi] - -* find_or_create_resource_for handles module nesting. #10646 [xavier] - -* Allow setting ActiveResource::Base#format before #site. [Rick Olson] - -* Support agnostic formats when calling custom methods. Closes #10635 [joerichsen] - -* Document custom methods. #10589 [Cheah Chu Yeow] - -* Ruby 1.9 compatibility. [Jeremy Kemper] - - -*2.0.2* (December 16th, 2007) - -* Added more specific exceptions for 400, 401, and 403 (all descending from ClientError so existing rescues will work) #10326 [trek] - -* Correct empty response handling. #10445 [seangeo] - - -*2.0.1* (December 7th, 2007) - -* Don't cache net/http object so that ActiveResource is more thread-safe. Closes #10142 [kou] - -* Update XML documentation examples to include explicit type attributes. Closes #9754 [Josh Susser] - -* Added one-off declarations of mock behavior [David Heinemeier Hansson]. Example: - - Before: - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1.xml", {}, "<person><name>David</name></person>" - end - - Now: - ActiveResource::HttpMock.respond_to.get "/people/1.xml", {}, "<person><name>David</name></person>" - -* Added ActiveResource.format= which defaults to :xml but can also be set to :json [David Heinemeier Hansson]. Example: - - class Person < ActiveResource::Base - self.site = "http://app/" - self.format = :json - end - - person = Person.find(1) # => GET http://app/people/1.json - person.name = "David" - person.save # => PUT http://app/people/1.json {name: "David"} - - Person.format = :xml - person.name = "Mary" - person.save # => PUT http://app/people/1.json <person><name>Mary</name></person> - -* Fix reload error when path prefix is used. #8727 [Ian Warshak] - -* Remove ActiveResource::Struct because it hasn't proven very useful. Creating a new ActiveResource::Base subclass is often less code and always clearer. #8612 [Josh Peek] - -* Fix query methods on resources. [Cody Fauser] - -* pass the prefix_options to the instantiated record when using find without a specific id. Closes #8544 [Eloy Duran] - -* Recognize and raise an exception on 405 Method Not Allowed responses. #7692 [Josh Peek] - -* Handle string and symbol param keys when splitting params into prefix params and query params. - - Comment.find(:all, :params => { :article_id => 5, :page => 2 }) or Comment.find(:all, :params => { 'article_id' => 5, :page => 2 }) - -* Added find-one with symbol [David Heinemeier Hansson]. Example: Person.find(:one, :from => :leader) # => GET /people/leader.xml - -* BACKWARDS INCOMPATIBLE: Changed the finder API to be more extensible with :params and more strict usage of scopes [David Heinemeier Hansson]. Changes: - - Person.find(:all, :title => "CEO") ...becomes: Person.find(:all, :params => { :title => "CEO" }) - Person.find(:managers) ...becomes: Person.find(:all, :from => :managers) - Person.find("/companies/1/manager.xml") ...becomes: Person.find(:one, :from => "/companies/1/manager.xml") - -* Add support for setting custom headers per Active Resource model [Rick Olson] - - class Project - headers['X-Token'] = 'foo' - end - - # makes the GET request with the custom X-Token header - Project.find(:all) - -* Added find-by-path options to ActiveResource::Base.find [David Heinemeier Hansson]. Examples: - - employees = Person.find(:all, :from => "/companies/1/people.xml") # => GET /companies/1/people.xml - manager = Person.find("/companies/1/manager.xml") # => GET /companies/1/manager.xml - - -* Added support for using classes from within a single nested module [David Heinemeier Hansson]. Example: - - module Highrise - class Note < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" - end - - class Comment < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" - end - end - - assert_kind_of Highrise::Comment, Note.find(1).comments.first - - -* Added load_attributes_from_response as a way of loading attributes from other responses than just create [David Heinemeier Hansson] - - class Highrise::Task < ActiveResource::Base - def complete - load_attributes_from_response(post(:complete)) - end - end - - ...will set "done_at" when complete is called. - - -* Added support for calling custom methods #6979 [rwdaigle] - - Person.find(:managers) # => GET /people/managers.xml - Kase.find(1).post(:close) # => POST /kases/1/close.xml - -* Remove explicit prefix_options parameter for ActiveResource::Base#initialize. [Rick Olson] - ActiveResource splits the prefix_options from it automatically. - -* Allow ActiveResource::Base.delete with custom prefix. [Rick Olson] - -* Add ActiveResource::Base#dup [Rick Olson] - -* Fixed constant warning when fetching the same object multiple times [David Heinemeier Hansson] - -* Added that saves which get a body response (and not just a 201) will use that response to update themselves [David Heinemeier Hansson] - -* Disregard namespaces from the default element name, so Highrise::Person will just try to fetch from "/people", not "/highrise/people" [David Heinemeier Hansson] - -* Allow array and hash query parameters. #7756 [Greg Spurrier] - -* Loading a resource preserves its prefix_options. #7353 [Ryan Daigle] - -* Carry over the convenience of #create from ActiveRecord. Closes #7340. [Ryan Daigle] - -* Increase ActiveResource::Base test coverage. Closes #7173, #7174 [Rich Collins] - -* Interpret 422 Unprocessable Entity as ResourceInvalid. #7097 [dkubb] - -* Mega documentation patches. #7025, #7069 [rwdaigle] - -* Base.exists?(id, options) and Base#exists? check whether the resource is found. #6970 [rwdaigle] - -* Query string support. [untext, Jeremy Kemper] - # GET /forums/1/topics.xml?sort=created_at - Topic.find(:all, :forum_id => 1, :sort => 'created_at') - -* Base#==, eql?, and hash methods. == returns true if its argument is identical to self or if it's an instance of the same class, is not new?, and has the same id. eql? is an alias for ==. hash delegates to id. [Jeremy Kemper] - -* Allow subclassed resources to share the site info [Rick Olson, Jeremy Kemper] -d - class BeastResource < ActiveResource::Base - self.site = 'http://beast.caboo.se' - end - - class Forum < BeastResource - # taken from BeastResource - # self.site = 'http://beast.caboo.se' - end - - class Topic < BeastResource - self.site += '/forums/:forum_id' - end - -* Fix issues with ActiveResource collection handling. Closes #6291. [bmilekic] - -* Use attr_accessor_with_default to dry up attribute initialization. References #6538. [Stuart Halloway] - -* Add basic logging support for logging outgoing requests. [Jamis Buck] - -* Add Base.delete for deleting resources without having to instantiate them first. [Jamis Buck] - -* Make #save behavior mimic AR::Base#save (true on success, false on failure). [Jamis Buck] - -* Add Basic HTTP Authentication to ActiveResource (closes #6305). [jonathan] - -* Extracted #id_from_response as an entry point for customizing how a created resource gets its own ID. - By default, it extracts from the Location response header. - -* Optimistic locking: raise ActiveResource::ResourceConflict on 409 Conflict response. [Jeremy Kemper] - - # Example controller action - def update - @person.save! - rescue ActiveRecord::StaleObjectError - render :xml => @person.reload.to_xml, :status => '409 Conflict' - end - -* Basic validation support [Rick Olson] - - Parses the xml response of ActiveRecord::Errors#to_xml with a similar interface to ActiveRecord::Errors. - - render :xml => @person.errors.to_xml, :status => '400 Validation Error' - -* Deep hashes are converted into collections of resources. [Jeremy Kemper] - Person.new :name => 'Bob', - :address => { :id => 1, :city => 'Portland' }, - :contacts => [{ :id => 1 }, { :id => 2 }] - Looks for Address and Contact resources and creates them if unavailable. - So clients can fetch a complex resource in a single request if you e.g. - render :xml => @person.to_xml(:include => [:address, :contacts]) - in your controller action. - -* Major updates [Rick Olson] - - * Add full support for find/create/update/destroy - * Add support for specifying prefixes. - * Allow overriding of element_name, collection_name, and primary key - * Provide simpler HTTP mock interface for testing - - # rails routing code - map.resources :posts do |post| - post.resources :comments - end - - # ActiveResources - class Post < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000/" - end - - class Comment < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000/posts/:post_id/" - end - - @post = Post.find 5 - @comments = Comment.find :all, :post_id => @post.id - - @comment = Comment.new({:body => 'hello world'}, {:post_id => @post.id}) - @comment.save - -* Base.site= accepts URIs. 200...400 are valid response codes. PUT and POST request bodies default to ''. [Jeremy Kemper] - -* Initial checkin: object-oriented client for restful HTTP resources which follow the Rails convention. [David Heinemeier Hansson] diff --git a/vendor/rails/activeresource/README b/vendor/rails/activeresource/README deleted file mode 100644 index 924017a..0000000 --- a/vendor/rails/activeresource/README +++ /dev/null @@ -1,165 +0,0 @@ -= Active Resource - -Active Resource (ARes) connects business objects and Representational State Transfer (REST) -web services. It implements object-relational mapping for REST webservices to provide transparent -proxying capabilities between a client (ActiveResource) and a RESTful service (which is provided by Simply RESTful routing -in ActionController::Resources). - -== Philosophy - -Active Resource attempts to provide a coherent wrapper object-relational mapping for REST -web services. It follows the same philosophy as Active Record, in that one of its prime aims -is to reduce the amount of code needed to map to these resources. This is made possible -by relying on a number of code- and protocol-based conventions that make it easy for Active Resource -to infer complex relations and structures. These conventions are outlined in detail in the documentation -for ActiveResource::Base. - -== Overview - -Model classes are mapped to remote REST resources by Active Resource much the same way Active Record maps model classes to database -tables. When a request is made to a remote resource, a REST XML request is generated, transmitted, and the result -received and serialized into a usable Ruby object. - -=== Configuration and Usage - -Putting ActiveResource to use is very similar to ActiveRecord. It's as simple as creating a model class -that inherits from ActiveResource::Base and providing a <tt>site</tt> class variable to it: - - class Person < ActiveResource::Base - self.site = "http://api.people.com:3000/" - end - -Now the Person class is REST enabled and can invoke REST services very similarly to how ActiveRecord invokes -lifecycle methods that operate against a persistent store. - - # Find a person with id = 1 - ryan = Person.find(1) - Person.exists?(1) #=> true - -As you can see, the methods are quite similar to Active Record's methods for dealing with database -records. But rather than dealing directly with a database record, you're dealing with HTTP resources (which may or may not be database records). - -==== Protocol - -Active Resource is built on a standard XML format for requesting and submitting resources over HTTP. It mirrors the RESTful routing -built into ActionController but will also work with any other REST service that properly implements the protocol. -REST uses HTTP, but unlike "typical" web applications, it makes use of all the verbs available in the HTTP specification: - -* GET requests are used for finding and retrieving resources. -* POST requests are used to create new resources. -* PUT requests are used to update existing resources. -* DELETE requests are used to delete resources. - -For more information on how this protocol works with Active Resource, see the ActiveResource::Base documentation; -for more general information on REST web services, see the article here[http://en.wikipedia.org/wiki/Representational_State_Transfer]. - -==== Find - -GET Http requests expect the XML form of whatever resource/resources is/are being requested. So, -for a request for a single element - the XML of that item is expected in response: - - # Expects a response of - # - # <person><id type="integer">1</id><attribute1>value1</attribute1><attribute2>..</attribute2></person> - # - # for GET http://api.people.com:3000/people/1.xml - # - ryan = Person.find(1) - -The XML document that is received is used to build a new object of type Person, with each -XML element becoming an attribute on the object. - - ryan.is_a? Person #=> true - ryan.attribute1 #=> 'value1' - -Any complex element (one that contains other elements) becomes its own object: - - # With this response: - # - # <person><id>1</id><attribute1>value1</attribute1><complex><attribute2>value2</attribute2></complex></person> - # - # for GET http://api.people.com:3000/people/1.xml - # - ryan = Person.find(1) - ryan.complex #=> <Person::Complex::xxxxx> - ryan.complex.attribute2 #=> 'value2' - -Collections can also be requested in a similar fashion - - # Expects a response of - # - # <people type="array"> - # <person><id type="integer">1</id><first>Ryan</first></person> - # <person><id type="integer">2</id><first>Jim</first></person> - # </people> - # - # for GET http://api.people.com:3000/people.xml - # - people = Person.find(:all) - people.first #=> <Person::xxx 'first' => 'Ryan' ...> - people.last #=> <Person::xxx 'first' => 'Jim' ...> - -==== Create - -Creating a new resource submits the xml form of the resource as the body of the request and expects -a 'Location' header in the response with the RESTful URL location of the newly created resource. The -id of the newly created resource is parsed out of the Location response header and automatically set -as the id of the ARes object. - - # <person><first>Ryan</first></person> - # - # is submitted as the body on - # - # POST http://api.people.com:3000/people.xml - # - # when save is called on a new Person object. An empty response is - # is expected with a 'Location' header value: - # - # Response (201): Location: http://api.people.com:3000/people/2 - # - ryan = Person.new(:first => 'Ryan') - ryan.new? #=> true - ryan.save #=> true - ryan.new? #=> false - ryan.id #=> 2 - -==== Update - -'save' is also used to update an existing resource - and follows the same protocol as creating a resource -with the exception that no response headers are needed - just an empty response when the update on the -server side was successful. - - # <person><first>Ryan</first></person> - # - # is submitted as the body on - # - # PUT http://api.people.com:3000/people/1.xml - # - # when save is called on an existing Person object. An empty response is - # is expected with code (204) - # - ryan = Person.find(1) - ryan.first #=> 'Ryan' - ryan.first = 'Rizzle' - ryan.save #=> true - -==== Delete - -Destruction of a resource can be invoked as a class and instance method of the resource. - - # A request is made to - # - # DELETE http://api.people.com:3000/people/1.xml - # - # for both of these forms. An empty response with - # is expected with response code (200) - # - ryan = Person.find(1) - ryan.destroy #=> true - ryan.exists? #=> false - Person.delete(2) #=> true - Person.exists?(2) #=> false - - -You can find more usage information in the ActiveResource::Base documentation. - diff --git a/vendor/rails/activeresource/Rakefile b/vendor/rails/activeresource/Rakefile deleted file mode 100644 index bf7bbb0..0000000 --- a/vendor/rails/activeresource/Rakefile +++ /dev/null @@ -1,138 +0,0 @@ -require 'rubygems' -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' -require 'rake/packagetask' -require 'rake/gempackagetask' -require 'rake/contrib/sshpublisher' - -require File.join(File.dirname(__FILE__), 'lib', 'active_resource', 'version') - -PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' -PKG_NAME = 'activeresource' -PKG_VERSION = ActiveResource::VERSION::STRING + PKG_BUILD -PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" - -RELEASE_NAME = "REL #{PKG_VERSION}" - -RUBY_FORGE_PROJECT = "activerecord" -RUBY_FORGE_USER = "webster132" - -PKG_FILES = FileList[ - "lib/**/*", "test/**/*", "[A-Z]*", "Rakefile" -].exclude(/\bCVS\b|~$/) - -desc "Default Task" -task :default => [ :test ] - -# Run the unit tests - -Rake::TestTask.new { |t| - activesupport_path = "#{File.dirname(__FILE__)}/../activesupport/lib" - t.libs << activesupport_path if File.directory?(activesupport_path) - t.libs << "test" - t.pattern = 'test/**/*_test.rb' - t.verbose = true - t.warning = true -} - - -# Generate the RDoc documentation - -Rake::RDocTask.new { |rdoc| - rdoc.rdoc_dir = 'doc' - rdoc.title = "Active Resource -- Object-oriented REST services" - rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object' - rdoc.options << '--charset' << 'utf-8' - rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo' - rdoc.rdoc_files.include('README', 'CHANGELOG') - rdoc.rdoc_files.include('lib/**/*.rb') - rdoc.rdoc_files.exclude('lib/activeresource.rb') -} - - -# Create compressed packages - -dist_dirs = [ "lib", "test", "examples", "dev-utils" ] - -spec = Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = PKG_NAME - s.version = PKG_VERSION - s.summary = "Think Active Record for web resources." - s.description = %q{Wraps web resources in model classes that can be manipulated through XML over REST.} - - s.files = [ "Rakefile", "README", "CHANGELOG" ] - dist_dirs.each do |dir| - s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) } - end - - s.add_dependency('activesupport', '= 2.3.2' + PKG_BUILD) - - s.require_path = 'lib' - s.autorequire = 'active_resource' - - s.has_rdoc = true - s.extra_rdoc_files = %w( README ) - s.rdoc_options.concat ['--main', 'README'] - - s.author = "David Heinemeier Hansson" - s.email = "david@loudthinking.com" - s.homepage = "http://www.rubyonrails.org" - s.rubyforge_project = "activeresource" -end - -Rake::GemPackageTask.new(spec) do |p| - p.gem_spec = spec - p.need_tar = true - p.need_zip = true -end - -task :lines do - lines, codelines, total_lines, total_codelines = 0, 0, 0, 0 - - for file_name in FileList["lib/active_resource/**/*.rb"] - next if file_name =~ /vendor/ - f = File.open(file_name) - - while line = f.gets - lines += 1 - next if line =~ /^\s*$/ - next if line =~ /^\s*#/ - codelines += 1 - end - puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}" - - total_lines += lines - total_codelines += codelines - - lines, codelines = 0, 0 - end - - puts "Total: Lines #{total_lines}, LOC #{total_codelines}" -end - - -# Publishing ------------------------------------------------------ - -desc "Publish the beta gem" -task :pgem => [:package] do - Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload - `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'` -end - -desc "Publish the API documentation" -task :pdoc => [:rdoc] do - Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ar", "doc").upload -end - -desc "Publish the release files to RubyForge." -task :release => [ :package ] do - `rubyforge login` - - for ext in %w( gem tgz zip ) - release_command = "rubyforge add_release #{PKG_NAME} #{PKG_NAME} 'REL #{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" - puts release_command - system(release_command) - end -end diff --git a/vendor/rails/activeresource/lib/active_resource.rb b/vendor/rails/activeresource/lib/active_resource.rb deleted file mode 100644 index db90070..0000000 --- a/vendor/rails/activeresource/lib/active_resource.rb +++ /dev/null @@ -1,44 +0,0 @@ -#-- -# Copyright (c) 2006 David Heinemeier Hansson -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ - -begin - require 'active_support' -rescue LoadError - activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib" - if File.directory?(activesupport_path) - $:.unshift activesupport_path - require 'active_support' - end -end - -require 'active_resource/formats' -require 'active_resource/base' -require 'active_resource/validations' -require 'active_resource/custom_methods' - -module ActiveResource - Base.class_eval do - include Validations - include CustomMethods - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/base.rb b/vendor/rails/activeresource/lib/active_resource/base.rb deleted file mode 100644 index a8c0da3..0000000 --- a/vendor/rails/activeresource/lib/active_resource/base.rb +++ /dev/null @@ -1,1077 +0,0 @@ -require 'active_resource/connection' -require 'cgi' -require 'set' - -module ActiveResource - # ActiveResource::Base is the main class for mapping RESTful resources as models in a Rails application. - # - # For an outline of what Active Resource is capable of, see link:files/vendor/rails/activeresource/README.html. - # - # == Automated mapping - # - # Active Resource objects represent your RESTful resources as manipulatable Ruby objects. To map resources - # to Ruby objects, Active Resource only needs a class name that corresponds to the resource name (e.g., the class - # Person maps to the resources people, very similarly to Active Record) and a +site+ value, which holds the - # URI of the resources. - # - # class Person < ActiveResource::Base - # self.site = "http://api.people.com:3000/" - # end - # - # Now the Person class is mapped to RESTful resources located at <tt>http://api.people.com:3000/people/</tt>, and - # you can now use Active Resource's lifecycles methods to manipulate resources. In the case where you already have - # an existing model with the same name as the desired RESTful resource you can set the +element_name+ value. - # - # class PersonResource < ActiveResource::Base - # self.site = "http://api.people.com:3000/" - # self.element_name = "person" - # end - # - # - # == Lifecycle methods - # - # Active Resource exposes methods for creating, finding, updating, and deleting resources - # from REST web services. - # - # ryan = Person.new(:first => 'Ryan', :last => 'Daigle') - # ryan.save # => true - # ryan.id # => 2 - # Person.exists?(ryan.id) # => true - # ryan.exists? # => true - # - # ryan = Person.find(1) - # # Resource holding our newly created Person object - # - # ryan.first = 'Rizzle' - # ryan.save # => true - # - # ryan.destroy # => true - # - # As you can see, these are very similar to Active Record's lifecycle methods for database records. - # You can read more about each of these methods in their respective documentation. - # - # === Custom REST methods - # - # Since simple CRUD/lifecycle methods can't accomplish every task, Active Resource also supports - # defining your own custom REST methods. To invoke them, Active Resource provides the <tt>get</tt>, - # <tt>post</tt>, <tt>put</tt> and <tt>\delete</tt> methods where you can specify a custom REST method - # name to invoke. - # - # # POST to the custom 'register' REST method, i.e. POST /people/new/register.xml. - # Person.new(:name => 'Ryan').post(:register) - # # => { :id => 1, :name => 'Ryan', :position => 'Clerk' } - # - # # PUT an update by invoking the 'promote' REST method, i.e. PUT /people/1/promote.xml?position=Manager. - # Person.find(1).put(:promote, :position => 'Manager') - # # => { :id => 1, :name => 'Ryan', :position => 'Manager' } - # - # # GET all the positions available, i.e. GET /people/positions.xml. - # Person.get(:positions) - # # => [{:name => 'Manager'}, {:name => 'Clerk'}] - # - # # DELETE to 'fire' a person, i.e. DELETE /people/1/fire.xml. - # Person.find(1).delete(:fire) - # - # For more information on using custom REST methods, see the - # ActiveResource::CustomMethods documentation. - # - # == Validations - # - # You can validate resources client side by overriding validation methods in the base class. - # - # class Person < ActiveResource::Base - # self.site = "http://api.people.com:3000/" - # protected - # def validate - # errors.add("last", "has invalid characters") unless last =~ /[a-zA-Z]*/ - # end - # end - # - # See the ActiveResource::Validations documentation for more information. - # - # == Authentication - # - # Many REST APIs will require authentication, usually in the form of basic - # HTTP authentication. Authentication can be specified by: - # * putting the credentials in the URL for the +site+ variable. - # - # class Person < ActiveResource::Base - # self.site = "http://ryan:password@api.people.com:3000/" - # end - # - # * defining +user+ and/or +password+ variables - # - # class Person < ActiveResource::Base - # self.site = "http://api.people.com:3000/" - # self.user = "ryan" - # self.password = "password" - # end - # - # For obvious security reasons, it is probably best if such services are available - # over HTTPS. - # - # Note: Some values cannot be provided in the URL passed to site. e.g. email addresses - # as usernames. In those situations you should use the separate user and password option. - # == Errors & Validation - # - # Error handling and validation is handled in much the same manner as you're used to seeing in - # Active Record. Both the response code in the HTTP response and the body of the response are used to - # indicate that an error occurred. - # - # === Resource errors - # - # When a GET is requested for a resource that does not exist, the HTTP <tt>404</tt> (Resource Not Found) - # response code will be returned from the server which will raise an ActiveResource::ResourceNotFound - # exception. - # - # # GET http://api.people.com:3000/people/999.xml - # ryan = Person.find(999) # 404, raises ActiveResource::ResourceNotFound - # - # <tt>404</tt> is just one of the HTTP error response codes that Active Resource will handle with its own exception. The - # following HTTP response codes will also result in these exceptions: - # - # * 200..399 - Valid response, no exception (other than 301, 302) - # * 301, 302 - ActiveResource::Redirection - # * 400 - ActiveResource::BadRequest - # * 401 - ActiveResource::UnauthorizedAccess - # * 403 - ActiveResource::ForbiddenAccess - # * 404 - ActiveResource::ResourceNotFound - # * 405 - ActiveResource::MethodNotAllowed - # * 409 - ActiveResource::ResourceConflict - # * 422 - ActiveResource::ResourceInvalid (rescued by save as validation errors) - # * 401..499 - ActiveResource::ClientError - # * 500..599 - ActiveResource::ServerError - # * Other - ActiveResource::ConnectionError - # - # These custom exceptions allow you to deal with resource errors more naturally and with more precision - # rather than returning a general HTTP error. For example: - # - # begin - # ryan = Person.find(my_id) - # rescue ActiveResource::ResourceNotFound - # redirect_to :action => 'not_found' - # rescue ActiveResource::ResourceConflict, ActiveResource::ResourceInvalid - # redirect_to :action => 'new' - # end - # - # === Validation errors - # - # Active Resource supports validations on resources and will return errors if any these validations fail - # (e.g., "First name can not be blank" and so on). These types of errors are denoted in the response by - # a response code of <tt>422</tt> and an XML representation of the validation errors. The save operation will - # then fail (with a <tt>false</tt> return value) and the validation errors can be accessed on the resource in question. - # - # ryan = Person.find(1) - # ryan.first # => '' - # ryan.save # => false - # - # # When - # # PUT http://api.people.com:3000/people/1.xml - # # is requested with invalid values, the response is: - # # - # # Response (422): - # # <errors type="array"><error>First cannot be empty</error></errors> - # # - # - # ryan.errors.invalid?(:first) # => true - # ryan.errors.full_messages # => ['First cannot be empty'] - # - # Learn more about Active Resource's validation features in the ActiveResource::Validations documentation. - # - # === Timeouts - # - # Active Resource relies on HTTP to access RESTful APIs and as such is inherently susceptible to slow or - # unresponsive servers. In such cases, your Active Resource method calls could \timeout. You can control the - # amount of time before Active Resource times out with the +timeout+ variable. - # - # class Person < ActiveResource::Base - # self.site = "http://api.people.com:3000/" - # self.timeout = 5 - # end - # - # This sets the +timeout+ to 5 seconds. You can adjust the +timeout+ to a value suitable for the RESTful API - # you are accessing. It is recommended to set this to a reasonably low value to allow your Active Resource - # clients (especially if you are using Active Resource in a Rails application) to fail-fast (see - # http://en.wikipedia.org/wiki/Fail-fast) rather than cause cascading failures that could incapacitate your - # server. - # - # When a \timeout occurs, an ActiveResource::TimeoutError is raised. You should rescue from - # ActiveResource::TimeoutError in your Active Resource method calls. - # - # Internally, Active Resource relies on Ruby's Net::HTTP library to make HTTP requests. Setting +timeout+ - # sets the <tt>read_timeout</tt> of the internal Net::HTTP instance to the same value. The default - # <tt>read_timeout</tt> is 60 seconds on most Ruby implementations. - class Base - ## - # :singleton-method: - # The logger for diagnosing and tracing Active Resource calls. - cattr_accessor :logger - - class << self - # Gets the URI of the REST resources to map for this class. The site variable is required for - # Active Resource's mapping to work. - def site - # Not using superclass_delegating_reader because don't want subclasses to modify superclass instance - # - # With superclass_delegating_reader - # - # Parent.site = 'http://anonymous@test.com' - # Subclass.site # => 'http://anonymous@test.com' - # Subclass.site.user = 'david' - # Parent.site # => 'http://david@test.com' - # - # Without superclass_delegating_reader (expected behaviour) - # - # Parent.site = 'http://anonymous@test.com' - # Subclass.site # => 'http://anonymous@test.com' - # Subclass.site.user = 'david' # => TypeError: can't modify frozen object - # - if defined?(@site) - @site - elsif superclass != Object && superclass.site - superclass.site.dup.freeze - end - end - - # Sets the URI of the REST resources to map for this class to the value in the +site+ argument. - # The site variable is required for Active Resource's mapping to work. - def site=(site) - @connection = nil - if site.nil? - @site = nil - else - @site = create_site_uri_from(site) - @user = URI.decode(@site.user) if @site.user - @password = URI.decode(@site.password) if @site.password - end - end - - # Gets the \user for REST HTTP authentication. - def user - # Not using superclass_delegating_reader. See +site+ for explanation - if defined?(@user) - @user - elsif superclass != Object && superclass.user - superclass.user.dup.freeze - end - end - - # Sets the \user for REST HTTP authentication. - def user=(user) - @connection = nil - @user = user - end - - # Gets the \password for REST HTTP authentication. - def password - # Not using superclass_delegating_reader. See +site+ for explanation - if defined?(@password) - @password - elsif superclass != Object && superclass.password - superclass.password.dup.freeze - end - end - - # Sets the \password for REST HTTP authentication. - def password=(password) - @connection = nil - @password = password - end - - # Sets the format that attributes are sent and received in from a mime type reference: - # - # Person.format = :json - # Person.find(1) # => GET /people/1.json - # - # Person.format = ActiveResource::Formats::XmlFormat - # Person.find(1) # => GET /people/1.xml - # - # Default format is <tt>:xml</tt>. - def format=(mime_type_reference_or_format) - format = mime_type_reference_or_format.is_a?(Symbol) ? - ActiveResource::Formats[mime_type_reference_or_format] : mime_type_reference_or_format - - write_inheritable_attribute(:format, format) - connection.format = format if site - end - - # Returns the current format, default is ActiveResource::Formats::XmlFormat. - def format - read_inheritable_attribute(:format) || ActiveResource::Formats[:xml] - end - - # Sets the number of seconds after which requests to the REST API should time out. - def timeout=(timeout) - @connection = nil - @timeout = timeout - end - - # Gets the number of seconds after which requests to the REST API should time out. - def timeout - if defined?(@timeout) - @timeout - elsif superclass != Object && superclass.timeout - superclass.timeout - end - end - - # An instance of ActiveResource::Connection that is the base \connection to the remote service. - # The +refresh+ parameter toggles whether or not the \connection is refreshed at every request - # or not (defaults to <tt>false</tt>). - def connection(refresh = false) - if defined?(@connection) || superclass == Object - @connection = Connection.new(site, format) if refresh || @connection.nil? - @connection.user = user if user - @connection.password = password if password - @connection.timeout = timeout if timeout - @connection - else - superclass.connection - end - end - - def headers - @headers ||= {} - end - - # Do not include any modules in the default element name. This makes it easier to seclude ARes objects - # in a separate namespace without having to set element_name repeatedly. - attr_accessor_with_default(:element_name) { to_s.split("::").last.underscore } #:nodoc: - - attr_accessor_with_default(:collection_name) { element_name.pluralize } #:nodoc: - attr_accessor_with_default(:primary_key, 'id') #:nodoc: - - # Gets the \prefix for a resource's nested URL (e.g., <tt>prefix/collectionname/1.xml</tt>) - # This method is regenerated at runtime based on what the \prefix is set to. - def prefix(options={}) - default = site.path - default << '/' unless default[-1..-1] == '/' - # generate the actual method based on the current site path - self.prefix = default - prefix(options) - end - - # An attribute reader for the source string for the resource path \prefix. This - # method is regenerated at runtime based on what the \prefix is set to. - def prefix_source - prefix # generate #prefix and #prefix_source methods first - prefix_source - end - - # Sets the \prefix for a resource's nested URL (e.g., <tt>prefix/collectionname/1.xml</tt>). - # Default value is <tt>site.path</tt>. - def prefix=(value = '/') - # Replace :placeholders with '#{embedded options[:lookups]}' - prefix_call = value.gsub(/:\w+/) { |key| "\#{options[#{key}]}" } - - # Clear prefix parameters in case they have been cached - @prefix_parameters = nil - - # Redefine the new methods. - code = <<-end_code - def prefix_source() "#{value}" end - def prefix(options={}) "#{prefix_call}" end - end_code - silence_warnings { instance_eval code, __FILE__, __LINE__ } - rescue - logger.error "Couldn't set prefix: #{$!}\n #{code}" - raise - end - - alias_method :set_prefix, :prefix= #:nodoc: - - alias_method :set_element_name, :element_name= #:nodoc: - alias_method :set_collection_name, :collection_name= #:nodoc: - - # Gets the element path for the given ID in +id+. If the +query_options+ parameter is omitted, Rails - # will split from the \prefix options. - # - # ==== Options - # +prefix_options+ - A \hash to add a \prefix to the request for nested URLs (e.g., <tt>:account_id => 19</tt> - # would yield a URL like <tt>/accounts/19/purchases.xml</tt>). - # +query_options+ - A \hash to add items to the query string for the request. - # - # ==== Examples - # Post.element_path(1) - # # => /posts/1.xml - # - # Comment.element_path(1, :post_id => 5) - # # => /posts/5/comments/1.xml - # - # Comment.element_path(1, :post_id => 5, :active => 1) - # # => /posts/5/comments/1.xml?active=1 - # - # Comment.element_path(1, {:post_id => 5}, {:active => 1}) - # # => /posts/5/comments/1.xml?active=1 - # - def element_path(id, prefix_options = {}, query_options = nil) - prefix_options, query_options = split_options(prefix_options) if query_options.nil? - "#{prefix(prefix_options)}#{collection_name}/#{id}.#{format.extension}#{query_string(query_options)}" - end - - # Gets the collection path for the REST resources. If the +query_options+ parameter is omitted, Rails - # will split from the +prefix_options+. - # - # ==== Options - # * +prefix_options+ - A hash to add a prefix to the request for nested URL's (e.g., <tt>:account_id => 19</tt> - # would yield a URL like <tt>/accounts/19/purchases.xml</tt>). - # * +query_options+ - A hash to add items to the query string for the request. - # - # ==== Examples - # Post.collection_path - # # => /posts.xml - # - # Comment.collection_path(:post_id => 5) - # # => /posts/5/comments.xml - # - # Comment.collection_path(:post_id => 5, :active => 1) - # # => /posts/5/comments.xml?active=1 - # - # Comment.collection_path({:post_id => 5}, {:active => 1}) - # # => /posts/5/comments.xml?active=1 - # - def collection_path(prefix_options = {}, query_options = nil) - prefix_options, query_options = split_options(prefix_options) if query_options.nil? - "#{prefix(prefix_options)}#{collection_name}.#{format.extension}#{query_string(query_options)}" - end - - alias_method :set_primary_key, :primary_key= #:nodoc: - - # Creates a new resource instance and makes a request to the remote service - # that it be saved, making it equivalent to the following simultaneous calls: - # - # ryan = Person.new(:first => 'ryan') - # ryan.save - # - # Returns the newly created resource. If a failure has occurred an - # exception will be raised (see <tt>save</tt>). If the resource is invalid and - # has not been saved then <tt>valid?</tt> will return <tt>false</tt>, - # while <tt>new?</tt> will still return <tt>true</tt>. - # - # ==== Examples - # Person.create(:name => 'Jeremy', :email => 'myname@nospam.com', :enabled => true) - # my_person = Person.find(:first) - # my_person.email # => myname@nospam.com - # - # dhh = Person.create(:name => 'David', :email => 'dhh@nospam.com', :enabled => true) - # dhh.valid? # => true - # dhh.new? # => false - # - # # We'll assume that there's a validation that requires the name attribute - # that_guy = Person.create(:name => '', :email => 'thatguy@nospam.com', :enabled => true) - # that_guy.valid? # => false - # that_guy.new? # => true - def create(attributes = {}) - self.new(attributes).tap { |resource| resource.save } - end - - # Core method for finding resources. Used similarly to Active Record's +find+ method. - # - # ==== Arguments - # The first argument is considered to be the scope of the query. That is, how many - # resources are returned from the request. It can be one of the following. - # - # * <tt>:one</tt> - Returns a single resource. - # * <tt>:first</tt> - Returns the first resource found. - # * <tt>:last</tt> - Returns the last resource found. - # * <tt>:all</tt> - Returns every resource that matches the request. - # - # ==== Options - # - # * <tt>:from</tt> - Sets the path or custom method that resources will be fetched from. - # * <tt>:params</tt> - Sets query and \prefix (nested URL) parameters. - # - # ==== Examples - # Person.find(1) - # # => GET /people/1.xml - # - # Person.find(:all) - # # => GET /people.xml - # - # Person.find(:all, :params => { :title => "CEO" }) - # # => GET /people.xml?title=CEO - # - # Person.find(:first, :from => :managers) - # # => GET /people/managers.xml - # - # Person.find(:last, :from => :managers) - # # => GET /people/managers.xml - # - # Person.find(:all, :from => "/companies/1/people.xml") - # # => GET /companies/1/people.xml - # - # Person.find(:one, :from => :leader) - # # => GET /people/leader.xml - # - # Person.find(:all, :from => :developers, :params => { :language => 'ruby' }) - # # => GET /people/developers.xml?language=ruby - # - # Person.find(:one, :from => "/companies/1/manager.xml") - # # => GET /companies/1/manager.xml - # - # StreetAddress.find(1, :params => { :person_id => 1 }) - # # => GET /people/1/street_addresses/1.xml - def find(*arguments) - scope = arguments.slice!(0) - options = arguments.slice!(0) || {} - - case scope - when :all then find_every(options) - when :first then find_every(options).first - when :last then find_every(options).last - when :one then find_one(options) - else find_single(scope, options) - end - end - - # Deletes the resources with the ID in the +id+ parameter. - # - # ==== Options - # All options specify \prefix and query parameters. - # - # ==== Examples - # Event.delete(2) # sends DELETE /events/2 - # - # Event.create(:name => 'Free Concert', :location => 'Community Center') - # my_event = Event.find(:first) # let's assume this is event with ID 7 - # Event.delete(my_event.id) # sends DELETE /events/7 - # - # # Let's assume a request to events/5/cancel.xml - # Event.delete(params[:id]) # sends DELETE /events/5 - def delete(id, options = {}) - connection.delete(element_path(id, options)) - end - - # Asserts the existence of a resource, returning <tt>true</tt> if the resource is found. - # - # ==== Examples - # Note.create(:title => 'Hello, world.', :body => 'Nothing more for now...') - # Note.exists?(1) # => true - # - # Note.exists(1349) # => false - def exists?(id, options = {}) - if id - prefix_options, query_options = split_options(options[:params]) - path = element_path(id, prefix_options, query_options) - response = connection.head(path, headers) - response.code.to_i == 200 - end - # id && !find_single(id, options).nil? - rescue ActiveResource::ResourceNotFound - false - end - - private - # Find every resource - def find_every(options) - case from = options[:from] - when Symbol - instantiate_collection(get(from, options[:params])) - when String - path = "#{from}#{query_string(options[:params])}" - instantiate_collection(connection.get(path, headers) || []) - else - prefix_options, query_options = split_options(options[:params]) - path = collection_path(prefix_options, query_options) - instantiate_collection( (connection.get(path, headers) || []), prefix_options ) - end - end - - # Find a single resource from a one-off URL - def find_one(options) - case from = options[:from] - when Symbol - instantiate_record(get(from, options[:params])) - when String - path = "#{from}#{query_string(options[:params])}" - instantiate_record(connection.get(path, headers)) - end - end - - # Find a single resource from the default URL - def find_single(scope, options) - prefix_options, query_options = split_options(options[:params]) - path = element_path(scope, prefix_options, query_options) - instantiate_record(connection.get(path, headers), prefix_options) - end - - def instantiate_collection(collection, prefix_options = {}) - collection.collect! { |record| instantiate_record(record, prefix_options) } - end - - def instantiate_record(record, prefix_options = {}) - new(record).tap do |resource| - resource.prefix_options = prefix_options - end - end - - - # Accepts a URI and creates the site URI from that. - def create_site_uri_from(site) - site.is_a?(URI) ? site.dup : URI.parse(site) - end - - # contains a set of the current prefix parameters. - def prefix_parameters - @prefix_parameters ||= prefix_source.scan(/:\w+/).map { |key| key[1..-1].to_sym }.to_set - end - - # Builds the query string for the request. - def query_string(options) - "?#{options.to_query}" unless options.nil? || options.empty? - end - - # split an option hash into two hashes, one containing the prefix options, - # and the other containing the leftovers. - def split_options(options = {}) - prefix_options, query_options = {}, {} - - (options || {}).each do |key, value| - next if key.blank? - (prefix_parameters.include?(key.to_sym) ? prefix_options : query_options)[key.to_sym] = value - end - - [ prefix_options, query_options ] - end - end - - attr_accessor :attributes #:nodoc: - attr_accessor :prefix_options #:nodoc: - - # Constructor method for \new resources; the optional +attributes+ parameter takes a \hash - # of attributes for the \new resource. - # - # ==== Examples - # my_course = Course.new - # my_course.name = "Western Civilization" - # my_course.lecturer = "Don Trotter" - # my_course.save - # - # my_other_course = Course.new(:name => "Philosophy: Reason and Being", :lecturer => "Ralph Cling") - # my_other_course.save - def initialize(attributes = {}) - @attributes = {} - @prefix_options = {} - load(attributes) - end - - # Returns a \clone of the resource that hasn't been assigned an +id+ yet and - # is treated as a \new resource. - # - # ryan = Person.find(1) - # not_ryan = ryan.clone - # not_ryan.new? # => true - # - # Any active resource member attributes will NOT be cloned, though all other - # attributes are. This is to prevent the conflict between any +prefix_options+ - # that refer to the original parent resource and the newly cloned parent - # resource that does not exist. - # - # ryan = Person.find(1) - # ryan.address = StreetAddress.find(1, :person_id => ryan.id) - # ryan.hash = {:not => "an ARes instance"} - # - # not_ryan = ryan.clone - # not_ryan.new? # => true - # not_ryan.address # => NoMethodError - # not_ryan.hash # => {:not => "an ARes instance"} - def clone - # Clone all attributes except the pk and any nested ARes - cloned = attributes.reject {|k,v| k == self.class.primary_key || v.is_a?(ActiveResource::Base)}.inject({}) do |attrs, (k, v)| - attrs[k] = v.clone - attrs - end - # Form the new resource - bypass initialize of resource with 'new' as that will call 'load' which - # attempts to convert hashes into member objects and arrays into collections of objects. We want - # the raw objects to be cloned so we bypass load by directly setting the attributes hash. - resource = self.class.new({}) - resource.prefix_options = self.prefix_options - resource.send :instance_variable_set, '@attributes', cloned - resource - end - - - # A method to determine if the resource a \new object (i.e., it has not been POSTed to the remote service yet). - # - # ==== Examples - # not_new = Computer.create(:brand => 'Apple', :make => 'MacBook', :vendor => 'MacMall') - # not_new.new? # => false - # - # is_new = Computer.new(:brand => 'IBM', :make => 'Thinkpad', :vendor => 'IBM') - # is_new.new? # => true - # - # is_new.save - # is_new.new? # => false - # - def new? - id.nil? - end - alias :new_record? :new? - - # Gets the <tt>\id</tt> attribute of the resource. - def id - attributes[self.class.primary_key] - end - - # Sets the <tt>\id</tt> attribute of the resource. - def id=(id) - attributes[self.class.primary_key] = id - end - - # Allows Active Resource objects to be used as parameters in Action Pack URL generation. - def to_param - id && id.to_s - end - - # Test for equality. Resource are equal if and only if +other+ is the same object or - # is an instance of the same class, is not <tt>new?</tt>, and has the same +id+. - # - # ==== Examples - # ryan = Person.create(:name => 'Ryan') - # jamie = Person.create(:name => 'Jamie') - # - # ryan == jamie - # # => false (Different name attribute and id) - # - # ryan_again = Person.new(:name => 'Ryan') - # ryan == ryan_again - # # => false (ryan_again is new?) - # - # ryans_clone = Person.create(:name => 'Ryan') - # ryan == ryans_clone - # # => false (Different id attributes) - # - # ryans_twin = Person.find(ryan.id) - # ryan == ryans_twin - # # => true - # - def ==(other) - other.equal?(self) || (other.instance_of?(self.class) && other.id == id && other.prefix_options == prefix_options) - end - - # Tests for equality (delegates to ==). - def eql?(other) - self == other - end - - # Delegates to id in order to allow two resources of the same type and \id to work with something like: - # [Person.find(1), Person.find(2)] & [Person.find(1), Person.find(4)] # => [Person.find(1)] - def hash - id.hash - end - - # Duplicate the current resource without saving it. - # - # ==== Examples - # my_invoice = Invoice.create(:customer => 'That Company') - # next_invoice = my_invoice.dup - # next_invoice.new? # => true - # - # next_invoice.save - # next_invoice == my_invoice # => false (different id attributes) - # - # my_invoice.customer # => That Company - # next_invoice.customer # => That Company - def dup - self.class.new.tap do |resource| - resource.attributes = @attributes - resource.prefix_options = @prefix_options - end - end - - # A method to \save (+POST+) or \update (+PUT+) a resource. It delegates to +create+ if a \new object, - # +update+ if it is existing. If the response to the \save includes a body, it will be assumed that this body - # is XML for the final object as it looked after the \save (which would include attributes like +created_at+ - # that weren't part of the original submit). - # - # ==== Examples - # my_company = Company.new(:name => 'RoleModel Software', :owner => 'Ken Auer', :size => 2) - # my_company.new? # => true - # my_company.save # sends POST /companies/ (create) - # - # my_company.new? # => false - # my_company.size = 10 - # my_company.save # sends PUT /companies/1 (update) - def save - new? ? create : update - end - - # Deletes the resource from the remote service. - # - # ==== Examples - # my_id = 3 - # my_person = Person.find(my_id) - # my_person.destroy - # Person.find(my_id) # 404 (Resource Not Found) - # - # new_person = Person.create(:name => 'James') - # new_id = new_person.id # => 7 - # new_person.destroy - # Person.find(new_id) # 404 (Resource Not Found) - def destroy - connection.delete(element_path, self.class.headers) - end - - # Evaluates to <tt>true</tt> if this resource is not <tt>new?</tt> and is - # found on the remote service. Using this method, you can check for - # resources that may have been deleted between the object's instantiation - # and actions on it. - # - # ==== Examples - # Person.create(:name => 'Theodore Roosevelt') - # that_guy = Person.find(:first) - # that_guy.exists? # => true - # - # that_lady = Person.new(:name => 'Paul Bean') - # that_lady.exists? # => false - # - # guys_id = that_guy.id - # Person.delete(guys_id) - # that_guy.exists? # => false - def exists? - !new? && self.class.exists?(to_param, :params => prefix_options) - end - - # A method to convert the the resource to an XML string. - # - # ==== Options - # The +options+ parameter is handed off to the +to_xml+ method on each - # attribute, so it has the same options as the +to_xml+ methods in - # Active Support. - # - # * <tt>:indent</tt> - Set the indent level for the XML output (default is +2+). - # * <tt>:dasherize</tt> - Boolean option to determine whether or not element names should - # replace underscores with dashes (default is <tt>false</tt>). - # * <tt>:skip_instruct</tt> - Toggle skipping the +instruct!+ call on the XML builder - # that generates the XML declaration (default is <tt>false</tt>). - # - # ==== Examples - # my_group = SubsidiaryGroup.find(:first) - # my_group.to_xml - # # => <?xml version="1.0" encoding="UTF-8"?> - # # <subsidiary_group> [...] </subsidiary_group> - # - # my_group.to_xml(:dasherize => true) - # # => <?xml version="1.0" encoding="UTF-8"?> - # # <subsidiary-group> [...] </subsidiary-group> - # - # my_group.to_xml(:skip_instruct => true) - # # => <subsidiary_group> [...] </subsidiary_group> - def to_xml(options={}) - attributes.to_xml({:root => self.class.element_name}.merge(options)) - end - - # Returns a JSON string representing the model. Some configuration is - # available through +options+. - # - # ==== Options - # The +options+ are passed to the +to_json+ method on each - # attribute, so the same options as the +to_json+ methods in - # Active Support. - # - # * <tt>:only</tt> - Only include the specified attribute or list of - # attributes in the serialized output. Attribute names must be specified - # as strings. - # * <tt>:except</tt> - Do not include the specified attribute or list of - # attributes in the serialized output. Attribute names must be specified - # as strings. - # - # ==== Examples - # person = Person.new(:first_name => "Jim", :last_name => "Smith") - # person.to_json - # # => {"first_name": "Jim", "last_name": "Smith"} - # - # person.to_json(:only => ["first_name"]) - # # => {"first_name": "Jim"} - # - # person.to_json(:except => ["first_name"]) - # # => {"last_name": "Smith"} - def to_json(options={}) - attributes.to_json(options) - end - - # Returns the serialized string representation of the resource in the configured - # serialization format specified in ActiveResource::Base.format. The options - # applicable depend on the configured encoding format. - def encode(options={}) - case self.class.format - when ActiveResource::Formats[:xml] - self.class.format.encode(attributes, {:root => self.class.element_name}.merge(options)) - else - self.class.format.encode(attributes, options) - end - end - - # A method to \reload the attributes of this object from the remote web service. - # - # ==== Examples - # my_branch = Branch.find(:first) - # my_branch.name # => "Wislon Raod" - # - # # Another client fixes the typo... - # - # my_branch.name # => "Wislon Raod" - # my_branch.reload - # my_branch.name # => "Wilson Road" - def reload - self.load(self.class.find(to_param, :params => @prefix_options).attributes) - end - - # A method to manually load attributes from a \hash. Recursively loads collections of - # resources. This method is called in +initialize+ and +create+ when a \hash of attributes - # is provided. - # - # ==== Examples - # my_attrs = {:name => 'J&J Textiles', :industry => 'Cloth and textiles'} - # my_attrs = {:name => 'Marty', :colors => ["red", "green", "blue"]} - # - # the_supplier = Supplier.find(:first) - # the_supplier.name # => 'J&M Textiles' - # the_supplier.load(my_attrs) - # the_supplier.name('J&J Textiles') - # - # # These two calls are the same as Supplier.new(my_attrs) - # my_supplier = Supplier.new - # my_supplier.load(my_attrs) - # - # # These three calls are the same as Supplier.create(my_attrs) - # your_supplier = Supplier.new - # your_supplier.load(my_attrs) - # your_supplier.save - def load(attributes) - raise ArgumentError, "expected an attributes Hash, got #{attributes.inspect}" unless attributes.is_a?(Hash) - @prefix_options, attributes = split_options(attributes) - attributes.each do |key, value| - @attributes[key.to_s] = - case value - when Array - resource = find_or_create_resource_for_collection(key) - value.map { |attrs| attrs.is_a?(String) ? attrs.dup : resource.new(attrs) } - when Hash - resource = find_or_create_resource_for(key) - resource.new(value) - else - value.dup rescue value - end - end - self - end - - # For checking <tt>respond_to?</tt> without searching the attributes (which is faster). - alias_method :respond_to_without_attributes?, :respond_to? - - # A method to determine if an object responds to a message (e.g., a method call). In Active Resource, a Person object with a - # +name+ attribute can answer <tt>true</tt> to <tt>my_person.respond_to?(:name)</tt>, <tt>my_person.respond_to?(:name=)</tt>, and - # <tt>my_person.respond_to?(:name?)</tt>. - def respond_to?(method, include_priv = false) - method_name = method.to_s - if attributes.nil? - return super - elsif attributes.has_key?(method_name) - return true - elsif ['?','='].include?(method_name.last) && attributes.has_key?(method_name.first(-1)) - return true - end - # super must be called at the end of the method, because the inherited respond_to? - # would return true for generated readers, even if the attribute wasn't present - super - end - - - protected - def connection(refresh = false) - self.class.connection(refresh) - end - - # Update the resource on the remote service. - def update - connection.put(element_path(prefix_options), encode, self.class.headers).tap do |response| - load_attributes_from_response(response) - end - end - - # Create (i.e., \save to the remote service) the \new resource. - def create - connection.post(collection_path, encode, self.class.headers).tap do |response| - self.id = id_from_response(response) - load_attributes_from_response(response) - end - end - - def load_attributes_from_response(response) - if response['Content-Length'] != "0" && response.body.strip.size > 0 - load(self.class.format.decode(response.body)) - end - end - - # Takes a response from a typical create post and pulls the ID out - def id_from_response(response) - response['Location'][/\/([^\/]*?)(\.\w+)?$/, 1] if response['Location'] - end - - def element_path(options = nil) - self.class.element_path(to_param, options || prefix_options) - end - - def collection_path(options = nil) - self.class.collection_path(options || prefix_options) - end - - private - # Tries to find a resource for a given collection name; if it fails, then the resource is created - def find_or_create_resource_for_collection(name) - find_or_create_resource_for(name.to_s.singularize) - end - - # Tries to find a resource in a non empty list of nested modules - # Raises a NameError if it was not found in any of the given nested modules - def find_resource_in_modules(resource_name, module_names) - receiver = Object - namespaces = module_names[0, module_names.size-1].map do |module_name| - receiver = receiver.const_get(module_name) - end - if namespace = namespaces.reverse.detect { |ns| ns.const_defined?(resource_name) } - return namespace.const_get(resource_name) - else - raise NameError - end - end - - # Tries to find a resource for a given name; if it fails, then the resource is created - def find_or_create_resource_for(name) - resource_name = name.to_s.camelize - ancestors = self.class.name.split("::") - if ancestors.size > 1 - find_resource_in_modules(resource_name, ancestors) - else - self.class.const_get(resource_name) - end - rescue NameError - if self.class.const_defined?(resource_name) - resource = self.class.const_get(resource_name) - else - resource = self.class.const_set(resource_name, Class.new(ActiveResource::Base)) - end - resource.prefix = self.class.prefix - resource.site = self.class.site - resource - end - - def split_options(options = {}) - self.class.__send__(:split_options, options) - end - - def method_missing(method_symbol, *arguments) #:nodoc: - method_name = method_symbol.to_s - - case method_name.last - when "=" - attributes[method_name.first(-1)] = arguments.first - when "?" - attributes[method_name.first(-1)] - else - attributes.has_key?(method_name) ? attributes[method_name] : super - end - end - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/connection.rb b/vendor/rails/activeresource/lib/active_resource/connection.rb deleted file mode 100644 index 85103b5..0000000 --- a/vendor/rails/activeresource/lib/active_resource/connection.rb +++ /dev/null @@ -1,218 +0,0 @@ -require 'net/https' -require 'date' -require 'time' -require 'uri' -require 'benchmark' - -module ActiveResource - class ConnectionError < StandardError # :nodoc: - attr_reader :response - - def initialize(response, message = nil) - @response = response - @message = message - end - - def to_s - "Failed with #{response.code} #{response.message if response.respond_to?(:message)}" - end - end - - # Raised when a Timeout::Error occurs. - class TimeoutError < ConnectionError - def initialize(message) - @message = message - end - def to_s; @message ;end - end - - # 3xx Redirection - class Redirection < ConnectionError # :nodoc: - def to_s; response['Location'] ? "#{super} => #{response['Location']}" : super; end - end - - # 4xx Client Error - class ClientError < ConnectionError; end # :nodoc: - - # 400 Bad Request - class BadRequest < ClientError; end # :nodoc - - # 401 Unauthorized - class UnauthorizedAccess < ClientError; end # :nodoc - - # 403 Forbidden - class ForbiddenAccess < ClientError; end # :nodoc - - # 404 Not Found - class ResourceNotFound < ClientError; end # :nodoc: - - # 409 Conflict - class ResourceConflict < ClientError; end # :nodoc: - - # 5xx Server Error - class ServerError < ConnectionError; end # :nodoc: - - # 405 Method Not Allowed - class MethodNotAllowed < ClientError # :nodoc: - def allowed_methods - @response['Allow'].split(',').map { |verb| verb.strip.downcase.to_sym } - end - end - - # Class to handle connections to remote web services. - # This class is used by ActiveResource::Base to interface with REST - # services. - class Connection - - HTTP_FORMAT_HEADER_NAMES = { :get => 'Accept', - :put => 'Content-Type', - :post => 'Content-Type', - :delete => 'Accept' - } - - attr_reader :site, :user, :password, :timeout - attr_accessor :format - - class << self - def requests - @@requests ||= [] - end - end - - # The +site+ parameter is required and will set the +site+ - # attribute to the URI for the remote resource service. - def initialize(site, format = ActiveResource::Formats[:xml]) - raise ArgumentError, 'Missing site URI' unless site - @user = @password = nil - self.site = site - self.format = format - end - - # Set URI for remote service. - def site=(site) - @site = site.is_a?(URI) ? site : URI.parse(site) - @user = URI.decode(@site.user) if @site.user - @password = URI.decode(@site.password) if @site.password - end - - # Set user for remote service. - def user=(user) - @user = user - end - - # Set password for remote service. - def password=(password) - @password = password - end - - # Set the number of seconds after which HTTP requests to the remote service should time out. - def timeout=(timeout) - @timeout = timeout - end - - # Execute a GET request. - # Used to get (find) resources. - def get(path, headers = {}) - format.decode(request(:get, path, build_request_headers(headers, :get)).body) - end - - # Execute a DELETE request (see HTTP protocol documentation if unfamiliar). - # Used to delete resources. - def delete(path, headers = {}) - request(:delete, path, build_request_headers(headers, :delete)) - end - - # Execute a PUT request (see HTTP protocol documentation if unfamiliar). - # Used to update resources. - def put(path, body = '', headers = {}) - request(:put, path, body.to_s, build_request_headers(headers, :put)) - end - - # Execute a POST request. - # Used to create new resources. - def post(path, body = '', headers = {}) - request(:post, path, body.to_s, build_request_headers(headers, :post)) - end - - # Execute a HEAD request. - # Used to obtain meta-information about resources, such as whether they exist and their size (via response headers). - def head(path, headers = {}) - request(:head, path, build_request_headers(headers)) - end - - - private - # Makes request to remote service. - def request(method, path, *arguments) - logger.info "#{method.to_s.upcase} #{site.scheme}://#{site.host}:#{site.port}#{path}" if logger - result = nil - ms = Benchmark.ms { result = http.send(method, path, *arguments) } - logger.info "--> %d %s (%d %.0fms)" % [result.code, result.message, result.body ? result.body.length : 0, ms] if logger - handle_response(result) - rescue Timeout::Error => e - raise TimeoutError.new(e.message) - end - - # Handles response and error codes from remote service. - def handle_response(response) - case response.code.to_i - when 301,302 - raise(Redirection.new(response)) - when 200...400 - response - when 400 - raise(BadRequest.new(response)) - when 401 - raise(UnauthorizedAccess.new(response)) - when 403 - raise(ForbiddenAccess.new(response)) - when 404 - raise(ResourceNotFound.new(response)) - when 405 - raise(MethodNotAllowed.new(response)) - when 409 - raise(ResourceConflict.new(response)) - when 422 - raise(ResourceInvalid.new(response)) - when 401...500 - raise(ClientError.new(response)) - when 500...600 - raise(ServerError.new(response)) - else - raise(ConnectionError.new(response, "Unknown response code: #{response.code}")) - end - end - - # Creates new Net::HTTP instance for communication with - # remote service and resources. - def http - http = Net::HTTP.new(@site.host, @site.port) - http.use_ssl = @site.is_a?(URI::HTTPS) - http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl - http.read_timeout = @timeout if @timeout # If timeout is not set, the default Net::HTTP timeout (60s) is used. - http - end - - def default_header - @default_header ||= {} - end - - # Builds headers for request to remote service. - def build_request_headers(headers, http_method=nil) - authorization_header.update(default_header).update(http_format_header(http_method)).update(headers) - end - - # Sets authorization header - def authorization_header - (@user || @password ? { 'Authorization' => 'Basic ' + ["#{@user}:#{ @password}"].pack('m').delete("\r\n") } : {}) - end - - def http_format_header(http_method) - {HTTP_FORMAT_HEADER_NAMES[http_method] => format.mime_type} - end - - def logger #:nodoc: - Base.logger - end - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/custom_methods.rb b/vendor/rails/activeresource/lib/active_resource/custom_methods.rb deleted file mode 100644 index 4647e83..0000000 --- a/vendor/rails/activeresource/lib/active_resource/custom_methods.rb +++ /dev/null @@ -1,120 +0,0 @@ -module ActiveResource - # A module to support custom REST methods and sub-resources, allowing you to break out - # of the "default" REST methods with your own custom resource requests. For example, - # say you use Rails to expose a REST service and configure your routes with: - # - # map.resources :people, :new => { :register => :post }, - # :member => { :promote => :put, :deactivate => :delete } - # :collection => { :active => :get } - # - # This route set creates routes for the following HTTP requests: - # - # POST /people/new/register.xml # PeopleController.register - # PUT /people/1/promote.xml # PeopleController.promote with :id => 1 - # DELETE /people/1/deactivate.xml # PeopleController.deactivate with :id => 1 - # GET /people/active.xml # PeopleController.active - # - # Using this module, Active Resource can use these custom REST methods just like the - # standard methods. - # - # class Person < ActiveResource::Base - # self.site = "http://37s.sunrise.i:3000" - # end - # - # Person.new(:name => 'Ryan).post(:register) # POST /people/new/register.xml - # # => { :id => 1, :name => 'Ryan' } - # - # Person.find(1).put(:promote, :position => 'Manager') # PUT /people/1/promote.xml - # Person.find(1).delete(:deactivate) # DELETE /people/1/deactivate.xml - # - # Person.get(:active) # GET /people/active.xml - # # => [{:id => 1, :name => 'Ryan'}, {:id => 2, :name => 'Joe'}] - # - module CustomMethods - def self.included(base) - base.class_eval do - extend ActiveResource::CustomMethods::ClassMethods - include ActiveResource::CustomMethods::InstanceMethods - - class << self - alias :orig_delete :delete - - # Invokes a GET to a given custom REST method. For example: - # - # Person.get(:active) # GET /people/active.xml - # # => [{:id => 1, :name => 'Ryan'}, {:id => 2, :name => 'Joe'}] - # - # Person.get(:active, :awesome => true) # GET /people/active.xml?awesome=true - # # => [{:id => 1, :name => 'Ryan'}] - # - # Note: the objects returned from this method are not automatically converted - # into ActiveResource::Base instances - they are ordinary Hashes. If you are expecting - # ActiveResource::Base instances, use the <tt>find</tt> class method with the - # <tt>:from</tt> option. For example: - # - # Person.find(:all, :from => :active) - def get(custom_method_name, options = {}) - connection.get(custom_method_collection_url(custom_method_name, options), headers) - end - - def post(custom_method_name, options = {}, body = '') - connection.post(custom_method_collection_url(custom_method_name, options), body, headers) - end - - def put(custom_method_name, options = {}, body = '') - connection.put(custom_method_collection_url(custom_method_name, options), body, headers) - end - - def delete(custom_method_name, options = {}) - # Need to jump through some hoops to retain the original class 'delete' method - if custom_method_name.is_a?(Symbol) - connection.delete(custom_method_collection_url(custom_method_name, options), headers) - else - orig_delete(custom_method_name, options) - end - end - end - end - end - - module ClassMethods - def custom_method_collection_url(method_name, options = {}) - prefix_options, query_options = split_options(options) - "#{prefix(prefix_options)}#{collection_name}/#{method_name}.#{format.extension}#{query_string(query_options)}" - end - end - - module InstanceMethods - def get(method_name, options = {}) - connection.get(custom_method_element_url(method_name, options), self.class.headers) - end - - def post(method_name, options = {}, body = nil) - request_body = body.blank? ? encode : body - if new? - connection.post(custom_method_new_element_url(method_name, options), request_body, self.class.headers) - else - connection.post(custom_method_element_url(method_name, options), request_body, self.class.headers) - end - end - - def put(method_name, options = {}, body = '') - connection.put(custom_method_element_url(method_name, options), body, self.class.headers) - end - - def delete(method_name, options = {}) - connection.delete(custom_method_element_url(method_name, options), self.class.headers) - end - - - private - def custom_method_element_url(method_name, options = {}) - "#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{id}/#{method_name}.#{self.class.format.extension}#{self.class.__send__(:query_string, options)}" - end - - def custom_method_new_element_url(method_name, options = {}) - "#{self.class.prefix(prefix_options)}#{self.class.collection_name}/new/#{method_name}.#{self.class.format.extension}#{self.class.__send__(:query_string, options)}" - end - end - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/formats.rb b/vendor/rails/activeresource/lib/active_resource/formats.rb deleted file mode 100644 index 28864cf..0000000 --- a/vendor/rails/activeresource/lib/active_resource/formats.rb +++ /dev/null @@ -1,14 +0,0 @@ -module ActiveResource - module Formats - # Lookup the format class from a mime type reference symbol. Example: - # - # ActiveResource::Formats[:xml] # => ActiveResource::Formats::XmlFormat - # ActiveResource::Formats[:json] # => ActiveResource::Formats::JsonFormat - def self.[](mime_type_reference) - ActiveResource::Formats.const_get(mime_type_reference.to_s.camelize + "Format") - end - end -end - -require 'active_resource/formats/xml_format' -require 'active_resource/formats/json_format' \ No newline at end of file diff --git a/vendor/rails/activeresource/lib/active_resource/formats/json_format.rb b/vendor/rails/activeresource/lib/active_resource/formats/json_format.rb deleted file mode 100644 index 1d88fc5..0000000 --- a/vendor/rails/activeresource/lib/active_resource/formats/json_format.rb +++ /dev/null @@ -1,23 +0,0 @@ -module ActiveResource - module Formats - module JsonFormat - extend self - - def extension - "json" - end - - def mime_type - "application/json" - end - - def encode(hash, options={}) - hash.to_json(options) - end - - def decode(json) - ActiveSupport::JSON.decode(json) - end - end - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb b/vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb deleted file mode 100644 index 86c6cec..0000000 --- a/vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb +++ /dev/null @@ -1,34 +0,0 @@ -module ActiveResource - module Formats - module XmlFormat - extend self - - def extension - "xml" - end - - def mime_type - "application/xml" - end - - def encode(hash, options={}) - hash.to_xml(options) - end - - def decode(xml) - from_xml_data(Hash.from_xml(xml)) - end - - private - # Manipulate from_xml Hash, because xml_simple is not exactly what we - # want for Active Resource. - def from_xml_data(data) - if data.is_a?(Hash) && data.keys.size == 1 - data.values.first - else - data - end - end - end - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/http_mock.rb b/vendor/rails/activeresource/lib/active_resource/http_mock.rb deleted file mode 100644 index 7d7e378..0000000 --- a/vendor/rails/activeresource/lib/active_resource/http_mock.rb +++ /dev/null @@ -1,207 +0,0 @@ -require 'active_resource/connection' - -module ActiveResource - class InvalidRequestError < StandardError; end #:nodoc: - - # One thing that has always been a pain with remote web services is testing. The HttpMock - # class makes it easy to test your Active Resource models by creating a set of mock responses to specific - # requests. - # - # To test your Active Resource model, you simply call the ActiveResource::HttpMock.respond_to - # method with an attached block. The block declares a set of URIs with expected input, and the output - # each request should return. The passed in block has any number of entries in the following generalized - # format: - # - # mock.http_method(path, request_headers = {}, body = nil, status = 200, response_headers = {}) - # - # * <tt>http_method</tt> - The HTTP method to listen for. This can be +get+, +post+, +put+, +delete+ or - # +head+. - # * <tt>path</tt> - A string, starting with a "/", defining the URI that is expected to be - # called. - # * <tt>request_headers</tt> - Headers that are expected along with the request. This argument uses a - # hash format, such as <tt>{ "Content-Type" => "application/xml" }</tt>. This mock will only trigger - # if your tests sends a request with identical headers. - # * <tt>body</tt> - The data to be returned. This should be a string of Active Resource parseable content, - # such as XML. - # * <tt>status</tt> - The HTTP response code, as an integer, to return with the response. - # * <tt>response_headers</tt> - Headers to be returned with the response. Uses the same hash format as - # <tt>request_headers</tt> listed above. - # - # In order for a mock to deliver its content, the incoming request must match by the <tt>http_method</tt>, - # +path+ and <tt>request_headers</tt>. If no match is found an InvalidRequestError exception - # will be raised letting you know you need to create a new mock for that request. - # - # ==== Example - # def setup - # @matz = { :id => 1, :name => "Matz" }.to_xml(:root => "person") - # ActiveResource::HttpMock.respond_to do |mock| - # mock.post "/people.xml", {}, @matz, 201, "Location" => "/people/1.xml" - # mock.get "/people/1.xml", {}, @matz - # mock.put "/people/1.xml", {}, nil, 204 - # mock.delete "/people/1.xml", {}, nil, 200 - # end - # end - # - # def test_get_matz - # person = Person.find(1) - # assert_equal "Matz", person.name - # end - # - class HttpMock - class Responder #:nodoc: - def initialize(responses) - @responses = responses - end - - for method in [ :post, :put, :get, :delete, :head ] - # def post(path, request_headers = {}, body = nil, status = 200, response_headers = {}) - # @responses[Request.new(:post, path, nil, request_headers)] = Response.new(body || "", status, response_headers) - # end - module_eval <<-EOE, __FILE__, __LINE__ - def #{method}(path, request_headers = {}, body = nil, status = 200, response_headers = {}) - @responses << [Request.new(:#{method}, path, nil, request_headers), Response.new(body || "", status, response_headers)] - end - EOE - end - end - - class << self - - # Returns an array of all request objects that have been sent to the mock. You can use this to check - # if your model actually sent an HTTP request. - # - # ==== Example - # def setup - # @matz = { :id => 1, :name => "Matz" }.to_xml(:root => "person") - # ActiveResource::HttpMock.respond_to do |mock| - # mock.get "/people/1.xml", {}, @matz - # end - # end - # - # def test_should_request_remote_service - # person = Person.find(1) # Call the remote service - # - # # This request object has the same HTTP method and path as declared by the mock - # expected_request = ActiveResource::Request.new(:get, "/people/1.xml") - # - # # Assert that the mock received, and responded to, the expected request from the model - # assert ActiveResource::HttpMock.requests.include?(expected_request) - # end - def requests - @@requests ||= [] - end - - # Returns the list of requests and their mocked responses. Look up a - # response for a request using responses.assoc(request). - def responses - @@responses ||= [] - end - - # Accepts a block which declares a set of requests and responses for the HttpMock to respond to. See the main - # ActiveResource::HttpMock description for a more detailed explanation. - def respond_to(pairs = {}) #:yields: mock - reset! - responses.concat pairs.to_a - if block_given? - yield Responder.new(responses) - else - Responder.new(responses) - end - end - - # Deletes all logged requests and responses. - def reset! - requests.clear - responses.clear - end - end - - # body? methods - { true => %w(post put), - false => %w(get delete head) }.each do |has_body, methods| - methods.each do |method| - # def post(path, body, headers) - # request = ActiveResource::Request.new(:post, path, body, headers) - # self.class.requests << request - # self.class.responses.assoc(request).try(:second) || raise(InvalidRequestError.new("No response recorded for #{request}")) - # end - module_eval <<-EOE, __FILE__, __LINE__ - def #{method}(path, #{'body, ' if has_body}headers) - request = ActiveResource::Request.new(:#{method}, path, #{has_body ? 'body, ' : 'nil, '}headers) - self.class.requests << request - self.class.responses.assoc(request).try(:second) || raise(InvalidRequestError.new("No response recorded for \#{request}")) - end - EOE - end - end - - def initialize(site) #:nodoc: - @site = site - end - end - - class Request - attr_accessor :path, :method, :body, :headers - - def initialize(method, path, body = nil, headers = {}) - @method, @path, @body, @headers = method, path, body, headers.merge(ActiveResource::Connection::HTTP_FORMAT_HEADER_NAMES[method] => 'application/xml') - end - - def ==(req) - path == req.path && method == req.method && headers == req.headers - end - - def to_s - "<#{method.to_s.upcase}: #{path} [#{headers}] (#{body})>" - end - end - - class Response - attr_accessor :body, :message, :code, :headers - - def initialize(body, message = 200, headers = {}) - @body, @message, @headers = body, message.to_s, headers - @code = @message[0,3].to_i - - resp_cls = Net::HTTPResponse::CODE_TO_OBJ[@code.to_s] - if resp_cls && !resp_cls.body_permitted? - @body = nil - end - - if @body.nil? - self['Content-Length'] = "0" - else - self['Content-Length'] = body.size.to_s - end - end - - def success? - (200..299).include?(code) - end - - def [](key) - headers[key] - end - - def []=(key, value) - headers[key] = value - end - - def ==(other) - if (other.is_a?(Response)) - other.body == body && other.message == message && other.headers == headers - else - false - end - end - end - - class Connection - private - silence_warnings do - def http - @http ||= HttpMock.new(@site) - end - end - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/validations.rb b/vendor/rails/activeresource/lib/active_resource/validations.rb deleted file mode 100644 index de33399..0000000 --- a/vendor/rails/activeresource/lib/active_resource/validations.rb +++ /dev/null @@ -1,274 +0,0 @@ -module ActiveResource - class ResourceInvalid < ClientError #:nodoc: - end - - # Active Resource validation is reported to and from this object, which is used by Base#save - # to determine whether the object in a valid state to be saved. See usage example in Validations. - class Errors - include Enumerable - attr_reader :errors - - delegate :empty?, :to => :errors - - def initialize(base) # :nodoc: - @base, @errors = base, {} - end - - # Add an error to the base Active Resource object rather than an attribute. - # - # ==== Examples - # my_folder = Folder.find(1) - # my_folder.errors.add_to_base("You can't edit an existing folder") - # my_folder.errors.on_base - # # => "You can't edit an existing folder" - # - # my_folder.errors.add_to_base("This folder has been tagged as frozen") - # my_folder.valid? - # # => false - # my_folder.errors.on_base - # # => ["You can't edit an existing folder", "This folder has been tagged as frozen"] - # - def add_to_base(msg) - add(:base, msg) - end - - # Adds an error to an Active Resource object's attribute (named for the +attribute+ parameter) - # with the error message in +msg+. - # - # ==== Examples - # my_resource = Node.find(1) - # my_resource.errors.add('name', 'can not be "base"') if my_resource.name == 'base' - # my_resource.errors.on('name') - # # => 'can not be "base"!' - # - # my_resource.errors.add('desc', 'can not be blank') if my_resource.desc == '' - # my_resource.valid? - # # => false - # my_resource.errors.on('desc') - # # => 'can not be blank!' - # - def add(attribute, msg) - @errors[attribute.to_s] = [] if @errors[attribute.to_s].nil? - @errors[attribute.to_s] << msg - end - - # Returns true if the specified +attribute+ has errors associated with it. - # - # ==== Examples - # my_resource = Disk.find(1) - # my_resource.errors.add('location', 'must be Main') unless my_resource.location == 'Main' - # my_resource.errors.on('location') - # # => 'must be Main!' - # - # my_resource.errors.invalid?('location') - # # => true - # my_resource.errors.invalid?('name') - # # => false - def invalid?(attribute) - !@errors[attribute.to_s].nil? - end - - # A method to return the errors associated with +attribute+, which returns nil, if no errors are - # associated with the specified +attribute+, the error message if one error is associated with the specified +attribute+, - # or an array of error messages if more than one error is associated with the specified +attribute+. - # - # ==== Examples - # my_person = Person.new(params[:person]) - # my_person.errors.on('login') - # # => nil - # - # my_person.errors.add('login', 'can not be empty') if my_person.login == '' - # my_person.errors.on('login') - # # => 'can not be empty' - # - # my_person.errors.add('login', 'can not be longer than 10 characters') if my_person.login.length > 10 - # my_person.errors.on('login') - # # => ['can not be empty', 'can not be longer than 10 characters'] - def on(attribute) - errors = @errors[attribute.to_s] - return nil if errors.nil? - errors.size == 1 ? errors.first : errors - end - - alias :[] :on - - # A method to return errors assigned to +base+ object through add_to_base, which returns nil, if no errors are - # associated with the specified +attribute+, the error message if one error is associated with the specified +attribute+, - # or an array of error messages if more than one error is associated with the specified +attribute+. - # - # ==== Examples - # my_account = Account.find(1) - # my_account.errors.on_base - # # => nil - # - # my_account.errors.add_to_base("This account is frozen") - # my_account.errors.on_base - # # => "This account is frozen" - # - # my_account.errors.add_to_base("This account has been closed") - # my_account.errors.on_base - # # => ["This account is frozen", "This account has been closed"] - # - def on_base - on(:base) - end - - # Yields each attribute and associated message per error added. - # - # ==== Examples - # my_person = Person.new(params[:person]) - # - # my_person.errors.add('login', 'can not be empty') if my_person.login == '' - # my_person.errors.add('password', 'can not be empty') if my_person.password == '' - # messages = '' - # my_person.errors.each {|attr, msg| messages += attr.humanize + " " + msg + "<br />"} - # messages - # # => "Login can not be empty<br />Password can not be empty<br />" - # - def each - @errors.each_key { |attr| @errors[attr].each { |msg| yield attr, msg } } - end - - # Yields each full error message added. So Person.errors.add("first_name", "can't be empty") will be returned - # through iteration as "First name can't be empty". - # - # ==== Examples - # my_person = Person.new(params[:person]) - # - # my_person.errors.add('login', 'can not be empty') if my_person.login == '' - # my_person.errors.add('password', 'can not be empty') if my_person.password == '' - # messages = '' - # my_person.errors.each_full {|msg| messages += msg + "<br/>"} - # messages - # # => "Login can not be empty<br />Password can not be empty<br />" - # - def each_full - full_messages.each { |msg| yield msg } - end - - # Returns all the full error messages in an array. - # - # ==== Examples - # my_person = Person.new(params[:person]) - # - # my_person.errors.add('login', 'can not be empty') if my_person.login == '' - # my_person.errors.add('password', 'can not be empty') if my_person.password == '' - # messages = '' - # my_person.errors.full_messages.each {|msg| messages += msg + "<br/>"} - # messages - # # => "Login can not be empty<br />Password can not be empty<br />" - # - def full_messages - full_messages = [] - - @errors.each_key do |attr| - @errors[attr].each do |msg| - next if msg.nil? - - if attr == "base" - full_messages << msg - else - full_messages << [attr.humanize, msg].join(' ') - end - end - end - full_messages - end - - def clear - @errors = {} - end - - # Returns the total number of errors added. Two errors added to the same attribute will be counted as such - # with this as well. - # - # ==== Examples - # my_person = Person.new(params[:person]) - # my_person.errors.size - # # => 0 - # - # my_person.errors.add('login', 'can not be empty') if my_person.login == '' - # my_person.errors.add('password', 'can not be empty') if my_person.password == '' - # my_person.error.size - # # => 2 - # - def size - @errors.values.inject(0) { |error_count, attribute| error_count + attribute.size } - end - - alias_method :count, :size - alias_method :length, :size - - # Grabs errors from the XML response. - def from_xml(xml) - clear - humanized_attributes = @base.attributes.keys.inject({}) { |h, attr_name| h.update(attr_name.humanize => attr_name) } - messages = Array.wrap(Hash.from_xml(xml)['errors']['error']) rescue [] - messages.each do |message| - attr_message = humanized_attributes.keys.detect do |attr_name| - if message[0, attr_name.size + 1] == "#{attr_name} " - add humanized_attributes[attr_name], message[(attr_name.size + 1)..-1] - end - end - - add_to_base message if attr_message.nil? - end - end - end - - # Module to support validation and errors with Active Resource objects. The module overrides - # Base#save to rescue ActiveResource::ResourceInvalid exceptions and parse the errors returned - # in the web service response. The module also adds an +errors+ collection that mimics the interface - # of the errors provided by ActiveRecord::Errors. - # - # ==== Example - # - # Consider a Person resource on the server requiring both a +first_name+ and a +last_name+ with a - # <tt>validates_presence_of :first_name, :last_name</tt> declaration in the model: - # - # person = Person.new(:first_name => "Jim", :last_name => "") - # person.save # => false (server returns an HTTP 422 status code and errors) - # person.valid? # => false - # person.errors.empty? # => false - # person.errors.count # => 1 - # person.errors.full_messages # => ["Last name can't be empty"] - # person.errors.on(:last_name) # => "can't be empty" - # person.last_name = "Halpert" - # person.save # => true (and person is now saved to the remote service) - # - module Validations - def self.included(base) # :nodoc: - base.class_eval do - alias_method_chain :save, :validation - end - end - - # Validate a resource and save (POST) it to the remote web service. - def save_with_validation - save_without_validation - true - rescue ResourceInvalid => error - errors.from_xml(error.response.body) - false - end - - # Checks for errors on an object (i.e., is resource.errors empty?). - # - # ==== Examples - # my_person = Person.create(params[:person]) - # my_person.valid? - # # => true - # - # my_person.errors.add('login', 'can not be empty') if my_person.login == '' - # my_person.valid? - # # => false - def valid? - errors.empty? - end - - # Returns the Errors object that holds all information about attribute error messages. - def errors - @errors ||= Errors.new(self) - end - end -end diff --git a/vendor/rails/activeresource/lib/active_resource/version.rb b/vendor/rails/activeresource/lib/active_resource/version.rb deleted file mode 100644 index 3df2555..0000000 --- a/vendor/rails/activeresource/lib/active_resource/version.rb +++ /dev/null @@ -1,9 +0,0 @@ -module ActiveResource - module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 2 - - STRING = [MAJOR, MINOR, TINY].join('.') - end -end diff --git a/vendor/rails/activeresource/lib/activeresource.rb b/vendor/rails/activeresource/lib/activeresource.rb deleted file mode 100644 index e076455..0000000 --- a/vendor/rails/activeresource/lib/activeresource.rb +++ /dev/null @@ -1 +0,0 @@ -require 'active_resource' diff --git a/vendor/rails/activeresource/test/abstract_unit.rb b/vendor/rails/activeresource/test/abstract_unit.rb deleted file mode 100644 index 0f11ea4..0000000 --- a/vendor/rails/activeresource/test/abstract_unit.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rubygems' -require 'test/unit' - -gem 'mocha', '>= 0.9.5' -require 'mocha' - -$:.unshift "#{File.dirname(__FILE__)}/../lib" -$:.unshift "#{File.dirname(__FILE__)}/../../activesupport/lib" -require 'active_resource' -require 'active_resource/http_mock' - -$:.unshift "#{File.dirname(__FILE__)}/../test" -require 'setter_trap' - -ActiveResource::Base.logger = Logger.new("#{File.dirname(__FILE__)}/debug.log") - -def uses_gem(gem_name, test_name, version = '> 0') - gem gem_name.to_s, version - require gem_name.to_s - yield -rescue LoadError - $stderr.puts "Skipping #{test_name} tests. `gem install #{gem_name}` and try again." -end diff --git a/vendor/rails/activeresource/test/authorization_test.rb b/vendor/rails/activeresource/test/authorization_test.rb deleted file mode 100644 index ca25f43..0000000 --- a/vendor/rails/activeresource/test/authorization_test.rb +++ /dev/null @@ -1,122 +0,0 @@ -require 'abstract_unit' - -class AuthorizationTest < Test::Unit::TestCase - Response = Struct.new(:code) - - def setup - @conn = ActiveResource::Connection.new('http://localhost') - @matz = { :id => 1, :name => 'Matz' }.to_xml(:root => 'person') - @david = { :id => 2, :name => 'David' }.to_xml(:root => 'person') - @authenticated_conn = ActiveResource::Connection.new("http://david:test123@localhost") - @authorization_request_header = { 'Authorization' => 'Basic ZGF2aWQ6dGVzdDEyMw==' } - - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/2.xml", @authorization_request_header, @david - mock.put "/people/2.xml", @authorization_request_header, nil, 204 - mock.delete "/people/2.xml", @authorization_request_header, nil, 200 - mock.post "/people/2/addresses.xml", @authorization_request_header, nil, 201, 'Location' => '/people/1/addresses/5' - end - end - - def test_authorization_header - authorization_header = @authenticated_conn.__send__(:authorization_header) - assert_equal @authorization_request_header['Authorization'], authorization_header['Authorization'] - authorization = authorization_header["Authorization"].to_s.split - - assert_equal "Basic", authorization[0] - assert_equal ["david", "test123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] - end - - def test_authorization_header_with_username_but_no_password - @conn = ActiveResource::Connection.new("http://david:@localhost") - authorization_header = @conn.__send__(:authorization_header) - authorization = authorization_header["Authorization"].to_s.split - - assert_equal "Basic", authorization[0] - assert_equal ["david"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] - end - - def test_authorization_header_with_password_but_no_username - @conn = ActiveResource::Connection.new("http://:test123@localhost") - authorization_header = @conn.__send__(:authorization_header) - authorization = authorization_header["Authorization"].to_s.split - - assert_equal "Basic", authorization[0] - assert_equal ["", "test123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] - end - - def test_authorization_header_with_decoded_credentials_from_url - @conn = ActiveResource::Connection.new("http://my%40email.com:%31%32%33@localhost") - authorization_header = @conn.__send__(:authorization_header) - authorization = authorization_header["Authorization"].to_s.split - - assert_equal "Basic", authorization[0] - assert_equal ["my@email.com", "123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] - end - - def test_authorization_header_explicitly_setting_username_and_password - @authenticated_conn = ActiveResource::Connection.new("http://@localhost") - @authenticated_conn.user = 'david' - @authenticated_conn.password = 'test123' - authorization_header = @authenticated_conn.__send__(:authorization_header) - assert_equal @authorization_request_header['Authorization'], authorization_header['Authorization'] - authorization = authorization_header["Authorization"].to_s.split - - assert_equal "Basic", authorization[0] - assert_equal ["david", "test123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] - end - - def test_authorization_header_explicitly_setting_username_but_no_password - @conn = ActiveResource::Connection.new("http://@localhost") - @conn.user = "david" - authorization_header = @conn.__send__(:authorization_header) - authorization = authorization_header["Authorization"].to_s.split - - assert_equal "Basic", authorization[0] - assert_equal ["david"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] - end - - def test_authorization_header_explicitly_setting_password_but_no_username - @conn = ActiveResource::Connection.new("http://@localhost") - @conn.password = "test123" - authorization_header = @conn.__send__(:authorization_header) - authorization = authorization_header["Authorization"].to_s.split - - assert_equal "Basic", authorization[0] - assert_equal ["", "test123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1] - end - - def test_get - david = @authenticated_conn.get("/people/2.xml") - assert_equal "David", david["name"] - end - - def test_post - response = @authenticated_conn.post("/people/2/addresses.xml") - assert_equal "/people/1/addresses/5", response["Location"] - end - - def test_put - response = @authenticated_conn.put("/people/2.xml") - assert_equal 204, response.code - end - - def test_delete - response = @authenticated_conn.delete("/people/2.xml") - assert_equal 200, response.code - end - - def test_raises_invalid_request_on_unauthorized_requests - assert_raise(ActiveResource::InvalidRequestError) { @conn.post("/people/2.xml") } - assert_raise(ActiveResource::InvalidRequestError) { @conn.post("/people/2/addresses.xml") } - assert_raise(ActiveResource::InvalidRequestError) { @conn.put("/people/2.xml") } - assert_raise(ActiveResource::InvalidRequestError) { @conn.delete("/people/2.xml") } - end - - protected - def assert_response_raises(klass, code) - assert_raise(klass, "Expected response code #{code} to raise #{klass}") do - @conn.__send__(:handle_response, Response.new(code)) - end - end -end diff --git a/vendor/rails/activeresource/test/base/custom_methods_test.rb b/vendor/rails/activeresource/test/base/custom_methods_test.rb deleted file mode 100644 index 61887f4..0000000 --- a/vendor/rails/activeresource/test/base/custom_methods_test.rb +++ /dev/null @@ -1,100 +0,0 @@ -require 'abstract_unit' -require 'fixtures/person' -require 'fixtures/street_address' - -class CustomMethodsTest < Test::Unit::TestCase - def setup - @matz = { :id => 1, :name => 'Matz' }.to_xml(:root => 'person') - @matz_deep = { :id => 1, :name => 'Matz', :other => 'other' }.to_xml(:root => 'person') - @matz_array = [{ :id => 1, :name => 'Matz' }].to_xml(:root => 'people') - @ryan = { :name => 'Ryan' }.to_xml(:root => 'person') - @addy = { :id => 1, :street => '12345 Street' }.to_xml(:root => 'address') - @addy_deep = { :id => 1, :street => '12345 Street', :zip => "27519" }.to_xml(:root => 'address') - - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1.xml", {}, @matz - mock.get "/people/1/shallow.xml", {}, @matz - mock.get "/people/1/deep.xml", {}, @matz_deep - mock.get "/people/retrieve.xml?name=Matz", {}, @matz_array - mock.get "/people/managers.xml", {}, @matz_array - mock.post "/people/hire.xml?name=Matz", {}, nil, 201 - mock.put "/people/1/promote.xml?position=Manager", {}, nil, 204 - mock.put "/people/promote.xml?name=Matz", {}, nil, 204, {} - mock.put "/people/sort.xml?by=name", {}, nil, 204 - mock.delete "/people/deactivate.xml?name=Matz", {}, nil, 200 - mock.delete "/people/1/deactivate.xml", {}, nil, 200 - mock.post "/people/new/register.xml", {}, @ryan, 201, 'Location' => '/people/5.xml' - mock.post "/people/1/register.xml", {}, @matz, 201 - mock.get "/people/1/addresses/1.xml", {}, @addy - mock.get "/people/1/addresses/1/deep.xml", {}, @addy_deep - mock.put "/people/1/addresses/1/normalize_phone.xml?locale=US", {}, nil, 204 - mock.put "/people/1/addresses/sort.xml?by=name", {}, nil, 204 - mock.post "/people/1/addresses/new/link.xml", {}, { :street => '12345 Street' }.to_xml(:root => 'address'), 201, 'Location' => '/people/1/addresses/2.xml' - end - - Person.user = nil - Person.password = nil - end - - def teardown - ActiveResource::HttpMock.reset! - end - - def test_custom_collection_method - # GET - assert_equal([{ "id" => 1, "name" => 'Matz' }], Person.get(:retrieve, :name => 'Matz')) - - # POST - assert_equal(ActiveResource::Response.new("", 201, {}), Person.post(:hire, :name => 'Matz')) - - # PUT - assert_equal ActiveResource::Response.new("", 204, {}), - Person.put(:promote, {:name => 'Matz'}, 'atestbody') - assert_equal ActiveResource::Response.new("", 204, {}), Person.put(:sort, :by => 'name') - - # DELETE - Person.delete :deactivate, :name => 'Matz' - - # Nested resource - assert_equal ActiveResource::Response.new("", 204, {}), StreetAddress.put(:sort, :person_id => 1, :by => 'name') - end - - def test_custom_element_method - # Test GET against an element URL - assert_equal Person.find(1).get(:shallow), {"id" => 1, "name" => 'Matz'} - assert_equal Person.find(1).get(:deep), {"id" => 1, "name" => 'Matz', "other" => 'other'} - - # Test PUT against an element URL - assert_equal ActiveResource::Response.new("", 204, {}), Person.find(1).put(:promote, {:position => 'Manager'}, 'body') - - # Test DELETE against an element URL - assert_equal ActiveResource::Response.new("", 200, {}), Person.find(1).delete(:deactivate) - - # With nested resources - assert_equal StreetAddress.find(1, :params => { :person_id => 1 }).get(:deep), - { "id" => 1, "street" => '12345 Street', "zip" => "27519" } - assert_equal ActiveResource::Response.new("", 204, {}), - StreetAddress.find(1, :params => { :person_id => 1 }).put(:normalize_phone, :locale => 'US') - end - - def test_custom_new_element_method - # Test POST against a new element URL - ryan = Person.new(:name => 'Ryan') - assert_equal ActiveResource::Response.new(@ryan, 201, {'Location' => '/people/5.xml'}), ryan.post(:register) - expected_request = ActiveResource::Request.new(:post, '/people/new/register.xml', @ryan) - assert_equal expected_request.body, ActiveResource::HttpMock.requests.first.body - - # Test POST against a nested collection URL - addy = StreetAddress.new(:street => '123 Test Dr.', :person_id => 1) - assert_equal ActiveResource::Response.new({ :street => '12345 Street' }.to_xml(:root => 'address'), - 201, {'Location' => '/people/1/addresses/2.xml'}), - addy.post(:link) - - matz = Person.new(:id => 1, :name => 'Matz') - assert_equal ActiveResource::Response.new(@matz, 201), matz.post(:register) - end - - def test_find_custom_resources - assert_equal 'Matz', Person.find(:all, :from => :managers).first.name - end -end diff --git a/vendor/rails/activeresource/test/base/equality_test.rb b/vendor/rails/activeresource/test/base/equality_test.rb deleted file mode 100644 index 84f1a7b..0000000 --- a/vendor/rails/activeresource/test/base/equality_test.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'abstract_unit' -require "fixtures/person" -require "fixtures/street_address" - -class BaseEqualityTest < Test::Unit::TestCase - def setup - @new = Person.new - @one = Person.new(:id => 1) - @two = Person.new(:id => 2) - @street = StreetAddress.new(:id => 2) - end - - def test_should_equal_self - assert @new == @new, '@new == @new' - assert @one == @one, '@one == @one' - end - - def test_shouldnt_equal_new_resource - assert @new != @one, '@new != @one' - assert @one != @new, '@one != @new' - end - - def test_shouldnt_equal_different_class - assert @two != @street, 'person != street_address with same id' - assert @street != @two, 'street_address != person with same id' - end - - def test_eql_should_alias_equals_operator - assert_equal @new == @new, @new.eql?(@new) - assert_equal @new == @one, @new.eql?(@one) - - assert_equal @one == @one, @one.eql?(@one) - assert_equal @one == @new, @one.eql?(@new) - - assert_equal @one == @street, @one.eql?(@street) - end - - def test_hash_should_be_id_hash - [@new, @one, @two, @street].each do |resource| - assert_equal resource.id.hash, resource.hash - end - end - - def test_with_prefix_options - assert_equal @one == @one, @one.eql?(@one) - assert_equal @one == @one.dup, @one.eql?(@one.dup) - new_one = @one.dup - new_one.prefix_options = {:foo => 'bar'} - assert_not_equal @one, new_one - end - -end diff --git a/vendor/rails/activeresource/test/base/load_test.rb b/vendor/rails/activeresource/test/base/load_test.rb deleted file mode 100644 index a475fab..0000000 --- a/vendor/rails/activeresource/test/base/load_test.rb +++ /dev/null @@ -1,146 +0,0 @@ -require 'abstract_unit' -require "fixtures/person" -require "fixtures/street_address" - -module Highrise - class Note < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" - end - - class Comment < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" - end - - module Deeply - module Nested - - class Note < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" - end - - class Comment < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" - end - - module TestDifferentLevels - - class Note < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" - end - - end - - end - end - -end - - -class BaseLoadTest < Test::Unit::TestCase - def setup - @matz = { :id => 1, :name => 'Matz' } - - @first_address = { :id => 1, :street => '12345 Street' } - @addresses = [@first_address, { :id => 2, :street => '67890 Street' }] - @addresses_from_xml = { :street_addresses => @addresses } - @addresses_from_xml_single = { :street_addresses => [ @first_address ] } - - @deep = { :id => 1, :street => { - :id => 1, :state => { :id => 1, :name => 'Oregon', - :notable_rivers => [ - { :id => 1, :name => 'Willamette' }, - { :id => 2, :name => 'Columbia', :rafted_by => @matz }] }}} - - @person = Person.new - end - - def test_load_expects_hash - assert_raise(ArgumentError) { @person.load nil } - assert_raise(ArgumentError) { @person.load '<person id="1"/>' } - end - - def test_load_simple_hash - assert_equal Hash.new, @person.attributes - assert_equal @matz.stringify_keys, @person.load(@matz).attributes - end - - def test_load_one_with_existing_resource - address = @person.load(:street_address => @first_address).street_address - assert_kind_of StreetAddress, address - assert_equal @first_address.stringify_keys, address.attributes - end - - def test_load_one_with_unknown_resource - address = silence_warnings { @person.load(:address => @first_address).address } - assert_kind_of Person::Address, address - assert_equal @first_address.stringify_keys, address.attributes - end - - def test_load_collection_with_existing_resource - addresses = @person.load(@addresses_from_xml).street_addresses - assert_kind_of Array, addresses - addresses.each { |address| assert_kind_of StreetAddress, address } - assert_equal @addresses.map(&:stringify_keys), addresses.map(&:attributes) - end - - def test_load_collection_with_unknown_resource - Person.__send__(:remove_const, :Address) if Person.const_defined?(:Address) - assert !Person.const_defined?(:Address), "Address shouldn't exist until autocreated" - addresses = silence_warnings { @person.load(:addresses => @addresses).addresses } - assert Person.const_defined?(:Address), "Address should have been autocreated" - addresses.each { |address| assert_kind_of Person::Address, address } - assert_equal @addresses.map(&:stringify_keys), addresses.map(&:attributes) - end - - def test_load_collection_with_single_existing_resource - addresses = @person.load(@addresses_from_xml_single).street_addresses - assert_kind_of Array, addresses - addresses.each { |address| assert_kind_of StreetAddress, address } - assert_equal [ @first_address ].map(&:stringify_keys), addresses.map(&:attributes) - end - - def test_load_collection_with_single_unknown_resource - Person.__send__(:remove_const, :Address) if Person.const_defined?(:Address) - assert !Person.const_defined?(:Address), "Address shouldn't exist until autocreated" - addresses = silence_warnings { @person.load(:addresses => [ @first_address ]).addresses } - assert Person.const_defined?(:Address), "Address should have been autocreated" - addresses.each { |address| assert_kind_of Person::Address, address } - assert_equal [ @first_address ].map(&:stringify_keys), addresses.map(&:attributes) - end - - def test_recursively_loaded_collections - person = @person.load(@deep) - assert_equal @deep[:id], person.id - - street = person.street - assert_kind_of Person::Street, street - assert_equal @deep[:street][:id], street.id - - state = street.state - assert_kind_of Person::Street::State, state - assert_equal @deep[:street][:state][:id], state.id - - rivers = state.notable_rivers - assert_kind_of Array, rivers - assert_kind_of Person::Street::State::NotableRiver, rivers.first - assert_equal @deep[:street][:state][:notable_rivers].first[:id], rivers.first.id - assert_equal @matz[:id], rivers.last.rafted_by.id - end - - def test_nested_collections_within_the_same_namespace - n = Highrise::Note.new(:comments => [{ :name => "1" }]) - assert_kind_of Highrise::Comment, n.comments.first - end - - def test_nested_collections_within_deeply_nested_namespace - n = Highrise::Deeply::Nested::Note.new(:comments => [{ :name => "1" }]) - assert_kind_of Highrise::Deeply::Nested::Comment, n.comments.first - end - - def test_nested_collections_in_different_levels_of_namespaces - n = Highrise::Deeply::Nested::TestDifferentLevels::Note.new(:comments => [{ :name => "1" }]) - assert_kind_of Highrise::Deeply::Nested::Comment, n.comments.first - end - - -end diff --git a/vendor/rails/activeresource/test/base_errors_test.rb b/vendor/rails/activeresource/test/base_errors_test.rb deleted file mode 100644 index 7ae92c7..0000000 --- a/vendor/rails/activeresource/test/base_errors_test.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'abstract_unit' -require "fixtures/person" - -class BaseErrorsTest < Test::Unit::TestCase - def setup - ActiveResource::HttpMock.respond_to do |mock| - mock.post "/people.xml", {}, "<?xml version=\"1.0\" encoding=\"UTF-8\"?><errors><error>Age can't be blank</error><error>Name can't be blank</error><error>Name must start with a letter</error><error>Person quota full for today.</error></errors>", 422 - end - @person = Person.new(:name => '', :age => '') - assert_equal @person.save, false - end - - def test_should_mark_as_invalid - assert !@person.valid? - end - - def test_should_parse_xml_errors - assert_kind_of ActiveResource::Errors, @person.errors - assert_equal 4, @person.errors.size - end - - def test_should_parse_errors_to_individual_attributes - assert @person.errors.invalid?(:name) - assert_equal "can't be blank", @person.errors.on(:age) - assert_equal ["can't be blank", "must start with a letter"], @person.errors[:name] - assert_equal "Person quota full for today.", @person.errors.on_base - end - - def test_should_iterate_over_errors - errors = [] - @person.errors.each { |attribute, message| errors << [attribute, message] } - assert errors.include?(["name", "can't be blank"]) - end - - def test_should_iterate_over_full_errors - errors = [] - @person.errors.each_full { |message| errors << message } - assert errors.include?("Name can't be blank") - end - - def test_should_format_full_errors - full = @person.errors.full_messages - assert full.include?("Age can't be blank") - assert full.include?("Name can't be blank") - assert full.include?("Name must start with a letter") - assert full.include?("Person quota full for today.") - end -end diff --git a/vendor/rails/activeresource/test/base_test.rb b/vendor/rails/activeresource/test/base_test.rb deleted file mode 100644 index 6ed6f1a..0000000 --- a/vendor/rails/activeresource/test/base_test.rb +++ /dev/null @@ -1,891 +0,0 @@ -require 'abstract_unit' -require "fixtures/person" -require "fixtures/customer" -require "fixtures/street_address" -require "fixtures/beast" - -class BaseTest < Test::Unit::TestCase - def setup - @matz = { :id => 1, :name => 'Matz' }.to_xml(:root => 'person') - @david = { :id => 2, :name => 'David' }.to_xml(:root => 'person') - @greg = { :id => 3, :name => 'Greg' }.to_xml(:root => 'person') - @addy = { :id => 1, :street => '12345 Street' }.to_xml(:root => 'address') - @default_request_headers = { 'Content-Type' => 'application/xml' } - @rick = { :name => "Rick", :age => 25 }.to_xml(:root => "person") - @people = [{ :id => 1, :name => 'Matz' }, { :id => 2, :name => 'David' }].to_xml(:root => 'people') - @people_david = [{ :id => 2, :name => 'David' }].to_xml(:root => 'people') - @addresses = [{ :id => 1, :street => '12345 Street' }].to_xml(:root => 'addresses') - - # - deep nested resource - - # - Luis (Customer) - # - JK (Customer::Friend) - # - Mateo (Customer::Friend::Brother) - # - Edith (Customer::Friend::Brother::Child) - # - Martha (Customer::Friend::Brother::Child) - # - Felipe (Customer::Friend::Brother) - # - Bryan (Customer::Friend::Brother::Child) - # - Luke (Customer::Friend::Brother::Child) - # - Eduardo (Customer::Friend) - # - Sebas (Customer::Friend::Brother) - # - Andres (Customer::Friend::Brother::Child) - # - Jorge (Customer::Friend::Brother::Child) - # - Elsa (Customer::Friend::Brother) - # - Natacha (Customer::Friend::Brother::Child) - # - Milena (Customer::Friend::Brother) - # - @luis = {:id => 1, :name => 'Luis', - :friends => [{:name => 'JK', - :brothers => [{:name => 'Mateo', - :children => [{:name => 'Edith'},{:name => 'Martha'}]}, - {:name => 'Felipe', - :children => [{:name => 'Bryan'},{:name => 'Luke'}]}]}, - {:name => 'Eduardo', - :brothers => [{:name => 'Sebas', - :children => [{:name => 'Andres'},{:name => 'Jorge'}]}, - {:name => 'Elsa', - :children => [{:name => 'Natacha'}]}, - {:name => 'Milena', - :children => []}]}]}.to_xml(:root => 'customer') - # - resource with yaml array of strings; for ActiveRecords using serialize :bar, Array - @marty = <<-eof.strip - <?xml version=\"1.0\" encoding=\"UTF-8\"?> - <person> - <id type=\"integer\">5</id> - <name>Marty</name> - <colors type=\"yaml\">--- - - \"red\" - - \"green\" - - \"blue\" - </colors> - </person> - eof - - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1.xml", {}, @matz - mock.get "/people/2.xml", {}, @david - mock.get "/people/5.xml", {}, @marty - mock.get "/people/Greg.xml", {}, @greg - mock.get "/people/4.xml", {'key' => 'value'}, nil, 404 - mock.put "/people/1.xml", {}, nil, 204 - mock.delete "/people/1.xml", {}, nil, 200 - mock.delete "/people/2.xml", {}, nil, 400 - mock.get "/people/99.xml", {}, nil, 404 - mock.post "/people.xml", {}, @rick, 201, 'Location' => '/people/5.xml' - mock.get "/people.xml", {}, @people - mock.get "/people/1/addresses.xml", {}, @addresses - mock.get "/people/1/addresses/1.xml", {}, @addy - mock.get "/people/1/addresses/2.xml", {}, nil, 404 - mock.get "/people/2/addresses/1.xml", {}, nil, 404 - mock.get "/people/Greg/addresses/1.xml", {}, @addy - mock.put "/people/1/addresses/1.xml", {}, nil, 204 - mock.delete "/people/1/addresses/1.xml", {}, nil, 200 - mock.post "/people/1/addresses.xml", {}, nil, 201, 'Location' => '/people/1/addresses/5' - mock.get "/people//addresses.xml", {}, nil, 404 - mock.get "/people//addresses/1.xml", {}, nil, 404 - mock.put "/people//addresses/1.xml", {}, nil, 404 - mock.delete "/people//addresses/1.xml", {}, nil, 404 - mock.post "/people//addresses.xml", {}, nil, 404 - mock.head "/people/1.xml", {}, nil, 200 - mock.head "/people/Greg.xml", {}, nil, 200 - mock.head "/people/99.xml", {}, nil, 404 - mock.head "/people/1/addresses/1.xml", {}, nil, 200 - mock.head "/people/1/addresses/2.xml", {}, nil, 404 - mock.head "/people/2/addresses/1.xml", {}, nil, 404 - mock.head "/people/Greg/addresses/1.xml", {}, nil, 200 - # customer - mock.get "/customers/1.xml", {}, @luis - end - - Person.user = nil - Person.password = nil - end - - - def test_site_accessor_accepts_uri_or_string_argument - site = URI.parse('http://localhost') - - assert_nothing_raised { Person.site = 'http://localhost' } - assert_equal site, Person.site - - assert_nothing_raised { Person.site = site } - assert_equal site, Person.site - end - - def test_should_use_site_prefix_and_credentials - assert_equal 'http://foo:bar@beast.caboo.se', Forum.site.to_s - assert_equal 'http://foo:bar@beast.caboo.se/forums/:forum_id', Topic.site.to_s - end - - def test_site_variable_can_be_reset - actor = Class.new(ActiveResource::Base) - assert_nil actor.site - actor.site = 'http://localhost:31337' - actor.site = nil - assert_nil actor.site - end - - def test_should_accept_setting_user - Forum.user = 'david' - assert_equal('david', Forum.user) - assert_equal('david', Forum.connection.user) - end - - def test_should_accept_setting_password - Forum.password = 'test123' - assert_equal('test123', Forum.password) - assert_equal('test123', Forum.connection.password) - end - - def test_should_accept_setting_timeout - Forum.timeout = 5 - assert_equal(5, Forum.timeout) - assert_equal(5, Forum.connection.timeout) - end - - def test_user_variable_can_be_reset - actor = Class.new(ActiveResource::Base) - actor.site = 'http://cinema' - assert_nil actor.user - actor.user = 'username' - actor.user = nil - assert_nil actor.user - assert_nil actor.connection.user - end - - def test_password_variable_can_be_reset - actor = Class.new(ActiveResource::Base) - actor.site = 'http://cinema' - assert_nil actor.password - actor.password = 'username' - actor.password = nil - assert_nil actor.password - assert_nil actor.connection.password - end - - def test_timeout_variable_can_be_reset - actor = Class.new(ActiveResource::Base) - actor.site = 'http://cinema' - assert_nil actor.timeout - actor.timeout = 5 - actor.timeout = nil - assert_nil actor.timeout - assert_nil actor.connection.timeout - end - - def test_credentials_from_site_are_decoded - actor = Class.new(ActiveResource::Base) - actor.site = 'http://my%40email.com:%31%32%33@cinema' - assert_equal("my@email.com", actor.user) - assert_equal("123", actor.password) - end - - def test_site_reader_uses_superclass_site_until_written - # Superclass is Object so returns nil. - assert_nil ActiveResource::Base.site - assert_nil Class.new(ActiveResource::Base).site - - # Subclass uses superclass site. - actor = Class.new(Person) - assert_equal Person.site, actor.site - - # Subclass returns frozen superclass copy. - assert !Person.site.frozen? - assert actor.site.frozen? - - # Changing subclass site doesn't change superclass site. - actor.site = 'http://localhost:31337' - assert_not_equal Person.site, actor.site - - # Changed subclass site is not frozen. - assert !actor.site.frozen? - - # Changing superclass site doesn't overwrite subclass site. - Person.site = 'http://somewhere.else' - assert_not_equal Person.site, actor.site - - # Changing superclass site after subclassing changes subclass site. - jester = Class.new(actor) - actor.site = 'http://nomad' - assert_equal actor.site, jester.site - assert jester.site.frozen? - - # Subclasses are always equal to superclass site when not overridden - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - - fruit.site = 'http://market' - assert_equal fruit.site, apple.site, 'subclass did not adopt changes from parent class' - - fruit.site = 'http://supermarket' - assert_equal fruit.site, apple.site, 'subclass did not adopt changes from parent class' - end - - def test_user_reader_uses_superclass_user_until_written - # Superclass is Object so returns nil. - assert_nil ActiveResource::Base.user - assert_nil Class.new(ActiveResource::Base).user - Person.user = 'anonymous' - - # Subclass uses superclass user. - actor = Class.new(Person) - assert_equal Person.user, actor.user - - # Subclass returns frozen superclass copy. - assert !Person.user.frozen? - assert actor.user.frozen? - - # Changing subclass user doesn't change superclass user. - actor.user = 'david' - assert_not_equal Person.user, actor.user - - # Changing superclass user doesn't overwrite subclass user. - Person.user = 'john' - assert_not_equal Person.user, actor.user - - # Changing superclass user after subclassing changes subclass user. - jester = Class.new(actor) - actor.user = 'john.doe' - assert_equal actor.user, jester.user - - # Subclasses are always equal to superclass user when not overridden - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - - fruit.user = 'manager' - assert_equal fruit.user, apple.user, 'subclass did not adopt changes from parent class' - - fruit.user = 'client' - assert_equal fruit.user, apple.user, 'subclass did not adopt changes from parent class' - end - - def test_password_reader_uses_superclass_password_until_written - # Superclass is Object so returns nil. - assert_nil ActiveResource::Base.password - assert_nil Class.new(ActiveResource::Base).password - Person.password = 'my-password' - - # Subclass uses superclass password. - actor = Class.new(Person) - assert_equal Person.password, actor.password - - # Subclass returns frozen superclass copy. - assert !Person.password.frozen? - assert actor.password.frozen? - - # Changing subclass password doesn't change superclass password. - actor.password = 'secret' - assert_not_equal Person.password, actor.password - - # Changing superclass password doesn't overwrite subclass password. - Person.password = 'super-secret' - assert_not_equal Person.password, actor.password - - # Changing superclass password after subclassing changes subclass password. - jester = Class.new(actor) - actor.password = 'even-more-secret' - assert_equal actor.password, jester.password - - # Subclasses are always equal to superclass password when not overridden - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - - fruit.password = 'mega-secret' - assert_equal fruit.password, apple.password, 'subclass did not adopt changes from parent class' - - fruit.password = 'ok-password' - assert_equal fruit.password, apple.password, 'subclass did not adopt changes from parent class' - end - - def test_timeout_reader_uses_superclass_timeout_until_written - # Superclass is Object so returns nil. - assert_nil ActiveResource::Base.timeout - assert_nil Class.new(ActiveResource::Base).timeout - Person.timeout = 5 - - # Subclass uses superclass timeout. - actor = Class.new(Person) - assert_equal Person.timeout, actor.timeout - - # Changing subclass timeout doesn't change superclass timeout. - actor.timeout = 10 - assert_not_equal Person.timeout, actor.timeout - - # Changing superclass timeout doesn't overwrite subclass timeout. - Person.timeout = 15 - assert_not_equal Person.timeout, actor.timeout - - # Changing superclass timeout after subclassing changes subclass timeout. - jester = Class.new(actor) - actor.timeout = 20 - assert_equal actor.timeout, jester.timeout - - # Subclasses are always equal to superclass timeout when not overridden. - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - - fruit.timeout = 25 - assert_equal fruit.timeout, apple.timeout, 'subclass did not adopt changes from parent class' - - fruit.timeout = 30 - assert_equal fruit.timeout, apple.timeout, 'subclass did not adopt changes from parent class' - end - - def test_updating_baseclass_site_object_wipes_descendent_cached_connection_objects - # Subclasses are always equal to superclass site when not overridden - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - - fruit.site = 'http://market' - assert_equal fruit.connection.site, apple.connection.site - first_connection = apple.connection.object_id - - fruit.site = 'http://supermarket' - assert_equal fruit.connection.site, apple.connection.site - second_connection = apple.connection.object_id - assert_not_equal(first_connection, second_connection, 'Connection should be re-created') - end - - def test_updating_baseclass_user_wipes_descendent_cached_connection_objects - # Subclasses are always equal to superclass user when not overridden - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - fruit.site = 'http://market' - - fruit.user = 'david' - assert_equal fruit.connection.user, apple.connection.user - first_connection = apple.connection.object_id - - fruit.user = 'john' - assert_equal fruit.connection.user, apple.connection.user - second_connection = apple.connection.object_id - assert_not_equal(first_connection, second_connection, 'Connection should be re-created') - end - - def test_updating_baseclass_password_wipes_descendent_cached_connection_objects - # Subclasses are always equal to superclass password when not overridden - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - fruit.site = 'http://market' - - fruit.password = 'secret' - assert_equal fruit.connection.password, apple.connection.password - first_connection = apple.connection.object_id - - fruit.password = 'supersecret' - assert_equal fruit.connection.password, apple.connection.password - second_connection = apple.connection.object_id - assert_not_equal(first_connection, second_connection, 'Connection should be re-created') - end - - def test_updating_baseclass_timeout_wipes_descendent_cached_connection_objects - # Subclasses are always equal to superclass timeout when not overridden - fruit = Class.new(ActiveResource::Base) - apple = Class.new(fruit) - fruit.site = 'http://market' - - fruit.timeout = 5 - assert_equal fruit.connection.timeout, apple.connection.timeout - first_connection = apple.connection.object_id - - fruit.timeout = 10 - assert_equal fruit.connection.timeout, apple.connection.timeout - second_connection = apple.connection.object_id - assert_not_equal(first_connection, second_connection, 'Connection should be re-created') - end - - def test_collection_name - assert_equal "people", Person.collection_name - end - - def test_collection_path - assert_equal '/people.xml', Person.collection_path - end - - def test_collection_path_with_parameters - assert_equal '/people.xml?gender=male', Person.collection_path(:gender => 'male') - assert_equal '/people.xml?gender=false', Person.collection_path(:gender => false) - assert_equal '/people.xml?gender=', Person.collection_path(:gender => nil) - - assert_equal '/people.xml?gender=male', Person.collection_path('gender' => 'male') - - # Use includes? because ordering of param hash is not guaranteed - assert Person.collection_path(:gender => 'male', :student => true).include?('/people.xml?') - assert Person.collection_path(:gender => 'male', :student => true).include?('gender=male') - assert Person.collection_path(:gender => 'male', :student => true).include?('student=true') - - assert_equal '/people.xml?name%5B%5D=bob&name%5B%5D=your+uncle%2Bme&name%5B%5D=&name%5B%5D=false', Person.collection_path(:name => ['bob', 'your uncle+me', nil, false]) - - assert_equal '/people.xml?struct%5Ba%5D%5B%5D=2&struct%5Ba%5D%5B%5D=1&struct%5Bb%5D=fred', Person.collection_path(:struct => {:a => [2,1], 'b' => 'fred'}) - end - - def test_custom_element_path - assert_equal '/people/1/addresses/1.xml', StreetAddress.element_path(1, :person_id => 1) - assert_equal '/people/1/addresses/1.xml', StreetAddress.element_path(1, 'person_id' => 1) - assert_equal '/people/Greg/addresses/1.xml', StreetAddress.element_path(1, 'person_id' => 'Greg') - end - - def test_custom_element_path_with_redefined_to_param - Person.module_eval do - alias_method :original_to_param_element_path, :to_param - def to_param - name - end - end - - # Class method. - assert_equal '/people/Greg.xml', Person.element_path('Greg') - - # Protected Instance method. - assert_equal '/people/Greg.xml', Person.find('Greg').send(:element_path) - - ensure - # revert back to original - Person.module_eval do - # save the 'new' to_param so we don't get a warning about discarding the method - alias_method :element_path_to_param, :to_param - alias_method :to_param, :original_to_param_element_path - end - end - - def test_custom_element_path_with_parameters - assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, :person_id => 1, :type => 'work') - assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, 'person_id' => 1, :type => 'work') - assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, :type => 'work', :person_id => 1) - assert_equal '/people/1/addresses/1.xml?type%5B%5D=work&type%5B%5D=play+time', StreetAddress.element_path(1, :person_id => 1, :type => ['work', 'play time']) - end - - def test_custom_element_path_with_prefix_and_parameters - assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, {:person_id => 1}, {:type => 'work'}) - end - - def test_custom_collection_path - assert_equal '/people/1/addresses.xml', StreetAddress.collection_path(:person_id => 1) - assert_equal '/people/1/addresses.xml', StreetAddress.collection_path('person_id' => 1) - end - - def test_custom_collection_path_with_parameters - assert_equal '/people/1/addresses.xml?type=work', StreetAddress.collection_path(:person_id => 1, :type => 'work') - assert_equal '/people/1/addresses.xml?type=work', StreetAddress.collection_path('person_id' => 1, :type => 'work') - end - - def test_custom_collection_path_with_prefix_and_parameters - assert_equal '/people/1/addresses.xml?type=work', StreetAddress.collection_path({:person_id => 1}, {:type => 'work'}) - end - - def test_custom_element_name - assert_equal 'address', StreetAddress.element_name - end - - def test_custom_collection_name - assert_equal 'addresses', StreetAddress.collection_name - end - - def test_prefix - assert_equal "/", Person.prefix - assert_equal Set.new, Person.__send__(:prefix_parameters) - end - - def test_set_prefix - SetterTrap.rollback_sets(Person) do |person_class| - person_class.prefix = "the_prefix" - assert_equal "the_prefix", person_class.prefix - end - end - - def test_set_prefix_with_inline_keys - SetterTrap.rollback_sets(Person) do |person_class| - person_class.prefix = "the_prefix:the_param" - assert_equal "the_prefixthe_param_value", person_class.prefix(:the_param => "the_param_value") - end - end - - def test_set_prefix_twice_should_clear_params - SetterTrap.rollback_sets(Person) do |person_class| - person_class.prefix = "the_prefix/:the_param1" - assert_equal Set.new([:the_param1]), person_class.prefix_parameters - person_class.prefix = "the_prefix/:the_param2" - assert_equal Set.new([:the_param2]), person_class.prefix_parameters - end - end - - def test_set_prefix_with_default_value - SetterTrap.rollback_sets(Person) do |person_class| - person_class.set_prefix - assert_equal "/", person_class.prefix - end - end - - def test_custom_prefix - assert_equal '/people//', StreetAddress.prefix - assert_equal '/people/1/', StreetAddress.prefix(:person_id => 1) - assert_equal [:person_id].to_set, StreetAddress.__send__(:prefix_parameters) - end - - def test_find_by_id - matz = Person.find(1) - assert_kind_of Person, matz - assert_equal "Matz", matz.name - assert matz.name? - end - - def test_respond_to - matz = Person.find(1) - assert matz.respond_to?(:name) - assert matz.respond_to?(:name=) - assert matz.respond_to?(:name?) - assert !matz.respond_to?(:super_scalable_stuff) - end - - def test_find_by_id_with_custom_prefix - addy = StreetAddress.find(1, :params => { :person_id => 1 }) - assert_kind_of StreetAddress, addy - assert_equal '12345 Street', addy.street - end - - def test_find_all - all = Person.find(:all) - assert_equal 2, all.size - assert_kind_of Person, all.first - assert_equal "Matz", all.first.name - assert_equal "David", all.last.name - end - - def test_find_first - matz = Person.find(:first) - assert_kind_of Person, matz - assert_equal "Matz", matz.name - end - - def test_find_last - david = Person.find(:last) - assert_kind_of Person, david - assert_equal 'David', david.name - end - - def test_custom_header - Person.headers['key'] = 'value' - assert_raise(ActiveResource::ResourceNotFound) { Person.find(4) } - ensure - Person.headers.delete('key') - end - - def test_find_by_id_not_found - assert_raise(ActiveResource::ResourceNotFound) { Person.find(99) } - assert_raise(ActiveResource::ResourceNotFound) { StreetAddress.find(1) } - end - - def test_find_all_by_from - ActiveResource::HttpMock.respond_to { |m| m.get "/companies/1/people.xml", {}, @people_david } - - people = Person.find(:all, :from => "/companies/1/people.xml") - assert_equal 1, people.size - assert_equal "David", people.first.name - end - - def test_find_all_by_from_with_options - ActiveResource::HttpMock.respond_to { |m| m.get "/companies/1/people.xml", {}, @people_david } - - people = Person.find(:all, :from => "/companies/1/people.xml") - assert_equal 1, people.size - assert_equal "David", people.first.name - end - - def test_find_all_by_symbol_from - ActiveResource::HttpMock.respond_to { |m| m.get "/people/managers.xml", {}, @people_david } - - people = Person.find(:all, :from => :managers) - assert_equal 1, people.size - assert_equal "David", people.first.name - end - - def test_find_single_by_from - ActiveResource::HttpMock.respond_to { |m| m.get "/companies/1/manager.xml", {}, @david } - - david = Person.find(:one, :from => "/companies/1/manager.xml") - assert_equal "David", david.name - end - - def test_find_single_by_symbol_from - ActiveResource::HttpMock.respond_to { |m| m.get "/people/leader.xml", {}, @david } - - david = Person.find(:one, :from => :leader) - assert_equal "David", david.name - end - - def test_save - rick = Person.new - assert_equal true, rick.save - assert_equal '5', rick.id - end - - def test_id_from_response - p = Person.new - resp = {'Location' => '/foo/bar/1'} - assert_equal '1', p.__send__(:id_from_response, resp) - - resp['Location'] << '.xml' - assert_equal '1', p.__send__(:id_from_response, resp) - end - - def test_id_from_response_without_location - p = Person.new - resp = {} - assert_equal nil, p.__send__(:id_from_response, resp) - end - - def test_create_with_custom_prefix - matzs_house = StreetAddress.new(:person_id => 1) - matzs_house.save - assert_equal '5', matzs_house.id - end - - # Test that loading a resource preserves its prefix_options. - def test_load_preserves_prefix_options - address = StreetAddress.find(1, :params => { :person_id => 1 }) - ryan = Person.new(:id => 1, :name => 'Ryan', :address => address) - assert_equal address.prefix_options, ryan.address.prefix_options - end - - def test_reload_works_with_prefix_options - address = StreetAddress.find(1, :params => { :person_id => 1 }) - assert_equal address, address.reload - end - - def test_reload_with_redefined_to_param - Person.module_eval do - alias_method :original_to_param_reload, :to_param - def to_param - name - end - end - - person = Person.find('Greg') - assert_equal person, person.reload - - ensure - # revert back to original - Person.module_eval do - # save the 'new' to_param so we don't get a warning about discarding the method - alias_method :reload_to_param, :to_param - alias_method :to_param, :original_to_param_reload - end - end - - def test_reload_works_without_prefix_options - person = Person.find(:first) - assert_equal person, person.reload - end - - def test_create - rick = Person.create(:name => 'Rick') - assert rick.valid? - assert !rick.new? - assert_equal '5', rick.id - - # test additional attribute returned on create - assert_equal 25, rick.age - - # Test that save exceptions get bubbled up too - ActiveResource::HttpMock.respond_to do |mock| - mock.post "/people.xml", {}, nil, 409 - end - assert_raise(ActiveResource::ResourceConflict) { Person.create(:name => 'Rick') } - end - - def test_create_without_location - ActiveResource::HttpMock.respond_to do |mock| - mock.post "/people.xml", {}, nil, 201 - end - person = Person.create(:name => 'Rick') - assert_equal nil, person.id - end - - def test_clone - matz = Person.find(1) - matz_c = matz.clone - assert matz_c.new? - matz.attributes.each do |k, v| - assert_equal v, matz_c.send(k) if k != Person.primary_key - end - end - - def test_nested_clone - addy = StreetAddress.find(1, :params => {:person_id => 1}) - addy_c = addy.clone - assert addy_c.new? - addy.attributes.each do |k, v| - assert_equal v, addy_c.send(k) if k != StreetAddress.primary_key - end - assert_equal addy.prefix_options, addy_c.prefix_options - end - - def test_complex_clone - matz = Person.find(1) - matz.address = StreetAddress.find(1, :params => {:person_id => matz.id}) - matz.non_ar_hash = {:not => "an ARes instance"} - matz.non_ar_arr = ["not", "ARes"] - matz_c = matz.clone - assert matz_c.new? - assert_raise(NoMethodError) {matz_c.address} - assert_equal matz.non_ar_hash, matz_c.non_ar_hash - assert_equal matz.non_ar_arr, matz_c.non_ar_arr - - # Test that actual copy, not just reference copy - matz.non_ar_hash[:not] = "changed" - assert_not_equal matz.non_ar_hash, matz_c.non_ar_hash - end - - def test_update - matz = Person.find(:first) - matz.name = "David" - assert_kind_of Person, matz - assert_equal "David", matz.name - assert_equal true, matz.save - end - - def test_update_with_custom_prefix_with_specific_id - addy = StreetAddress.find(1, :params => { :person_id => 1 }) - addy.street = "54321 Street" - assert_kind_of StreetAddress, addy - assert_equal "54321 Street", addy.street - addy.save - end - - def test_update_with_custom_prefix_without_specific_id - addy = StreetAddress.find(:first, :params => { :person_id => 1 }) - addy.street = "54321 Lane" - assert_kind_of StreetAddress, addy - assert_equal "54321 Lane", addy.street - addy.save - end - - def test_update_conflict - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/2.xml", {}, @david - mock.put "/people/2.xml", @default_request_headers, nil, 409 - end - assert_raise(ActiveResource::ResourceConflict) { Person.find(2).save } - end - - def test_destroy - assert Person.find(1).destroy - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1.xml", {}, nil, 404 - end - assert_raise(ActiveResource::ResourceNotFound) { Person.find(1).destroy } - end - - def test_destroy_with_custom_prefix - assert StreetAddress.find(1, :params => { :person_id => 1 }).destroy - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1/addresses/1.xml", {}, nil, 404 - end - assert_raise(ActiveResource::ResourceNotFound) { StreetAddress.find(1, :params => { :person_id => 1 }) } - end - - def test_delete - assert Person.delete(1) - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1.xml", {}, nil, 404 - end - assert_raise(ActiveResource::ResourceNotFound) { Person.find(1) } - end - - def test_delete_with_custom_prefix - assert StreetAddress.delete(1, :person_id => 1) - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/1/addresses/1.xml", {}, nil, 404 - end - assert_raise(ActiveResource::ResourceNotFound) { StreetAddress.find(1, :params => { :person_id => 1 }) } - end - - def test_exists - # Class method. - assert !Person.exists?(nil) - assert Person.exists?(1) - assert !Person.exists?(99) - - # Instance method. - assert !Person.new.exists? - assert Person.find(1).exists? - assert !Person.new(:id => 99).exists? - - # Nested class method. - assert StreetAddress.exists?(1, :params => { :person_id => 1 }) - assert !StreetAddress.exists?(1, :params => { :person_id => 2 }) - assert !StreetAddress.exists?(2, :params => { :person_id => 1 }) - - # Nested instance method. - assert StreetAddress.find(1, :params => { :person_id => 1 }).exists? - assert !StreetAddress.new({:id => 1, :person_id => 2}).exists? - assert !StreetAddress.new({:id => 2, :person_id => 1}).exists? - end - - def test_exists_with_redefined_to_param - Person.module_eval do - alias_method :original_to_param_exists, :to_param - def to_param - name - end - end - - # Class method. - assert Person.exists?('Greg') - - # Instance method. - assert Person.find('Greg').exists? - - # Nested class method. - assert StreetAddress.exists?(1, :params => { :person_id => Person.find('Greg').to_param }) - - # Nested instance method. - assert StreetAddress.find(1, :params => { :person_id => Person.find('Greg').to_param }).exists? - - ensure - # revert back to original - Person.module_eval do - # save the 'new' to_param so we don't get a warning about discarding the method - alias_method :exists_to_param, :to_param - alias_method :to_param, :original_to_param_exists - end - end - - def test_to_xml - matz = Person.find(1) - xml = matz.encode - assert xml.starts_with?('<?xml version="1.0" encoding="UTF-8"?>') - assert xml.include?('<name>Matz</name>') - assert xml.include?('<id type="integer">1</id>') - end - - def test_to_param_quacks_like_active_record - new_person = Person.new - assert_nil new_person.to_param - matz = Person.find(1) - assert_equal '1', matz.to_param - end - - def test_parse_deep_nested_resources - luis = Customer.find(1) - assert_kind_of Customer, luis - luis.friends.each do |friend| - assert_kind_of Customer::Friend, friend - friend.brothers.each do |brother| - assert_kind_of Customer::Friend::Brother, brother - brother.children.each do |child| - assert_kind_of Customer::Friend::Brother::Child, child - end - end - end - end - - def test_load_yaml_array - assert_nothing_raised do - marty = Person.find(5) - assert_equal 3, marty.colors.size - marty.colors.each do |color| - assert_kind_of String, color - end - end - end -end diff --git a/vendor/rails/activeresource/test/connection_test.rb b/vendor/rails/activeresource/test/connection_test.rb deleted file mode 100644 index 831fbc4..0000000 --- a/vendor/rails/activeresource/test/connection_test.rb +++ /dev/null @@ -1,196 +0,0 @@ -require 'abstract_unit' - -class ConnectionTest < Test::Unit::TestCase - ResponseCodeStub = Struct.new(:code) - - def setup - @conn = ActiveResource::Connection.new('http://localhost') - @matz = { :id => 1, :name => 'Matz' } - @david = { :id => 2, :name => 'David' } - @people = [ @matz, @david ].to_xml(:root => 'people') - @people_single = [ @matz ].to_xml(:root => 'people-single-elements') - @people_empty = [ ].to_xml(:root => 'people-empty-elements') - @matz = @matz.to_xml(:root => 'person') - @david = @david.to_xml(:root => 'person') - @header = {'key' => 'value'}.freeze - - @default_request_headers = { 'Content-Type' => 'application/xml' } - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/2.xml", @header, @david - mock.get "/people.xml", {}, @people - mock.get "/people_single_elements.xml", {}, @people_single - mock.get "/people_empty_elements.xml", {}, @people_empty - mock.get "/people/1.xml", {}, @matz - mock.put "/people/1.xml", {}, nil, 204 - mock.put "/people/2.xml", {}, @header, 204 - mock.delete "/people/1.xml", {}, nil, 200 - mock.delete "/people/2.xml", @header, nil, 200 - mock.post "/people.xml", {}, nil, 201, 'Location' => '/people/5.xml' - mock.post "/members.xml", {}, @header, 201, 'Location' => '/people/6.xml' - mock.head "/people/1.xml", {}, nil, 200 - end - end - - def test_handle_response - # 2xx and 3xx are valid responses. - [200, 299, 300, 399].each do |code| - expected = ResponseCodeStub.new(code) - assert_equal expected, handle_response(expected) - end - - # 400 is a bad request (e.g. malformed URI or missing request parameter) - assert_response_raises ActiveResource::BadRequest, 400 - - # 401 is an unauthorized request - assert_response_raises ActiveResource::UnauthorizedAccess, 401 - - # 403 is a forbidden requst (and authorizing will not help) - assert_response_raises ActiveResource::ForbiddenAccess, 403 - - # 404 is a missing resource. - assert_response_raises ActiveResource::ResourceNotFound, 404 - - # 405 is a missing not allowed error - assert_response_raises ActiveResource::MethodNotAllowed, 405 - - # 409 is an optimistic locking error - assert_response_raises ActiveResource::ResourceConflict, 409 - - # 422 is a validation error - assert_response_raises ActiveResource::ResourceInvalid, 422 - - # 4xx are client errors. - [402, 499].each do |code| - assert_response_raises ActiveResource::ClientError, code - end - - # 5xx are server errors. - [500, 599].each do |code| - assert_response_raises ActiveResource::ServerError, code - end - - # Others are unknown. - [199, 600].each do |code| - assert_response_raises ActiveResource::ConnectionError, code - end - end - - ResponseHeaderStub = Struct.new(:code, :message, 'Allow') - def test_should_return_allowed_methods_for_method_no_allowed_exception - begin - handle_response ResponseHeaderStub.new(405, "HTTP Failed...", "GET, POST") - rescue ActiveResource::MethodNotAllowed => e - assert_equal "Failed with 405 HTTP Failed...", e.message - assert_equal [:get, :post], e.allowed_methods - end - end - - def test_initialize_raises_argument_error_on_missing_site - assert_raise(ArgumentError) { ActiveResource::Connection.new(nil) } - end - - def test_site_accessor_accepts_uri_or_string_argument - site = URI.parse("http://localhost") - - assert_raise(URI::InvalidURIError) { @conn.site = nil } - - assert_nothing_raised { @conn.site = "http://localhost" } - assert_equal site, @conn.site - - assert_nothing_raised { @conn.site = site } - assert_equal site, @conn.site - end - - def test_timeout_accessor - @conn.timeout = 5 - assert_equal 5, @conn.timeout - end - - def test_get - matz = @conn.get("/people/1.xml") - assert_equal "Matz", matz["name"] - end - - def test_head - response = @conn.head("/people/1.xml") - assert response.body.blank? - assert_equal 200, response.code - end - - def test_get_with_header - david = @conn.get("/people/2.xml", @header) - assert_equal "David", david["name"] - end - - def test_get_collection - people = @conn.get("/people.xml") - assert_equal "Matz", people[0]["name"] - assert_equal "David", people[1]["name"] - end - - def test_get_collection_single - people = @conn.get("/people_single_elements.xml") - assert_equal "Matz", people[0]["name"] - end - - def test_get_collection_empty - people = @conn.get("/people_empty_elements.xml") - assert_equal [], people - end - - def test_post - response = @conn.post("/people.xml") - assert_equal "/people/5.xml", response["Location"] - end - - def test_post_with_header - response = @conn.post("/members.xml", @header) - assert_equal "/people/6.xml", response["Location"] - end - - def test_put - response = @conn.put("/people/1.xml") - assert_equal 204, response.code - end - - def test_put_with_header - response = @conn.put("/people/2.xml", @header) - assert_equal 204, response.code - end - - def test_delete - response = @conn.delete("/people/1.xml") - assert_equal 200, response.code - end - - def test_delete_with_header - response = @conn.delete("/people/2.xml", @header) - assert_equal 200, response.code - end - - def test_timeout - @http = mock('new Net::HTTP') - @conn.expects(:http).returns(@http) - @http.expects(:get).raises(Timeout::Error, 'execution expired') - assert_raise(ActiveResource::TimeoutError) { @conn.get('/people_timeout.xml') } - end - - def test_accept_http_header - @http = mock('new Net::HTTP') - @conn.expects(:http).returns(@http) - path = '/people/1.xml' - @http.expects(:get).with(path, {'Accept' => 'application/xhtml+xml'}).returns(ActiveResource::Response.new(@matz, 200, {'Content-Type' => 'text/xhtml'})) - assert_nothing_raised(Mocha::ExpectationError) { @conn.get(path, {'Accept' => 'application/xhtml+xml'}) } - end - - protected - def assert_response_raises(klass, code) - assert_raise(klass, "Expected response code #{code} to raise #{klass}") do - handle_response ResponseCodeStub.new(code) - end - end - - def handle_response(response) - @conn.__send__(:handle_response, response) - end -end diff --git a/vendor/rails/activeresource/test/fixtures/beast.rb b/vendor/rails/activeresource/test/fixtures/beast.rb deleted file mode 100644 index e31ec58..0000000 --- a/vendor/rails/activeresource/test/fixtures/beast.rb +++ /dev/null @@ -1,14 +0,0 @@ -class BeastResource < ActiveResource::Base - self.site = 'http://beast.caboo.se' - site.user = 'foo' - site.password = 'bar' -end - -class Forum < BeastResource - # taken from BeastResource - # self.site = 'http://beast.caboo.se' -end - -class Topic < BeastResource - self.site += '/forums/:forum_id' -end diff --git a/vendor/rails/activeresource/test/fixtures/customer.rb b/vendor/rails/activeresource/test/fixtures/customer.rb deleted file mode 100644 index 845d5d1..0000000 --- a/vendor/rails/activeresource/test/fixtures/customer.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Customer < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" -end diff --git a/vendor/rails/activeresource/test/fixtures/person.rb b/vendor/rails/activeresource/test/fixtures/person.rb deleted file mode 100644 index e88bb69..0000000 --- a/vendor/rails/activeresource/test/fixtures/person.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Person < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000" -end diff --git a/vendor/rails/activeresource/test/fixtures/street_address.rb b/vendor/rails/activeresource/test/fixtures/street_address.rb deleted file mode 100644 index 94a8670..0000000 --- a/vendor/rails/activeresource/test/fixtures/street_address.rb +++ /dev/null @@ -1,4 +0,0 @@ -class StreetAddress < ActiveResource::Base - self.site = "http://37s.sunrise.i:3000/people/:person_id/" - self.element_name = 'address' -end diff --git a/vendor/rails/activeresource/test/format_test.rb b/vendor/rails/activeresource/test/format_test.rb deleted file mode 100644 index c3733e1..0000000 --- a/vendor/rails/activeresource/test/format_test.rb +++ /dev/null @@ -1,112 +0,0 @@ -require 'abstract_unit' -require "fixtures/person" -require "fixtures/street_address" - -class FormatTest < Test::Unit::TestCase - def setup - @matz = { :id => 1, :name => 'Matz' } - @david = { :id => 2, :name => 'David' } - - @programmers = [ @matz, @david ] - end - - def test_http_format_header_name - header_name = ActiveResource::Connection::HTTP_FORMAT_HEADER_NAMES[:get] - assert_equal 'Accept', header_name - - headers_names = [ActiveResource::Connection::HTTP_FORMAT_HEADER_NAMES[:put], ActiveResource::Connection::HTTP_FORMAT_HEADER_NAMES[:post]] - headers_names.each{ |name| assert_equal 'Content-Type', name } - end - - def test_formats_on_single_element - for format in [ :json, :xml ] - using_format(Person, format) do - ActiveResource::HttpMock.respond_to.get "/people/1.#{format}", {'Accept' => ActiveResource::Formats[format].mime_type}, ActiveResource::Formats[format].encode(@david) - assert_equal @david[:name], Person.find(1).name - end - end - end - - def test_formats_on_collection - for format in [ :json, :xml ] - using_format(Person, format) do - ActiveResource::HttpMock.respond_to.get "/people.#{format}", {'Accept' => ActiveResource::Formats[format].mime_type}, ActiveResource::Formats[format].encode(@programmers) - remote_programmers = Person.find(:all) - assert_equal 2, remote_programmers.size - assert remote_programmers.select { |p| p.name == 'David' } - end - end - end - - def test_formats_on_custom_collection_method - for format in [ :json, :xml ] - using_format(Person, format) do - ActiveResource::HttpMock.respond_to.get "/people/retrieve.#{format}?name=David", {'Accept' => ActiveResource::Formats[format].mime_type}, ActiveResource::Formats[format].encode([@david]) - remote_programmers = Person.get(:retrieve, :name => 'David') - assert_equal 1, remote_programmers.size - assert_equal @david[:id], remote_programmers[0]['id'] - assert_equal @david[:name], remote_programmers[0]['name'] - end - end - end - - def test_formats_on_custom_element_method - for format in [ :json, :xml ] - using_format(Person, format) do - ActiveResource::HttpMock.respond_to do |mock| - mock.get "/people/2.#{format}", {'Accept' => ActiveResource::Formats[format].mime_type}, ActiveResource::Formats[format].encode(@david) - mock.get "/people/2/shallow.#{format}", {'Accept' => ActiveResource::Formats[format].mime_type}, ActiveResource::Formats[format].encode(@david) - end - remote_programmer = Person.find(2).get(:shallow) - assert_equal @david[:id], remote_programmer['id'] - assert_equal @david[:name], remote_programmer['name'] - end - end - - for format in [ :json, :xml ] - ryan = ActiveResource::Formats[format].encode({ :name => 'Ryan' }) - using_format(Person, format) do - remote_ryan = Person.new(:name => 'Ryan') - ActiveResource::HttpMock.respond_to.post "/people.#{format}", {'Content-Type' => ActiveResource::Formats[format].mime_type}, ryan, 201, {'Location' => "/people/5.#{format}"} - remote_ryan.save - - remote_ryan = Person.new(:name => 'Ryan') - ActiveResource::HttpMock.respond_to.post "/people/new/register.#{format}", {'Content-Type' => ActiveResource::Formats[format].mime_type}, ryan, 201, {'Location' => "/people/5.#{format}"} - assert_equal ActiveResource::Response.new(ryan, 201, {'Location' => "/people/5.#{format}"}), remote_ryan.post(:register) - end - end - end - - def test_setting_format_before_site - resource = Class.new(ActiveResource::Base) - resource.format = :json - resource.site = 'http://37s.sunrise.i:3000' - assert_equal ActiveResource::Formats[:json], resource.connection.format - end - - def test_serialization_of_nested_resource - address = { :street => '12345 Street' } - person = { :name=> 'Rus', :address => address} - - [:json, :xml].each do |format| - encoded_person = ActiveResource::Formats[format].encode(person) - assert_match(/12345 Street/, encoded_person) - remote_person = Person.new(person.update({:address => StreetAddress.new(address)})) - assert_kind_of StreetAddress, remote_person.address - using_format(Person, format) do - ActiveResource::HttpMock.respond_to.post "/people.#{format}", {'Content-Type' => ActiveResource::Formats[format].mime_type}, encoded_person, 201, {'Location' => "/people/5.#{format}"} - remote_person.save - end - end - end - - private - def using_format(klass, mime_type_reference) - previous_format = klass.format - klass.format = mime_type_reference - - yield - ensure - klass.format = previous_format - end -end diff --git a/vendor/rails/activeresource/test/setter_trap.rb b/vendor/rails/activeresource/test/setter_trap.rb deleted file mode 100644 index 7cfd9ca..0000000 --- a/vendor/rails/activeresource/test/setter_trap.rb +++ /dev/null @@ -1,26 +0,0 @@ -class SetterTrap < ActiveSupport::BasicObject - class << self - def rollback_sets(obj) - trapped = new(obj) - yield(trapped).tap { trapped.rollback_sets } - end - end - - def initialize(obj) - @cache = {} - @obj = obj - end - - def respond_to?(method) - @obj.respond_to?(method) - end - - def method_missing(method, *args, &proc) - @cache[method] ||= @obj.send($`) if method.to_s =~ /=$/ - @obj.send method, *args, &proc - end - - def rollback_sets - @cache.each { |k, v| @obj.send k, v } - end -end diff --git a/vendor/rails/activesupport/CHANGELOG b/vendor/rails/activesupport/CHANGELOG deleted file mode 100644 index ab40e1a..0000000 --- a/vendor/rails/activesupport/CHANGELOG +++ /dev/null @@ -1,1309 +0,0 @@ -*2.3.2 [Final] (March 15, 2009)* - -* XmlMini supports LibXML and Nokogiri backends. #2084, #2190 [Bart ten Brinke, Aaron Patterson] - Example: XmlMini.backend = 'Nokogiri' - -* Vendorize i18n 0.1.3 gem (fixes issues with incompatible character encodings in Ruby 1.9) #2038 [Akira Matsuda] - -* Update bundled memcache-client from 1.5.0.5 to 1.6.4.99. See http://www.mikeperham.com/2009/02/15/memcache-client-performance/ [Mike Perham] - -* Ruby 1.9.1p0 fix: URI.unescape can decode multibyte chars. #2033 [MOROHASHI Kyosuke] - -* Time#to_s(:rfc822) uses #formatted_offset instead of unreliable and non-standard %z directive #1899 [Zachary Zolton] - -* Make TimeWithZone#to_formatted_s an alias to TimeWithZone#to_s #1796 [Levin Alexander] - -* Introduce Array.wrap(foo) to wrap the argument in an array unless it's already an array. Wraps nil as an empty array. Use instead of Array(foo) and foo.to_a since they treat String as Enumerable. [Jeremy Kemper] - -* TimeWithZone#xmlschema accepts optional fraction_digits argument [#1725 state:resolved] [Nicholas Dainty] - -* Object#tap shim for Ruby < 1.8.7. Similar to Object#returning, tap yields self then returns self. [Jeremy Kemper] - array.select { ... }.tap(&:inspect).map { ... } - -* TimeWithZone#- gives correct result with wrapped DateTime, and with DateTime argument [Geoff Buesing] - -* Updated i18n gem to version 0.1.1 #1635 [Yaroslav Markin] - -* Add :allow_nil option to delegate. #1127 [Sergio Gil] - -* Add Benchmark.ms convenience method to benchmark realtime in milliseconds. [Jeremy Kemper] - -* Updated included memcache-client to the 1.5.0.5 version which includes fixes from fiveruns and 37signals to deal with failover and timeouts #1535 [Joshua Sierles] - -* Multibyte: add multibyte-safe Chars#ord rather than falling back to String#ord. #1483 [Jason Cheow] - -* I18n support for Array#to_sentence. Introduces support.array.words_connector, .two_words_connector, and .last_word_connector translation keys. #1397 [Akira Matsuda] - -* Added ActiveSupport::OrderedHash#each_key and ActiveSupport::OrderedHash#each_value #1410 [Christoffer Sawicki] - -* Added ActiveSupport::MessageVerifier and MessageEncryptor to aid users who need to store signed and/or encrypted messages. [Michael Koziarski] - -* Added ActiveSupport::BacktraceCleaner to cut down on backtrace noise according to filters and silencers [David Heinemeier Hansson] - -* Added Object#try. ( Taken from http://ozmm.org/posts/try.html ) [Chris Wanstrath] - -* Added Enumerable#none? to check that none of the elements match the block #1408 [Damian Janowski] - -* TimeZone offset tests: use current_period, to ensure TimeZone#utc_offset is up-to-date [Geoff Buesing] - -* Update bundled TZInfo to 0.3.12 [Geoff Buesing] - -* Added lambda merging to OptionMerger (especially useful with named_scope and with_options) #726 [Paweł Kondzior] - - -*2.2.1 [RC2] (November 14th, 2008)* - -* Increment the version of our altered memcache-client to prevent confusion caused when the 1.5.0 gem is installed. - -* Fixed the option merging in Array#to_xml #1126 [Rudolf Gavlas] - -* Make I18n::Backend::Simple reload its translations in development mode [David Heinemeier Hansson/Sven Fuchs] - - -*2.2.0 [RC1] (October 24th, 2008)* - -* TimeWithZone#freeze: preload instance variables so that we can actually freeze [Geoff Buesing] - -* Fix Brasilia timezone #1180 [Marcus Derencius, Kane] - -* Time#advance recognizes fractional days and weeks. Deprecate Durations of fractional months and years #970 [Tom Lea] - -* Add ActiveSupport::Rescuable module abstracting ActionController::Base rescue_from features. [Norbert Crombach, Pratik Naik] - -* Switch from String#chars to String#mb_chars for the unicode proxy. [Manfred Stienstra] - - This helps with 1.8.7 compatibility and also improves performance for some operations by reducing indirection. - -* TimeWithZone #wday, #yday and #to_date avoid trip through #method_missing [Geoff Buesing] - -* Added Time, Date, DateTime and TimeWithZone #past?, #future? and #today? #720 [Clemens Kofler, Geoff Buesing] - -* Fixed Sri Jayawardenepura time zone to map to Asia/Colombo [Jamis Buck] - -* Added Inflector#parameterize for easy slug generation ("Donald E. Knuth".parameterize => "donald-e-knuth") #713 [Matt Darby] - -* Changed cache benchmarking to be reported in milliseconds [David Heinemeier Hansson] - -* Fix Ruby's Time marshaling bug in pre-1.9 versions of Ruby: utc instances are now correctly unmarshaled with a utc zone instead of the system local zone [#900 state:resolved] [Luca Guidi, Geoff Buesing] - -* Add Array#in_groups which splits or iterates over the array in specified number of groups. #579. [Adrian Mugnolo] Example: - - a = (1..10).to_a - a.in_groups(3) #=> [[1, 2, 3, 4], [5, 6, 7, nil], [8, 9, 10, nil]] - a.in_groups(3, false) #=> [[1, 2, 3, 4], [5, 6, 7], [8, 9, 10]] - -* Fix TimeWithZone unmarshaling: coerce unmarshaled Time instances to utc, because Ruby's marshaling of Time instances doesn't respect the zone [Geoff Buesing] - -* Added Memoizable mixin for caching simple lazy loaded attributes [Josh Peek] - -* Move the test related core_ext stuff out of core_ext so it's only loaded by the test helpers. [Michael Koziarski] - -* Add Inflection rules for String#humanize. #535 [Dan Manges] - - ActiveSupport::Inflector.inflections do |inflect| - inflect.human(/_cnt$/i, '\1_count') - end - - 'jargon_cnt'.humanize # => 'Jargon count' - -* TimeWithZone: when crossing DST boundary, treat Durations of days, months or years as variable-length, and all other values as absolute length. A time + 24.hours will advance exactly 24 hours, but a time + 1.day will advance 23-25 hours, depending on the day. Ensure consistent behavior across all advancing methods [Geoff Buesing] - -* Added TimeZone #=~, to support matching zones by regex in time_zone_select. #195 [Ernie Miller] - -* Added Array#second through Array#fifth as aliases for Array#[1] through Array#[4] + Array#forty_two as alias for Array[41] [David Heinemeier Hansson] - -* Added test/do declaration style testing to ActiveSupport::TestCase [DHH via Jay Fields] - -* Added Object#present? which is equivalent to !Object#blank? [David Heinemeier Hansson] - -* Added Enumberable#many? to encapsulate collection.size > 1 [David Heinemeier Hansson/Damian Janowski] - -* Add more standard Hash methods to ActiveSupport::OrderedHash [Steve Purcell] - -* Namespace Inflector, Dependencies, OrderedOptions, and TimeZone under ActiveSupport [Josh Peek] - -* Added StringInquirer for doing things like StringInquirer.new("production").production? # => true and StringInquirer.new("production").development? # => false [David Heinemeier Hansson] - -* Fixed Date#end_of_quarter to not blow up on May 31st [#289 state:resolved] (Danger) - - -*2.1.0 (May 31st, 2008)* - -* TimeZone#to_s shows offset as GMT instead of UTC, because GMT will be more familiar to end users (see time zone selects used by Windows OS, google.com and yahoo.com.) Reverts [8370] [Geoff Buesing] - -* Hash.from_xml: datetime xml types overflow to Ruby DateTime class when out of range of Time. Adding tests for utc offsets [Geoff Buesing] - -* TimeWithZone #+ and #- : ensure overflow to DateTime with Numeric arg [Geoff Buesing] - -* Time#to_json: don't convert to utc before encoding. References #175 [Geoff Buesing] - -* Remove unused JSON::RESERVED_WORDS, JSON.valid_identifier? and JSON.reserved_word? methods. Resolves #164. [Cheah Chu Yeow] - -* Adding Date.current, which returns Time.zone.today if config.time_zone is set; otherwise returns Date.today [Geoff Buesing] - -* TimeWithZone: date part getter methods (#year #mon #day etc) are defined on class; no longer relying on method_missing [Geoff Buesing] - -* Time.zone.parse return nil for strings with no date information [Geoff Buesing] - -* Time.zone.parse respects offset information in string. Resolves #105. [Scott Fleckenstein, Geoff Buesing] - -* Added Ruby 1.8 implementation of Process.daemon - -* Duration #since and #ago with no argument (e.g., 5.days.ago) return TimeWithZone when config.time_zone is set. Introducing Time.current, which returns Time.zone.now if config.time_zone is set, otherwise just returns Time.now [Geoff Buesing] - -* Time#since behaves correctly when passed a Duration. Closes #11527 [kemiller] - -* Add #getutc alias for DateTime#utc [Geoff Buesing] - -* Refactor TimeWithZone: don't send #since, #ago, #+, #-, #advance through method_missing [Geoff Buesing] - -* TimeWithZone respects config.active_support.use_standard_json_time_format [Geoff Buesing] - -* Add config.active_support.escape_html_entities_in_json to allow disabling of html entity escaping. [Rick Olson] - -* Improve documentation. [Xavier Noria] - -* Modified ActiveSupport::Callbacks::Callback#call to accept multiple arguments. - -* Time #yesterday and #tomorrow behave correctly crossing DST boundary. Closes #7399 [sblackstone] - -* TimeWithZone: Adding tests for dst and leap day edge cases when advancing time [Geoff Buesing] - -* TimeWithZone#method_missing: send to utc to advance with dst correctness, otherwise send to time. Adding tests for time calculations methods [Geoff Buesing] - -* Add config.active_support.use_standard_json_time_format setting so that Times and Dates export to ISO 8601 dates. [Rick Olson] - -* TZInfo: Removing unneeded TimezoneProxy class [Geoff Buesing] - -* TZInfo: Removing unneeded TimezoneIndexDefinition, since we're not including Indexes::Timezones [Geoff Buesing] - -* Removing unnecessary uses_tzinfo helper from tests, given that TZInfo is now bundled [Geoff Buesing] - -* Bundling abbreviated version of TZInfo gem 0.3.8: only the classes and zone definitions required to support Rails time zone features are included. If a recent version of the full TZInfo gem is installed, this will take precedence over the bundled version [Geoff Buesing] - -* TimeWithZone#marshal_load does zone lookup via Time.get_zone, so that tzinfo/Olson identifiers are handled [Geoff Buesing] - -* Time.zone= accepts TZInfo::Timezone instances and Olson identifiers; wraps result in TimeZone instance [Geoff Buesing] - -* TimeWithZone time conversions don't need to be wrapped in TimeOrDateTime, because TZInfo does this internally [Geoff Buesing] - -* TimeWithZone#usec returns 0 instead of error when DateTime is wrapped [Geoff Buesing] - -* Improve documentation. [Ryan Bigg, Jan De Poorter, Cheah Chu Yeow, Xavier Shay, Jack Danger Canty, Emilio Tagua, Xavier Noria, Sunny Ripert] - -* Ensure that TimeWithZone#to_yaml works when passed a YAML::Emitter. [Rick Olson] - -* Ensure correct TimeWithZone#to_date [Geoff Buesing] - -* Make TimeWithZone work with tzinfo 0.2.x: use TZInfo::Timezone#zone_identifier alias for #abbreviation, silence warnings on tests. Raise LoadError when TZInfo version is < 0.2 by sniffing for TZInfo::TimeOrDateTime constant. Move all tzinfo-dependent TimeZone tests into uses_tzinfo block [Geoff Buesing] - -* Time, DateTime and TimeWithZone #in_time_zone defaults to Time.zone. Removing now unneeded #in_current_time_zone [Geoff Buesing] - -* TZInfo caches Timezone instances in its own internal hash cache, so TimeZone::MAPPING doesn't need to cache them as well [Geoff Buesing] - -* Adding TimeZone#parse [Geoff Buesing] - -* Adding TimeZone#at and DateTime#to_f [Geoff Buesing] - -* TimeWithZone responds to Ruby 1.9 weekday-named query methods [Geoff Buesing] - -* TimeWithZone caches TZInfo::TimezonePeriod used for time conversion so that it can be reused, and enforces DST rules correctly when instance is created from a local time [Geoff Buesing] - -* Fixed that BufferedLogger should create its own directory if one doesn't already exist #11285 [lotswholetime] - -* Fix Numeric time tests broken by DST change by anchoring them to fixed times instead of Time.now. Anchor TimeZone#now DST test to time specified with Time.at instead of Time.local to work around platform differences with Time.local and DST representation [Geoff Buesing] - -* Removing unneeded #change_time_zone method from Time, DateTime and TimeWithZone [Geoff Buesing] - -* TimeZone #local and #now correctly enforce DST rules [Geoff Buesing] - -* TimeWithZone instances correctly enforce DST rules. Adding TimeZone#period_for_utc [Geoff Buesing] - -* test_time_with_datetime_fallback expects DateTime.local_offset instead of DateTime.now.offset [Geoff Buesing] - -* Adding TimeWithZone #marshal_dump and #marshal_load [Geoff Buesing] - -* Add OrderedHash#to_hash [Josh Peek] - -* Adding Time#end_of_day, _quarter, _week, and _year. #9312 [Juanjo Bazan, Tarmo Tänav, BigTitus] - -* Adding TimeWithZone#between? [Geoff Buesing] - -* Time.=== returns true for TimeWithZone instances [Geoff Buesing] - -* TimeWithZone #+ and #- behave consistently with numeric arguments regardless of whether wrapped time is a Time or DateTime; consistenty answers false to #acts_like?(:date) [Geoff Buesing] - -* Add String#squish and String#squish! to remove consecutive chunks of whitespace. #11123 [Jordi Bunster, Henrik N] - -* Serialize BigDecimals as Floats when using to_yaml. #8746 [Ernesto Jimenez] - -* Adding TimeWithZone #to_yaml, #to_datetime, #eql? and method aliases for duck-typing compatibility with Time [Geoff Buesing] - -* TimeWithZone #in_time_zone returns +self+ if zone argument is the same as #time_zone [Geoff Buesing] - -* Adding TimeWithZone #to_a, #to_f, #to_i, #httpdate, #rfc2822 [Geoff Buesing] - -* Pruning unneeded TimeWithZone#change_time_zone_to_current [Geoff Buesing] - -* Time#zone=, #in_time_zone and #change_time_zone accept a Duration [Geoff Buesing] - -* Time#in_time_zone handles Time.local instances correctly [Geoff Buesing] - -* Pruning unneeded Time#change_time_zone_to_current. Enhanced docs to #change_time_zone to explain the difference between this method and #in_time_zone [Geoff Buesing] - -* TimeZone#new method renamed #local; when used with Time.zone, constructor now reads: Time.zone.local() [Geoff Buesing] - -* Added Base64.encode64s to encode values in base64 without the newlines. This makes the values immediately usable as URL parameters or memcache keys without further processing [David Heinemeier Hansson] - -* Remove :nodoc: entries around the ActiveSupport test/unit assertions. #10946 [dancroak, jamesh] - -* Add Time.zone_default accessor for setting the default time zone. Rails::Configuration.time_zone sets this. #10982 [Geoff Buesing] - -* cache.fetch(key, :force => true) to force a cache miss. [Jeremy Kemper] - -* Support retrieving TimeZones with a Duration. TimeZone[-28800] == TimeZone[-480.minutes]. [Rick Olson] - -* TimeWithZone#- added, so that #- can handle a Time or TimeWithZone argument correctly [Geoff Buesing] - -* with_timezone test helper renamed with_env_tz, to distinguish between setting ENV['TZ'] and setting Time.zone in tests [Geoff Buesing] - -* Time#- coerces TimeWithZone argument to a Time instance so that difference in seconds can be calculated. Closes #10914 [Geoff Buesing, yyyc514] - -* Adding UTC zone to TimeZone; TimeWithZone no longer has to fake UTC zone with nil [Geoff Buesing] - -* Time.get_zone refactored to private method, given that the encapsulated logic is only useful internally [Geoff Buesing] - -* Time.zone uses thread-local variable for thread safety. Adding Time.use_zone, for overriding Time.zone locally inside a block. Removing unneeded Time.zone_reset! [Geoff Buesing] - -* TimeZone#to_s uses UTC rather than GMT; reapplying change that was undone in [8679]. #1689 [Cheah Chu Yeow] - -* Time.days_in_month defaults to current year if no year is supplied as argument #10799 [Radar], uses Date.gregorian_leap? to determine leap year, and uses constant lookup to determine days in month [Geoff Buesing] - -* Adding Time and DateTime #compare_with_coercion, which layers behavior on #<=> so that any combination of Time, DateTime and ActiveSupport::TimeWithZone instances can be chronologically compared [Geoff Buesing] - -* TimeZone#now returns an ActiveSupport::TimeWithZone [Geoff Buesing] - -* Time #in_current_time_zone and #change_time_zone_to_current return self when Time.zone is nil [Geoff Buesing] - -* Remove unneeded #to_datetime_default_s alias for DateTime#to_s, given that we inherit a #to_default_s from Date that does exactly the same thing [Geoff Buesing] - -* Refactor Time and DateTime #to_formatted_s: use ternary instead of nested if/else [Geoff Buesing] - -* Adding Time and DateTime #formatted_offset, for outputting +HH:MM utc offset strings with cross-platform consistency [Geoff Buesing] - -* Adding alternate_utc_string option to TimeZone#formatted_offset. Removing unneeded TimeZone#offset. [Geoff Buesing] - -* Introduce ActiveSupport::TimeWithZone, for wrapping Time instances with a TimeZone. Introduce instance methods to Time for creating TimeWithZone instances, and class methods for managing a global time zone. [Geoff Buesing] - -* Replace non-dst-aware TimeZone class with dst-aware class from tzinfo_timezone plugin. TimeZone#adjust and #unadjust are no longer available; tzinfo gem must now be present in order to perform time zone calculations, via #local_to_utc and #utc_to_local methods. [Geoff Buesing] - -* Extract ActiveSupport::Callbacks from Active Record, test case setup and teardown, and ActionController::Dispatcher. #10727 [Josh Peek] - -* Introducing DateTime #utc, #utc? and #utc_offset, for duck-typing compatibility with Time. Closes #10002 [Geoff Buesing] - -* Time#to_json uses Numeric#to_utc_offset_s to output a cross-platform-consistent representation without having to convert to DateTime. References #9750 [Geoff Buesing] - -* Refactor number-to-HH:MM-string conversion logic from TimeZone#formatted_offset to a reusable Numeric#to_utc_offset_s method. [Geoff Buesing] - -* Continue evolution toward ActiveSupport::TestCase. #10679 [Josh Peek] - -* TestCase: introduce declared setup and teardown callbacks. Pass a list of methods and an optional block to call before setup or after teardown. Setup callbacks are run in the order declared; teardown callbacks are run in reverse. [Jeremy Kemper] - -* Added ActiveSupport::Gzip.decompress/compress(source) as an easy wrapper for Zlib [Tobias Lütke] - -* Included MemCache-Client to make the improved ActiveSupport::Cache::MemCacheStore work out of the box [Bob Cottrell, Eric Hodel] - -* Added ActiveSupport::Cache::* framework as an extraction from ActionController::Caching::Fragments::* [David Heinemeier Hansson] - -* Fixed String#titleize to work for strings with 's too #10571 [trek] - -* Changed the implementation of Enumerable#group_by to use a double array approach instead of a hash such that the insert order is honored [David Heinemeier Hansson/Marcel Molina Jr.] - -* remove multiple enumerations from ActiveSupport::JSON#convert_json_to_yaml when dealing with date/time values. [Rick Olson] - -* Hash#symbolize_keys skips keys that can't be symbolized. #10500 [Brad Greenlee] - -* Ruby 1.9 compatibility. #1689, #10466, #10468, #10554, #10594, #10632 [Cheah Chu Yeow, Pratik Naik, Jeremy Kemper, Dirkjan Bussink, Xavier Noria] - -* TimeZone#to_s uses UTC rather than GMT. #1689 [Cheah Chu Yeow] - -* Refactor of Hash#symbolize_keys! to use Hash#replace. Closes #10420 [ReinH] - -* Fix HashWithIndifferentAccess#to_options! so it doesn't clear the options hash. Closes #10419 [ReinH] - - -*2.0.1* (December 7th, 2007) - -* Added Array#from and Array#to that behaves just from String#from and String#to [David Heinemeier Hansson] - -* Fix that empty collections should be treated as empty arrays regardless of whitespace for Hash#from_xml #10255 [adamj] - -* Time#time_with_datetime_fallback, Time#to_datetime, Date#to_datetime and String#to_datetime honor Ruby's default calendar reform setting. #10201 [Geoff Buesing] - -* Change Time and DateTime #end_of_month to return last second of month instead of beginning of last day of month. Closes #10200 [Geoff Buesing] - -* Speedup String#blank? [Jeremy Kemper, Michael Koziarski] - -* Add documentation for Hash#diff. Closes #9306 [Tarmo Tänav] - -* Add new superclass_delegating_accessors. Similar to class inheritable attributes but with subtly different semantics. [Michael Koziarski, Tarmo Tänav] - -* Change JSON to encode %w(< > &) as 4 digit hex codes to be in compliance with the JSON spec. Closes #9975 [Josh Peek, Cheah Chu Yeow, Tim Pope] - -* Fix JSON encoding/decoding bugs dealing with /'s. Closes #9990 [Rick Olson, theamazingrando] - -* Introduce a base class for all test cases used by rails applications. ActiveSupport::TestCase [Michael Koziarski] - - The intention is to use this to reduce the amount of monkeypatching / overriding that - is done to test/unit's classes. - -* Document Enumerable and Hash #to_json. #9970 [Cheah Chu Yeow] - -* Hash#to_xml handles symbol values. #9954 [Assaf] - -* Hash#symbolize_keys behaves well with integer keys. #9890 [PotatoSalad] - -* Multibyte: String#slice supports regexp argument. #9646 [yob] - -* object.duplicable? returns true if object.dup is safe. False for nil, true, false, symbols, and numbers; true otherwise. #9333 [sur] - -* Time, Date and DateTime #advance accept :weeks option. #9866 [Geoff Buesing] - -* Fix Time#years_ago and #years_since from leap days. #9865 [Geoff Buesing] - -* Time and DateTime#advance accept :hours, :minutes, and :seconds options. #9825 [Geoff Buesing] - -* Fix Date#years_ago and #years_since from leap days. #9864 [Geoff Buesing] - -* Refactor Time and Date#months_since and #months_ago to use #advance. #9863 [Geoff Buesing] - -* Rebundle Builder 2.1.2 but prefer a newer RubyGem if available. [Jeremy Kemper] - -* Add Range#overlaps?(range), Range#include?(range), and Range#step without a block. [brandon] - -* Correct BufferedLogger#level? checks. #9806 [wildchild, Johan Sorensen] - -* String#to_xs uses Eric Wong's fast_xs extension, if available, for Builder speedup. http://bogomips.org/fast_xs/ [Jeremy Kemper] - -* Introduce BasicObject as Builder::BlankSlate for Ruby 1.9 forward compatibility. [Jeremy Kemper] - -* Unbundle Builder in favor of a gem dependency. [Jeremy Kemper] - -* Disambiguate Time, Date, and DateTime#to_json formatting. #9750 [Geoff Buesing, Cheah Chu Yeow] - -* Hash#to_json takes :only or :except options to specific or omit certain hash keys. Enumerable#to_json passes through its options to each element. #9751 [Cheah Chu Yeow] - -* BufferedLogger#auto_flushing = N flushes the log every N messages. Buffers with an array instead of string. Disabling auto_flushing still flushes when the buffer hits a maximum size, as a failsafe against memory-gobbling. [Jeremy Kemper] - -* Fixed Date#xmlschema for dates outside the range of what can be created with Time #9744 [Geoff Buesing] - -* Fixed that La Paz was included in -25200 and -14400 offsets when it should only be in -14400 #9735 [bermi] - -* Fixed JSON encoding to use quoted keys according to the JSON standard. #8762 [choonkat, Cheah Chu Yeow] - -* Alias Object#send to send! for Ruby 1.9 forward compatibility. [Jeremy Kemper] - -* Backport Object#instance_variable_defined? for Ruby < 1.8.6. [Jeremy Kemper] - -* BufferedLogger#add converts the message to a string. #9702, #9724 [eigentone, DrMark, Tom Ward] - -* Added ActiveSupport::BufferedLogger as a duck-typing alternative (albeit with no formatter) to the Ruby Logger, which provides a very nice speed bump (inspired by Ezra's buffered logger) [David Heinemeier Hansson] - -* Object#instance_exec produces fewer garbage methods. [Mauricio Fernandez] - -* Decode json strings as Dates/Times if they're using a YAML-compatible format. Closes #9614 [Rick Olson] - -* Fixed cache_page to use the request url instead of the routing options when picking a save path. #8614 [Josh Peek] - -* Object.subclasses_of includes anonymous subclasses. [Jeremy Kemper] - -* Fixed that pluralizing an empty string should return the same empty string, not "s". #7720 [Josh Peek] - -* Added call to inspect on non-string classes for the logger #8533 [Coda Hale] - -* Deprecation: remove deprecated :mday option from Time, Date, and DateTime#change. [Jeremy Kemper] - -* Fix JSON decoder with nested quotes and commas. #9579 [Zach Dennis] - -* Hash#to_xml doesn't double-unescape. #8806 [Ezran] - -* Added Array#rand #9170 [Norbert Crombach]. Examples: - - [].rand # => nil - ['a'].rand # => 'a' - [1,2,3].rand # => 1 or 2 or 3 - -* Deprecation: removed Reloadable. [Jeremy Kemper] - -* Make the utf-handler return the correct value for non-matching regular expressions. Closes #9049 [Manfred Stienstra] - -* Add ljust, rjust and center to utf8-handler. Closes #9165 [Manfred Stienstra] - -* Fix Time#advance bug when trying to advance a year from leap day. Closes #8655 [Geoff Buesing] - -* Add support for []= on ActiveSupport::Multibyte::Chars. Closes #9142. [ewan, Manfred Stienstra] - -* Added Array#extract_options! to encapsulate the pattern of getting an options hash out of a variable number of parameters. #8759 [Norbert Crombach] - -* Let alias_attribute work with attributes with initial capital letters (legacy columns etc). Closes #8596 [mpalmer] - -* Added Hash#except which is the inverse of Hash#slice -- return the hash except the keys that are specified [David Heinemeier Hansson] - -* Added support for pluralization with a different starting letter than the singular version (cow/kine) #4929 [norri_b/Josh Susser] - -* Demote Hash#to_xml to use XmlSimple#xml_in_string so it can't read files or stdin. #8453 [candlerb, Jeremy Kemper] - -* Backport clean_logger changes to support ruby 1.8.2 [Mislav Marohnić] - -* Added proper handling of arrays #8537 [Josh Susser] - - Before: - Hash.from_xml '<images></images>' - # => {:images => nil} - - Hash.from_xml '<images><image>foo.jpg</image></images>' - # => {:images => {:image => "foo.jpg"}} - - Hash.from_xml '<images><image>foo.jpg</image><image>bar.jpg</image></images>' - # => {:images => {:image => ["foo.jpg", "bar.jpg"]}} - - After: - Hash.from_xml '<images type="array"></images>' - # => {:images => []} - - Hash.from_xml '<images type="array"><image>foo.jpg</image></images>' - # => {:images => ["foo.jpg"]} - - Hash.from_xml '<images type="array"><image>foo.jpg</image><image>bar.jpg</image></images>' - # => {:images => ["foo.jpg", "bar.jpg"]} - -* Improve Time and Date test coverage. #8646 [Josh Peek] - -* Add Date#since, ago, beginning_of_day, and end_of_day. Date + seconds works now. #8575 [Geoff Buesing] - -* String#to_time overflows to DateTime. Add String#to_datetime. #8572 [Geoff Buesing] - -* Date.yesterday and .tomorrow. #8571 [Geoff Buesing] - -* Readable Date and DateTime#inspect. #8570 [Geoff Buesing] - -* Move common DateTime calculations to Date. #8536 [Geoff Buesing] - -* Added Date#change (like Time#change) [David Heinemeier Hansson] - -* DateTime#to_time converts to Time unless out of range. #8512 [Geoff Buesing] - -* Date#to_datetime, #to_s(:rfc822). #8512 [Geoff Buesing] - -* Time durations use since instead of + for accuracy. #8513 [Geoff Buesing] - -* escape <'s and >'s in JSON strings. #8371 [Rick Olson] - -* Inflections: MatrixTest -> MatrixTests instead of MatricesTest. #8496 [jbwiv] - -* Multibyte strings respond_to the String methods they proxy so they can be duck-typed. #6549 [Tuxie] - -* Array#to_xml yields the builder just like Hash and ActiveRecord::Base. #8472 [seth] - -* Date, Time, and DateTime support formatting blocks in addition to strftime strings. Introduce :long_ordinal format, e.g. "February 21st, 2005". #8191 [Coda Hale] - -* Document Object#blank?. #6491 [Chris Mear] - -* Date, Time, and DateTime#to_json. #8399 [wycats] - -* Simplify API of assert_difference by passing in an expression that is evaluated before and after the passed in block. See documenation for examples of new API. [Marcel Molina Jr.] - -* Added assert_difference and assert_no_difference to test/unit assertions [Tobias Lütke] - -* Removed breakpointer and Binding.of_caller in favor of relying on ruby-debug by Kent Sibilev since the breakpointer has been broken since Ruby 1.8.4 and will not be coming back [David Heinemeier Hansson] - -* Added parsing of file type in Hash.xml_in so you can easily do file uploads with base64 from an API [David Heinemeier Hansson] - - <person> - <name>David</name> - <avatar type="file" name="me.jpg" content_type="image/jpg">R0lGODlhkACZAPUAAM5lcfjrtMQCG=\n</avatar> - </person> - - ...becomes: - - attributes = { :person => { :name => "David", :avatar => #<StringIO> } } - attributes[:person][:avatar].content_type # => "image/jpg" - attributes[:person][:avatar].original_filename # => "me.jpg" - attributes[:person][:avatar].read # => binary data of the file - - Which is duck-type compatible with the files that you get when doing multipart uploads through HTML. - -* Improved multibyte performance by relying less on exception raising #8159 [Blaine] - -* Use XSD-compatible type names for Hash#to_xml and make the converters extendable #8047 [Tim Pope] - -* Added yielding of builder in Hash#to_xml [David Heinemeier Hansson] - -* Hash#with_indifferent_access now also converts hashes kept in arrays to indifferent access (makes it easier to treat HTML and XML parameters the same) [David Heinemeier Hansson] - -* Hash#to_xml supports YAML attributes. #7502 [jonathan] - -* Refactor ActiveSupport::JSON to be less obtuse. Add support for JSON decoding by way of Syck with ActiveSupport::JSON.decode(json_string). Prevent hash keys that are JavaScript reserved words from being unquoted during encoding. [Sam Stephenson] - -* alias_method_chain preserves the original method's visibility. #7854 [Jonathan Viney] - -* Update Dependencies to ignore constants inherited from ancestors. Closes #6951. [Nicholas Seckar] - -* Array#to_query preserves its ordering. #7756 [Greg Spurrier] - -* Out-of-range Time calculations transparently overflow to DateTime. Introduce Time#to_datetime. #7706, #7715 [Geoff Buesing] - -* DateTime calculations analogous to the Date and Time extensions. #7693 [Geoff Buesing] - -* Give DateTime correct .to_s implementations, lets it play nice with ActiveRecord quoting. #7649 [Geoff Buesing] - -* Add File.atomic_write, allows you to write large files in an atomic manner, preventing users from seeing half written files. [Michael Koziarski] - -* Allow users to provide custom formatters to Logger. [Anthony Eden] - -* Hash#to_query CGI-escapes its keys. [Jeremy Kemper] - -* Optimize Class Inheritable Attributes so that unnecessary hashes are not created. Closes #7472 [Bruce Perens] - -* :db format for Date#to_s [Jeremy Kemper] - Date.new(2007, 1, 27).to_s(:db) # => '2007-01-27' - -* Added :instance_writer option to #mattr_writer/accessor, #cattr_writer/accessor, and #class_inheritable_writer to skip the creation of the instance writer. [Rick Olson] - -* Added Hash#to_query to turn a hash of values into a form-encoded query string [Nicholas Seckar] - -* Increase test coverage for subclasses_of. Closes #7335. [Roman2K, Nicholas Seckar] - -* Remove unused code from Duration#inspect. Closes #7180. [Rich Collins] - -* Added test coverage for Inflector.inflections.clear. Closes #7179. [Rich Collins] - -* ActiveSupport::Multibyte::Handlers::UTF8Handler should raise when a range and an integer are passed in (just like the native implementation). Closes #7176 [Rich Collins] - -* A couple extra tests for #classify. Closes #7273. [Josh Susser] - -* Better docs for Object extensions [zackchandler, Jamis Buck] - -* Fix that Dates couldn't be subtracted from Dates after [5940]. [Sam Stephenson] - -* Add Object#acts_like? and Time#acts_like_time? and Date#acts_like_date? to facilitate duck-typing. [Jamis Buck] - -* Make 1.months and friends accurate by introducing a Duration class. #6835 [eventualbuddha] - - -*1.4.2* (March 12th, 2007) - -* Ruby 1.8.6 and 1.9 define private Time#to_date and #to_datetime; make them -public for compatibility. [Jeremy Kemper] - -* Deprecation: warn on stderr if RAILS_DEFAULT_LOGGER isn't set yet. [Jeremy Kemper] - - -*1.4.1* (February 5th, 2007) - -* Optimize Class Inheritable Attributes so that unnecessary hashes are not created. Closes #7472 [Bruce Perens] - -* Added :instance_writer option to #mattr_writer/accessor, #cattr_writer/accessor, and #class_inheritable_writer to skip the creation of the instance writer. [Rick Olson] - -* Full test coverage for Inflector. #7228 [Dan Kubb] - - -*1.4.0* (January 16th, 2007) - -* Document Inflector.ordinalize and merge docs from String inflections. #7023 [smeade] - -* Unbundle flexmock. [Jeremy Kemper] - -* Fix Dependencies.autoloaded? to ignore anonymous modules. Closes #6561. [Nicholas Seckar] - -* Update load once paths to prevent nested once constants from being detected and claimed by an external non-once load. [Nicholas Seckar] - -* Deprecation: silence warnings when reporting test errors. [Jeremy Kemper] - -* Hash#slice(*keys) returns a new hash with only the given keys. #slice! replaces the hash with only the given keys. Works with HashWithIndifferentAccess also. [Jeremy Kemper] - -* HashWithIndifferentAccess#to_hash converts to a Hash with String keys and the same default value. [Jeremy Kemper] - -* Fix remove_constant to correctly handle constant names of the form "::A::...". References #6720. [Nicholas Seckar] - -* Fixed Array#to_xml when it contains a series of hashes (each piece would get its own XML declaration) #6610 [thkarcher/cyu] - -* Added Time#to_s(:time) which will just return H:M, like 17:44 [David Heinemeier Hansson] - -* Add Module#attr_accessor_with_default to initialize value of attribute before setting it. Closes #6538. [Stuart Halloway, Marcel Molina Jr.] - -* Hash#to_xml handles keys with the same name as Kernel methods. #6613 [Jonathan del Strother] - -* Added Time#end_of_day to get 23:59:59 of that day [David Heinemeier Hansson] - -* Don't quote hash keys in Hash#to_json if they're valid JavaScript identifiers. Disable this with ActiveSupport::JSON.unquote_hash_key_identifiers = false if you need strict JSON compliance. [Sam Stephenson] - -* Lazily load the Unicode Database in the UTF-8 Handler [Rick Olson] - -* Update dependencies to delete partially loaded constants. [Nicholas Seckar] - -* Fix unicode JSON regexp for Onigurama compatibility. #6494 [whitley] - -* update XmlSimple to 1.0.10. Closes #6532. [Nick Sieger] - -* Update dependencies to allow constants to be defined alongside their siblings. A common case for this is AR model classes with STI; user.rb might define User, Administrator and Guest for example. [Nicholas Seckar] - -* next_week respects DST changes. #6483, #5617, #2353, #2509, #4551 [marclove, Rob Biedenharn, rails@roetzel.de, jsolson@damogran.org, drbrain@segment7.net] - -* Expose methods added to Enumerable in the documentation, such as group_by. Closes #6170. [sergeykojin@gmail.com, Marcel Molina Jr.] - -* Ensure Chars#tidy_bytes only tidies broken bytes. Closes #6397 [Manfred Stienstra] - -* Add 'unloadable', a method used to mark any constant as requiring an unload after each request. [Nicholas Seckar] - -* Make core_ext/string/access.rb multibyte safe. Closes #6388 [Manfred Stienstra] - -* Make String#chars slicing behaviour consistent with String. Closes #6387 [Manfred Stienstra] - -* Pull in latest multibyte patch. Closes #6346 [Manfred Stienstra] - -* Add ActiveSupport::Multibyte. Provides String#chars which lets you deal with strings as a sequence of chars, not of bytes. Closes #6242 [Julian Tarkhanov, Manfred Stienstra, Thijs van der Vossen & Jan Behrens] - -* Fix issue with #class_inheritable_accessor saving updates to the parent class when initialized with an Array or Hash [mojombo] - -* Hash#to_xml supports Bignum and BigDecimal. #6313 [edibiase] - -* Don't undefine #class in OptionMerger [Rick Olson] - -* Hash.create_from_xml has been renamed to Hash.from_xml, alias will exist until Rails 2.0 [David Heinemeier Hansson] - -* alias_method_chain works with accessor= methods also. #6153 [Caio Chassot] - -* Fix loadable_constants_for_path to handle load paths that do not end with a slash. [Nicholas Seckar] - -* Fix logic error in determining what was loaded by a given file. Closes #6039. [Nicholas Seckar] - -* Equate Kernel.const_missing with Object.const_missing. Fixes #5988. [Nicholas Seckar] - -* Add ApplicationController special case to Dependencies. [Nicholas Seckar] - -* Don't pad remaining places with in_groups_of if specified padding value is false. [Marcel Molina Jr.] - -* Fix cases where empty xml nodes weren't being translated to nil in Hash.create_from_xml [Rick Olso n] - - <written-on type="date"></written-on> # => { :type => 'date' } # WRONG - <written-on type="date"></written-on> # => nil # RIGHT - -* Tighten rescue clauses. #5985 [james@grayproductions.net] - -* Inflections: don't singularize -ies plurals. [foamdino@gmail.com, Mark Van Holstyn] - -* Update Initializer to use load_once_paths to avoid plugin reloading. References #5852. [Nicholas Seckar] - -* Use Array#assoc in ActiveSupport::OrderedHash. [Mauricio Fernandez] - -* Greatly increased performance of String.to_json, which speeds up RJS considerably on large pages, fixes #3473 [Shugo Maeda] - -* Detect missing_constants calls from removed modules and fail accordingly. [Nicholas Seckar] - -* Stop using defined? in Dependencies.qualified_const_defined? since defined? may invoke const_missing. [Nicholas Seckar] - -* Dependencies can autoload directories of nested classes. [Jeremy Kemper] - Example: - invoice.rb class Invoice - invoice/lineitem.rb class Invoice::Lineitem - -* Add Deprecation.silence so that Reloadable does not scold itself. [Nicholas Seckar] - -* Add debugging logging to Dependencies. Currently can be enabled with Dependencies.log_activity = true; adding to Initializer and documenting is forthcoming. [Nicholas Seckar] - -* Replace Reloadable with improvements to the Dependencies mechanism. [Nicholas Seckar] - -* DateTime#to_time gives hour/minute/second resolution. #5747 [jon.evans@pobox.com] - -* attr_internal to support namespacing and deprecation. Like attr_* except backed by internally-named instance variable. Set attr_internal_naming_format to change the format from the default '@_%s'. [Jeremy Kemper] - # def foo() @foo__rofl end - # def foo=(v) @foo__rofl = v end - self.attr_internal_naming_format = '@%s__rofl' - attr_internal :foo - -* Raise fully qualified names upon name errors. #5533 [Lars Pind, Nicholas Seckar] - -* Add extention to obtain the missing constant from NameError instances. [Nicholas Seckar] - -* Thoroughly document inflections. #5700 [petermichaux@gmail.com] - -* Added Module#alias_attribute [Jamis/David Heinemeier Hansson]. Example: - - class Content < ActiveRecord::Base - # has a title attribute - end - - class Email < ActiveRecord::Base - alias_attribute :subject, :title - end - - e = Email.find(1) - e.title # => "Superstars" - e.subject # => "Superstars" - e.subject? # => true - e.subject = "Megastars" - e.title # => "Megastars" - -* Deprecation: easier to work with warning behavior as procs; default behaviors for each environment so users needn't update env.rb; and testing pleasure with assert_deprecated, assert_not_deprecated. [Jeremy Kemper] - By default, test prints to $stderr, dev logs, production ignores. - Provide your own per-environment in e.g. config/environments/development.rb: - ActiveSupport::Deprecation.behavior = Proc.new { |message| raise message } - -* First cut of the Rails Deprecation system. [Michael Koziarski] - -* Strip boolean XML content before checking for 'true' [Rick Olson] - -* Customize default BigDecimal formatting. References #5672 [Dave Thomas] - -* Correctly convert <foo nil="true"> to nil when using Hash.create_from_xml. [Rick Olson] - -* Optional identity for Enumerable#sum defaults to zero. #5657 [gensym@mac.com] - -* HashWithIndifferentAccess shouldn't confuse false and nil. #5601 [Shugo Maeda] - -* Fixed HashWithIndifferentAccess#default #5586 [chris@seagul.co.uk] - -* More compatible Hash.create_from_xml. #5523 [nunemaker@gmail.com] - -* Added Enumerable#sum for calculating a sum from the elements [David Heinemeier Hansson, jonathan@daikini.com]. Examples: - - [1, 2, 3].sum - payments.sum { |p| p.price * p.tax_rate } - payments.sum(&:price) - - This is instead of payments.inject(0) { |sum, p| sum + p.price } - -* Correct and clarify Array#to_sentence docs. #5458 [brad@madriska.com] - -* alias_method_chain preserves method punctuation so foo, foo?, and foo! may be chained with the same feature. [Jeremy Kemper] - Example: - alias_method_chain :save!, :validation - is equivalent to - alias_method :save_without_validation!, :save! - alias_method :save!, :save_with_validation! - -* Enhance Symbol#to_proc so it works with list objects, such as multi-dimensional arrays. Closes #5295 [nov@yo.rim.or.jp]. Example: - - {1 => "one", 2 => "two", 3 => "three"}.sort_by(&:first).map(&:last) - #=> ["one", "two", "three"] - -* Added Hash.create_from_xml(string) which will create a hash from a XML string and even typecast if possible [David Heinemeier Hansson]. Example: - - Hash.create_from_xml <<-EOT - <note> - <title>This is a note</title> - <created-at type="date">2004-10-10</created-at> - </note> - EOT - - ...would return: - - { :note => { :title => "This is a note", :created_at => Date.new(2004, 10, 10) } } - -* Added Jim Weirich's excellent FlexMock class to vendor (Copyright 2003, 2004 by Jim Weirich (jim@weriichhouse.org)) -- it's not automatically required, though, so require 'flexmock' is still necessary [David Heinemeier Hansson] - -* Fixed that Module#alias_method_chain should work with both foo? foo! and foo at the same time #4954 [anna@wota.jp] - -* to_xml fixes, features, and speedup: introduce :dasherize option that converts updated_at to updated-at if true (the existing default); binary columns get encoding="base64" attribute; nil values get nil="true" attribute to distinguish empty values; add type information for float columns; allow arbitrarily deep :include; include SQL type information as the type attribute. #4989 [Blair Zajac <blair@orcaware.com>] - -* Add OrderedHash#values. [Sam Stephenson] - -* Added Array#to_s(:db) that'll produce a comma-separated list of ids [David Heinemeier Hansson]. Example: - - Purchase.find(:all, :conditions => "product_id IN (#{shops.products.to_s(:db)})" - -* Normalize classify's argument to a String so that it plays nice with Symbols. [Marcel Molina Jr.] - -* Strip out leading schema name in classify. References #5139. [Michael Schoen] - -* Remove Enumerable#first_match since break(value) handles the use case well enough. [Nicholas Seckar] - - Enumerable#first_match was like detect, but instead of returning the matching element, the yielded value returned. For example: - - user_xml = adapters(:from => User, :to => Xml).first_match do |adapter| - adapter.adapt @user - end - - But this is just as easily done with: - - user_xml = adapters(:from => User, :to => Xml).each do - break adapter.adapt(@user) - end - -* Make Array#in_groups_of just return the grouped collection if a block isn't given. [Marcel Molina Jr.] - -* Don't destroy a HashWithIndifferentAccess if symbolize_keys! or stringify_keys! is called on it. Closes #5076. [Marcel Molina Jr., guy.naor@famundo.com] - -* Document Module::delegate. #5002 [pergesu@gmail.com] - -* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.] - -* Strip out punctuation on predicates or bang methods being aliased with alias_method_chain since target?_without_feature is not a valid method name. Add tests for Module#alias_method_chain. [Marcel Molina Jr.] - -* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.] - -* Allow default options in with_options to be overridden. Closes #4480. [murphy@cYcnus.de] - -* Added Module#alias_method_chain [Jamis Buck] - -* Updated to Builder 2.0 [David Heinemeier Hansson] - -* Add Array#split for dividing arrays into one or more subarrays by value or block. [Sam Stephenson] - -*1.3.1* (April 6th, 2006) - -* Clean paths inside of exception messages and traces. [Nicholas Seckar] - -* Add Pathname.clean_within for cleaning all the paths inside of a string. [Nicholas Seckar] - -* provide an empty Dependencies::LoadingModule.load which prints deprecation warnings. Lets 1.0 applications function with .13-style environment.rb. - - -*1.3.0* (March 27th, 2006) - -* When possible, avoid incorrectly obtaining constants from parent modules. Fixes #4221. [Nicholas Seckar] - -* Add more tests for dependencies; refactor existing cases. [Nicholas Seckar] - -* Move Module#parent and Module#as_load_path into core_ext. Add Module#parent. [Nicholas Seckar] - -* Add CachingTools::HashCaching to simplify the creation of nested, autofilling hashes. [Nicholas Seckar] - -* Remove a hack intended to avoid unloading the same class twice, but which would not work anyways. [Nicholas Seckar] - -* Update Object.subclasses_of to locate nested classes. This affects Object.remove_subclasses_of in that nested classes will now be unloaded. [Nicholas Seckar] - -* Update Object.remove_subclasses_of to use Class.remove_class, reducing duplication. [Nicholas Seckar] - -* Added Fixnum#seconds for consistency, so you can say 5.minutes + 30.seconds instead of 5.minutes + 30 #4389 [François Beausoleil] - -* Added option to String#camelize to generate lower-cased camel case by passing in :lower, like "super_man".camelize(:lower) # => "superMan" [David Heinemeier Hansson] - -* Added Hash#diff to show the difference between two hashes [Chris McGrath] - -* Added Time#advance to do precise time time calculations for cases where a month being approximated to 30 days won't do #1860 [Rick Olson] - -* Enhance Inflector.underscore to convert '-' into '_' (as the inverse of Inflector.dasherize) [Jamis Buck] - -* Switched to_xml to use the xml schema format for datetimes. This allows the encoding of time zones and should improve operability. [Michael Koziarski] - -* Added a note to the documentation for the Date related Numeric extensions to indicate that they're -approximations and shouldn't be used for critical calculations. [Michael Koziarski] - -* Added Hash#to_xml and Array#to_xml that makes it much easier to produce XML from basic structures [David Heinemeier Hansson]. Examples: - - { :name => "David", :street_name => "Paulina", :age => 26, :moved_on => Date.new(2005, 11, 15) }.to_xml - - ...returns: - - <person> - <street-name>Paulina</street-name> - <name>David</name> - <age type="integer">26</age> - <moved-on type="date">2005-11-15</moved-on> - </person> - -* Moved Jim Weirich's wonderful Builder from Action Pack to Active Support (it's simply too useful to be stuck in AP) [David Heinemeier Hansson] - -* Fixed that Array#to_sentence will return "" on an empty array instead of ", and" #3842, #4031 [rubyonrails@beautifulpixel.com] - -* Add Enumerable#group_by for grouping collections based on the result of some - block. Useful, for example, for grouping records by date. - - ex. - - latest_transcripts.group_by(&:day).each do |day, transcripts| - p "#{day} -> #{transcripts.map(&:class) * ', '}" - end - "2006-03-01 -> Transcript" - "2006-02-28 -> Transcript" - "2006-02-27 -> Transcript, Transcript" - "2006-02-26 -> Transcript, Transcript" - - Add Array#in_groups_of, for iterating over an array in groups of a certain - size. - - ex. - - %w(1 2 3 4 5 6 7).in_groups_of(3) {|g| p g} - ["1", "2", "3"] - ["4", "5", "6"] - ["7", nil, nil] - - [Marcel Molina Jr., Sam Stephenson] - -* Added Kernel#daemonize to turn the current process into a daemon that can be killed with a TERM signal [David Heinemeier Hansson] - -* Add 'around' methods to Logger, to make it easy to log before and after messages for a given block as requested in #3809. [Michael Koziarski] Example: - - logger.around_info("Start rendering component (#{options.inspect}): ", - "\n\nEnd of component rendering") { yield } - -* Added Time#beginning_of_quarter #3607 [cohen.jeff@gmail.com] - -* Fix Object.subclasses_of to only return currently defined objects [Jonathan Viney <jonathan@bluewire.net.nz>] - -* Fix constantize to properly handle names beginning with '::'. [Nicholas Seckar] - -* Make String#last return the string instead of nil when it is shorter than the limit [Scott Barron]. - -* Added delegation support to Module that allows multiple delegations at once (unlike Forwardable in the stdlib) [David Heinemeier Hansson]. Example: - - class Account < ActiveRecord::Base - has_one :subscription - delegate :free?, :paying?, :to => :subscription - delegate :overdue?, :to => "subscription.last_payment" - end - - account.free? # => account.subscription.free? - account.overdue? # => account.subscription.last_payment.overdue? - -* Fix Reloadable to handle the case where a class that has been 'removed' has not yet been garbage collected. [Nicholas Seckar] - -* Don't allow Reloadable to be included into Modules. - -* Remove LoadingModule. [Nicholas Seckar] - -* Add documentation for Reloadable::Subclasses. [Nicholas Seckar] - -* Add Reloadable::Subclasses which handles the common case where a base class should not be reloaded, but its subclasses should be. [Nicholas Seckar] - -* Further improvements to reloading code [Nicholas Seckar, Trevor Squires] - - - All classes/modules which include Reloadable can define reloadable? for fine grained control of reloading - - Class.remove_class uses Module#parent to access the parent module - - Class.remove_class expanded to handle multiple classes in a single call - - LoadingModule.clear! has been removed as it is no longer required - - Module#remove_classes_including has been removed in favor of Reloadable.reloadable_classes - -* Added reusable reloading support through the inclusion of the Relodable module that all subclasses of ActiveRecord::Base, ActiveRecord::Observer, ActiveController::Base, and ActionMailer::Base automatically gets. This means that these classes will be reloaded by the dispatcher when Dependencies.mechanism = :load. You can make your own models reloadable easily: - - class Setting - include Reloadable - end - - Reloading a class is done by removing its constant which will cause it to be loaded again on the next reference. [David Heinemeier Hansson] - -* Added auto-loading support for classes in modules, so Conductor::Migration will look for conductor/migration.rb and Conductor::Database::Settings will look for conductor/database/settings.rb [Nicholas Seckar] - -* Add Object#instance_exec, like instance_eval but passes its arguments to the block. (Active Support will not override the Ruby 1.9 implementation of this method.) [Sam Stephenson] - -* Add Proc#bind(object) for changing a proc or block's self by returning a Method bound to the given object. Based on why the lucky stiff's "cloaker" method. [Sam Stephenson] - -* Fix merge and dup for hashes with indifferent access #3404 [Ken Miller] - -* Fix the requires in option_merger_test to unbreak AS tests. [Sam Stephenson] - -* Make HashWithIndifferentAccess#update behave like Hash#update by returning the hash. #3419, #3425 [asnem@student.ethz.ch, JanPrill@blauton.de, Marcel Molina Jr.] - -* Add ActiveSupport::JSON and Object#to_json for converting Ruby objects to JSON strings. [Sam Stephenson] - -* Add Object#with_options for DRYing up multiple calls to methods having shared options. [Sam Stephenson] Example: - - ActionController::Routing::Routes.draw do |map| - # Account routes - map.with_options(:controller => 'account') do |account| - account.home '', :action => 'dashboard' - account.signup 'signup', :action => 'new' - account.logout 'logout', :action => 'logout' - end - end - -* Introduce Dependencies.warnings_on_first_load setting. If true, enables warnings on first load of a require_dependency. Otherwise, loads without warnings. Disabled (set to false) by default. [Jeremy Kemper] - -* Active Support is warnings-safe. #1792 [Eric Hodel] - -* Introduce enable_warnings counterpart to silence_warnings. Turn warnings on when loading a file for the first time if Dependencies.mechanism == :load. Common mistakes such as redefined methods will print warnings to stderr. [Jeremy Kemper] - -* Add Symbol#to_proc, which allows for, e.g. [:foo, :bar].map(&:to_s). [Marcel Molina Jr.] - -* Added the following methods [Marcel Molina Jr., Sam Stephenson]: - * Object#copy_instance_variables_from(object) to copy instance variables from one object to another - * Object#extended_by to get an instance's included/extended modules - * Object#extend_with_included_modules_from(object) to extend an instance with the modules from another instance - -*1.2.5* (December 13th, 2005) - -* Become part of Rails 1.0 - -* Rename Version constant to VERSION. #2802 [Marcel Molina Jr.] - -*1.2.3* (November 7th, 2005) - -* Change Inflector#constantize to use eval instead of const_get. [Nicholas Seckar] - -* Fix const_missing handler to ignore the trailing '.rb' on files when comparing paths. [Nicholas Seckar] - -* Define kernel.rb methods in "class Object" instead of "module Kernel" to work around a Windows peculiarity [Sam Stephenson] - -* Fix broken tests caused by incomplete loading of active support. [Nicholas Seckar] - -* Fix status pluralization bug so status_codes doesn't get pluralized as statuses_code. #2758 [keithm@infused.org] - -* Added Kernel#silence_stderr to silence stderr for the duration of the given block [Sam Stephenson] - -* Changed Kernel#` to print a message to stderr (like Unix) instead of raising Errno::ENOENT on Win32 [Sam Stephenson] - -* Changed 0.blank? to false rather than true since it violates everyone's expectation of blankness. #2518, #2705 [rails@jeffcole.net] - -* When loading classes using const_missing, raise a NameError if and only if the file we tried to load was not present. [Nicholas Seckar] - -* Added petabytes and exebytes to numeric extensions #2397 [timct@mac.com] - -* Added Time#end_of_month to accompany Time#beginning_of_month #2514 [Jens-Christian Fischer] - - -*1.2.2* (October 26th, 2005) - -* Set Logger.silencer = false to disable Logger#silence. Useful for debugging fixtures. - -* Add title case method to String to do, e.g., 'action_web_service'.titlecase # => 'Action Web Service'. [Marcel Molina Jr.] - - -*1.2.1* (October 19th, 2005) - -* Classify generated routing code as framework code to avoid appearing in application traces. [Nicholas Seckar] - -* Show all framework frames in the framework trace. [Nicholas Seckar] - - -*1.2.0* (October 16th, 2005) - -* Update Exception extension to show the first few framework frames in an application trace. [Nicholas Seckar] - -* Added Exception extension to provide support for clean backtraces. [Nicholas Seckar] - -* Updated whiny nil to be more concise and useful. [Nicholas Seckar] - -* Added Enumerable#first_match [Nicholas Seckar] - -* Fixed that Time#change should also reset usec when also resetting minutes #2459 [ikeda@dream.big.or.jp] - -* Fix Logger compatibility for distributions that don't keep Ruby and its standard library in sync. - -* Replace '%e' from long and short time formats as Windows does not support it. #2344. [Tom Ward <tom@popdog.net>] - -* Added to_s(:db) to Range, so you can get "BETWEEN '2005-12-10' AND '2005-12-12'" from Date.new(2005, 12, 10)..Date.new(2005, 12, 12) (and likewise with Times) - -* Moved require_library_or_gem into Kernel. #1992 [Michael Schuerig <michael@schuerig.de>] - -* Add :rfc822 as an option for Time#to_s (to get rfc822-formatted times) - -* Chain the const_missing hook to any previously existing hook so rails can play nicely with rake - -* Clean logger is compatible with both 1.8.2 and 1.8.3 Logger. #2263 [Michael Schuerig <michael@schuerig.de>] - -* Added native, faster implementations of .blank? for the core types #2286 [skae] - -* Fixed clean logger to work with Ruby 1.8.3 Logger class #2245 - -* Fixed memory leak with Active Record classes when Dependencies.mechanism = :load #1704 [Chris McGrath] - -* Fixed Inflector.underscore for use with acronyms, so HTML becomes html instead of htm_l #2173 [k@v2studio.com] - -* Fixed dependencies related infinite recursion bug when a controller file does not contain a controller class. Closes #1760. [rcolli2@tampabay.rr.com] - -* Fixed inflections for status, quiz, move #2056 [deirdre@deirdre.net] - -* Added Hash#reverse_merge, Hash#reverse_merge!, and Hash#reverse_update to ease the use of default options - -* Added Array#to_sentence that'll turn ['one', 'two', 'three'] into "one, two, and three" #2157 [Manfred Stienstra] - -* Added Kernel#silence_warnings to turn off warnings temporarily for the passed block - -* Added String#starts_with? and String#ends_with? #2118 [Thijs van der Vossen] - -* Added easy extendability to the inflector through Inflector.inflections (using the Inflector::Inflections singleton class). Examples: - - Inflector.inflections do |inflect| - inflect.plural /^(ox)$/i, '\1\2en' - inflect.singular /^(ox)en/i, '\1' - - inflect.irregular 'octopus', 'octopi' - - inflect.uncountable "equipment" - end - -* Added String#at, String#from, String#to, String#first, String#last in ActiveSupport::CoreExtensions::String::Access to ease access to individual characters and substrings in a string serving basically as human names for range access. - -* Make Time#last_month work when invoked on the 31st of a month. - -* Add Time.days_in_month, and make Time#next_month work when invoked on the 31st of a month - -* Fixed that Time#midnight would have a non-zero usec on some platforms #1836 - -* Fixed inflections of "index/indices" #1766 [damn_pepe@gmail.com] - -* Added stripping of _id to String#humanize, so "employee_id" becomes "Employee" #1574 [Justin French] - -* Factor Fixnum and Bignum extensions into Integer extensions [Nicholas Seckar] - -* Hooked #ordinalize into Fixnum and Bignum classes. [Nicholas Seckar, danp] - -* Added Fixnum#ordinalize to turn 1.ordinalize to "1st", 3.ordinalize to "3rd", and 10.ordinalize to "10th" and so on #1724 [paul@cnt.org] - - -*1.1.1* (11 July, 2005) - -* Added more efficient implementation of the development mode reset of classes #1638 [Chris McGrath] - - -*1.1.0* (6 July, 2005) - -* Fixed conflict with Glue gem #1606 [Rick Olson] - -* Added new rules to the Inflector to deal with more unusual plurals mouse/louse => mice/lice, information => information, ox => oxen, virus => viri, archive => archives #1571, #1583, #1490, #1599, #1608 [foamdino@gmail.com/others] - -* Fixed memory leak with Object#remove_subclasses_of, which inflicted a Rails application running in development mode with a ~20KB leak per request #1289 [Chris McGrath] - -* Made 1.year == 365.25.days to account for leap years. This allows you to do User.find(:all, :conditions => ['birthday > ?', 50.years.ago]) without losing a lot of days. #1488 [tuxie@dekadance.se] - -* Added an exception if calling id on nil to WhinyNil #584 [kevin-temp@writesoon.com] - -* Added Fix/Bignum#multiple_of? which returns true on 14.multiple_of?(7) and false on 16.multiple_of?(7) #1464 [Thomas Fuchs] - -* Added even? and odd? to work with Bignums in addition to Fixnums #1464 [Thomas Fuchs] - -* Fixed Time#at_beginning_of_week returned the next Monday instead of the previous one when called on a Sunday #1403 [jean.helou@gmail.com] - -* Increased the speed of indifferent hash access by using Hash#default. #1436 [Nicholas Seckar] - -* Added that " " is now also blank? (using strip if available) - -* Fixed Dependencies so all modules are able to load missing constants #1173 [Nicholas Seckar] - -* Fixed the Inflector to underscore strings containing numbers, so Area51Controller becomes area51_controller #1176 [Nicholas Seckar] - -* Fixed that HashWithIndifferentAccess stringified all keys including symbols, ints, objects, and arrays #1162 [Nicholas Seckar] - -* Fixed Time#last_year to go back in time, not forward #1278 [fabien@odilat.com] - -* Fixed the pluralization of analysis to analyses #1295 [seattle@rootimage.msu.edu] - -* Fixed that Time.local(2005,12).months_since(1) would raise "ArgumentError: argument out of range" #1311 [jhahn@niveon.com] - -* Added silencing to the default Logger class - - -*1.0.4* (19th April, 2005) - -* Fixed that in some circumstances controllers outside of modules may have hidden ones inside modules. For example, admin/content might have been hidden by /content. #1075 [Nicholas Seckar] - -* Fixed inflection of perspectives and similar words #1045 [Thijs van der Vossen] - -* Added Fixnum#even? and Fixnum#odd? - -* Fixed problem with classes being required twice. Object#const_missing now uses require_dependency to load files. It used to use require_or_load which would cause models to be loaded twice, which was not good for validations and other class methods #971 [Nicholas Seckar] - - -*1.0.3* (27th March, 2005) - -* Fixed Inflector.pluralize to handle capitalized words #932 [Jeremy Kemper] - -* Added Object#suppress which allows you to make a saner choice around with exceptions to swallow #980. Example: - - suppress(ZeroDivisionError) { 1/0 } - - ...instead of: - - 1/0 rescue nil # BAD, EVIL, DIRTY. - - -*1.0.2* (22th March, 2005) - -* Added Kernel#returning -- a Ruby-ized realization of the K combinator, courtesy of Mikael Brockman. - - def foo - returning values = [] do - values << 'bar' - values << 'baz' - end - end - - foo # => ['bar', 'baz'] - - -*1.0.1* (7th March, 2005) - -* Fixed Hash#indifferent_access to also deal with include? and fetch and nested hashes #726 [Nicholas Seckar] - -* Added Object#blank? -- see http://redhanded.hobix.com/inspect/objectBlank.html #783 [_why the lucky stiff] - -* Added inflection rules for "sh" words, like "wish" and "fish" #755 [phillip@pjbsoftware.com] - -* Fixed an exception when using Ajax based requests from Safari because Safari appends a \000 to the post body. Symbols can't have \000 in them so indifferent access would throw an exception in the constructor. Indifferent hashes now use strings internally instead. #746 [Tobias Lütke] - -* Added String#to_time and String#to_date for wrapping ParseDate - - -*1.0.0* (24th February, 2005) - -* Added TimeZone as the first of a number of value objects that among others Active Record can use rich value objects using composed_of #688 [Jamis Buck] - -* Added Date::Conversions for getting dates in different convenient string representations and other objects - -* Added Time::Conversions for getting times in different convenient string representations and other objects - -* Added Time::Calculations to ask for things like Time.now.tomorrow, Time.now.yesterday, Time.now.months_ago(4) #580 [DP|Flurin]. Examples: - - "Later today" => now.in(3.hours), - "Tomorrow morning" => now.tomorrow.change(:hour => 9), - "Tomorrow afternoon" => now.tomorrow.change(:hour => 14), - "In a couple of days" => now.tomorrow.tomorrow.change(:hour => 9), - "Next monday" => now.next_week.change(:hour => 9), - "In a month" => now.next_month.change(:hour => 9), - "In 6 months" => now.months_since(6).change(:hour => 9), - "In a year" => now.in(1.year).change(:hour => 9) - -* Upgraded to breakpoint 92 which fixes: - - * overload IRB.parse_opts(), fixes #443 - => breakpoints in tests work even when running them via rake - * untaint handlers, might fix an issue discussed on the Rails ML - * added verbose mode to breakpoint_client - * less noise caused by breakpoint_client by default - * ignored TerminateLineInput exception in signal handler - => quiet exit on Ctrl-C - -* Fixed Inflector for words like "news" and "series" that are the same in plural and singular #603 [echion], #615 [marcenuc] - -* Added Hash#stringify_keys and Hash#stringify_keys! - -* Added IndifferentAccess as a way to wrap a hash by a symbol-based store that also can be accessed by string keys - -* Added Inflector.constantize to turn "Admin::User" into a reference for the constant Admin::User - -* Added that Inflector.camelize and Inflector.underscore can deal with modules like turning "Admin::User" into "admin/user" and back - -* Added Inflector.humanize to turn attribute names like employee_salary into "Employee salary". Used by automated error reporting in AR. - -* Added availability of class inheritable attributes to the masses #477 [Jeremy Kemper] - - class Foo - class_inheritable_reader :read_me - class_inheritable_writer :write_me - class_inheritable_accessor :read_and_write_me - class_inheritable_array :read_and_concat_me - class_inheritable_hash :read_and_update_me - end - - # Bar gets a clone of (not a reference to) Foo's attributes. - class Bar < Foo - end - - Bar.read_and_write_me == Foo.read_and_write_me - Bar.read_and_write_me = 'bar' - Bar.read_and_write_me != Foo.read_and_write_me - -* Added Inflections as an extension on String, so Inflector.pluralize(Inflector.classify(name)) becomes name.classify.pluralize #476 [Jeremy Kemper] - -* Added Byte operations to Numeric, so 5.5.megabytes + 200.kilobytes #461 [Marcel Molina Jr.] - -* Fixed that Dependencies.reload can't load the same file twice #420 [Kent Sibilev] - -* Added Fixnum#ago/until, Fixnum#since/from_now #450 [Jeremy Kemper] - -* Added that Inflector now accepts Symbols and Classes by calling .to_s on the word supplied - -* Added time unit extensions to Fixnum that'll return the period in seconds, like 2.days + 4.hours. diff --git a/vendor/rails/activesupport/README b/vendor/rails/activesupport/README deleted file mode 100644 index 9fb9a80..0000000 --- a/vendor/rails/activesupport/README +++ /dev/null @@ -1,43 +0,0 @@ -= Active Support -- Utility classes and standard library extensions from Rails - -Active Support is a collection of various utility classes and standard library extensions that were found useful -for Rails. All these additions have hence been collected in this bundle as way to gather all that sugar that makes -Ruby sweeter. - - -== Download - -The latest version of Active Support can be found at - -* http://rubyforge.org/project/showfiles.php?group_id=182 - -Documentation can be found at - -* http://as.rubyonrails.com - - -== Installation - -The preferred method of installing Active Support is through its GEM file. You'll need to have -RubyGems[http://rubygems.rubyforge.org/wiki/wiki.pl] installed for that, though. If you have it, -then use: - - % [sudo] gem install activesupport-1.0.0.gem - - -== License - -Active Support is released under the MIT license. - - -== Support - -The Active Support homepage is http://www.rubyonrails.com. You can find the Active Support -RubyForge page at http://rubyforge.org/projects/activesupport. And as Jim from Rake says: - - Feel free to submit commits or feature requests. If you send a patch, - remember to update the corresponding unit tests. If fact, I prefer - new feature to be submitted in the form of new unit tests. - -For other information, feel free to ask on the ruby-talk mailing list -(which is mirrored to comp.lang.ruby) or contact mailto:david@loudthinking.com. diff --git a/vendor/rails/activesupport/lib/active_support.rb b/vendor/rails/activesupport/lib/active_support.rb deleted file mode 100644 index 7ebb3c4..0000000 --- a/vendor/rails/activesupport/lib/active_support.rb +++ /dev/null @@ -1,59 +0,0 @@ -#-- -# Copyright (c) 2005 David Heinemeier Hansson -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ - -module ActiveSupport - def self.load_all! - [Dependencies, Deprecation, Gzip, MessageVerifier, Multibyte, SecureRandom, TimeWithZone] - end - - autoload :BacktraceCleaner, 'active_support/backtrace_cleaner' - autoload :Base64, 'active_support/base64' - autoload :BasicObject, 'active_support/basic_object' - autoload :BufferedLogger, 'active_support/buffered_logger' - autoload :Cache, 'active_support/cache' - autoload :Callbacks, 'active_support/callbacks' - autoload :Deprecation, 'active_support/deprecation' - autoload :Duration, 'active_support/duration' - autoload :Gzip, 'active_support/gzip' - autoload :Inflector, 'active_support/inflector' - autoload :Memoizable, 'active_support/memoizable' - autoload :MessageEncryptor, 'active_support/message_encryptor' - autoload :MessageVerifier, 'active_support/message_verifier' - autoload :Multibyte, 'active_support/multibyte' - autoload :OptionMerger, 'active_support/option_merger' - autoload :OrderedHash, 'active_support/ordered_hash' - autoload :OrderedOptions, 'active_support/ordered_options' - autoload :Rescuable, 'active_support/rescuable' - autoload :SecureRandom, 'active_support/secure_random' - autoload :StringInquirer, 'active_support/string_inquirer' - autoload :TimeWithZone, 'active_support/time_with_zone' - autoload :TimeZone, 'active_support/values/time_zone' - autoload :XmlMini, 'active_support/xml_mini' -end - -require 'active_support/vendor' -require 'active_support/core_ext' -require 'active_support/dependencies' -require 'active_support/json' - -I18n.load_path << "#{File.dirname(__FILE__)}/active_support/locale/en.yml" diff --git a/vendor/rails/activesupport/lib/active_support/backtrace_cleaner.rb b/vendor/rails/activesupport/lib/active_support/backtrace_cleaner.rb deleted file mode 100644 index 0e262c0..0000000 --- a/vendor/rails/activesupport/lib/active_support/backtrace_cleaner.rb +++ /dev/null @@ -1,72 +0,0 @@ -module ActiveSupport - # Many backtraces include too much information that's not relevant for the context. This makes it hard to find the signal - # in the backtrace and adds debugging time. With a BacktraceCleaner, you can setup filters and silencers for your particular - # context, so only the relevant lines are included. - # - # If you need to reconfigure an existing BacktraceCleaner, like the one in Rails, to show as much as possible, you can always - # call BacktraceCleaner#remove_silencers! - # - # Example: - # - # bc = BacktraceCleaner.new - # bc.add_filter { |line| line.gsub(Rails.root, '') } - # bc.add_silencer { |line| line =~ /mongrel|rubygems/ } - # bc.clean(exception.backtrace) # will strip the Rails.root prefix and skip any lines from mongrel or rubygems - # - # Inspired by the Quiet Backtrace gem by Thoughtbot. - class BacktraceCleaner - def initialize - @filters, @silencers = [], [] - end - - # Returns the backtrace after all filters and silencers has been run against it. Filters run first, then silencers. - def clean(backtrace) - silence(filter(backtrace)) - end - - # Adds a filter from the block provided. Each line in the backtrace will be mapped against this filter. - # - # Example: - # - # # Will turn "/my/rails/root/app/models/person.rb" into "/app/models/person.rb" - # backtrace_cleaner.add_filter { |line| line.gsub(Rails.root, '') } - def add_filter(&block) - @filters << block - end - - # Adds a silencer from the block provided. If the silencer returns true for a given line, it'll be excluded from the - # clean backtrace. - # - # Example: - # - # # Will reject all lines that include the word "mongrel", like "/gems/mongrel/server.rb" or "/app/my_mongrel_server/rb" - # backtrace_cleaner.add_silencer { |line| line =~ /mongrel/ } - def add_silencer(&block) - @silencers << block - end - - # Will remove all silencers, but leave in the filters. This is useful if your context of debugging suddenly expands as - # you suspect a bug in the libraries you use. - def remove_silencers! - @silencers = [] - end - - - private - def filter(backtrace) - @filters.each do |f| - backtrace = backtrace.map { |line| f.call(line) } - end - - backtrace - end - - def silence(backtrace) - @silencers.each do |s| - backtrace = backtrace.reject { |line| s.call(line) } - end - - backtrace - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/base64.rb b/vendor/rails/activesupport/lib/active_support/base64.rb deleted file mode 100644 index acb8e5a..0000000 --- a/vendor/rails/activesupport/lib/active_support/base64.rb +++ /dev/null @@ -1,33 +0,0 @@ -begin - require 'base64' -rescue LoadError -end - -module ActiveSupport - if defined? ::Base64 - Base64 = ::Base64 - else - # Base64 provides utility methods for encoding and de-coding binary data - # using a base 64 representation. A base 64 representation of binary data - # consists entirely of printable US-ASCII characters. The Base64 module - # is included in Ruby 1.8, but has been removed in Ruby 1.9. - module Base64 - # Encodes a string to its base 64 representation. Each 60 characters of - # output is separated by a newline character. - # - # ActiveSupport::Base64.encode64("Original unencoded string") - # # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==\n" - def self.encode64(data) - [data].pack("m") - end - - # Decodes a base 64 encoded string to its original representation. - # - # ActiveSupport::Base64.decode64("T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==") - # # => "Original unencoded string" - def self.decode64(data) - data.unpack("m").first - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/basic_object.rb b/vendor/rails/activesupport/lib/active_support/basic_object.rb deleted file mode 100644 index 1f77209..0000000 --- a/vendor/rails/activesupport/lib/active_support/basic_object.rb +++ /dev/null @@ -1,24 +0,0 @@ -# A base class with no predefined methods that tries to behave like Builder's -# BlankSlate in Ruby 1.9. In Ruby pre-1.9, this is actually the -# Builder::BlankSlate class. -# -# Ruby 1.9 introduces BasicObject which differs slightly from Builder's -# BlankSlate that has been used so far. ActiveSupport::BasicObject provides a -# barebones base class that emulates Builder::BlankSlate while still relying on -# Ruby 1.9's BasicObject in Ruby 1.9. -module ActiveSupport - if defined? ::BasicObject - class BasicObject < ::BasicObject - undef_method :== - undef_method :equal? - - # Let ActiveSupport::BasicObject at least raise exceptions. - def raise(*args) - ::Object.send(:raise, *args) - end - end - else - require 'blankslate' - BasicObject = BlankSlate - end -end diff --git a/vendor/rails/activesupport/lib/active_support/buffered_logger.rb b/vendor/rails/activesupport/lib/active_support/buffered_logger.rb deleted file mode 100644 index 33bcf32..0000000 --- a/vendor/rails/activesupport/lib/active_support/buffered_logger.rb +++ /dev/null @@ -1,127 +0,0 @@ -module ActiveSupport - # Inspired by the buffered logger idea by Ezra - class BufferedLogger - module Severity - DEBUG = 0 - INFO = 1 - WARN = 2 - ERROR = 3 - FATAL = 4 - UNKNOWN = 5 - end - include Severity - - MAX_BUFFER_SIZE = 1000 - - ## - # :singleton-method: - # Set to false to disable the silencer - cattr_accessor :silencer - self.silencer = true - - # Silences the logger for the duration of the block. - def silence(temporary_level = ERROR) - if silencer - begin - old_logger_level, self.level = level, temporary_level - yield self - ensure - self.level = old_logger_level - end - else - yield self - end - end - - attr_accessor :level - attr_reader :auto_flushing - - def initialize(log, level = DEBUG) - @level = level - @buffer = {} - @auto_flushing = 1 - @guard = Mutex.new - - if log.respond_to?(:write) - @log = log - elsif File.exist?(log) - @log = open(log, (File::WRONLY | File::APPEND)) - @log.sync = true - else - FileUtils.mkdir_p(File.dirname(log)) - @log = open(log, (File::WRONLY | File::APPEND | File::CREAT)) - @log.sync = true - @log.write("# Logfile created on %s" % [Time.now.to_s]) - end - end - - def add(severity, message = nil, progname = nil, &block) - return if @level > severity - message = (message || (block && block.call) || progname).to_s - # If a newline is necessary then create a new message ending with a newline. - # Ensures that the original message is not mutated. - message = "#{message}\n" unless message[-1] == ?\n - buffer << message - auto_flush - message - end - - for severity in Severity.constants - class_eval <<-EOT, __FILE__, __LINE__ - def #{severity.downcase}(message = nil, progname = nil, &block) # def debug(message = nil, progname = nil, &block) - add(#{severity}, message, progname, &block) # add(DEBUG, message, progname, &block) - end # end - # - def #{severity.downcase}? # def debug? - #{severity} >= @level # DEBUG >= @level - end # end - EOT - end - - # Set the auto-flush period. Set to true to flush after every log message, - # to an integer to flush every N messages, or to false, nil, or zero to - # never auto-flush. If you turn auto-flushing off, be sure to regularly - # flush the log yourself -- it will eat up memory until you do. - def auto_flushing=(period) - @auto_flushing = - case period - when true; 1 - when false, nil, 0; MAX_BUFFER_SIZE - when Integer; period - else raise ArgumentError, "Unrecognized auto_flushing period: #{period.inspect}" - end - end - - def flush - @guard.synchronize do - unless buffer.empty? - old_buffer = buffer - @log.write(old_buffer.join) - end - - # Important to do this even if buffer was empty or else @buffer will - # accumulate empty arrays for each request where nothing was logged. - clear_buffer - end - end - - def close - flush - @log.close if @log.respond_to?(:close) - @log = nil - end - - protected - def auto_flush - flush if buffer.size >= @auto_flushing - end - - def buffer - @buffer[Thread.current] ||= [] - end - - def clear_buffer - @buffer.delete(Thread.current) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache.rb b/vendor/rails/activesupport/lib/active_support/cache.rb deleted file mode 100644 index 83174d3..0000000 --- a/vendor/rails/activesupport/lib/active_support/cache.rb +++ /dev/null @@ -1,228 +0,0 @@ -require 'benchmark' - -module ActiveSupport - # See ActiveSupport::Cache::Store for documentation. - module Cache - autoload :FileStore, 'active_support/cache/file_store' - autoload :MemoryStore, 'active_support/cache/memory_store' - autoload :SynchronizedMemoryStore, 'active_support/cache/synchronized_memory_store' - autoload :DRbStore, 'active_support/cache/drb_store' - autoload :MemCacheStore, 'active_support/cache/mem_cache_store' - autoload :CompressedMemCacheStore, 'active_support/cache/compressed_mem_cache_store' - - module Strategy - autoload :LocalCache, 'active_support/cache/strategy/local_cache' - end - - # Creates a new CacheStore object according to the given options. - # - # If no arguments are passed to this method, then a new - # ActiveSupport::Cache::MemoryStore object will be returned. - # - # If you pass a Symbol as the first argument, then a corresponding cache - # store class under the ActiveSupport::Cache namespace will be created. - # For example: - # - # ActiveSupport::Cache.lookup_store(:memory_store) - # # => returns a new ActiveSupport::Cache::MemoryStore object - # - # ActiveSupport::Cache.lookup_store(:drb_store) - # # => returns a new ActiveSupport::Cache::DRbStore object - # - # Any additional arguments will be passed to the corresponding cache store - # class's constructor: - # - # ActiveSupport::Cache.lookup_store(:file_store, "/tmp/cache") - # # => same as: ActiveSupport::Cache::FileStore.new("/tmp/cache") - # - # If the first argument is not a Symbol, then it will simply be returned: - # - # ActiveSupport::Cache.lookup_store(MyOwnCacheStore.new) - # # => returns MyOwnCacheStore.new - def self.lookup_store(*store_option) - store, *parameters = *([ store_option ].flatten) - - case store - when Symbol - store_class_name = (store == :drb_store ? "DRbStore" : store.to_s.camelize) - store_class = ActiveSupport::Cache.const_get(store_class_name) - store_class.new(*parameters) - when nil - ActiveSupport::Cache::MemoryStore.new - else - store - end - end - - def self.expand_cache_key(key, namespace = nil) - expanded_cache_key = namespace ? "#{namespace}/" : "" - - if ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"] - expanded_cache_key << "#{ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]}/" - end - - expanded_cache_key << case - when key.respond_to?(:cache_key) - key.cache_key - when key.is_a?(Array) - key.collect { |element| expand_cache_key(element) }.to_param - when key - key.to_param - end.to_s - - expanded_cache_key - end - - # An abstract cache store class. There are multiple cache store - # implementations, each having its own additional features. See the classes - # under the ActiveSupport::Cache module, e.g. - # ActiveSupport::Cache::MemCacheStore. MemCacheStore is currently the most - # popular cache store for large production websites. - # - # ActiveSupport::Cache::Store is meant for caching strings. Some cache - # store implementations, like MemoryStore, are able to cache arbitrary - # Ruby objects, but don't count on every cache store to be able to do that. - # - # cache = ActiveSupport::Cache::MemoryStore.new - # - # cache.read("city") # => nil - # cache.write("city", "Duckburgh") - # cache.read("city") # => "Duckburgh" - class Store - cattr_accessor :logger - - def silence! - @silence = true - self - end - - # Fetches data from the cache, using the given key. If there is data in - # the cache with the given key, then that data is returned. - # - # If there is no such data in the cache (a cache miss occurred), then - # then nil will be returned. However, if a block has been passed, then - # that block will be run in the event of a cache miss. The return value - # of the block will be written to the cache under the given cache key, - # and that return value will be returned. - # - # cache.write("today", "Monday") - # cache.fetch("today") # => "Monday" - # - # cache.fetch("city") # => nil - # cache.fetch("city") do - # "Duckburgh" - # end - # cache.fetch("city") # => "Duckburgh" - # - # You may also specify additional options via the +options+ argument. - # Setting <tt>:force => true</tt> will force a cache miss: - # - # cache.write("today", "Monday") - # cache.fetch("today", :force => true) # => nil - # - # Other options will be handled by the specific cache store implementation. - # Internally, #fetch calls #read, and calls #write on a cache miss. - # +options+ will be passed to the #read and #write calls. - # - # For example, MemCacheStore's #write method supports the +:expires_in+ - # option, which tells the memcached server to automatically expire the - # cache item after a certain period. We can use this option with #fetch - # too: - # - # cache = ActiveSupport::Cache::MemCacheStore.new - # cache.fetch("foo", :force => true, :expires_in => 5.seconds) do - # "bar" - # end - # cache.fetch("foo") # => "bar" - # sleep(6) - # cache.fetch("foo") # => nil - def fetch(key, options = {}) - @logger_off = true - if !options[:force] && value = read(key, options) - @logger_off = false - log("hit", key, options) - value - elsif block_given? - @logger_off = false - log("miss", key, options) - - value = nil - ms = Benchmark.ms { value = yield } - - @logger_off = true - write(key, value, options) - @logger_off = false - - log('write (will save %.2fms)' % ms, key, nil) - - value - end - end - - # Fetches data from the cache, using the given key. If there is data in - # the cache with the given key, then that data is returned. Otherwise, - # nil is returned. - # - # You may also specify additional options via the +options+ argument. - # The specific cache store implementation will decide what to do with - # +options+. - def read(key, options = nil) - log("read", key, options) - end - - # Writes the given value to the cache, with the given key. - # - # You may also specify additional options via the +options+ argument. - # The specific cache store implementation will decide what to do with - # +options+. - # - # For example, MemCacheStore supports the +:expires_in+ option, which - # tells the memcached server to automatically expire the cache item after - # a certain period: - # - # cache = ActiveSupport::Cache::MemCacheStore.new - # cache.write("foo", "bar", :expires_in => 5.seconds) - # cache.read("foo") # => "bar" - # sleep(6) - # cache.read("foo") # => nil - def write(key, value, options = nil) - log("write", key, options) - end - - def delete(key, options = nil) - log("delete", key, options) - end - - def delete_matched(matcher, options = nil) - log("delete matched", matcher.inspect, options) - end - - def exist?(key, options = nil) - log("exist?", key, options) - end - - def increment(key, amount = 1) - log("incrementing", key, amount) - if num = read(key) - write(key, num + amount) - else - nil - end - end - - def decrement(key, amount = 1) - log("decrementing", key, amount) - if num = read(key) - write(key, num - amount) - else - nil - end - end - - private - def log(operation, key, options) - logger.debug("Cache #{operation}: #{key}#{options ? " (#{options.inspect})" : ""}") if logger && !@silence && !@logger_off - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb b/vendor/rails/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb deleted file mode 100644 index d87eb17..0000000 --- a/vendor/rails/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb +++ /dev/null @@ -1,20 +0,0 @@ -module ActiveSupport - module Cache - class CompressedMemCacheStore < MemCacheStore - def read(name, options = nil) - if value = super(name, (options || {}).merge(:raw => true)) - if raw?(options) - value - else - Marshal.load(ActiveSupport::Gzip.decompress(value)) - end - end - end - - def write(name, value, options = nil) - value = ActiveSupport::Gzip.compress(Marshal.dump(value)) unless raw?(options) - super(name, value, (options || {}).merge(:raw => true)) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache/drb_store.rb b/vendor/rails/activesupport/lib/active_support/cache/drb_store.rb deleted file mode 100644 index b16ed25..0000000 --- a/vendor/rails/activesupport/lib/active_support/cache/drb_store.rb +++ /dev/null @@ -1,14 +0,0 @@ -module ActiveSupport - module Cache - class DRbStore < MemoryStore #:nodoc: - attr_reader :address - - def initialize(address = 'druby://localhost:9192') - require 'drb' unless defined?(DRbObject) - super() - @address = address - @data = DRbObject.new(nil, address) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache/file_store.rb b/vendor/rails/activesupport/lib/active_support/cache/file_store.rb deleted file mode 100644 index 7f34cb5..0000000 --- a/vendor/rails/activesupport/lib/active_support/cache/file_store.rb +++ /dev/null @@ -1,72 +0,0 @@ -module ActiveSupport - module Cache - # A cache store implementation which stores everything on the filesystem. - class FileStore < Store - attr_reader :cache_path - - def initialize(cache_path) - @cache_path = cache_path - end - - def read(name, options = nil) - super - File.open(real_file_path(name), 'rb') { |f| Marshal.load(f) } rescue nil - end - - def write(name, value, options = nil) - super - ensure_cache_path(File.dirname(real_file_path(name))) - File.atomic_write(real_file_path(name), cache_path) { |f| Marshal.dump(value, f) } - value - rescue => e - logger.error "Couldn't create cache directory: #{name} (#{e.message})" if logger - end - - def delete(name, options = nil) - super - File.delete(real_file_path(name)) - rescue SystemCallError => e - # If there's no cache, then there's nothing to complain about - end - - def delete_matched(matcher, options = nil) - super - search_dir(@cache_path) do |f| - if f =~ matcher - begin - File.delete(f) - rescue SystemCallError => e - # If there's no cache, then there's nothing to complain about - end - end - end - end - - def exist?(name, options = nil) - super - File.exist?(real_file_path(name)) - end - - private - def real_file_path(name) - '%s/%s.cache' % [@cache_path, name.gsub('?', '.').gsub(':', '.')] - end - - def ensure_cache_path(path) - FileUtils.makedirs(path) unless File.exist?(path) - end - - def search_dir(dir, &callback) - Dir.foreach(dir) do |d| - next if d == "." || d == ".." - name = File.join(dir, d) - if File.directory?(name) - search_dir(name, &callback) - else - callback.call name - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb b/vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb deleted file mode 100644 index 4d8e1fd..0000000 --- a/vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb +++ /dev/null @@ -1,132 +0,0 @@ -require 'memcache' - -module ActiveSupport - module Cache - # A cache store implementation which stores data in Memcached: - # http://www.danga.com/memcached/ - # - # This is currently the most popular cache store for production websites. - # - # Special features: - # - Clustering and load balancing. One can specify multiple memcached servers, - # and MemCacheStore will load balance between all available servers. If a - # server goes down, then MemCacheStore will ignore it until it goes back - # online. - # - Time-based expiry support. See #write and the +:expires_in+ option. - # - Per-request in memory cache for all communication with the MemCache server(s). - class MemCacheStore < Store - module Response # :nodoc: - STORED = "STORED\r\n" - NOT_STORED = "NOT_STORED\r\n" - EXISTS = "EXISTS\r\n" - NOT_FOUND = "NOT_FOUND\r\n" - DELETED = "DELETED\r\n" - end - - attr_reader :addresses - - # Creates a new MemCacheStore object, with the given memcached server - # addresses. Each address is either a host name, or a host-with-port string - # in the form of "host_name:port". For example: - # - # ActiveSupport::Cache::MemCacheStore.new("localhost", "server-downstairs.localnetwork:8229") - # - # If no addresses are specified, then MemCacheStore will connect to - # localhost port 11211 (the default memcached port). - def initialize(*addresses) - addresses = addresses.flatten - options = addresses.extract_options! - addresses = ["localhost"] if addresses.empty? - @addresses = addresses - @data = MemCache.new(addresses, options) - - extend Strategy::LocalCache - end - - def read(key, options = nil) # :nodoc: - super - @data.get(key, raw?(options)) - rescue MemCache::MemCacheError => e - logger.error("MemCacheError (#{e}): #{e.message}") - nil - end - - # Writes a value to the cache. - # - # Possible options: - # - +:unless_exist+ - set to true if you don't want to update the cache - # if the key is already set. - # - +:expires_in+ - the number of seconds that this value may stay in - # the cache. See ActiveSupport::Cache::Store#write for an example. - def write(key, value, options = nil) - super - method = options && options[:unless_exist] ? :add : :set - # memcache-client will break the connection if you send it an integer - # in raw mode, so we convert it to a string to be sure it continues working. - value = value.to_s if raw?(options) - response = @data.send(method, key, value, expires_in(options), raw?(options)) - response == Response::STORED - rescue MemCache::MemCacheError => e - logger.error("MemCacheError (#{e}): #{e.message}") - false - end - - def delete(key, options = nil) # :nodoc: - super - response = @data.delete(key, expires_in(options)) - response == Response::DELETED - rescue MemCache::MemCacheError => e - logger.error("MemCacheError (#{e}): #{e.message}") - false - end - - def exist?(key, options = nil) # :nodoc: - # Doesn't call super, cause exist? in memcache is in fact a read - # But who cares? Reading is very fast anyway - # Local cache is checked first, if it doesn't know then memcache itself is read from - !read(key, options).nil? - end - - def increment(key, amount = 1) # :nodoc: - log("incrementing", key, amount) - - response = @data.incr(key, amount) - response == Response::NOT_FOUND ? nil : response - rescue MemCache::MemCacheError - nil - end - - def decrement(key, amount = 1) # :nodoc: - log("decrement", key, amount) - response = @data.decr(key, amount) - response == Response::NOT_FOUND ? nil : response - rescue MemCache::MemCacheError - nil - end - - def delete_matched(matcher, options = nil) # :nodoc: - # don't do any local caching at present, just pass - # through and let the error happen - super - raise "Not supported by Memcache" - end - - def clear - @data.flush_all - end - - def stats - @data.stats - end - - private - def expires_in(options) - (options && options[:expires_in]) || 0 - end - - def raw?(options) - options && options[:raw] - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache/memory_store.rb b/vendor/rails/activesupport/lib/active_support/cache/memory_store.rb deleted file mode 100644 index 1b30d49..0000000 --- a/vendor/rails/activesupport/lib/active_support/cache/memory_store.rb +++ /dev/null @@ -1,52 +0,0 @@ -module ActiveSupport - module Cache - # A cache store implementation which stores everything into memory in the - # same process. If you're running multiple Ruby on Rails server processes - # (which is the case if you're using mongrel_cluster or Phusion Passenger), - # then this means that your Rails server process instances won't be able - # to share cache data with each other. If your application never performs - # manual cache item expiry (e.g. when you're using generational cache keys), - # then using MemoryStore is ok. Otherwise, consider carefully whether you - # should be using this cache store. - # - # MemoryStore is not only able to store strings, but also arbitrary Ruby - # objects. - # - # MemoryStore is not thread-safe. Use SynchronizedMemoryStore instead - # if you need thread-safety. - class MemoryStore < Store - def initialize - @data = {} - end - - def read(name, options = nil) - super - @data[name] - end - - def write(name, value, options = nil) - super - @data[name] = value.freeze - end - - def delete(name, options = nil) - super - @data.delete(name) - end - - def delete_matched(matcher, options = nil) - super - @data.delete_if { |k,v| k =~ matcher } - end - - def exist?(name,options = nil) - super - @data.has_key?(name) - end - - def clear - @data.clear - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache/strategy/local_cache.rb b/vendor/rails/activesupport/lib/active_support/cache/strategy/local_cache.rb deleted file mode 100644 index d83e259..0000000 --- a/vendor/rails/activesupport/lib/active_support/cache/strategy/local_cache.rb +++ /dev/null @@ -1,104 +0,0 @@ -module ActiveSupport - module Cache - module Strategy - module LocalCache - # this allows caching of the fact that there is nothing in the remote cache - NULL = 'remote_cache_store:null' - - def with_local_cache - Thread.current[thread_local_key] = MemoryStore.new - yield - ensure - Thread.current[thread_local_key] = nil - end - - def middleware - @middleware ||= begin - klass = Class.new - klass.class_eval(<<-EOS, __FILE__, __LINE__) - def initialize(app) - @app = app - end - - def call(env) - Thread.current[:#{thread_local_key}] = MemoryStore.new - @app.call(env) - ensure - Thread.current[:#{thread_local_key}] = nil - end - EOS - klass - end - end - - def read(key, options = nil) - value = local_cache && local_cache.read(key) - if value == NULL - nil - elsif value.nil? - value = super - local_cache.write(key, value || NULL) if local_cache - value - else - # forcing the value to be immutable - value.duplicable? ? value.dup : value - end - end - - def write(key, value, options = nil) - value = value.to_s if respond_to?(:raw?) && raw?(options) - local_cache.write(key, value || NULL) if local_cache - super - end - - def delete(key, options = nil) - local_cache.write(key, NULL) if local_cache - super - end - - def exist(key, options = nil) - value = local_cache.read(key) if local_cache - if value == NULL - false - elsif value - true - else - super - end - end - - def increment(key, amount = 1) - if value = super - local_cache.write(key, value.to_s) if local_cache - value - else - nil - end - end - - def decrement(key, amount = 1) - if value = super - local_cache.write(key, value.to_s) if local_cache - value - else - nil - end - end - - def clear - local_cache.clear if local_cache - super - end - - private - def thread_local_key - @thread_local_key ||= "#{self.class.name.underscore}_local_cache".gsub("/", "_").to_sym - end - - def local_cache - Thread.current[thread_local_key] - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/cache/synchronized_memory_store.rb b/vendor/rails/activesupport/lib/active_support/cache/synchronized_memory_store.rb deleted file mode 100644 index ea03a11..0000000 --- a/vendor/rails/activesupport/lib/active_support/cache/synchronized_memory_store.rb +++ /dev/null @@ -1,47 +0,0 @@ -module ActiveSupport - module Cache - # Like MemoryStore, but thread-safe. - class SynchronizedMemoryStore < MemoryStore - def initialize - super - @guard = Monitor.new - end - - def fetch(key, options = {}) - @guard.synchronize { super } - end - - def read(name, options = nil) - @guard.synchronize { super } - end - - def write(name, value, options = nil) - @guard.synchronize { super } - end - - def delete(name, options = nil) - @guard.synchronize { super } - end - - def delete_matched(matcher, options = nil) - @guard.synchronize { super } - end - - def exist?(name,options = nil) - @guard.synchronize { super } - end - - def increment(key, amount = 1) - @guard.synchronize { super } - end - - def decrement(key, amount = 1) - @guard.synchronize { super } - end - - def clear - @guard.synchronize { super } - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/callbacks.rb b/vendor/rails/activesupport/lib/active_support/callbacks.rb deleted file mode 100644 index 86e66e0..0000000 --- a/vendor/rails/activesupport/lib/active_support/callbacks.rb +++ /dev/null @@ -1,279 +0,0 @@ -module ActiveSupport - # Callbacks are hooks into the lifecycle of an object that allow you to trigger logic - # before or after an alteration of the object state. - # - # Mixing in this module allows you to define callbacks in your class. - # - # Example: - # class Storage - # include ActiveSupport::Callbacks - # - # define_callbacks :before_save, :after_save - # end - # - # class ConfigStorage < Storage - # before_save :saving_message - # def saving_message - # puts "saving..." - # end - # - # after_save do |object| - # puts "saved" - # end - # - # def save - # run_callbacks(:before_save) - # puts "- save" - # run_callbacks(:after_save) - # end - # end - # - # config = ConfigStorage.new - # config.save - # - # Output: - # saving... - # - save - # saved - # - # Callbacks from parent classes are inherited. - # - # Example: - # class Storage - # include ActiveSupport::Callbacks - # - # define_callbacks :before_save, :after_save - # - # before_save :prepare - # def prepare - # puts "preparing save" - # end - # end - # - # class ConfigStorage < Storage - # before_save :saving_message - # def saving_message - # puts "saving..." - # end - # - # after_save do |object| - # puts "saved" - # end - # - # def save - # run_callbacks(:before_save) - # puts "- save" - # run_callbacks(:after_save) - # end - # end - # - # config = ConfigStorage.new - # config.save - # - # Output: - # preparing save - # saving... - # - save - # saved - module Callbacks - class CallbackChain < Array - def self.build(kind, *methods, &block) - methods, options = extract_options(*methods, &block) - methods.map! { |method| Callback.new(kind, method, options) } - new(methods) - end - - def run(object, options = {}, &terminator) - enumerator = options[:enumerator] || :each - - unless block_given? - send(enumerator) { |callback| callback.call(object) } - else - send(enumerator) do |callback| - result = callback.call(object) - break result if terminator.call(result, object) - end - end - end - - # TODO: Decompose into more Array like behavior - def replace_or_append!(chain) - if index = index(chain) - self[index] = chain - else - self << chain - end - self - end - - def find(callback, &block) - select { |c| c == callback && (!block_given? || yield(c)) }.first - end - - def delete(callback) - super(callback.is_a?(Callback) ? callback : find(callback)) - end - - private - def self.extract_options(*methods, &block) - methods.flatten! - options = methods.extract_options! - methods << block if block_given? - return methods, options - end - - def extract_options(*methods, &block) - self.class.extract_options(*methods, &block) - end - end - - class Callback - attr_reader :kind, :method, :identifier, :options - - def initialize(kind, method, options = {}) - @kind = kind - @method = method - @identifier = options[:identifier] - @options = options - end - - def ==(other) - case other - when Callback - (self.identifier && self.identifier == other.identifier) || self.method == other.method - else - (self.identifier && self.identifier == other) || self.method == other - end - end - - def eql?(other) - self == other - end - - def dup - self.class.new(@kind, @method, @options.dup) - end - - def hash - if @identifier - @identifier.hash - else - @method.hash - end - end - - def call(*args, &block) - evaluate_method(method, *args, &block) if should_run_callback?(*args) - rescue LocalJumpError - raise ArgumentError, - "Cannot yield from a Proc type filter. The Proc must take two " + - "arguments and execute #call on the second argument." - end - - private - def evaluate_method(method, *args, &block) - case method - when Symbol - object = args.shift - object.send(method, *args, &block) - when String - eval(method, args.first.instance_eval { binding }) - when Proc, Method - method.call(*args, &block) - else - if method.respond_to?(kind) - method.send(kind, *args, &block) - else - raise ArgumentError, - "Callbacks must be a symbol denoting the method to call, a string to be evaluated, " + - "a block to be invoked, or an object responding to the callback method." - end - end - end - - def should_run_callback?(*args) - [options[:if]].flatten.compact.all? { |a| evaluate_method(a, *args) } && - ![options[:unless]].flatten.compact.any? { |a| evaluate_method(a, *args) } - end - end - - def self.included(base) - base.extend ClassMethods - end - - module ClassMethods - def define_callbacks(*callbacks) - callbacks.each do |callback| - class_eval <<-"end_eval" - def self.#{callback}(*methods, &block) # def self.before_save(*methods, &block) - callbacks = CallbackChain.build(:#{callback}, *methods, &block) # callbacks = CallbackChain.build(:before_save, *methods, &block) - @#{callback}_callbacks ||= CallbackChain.new # @before_save_callbacks ||= CallbackChain.new - @#{callback}_callbacks.concat callbacks # @before_save_callbacks.concat callbacks - end # end - # - def self.#{callback}_callback_chain # def self.before_save_callback_chain - @#{callback}_callbacks ||= CallbackChain.new # @before_save_callbacks ||= CallbackChain.new - # - if superclass.respond_to?(:#{callback}_callback_chain) # if superclass.respond_to?(:before_save_callback_chain) - CallbackChain.new( # CallbackChain.new( - superclass.#{callback}_callback_chain + # superclass.before_save_callback_chain + - @#{callback}_callbacks # @before_save_callbacks - ) # ) - else # else - @#{callback}_callbacks # @before_save_callbacks - end # end - end # end - end_eval - end - end - end - - # Runs all the callbacks defined for the given options. - # - # If a block is given it will be called after each callback receiving as arguments: - # - # * the result from the callback - # * the object which has the callback - # - # If the result from the block evaluates to false, the callback chain is stopped. - # - # Example: - # class Storage - # include ActiveSupport::Callbacks - # - # define_callbacks :before_save, :after_save - # end - # - # class ConfigStorage < Storage - # before_save :pass - # before_save :pass - # before_save :stop - # before_save :pass - # - # def pass - # puts "pass" - # end - # - # def stop - # puts "stop" - # return false - # end - # - # def save - # result = run_callbacks(:before_save) { |result, object| result == false } - # puts "- save" if result - # end - # end - # - # config = ConfigStorage.new - # config.save - # - # Output: - # pass - # pass - # stop - def run_callbacks(kind, options = {}, &block) - self.class.send("#{kind}_callback_chain").run(self, options, &block) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext.rb b/vendor/rails/activesupport/lib/active_support/core_ext.rb deleted file mode 100644 index f2f976d..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext.rb +++ /dev/null @@ -1,4 +0,0 @@ -Dir[File.dirname(__FILE__) + "/core_ext/*.rb"].sort.each do |path| - filename = File.basename(path, '.rb') - require "active_support/core_ext/#{filename}" -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/array.rb b/vendor/rails/activesupport/lib/active_support/core_ext/array.rb deleted file mode 100644 index 82c6b12..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/array.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'active_support/core_ext/array/access' -require 'active_support/core_ext/array/conversions' -require 'active_support/core_ext/array/extract_options' -require 'active_support/core_ext/array/grouping' -require 'active_support/core_ext/array/random_access' -require 'active_support/core_ext/array/wrapper' - -class Array #:nodoc: - include ActiveSupport::CoreExtensions::Array::Access - include ActiveSupport::CoreExtensions::Array::Conversions - include ActiveSupport::CoreExtensions::Array::ExtractOptions - include ActiveSupport::CoreExtensions::Array::Grouping - include ActiveSupport::CoreExtensions::Array::RandomAccess - extend ActiveSupport::CoreExtensions::Array::Wrapper -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb b/vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb deleted file mode 100644 index 6de338b..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb +++ /dev/null @@ -1,53 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Array #:nodoc: - # Makes it easier to access parts of an array. - module Access - # Returns the tail of the array from +position+. - # - # %w( a b c d ).from(0) # => %w( a b c d ) - # %w( a b c d ).from(2) # => %w( c d ) - # %w( a b c d ).from(10) # => nil - # %w().from(0) # => nil - def from(position) - self[position..-1] - end - - # Returns the beginning of the array up to +position+. - # - # %w( a b c d ).to(0) # => %w( a ) - # %w( a b c d ).to(2) # => %w( a b c ) - # %w( a b c d ).to(10) # => %w( a b c d ) - # %w().to(0) # => %w() - def to(position) - self[0..position] - end - - # Equal to <tt>self[1]</tt>. - def second - self[1] - end - - # Equal to <tt>self[2]</tt>. - def third - self[2] - end - - # Equal to <tt>self[3]</tt>. - def fourth - self[3] - end - - # Equal to <tt>self[4]</tt>. - def fifth - self[4] - end - - # Equal to <tt>self[41]</tt>. Also known as accessing "the reddit". - def forty_two - self[41] - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/array/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/array/conversions.rb deleted file mode 100644 index ba8e022..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/array/conversions.rb +++ /dev/null @@ -1,196 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Array #:nodoc: - module Conversions - # Converts the array to a comma-separated sentence where the last element is joined by the connector word. Options: - # * <tt>:words_connector</tt> - The sign or word used to join the elements in arrays with two or more elements (default: ", ") - # * <tt>:two_words_connector</tt> - The sign or word used to join the elements in arrays with two elements (default: " and ") - # * <tt>:last_word_connector</tt> - The sign or word used to join the last element in arrays with three or more elements (default: ", and ") - def to_sentence(options = {}) - default_words_connector = I18n.translate(:'support.array.words_connector', :locale => options[:locale]) - default_two_words_connector = I18n.translate(:'support.array.two_words_connector', :locale => options[:locale]) - default_last_word_connector = I18n.translate(:'support.array.last_word_connector', :locale => options[:locale]) - - # Try to emulate to_senteces previous to 2.3 - if options.has_key?(:connector) || options.has_key?(:skip_last_comma) - ::ActiveSupport::Deprecation.warn(":connector has been deprecated. Use :words_connector instead", caller) if options.has_key? :connector - ::ActiveSupport::Deprecation.warn(":skip_last_comma has been deprecated. Use :last_word_connector instead", caller) if options.has_key? :skip_last_comma - - skip_last_comma = options.delete :skip_last_comma - if connector = options.delete(:connector) - options[:last_word_connector] ||= skip_last_comma ? connector : ", #{connector}" - else - options[:last_word_connector] ||= skip_last_comma ? default_two_words_connector : default_last_word_connector - end - end - - options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector, :locale) - options.reverse_merge! :words_connector => default_words_connector, :two_words_connector => default_two_words_connector, :last_word_connector => default_last_word_connector - - case length - when 0 - "" - when 1 - self[0].to_s - when 2 - "#{self[0]}#{options[:two_words_connector]}#{self[1]}" - else - "#{self[0...-1].join(options[:words_connector])}#{options[:last_word_connector]}#{self[-1]}" - end - end - - - # Calls <tt>to_param</tt> on all its elements and joins the result with - # slashes. This is used by <tt>url_for</tt> in Action Pack. - def to_param - collect { |e| e.to_param }.join '/' - end - - # Converts an array into a string suitable for use as a URL query string, - # using the given +key+ as the param name. - # - # ['Rails', 'coding'].to_query('hobbies') # => "hobbies%5B%5D=Rails&hobbies%5B%5D=coding" - def to_query(key) - prefix = "#{key}[]" - collect { |value| value.to_query(prefix) }.join '&' - end - - def self.included(base) #:nodoc: - base.class_eval do - alias_method :to_default_s, :to_s - alias_method :to_s, :to_formatted_s - end - end - - # Converts a collection of elements into a formatted string by calling - # <tt>to_s</tt> on all elements and joining them: - # - # Blog.find(:all).to_formatted_s # => "First PostSecond PostThird Post" - # - # Adding in the <tt>:db</tt> argument as the format yields a prettier - # output: - # - # Blog.find(:all).to_formatted_s(:db) # => "First Post,Second Post,Third Post" - def to_formatted_s(format = :default) - case format - when :db - if respond_to?(:empty?) && self.empty? - "null" - else - collect { |element| element.id }.join(",") - end - else - to_default_s - end - end - - # Returns a string that represents this array in XML by sending +to_xml+ - # to each element. Active Record collections delegate their representation - # in XML to this method. - # - # All elements are expected to respond to +to_xml+, if any of them does - # not an exception is raised. - # - # The root node reflects the class name of the first element in plural - # if all elements belong to the same type and that's not Hash: - # - # customer.projects.to_xml - # - # <?xml version="1.0" encoding="UTF-8"?> - # <projects type="array"> - # <project> - # <amount type="decimal">20000.0</amount> - # <customer-id type="integer">1567</customer-id> - # <deal-date type="date">2008-04-09</deal-date> - # ... - # </project> - # <project> - # <amount type="decimal">57230.0</amount> - # <customer-id type="integer">1567</customer-id> - # <deal-date type="date">2008-04-15</deal-date> - # ... - # </project> - # </projects> - # - # Otherwise the root element is "records": - # - # [{:foo => 1, :bar => 2}, {:baz => 3}].to_xml - # - # <?xml version="1.0" encoding="UTF-8"?> - # <records type="array"> - # <record> - # <bar type="integer">2</bar> - # <foo type="integer">1</foo> - # </record> - # <record> - # <baz type="integer">3</baz> - # </record> - # </records> - # - # If the collection is empty the root element is "nil-classes" by default: - # - # [].to_xml - # - # <?xml version="1.0" encoding="UTF-8"?> - # <nil-classes type="array"/> - # - # To ensure a meaningful root element use the <tt>:root</tt> option: - # - # customer_with_no_projects.projects.to_xml(:root => "projects") - # - # <?xml version="1.0" encoding="UTF-8"?> - # <projects type="array"/> - # - # By default root children have as node name the one of the root - # singularized. You can change it with the <tt>:children</tt> option. - # - # The +options+ hash is passed downwards: - # - # Message.all.to_xml(:skip_types => true) - # - # <?xml version="1.0" encoding="UTF-8"?> - # <messages> - # <message> - # <created-at>2008-03-07T09:58:18+01:00</created-at> - # <id>1</id> - # <name>1</name> - # <updated-at>2008-03-07T09:58:18+01:00</updated-at> - # <user-id>1</user-id> - # </message> - # </messages> - # - def to_xml(options = {}) - raise "Not all elements respond to to_xml" unless all? { |e| e.respond_to? :to_xml } - require 'builder' unless defined?(Builder) - - options[:root] ||= all? { |e| e.is_a?(first.class) && first.class.to_s != "Hash" } ? first.class.to_s.underscore.pluralize : "records" - options[:children] ||= options[:root].singularize - options[:indent] ||= 2 - options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent]) - - root = options.delete(:root).to_s - children = options.delete(:children) - - if !options.has_key?(:dasherize) || options[:dasherize] - root = root.dasherize - end - - options[:builder].instruct! unless options.delete(:skip_instruct) - - opts = options.merge({ :root => children }) - - xml = options[:builder] - if empty? - xml.tag!(root, options[:skip_types] ? {} : {:type => "array"}) - else - xml.tag!(root, options[:skip_types] ? {} : {:type => "array"}) { - yield xml if block_given? - each { |e| e.to_xml(opts.merge({ :skip_instruct => true })) } - } - end - end - - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/array/extract_options.rb b/vendor/rails/activesupport/lib/active_support/core_ext/array/extract_options.rb deleted file mode 100644 index eb91757..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/array/extract_options.rb +++ /dev/null @@ -1,20 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Array #:nodoc: - module ExtractOptions - # Extracts options from a set of arguments. Removes and returns the last - # element in the array if it's a hash, otherwise returns a blank hash. - # - # def options(*args) - # args.extract_options! - # end - # - # options(1, 2) # => {} - # options(1, 2, :a => :b) # => {:a=>:b} - def extract_options! - last.is_a?(::Hash) ? pop : {} - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/array/grouping.rb b/vendor/rails/activesupport/lib/active_support/core_ext/array/grouping.rb deleted file mode 100644 index f782f8f..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/array/grouping.rb +++ /dev/null @@ -1,106 +0,0 @@ -require 'enumerator' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Array #:nodoc: - module Grouping - # Splits or iterates over the array in groups of size +number+, - # padding any remaining slots with +fill_with+ unless it is +false+. - # - # %w(1 2 3 4 5 6 7).in_groups_of(3) {|group| p group} - # ["1", "2", "3"] - # ["4", "5", "6"] - # ["7", nil, nil] - # - # %w(1 2 3).in_groups_of(2, '&nbsp;') {|group| p group} - # ["1", "2"] - # ["3", "&nbsp;"] - # - # %w(1 2 3).in_groups_of(2, false) {|group| p group} - # ["1", "2"] - # ["3"] - def in_groups_of(number, fill_with = nil) - if fill_with == false - collection = self - else - # size % number gives how many extra we have; - # subtracting from number gives how many to add; - # modulo number ensures we don't add group of just fill. - padding = (number - size % number) % number - collection = dup.concat([fill_with] * padding) - end - - if block_given? - collection.each_slice(number) { |slice| yield(slice) } - else - returning [] do |groups| - collection.each_slice(number) { |group| groups << group } - end - end - end - - # Splits or iterates over the array in +number+ of groups, padding any - # remaining slots with +fill_with+ unless it is +false+. - # - # %w(1 2 3 4 5 6 7 8 9 10).in_groups(3) {|group| p group} - # ["1", "2", "3", "4"] - # ["5", "6", "7", nil] - # ["8", "9", "10", nil] - # - # %w(1 2 3 4 5 6 7).in_groups(3, '&nbsp;') {|group| p group} - # ["1", "2", "3"] - # ["4", "5", "&nbsp;"] - # ["6", "7", "&nbsp;"] - # - # %w(1 2 3 4 5 6 7).in_groups(3, false) {|group| p group} - # ["1", "2", "3"] - # ["4", "5"] - # ["6", "7"] - def in_groups(number, fill_with = nil) - # size / number gives minor group size; - # size % number gives how many objects need extra accomodation; - # each group hold either division or division + 1 items. - division = size / number - modulo = size % number - - # create a new array avoiding dup - groups = [] - start = 0 - - number.times do |index| - length = division + (modulo > 0 && modulo > index ? 1 : 0) - padding = fill_with != false && - modulo > 0 && length == division ? 1 : 0 - groups << slice(start, length).concat([fill_with] * padding) - start += length - end - - if block_given? - groups.each{|g| yield(g) } - else - groups - end - end - - # Divides the array into one or more subarrays based on a delimiting +value+ - # or the result of an optional block. - # - # [1, 2, 3, 4, 5].split(3) # => [[1, 2], [4, 5]] - # (1..10).to_a.split { |i| i % 3 == 0 } # => [[1, 2], [4, 5], [7, 8], [10]] - def split(value = nil) - using_block = block_given? - - inject([[]]) do |results, element| - if (using_block && yield(element)) || (value == element) - results << [] - else - results.last << element - end - - results - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/array/random_access.rb b/vendor/rails/activesupport/lib/active_support/core_ext/array/random_access.rb deleted file mode 100644 index 54d17cb..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/array/random_access.rb +++ /dev/null @@ -1,12 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Array #:nodoc: - module RandomAccess - # Returns a random element from the array. - def rand - self[Kernel.rand(length)] - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb b/vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb deleted file mode 100644 index 80b8f05..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb +++ /dev/null @@ -1,24 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Array #:nodoc: - module Wrapper - # Wraps the object in an Array unless it's an Array. Converts the - # object to an Array using #to_ary if it implements that. - def wrap(object) - case object - when nil - [] - when self - object - else - if object.respond_to?(:to_ary) - object.to_ary - else - [object] - end - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/base64.rb b/vendor/rails/activesupport/lib/active_support/core_ext/base64.rb deleted file mode 100644 index 235e2ed..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/base64.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'active_support/base64' -require 'active_support/core_ext/base64/encoding' - -ActiveSupport::Base64.extend ActiveSupport::CoreExtensions::Base64::Encoding diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/base64/encoding.rb b/vendor/rails/activesupport/lib/active_support/core_ext/base64/encoding.rb deleted file mode 100644 index a9656c1..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/base64/encoding.rb +++ /dev/null @@ -1,16 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Base64 #:nodoc: - module Encoding - # Encodes the value as base64 without the newline breaks. This makes the base64 encoding readily usable as URL parameters - # or memcache keys without further processing. - # - # ActiveSupport::Base64.encode64s("Original unencoded string") - # # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==" - def encode64s(value) - encode64(value).gsub(/\n/, '') - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb b/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb deleted file mode 100644 index ae57b15..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'benchmark' - -class << Benchmark - # Earlier Ruby had a slower implementation. - if RUBY_VERSION < '1.8.7' - remove_method :realtime - - def realtime - r0 = Time.now - yield - r1 = Time.now - r1.to_f - r0.to_f - end - end - - def ms - 1000 * realtime { yield } - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal.rb b/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal.rb deleted file mode 100644 index d429078..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'bigdecimal' -require 'active_support/core_ext/bigdecimal/conversions' - -class BigDecimal#:nodoc: - include ActiveSupport::CoreExtensions::BigDecimal::Conversions -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal/conversions.rb deleted file mode 100644 index bc9d578..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal/conversions.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'yaml' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module BigDecimal #:nodoc: - module Conversions - DEFAULT_STRING_FORMAT = 'F'.freeze - YAML_TAG = 'tag:yaml.org,2002:float'.freeze - YAML_MAPPING = { 'Infinity' => '.Inf', '-Infinity' => '-.Inf', 'NaN' => '.NaN' } - - def self.included(base) #:nodoc: - base.class_eval do - alias_method :_original_to_s, :to_s - alias_method :to_s, :to_formatted_s - - yaml_as YAML_TAG - end - end - - def to_formatted_s(format = DEFAULT_STRING_FORMAT) - _original_to_s(format) - end - - # This emits the number without any scientific notation. - # This is better than self.to_f.to_s since it doesn't lose precision. - # - # Note that reconstituting YAML floats to native floats may lose precision. - def to_yaml(opts = {}) - YAML.quick_emit(nil, opts) do |out| - string = to_s - out.scalar(YAML_TAG, YAML_MAPPING[string] || string, :plain) - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/blank.rb b/vendor/rails/activesupport/lib/active_support/core_ext/blank.rb deleted file mode 100644 index 4f8dc4e..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/blank.rb +++ /dev/null @@ -1,58 +0,0 @@ -class Object - # An object is blank if it's false, empty, or a whitespace string. - # For example, "", " ", +nil+, [], and {} are blank. - # - # This simplifies - # - # if !address.nil? && !address.empty? - # - # to - # - # if !address.blank? - def blank? - respond_to?(:empty?) ? empty? : !self - end - - # An object is present if it's not blank. - def present? - !blank? - end -end - -class NilClass #:nodoc: - def blank? - true - end -end - -class FalseClass #:nodoc: - def blank? - true - end -end - -class TrueClass #:nodoc: - def blank? - false - end -end - -class Array #:nodoc: - alias_method :blank?, :empty? -end - -class Hash #:nodoc: - alias_method :blank?, :empty? -end - -class String #:nodoc: - def blank? - self !~ /\S/ - end -end - -class Numeric #:nodoc: - def blank? - false - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/cgi.rb b/vendor/rails/activesupport/lib/active_support/core_ext/cgi.rb deleted file mode 100644 index db90e5c..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/cgi.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'active_support/core_ext/cgi/escape_skipping_slashes' - -class CGI #:nodoc: - extend ActiveSupport::CoreExtensions::CGI::EscapeSkippingSlashes -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb b/vendor/rails/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb deleted file mode 100644 index 1edb377..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +++ /dev/null @@ -1,23 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module CGI #:nodoc: - module EscapeSkippingSlashes #:nodoc: - if RUBY_VERSION >= '1.9' - def escape_skipping_slashes(str) - str = str.join('/') if str.respond_to? :join - str.gsub(/([^ \/a-zA-Z0-9_.-])/n) do - "%#{$1.unpack('H2' * $1.bytesize).join('%').upcase}" - end.tr(' ', '+') - end - else - def escape_skipping_slashes(str) - str = str.join('/') if str.respond_to? :join - str.gsub(/([^ \/a-zA-Z0-9_.-])/n) do - "%#{$1.unpack('H2').first.upcase}" - end.tr(' ', '+') - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/class.rb b/vendor/rails/activesupport/lib/active_support/core_ext/class.rb deleted file mode 100644 index 44ad6c8..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/class.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'active_support/core_ext/class/attribute_accessors' -require 'active_support/core_ext/class/inheritable_attributes' -require 'active_support/core_ext/class/removal' -require 'active_support/core_ext/class/delegating_attributes' diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb b/vendor/rails/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb deleted file mode 100644 index c795871..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb +++ /dev/null @@ -1,54 +0,0 @@ -# Extends the class object with class and instance accessors for class attributes, -# just like the native attr* accessors for instance attributes. -# -# class Person -# cattr_accessor :hair_colors -# end -# -# Person.hair_colors = [:brown, :black, :blonde, :red] -class Class - def cattr_reader(*syms) - syms.flatten.each do |sym| - next if sym.is_a?(Hash) - class_eval(<<-EOS, __FILE__, __LINE__) - unless defined? @@#{sym} # unless defined? @@hair_colors - @@#{sym} = nil # @@hair_colors = nil - end # end - # - def self.#{sym} # def self.hair_colors - @@#{sym} # @@hair_colors - end # end - # - def #{sym} # def hair_colors - @@#{sym} # @@hair_colors - end # end - EOS - end - end - - def cattr_writer(*syms) - options = syms.extract_options! - syms.flatten.each do |sym| - class_eval(<<-EOS, __FILE__, __LINE__) - unless defined? @@#{sym} # unless defined? @@hair_colors - @@#{sym} = nil # @@hair_colors = nil - end # end - # - def self.#{sym}=(obj) # def self.hair_colors=(obj) - @@#{sym} = obj # @@hair_colors = obj - end # end - # - #{" # - def #{sym}=(obj) # def hair_colors=(obj) - @@#{sym} = obj # @@hair_colors = obj - end # end - " unless options[:instance_writer] == false } # # instance writer above is generated unless options[:instance_writer] == false - EOS - end - end - - def cattr_accessor(*syms) - cattr_reader(*syms) - cattr_writer(*syms) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb b/vendor/rails/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb deleted file mode 100644 index 000ccf4..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb +++ /dev/null @@ -1,47 +0,0 @@ -# These class attributes behave something like the class -# inheritable accessors. But instead of copying the hash over at -# the time the subclass is first defined, the accessors simply -# delegate to their superclass unless they have been given a -# specific value. This stops the strange situation where values -# set after class definition don't get applied to subclasses. -class Class - def superclass_delegating_reader(*names) - class_name_to_stop_searching_on = self.superclass.name.blank? ? "Object" : self.superclass.name - names.each do |name| - class_eval <<-EOS - def self.#{name} # def self.only_reader - if defined?(@#{name}) # if defined?(@only_reader) - @#{name} # @only_reader - elsif superclass < #{class_name_to_stop_searching_on} && # elsif superclass < Object && - superclass.respond_to?(:#{name}) # superclass.respond_to?(:only_reader) - superclass.#{name} # superclass.only_reader - end # end - end # end - def #{name} # def only_reader - self.class.#{name} # self.class.only_reader - end # end - def self.#{name}? # def self.only_reader? - !!#{name} # !!only_reader - end # end - def #{name}? # def only_reader? - !!#{name} # !!only_reader - end # end - EOS - end - end - - def superclass_delegating_writer(*names) - names.each do |name| - class_eval <<-EOS - def self.#{name}=(value) # def self.only_writer=(value) - @#{name} = value # @only_writer = value - end # end - EOS - end - end - - def superclass_delegating_accessor(*names) - superclass_delegating_reader(*names) - superclass_delegating_writer(*names) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb b/vendor/rails/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb deleted file mode 100644 index 1794afe..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb +++ /dev/null @@ -1,140 +0,0 @@ -# Retain for backward compatibility. Methods are now included in Class. -module ClassInheritableAttributes # :nodoc: -end - -# Allows attributes to be shared within an inheritance hierarchy, but where each descendant gets a copy of -# their parents' attributes, instead of just a pointer to the same. This means that the child can add elements -# to, for example, an array without those additions being shared with either their parent, siblings, or -# children, which is unlike the regular class-level attributes that are shared across the entire hierarchy. -class Class # :nodoc: - def class_inheritable_reader(*syms) - syms.each do |sym| - next if sym.is_a?(Hash) - class_eval <<-EOS - def self.#{sym} # def self.before_add_for_comments - read_inheritable_attribute(:#{sym}) # read_inheritable_attribute(:before_add_for_comments) - end # end - # - def #{sym} # def before_add_for_comments - self.class.#{sym} # self.class.before_add_for_comments - end # end - EOS - end - end - - def class_inheritable_writer(*syms) - options = syms.extract_options! - syms.each do |sym| - class_eval <<-EOS - def self.#{sym}=(obj) # def self.color=(obj) - write_inheritable_attribute(:#{sym}, obj) # write_inheritable_attribute(:color, obj) - end # end - # - #{" # - def #{sym}=(obj) # def color=(obj) - self.class.#{sym} = obj # self.class.color = obj - end # end - " unless options[:instance_writer] == false } # # the writer above is generated unless options[:instance_writer] == false - EOS - end - end - - def class_inheritable_array_writer(*syms) - options = syms.extract_options! - syms.each do |sym| - class_eval <<-EOS - def self.#{sym}=(obj) # def self.levels=(obj) - write_inheritable_array(:#{sym}, obj) # write_inheritable_array(:levels, obj) - end # end - # - #{" # - def #{sym}=(obj) # def levels=(obj) - self.class.#{sym} = obj # self.class.levels = obj - end # end - " unless options[:instance_writer] == false } # # the writer above is generated unless options[:instance_writer] == false - EOS - end - end - - def class_inheritable_hash_writer(*syms) - options = syms.extract_options! - syms.each do |sym| - class_eval <<-EOS - def self.#{sym}=(obj) # def self.nicknames=(obj) - write_inheritable_hash(:#{sym}, obj) # write_inheritable_hash(:nicknames, obj) - end # end - # - #{" # - def #{sym}=(obj) # def nicknames=(obj) - self.class.#{sym} = obj # self.class.nicknames = obj - end # end - " unless options[:instance_writer] == false } # # the writer above is generated unless options[:instance_writer] == false - EOS - end - end - - def class_inheritable_accessor(*syms) - class_inheritable_reader(*syms) - class_inheritable_writer(*syms) - end - - def class_inheritable_array(*syms) - class_inheritable_reader(*syms) - class_inheritable_array_writer(*syms) - end - - def class_inheritable_hash(*syms) - class_inheritable_reader(*syms) - class_inheritable_hash_writer(*syms) - end - - def inheritable_attributes - @inheritable_attributes ||= EMPTY_INHERITABLE_ATTRIBUTES - end - - def write_inheritable_attribute(key, value) - if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES) - @inheritable_attributes = {} - end - inheritable_attributes[key] = value - end - - def write_inheritable_array(key, elements) - write_inheritable_attribute(key, []) if read_inheritable_attribute(key).nil? - write_inheritable_attribute(key, read_inheritable_attribute(key) + elements) - end - - def write_inheritable_hash(key, hash) - write_inheritable_attribute(key, {}) if read_inheritable_attribute(key).nil? - write_inheritable_attribute(key, read_inheritable_attribute(key).merge(hash)) - end - - def read_inheritable_attribute(key) - inheritable_attributes[key] - end - - def reset_inheritable_attributes - @inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES - end - - private - # Prevent this constant from being created multiple times - EMPTY_INHERITABLE_ATTRIBUTES = {}.freeze unless const_defined?(:EMPTY_INHERITABLE_ATTRIBUTES) - - def inherited_with_inheritable_attributes(child) - inherited_without_inheritable_attributes(child) if respond_to?(:inherited_without_inheritable_attributes) - - if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES) - new_inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES - else - new_inheritable_attributes = inheritable_attributes.inject({}) do |memo, (key, value)| - memo.update(key => value.duplicable? ? value.dup : value) - end - end - - child.instance_variable_set('@inheritable_attributes', new_inheritable_attributes) - end - - alias inherited_without_inheritable_attributes inherited - alias inherited inherited_with_inheritable_attributes -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb b/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb deleted file mode 100644 index 10660ed..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb +++ /dev/null @@ -1,50 +0,0 @@ -class Class #:nodoc: - - # Unassociates the class with its subclasses and removes the subclasses - # themselves. - # - # Integer.remove_subclasses # => [Bignum, Fixnum] - # Fixnum # => NameError: uninitialized constant Fixnum - def remove_subclasses - Object.remove_subclasses_of(self) - end - - # Returns an array with the names of the subclasses of +self+ as strings. - # - # Integer.subclasses # => ["Bignum", "Fixnum"] - def subclasses - Object.subclasses_of(self).map { |o| o.to_s } - end - - # Removes the classes in +klasses+ from their parent module. - # - # Ordinary classes belong to some module via a constant. This method computes - # that constant name from the class name and removes it from the module it - # belongs to. - # - # Object.remove_class(Integer) # => [Integer] - # Integer # => NameError: uninitialized constant Integer - # - # Take into account that in general the class object could be still stored - # somewhere else. - # - # i = Integer # => Integer - # Object.remove_class(Integer) # => [Integer] - # Integer # => NameError: uninitialized constant Integer - # i.subclasses # => ["Bignum", "Fixnum"] - # Fixnum.superclass # => Integer - def remove_class(*klasses) - klasses.flatten.each do |klass| - # Skip this class if there is nothing bound to this name - next unless defined?(klass.name) - - basename = klass.to_s.split("::").last - parent = klass.parent - - # Skip this class if it does not match the current one bound to this name - next unless parent.const_defined?(basename) && klass = parent.const_get(basename) - - parent.instance_eval { remove_const basename } unless parent == klass - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/date.rb b/vendor/rails/activesupport/lib/active_support/core_ext/date.rb deleted file mode 100644 index 3f56c56..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/date.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'date' -require 'active_support/core_ext/date/behavior' -require 'active_support/core_ext/date/calculations' -require 'active_support/core_ext/date/conversions' - -class Date#:nodoc: - include ActiveSupport::CoreExtensions::Date::Behavior - include ActiveSupport::CoreExtensions::Date::Calculations - include ActiveSupport::CoreExtensions::Date::Conversions -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/date/behavior.rb b/vendor/rails/activesupport/lib/active_support/core_ext/date/behavior.rb deleted file mode 100644 index bd378eb..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/date/behavior.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'date' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Date #:nodoc: - module Behavior - # Enable more predictable duck-typing on Date-like classes. See - # Object#acts_like?. - def acts_like_date? - true - end - - # Date memoizes some instance methods using metaprogramming to wrap - # the methods with one that caches the result in an instance variable. - # - # If a Date is frozen but the memoized method hasn't been called, the - # first call will result in a frozen object error since the memo - # instance variable is uninitialized. - # - # Work around by eagerly memoizing before freezing. - # - # Ruby 1.9 uses a preinitialized instance variable so it's unaffected. - # This hack is as close as we can get to feature detection: - begin - ::Date.today.freeze.jd - rescue => frozen_object_error - if frozen_object_error.message =~ /frozen/ - def freeze #:nodoc: - self.class.private_instance_methods(false).each do |m| - if m.to_s =~ /\A__\d+__\Z/ - instance_variable_set(:"@#{m}", [send(m)]) - end - end - - super - end - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb b/vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb deleted file mode 100644 index 43d70c7..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb +++ /dev/null @@ -1,230 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Date #:nodoc: - # Enables the use of time calculations within Time itself - module Calculations - def self.included(base) #:nodoc: - base.extend ClassMethods - - base.instance_eval do - alias_method :plus_without_duration, :+ - alias_method :+, :plus_with_duration - - alias_method :minus_without_duration, :- - alias_method :-, :minus_with_duration - end - end - - module ClassMethods - # Returns a new Date representing the date 1 day ago (i.e. yesterday's date). - def yesterday - ::Date.today.yesterday - end - - # Returns a new Date representing the date 1 day after today (i.e. tomorrow's date). - def tomorrow - ::Date.today.tomorrow - end - - # Returns Time.zone.today when config.time_zone is set, otherwise just returns Date.today. - def current - ::Time.zone_default ? ::Time.zone.today : ::Date.today - end - end - - # Tells whether the Date object's date lies in the past - def past? - self < ::Date.current - end - - # Tells whether the Date object's date is today - def today? - self.to_date == ::Date.current # we need the to_date because of DateTime - end - - # Tells whether the Date object's date lies in the future - def future? - self > ::Date.current - end - - # Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00) - # and then subtracts the specified number of seconds - def ago(seconds) - to_time.since(-seconds) - end - - # Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00) - # and then adds the specified number of seconds - def since(seconds) - to_time.since(seconds) - end - alias :in :since - - # Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00) - def beginning_of_day - to_time - end - alias :midnight :beginning_of_day - alias :at_midnight :beginning_of_day - alias :at_beginning_of_day :beginning_of_day - - # Converts Date to a Time (or DateTime if necessary) with the time portion set to the end of the day (23:59:59) - def end_of_day - to_time.end_of_day - end - - def plus_with_duration(other) #:nodoc: - if ActiveSupport::Duration === other - other.since(self) - else - plus_without_duration(other) - end - end - - def minus_with_duration(other) #:nodoc: - if ActiveSupport::Duration === other - plus_with_duration(-other) - else - minus_without_duration(other) - end - end - - # Provides precise Date calculations for years, months, and days. The +options+ parameter takes a hash with - # any of these keys: <tt>:years</tt>, <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>. - def advance(options) - d = self - d = d >> options.delete(:years) * 12 if options[:years] - d = d >> options.delete(:months) if options[:months] - d = d + options.delete(:weeks) * 7 if options[:weeks] - d = d + options.delete(:days) if options[:days] - d - end - - # Returns a new Date where one or more of the elements have been changed according to the +options+ parameter. - # - # Examples: - # - # Date.new(2007, 5, 12).change(:day => 1) # => Date.new(2007, 5, 1) - # Date.new(2007, 5, 12).change(:year => 2005, :month => 1) # => Date.new(2005, 1, 12) - def change(options) - ::Date.new( - options[:year] || self.year, - options[:month] || self.month, - options[:day] || self.day - ) - end - - # Returns a new Date/DateTime representing the time a number of specified months ago - def months_ago(months) - advance(:months => -months) - end - - # Returns a new Date/DateTime representing the time a number of specified months in the future - def months_since(months) - advance(:months => months) - end - - # Returns a new Date/DateTime representing the time a number of specified years ago - def years_ago(years) - advance(:years => -years) - end - - # Returns a new Date/DateTime representing the time a number of specified years in the future - def years_since(years) - advance(:years => years) - end - - # Short-hand for years_ago(1) - def last_year - years_ago(1) - end - - # Short-hand for years_since(1) - def next_year - years_since(1) - end - - # Short-hand for months_ago(1) - def last_month - months_ago(1) - end - - # Short-hand for months_since(1) - def next_month - months_since(1) - end - - # Returns a new Date/DateTime representing the "start" of this week (i.e, Monday; DateTime objects will have time set to 0:00) - def beginning_of_week - days_to_monday = self.wday!=0 ? self.wday-1 : 6 - result = self - days_to_monday - self.acts_like?(:time) ? result.midnight : result - end - alias :monday :beginning_of_week - alias :at_beginning_of_week :beginning_of_week - - # Returns a new Date/DateTime representing the end of this week (Sunday, DateTime objects will have time set to 23:59:59) - def end_of_week - days_to_sunday = self.wday!=0 ? 7-self.wday : 0 - result = self + days_to_sunday.days - self.acts_like?(:time) ? result.end_of_day : result - end - alias :at_end_of_week :end_of_week - - # Returns a new Date/DateTime representing the start of the given day in next week (default is Monday). - def next_week(day = :monday) - days_into_week = { :monday => 0, :tuesday => 1, :wednesday => 2, :thursday => 3, :friday => 4, :saturday => 5, :sunday => 6} - result = (self + 7).beginning_of_week + days_into_week[day] - self.acts_like?(:time) ? result.change(:hour => 0) : result - end - - # Returns a new ; DateTime objects will have time set to 0:00DateTime representing the start of the month (1st of the month; DateTime objects will have time set to 0:00) - def beginning_of_month - self.acts_like?(:time) ? change(:day => 1,:hour => 0, :min => 0, :sec => 0) : change(:day => 1) - end - alias :at_beginning_of_month :beginning_of_month - - # Returns a new Date/DateTime representing the end of the month (last day of the month; DateTime objects will have time set to 0:00) - def end_of_month - last_day = ::Time.days_in_month( self.month, self.year ) - self.acts_like?(:time) ? change(:day => last_day, :hour => 23, :min => 59, :sec => 59) : change(:day => last_day) - end - alias :at_end_of_month :end_of_month - - # Returns a new Date/DateTime representing the start of the quarter (1st of january, april, july, october; DateTime objects will have time set to 0:00) - def beginning_of_quarter - beginning_of_month.change(:month => [10, 7, 4, 1].detect { |m| m <= self.month }) - end - alias :at_beginning_of_quarter :beginning_of_quarter - - # Returns a new Date/DateTime representing the end of the quarter (last day of march, june, september, december; DateTime objects will have time set to 23:59:59) - def end_of_quarter - beginning_of_month.change(:month => [3, 6, 9, 12].detect { |m| m >= self.month }).end_of_month - end - alias :at_end_of_quarter :end_of_quarter - - # Returns a new Date/DateTime representing the start of the year (1st of january; DateTime objects will have time set to 0:00) - def beginning_of_year - self.acts_like?(:time) ? change(:month => 1, :day => 1, :hour => 0, :min => 0, :sec => 0) : change(:month => 1, :day => 1) - end - alias :at_beginning_of_year :beginning_of_year - - # Returns a new Time representing the end of the year (31st of december; DateTime objects will have time set to 23:59:59) - def end_of_year - self.acts_like?(:time) ? change(:month => 12,:day => 31,:hour => 23, :min => 59, :sec => 59) : change(:month => 12, :day => 31) - end - alias :at_end_of_year :end_of_year - - # Convenience method which returns a new Date/DateTime representing the time 1 day ago - def yesterday - self - 1 - end - - # Convenience method which returns a new Date/DateTime representing the time 1 day since the instance time - def tomorrow - self + 1 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/date/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/date/conversions.rb deleted file mode 100644 index 8d9f023..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/date/conversions.rb +++ /dev/null @@ -1,107 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Date #:nodoc: - # Converting dates to formatted strings, times, and datetimes. - module Conversions - DATE_FORMATS = { - :short => "%e %b", - :long => "%B %e, %Y", - :db => "%Y-%m-%d", - :number => "%Y%m%d", - :long_ordinal => lambda { |date| date.strftime("%B #{date.day.ordinalize}, %Y") }, # => "April 25th, 2007" - :rfc822 => "%e %b %Y" - } - - def self.included(base) #:nodoc: - base.instance_eval do - alias_method :to_default_s, :to_s - alias_method :to_s, :to_formatted_s - alias_method :default_inspect, :inspect - alias_method :inspect, :readable_inspect - - # Ruby 1.9 has Date#to_time which converts to localtime only. - remove_method :to_time if base.instance_methods.include?(:to_time) - - # Ruby 1.9 has Date#xmlschema which converts to a string without the time component. - remove_method :xmlschema if base.instance_methods.include?(:xmlschema) - end - end - - # Convert to a formatted string. See DATE_FORMATS for predefined formats. - # - # This method is aliased to <tt>to_s</tt>. - # - # ==== Examples - # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007 - # - # date.to_formatted_s(:db) # => "2007-11-10" - # date.to_s(:db) # => "2007-11-10" - # - # date.to_formatted_s(:short) # => "10 Nov" - # date.to_formatted_s(:long) # => "November 10, 2007" - # date.to_formatted_s(:long_ordinal) # => "November 10th, 2007" - # date.to_formatted_s(:rfc822) # => "10 Nov 2007" - # - # == Adding your own time formats to to_formatted_s - # You can add your own formats to the Date::DATE_FORMATS hash. - # Use the format name as the hash key and either a strftime string - # or Proc instance that takes a date argument as the value. - # - # # config/initializers/time_formats.rb - # Date::DATE_FORMATS[:month_and_year] = "%B %Y" - # Date::DATE_FORMATS[:short_ordinal] = lambda { |date| date.strftime("%B #{date.day.ordinalize}") } - def to_formatted_s(format = :default) - if formatter = DATE_FORMATS[format] - if formatter.respond_to?(:call) - formatter.call(self).to_s - else - strftime(formatter) - end - else - to_default_s - end - end - - # Overrides the default inspect method with a human readable one, e.g., "Mon, 21 Feb 2005" - def readable_inspect - strftime("%a, %d %b %Y") - end - - # A method to keep Time, Date and DateTime instances interchangeable on conversions. - # In this case, it simply returns +self+. - def to_date - self - end if RUBY_VERSION < '1.9' - - # Converts a Date instance to a Time, where the time is set to the beginning of the day. - # The timezone can be either :local or :utc (default :local). - # - # ==== Examples - # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007 - # - # date.to_time # => Sat Nov 10 00:00:00 0800 2007 - # date.to_time(:local) # => Sat Nov 10 00:00:00 0800 2007 - # - # date.to_time(:utc) # => Sat Nov 10 00:00:00 UTC 2007 - def to_time(form = :local) - ::Time.send("#{form}_time", year, month, day) - end - - # Converts a Date instance to a DateTime, where the time is set to the beginning of the day - # and UTC offset is set to 0. - # - # ==== Examples - # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007 - # - # date.to_datetime # => Sat, 10 Nov 2007 00:00:00 0000 - def to_datetime - ::DateTime.civil(year, month, day, 0, 0, 0, 0) - end if RUBY_VERSION < '1.9' - - def xmlschema - to_time.xmlschema - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/date_time.rb b/vendor/rails/activesupport/lib/active_support/core_ext/date_time.rb deleted file mode 100644 index 66a93ea..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/date_time.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'date' -require 'active_support/core_ext/time/behavior' -require 'active_support/core_ext/time/zones' -require 'active_support/core_ext/date_time/calculations' -require 'active_support/core_ext/date_time/conversions' - -class DateTime - include ActiveSupport::CoreExtensions::Time::Behavior - include ActiveSupport::CoreExtensions::Time::Zones - include ActiveSupport::CoreExtensions::DateTime::Calculations - include ActiveSupport::CoreExtensions::DateTime::Conversions -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/vendor/rails/activesupport/lib/active_support/core_ext/date_time/calculations.rb deleted file mode 100644 index 0099431..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/date_time/calculations.rb +++ /dev/null @@ -1,126 +0,0 @@ -require 'rational' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module DateTime #:nodoc: - # Enables the use of time calculations within DateTime itself - module Calculations - def self.included(base) #:nodoc: - base.extend ClassMethods - - base.class_eval do - alias_method :compare_without_coercion, :<=> - alias_method :<=>, :compare_with_coercion - end - end - - module ClassMethods - # DateTimes aren't aware of DST rules, so use a consistent non-DST offset when creating a DateTime with an offset in the local zone - def local_offset - ::Time.local(2007).utc_offset.to_r / 86400 - end - - def current - ::Time.zone_default ? ::Time.zone.now.to_datetime : ::Time.now.to_datetime - end - end - - # Tells whether the DateTime object's datetime lies in the past - def past? - self < ::DateTime.current - end - - # Tells whether the DateTime object's datetime lies in the future - def future? - self > ::DateTime.current - end - - # Seconds since midnight: DateTime.now.seconds_since_midnight - def seconds_since_midnight - self.sec + (self.min * 60) + (self.hour * 3600) - end - - # Returns a new DateTime where one or more of the elements have been changed according to the +options+ parameter. The time options - # (hour, minute, sec) reset cascadingly, so if only the hour is passed, then minute and sec is set to 0. If the hour and - # minute is passed, then sec is set to 0. - def change(options) - ::DateTime.civil( - options[:year] || self.year, - options[:month] || self.month, - options[:day] || self.day, - options[:hour] || self.hour, - options[:min] || (options[:hour] ? 0 : self.min), - options[:sec] || ((options[:hour] || options[:min]) ? 0 : self.sec), - options[:offset] || self.offset, - options[:start] || self.start - ) - end - - # Uses Date to provide precise Time calculations for years, months, and days. - # The +options+ parameter takes a hash with any of these keys: <tt>:years</tt>, - # <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>, <tt>:hours</tt>, - # <tt>:minutes</tt>, <tt>:seconds</tt>. - def advance(options) - d = to_date.advance(options) - datetime_advanced_by_date = change(:year => d.year, :month => d.month, :day => d.day) - seconds_to_advance = (options[:seconds] || 0) + (options[:minutes] || 0) * 60 + (options[:hours] || 0) * 3600 - seconds_to_advance == 0 ? datetime_advanced_by_date : datetime_advanced_by_date.since(seconds_to_advance) - end - - # Returns a new DateTime representing the time a number of seconds ago - # Do not use this method in combination with x.months, use months_ago instead! - def ago(seconds) - self.since(-seconds) - end - - # Returns a new DateTime representing the time a number of seconds since the instance time - # Do not use this method in combination with x.months, use months_since instead! - def since(seconds) - self + Rational(seconds.round, 86400) - end - alias :in :since - - # Returns a new DateTime representing the start of the day (0:00) - def beginning_of_day - change(:hour => 0) - end - alias :midnight :beginning_of_day - alias :at_midnight :beginning_of_day - alias :at_beginning_of_day :beginning_of_day - - # Returns a new DateTime representing the end of the day (23:59:59) - def end_of_day - change(:hour => 23, :min => 59, :sec => 59) - end - - # Adjusts DateTime to UTC by adding its offset value; offset is set to 0 - # - # Example: - # - # DateTime.civil(2005, 2, 21, 10, 11, 12, Rational(-6, 24)) # => Mon, 21 Feb 2005 10:11:12 -0600 - # DateTime.civil(2005, 2, 21, 10, 11, 12, Rational(-6, 24)).utc # => Mon, 21 Feb 2005 16:11:12 +0000 - def utc - new_offset(0) - end - alias_method :getutc, :utc - - # Returns true if offset == 0 - def utc? - offset == 0 - end - - # Returns the offset value in seconds - def utc_offset - (offset * 86400).to_i - end - - # Layers additional behavior on DateTime#<=> so that Time and ActiveSupport::TimeWithZone instances can be compared with a DateTime - def compare_with_coercion(other) - other = other.comparable_time if other.respond_to?(:comparable_time) - other = other.to_datetime unless other.acts_like?(:date) - compare_without_coercion(other) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/date_time/conversions.rb deleted file mode 100644 index 7c94826..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/date_time/conversions.rb +++ /dev/null @@ -1,96 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module DateTime #:nodoc: - # Converting datetimes to formatted strings, dates, and times. - module Conversions - def self.append_features(base) #:nodoc: - base.class_eval do - alias_method :default_inspect, :inspect - alias_method :to_default_s, :to_s unless (instance_methods(false) & [:to_s, 'to_s']).empty? - - # Ruby 1.9 has DateTime#to_time which internally relies on Time. We define our own #to_time which allows - # DateTimes outside the range of what can be created with Time. - remove_method :to_time if instance_methods.include?(:to_time) - end - - super - - base.class_eval do - alias_method :to_s, :to_formatted_s - alias_method :inspect, :readable_inspect - end - end - - # Convert to a formatted string. See Time::DATE_FORMATS for predefined formats. - # - # This method is aliased to <tt>to_s</tt>. - # - # === Examples - # datetime = DateTime.civil(2007, 12, 4, 0, 0, 0, 0) # => Tue, 04 Dec 2007 00:00:00 +0000 - # - # datetime.to_formatted_s(:db) # => "2007-12-04 00:00:00" - # datetime.to_s(:db) # => "2007-12-04 00:00:00" - # datetime.to_s(:number) # => "20071204000000" - # datetime.to_formatted_s(:short) # => "04 Dec 00:00" - # datetime.to_formatted_s(:long) # => "December 04, 2007 00:00" - # datetime.to_formatted_s(:long_ordinal) # => "December 4th, 2007 00:00" - # datetime.to_formatted_s(:rfc822) # => "Tue, 04 Dec 2007 00:00:00 +0000" - # - # == Adding your own datetime formats to to_formatted_s - # DateTime formats are shared with Time. You can add your own to the - # Time::DATE_FORMATS hash. Use the format name as the hash key and - # either a strftime string or Proc instance that takes a time or - # datetime argument as the value. - # - # # config/initializers/time_formats.rb - # Time::DATE_FORMATS[:month_and_year] = "%B %Y" - # Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") } - def to_formatted_s(format = :default) - return to_default_s unless formatter = ::Time::DATE_FORMATS[format] - formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter) - end - - # Returns the +utc_offset+ as an +HH:MM formatted string. Examples: - # - # datetime = DateTime.civil(2000, 1, 1, 0, 0, 0, Rational(-6, 24)) - # datetime.formatted_offset # => "-06:00" - # datetime.formatted_offset(false) # => "-0600" - def formatted_offset(colon = true, alternate_utc_string = nil) - utc? && alternate_utc_string || utc_offset.to_utc_offset_s(colon) - end - - # Overrides the default inspect method with a human readable one, e.g., "Mon, 21 Feb 2005 14:30:00 +0000" - def readable_inspect - to_s(:rfc822) - end - - # Converts self to a Ruby Date object; time portion is discarded - def to_date - ::Date.new(year, month, day) - end - - # Attempts to convert self to a Ruby Time object; returns self if out of range of Ruby Time class - # If self has an offset other than 0, self will just be returned unaltered, since there's no clean way to map it to a Time - def to_time - self.offset == 0 ? ::Time.utc_time(year, month, day, hour, min, sec) : self - end - - # To be able to keep Times, Dates and DateTimes interchangeable on conversions - def to_datetime - self - end - - # Converts datetime to an appropriate format for use in XML - def xmlschema - strftime("%Y-%m-%dT%H:%M:%S%Z") - end if RUBY_VERSION < '1.9' - - # Converts self to a floating-point number of seconds since the Unix epoch - def to_f - days_since_unix_epoch = self - ::DateTime.civil(1970) - (days_since_unix_epoch * 86_400).to_f - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/duplicable.rb b/vendor/rails/activesupport/lib/active_support/core_ext/duplicable.rb deleted file mode 100644 index 8f49ddf..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/duplicable.rb +++ /dev/null @@ -1,43 +0,0 @@ -class Object - # Can you safely .dup this object? - # False for nil, false, true, symbols, and numbers; true otherwise. - def duplicable? - true - end -end - -class NilClass #:nodoc: - def duplicable? - false - end -end - -class FalseClass #:nodoc: - def duplicable? - false - end -end - -class TrueClass #:nodoc: - def duplicable? - false - end -end - -class Symbol #:nodoc: - def duplicable? - false - end -end - -class Numeric #:nodoc: - def duplicable? - false - end -end - -class Class #:nodoc: - def duplicable? - false - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/enumerable.rb b/vendor/rails/activesupport/lib/active_support/core_ext/enumerable.rb deleted file mode 100644 index a7eaccf..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/enumerable.rb +++ /dev/null @@ -1,116 +0,0 @@ -require 'active_support/ordered_hash' - -module Enumerable - # Ruby 1.8.7 introduces group_by, but the result isn't ordered. Override it. - remove_method(:group_by) if [].respond_to?(:group_by) && RUBY_VERSION < '1.9' - - # Collect an enumerable into sets, grouped by the result of a block. Useful, - # for example, for grouping records by date. - # - # Example: - # - # latest_transcripts.group_by(&:day).each do |day, transcripts| - # p "#{day} -> #{transcripts.map(&:class).join(', ')}" - # end - # "2006-03-01 -> Transcript" - # "2006-02-28 -> Transcript" - # "2006-02-27 -> Transcript, Transcript" - # "2006-02-26 -> Transcript, Transcript" - # "2006-02-25 -> Transcript" - # "2006-02-24 -> Transcript, Transcript" - # "2006-02-23 -> Transcript" - def group_by - assoc = ActiveSupport::OrderedHash.new - - each do |element| - key = yield(element) - - if assoc.has_key?(key) - assoc[key] << element - else - assoc[key] = [element] - end - end - - assoc - end unless [].respond_to?(:group_by) - - # Calculates a sum from the elements. Examples: - # - # payments.sum { |p| p.price * p.tax_rate } - # payments.sum(&:price) - # - # The latter is a shortcut for: - # - # payments.inject { |sum, p| sum + p.price } - # - # It can also calculate the sum without the use of a block. - # - # [5, 15, 10].sum # => 30 - # ["foo", "bar"].sum # => "foobar" - # [[1, 2], [3, 1, 5]].sum => [1, 2, 3, 1, 5] - # - # The default sum of an empty list is zero. You can override this default: - # - # [].sum(Payment.new(0)) { |i| i.amount } # => Payment.new(0) - # - def sum(identity = 0, &block) - return identity unless size > 0 - - if block_given? - map(&block).sum - else - inject { |sum, element| sum + element } - end - end - - # Iterates over a collection, passing the current element *and* the - # +memo+ to the block. Handy for building up hashes or - # reducing collections down to one object. Examples: - # - # %w(foo bar).each_with_object({}) { |str, hsh| hsh[str] = str.upcase } #=> {'foo' => 'FOO', 'bar' => 'BAR'} - # - # *Note* that you can't use immutable objects like numbers, true or false as - # the memo. You would think the following returns 120, but since the memo is - # never changed, it does not. - # - # (1..5).each_with_object(1) { |value, memo| memo *= value } # => 1 - # - def each_with_object(memo, &block) - returning memo do |m| - each do |element| - block.call(element, m) - end - end - end unless [].respond_to?(:each_with_object) - - # Convert an enumerable to a hash. Examples: - # - # people.index_by(&:login) - # => { "nextangle" => <Person ...>, "chade-" => <Person ...>, ...} - # people.index_by { |person| "#{person.first_name} #{person.last_name}" } - # => { "Chade- Fowlersburg-e" => <Person ...>, "David Heinemeier Hansson" => <Person ...>, ...} - # - def index_by - inject({}) do |accum, elem| - accum[yield(elem)] = elem - accum - end - end - - # Returns true if the collection has more than 1 element. Functionally equivalent to collection.size > 1. - # Works with a block too ala any?, so people.many? { |p| p.age > 26 } # => returns true if more than 1 person is over 26. - def many?(&block) - size = block_given? ? select(&block).size : self.size - size > 1 - end - - # Returns true if none of the elements match the given block. - # - # success = responses.none? {|r| r.status / 100 == 5 } - # - # This is a builtin method in Ruby 1.8.7 and later. - def none?(&block) - !any?(&block) - end unless [].respond_to?(:none?) -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/exception.rb b/vendor/rails/activesupport/lib/active_support/core_ext/exception.rb deleted file mode 100644 index cde0df4..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/exception.rb +++ /dev/null @@ -1,45 +0,0 @@ -module ActiveSupport - if RUBY_VERSION >= '1.9' - FrozenObjectError = RuntimeError - else - FrozenObjectError = TypeError - end -end - -# TODO: Turn all this into using the BacktraceCleaner. -class Exception # :nodoc: - def clean_message - Pathname.clean_within message - end - - TraceSubstitutions = [] - FrameworkStart = /action_controller\/dispatcher\.rb/.freeze - FrameworkRegexp = /generated|vendor|dispatch|ruby|script\/\w+/.freeze - - def clean_backtrace - backtrace.collect do |line| - Pathname.clean_within(TraceSubstitutions.inject(line) do |result, (regexp, sub)| - result.gsub regexp, sub - end) - end - end - - def application_backtrace - before_framework_frame = nil - before_application_frame = true - - trace = clean_backtrace.reject do |line| - before_framework_frame ||= (line =~ FrameworkStart) - non_app_frame = (line =~ FrameworkRegexp) - before_application_frame = false unless non_app_frame - before_framework_frame || (non_app_frame && !before_application_frame) - end - - # If we didn't find any application frames, return an empty app trace. - before_application_frame ? [] : trace - end - - def framework_backtrace - clean_backtrace.grep FrameworkRegexp - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/file.rb b/vendor/rails/activesupport/lib/active_support/core_ext/file.rb deleted file mode 100644 index e03f8ac..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/file.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'active_support/core_ext/file/atomic' - -class File #:nodoc: - extend ActiveSupport::CoreExtensions::File::Atomic -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/file/atomic.rb b/vendor/rails/activesupport/lib/active_support/core_ext/file/atomic.rb deleted file mode 100644 index 8cc5654..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/file/atomic.rb +++ /dev/null @@ -1,46 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module File #:nodoc: - module Atomic - # Write to a file atomically. Useful for situations where you don't - # want other processes or threads to see half-written files. - # - # File.atomic_write("important.file") do |file| - # file.write("hello") - # end - # - # If your temp directory is not on the same filesystem as the file you're - # trying to write, you can provide a different temporary directory. - # - # File.atomic_write("/data/something.important", "/data/tmp") do |f| - # file.write("hello") - # end - def atomic_write(file_name, temp_dir = Dir.tmpdir) - require 'tempfile' unless defined?(Tempfile) - - temp_file = Tempfile.new(basename(file_name), temp_dir) - yield temp_file - temp_file.close - - begin - # Get original file permissions - old_stat = stat(file_name) - rescue Errno::ENOENT - # No old permissions, write a temp file to determine the defaults - check_name = join(dirname(file_name), ".permissions_check.#{Thread.current.object_id}.#{Process.pid}.#{rand(1000000)}") - open(check_name, "w") { } - old_stat = stat(check_name) - unlink(check_name) - end - - # Overwrite original file with temp file - rename(temp_file.path, file_name) - - # Set correct permissions on new file - chown(old_stat.uid, old_stat.gid, file_name) - chmod(old_stat.mode, file_name) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/float.rb b/vendor/rails/activesupport/lib/active_support/core_ext/float.rb deleted file mode 100644 index af166aa..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/float.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'active_support/core_ext/float/rounding' -require 'active_support/core_ext/float/time' - -class Float #:nodoc: - include ActiveSupport::CoreExtensions::Float::Rounding - include ActiveSupport::CoreExtensions::Float::Time -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/float/rounding.rb b/vendor/rails/activesupport/lib/active_support/core_ext/float/rounding.rb deleted file mode 100644 index 062d466..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/float/rounding.rb +++ /dev/null @@ -1,24 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Float #:nodoc: - module Rounding - def self.included(base) #:nodoc: - base.class_eval do - alias_method :round_without_precision, :round - alias_method :round, :round_with_precision - end - end - - # Rounds the float with the specified precision. - # - # x = 1.337 - # x.round # => 1 - # x.round(1) # => 1.3 - # x.round(2) # => 1.34 - def round_with_precision(precision = nil) - precision.nil? ? round_without_precision : (self * (10 ** precision)).round / (10 ** precision).to_f - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/float/time.rb b/vendor/rails/activesupport/lib/active_support/core_ext/float/time.rb deleted file mode 100644 index 13f2e0d..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/float/time.rb +++ /dev/null @@ -1,27 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Float #:nodoc: - module Time - # Deprication helper methods not available as core_ext is loaded first. - def years - ::ActiveSupport::Deprecation.warn(self.class.deprecated_method_warning(:years, "Fractional years are not respected. Convert value to integer before calling #years."), caller) - years_without_deprecation - end - def months - ::ActiveSupport::Deprecation.warn(self.class.deprecated_method_warning(:months, "Fractional months are not respected. Convert value to integer before calling #months."), caller) - months_without_deprecation - end - - def months_without_deprecation - ActiveSupport::Duration.new(self * 30.days, [[:months, self]]) - end - alias :month :months - - def years_without_deprecation - ActiveSupport::Duration.new(self * 365.25.days, [[:years, self]]) - end - alias :year :years - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash.rb deleted file mode 100644 index a6065ab..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash.rb +++ /dev/null @@ -1,14 +0,0 @@ -%w(keys indifferent_access deep_merge reverse_merge conversions diff slice except).each do |ext| - require "active_support/core_ext/hash/#{ext}" -end - -class Hash #:nodoc: - include ActiveSupport::CoreExtensions::Hash::Keys - include ActiveSupport::CoreExtensions::Hash::IndifferentAccess - include ActiveSupport::CoreExtensions::Hash::DeepMerge - include ActiveSupport::CoreExtensions::Hash::ReverseMerge - include ActiveSupport::CoreExtensions::Hash::Conversions - include ActiveSupport::CoreExtensions::Hash::Diff - include ActiveSupport::CoreExtensions::Hash::Slice - include ActiveSupport::CoreExtensions::Hash::Except -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb deleted file mode 100644 index 1043597..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb +++ /dev/null @@ -1,237 +0,0 @@ -require 'date' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Hash #:nodoc: - module Conversions - # This module exists to decorate files deserialized using Hash.from_xml with - # the <tt>original_filename</tt> and <tt>content_type</tt> methods. - module FileLike #:nodoc: - attr_writer :original_filename, :content_type - - def original_filename - @original_filename || 'untitled' - end - - def content_type - @content_type || 'application/octet-stream' - end - end - - XML_TYPE_NAMES = { - "Symbol" => "symbol", - "Fixnum" => "integer", - "Bignum" => "integer", - "BigDecimal" => "decimal", - "Float" => "float", - "TrueClass" => "boolean", - "FalseClass" => "boolean", - "Date" => "date", - "DateTime" => "datetime", - "Time" => "datetime", - "ActiveSupport::TimeWithZone" => "datetime" - } unless defined?(XML_TYPE_NAMES) - - XML_FORMATTING = { - "symbol" => Proc.new { |symbol| symbol.to_s }, - "date" => Proc.new { |date| date.to_s(:db) }, - "datetime" => Proc.new { |time| time.xmlschema }, - "binary" => Proc.new { |binary| ActiveSupport::Base64.encode64(binary) }, - "yaml" => Proc.new { |yaml| yaml.to_yaml } - } unless defined?(XML_FORMATTING) - - # TODO: use Time.xmlschema instead of Time.parse; - # use regexp instead of Date.parse - unless defined?(XML_PARSING) - XML_PARSING = { - "symbol" => Proc.new { |symbol| symbol.to_sym }, - "date" => Proc.new { |date| ::Date.parse(date) }, - "datetime" => Proc.new { |time| ::Time.parse(time).utc rescue ::DateTime.parse(time).utc }, - "integer" => Proc.new { |integer| integer.to_i }, - "float" => Proc.new { |float| float.to_f }, - "decimal" => Proc.new { |number| BigDecimal(number) }, - "boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.strip) }, - "string" => Proc.new { |string| string.to_s }, - "yaml" => Proc.new { |yaml| YAML::load(yaml) rescue yaml }, - "base64Binary" => Proc.new { |bin| ActiveSupport::Base64.decode64(bin) }, - "file" => Proc.new do |file, entity| - f = StringIO.new(ActiveSupport::Base64.decode64(file)) - f.extend(FileLike) - f.original_filename = entity['name'] - f.content_type = entity['content_type'] - f - end - } - - XML_PARSING.update( - "double" => XML_PARSING["float"], - "dateTime" => XML_PARSING["datetime"] - ) - end - - def self.included(klass) - klass.extend(ClassMethods) - end - - # Converts a hash into a string suitable for use as a URL query string. An optional <tt>namespace</tt> can be - # passed to enclose the param names (see example below). - # - # ==== Examples - # { :name => 'David', :nationality => 'Danish' }.to_query # => "name=David&nationality=Danish" - # - # { :name => 'David', :nationality => 'Danish' }.to_query('user') # => "user%5Bname%5D=David&user%5Bnationality%5D=Danish" - def to_query(namespace = nil) - collect do |key, value| - value.to_query(namespace ? "#{namespace}[#{key}]" : key) - end.sort * '&' - end - - alias_method :to_param, :to_query - - def to_xml(options = {}) - require 'builder' unless defined?(Builder) - - options[:indent] ||= 2 - options.reverse_merge!({ :builder => Builder::XmlMarkup.new(:indent => options[:indent]), - :root => "hash" }) - options[:builder].instruct! unless options.delete(:skip_instruct) - root = rename_key(options[:root].to_s, options) - - options[:builder].__send__(:method_missing, root) do - each do |key, value| - case value - when ::Hash - value.to_xml(options.merge({ :root => key, :skip_instruct => true })) - when ::Array - value.to_xml(options.merge({ :root => key, :children => key.to_s.singularize, :skip_instruct => true})) - when ::Method, ::Proc - # If the Method or Proc takes two arguments, then - # pass the suggested child element name. This is - # used if the Method or Proc will be operating over - # multiple records and needs to create an containing - # element that will contain the objects being - # serialized. - if 1 == value.arity - value.call(options.merge({ :root => key, :skip_instruct => true })) - else - value.call(options.merge({ :root => key, :skip_instruct => true }), key.to_s.singularize) - end - else - if value.respond_to?(:to_xml) - value.to_xml(options.merge({ :root => key, :skip_instruct => true })) - else - type_name = XML_TYPE_NAMES[value.class.name] - - key = rename_key(key.to_s, options) - - attributes = options[:skip_types] || value.nil? || type_name.nil? ? { } : { :type => type_name } - if value.nil? - attributes[:nil] = true - end - - options[:builder].tag!(key, - XML_FORMATTING[type_name] ? XML_FORMATTING[type_name].call(value) : value, - attributes - ) - end - end - end - - yield options[:builder] if block_given? - end - - end - - def rename_key(key, options = {}) - camelize = options.has_key?(:camelize) && options[:camelize] - dasherize = !options.has_key?(:dasherize) || options[:dasherize] - key = key.camelize if camelize - dasherize ? key.dasherize : key - end - - module ClassMethods - def from_xml(xml) - typecast_xml_value(unrename_keys(XmlMini.parse(xml))) - end - - private - def typecast_xml_value(value) - case value.class.to_s - when 'Hash' - if value['type'] == 'array' - child_key, entries = value.detect { |k,v| k != 'type' } # child_key is throwaway - if entries.nil? || (c = value['__content__'] && c.blank?) - [] - else - case entries.class.to_s # something weird with classes not matching here. maybe singleton methods breaking is_a? - when "Array" - entries.collect { |v| typecast_xml_value(v) } - when "Hash" - [typecast_xml_value(entries)] - else - raise "can't typecast #{entries.inspect}" - end - end - elsif value.has_key?("__content__") - content = value["__content__"] - if parser = XML_PARSING[value["type"]] - if parser.arity == 2 - XML_PARSING[value["type"]].call(content, value) - else - XML_PARSING[value["type"]].call(content) - end - else - content - end - elsif value['type'] == 'string' && value['nil'] != 'true' - "" - # blank or nil parsed values are represented by nil - elsif value.blank? || value['nil'] == 'true' - nil - # If the type is the only element which makes it then - # this still makes the value nil, except if type is - # a XML node(where type['value'] is a Hash) - elsif value['type'] && value.size == 1 && !value['type'].is_a?(::Hash) - nil - else - xml_value = value.inject({}) do |h,(k,v)| - h[k] = typecast_xml_value(v) - h - end - - # Turn { :files => { :file => #<StringIO> } into { :files => #<StringIO> } so it is compatible with - # how multipart uploaded files from HTML appear - xml_value["file"].is_a?(StringIO) ? xml_value["file"] : xml_value - end - when 'Array' - value.map! { |i| typecast_xml_value(i) } - case value.length - when 0 then nil - when 1 then value.first - else value - end - when 'String' - value - else - raise "can't typecast #{value.class.name} - #{value.inspect}" - end - end - - def unrename_keys(params) - case params.class.to_s - when "Hash" - params.inject({}) do |h,(k,v)| - h[k.to_s.underscore.tr("-", "_")] = unrename_keys(v) - h - end - when "Array" - params.map { |v| unrename_keys(v) } - else - params - end - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/deep_merge.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/deep_merge.rb deleted file mode 100644 index f8842ba..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/deep_merge.rb +++ /dev/null @@ -1,23 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Hash #:nodoc: - # Allows for deep merging - module DeepMerge - # Returns a new hash with +self+ and +other_hash+ merged recursively. - def deep_merge(other_hash) - self.merge(other_hash) do |key, oldval, newval| - oldval = oldval.to_hash if oldval.respond_to?(:to_hash) - newval = newval.to_hash if newval.respond_to?(:to_hash) - oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? oldval.deep_merge(newval) : newval - end - end - - # Returns a new hash with +self+ and +other_hash+ merged recursively. - # Modifies the receiver in place. - def deep_merge!(other_hash) - replace(deep_merge(other_hash)) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/diff.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/diff.rb deleted file mode 100644 index 6abd678..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/diff.rb +++ /dev/null @@ -1,19 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Hash #:nodoc: - module Diff - # Returns a hash that represents the difference between two hashes. - # - # Examples: - # - # {1 => 2}.diff(1 => 2) # => {} - # {1 => 2}.diff(1 => 3) # => {1 => 2} - # {}.diff(1 => 2) # => {1 => 2} - # {1 => 2, 3 => 4}.diff(1 => 2) # => {3 => 4} - def diff(h2) - self.dup.delete_if { |k, v| h2[k] == v }.merge(h2.dup.delete_if { |k, v| self.has_key?(k) }) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb deleted file mode 100644 index 949976d..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'set' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Hash #:nodoc: - # Return a hash that includes everything but the given keys. This is useful for - # limiting a set of parameters to everything but a few known toggles: - # - # @person.update_attributes(params[:person].except(:admin)) - module Except - # Returns a new hash without the given keys. - def except(*keys) - dup.except!(*keys) - end - - # Replaces the hash without the given keys. - def except!(*keys) - keys.map! { |key| convert_key(key) } if respond_to?(:convert_key) - keys.each { |key| delete(key) } - self - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb deleted file mode 100644 index 34ba8a0..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb +++ /dev/null @@ -1,143 +0,0 @@ -# This class has dubious semantics and we only have it so that -# people can write params[:key] instead of params['key'] -# and they get the same value for both keys. - -class HashWithIndifferentAccess < Hash - def initialize(constructor = {}) - if constructor.is_a?(Hash) - super() - update(constructor) - else - super(constructor) - end - end - - def default(key = nil) - if key.is_a?(Symbol) && include?(key = key.to_s) - self[key] - else - super - end - end - - alias_method :regular_writer, :[]= unless method_defined?(:regular_writer) - alias_method :regular_update, :update unless method_defined?(:regular_update) - - # Assigns a new value to the hash: - # - # hash = HashWithIndifferentAccess.new - # hash[:key] = "value" - # - def []=(key, value) - regular_writer(convert_key(key), convert_value(value)) - end - - # Updates the instantized hash with values from the second: - # - # hash_1 = HashWithIndifferentAccess.new - # hash_1[:key] = "value" - # - # hash_2 = HashWithIndifferentAccess.new - # hash_2[:key] = "New Value!" - # - # hash_1.update(hash_2) # => {"key"=>"New Value!"} - # - def update(other_hash) - other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) } - self - end - - alias_method :merge!, :update - - # Checks the hash for a key matching the argument passed in: - # - # hash = HashWithIndifferentAccess.new - # hash["key"] = "value" - # hash.key? :key # => true - # hash.key? "key" # => true - # - def key?(key) - super(convert_key(key)) - end - - alias_method :include?, :key? - alias_method :has_key?, :key? - alias_method :member?, :key? - - # Fetches the value for the specified key, same as doing hash[key] - def fetch(key, *extras) - super(convert_key(key), *extras) - end - - # Returns an array of the values at the specified indices: - # - # hash = HashWithIndifferentAccess.new - # hash[:a] = "x" - # hash[:b] = "y" - # hash.values_at("a", "b") # => ["x", "y"] - # - def values_at(*indices) - indices.collect {|key| self[convert_key(key)]} - end - - # Returns an exact copy of the hash. - def dup - HashWithIndifferentAccess.new(self) - end - - # Merges the instantized and the specified hashes together, giving precedence to the values from the second hash - # Does not overwrite the existing hash. - def merge(hash) - self.dup.update(hash) - end - - # Performs the opposite of merge, with the keys and values from the first hash taking precedence over the second. - # This overloaded definition prevents returning a regular hash, if reverse_merge is called on a HashWithDifferentAccess. - def reverse_merge(other_hash) - super other_hash.with_indifferent_access - end - - # Removes a specified key from the hash. - def delete(key) - super(convert_key(key)) - end - - def stringify_keys!; self end - def symbolize_keys!; self end - def to_options!; self end - - # Convert to a Hash with String keys. - def to_hash - Hash.new(default).merge(self) - end - - protected - def convert_key(key) - key.kind_of?(Symbol) ? key.to_s : key - end - - def convert_value(value) - case value - when Hash - value.with_indifferent_access - when Array - value.collect { |e| e.is_a?(Hash) ? e.with_indifferent_access : e } - else - value - end - end -end - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Hash #:nodoc: - module IndifferentAccess #:nodoc: - def with_indifferent_access - hash = HashWithIndifferentAccess.new(self) - hash.default = self.default - hash - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/keys.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/keys.rb deleted file mode 100644 index af9d372..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/keys.rb +++ /dev/null @@ -1,52 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Hash #:nodoc: - module Keys - # Return a new hash with all keys converted to strings. - def stringify_keys - inject({}) do |options, (key, value)| - options[key.to_s] = value - options - end - end - - # Destructively convert all keys to strings. - def stringify_keys! - keys.each do |key| - self[key.to_s] = delete(key) - end - self - end - - # Return a new hash with all keys converted to symbols. - def symbolize_keys - inject({}) do |options, (key, value)| - options[(key.to_sym rescue key) || key] = value - options - end - end - - # Destructively convert all keys to symbols. - def symbolize_keys! - self.replace(self.symbolize_keys) - end - - alias_method :to_options, :symbolize_keys - alias_method :to_options!, :symbolize_keys! - - # Validate all keys in a hash match *valid keys, raising ArgumentError on a mismatch. - # Note that keys are NOT treated indifferently, meaning if you use strings for keys but assert symbols - # as keys, this will fail. - # - # ==== Examples - # { :name => "Rob", :years => "28" }.assert_valid_keys(:name, :age) # => raises "ArgumentError: Unknown key(s): years" - # { :name => "Rob", :age => "28" }.assert_valid_keys("name", "age") # => raises "ArgumentError: Unknown key(s): name, age" - # { :name => "Rob", :age => "28" }.assert_valid_keys(:name, :age) # => passes, raises nothing - def assert_valid_keys(*valid_keys) - unknown_keys = keys - [valid_keys].flatten - raise(ArgumentError, "Unknown key(s): #{unknown_keys.join(", ")}") unless unknown_keys.empty? - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb deleted file mode 100644 index 546e261..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb +++ /dev/null @@ -1,35 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Hash #:nodoc: - # Allows for reverse merging two hashes where the keys in the calling hash take precedence over those - # in the <tt>other_hash</tt>. This is particularly useful for initializing an option hash with default values: - # - # def setup(options = {}) - # options.reverse_merge! :size => 25, :velocity => 10 - # end - # - # Using <tt>merge</tt>, the above example would look as follows: - # - # def setup(options = {}) - # { :size => 25, :velocity => 10 }.merge(options) - # end - # - # The default <tt>:size</tt> and <tt>:velocity</tt> are only set if the +options+ hash passed in doesn't already - # have the respective key. - module ReverseMerge - # Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second. - def reverse_merge(other_hash) - other_hash.merge(self) - end - - # Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second. - # Modifies the receiver in place. - def reverse_merge!(other_hash) - replace(reverse_merge(other_hash)) - end - - alias_method :reverse_update, :reverse_merge! - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/hash/slice.rb b/vendor/rails/activesupport/lib/active_support/core_ext/hash/slice.rb deleted file mode 100644 index d845a6d..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/hash/slice.rb +++ /dev/null @@ -1,40 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Hash #:nodoc: - # Slice a hash to include only the given keys. This is useful for - # limiting an options hash to valid keys before passing to a method: - # - # def search(criteria = {}) - # assert_valid_keys(:mass, :velocity, :time) - # end - # - # search(options.slice(:mass, :velocity, :time)) - # - # If you have an array of keys you want to limit to, you should splat them: - # - # valid_keys = [:mass, :velocity, :time] - # search(options.slice(*valid_keys)) - module Slice - # Returns a new hash with only the given keys. - def slice(*keys) - keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key) - hash = self.class.new - keys.each { |k| hash[k] = self[k] if has_key?(k) } - hash - end - - # Replaces the hash with only the given keys. - # Returns a hash contained the removed key/value pairs - # {:a => 1, :b => 2, :c => 3, :d => 4}.slice!(:a, :b) # => {:c => 3, :d =>4} - def slice!(*keys) - keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key) - omit = slice(*self.keys - keys) - hash = slice(*keys) - replace(hash) - omit - end - end - end - end -end - diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/integer.rb b/vendor/rails/activesupport/lib/active_support/core_ext/integer.rb deleted file mode 100644 index 18a7a40..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/integer.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'active_support/core_ext/integer/even_odd' -require 'active_support/core_ext/integer/inflections' -require 'active_support/core_ext/integer/time' - -class Integer #:nodoc: - include ActiveSupport::CoreExtensions::Integer::EvenOdd - include ActiveSupport::CoreExtensions::Integer::Inflections - include ActiveSupport::CoreExtensions::Integer::Time -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb b/vendor/rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb deleted file mode 100644 index b1d1e28..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb +++ /dev/null @@ -1,29 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Integer #:nodoc: - # For checking if a fixnum is even or odd. - # - # 2.even? # => true - # 2.odd? # => false - # 1.even? # => false - # 1.odd? # => true - # 0.even? # => true - # 0.odd? # => false - # -1.even? # => false - # -1.odd? # => true - module EvenOdd - def multiple_of?(number) - self % number == 0 - end - - def even? - multiple_of? 2 - end if RUBY_VERSION < '1.9' - - def odd? - !even? - end if RUBY_VERSION < '1.9' - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/integer/inflections.rb b/vendor/rails/activesupport/lib/active_support/core_ext/integer/inflections.rb deleted file mode 100644 index 804702b..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/integer/inflections.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'active_support/inflector' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Integer #:nodoc: - module Inflections - # Ordinalize turns a number into an ordinal string used to denote the - # position in an ordered sequence such as 1st, 2nd, 3rd, 4th. - # - # 1.ordinalize # => "1st" - # 2.ordinalize # => "2nd" - # 1002.ordinalize # => "1002nd" - # 1003.ordinalize # => "1003rd" - def ordinalize - Inflector.ordinalize(self) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/integer/time.rb b/vendor/rails/activesupport/lib/active_support/core_ext/integer/time.rb deleted file mode 100644 index 356e145..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/integer/time.rb +++ /dev/null @@ -1,45 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Integer #:nodoc: - # Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years. - # - # These methods use Time#advance for precise date calculations when using from_now, ago, etc. - # as well as adding or subtracting their results from a Time object. For example: - # - # # equivalent to Time.now.advance(:months => 1) - # 1.month.from_now - # - # # equivalent to Time.now.advance(:years => 2) - # 2.years.from_now - # - # # equivalent to Time.now.advance(:months => 4, :years => 5) - # (4.months + 5.years).from_now - # - # While these methods provide precise calculation when used as in the examples above, care - # should be taken to note that this is not true if the result of `months', `years', etc is - # converted before use: - # - # # equivalent to 30.days.to_i.from_now - # 1.month.to_i.from_now - # - # # equivalent to 365.25.days.to_f.from_now - # 1.year.to_f.from_now - # - # In such cases, Ruby's core - # Date[http://stdlib.rubyonrails.org/libdoc/date/rdoc/index.html] and - # Time[http://stdlib.rubyonrails.org/libdoc/time/rdoc/index.html] should be used for precision - # date and time arithmetic - module Time - def months - ActiveSupport::Duration.new(self * 30.days, [[:months, self]]) - end - alias :month :months - - def years - ActiveSupport::Duration.new(self * 365.25.days, [[:years, self]]) - end - alias :year :years - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/kernel.rb b/vendor/rails/activesupport/lib/active_support/core_ext/kernel.rb deleted file mode 100644 index 1922d80..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/kernel.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'active_support/core_ext/kernel/daemonizing' -require 'active_support/core_ext/kernel/reporting' -require 'active_support/core_ext/kernel/agnostics' -require 'active_support/core_ext/kernel/requires' -require 'active_support/core_ext/kernel/debugger' diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/agnostics.rb b/vendor/rails/activesupport/lib/active_support/core_ext/kernel/agnostics.rb deleted file mode 100644 index c0cb4fb..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/agnostics.rb +++ /dev/null @@ -1,11 +0,0 @@ -class Object - # Makes backticks behave (somewhat more) similarly on all platforms. - # On win32 `nonexistent_command` raises Errno::ENOENT; on Unix, the - # spawned shell prints a message to stderr and sets $?. We emulate - # Unix on the former but not the latter. - def `(command) #:nodoc: - super - rescue Errno::ENOENT => e - STDERR.puts "#$0: #{e}" - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb b/vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb deleted file mode 100644 index ed9d1f9..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Kernel - # Turns the current script into a daemon process that detaches from the console. - # It can be shut down with a TERM signal. - def daemonize - Process.daemon - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb b/vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb deleted file mode 100644 index 4007a64..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Kernel - unless respond_to?(:debugger) - # Starts a debugging session if ruby-debug has been loaded (call script/server --debugger to do load it). - def debugger - Rails.logger.info "\n***** Debugger requested, but was not available: Start server with --debugger to enable *****\n" - end - end - - def breakpoint - Rails.logger.info "\n***** The 'breakpoint' command has been renamed 'debugger' -- please change *****\n" - debugger - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb b/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb deleted file mode 100644 index 0f101e8..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb +++ /dev/null @@ -1,59 +0,0 @@ -module Kernel - # Sets $VERBOSE to nil for the duration of the block and back to its original value afterwards. - # - # silence_warnings do - # value = noisy_call # no warning voiced - # end - # - # noisy_call # warning voiced - def silence_warnings - old_verbose, $VERBOSE = $VERBOSE, nil - yield - ensure - $VERBOSE = old_verbose - end - - # Sets $VERBOSE to true for the duration of the block and back to its original value afterwards. - def enable_warnings - old_verbose, $VERBOSE = $VERBOSE, true - yield - ensure - $VERBOSE = old_verbose - end - - # For compatibility - def silence_stderr #:nodoc: - silence_stream(STDERR) { yield } - end - - # Silences any stream for the duration of the block. - # - # silence_stream(STDOUT) do - # puts 'This will never be seen' - # end - # - # puts 'But this will' - def silence_stream(stream) - old_stream = stream.dup - stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null') - stream.sync = true - yield - ensure - stream.reopen(old_stream) - end - - # Blocks and ignores any exception passed as argument if raised within the block. - # - # suppress(ZeroDivisionError) do - # 1/0 - # puts "This code is NOT reached" - # end - # - # puts "This code gets executed and nothing related to ZeroDivisionError was seen" - def suppress(*exception_classes) - begin yield - rescue Exception => e - raise unless exception_classes.any? { |cls| e.kind_of?(cls) } - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/requires.rb b/vendor/rails/activesupport/lib/active_support/core_ext/kernel/requires.rb deleted file mode 100644 index 323fea4..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/kernel/requires.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Kernel - # Require a library with fallback to RubyGems. Warnings during library - # loading are silenced to increase signal/noise for application warnings. - def require_library_or_gem(library_name) - silence_warnings do - begin - require library_name - rescue LoadError => cannot_require - # 1. Requiring the module is unsuccessful, maybe it's a gem and nobody required rubygems yet. Try. - begin - require 'rubygems' - rescue LoadError => rubygems_not_installed - raise cannot_require - end - # 2. Rubygems is installed and loaded. Try to load the library again - begin - require library_name - rescue LoadError => gem_not_installed - raise cannot_require - end - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/load_error.rb b/vendor/rails/activesupport/lib/active_support/core_ext/load_error.rb deleted file mode 100644 index 6165e95..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/load_error.rb +++ /dev/null @@ -1,38 +0,0 @@ -class MissingSourceFile < LoadError #:nodoc: - attr_reader :path - def initialize(message, path) - super(message) - @path = path - end - - def is_missing?(path) - path.gsub(/\.rb$/, '') == self.path.gsub(/\.rb$/, '') - end - - def self.from_message(message) - REGEXPS.each do |regexp, capture| - match = regexp.match(message) - return MissingSourceFile.new(message, match[capture]) unless match.nil? - end - nil - end - - REGEXPS = [ - [/^no such file to load -- (.+)$/i, 1], - [/^Missing \w+ (file\s*)?([^\s]+.rb)$/i, 2], - [/^Missing API definition file in (.+)$/i, 1] - ] unless defined?(REGEXPS) -end - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module LoadErrorExtensions #:nodoc: - module LoadErrorClassMethods #:nodoc: - def new(*args) - (self == LoadError && MissingSourceFile.from_message(args.first)) || super - end - end - ::LoadError.extend(LoadErrorClassMethods) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/logger.rb b/vendor/rails/activesupport/lib/active_support/core_ext/logger.rb deleted file mode 100644 index 858da7a..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/logger.rb +++ /dev/null @@ -1,145 +0,0 @@ -# Adds the 'around_level' method to Logger. - -class Logger - def self.define_around_helper(level) - module_eval <<-end_eval - def around_#{level}(before_message, after_message, &block) # def around_debug(before_message, after_message, &block) - self.#{level}(before_message) # self.debug(before_message) - return_value = block.call(self) # return_value = block.call(self) - self.#{level}(after_message) # self.debug(after_message) - return return_value # return return_value - end # end - end_eval - end - [:debug, :info, :error, :fatal].each {|level| define_around_helper(level) } -end - - -require 'logger' - -# Extensions to the built in Ruby logger. -# -# If you want to use the default log formatter as defined in the Ruby core, then you -# will need to set the formatter for the logger as in: -# -# logger.formatter = Formatter.new -# -# You can then specify the datetime format, for example: -# -# logger.datetime_format = "%Y-%m-%d" -# -# Note: This logger is deprecated in favor of ActiveSupport::BufferedLogger -class Logger - ## - # :singleton-method: - # Set to false to disable the silencer - cattr_accessor :silencer - self.silencer = true - - # Silences the logger for the duration of the block. - def silence(temporary_level = Logger::ERROR) - if silencer - begin - old_logger_level, self.level = level, temporary_level - yield self - ensure - self.level = old_logger_level - end - else - yield self - end - end - - alias :old_datetime_format= :datetime_format= - # Logging date-time format (string passed to +strftime+). Ignored if the formatter - # does not respond to datetime_format=. - def datetime_format=(datetime_format) - formatter.datetime_format = datetime_format if formatter.respond_to?(:datetime_format=) - end - - alias :old_datetime_format :datetime_format - # Get the logging datetime format. Returns nil if the formatter does not support - # datetime formatting. - def datetime_format - formatter.datetime_format if formatter.respond_to?(:datetime_format) - end - - alias :old_formatter :formatter if method_defined?(:formatter) - # Get the current formatter. The default formatter is a SimpleFormatter which only - # displays the log message - def formatter - @formatter ||= SimpleFormatter.new - end - - unless const_defined? :Formatter - class Formatter - Format = "%s, [%s#%d] %5s -- %s: %s\n" - - attr_accessor :datetime_format - - def initialize - @datetime_format = nil - end - - def call(severity, time, progname, msg) - Format % [severity[0..0], format_datetime(time), $$, severity, progname, - msg2str(msg)] - end - - private - def format_datetime(time) - if @datetime_format.nil? - time.strftime("%Y-%m-%dT%H:%M:%S.") << "%06d " % time.usec - else - time.strftime(@datetime_format) - end - end - - def msg2str(msg) - case msg - when ::String - msg - when ::Exception - "#{ msg.message } (#{ msg.class })\n" << - (msg.backtrace || []).join("\n") - else - msg.inspect - end - end - end - end - - # Simple formatter which only displays the message. - class SimpleFormatter < Logger::Formatter - # This method is invoked when a log event occurs - def call(severity, timestamp, progname, msg) - "#{String === msg ? msg : msg.inspect}\n" - end - end - - private - alias old_format_message format_message - - # Ruby 1.8.3 transposed the msg and progname arguments to format_message. - # We can't test RUBY_VERSION because some distributions don't keep Ruby - # and its standard library in sync, leading to installations of Ruby 1.8.2 - # with Logger from 1.8.3 and vice versa. - if method_defined?(:formatter=) - def format_message(severity, timestamp, progname, msg) - formatter.call(severity, timestamp, progname, msg) - end - else - def format_message(severity, timestamp, msg, progname) - formatter.call(severity, timestamp, progname, msg) - end - - attr_writer :formatter - public :formatter= - - alias old_format_datetime format_datetime - def format_datetime(datetime) datetime end - - alias old_msg2str msg2str - def msg2str(msg) msg end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module.rb deleted file mode 100644 index da8d28e..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'active_support/core_ext/module/inclusion' -require 'active_support/core_ext/module/attribute_accessors' -require 'active_support/core_ext/module/attr_internal' -require 'active_support/core_ext/module/attr_accessor_with_default' -require 'active_support/core_ext/module/delegation' -require 'active_support/core_ext/module/introspection' -require 'active_support/core_ext/module/loading' -require 'active_support/core_ext/module/aliasing' -require 'active_support/core_ext/module/model_naming' -require 'active_support/core_ext/module/synchronization' - -module ActiveSupport - module CoreExtensions - # Various extensions for the Ruby core Module class. - module Module - # Nothing here. Only defined for API documentation purposes. - end - end -end - -class Module - include ActiveSupport::CoreExtensions::Module -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/aliasing.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/aliasing.rb deleted file mode 100644 index 10fa520..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/aliasing.rb +++ /dev/null @@ -1,74 +0,0 @@ -module ActiveSupport - module CoreExtensions - module Module - # Encapsulates the common pattern of: - # - # alias_method :foo_without_feature, :foo - # alias_method :foo, :foo_with_feature - # - # With this, you simply do: - # - # alias_method_chain :foo, :feature - # - # And both aliases are set up for you. - # - # Query and bang methods (foo?, foo!) keep the same punctuation: - # - # alias_method_chain :foo?, :feature - # - # is equivalent to - # - # alias_method :foo_without_feature?, :foo? - # alias_method :foo?, :foo_with_feature? - # - # so you can safely chain foo, foo?, and foo! with the same feature. - def alias_method_chain(target, feature) - # Strip out punctuation on predicates or bang methods since - # e.g. target?_without_feature is not a valid method name. - aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1 - yield(aliased_target, punctuation) if block_given? - - with_method, without_method = "#{aliased_target}_with_#{feature}#{punctuation}", "#{aliased_target}_without_#{feature}#{punctuation}" - - alias_method without_method, target - alias_method target, with_method - - case - when public_method_defined?(without_method) - public target - when protected_method_defined?(without_method) - protected target - when private_method_defined?(without_method) - private target - end - end - - # Allows you to make aliases for attributes, which includes - # getter, setter, and query methods. - # - # Example: - # - # class Content < ActiveRecord::Base - # # has a title attribute - # end - # - # class Email < Content - # alias_attribute :subject, :title - # end - # - # e = Email.find(1) - # e.title # => "Superstars" - # e.subject # => "Superstars" - # e.subject? # => true - # e.subject = "Megastars" - # e.title # => "Megastars" - def alias_attribute(new_name, old_name) - module_eval <<-STR, __FILE__, __LINE__+1 - def #{new_name}; self.#{old_name}; end # def subject; self.title; end - def #{new_name}?; self.#{old_name}?; end # def subject?; self.title?; end - def #{new_name}=(v); self.#{old_name} = v; end # def subject=(v); self.title = v; end - STR - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb deleted file mode 100644 index 4d0198f..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb +++ /dev/null @@ -1,31 +0,0 @@ -class Module - # Declare an attribute accessor with an initial default return value. - # - # To give attribute <tt>:age</tt> the initial value <tt>25</tt>: - # - # class Person - # attr_accessor_with_default :age, 25 - # end - # - # some_person.age - # => 25 - # some_person.age = 26 - # some_person.age - # => 26 - # - # To give attribute <tt>:element_name</tt> a dynamic default value, evaluated - # in scope of self: - # - # attr_accessor_with_default(:element_name) { name.underscore } - # - def attr_accessor_with_default(sym, default = nil, &block) - raise 'Default value or block required' unless !default.nil? || block - define_method(sym, block_given? ? block : Proc.new { default }) - module_eval(<<-EVAL, __FILE__, __LINE__) - def #{sym}=(value) # def age=(value) - class << self; attr_reader :#{sym} end # class << self; attr_reader :age end - @#{sym} = value # @age = value - end # end - EVAL - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb deleted file mode 100644 index b66c0d7..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb +++ /dev/null @@ -1,32 +0,0 @@ -class Module - # Declares an attribute reader backed by an internally-named instance variable. - def attr_internal_reader(*attrs) - attrs.each do |attr| - module_eval "def #{attr}() #{attr_internal_ivar_name(attr)} end" - end - end - - # Declares an attribute writer backed by an internally-named instance variable. - def attr_internal_writer(*attrs) - attrs.each do |attr| - module_eval "def #{attr}=(v) #{attr_internal_ivar_name(attr)} = v end" - end - end - - # Declares an attribute reader and writer backed by an internally-named instance - # variable. - def attr_internal_accessor(*attrs) - attr_internal_reader(*attrs) - attr_internal_writer(*attrs) - end - - alias_method :attr_internal, :attr_internal_accessor - - private - mattr_accessor :attr_internal_naming_format - self.attr_internal_naming_format = '@_%s' - - def attr_internal_ivar_name(attr) - attr_internal_naming_format % attr - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb deleted file mode 100644 index 9402cb8..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb +++ /dev/null @@ -1,58 +0,0 @@ -# Extends the module object with module and instance accessors for class attributes, -# just like the native attr* accessors for instance attributes. -# -# module AppConfiguration -# mattr_accessor :google_api_key -# self.google_api_key = "123456789" -# -# mattr_accessor :paypal_url -# self.paypal_url = "www.sandbox.paypal.com" -# end -# -# AppConfiguration.google_api_key = "overriding the api key!" -class Module - def mattr_reader(*syms) - syms.each do |sym| - next if sym.is_a?(Hash) - class_eval(<<-EOS, __FILE__, __LINE__) - unless defined? @@#{sym} # unless defined? @@pagination_options - @@#{sym} = nil # @@pagination_options = nil - end # end - # - def self.#{sym} # def self.pagination_options - @@#{sym} # @@pagination_options - end # end - # - def #{sym} # def pagination_options - @@#{sym} # @@pagination_options - end # end - EOS - end - end - - def mattr_writer(*syms) - options = syms.extract_options! - syms.each do |sym| - class_eval(<<-EOS, __FILE__, __LINE__) - unless defined? @@#{sym} # unless defined? @@pagination_options - @@#{sym} = nil # @@pagination_options = nil - end # end - # - def self.#{sym}=(obj) # def self.pagination_options=(obj) - @@#{sym} = obj # @@pagination_options = obj - end # end - # - #{" # - def #{sym}=(obj) # def pagination_options=(obj) - @@#{sym} = obj # @@pagination_options = obj - end # end - " unless options[:instance_writer] == false } # # instance writer above is generated unless options[:instance_writer] == false - EOS - end - end - - def mattr_accessor(*syms) - mattr_reader(*syms) - mattr_writer(*syms) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/delegation.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/delegation.rb deleted file mode 100644 index fb4b5f0..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/delegation.rb +++ /dev/null @@ -1,121 +0,0 @@ -class Module - # Provides a delegate class method to easily expose contained objects' methods - # as your own. Pass one or more methods (specified as symbols or strings) - # and the name of the target object as the final <tt>:to</tt> option (also a symbol - # or string). At least one method and the <tt>:to</tt> option are required. - # - # Delegation is particularly useful with Active Record associations: - # - # class Greeter < ActiveRecord::Base - # def hello() "hello" end - # def goodbye() "goodbye" end - # end - # - # class Foo < ActiveRecord::Base - # belongs_to :greeter - # delegate :hello, :to => :greeter - # end - # - # Foo.new.hello # => "hello" - # Foo.new.goodbye # => NoMethodError: undefined method `goodbye' for #<Foo:0x1af30c> - # - # Multiple delegates to the same target are allowed: - # - # class Foo < ActiveRecord::Base - # belongs_to :greeter - # delegate :hello, :goodbye, :to => :greeter - # end - # - # Foo.new.goodbye # => "goodbye" - # - # Methods can be delegated to instance variables, class variables, or constants - # by providing them as a symbols: - # - # class Foo - # CONSTANT_ARRAY = [0,1,2,3] - # @@class_array = [4,5,6,7] - # - # def initialize - # @instance_array = [8,9,10,11] - # end - # delegate :sum, :to => :CONSTANT_ARRAY - # delegate :min, :to => :@@class_array - # delegate :max, :to => :@instance_array - # end - # - # Foo.new.sum # => 6 - # Foo.new.min # => 4 - # Foo.new.max # => 11 - # - # Delegates can optionally be prefixed using the <tt>:prefix</tt> option. If the value - # is <tt>true</tt>, the delegate methods are prefixed with the name of the object being - # delegated to. - # - # Person = Struct.new(:name, :address) - # - # class Invoice < Struct.new(:client) - # delegate :name, :address, :to => :client, :prefix => true - # end - # - # john_doe = Person.new("John Doe", "Vimmersvej 13") - # invoice = Invoice.new(john_doe) - # invoice.client_name # => "John Doe" - # invoice.client_address # => "Vimmersvej 13" - # - # It is also possible to supply a custom prefix. - # - # class Invoice < Struct.new(:client) - # delegate :name, :address, :to => :client, :prefix => :customer - # end - # - # invoice = Invoice.new(john_doe) - # invoice.customer_name # => "John Doe" - # invoice.customer_address # => "Vimmersvej 13" - # - # If the object to which you delegate can be nil, you may want to use the - # :allow_nil option. In that case, it returns nil instead of raising a - # NoMethodError exception: - # - # class Foo - # attr_accessor :bar - # def initialize(bar = nil) - # @bar = bar - # end - # delegate :zoo, :to => :bar - # end - # - # Foo.new.zoo # raises NoMethodError exception (you called nil.zoo) - # - # class Foo - # attr_accessor :bar - # def initialize(bar = nil) - # @bar = bar - # end - # delegate :zoo, :to => :bar, :allow_nil => true - # end - # - # Foo.new.zoo # returns nil - # - def delegate(*methods) - options = methods.pop - unless options.is_a?(Hash) && to = options[:to] - raise ArgumentError, "Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, :to => :greeter)." - end - - if options[:prefix] == true && options[:to].to_s =~ /^[^a-z_]/ - raise ArgumentError, "Can only automatically set the delegation prefix when delegating to a method." - end - - prefix = options[:prefix] && "#{options[:prefix] == true ? to : options[:prefix]}_" - - allow_nil = options[:allow_nil] && "#{to} && " - - methods.each do |method| - module_eval(<<-EOS, "(__DELEGATION__)", 1) - def #{prefix}#{method}(*args, &block) # def customer_name(*args, &block) - #{allow_nil}#{to}.__send__(#{method.inspect}, *args, &block) # client && client.__send__(:name, *args, &block) - end # end - EOS - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/inclusion.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/inclusion.rb deleted file mode 100644 index 4f23841..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/inclusion.rb +++ /dev/null @@ -1,30 +0,0 @@ -class Module - # Returns the classes in the current ObjectSpace where this module has been - # mixed in according to Module#included_modules. - # - # module M - # end - # - # module N - # include M - # end - # - # class C - # include M - # end - # - # class D < C - # end - # - # p M.included_in_classes # => [C, D] - # - def included_in_classes - classes = [] - ObjectSpace.each_object(Class) { |k| classes << k if k.included_modules.include?(self) } - - classes.reverse.inject([]) do |unique_classes, klass| - unique_classes << klass unless unique_classes.collect { |k| k.to_s }.include?(klass.to_s) - unique_classes - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/introspection.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/introspection.rb deleted file mode 100644 index 8beaff4..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/introspection.rb +++ /dev/null @@ -1,90 +0,0 @@ -module ActiveSupport - module CoreExtensions - module Module - # Returns the name of the module containing this one. - # - # p M::N.parent_name # => "M" - def parent_name - unless defined? @parent_name - @parent_name = name =~ /::[^:]+\Z/ ? $`.freeze : nil - end - @parent_name - end - - # Returns the module which contains this one according to its name. - # - # module M - # module N - # end - # end - # X = M::N - # - # p M::N.parent # => M - # p X.parent # => M - # - # The parent of top-level and anonymous modules is Object. - # - # p M.parent # => Object - # p Module.new.parent # => Object - # - def parent - parent_name ? parent_name.constantize : Object - end - - # Returns all the parents of this module according to its name, ordered from - # nested outwards. The receiver is not contained within the result. - # - # module M - # module N - # end - # end - # X = M::N - # - # p M.parents # => [Object] - # p M::N.parents # => [M, Object] - # p X.parents # => [M, Object] - # - def parents - parents = [] - if parent_name - parts = parent_name.split('::') - until parts.empty? - parents << (parts * '::').constantize - parts.pop - end - end - parents << Object unless parents.include? Object - parents - end - - if RUBY_VERSION < '1.9' - # Returns the constants that have been defined locally by this object and - # not in an ancestor. This method is exact if running under Ruby 1.9. In - # previous versions it may miss some constants if their definition in some - # ancestor is identical to their definition in the receiver. - def local_constants - inherited = {} - - ancestors.each do |anc| - next if anc == self - anc.constants.each { |const| inherited[const] = anc.const_get(const) } - end - - constants.select do |const| - !inherited.key?(const) || inherited[const].object_id != const_get(const).object_id - end - end - else - def local_constants #:nodoc: - constants(false) - end - end - - # Returns the names of the constants defined locally rather than the - # constants themselves. See <tt>local_constants</tt>. - def local_constant_names - local_constants.map { |c| c.to_s } - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/loading.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/loading.rb deleted file mode 100644 index 4b4b110..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/loading.rb +++ /dev/null @@ -1,23 +0,0 @@ -class Module - # Returns String#underscore applied to the module name minus trailing classes. - # - # ActiveRecord.as_load_path # => "active_record" - # ActiveRecord::Associations.as_load_path # => "active_record/associations" - # ActiveRecord::Base.as_load_path # => "active_record" (Base is a class) - # - # The Kernel module gives an empty string by definition. - # - # Kernel.as_load_path # => "" - # Math.as_load_path # => "math" - def as_load_path - if self == Object || self == Kernel - '' - elsif is_a? Class - parent == self ? '' : parent.as_load_path - else - name.split('::').collect do |word| - word.underscore - end * '/' - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/model_naming.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/model_naming.rb deleted file mode 100644 index 3ec4f3b..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/model_naming.rb +++ /dev/null @@ -1,23 +0,0 @@ -module ActiveSupport - class ModelName < String - attr_reader :singular, :plural, :cache_key, :partial_path - - def initialize(name) - super - @singular = underscore.tr('/', '_').freeze - @plural = @singular.pluralize.freeze - @cache_key = tableize.freeze - @partial_path = "#{@cache_key}/#{demodulize.underscore}".freeze - end - end - - module CoreExtensions - module Module - # Returns an ActiveSupport::ModelName object for module. It can be - # used to retrieve all kinds of naming-related information. - def model_name - @model_name ||= ModelName.new(name) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/module/synchronization.rb b/vendor/rails/activesupport/lib/active_support/core_ext/module/synchronization.rb deleted file mode 100644 index 069db3f..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/module/synchronization.rb +++ /dev/null @@ -1,39 +0,0 @@ -class Module - # Synchronize access around a method, delegating synchronization to a - # particular mutex. A mutex (either a Mutex, or any object that responds to - # #synchronize and yields to a block) must be provided as a final :with option. - # The :with option should be a symbol or string, and can represent a method, - # constant, or instance or class variable. - # Example: - # class SharedCache - # @@lock = Mutex.new - # def expire - # ... - # end - # synchronize :expire, :with => :@@lock - # end - def synchronize(*methods) - options = methods.extract_options! - unless options.is_a?(Hash) && with = options[:with] - raise ArgumentError, "Synchronization needs a mutex. Supply an options hash with a :with key as the last argument (e.g. synchronize :hello, :with => :@mutex)." - end - - methods.each do |method| - aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1 - - if method_defined?("#{aliased_method}_without_synchronization#{punctuation}") - raise ArgumentError, "#{method} is already synchronized. Double synchronization is not currently supported." - end - - module_eval(<<-EOS, __FILE__, __LINE__) - def #{aliased_method}_with_synchronization#{punctuation}(*args, &block) # def expire_with_synchronization(*args, &block) - #{with}.synchronize do # @@lock.synchronize do - #{aliased_method}_without_synchronization#{punctuation}(*args, &block) # expire_without_synchronization(*args, &block) - end # end - end # end - EOS - - alias_method_chain method, :synchronization - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb b/vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb deleted file mode 100644 index 49176c1..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb +++ /dev/null @@ -1,17 +0,0 @@ -# Add a +missing_name+ method to NameError instances. -class NameError #:nodoc: - # Add a method to obtain the missing name from a NameError. - def missing_name - $1 if /((::)?([A-Z]\w*)(::[A-Z]\w*)*)$/ =~ message - end - - # Was this exception raised because the given name was missing? - def missing_name?(name) - if name.is_a? Symbol - last_name = (missing_name || '').split('::').last - last_name == name.to_s - else - missing_name == name.to_s - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/numeric.rb b/vendor/rails/activesupport/lib/active_support/core_ext/numeric.rb deleted file mode 100644 index 759b86b..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/numeric.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'active_support/core_ext/numeric/time' -require 'active_support/core_ext/numeric/bytes' -require 'active_support/core_ext/numeric/conversions' - -class Numeric #:nodoc: - include ActiveSupport::CoreExtensions::Numeric::Time - include ActiveSupport::CoreExtensions::Numeric::Bytes - include ActiveSupport::CoreExtensions::Numeric::Conversions -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/numeric/bytes.rb b/vendor/rails/activesupport/lib/active_support/core_ext/numeric/bytes.rb deleted file mode 100644 index 5647767..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/numeric/bytes.rb +++ /dev/null @@ -1,44 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Numeric #:nodoc: - # Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes - module Bytes - def bytes - self - end - alias :byte :bytes - - def kilobytes - self * 1024 - end - alias :kilobyte :kilobytes - - def megabytes - self * 1024.kilobytes - end - alias :megabyte :megabytes - - def gigabytes - self * 1024.megabytes - end - alias :gigabyte :gigabytes - - def terabytes - self * 1024.gigabytes - end - alias :terabyte :terabytes - - def petabytes - self * 1024.terabytes - end - alias :petabyte :petabytes - - def exabytes - self * 1024.petabytes - end - alias :exabyte :exabytes - - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/numeric/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/numeric/conversions.rb deleted file mode 100644 index e652ae5..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/numeric/conversions.rb +++ /dev/null @@ -1,19 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Numeric #:nodoc: - module Conversions - # Assumes self represents an offset from UTC in seconds (as returned from Time#utc_offset) - # and turns this into an +HH:MM formatted string. Example: - # - # -21_600.to_utc_offset_s # => "-06:00" - def to_utc_offset_s(colon=true) - seconds = self - sign = (seconds < 0 ? -1 : 1) - hours = seconds.abs / 3600 - minutes = (seconds.abs % 3600) / 60 - "%+03d%s%02d" % [ hours * sign, colon ? ":" : "", minutes ] - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb b/vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb deleted file mode 100644 index bc7f180..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb +++ /dev/null @@ -1,81 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Numeric #:nodoc: - # Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years. - # - # These methods use Time#advance for precise date calculations when using from_now, ago, etc. - # as well as adding or subtracting their results from a Time object. For example: - # - # # equivalent to Time.now.advance(:months => 1) - # 1.month.from_now - # - # # equivalent to Time.now.advance(:years => 2) - # 2.years.from_now - # - # # equivalent to Time.now.advance(:months => 4, :years => 5) - # (4.months + 5.years).from_now - # - # While these methods provide precise calculation when used as in the examples above, care - # should be taken to note that this is not true if the result of `months', `years', etc is - # converted before use: - # - # # equivalent to 30.days.to_i.from_now - # 1.month.to_i.from_now - # - # # equivalent to 365.25.days.to_f.from_now - # 1.year.to_f.from_now - # - # In such cases, Ruby's core - # Date[http://stdlib.rubyonrails.org/libdoc/date/rdoc/index.html] and - # Time[http://stdlib.rubyonrails.org/libdoc/time/rdoc/index.html] should be used for precision - # date and time arithmetic - module Time - def seconds - ActiveSupport::Duration.new(self, [[:seconds, self]]) - end - alias :second :seconds - - def minutes - ActiveSupport::Duration.new(self * 60, [[:seconds, self * 60]]) - end - alias :minute :minutes - - def hours - ActiveSupport::Duration.new(self * 3600, [[:seconds, self * 3600]]) - end - alias :hour :hours - - def days - ActiveSupport::Duration.new(self * 24.hours, [[:days, self]]) - end - alias :day :days - - def weeks - ActiveSupport::Duration.new(self * 7.days, [[:days, self * 7]]) - end - alias :week :weeks - - def fortnights - ActiveSupport::Duration.new(self * 2.weeks, [[:days, self * 14]]) - end - alias :fortnight :fortnights - - # Reads best without arguments: 10.minutes.ago - def ago(time = ::Time.now) - time - self - end - - # Reads best with argument: 10.minutes.until(time) - alias :until :ago - - # Reads best with argument: 10.minutes.since(time) - def since(time = ::Time.now) - time + self - end - - # Reads best without arguments: 10.minutes.from_now - alias :from_now :since - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/object.rb b/vendor/rails/activesupport/lib/active_support/core_ext/object.rb deleted file mode 100644 index 0796a7b..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/object.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'active_support/core_ext/object/conversions' -require 'active_support/core_ext/object/extending' -require 'active_support/core_ext/object/instance_variables' -require 'active_support/core_ext/object/metaclass' -require 'active_support/core_ext/object/misc' diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/object/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/object/conversions.rb deleted file mode 100644 index 278b856..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/object/conversions.rb +++ /dev/null @@ -1,15 +0,0 @@ -class Object - # Alias of <tt>to_s</tt>. - def to_param - to_s - end - - # Converts an object into a string suitable for use as a URL query string, using the given <tt>key</tt> as the - # param name. - # - # Note: This method is defined as a default implementation for all Objects for Hash#to_query to work. - def to_query(key) - require 'cgi' unless defined?(CGI) && defined?(CGI::escape) - "#{CGI.escape(key.to_s)}=#{CGI.escape(to_param.to_s)}" - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/object/extending.rb b/vendor/rails/activesupport/lib/active_support/core_ext/object/extending.rb deleted file mode 100644 index bbf6f85..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/object/extending.rb +++ /dev/null @@ -1,80 +0,0 @@ -class Object - def remove_subclasses_of(*superclasses) #:nodoc: - Class.remove_class(*subclasses_of(*superclasses)) - end - - begin - ObjectSpace.each_object(Class.new) {} - - # Exclude this class unless it's a subclass of our supers and is defined. - # We check defined? in case we find a removed class that has yet to be - # garbage collected. This also fails for anonymous classes -- please - # submit a patch if you have a workaround. - def subclasses_of(*superclasses) #:nodoc: - subclasses = [] - - superclasses.each do |sup| - ObjectSpace.each_object(class << sup; self; end) do |k| - if k != sup && (k.name.blank? || eval("defined?(::#{k}) && ::#{k}.object_id == k.object_id")) - subclasses << k - end - end - end - - subclasses - end - rescue RuntimeError - # JRuby and any implementations which cannot handle the objectspace traversal - # above fall back to this implementation - def subclasses_of(*superclasses) #:nodoc: - subclasses = [] - - superclasses.each do |sup| - ObjectSpace.each_object(Class) do |k| - if superclasses.any? { |superclass| k < superclass } && - (k.name.blank? || eval("defined?(::#{k}) && ::#{k}.object_id == k.object_id")) - subclasses << k - end - end - subclasses.uniq! - end - subclasses - end - end - - def extended_by #:nodoc: - ancestors = class << self; ancestors end - ancestors.select { |mod| mod.class == Module } - [ Object, Kernel ] - end - - def extend_with_included_modules_from(object) #:nodoc: - object.extended_by.each { |mod| extend mod } - end - - unless defined? instance_exec # 1.9 - module InstanceExecMethods #:nodoc: - end - include InstanceExecMethods - - # Evaluate the block with the given arguments within the context of - # this object, so self is set to the method receiver. - # - # From Mauricio's http://eigenclass.org/hiki/bounded+space+instance_exec - def instance_exec(*args, &block) - begin - old_critical, Thread.critical = Thread.critical, true - n = 0 - n += 1 while respond_to?(method_name = "__instance_exec#{n}") - InstanceExecMethods.module_eval { define_method(method_name, &block) } - ensure - Thread.critical = old_critical - end - - begin - send(method_name, *args) - ensure - InstanceExecMethods.module_eval { remove_method(method_name) } rescue nil - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb b/vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb deleted file mode 100644 index 4ecaab3..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb +++ /dev/null @@ -1,74 +0,0 @@ -class Object - # Available in 1.8.6 and later. - unless respond_to?(:instance_variable_defined?) - def instance_variable_defined?(variable) - instance_variables.include?(variable.to_s) - end - end - - # Returns a hash that maps instance variable names without "@" to their - # corresponding values. Keys are strings both in Ruby 1.8 and 1.9. - # - # class C - # def initialize(x, y) - # @x, @y = x, y - # end - # end - # - # C.new(0, 1).instance_values # => {"x" => 0, "y" => 1} - def instance_values #:nodoc: - instance_variables.inject({}) do |values, name| - values[name.to_s[1..-1]] = instance_variable_get(name) - values - end - end - - # Returns an array of instance variable names including "@". They are strings - # both in Ruby 1.8 and 1.9. - # - # class C - # def initialize(x, y) - # @x, @y = x, y - # end - # end - # - # C.new(0, 1).instance_variable_names # => ["@y", "@x"] - if RUBY_VERSION >= '1.9' - def instance_variable_names - instance_variables.map { |var| var.to_s } - end - else - alias_method :instance_variable_names, :instance_variables - end - - # Copies the instance variables of +object+ into +self+. - # - # Instance variable names in the +exclude+ array are ignored. If +object+ - # responds to <tt>protected_instance_variables</tt> the ones returned are - # also ignored. For example, Rails controllers implement that method. - # - # In both cases strings and symbols are understood, and they have to include - # the at sign. - # - # class C - # def initialize(x, y, z) - # @x, @y, @z = x, y, z - # end - # - # def protected_instance_variables - # %w(@z) - # end - # end - # - # a = C.new(0, 1, 2) - # b = C.new(3, 4, 5) - # - # a.copy_instance_variables_from(b, [:@y]) - # # a is now: @x = 3, @y = 1, @z = 2 - def copy_instance_variables_from(object, exclude = []) #:nodoc: - exclude += object.protected_instance_variables if object.respond_to? :protected_instance_variables - - vars = object.instance_variables.map(&:to_s) - exclude.map(&:to_s) - vars.each { |name| instance_variable_set(name, object.instance_variable_get(name)) } - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/object/metaclass.rb b/vendor/rails/activesupport/lib/active_support/core_ext/object/metaclass.rb deleted file mode 100644 index 93fb0ad..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/object/metaclass.rb +++ /dev/null @@ -1,13 +0,0 @@ -class Object - # Get object's meta (ghost, eigenclass, singleton) class - def metaclass - class << self - self - end - end - - # If class_eval is called on an object, add those methods to its metaclass - def class_eval(*args, &block) - metaclass.class_eval(*args, &block) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb b/vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb deleted file mode 100644 index 4acdfa3..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb +++ /dev/null @@ -1,90 +0,0 @@ -class Object - # Returns +value+ after yielding +value+ to the block. This simplifies the - # process of constructing an object, performing work on the object, and then - # returning the object from a method. It is a Ruby-ized realization of the K - # combinator, courtesy of Mikael Brockman. - # - # ==== Examples - # - # # Without returning - # def foo - # values = [] - # values << "bar" - # values << "baz" - # return values - # end - # - # foo # => ['bar', 'baz'] - # - # # returning with a local variable - # def foo - # returning values = [] do - # values << 'bar' - # values << 'baz' - # end - # end - # - # foo # => ['bar', 'baz'] - # - # # returning with a block argument - # def foo - # returning [] do |values| - # values << 'bar' - # values << 'baz' - # end - # end - # - # foo # => ['bar', 'baz'] - def returning(value) - yield(value) - value - end - - # Yields <code>x</code> to the block, and then returns <code>x</code>. - # The primary purpose of this method is to "tap into" a method chain, - # in order to perform operations on intermediate results within the chain. - # - # (1..10).tap { |x| puts "original: #{x.inspect}" }.to_a. - # tap { |x| puts "array: #{x.inspect}" }. - # select { |x| x%2 == 0 }. - # tap { |x| puts "evens: #{x.inspect}" }. - # map { |x| x*x }. - # tap { |x| puts "squares: #{x.inspect}" } - def tap - yield self - self - end unless Object.respond_to?(:tap) - - # An elegant way to factor duplication out of options passed to a series of - # method calls. Each method called in the block, with the block variable as - # the receiver, will have its options merged with the default +options+ hash - # provided. Each method called on the block variable must take an options - # hash as its final argument. - # - # with_options :order => 'created_at', :class_name => 'Comment' do |post| - # post.has_many :comments, :conditions => ['approved = ?', true], :dependent => :delete_all - # post.has_many :unapproved_comments, :conditions => ['approved = ?', false] - # post.has_many :all_comments - # end - # - # Can also be used with an explicit receiver: - # - # map.with_options :controller => "people" do |people| - # people.connect "/people", :action => "index" - # people.connect "/people/:id", :action => "show" - # end - # - def with_options(options) - yield ActiveSupport::OptionMerger.new(self, options) - end - - # A duck-type assistant method. For example, Active Support extends Date - # to define an acts_like_date? method, and extends Time to define - # acts_like_time?. As a result, we can do "x.acts_like?(:time)" and - # "x.acts_like?(:date)" to do duck-type-safe comparisons, since classes that - # we want to act like Time simply need to define an acts_like_time? method. - def acts_like?(duck) - respond_to? "acts_like_#{duck}?" - end - -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/pathname.rb b/vendor/rails/activesupport/lib/active_support/core_ext/pathname.rb deleted file mode 100644 index 4c5318e..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/pathname.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'pathname' -require 'active_support/core_ext/pathname/clean_within' - -class Pathname#:nodoc: - extend ActiveSupport::CoreExtensions::Pathname::CleanWithin -end - diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/pathname/clean_within.rb b/vendor/rails/activesupport/lib/active_support/core_ext/pathname/clean_within.rb deleted file mode 100644 index ae03e1b..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/pathname/clean_within.rb +++ /dev/null @@ -1,14 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Pathname #:nodoc: - module CleanWithin - # Clean the paths contained in the provided string. - def clean_within(string) - string.gsub(%r{[\w. ]+(/[\w. ]+)+(\.rb)?(\b|$)}) do |path| - new(path).cleanpath - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/proc.rb b/vendor/rails/activesupport/lib/active_support/core_ext/proc.rb deleted file mode 100644 index 2ca23f6..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/proc.rb +++ /dev/null @@ -1,12 +0,0 @@ -class Proc #:nodoc: - def bind(object) - block, time = self, Time.now - (class << object; self end).class_eval do - method_name = "__bind_#{time.to_i}_#{time.usec}" - define_method(method_name, &block) - method = instance_method(method_name) - remove_method(method_name) - method - end.bind(object) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/process.rb b/vendor/rails/activesupport/lib/active_support/core_ext/process.rb deleted file mode 100644 index 0b0bc6d..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/process.rb +++ /dev/null @@ -1 +0,0 @@ -require 'active_support/core_ext/process/daemon' diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/process/daemon.rb b/vendor/rails/activesupport/lib/active_support/core_ext/process/daemon.rb deleted file mode 100644 index 95ad5f8..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/process/daemon.rb +++ /dev/null @@ -1,25 +0,0 @@ -if RUBY_VERSION < "1.9" - module Process - def self.daemon(nochdir = nil, noclose = nil) - exit if fork # Parent exits, child continues. - Process.setsid # Become session leader. - exit if fork # Zap session leader. See [1]. - - unless nochdir - Dir.chdir "/" # Release old working directory. - end - - File.umask 0000 # Ensure sensible umask. Adjust as needed. - - unless noclose - STDIN.reopen "/dev/null" # Free file descriptors and - STDOUT.reopen "/dev/null", "a" # point them somewhere sensible. - STDERR.reopen '/dev/null', 'a' - end - - trap("TERM") { exit } - - return 0 - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/range.rb b/vendor/rails/activesupport/lib/active_support/core_ext/range.rb deleted file mode 100644 index 0d2b169..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/range.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'active_support/core_ext/range/conversions' -require 'active_support/core_ext/range/overlaps' -require 'active_support/core_ext/range/include_range' -require 'active_support/core_ext/range/blockless_step' - -class Range #:nodoc: - include ActiveSupport::CoreExtensions::Range::Conversions - include ActiveSupport::CoreExtensions::Range::Overlaps - include ActiveSupport::CoreExtensions::Range::IncludeRange - include ActiveSupport::CoreExtensions::Range::BlocklessStep -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/range/blockless_step.rb b/vendor/rails/activesupport/lib/active_support/core_ext/range/blockless_step.rb deleted file mode 100644 index 6fa1eb5..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/range/blockless_step.rb +++ /dev/null @@ -1,32 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Range #:nodoc: - # Return an array when step is called without a block. - module BlocklessStep - def self.included(base) #:nodoc: - base.alias_method_chain :step, :blockless - end - - if RUBY_VERSION < '1.9' - def step_with_blockless(value = 1, &block) - if block_given? - step_without_blockless(value, &block) - else - returning [] do |array| - step_without_blockless(value) { |step| array << step } - end - end - end - else - def step_with_blockless(value = 1, &block) - if block_given? - step_without_blockless(value, &block) - else - step_without_blockless(value).to_a - end - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/range/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/range/conversions.rb deleted file mode 100644 index 45b0826..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/range/conversions.rb +++ /dev/null @@ -1,27 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Range #:nodoc: - # Getting ranges in different convenient string representations and other objects - module Conversions - RANGE_FORMATS = { - :db => Proc.new { |start, stop| "BETWEEN '#{start.to_s(:db)}' AND '#{stop.to_s(:db)}'" } - } - - def self.included(base) #:nodoc: - base.class_eval do - alias_method :to_default_s, :to_s - alias_method :to_s, :to_formatted_s - end - end - # Gives a human readable format of the range. - # - # ==== Example - # - # [1..100].to_formatted_s # => "1..100" - def to_formatted_s(format = :default) - RANGE_FORMATS[format] ? RANGE_FORMATS[format].call(first, last) : to_default_s - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/range/include_range.rb b/vendor/rails/activesupport/lib/active_support/core_ext/range/include_range.rb deleted file mode 100644 index 9a7d235..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/range/include_range.rb +++ /dev/null @@ -1,30 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Range #:nodoc: - # Check if a Range includes another Range. - module IncludeRange - def self.included(base) #:nodoc: - base.alias_method_chain :include?, :range - end - - # Extends the default Range#include? to support range comparisons. - # (1..5).include?(1..5) # => true - # (1..5).include?(2..3) # => true - # (1..5).include?(2..6) # => false - # - # The native Range#include? behavior is untouched. - # ("a".."f").include?("c") # => true - # (5..9).include?(11) # => false - def include_with_range?(value) - if value.is_a?(::Range) - operator = exclude_end? ? :< : :<= - end_value = value.exclude_end? ? last.succ : last - include?(value.first) && (value.last <=> end_value).send(operator, 0) - else - include_without_range?(value) - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/range/overlaps.rb b/vendor/rails/activesupport/lib/active_support/core_ext/range/overlaps.rb deleted file mode 100644 index 43c6945..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/range/overlaps.rb +++ /dev/null @@ -1,15 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Range #:nodoc: - # Check if Ranges overlap. - module Overlaps - # Compare two ranges and see if they overlap eachother - # (1..5).overlaps?(4..6) # => true - # (1..5).overlaps?(7..9) # => false - def overlaps?(other) - include?(other.first) || other.include?(first) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/rexml.rb b/vendor/rails/activesupport/lib/active_support/core_ext/rexml.rb deleted file mode 100644 index b4891a9..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/rexml.rb +++ /dev/null @@ -1,41 +0,0 @@ -# Fixes the rexml vulnerability disclosed at: -# http://www.ruby-lang.org/en/news/2008/08/23/dos-vulnerability-in-rexml/ -# This fix is identical to rexml-expansion-fix version 1.0.1 -require 'rexml/rexml' - -# Earlier versions of rexml defined REXML::Version, newer ones REXML::VERSION -unless (defined?(REXML::VERSION) ? REXML::VERSION : REXML::Version) > "3.1.7.2" - require 'rexml/document' - - # REXML in 1.8.7 has the patch but didn't update Version from 3.1.7.2. - unless REXML::Document.respond_to?(:entity_expansion_limit=) - require 'rexml/entity' - - module REXML - class Entity < Child - undef_method :unnormalized - def unnormalized - document.record_entity_expansion! if document - v = value() - return nil if v.nil? - @unnormalized = Text::unnormalize(v, parent) - @unnormalized - end - end - class Document < Element - @@entity_expansion_limit = 10_000 - def self.entity_expansion_limit= val - @@entity_expansion_limit = val - end - - def record_entity_expansion! - @number_of_expansions ||= 0 - @number_of_expansions += 1 - if @number_of_expansions > @@entity_expansion_limit - raise "Number of entity expansions exceeded, processing aborted." - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string.rb deleted file mode 100644 index 16c544a..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string.rb +++ /dev/null @@ -1,22 +0,0 @@ -# encoding: utf-8 - -require 'active_support/core_ext/string/inflections' -require 'active_support/core_ext/string/conversions' -require 'active_support/core_ext/string/access' -require 'active_support/core_ext/string/starts_ends_with' -require 'active_support/core_ext/string/iterators' -require 'active_support/core_ext/string/multibyte' -require 'active_support/core_ext/string/xchar' -require 'active_support/core_ext/string/filters' -require 'active_support/core_ext/string/behavior' - -class String #:nodoc: - include ActiveSupport::CoreExtensions::String::Access - include ActiveSupport::CoreExtensions::String::Conversions - include ActiveSupport::CoreExtensions::String::Filters - include ActiveSupport::CoreExtensions::String::Inflections - include ActiveSupport::CoreExtensions::String::StartsEndsWith - include ActiveSupport::CoreExtensions::String::Iterators - include ActiveSupport::CoreExtensions::String::Behavior - include ActiveSupport::CoreExtensions::String::Multibyte -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/access.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/access.rb deleted file mode 100644 index 7fb21fa..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/access.rb +++ /dev/null @@ -1,82 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - unless '1.9'.respond_to?(:force_encoding) - # Makes it easier to access parts of a string, such as specific characters and substrings. - module Access - # Returns the character at the +position+ treating the string as an array (where 0 is the first character). - # - # Examples: - # "hello".at(0) # => "h" - # "hello".at(4) # => "o" - # "hello".at(10) # => nil - def at(position) - mb_chars[position, 1].to_s - end - - # Returns the remaining of the string from the +position+ treating the string as an array (where 0 is the first character). - # - # Examples: - # "hello".from(0) # => "hello" - # "hello".from(2) # => "llo" - # "hello".from(10) # => nil - def from(position) - mb_chars[position..-1].to_s - end - - # Returns the beginning of the string up to the +position+ treating the string as an array (where 0 is the first character). - # - # Examples: - # "hello".to(0) # => "h" - # "hello".to(2) # => "hel" - # "hello".to(10) # => "hello" - def to(position) - mb_chars[0..position].to_s - end - - # Returns the first character of the string or the first +limit+ characters. - # - # Examples: - # "hello".first # => "h" - # "hello".first(2) # => "he" - # "hello".first(10) # => "hello" - def first(limit = 1) - mb_chars[0..(limit - 1)].to_s - end - - # Returns the last character of the string or the last +limit+ characters. - # - # Examples: - # "hello".last # => "o" - # "hello".last(2) # => "lo" - # "hello".last(10) # => "hello" - def last(limit = 1) - (mb_chars[(-limit)..-1] || self).to_s - end - end - else - module Access #:nodoc: - def at(position) - self[position] - end - - def from(position) - self[position..-1] - end - - def to(position) - self[0..position] - end - - def first(limit = 1) - self[0..(limit - 1)] - end - - def last(limit = 1) - from(-limit) || self - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/behavior.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/behavior.rb deleted file mode 100644 index a93ca30..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/behavior.rb +++ /dev/null @@ -1,13 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - module Behavior - # Enable more predictable duck-typing on String-like classes. See - # Object#acts_like?. - def acts_like_string? - true - end - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb deleted file mode 100644 index d4334dc..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'date' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - # Converting strings to other objects - module Conversions - # 'a'.ord == 'a'[0] for Ruby 1.9 forward compatibility. - def ord - self[0] - end if RUBY_VERSION < '1.9' - - # Form can be either :utc (default) or :local. - def to_time(form = :utc) - ::Time.send("#{form}_time", *::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec).map { |arg| arg || 0 }) - end - - def to_date - ::Date.new(*::Date._parse(self, false).values_at(:year, :mon, :mday)) - end - - def to_datetime - ::DateTime.civil(*::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec).map { |arg| arg || 0 }) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/filters.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/filters.rb deleted file mode 100644 index 0329fbb..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/filters.rb +++ /dev/null @@ -1,26 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - module Filters - # Returns the string, first removing all whitespace on both ends of - # the string, and then changing remaining consecutive whitespace - # groups into one space each. - # - # Examples: - # %{ Multi-line - # string }.squish # => "Multi-line string" - # " foo bar \n \t boo".squish # => "foo bar boo" - def squish - dup.squish! - end - - # Performs a destructive squish. See String#squish. - def squish! - strip! - gsub!(/\s+/, ' ') - self - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb deleted file mode 100644 index 48e812a..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb +++ /dev/null @@ -1,167 +0,0 @@ -require 'active_support/inflector' unless defined?(ActiveSupport::Inflector) - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - # String inflections define new methods on the String class to transform names for different purposes. - # For instance, you can figure out the name of a database from the name of a class. - # - # "ScaleScore".tableize # => "scale_scores" - module Inflections - # Returns the plural form of the word in the string. - # - # "post".pluralize # => "posts" - # "octopus".pluralize # => "octopi" - # "sheep".pluralize # => "sheep" - # "words".pluralize # => "words" - # "the blue mailman".pluralize # => "the blue mailmen" - # "CamelOctopus".pluralize # => "CamelOctopi" - def pluralize - Inflector.pluralize(self) - end - - # The reverse of +pluralize+, returns the singular form of a word in a string. - # - # "posts".singularize # => "post" - # "octopi".singularize # => "octopus" - # "sheep".singularize # => "sheep" - # "word".singularize # => "word" - # "the blue mailmen".singularize # => "the blue mailman" - # "CamelOctopi".singularize # => "CamelOctopus" - def singularize - Inflector.singularize(self) - end - - # By default, +camelize+ converts strings to UpperCamelCase. If the argument to camelize - # is set to <tt>:lower</tt> then camelize produces lowerCamelCase. - # - # +camelize+ will also convert '/' to '::' which is useful for converting paths to namespaces. - # - # "active_record".camelize # => "ActiveRecord" - # "active_record".camelize(:lower) # => "activeRecord" - # "active_record/errors".camelize # => "ActiveRecord::Errors" - # "active_record/errors".camelize(:lower) # => "activeRecord::Errors" - def camelize(first_letter = :upper) - case first_letter - when :upper then Inflector.camelize(self, true) - when :lower then Inflector.camelize(self, false) - end - end - alias_method :camelcase, :camelize - - # Capitalizes all the words and replaces some characters in the string to create - # a nicer looking title. +titleize+ is meant for creating pretty output. It is not - # used in the Rails internals. - # - # +titleize+ is also aliased as +titlecase+. - # - # "man from the boondocks".titleize # => "Man From The Boondocks" - # "x-men: the last stand".titleize # => "X Men: The Last Stand" - def titleize - Inflector.titleize(self) - end - alias_method :titlecase, :titleize - - # The reverse of +camelize+. Makes an underscored, lowercase form from the expression in the string. - # - # +underscore+ will also change '::' to '/' to convert namespaces to paths. - # - # "ActiveRecord".underscore # => "active_record" - # "ActiveRecord::Errors".underscore # => active_record/errors - def underscore - Inflector.underscore(self) - end - - # Replaces underscores with dashes in the string. - # - # "puni_puni" # => "puni-puni" - def dasherize - Inflector.dasherize(self) - end - - # Removes the module part from the constant expression in the string. - # - # "ActiveRecord::CoreExtensions::String::Inflections".demodulize # => "Inflections" - # "Inflections".demodulize # => "Inflections" - def demodulize - Inflector.demodulize(self) - end - - # Replaces special characters in a string so that it may be used as part of a 'pretty' URL. - # - # ==== Examples - # - # class Person - # def to_param - # "#{id}-#{name.parameterize}" - # end - # end - # - # @person = Person.find(1) - # # => #<Person id: 1, name: "Donald E. Knuth"> - # - # <%= link_to(@person.name, person_path %> - # # => <a href="/person/1-donald-e-knuth">Donald E. Knuth</a> - def parameterize(sep = '-') - Inflector.parameterize(self, sep) - end - - # Creates the name of a table like Rails does for models to table names. This method - # uses the +pluralize+ method on the last word in the string. - # - # "RawScaledScorer".tableize # => "raw_scaled_scorers" - # "egg_and_ham".tableize # => "egg_and_hams" - # "fancyCategory".tableize # => "fancy_categories" - def tableize - Inflector.tableize(self) - end - - # Create a class name from a plural table name like Rails does for table names to models. - # Note that this returns a string and not a class. (To convert to an actual class - # follow +classify+ with +constantize+.) - # - # "egg_and_hams".classify # => "EggAndHam" - # "posts".classify # => "Post" - # - # Singular names are not handled correctly. - # - # "business".classify # => "Busines" - def classify - Inflector.classify(self) - end - - # Capitalizes the first word, turns underscores into spaces, and strips '_id'. - # Like +titleize+, this is meant for creating pretty output. - # - # "employee_salary" # => "Employee salary" - # "author_id" # => "Author" - def humanize - Inflector.humanize(self) - end - - # Creates a foreign key name from a class name. - # +separate_class_name_and_id_with_underscore+ sets whether - # the method should put '_' between the name and 'id'. - # - # Examples - # "Message".foreign_key # => "message_id" - # "Message".foreign_key(false) # => "messageid" - # "Admin::Post".foreign_key # => "post_id" - def foreign_key(separate_class_name_and_id_with_underscore = true) - Inflector.foreign_key(self, separate_class_name_and_id_with_underscore) - end - - # +constantize+ tries to find a declared constant with the name specified - # in the string. It raises a NameError when the name is not in CamelCase - # or is not initialized. - # - # Examples - # "Module".constantize # => Module - # "Class".constantize # => Class - def constantize - Inflector.constantize(self) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb deleted file mode 100644 index fe17d14..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'strscan' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - # Custom string iterators - module Iterators - def self.append_features(base) - super unless '1.9'.respond_to?(:each_char) - end - - # Yields a single-character string for each character in the string. - # When $KCODE = 'UTF8', multi-byte characters are yielded appropriately. - def each_char - scanner, char = StringScanner.new(self), /./mu - while c = scanner.scan(char) - yield c - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/multibyte.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/multibyte.rb deleted file mode 100644 index a4caa83..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/multibyte.rb +++ /dev/null @@ -1,81 +0,0 @@ -# encoding: utf-8 - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - # Implements multibyte methods for easier access to multibyte characters in a String instance. - module Multibyte - unless '1.9'.respond_to?(:force_encoding) - # == Multibyte proxy - # - # +mb_chars+ is a multibyte safe proxy for string methods. - # - # In Ruby 1.8 and older it creates and returns an instance of the ActiveSupport::Multibyte::Chars class which - # encapsulates the original string. A Unicode safe version of all the String methods are defined on this proxy - # class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsuled string. - # - # name = 'Claus Müller' - # name.reverse #=> "rell??M sualC" - # name.length #=> 13 - # - # name.mb_chars.reverse.to_s #=> "rellüM sualC" - # name.mb_chars.length #=> 12 - # - # In Ruby 1.9 and newer +mb_chars+ returns +self+ because String is (mostly) encoding aware. This means that - # it becomes easy to run one version of your code on multiple Ruby versions. - # - # == Method chaining - # - # All the methods on the Chars proxy which normally return a string will return a Chars object. This allows - # method chaining on the result of any of these methods. - # - # name.mb_chars.reverse.length #=> 12 - # - # == Interoperability and configuration - # - # The Chars object tries to be as interchangeable with String objects as possible: sorting and comparing between - # String and Char work like expected. The bang! methods change the internal string representation in the Chars - # object. Interoperability problems can be resolved easily with a +to_s+ call. - # - # For more information about the methods defined on the Chars proxy see ActiveSupport::Multibyte::Chars. For - # information about how to change the default Multibyte behaviour see ActiveSupport::Multibyte. - def mb_chars - if ActiveSupport::Multibyte.proxy_class.wants?(self) - ActiveSupport::Multibyte.proxy_class.new(self) - else - self - end - end - - # Returns true if the string has UTF-8 semantics (a String used for purely byte resources is unlikely to have - # them), returns false otherwise. - def is_utf8? - ActiveSupport::Multibyte::Chars.consumes?(self) - end - - unless '1.8.7 and later'.respond_to?(:chars) - def chars - ActiveSupport::Deprecation.warn('String#chars has been deprecated in favor of String#mb_chars.', caller) - mb_chars - end - end - else - def mb_chars #:nodoc - self - end - - def is_utf8? #:nodoc - case encoding - when Encoding::UTF_8 - valid_encoding? - when Encoding::ASCII_8BIT, Encoding::US_ASCII - dup.force_encoding(Encoding::UTF_8).valid_encoding? - else - false - end - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb deleted file mode 100644 index 09f9a18..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb +++ /dev/null @@ -1,35 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - # Additional string tests. - module StartsEndsWith - def self.append_features(base) - if '1.8.7 and up'.respond_to?(:start_with?) - base.class_eval do - alias_method :starts_with?, :start_with? - alias_method :ends_with?, :end_with? - end - else - super - base.class_eval do - alias_method :start_with?, :starts_with? - alias_method :end_with?, :ends_with? - end - end - end - - # Does the string start with the specified +prefix+? - def starts_with?(prefix) - prefix = prefix.to_s - self[0, prefix.length] == prefix - end - - # Does the string end with the specified +suffix+? - def ends_with?(suffix) - suffix = suffix.to_s - self[-suffix.length, suffix.length] == suffix - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/xchar.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/xchar.rb deleted file mode 100644 index df186e4..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/string/xchar.rb +++ /dev/null @@ -1,11 +0,0 @@ -begin - # See http://bogomips.org/fast_xs/ by Eric Wong - require 'fast_xs' - - class String - alias_method :original_xs, :to_xs if method_defined?(:to_xs) - alias_method :to_xs, :fast_xs - end -rescue LoadError - # fast_xs extension unavailable. -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb b/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb deleted file mode 100644 index e4ac443..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb +++ /dev/null @@ -1,14 +0,0 @@ -unless :to_proc.respond_to?(:to_proc) - class Symbol - # Turns the symbol into a simple proc, which is especially useful for enumerations. Examples: - # - # # The same as people.collect { |p| p.name } - # people.collect(&:name) - # - # # The same as people.select { |p| p.manager? }.collect { |p| p.salary } - # people.select(&:manager?).collect(&:salary) - def to_proc - Proc.new { |*args| args.shift.__send__(self, *args) } - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/time.rb b/vendor/rails/activesupport/lib/active_support/core_ext/time.rb deleted file mode 100644 index 78bbfc9..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/time.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'date' -require 'time' - -class Time - # Ruby 1.8-cvs and 1.9 define private Time#to_date - %w(to_date to_datetime).each do |method| - public method if private_instance_methods.include?(method) - end - - # Pre-1.9 versions of Ruby have a bug with marshaling Time instances, where utc instances are - # unmarshaled in the local zone, instead of utc. We're layering behavior on the _dump and _load - # methods so that utc instances can be flagged on dump, and coerced back to utc on load. - if RUBY_VERSION < '1.9' - class << self - alias_method :_original_load, :_load - def _load(marshaled_time) - time = _original_load(marshaled_time) - utc = time.instance_variable_get('@marshal_with_utc_coercion') - utc ? time.utc : time - end - end - - alias_method :_original_dump, :_dump - def _dump(*args) - obj = self.frozen? ? self.dup : self - obj.instance_variable_set('@marshal_with_utc_coercion', utc?) - obj._original_dump(*args) - end - end -end - -require 'active_support/core_ext/time/behavior' -require 'active_support/core_ext/time/calculations' -require 'active_support/core_ext/time/conversions' -require 'active_support/core_ext/time/zones' - -class Time#:nodoc: - include ActiveSupport::CoreExtensions::Time::Behavior - include ActiveSupport::CoreExtensions::Time::Calculations - include ActiveSupport::CoreExtensions::Time::Conversions - include ActiveSupport::CoreExtensions::Time::Zones -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/time/behavior.rb b/vendor/rails/activesupport/lib/active_support/core_ext/time/behavior.rb deleted file mode 100644 index a5c0baa..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/time/behavior.rb +++ /dev/null @@ -1,13 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Time #:nodoc: - module Behavior - # Enable more predictable duck-typing on Time-like classes. See - # Object#acts_like?. - def acts_like_time? - true - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb b/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb deleted file mode 100644 index 5ed750a..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb +++ /dev/null @@ -1,303 +0,0 @@ -require 'active_support/duration' - -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Time #:nodoc: - # Enables the use of time calculations within Time itself - module Calculations - def self.included(base) #:nodoc: - base.extend ClassMethods - - base.class_eval do - alias_method :plus_without_duration, :+ - alias_method :+, :plus_with_duration - - alias_method :minus_without_duration, :- - alias_method :-, :minus_with_duration - - alias_method :minus_without_coercion, :- - alias_method :-, :minus_with_coercion - - alias_method :compare_without_coercion, :<=> - alias_method :<=>, :compare_with_coercion - end - end - - COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] - - module ClassMethods - # Overriding case equality method so that it returns true for ActiveSupport::TimeWithZone instances - def ===(other) - other.is_a?(::Time) - end - - # Return the number of days in the given month. - # If no year is specified, it will use the current year. - def days_in_month(month, year = now.year) - return 29 if month == 2 && ::Date.gregorian_leap?(year) - COMMON_YEAR_DAYS_IN_MONTH[month] - end - - # Returns a new Time if requested year can be accommodated by Ruby's Time class - # (i.e., if year is within either 1970..2038 or 1902..2038, depending on system architecture); - # otherwise returns a DateTime - def time_with_datetime_fallback(utc_or_local, year, month=1, day=1, hour=0, min=0, sec=0, usec=0) - ::Time.send(utc_or_local, year, month, day, hour, min, sec, usec) - rescue - offset = utc_or_local.to_sym == :local ? ::DateTime.local_offset : 0 - ::DateTime.civil(year, month, day, hour, min, sec, offset) - end - - # Wraps class method +time_with_datetime_fallback+ with +utc_or_local+ set to <tt>:utc</tt>. - def utc_time(*args) - time_with_datetime_fallback(:utc, *args) - end - - # Wraps class method +time_with_datetime_fallback+ with +utc_or_local+ set to <tt>:local</tt>. - def local_time(*args) - time_with_datetime_fallback(:local, *args) - end - end - - # Tells whether the Time object's time lies in the past - def past? - self < ::Time.current - end - - # Tells whether the Time object's time is today - def today? - self.to_date == ::Date.current - end - - # Tells whether the Time object's time lies in the future - def future? - self > ::Time.current - end - - # Seconds since midnight: Time.now.seconds_since_midnight - def seconds_since_midnight - self.to_i - self.change(:hour => 0).to_i + (self.usec/1.0e+6) - end - - # Returns a new Time where one or more of the elements have been changed according to the +options+ parameter. The time options - # (hour, minute, sec, usec) reset cascadingly, so if only the hour is passed, then minute, sec, and usec is set to 0. If the hour and - # minute is passed, then sec and usec is set to 0. - def change(options) - ::Time.send( - self.utc? ? :utc_time : :local_time, - options[:year] || self.year, - options[:month] || self.month, - options[:day] || self.day, - options[:hour] || self.hour, - options[:min] || (options[:hour] ? 0 : self.min), - options[:sec] || ((options[:hour] || options[:min]) ? 0 : self.sec), - options[:usec] || ((options[:hour] || options[:min] || options[:sec]) ? 0 : self.usec) - ) - end - - # Uses Date to provide precise Time calculations for years, months, and days. - # The +options+ parameter takes a hash with any of these keys: <tt>:years</tt>, - # <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>, <tt>:hours</tt>, - # <tt>:minutes</tt>, <tt>:seconds</tt>. - def advance(options) - unless options[:weeks].nil? - options[:weeks], partial_weeks = options[:weeks].divmod(1) - options[:days] = (options[:days] || 0) + 7 * partial_weeks - end - - unless options[:days].nil? - options[:days], partial_days = options[:days].divmod(1) - options[:hours] = (options[:hours] || 0) + 24 * partial_days - end - - d = to_date.advance(options) - time_advanced_by_date = change(:year => d.year, :month => d.month, :day => d.day) - seconds_to_advance = (options[:seconds] || 0) + (options[:minutes] || 0) * 60 + (options[:hours] || 0) * 3600 - seconds_to_advance == 0 ? time_advanced_by_date : time_advanced_by_date.since(seconds_to_advance) - end - - # Returns a new Time representing the time a number of seconds ago, this is basically a wrapper around the Numeric extension - def ago(seconds) - self.since(-seconds) - end - - # Returns a new Time representing the time a number of seconds since the instance time, this is basically a wrapper around - # the Numeric extension. - def since(seconds) - f = seconds.since(self) - if ActiveSupport::Duration === seconds - f - else - initial_dst = self.dst? ? 1 : 0 - final_dst = f.dst? ? 1 : 0 - (seconds.abs >= 86400 && initial_dst != final_dst) ? f + (initial_dst - final_dst).hours : f - end - rescue - self.to_datetime.since(seconds) - end - alias :in :since - - # Returns a new Time representing the time a number of specified months ago - def months_ago(months) - advance(:months => -months) - end - - # Returns a new Time representing the time a number of specified months in the future - def months_since(months) - advance(:months => months) - end - - # Returns a new Time representing the time a number of specified years ago - def years_ago(years) - advance(:years => -years) - end - - # Returns a new Time representing the time a number of specified years in the future - def years_since(years) - advance(:years => years) - end - - # Short-hand for years_ago(1) - def last_year - years_ago(1) - end - - # Short-hand for years_since(1) - def next_year - years_since(1) - end - - - # Short-hand for months_ago(1) - def last_month - months_ago(1) - end - - # Short-hand for months_since(1) - def next_month - months_since(1) - end - - # Returns a new Time representing the "start" of this week (Monday, 0:00) - def beginning_of_week - days_to_monday = self.wday!=0 ? self.wday-1 : 6 - (self - days_to_monday.days).midnight - end - alias :monday :beginning_of_week - alias :at_beginning_of_week :beginning_of_week - - # Returns a new Time representing the end of this week (Sunday, 23:59:59) - def end_of_week - days_to_sunday = self.wday!=0 ? 7-self.wday : 0 - (self + days_to_sunday.days).end_of_day - end - alias :at_end_of_week :end_of_week - - # Returns a new Time representing the start of the given day in next week (default is Monday). - def next_week(day = :monday) - days_into_week = { :monday => 0, :tuesday => 1, :wednesday => 2, :thursday => 3, :friday => 4, :saturday => 5, :sunday => 6} - since(1.week).beginning_of_week.since(days_into_week[day].day).change(:hour => 0) - end - - # Returns a new Time representing the start of the day (0:00) - def beginning_of_day - (self - self.seconds_since_midnight).change(:usec => 0) - end - alias :midnight :beginning_of_day - alias :at_midnight :beginning_of_day - alias :at_beginning_of_day :beginning_of_day - - # Returns a new Time representing the end of the day (23:59:59) - def end_of_day - change(:hour => 23, :min => 59, :sec => 59) - end - - # Returns a new Time representing the start of the month (1st of the month, 0:00) - def beginning_of_month - #self - ((self.mday-1).days + self.seconds_since_midnight) - change(:day => 1,:hour => 0, :min => 0, :sec => 0, :usec => 0) - end - alias :at_beginning_of_month :beginning_of_month - - # Returns a new Time representing the end of the month (last day of the month, 0:00) - def end_of_month - #self - ((self.mday-1).days + self.seconds_since_midnight) - last_day = ::Time.days_in_month( self.month, self.year ) - change(:day => last_day, :hour => 23, :min => 59, :sec => 59, :usec => 0) - end - alias :at_end_of_month :end_of_month - - # Returns a new Time representing the start of the quarter (1st of january, april, july, october, 0:00) - def beginning_of_quarter - beginning_of_month.change(:month => [10, 7, 4, 1].detect { |m| m <= self.month }) - end - alias :at_beginning_of_quarter :beginning_of_quarter - - # Returns a new Time representing the end of the quarter (last day of march, june, september, december, 23:59:59) - def end_of_quarter - beginning_of_month.change(:month => [3, 6, 9, 12].detect { |m| m >= self.month }).end_of_month - end - alias :at_end_of_quarter :end_of_quarter - - # Returns a new Time representing the start of the year (1st of january, 0:00) - def beginning_of_year - change(:month => 1,:day => 1,:hour => 0, :min => 0, :sec => 0, :usec => 0) - end - alias :at_beginning_of_year :beginning_of_year - - # Returns a new Time representing the end of the year (31st of december, 23:59:59) - def end_of_year - change(:month => 12,:day => 31,:hour => 23, :min => 59, :sec => 59) - end - alias :at_end_of_year :end_of_year - - # Convenience method which returns a new Time representing the time 1 day ago - def yesterday - advance(:days => -1) - end - - # Convenience method which returns a new Time representing the time 1 day since the instance time - def tomorrow - advance(:days => 1) - end - - def plus_with_duration(other) #:nodoc: - if ActiveSupport::Duration === other - other.since(self) - else - plus_without_duration(other) - end - end - - def minus_with_duration(other) #:nodoc: - if ActiveSupport::Duration === other - other.until(self) - else - minus_without_duration(other) - end - end - - # Time#- can also be used to determine the number of seconds between two Time instances. - # We're layering on additional behavior so that ActiveSupport::TimeWithZone instances - # are coerced into values that Time#- will recognize - def minus_with_coercion(other) - other = other.comparable_time if other.respond_to?(:comparable_time) - minus_without_coercion(other) - end - - # Layers additional behavior on Time#<=> so that DateTime and ActiveSupport::TimeWithZone instances - # can be chronologically compared with a Time - def compare_with_coercion(other) - # if other is an ActiveSupport::TimeWithZone, coerce a Time instance from it so we can do <=> comparison - other = other.comparable_time if other.respond_to?(:comparable_time) - if other.acts_like?(:date) - # other is a Date/DateTime, so coerce self #to_datetime and hand off to DateTime#<=> - to_datetime.compare_without_coercion(other) - else - compare_without_coercion(other) - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/time/conversions.rb b/vendor/rails/activesupport/lib/active_support/core_ext/time/conversions.rb deleted file mode 100644 index e6f9134..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/time/conversions.rb +++ /dev/null @@ -1,90 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Time #:nodoc: - # Converting times to formatted strings, dates, and datetimes. - module Conversions - DATE_FORMATS = { - :db => "%Y-%m-%d %H:%M:%S", - :number => "%Y%m%d%H%M%S", - :time => "%H:%M", - :short => "%d %b %H:%M", - :long => "%B %d, %Y %H:%M", - :long_ordinal => lambda { |time| time.strftime("%B #{time.day.ordinalize}, %Y %H:%M") }, - :rfc822 => lambda { |time| time.strftime("%a, %d %b %Y %H:%M:%S #{time.formatted_offset(false)}") } - } - - def self.included(base) #:nodoc: - base.class_eval do - alias_method :to_default_s, :to_s - alias_method :to_s, :to_formatted_s - end - end - - # Converts to a formatted string. See DATE_FORMATS for builtin formats. - # - # This method is aliased to <tt>to_s</tt>. - # - # time = Time.now # => Thu Jan 18 06:10:17 CST 2007 - # - # time.to_formatted_s(:time) # => "06:10:17" - # time.to_s(:time) # => "06:10:17" - # - # time.to_formatted_s(:db) # => "2007-01-18 06:10:17" - # time.to_formatted_s(:number) # => "20070118061017" - # time.to_formatted_s(:short) # => "18 Jan 06:10" - # time.to_formatted_s(:long) # => "January 18, 2007 06:10" - # time.to_formatted_s(:long_ordinal) # => "January 18th, 2007 06:10" - # time.to_formatted_s(:rfc822) # => "Thu, 18 Jan 2007 06:10:17 -0600" - # - # == Adding your own time formats to +to_formatted_s+ - # You can add your own formats to the Time::DATE_FORMATS hash. - # Use the format name as the hash key and either a strftime string - # or Proc instance that takes a time argument as the value. - # - # # config/initializers/time_formats.rb - # Time::DATE_FORMATS[:month_and_year] = "%B %Y" - # Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") } - def to_formatted_s(format = :default) - return to_default_s unless formatter = DATE_FORMATS[format] - formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter) - end - - # Returns the UTC offset as an +HH:MM formatted string. - # - # Time.local(2000).formatted_offset # => "-06:00" - # Time.local(2000).formatted_offset(false) # => "-0600" - def formatted_offset(colon = true, alternate_utc_string = nil) - utc? && alternate_utc_string || utc_offset.to_utc_offset_s(colon) - end - - # Converts a Time object to a Date, dropping hour, minute, and second precision. - # - # my_time = Time.now # => Mon Nov 12 22:59:51 -0500 2007 - # my_time.to_date # => Mon, 12 Nov 2007 - # - # your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009 - # your_time.to_date # => Tue, 13 Jan 2009 - def to_date - ::Date.new(year, month, day) - end - - # A method to keep Time, Date and DateTime instances interchangeable on conversions. - # In this case, it simply returns +self+. - def to_time - self - end - - # Converts a Time instance to a Ruby DateTime instance, preserving UTC offset. - # - # my_time = Time.now # => Mon Nov 12 23:04:21 -0500 2007 - # my_time.to_datetime # => Mon, 12 Nov 2007 23:04:21 -0500 - # - # your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009 - # your_time.to_datetime # => Tue, 13 Jan 2009 13:13:03 -0500 - def to_datetime - ::DateTime.civil(year, month, day, hour, min, sec, Rational(utc_offset, 86400)) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/time/zones.rb b/vendor/rails/activesupport/lib/active_support/core_ext/time/zones.rb deleted file mode 100644 index 9d8eb73..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/time/zones.rb +++ /dev/null @@ -1,86 +0,0 @@ -module ActiveSupport #:nodoc: - module CoreExtensions #:nodoc: - module Time #:nodoc: - module Zones - def self.included(base) #:nodoc: - base.extend(ClassMethods) if base == ::Time # i.e., don't include class methods in DateTime - end - - module ClassMethods - attr_accessor :zone_default - - # Returns the TimeZone for the current request, if this has been set (via Time.zone=). - # If <tt>Time.zone</tt> has not been set for the current request, returns the TimeZone specified in <tt>config.time_zone</tt>. - def zone - Thread.current[:time_zone] || zone_default - end - - # Sets <tt>Time.zone</tt> to a TimeZone object for the current request/thread. - # - # This method accepts any of the following: - # - # * A Rails TimeZone object. - # * An identifier for a Rails TimeZone object (e.g., "Eastern Time (US & Canada)", <tt>-5.hours</tt>). - # * A TZInfo::Timezone object. - # * An identifier for a TZInfo::Timezone object (e.g., "America/New_York"). - # - # Here's an example of how you might set <tt>Time.zone</tt> on a per request basis -- <tt>current_user.time_zone</tt> - # just needs to return a string identifying the user's preferred TimeZone: - # - # class ApplicationController < ActionController::Base - # before_filter :set_time_zone - # - # def set_time_zone - # Time.zone = current_user.time_zone - # end - # end - def zone=(time_zone) - Thread.current[:time_zone] = get_zone(time_zone) - end - - # Allows override of <tt>Time.zone</tt> locally inside supplied block; resets <tt>Time.zone</tt> to existing value when done. - def use_zone(time_zone) - old_zone, ::Time.zone = ::Time.zone, get_zone(time_zone) - yield - ensure - ::Time.zone = old_zone - end - - # Returns <tt>Time.zone.now</tt> when <tt>config.time_zone</tt> is set, otherwise just returns <tt>Time.now</tt>. - def current - ::Time.zone_default ? ::Time.zone.now : ::Time.now - end - - private - def get_zone(time_zone) - return time_zone if time_zone.nil? || time_zone.is_a?(TimeZone) - # lookup timezone based on identifier (unless we've been passed a TZInfo::Timezone) - unless time_zone.respond_to?(:period_for_local) - time_zone = TimeZone[time_zone] || TZInfo::Timezone.get(time_zone) rescue nil - end - # Return if a TimeZone instance, or wrap in a TimeZone instance if a TZInfo::Timezone - if time_zone - time_zone.is_a?(TimeZone) ? time_zone : TimeZone.create(time_zone.name, nil, time_zone) - end - end - end - - # Returns the simultaneous time in <tt>Time.zone</tt>. - # - # Time.zone = 'Hawaii' # => 'Hawaii' - # Time.utc(2000).in_time_zone # => Fri, 31 Dec 1999 14:00:00 HST -10:00 - # - # This method is similar to Time#localtime, except that it uses <tt>Time.zone</tt> as the local zone - # instead of the operating system's time zone. - # - # You can also pass in a TimeZone instance or string that identifies a TimeZone as an argument, - # and the conversion will be based on that zone instead of <tt>Time.zone</tt>. - # - # Time.utc(2000).in_time_zone('Alaska') # => Fri, 31 Dec 1999 15:00:00 AKST -09:00 - def in_time_zone(zone = ::Time.zone) - ActiveSupport::TimeWithZone.new(utc? ? self : getutc, ::Time.__send__(:get_zone, zone)) - end - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/try.rb b/vendor/rails/activesupport/lib/active_support/core_ext/try.rb deleted file mode 100644 index 3de198d..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/try.rb +++ /dev/null @@ -1,36 +0,0 @@ -class Object - # Invokes the method identified by the symbol +method+, passing it any arguments - # and/or the block specified, just like the regular Ruby <tt>Object#send</tt> does. - # - # *Unlike* that method however, a +NoMethodError+ exception will *not* be raised - # and +nil+ will be returned instead, if the receiving object is a +nil+ object or NilClass. - # - # ==== Examples - # - # Without try - # @person && @person.name - # or - # @person ? @person.name : nil - # - # With try - # @person.try(:name) - # - # +try+ also accepts arguments and/or a block, for the method it is trying - # Person.try(:find, 1) - # @people.try(:collect) {|p| p.name} - #-- - # This method definition below is for rdoc purposes only. The alias_method call - # below overrides it as an optimization since +try+ behaves like +Object#send+, - # unless called on +NilClass+. - def try(method, *args, &block) - send(method, *args, &block) - end - remove_method :try - alias_method :try, :__send__ -end - -class NilClass - def try(*args) - nil - end -end diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/uri.rb b/vendor/rails/activesupport/lib/active_support/core_ext/uri.rb deleted file mode 100644 index 9a1c61d..0000000 --- a/vendor/rails/activesupport/lib/active_support/core_ext/uri.rb +++ /dev/null @@ -1,16 +0,0 @@ -if RUBY_VERSION >= '1.9' - require 'uri' - - str = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E" # Ni-ho-nn-go in UTF-8, means Japanese. - str.force_encoding(Encoding::UTF_8) if str.respond_to?(:force_encoding) - - unless str == URI.unescape(URI.escape(str)) - URI::Parser.class_eval do - remove_method :unescape - def unescape(str, escaped = @regexp[:ESCAPED]) - enc = (str.encoding == Encoding::US_ASCII) ? Encoding::UTF_8 : str.encoding - str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(enc) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/dependencies.rb b/vendor/rails/activesupport/lib/active_support/dependencies.rb deleted file mode 100644 index 2badad5..0000000 --- a/vendor/rails/activesupport/lib/active_support/dependencies.rb +++ /dev/null @@ -1,625 +0,0 @@ -module ActiveSupport #:nodoc: - module Dependencies #:nodoc: - extend self - - # Should we turn on Ruby warnings on the first load of dependent files? - mattr_accessor :warnings_on_first_load - self.warnings_on_first_load = false - - # All files ever loaded. - mattr_accessor :history - self.history = Set.new - - # All files currently loaded. - mattr_accessor :loaded - self.loaded = Set.new - - # Should we load files or require them? - mattr_accessor :mechanism - self.mechanism = :load - - # The set of directories from which we may automatically load files. Files - # under these directories will be reloaded on each request in development mode, - # unless the directory also appears in load_once_paths. - mattr_accessor :load_paths - self.load_paths = [] - - # The set of directories from which automatically loaded constants are loaded - # only once. All directories in this set must also be present in +load_paths+. - mattr_accessor :load_once_paths - self.load_once_paths = [] - - # An array of qualified constant names that have been loaded. Adding a name to - # this array will cause it to be unloaded the next time Dependencies are cleared. - mattr_accessor :autoloaded_constants - self.autoloaded_constants = [] - - # An array of constant names that need to be unloaded on every request. Used - # to allow arbitrary constants to be marked for unloading. - mattr_accessor :explicitly_unloadable_constants - self.explicitly_unloadable_constants = [] - - # The logger is used for generating information on the action run-time (including benchmarking) if available. - # Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers. - mattr_accessor :logger - - # Set to true to enable logging of const_missing and file loads - mattr_accessor :log_activity - self.log_activity = false - - # An internal stack used to record which constants are loaded by any block. - mattr_accessor :constant_watch_stack - self.constant_watch_stack = [] - - mattr_accessor :constant_watch_stack_mutex - self.constant_watch_stack_mutex = Mutex.new - - # Module includes this module - module ModuleConstMissing #:nodoc: - def self.included(base) #:nodoc: - base.class_eval do - unless defined? const_missing_without_dependencies - alias_method_chain :const_missing, :dependencies - end - end - end - - def self.excluded(base) #:nodoc: - base.class_eval do - if defined? const_missing_without_dependencies - undef_method :const_missing - alias_method :const_missing, :const_missing_without_dependencies - undef_method :const_missing_without_dependencies - end - end - end - - # Use const_missing to autoload associations so we don't have to - # require_association when using single-table inheritance. - def const_missing_with_dependencies(class_id) - ActiveSupport::Dependencies.load_missing_constant self, class_id - end - - def unloadable(const_desc = self) - super(const_desc) - end - end - - # Class includes this module - module ClassConstMissing #:nodoc: - def const_missing(const_name) - if [Object, Kernel].include?(self) || parent == self - super - else - begin - begin - Dependencies.load_missing_constant self, const_name - rescue NameError - parent.send :const_missing, const_name - end - rescue NameError => e - # Make sure that the name we are missing is the one that caused the error - parent_qualified_name = Dependencies.qualified_name_for parent, const_name - raise unless e.missing_name? parent_qualified_name - qualified_name = Dependencies.qualified_name_for self, const_name - raise NameError.new("uninitialized constant #{qualified_name}").copy_blame!(e) - end - end - end - end - - # Object includes this module - module Loadable #:nodoc: - def self.included(base) #:nodoc: - base.class_eval do - unless defined? load_without_new_constant_marking - alias_method_chain :load, :new_constant_marking - end - end - end - - def self.excluded(base) #:nodoc: - base.class_eval do - if defined? load_without_new_constant_marking - undef_method :load - alias_method :load, :load_without_new_constant_marking - undef_method :load_without_new_constant_marking - end - end - end - - def require_or_load(file_name) - Dependencies.require_or_load(file_name) - end - - def require_dependency(file_name) - Dependencies.depend_on(file_name) - end - - def require_association(file_name) - Dependencies.associate_with(file_name) - end - - def load_with_new_constant_marking(file, *extras) #:nodoc: - if Dependencies.load? - Dependencies.new_constants_in(Object) { load_without_new_constant_marking(file, *extras) } - else - load_without_new_constant_marking(file, *extras) - end - rescue Exception => exception # errors from loading file - exception.blame_file! file - raise - end - - def require(file, *extras) #:nodoc: - if Dependencies.load? - Dependencies.new_constants_in(Object) { super } - else - super - end - rescue Exception => exception # errors from required file - exception.blame_file! file - raise - end - - # Mark the given constant as unloadable. Unloadable constants are removed each - # time dependencies are cleared. - # - # Note that marking a constant for unloading need only be done once. Setup - # or init scripts may list each unloadable constant that may need unloading; - # each constant will be removed for every subsequent clear, as opposed to for - # the first clear. - # - # The provided constant descriptor may be a (non-anonymous) module or class, - # or a qualified constant name as a string or symbol. - # - # Returns true if the constant was not previously marked for unloading, false - # otherwise. - def unloadable(const_desc) - Dependencies.mark_for_unload const_desc - end - end - - # Exception file-blaming - module Blamable #:nodoc: - def blame_file!(file) - (@blamed_files ||= []).unshift file - end - - def blamed_files - @blamed_files ||= [] - end - - def describe_blame - return nil if blamed_files.empty? - "This error occurred while loading the following files:\n #{blamed_files.join "\n "}" - end - - def copy_blame!(exc) - @blamed_files = exc.blamed_files.clone - self - end - end - - def hook! - Object.instance_eval { include Loadable } - Module.instance_eval { include ModuleConstMissing } - Class.instance_eval { include ClassConstMissing } - Exception.instance_eval { include Blamable } - true - end - - def unhook! - ModuleConstMissing.excluded(Module) - Loadable.excluded(Object) - true - end - - def load? - mechanism == :load - end - - def depend_on(file_name, swallow_load_errors = false) - path = search_for_file(file_name) - require_or_load(path || file_name) - rescue LoadError - raise unless swallow_load_errors - end - - def associate_with(file_name) - depend_on(file_name, true) - end - - def clear - log_call - loaded.clear - remove_unloadable_constants! - end - - def require_or_load(file_name, const_path = nil) - log_call file_name, const_path - file_name = $1 if file_name =~ /^(.*)\.rb$/ - expanded = File.expand_path(file_name) - return if loaded.include?(expanded) - - # Record that we've seen this file *before* loading it to avoid an - # infinite loop with mutual dependencies. - loaded << expanded - - begin - if load? - log "loading #{file_name}" - - # Enable warnings iff this file has not been loaded before and - # warnings_on_first_load is set. - load_args = ["#{file_name}.rb"] - load_args << const_path unless const_path.nil? - - if !warnings_on_first_load or history.include?(expanded) - result = load_file(*load_args) - else - enable_warnings { result = load_file(*load_args) } - end - else - log "requiring #{file_name}" - result = require file_name - end - rescue Exception - loaded.delete expanded - raise - end - - # Record history *after* loading so first load gets warnings. - history << expanded - return result - end - - # Is the provided constant path defined? - def qualified_const_defined?(path) - raise NameError, "#{path.inspect} is not a valid constant name!" unless - /^(::)?([A-Z]\w*)(::[A-Z]\w*)*$/ =~ path - - names = path.to_s.split('::') - names.shift if names.first.empty? - - # We can't use defined? because it will invoke const_missing for the parent - # of the name we are checking. - names.inject(Object) do |mod, name| - return false unless uninherited_const_defined?(mod, name) - mod.const_get name - end - return true - end - - if Module.method(:const_defined?).arity == 1 - # Does this module define this constant? - # Wrapper to accomodate changing Module#const_defined? in Ruby 1.9 - def uninherited_const_defined?(mod, const) - mod.const_defined?(const) - end - else - def uninherited_const_defined?(mod, const) #:nodoc: - mod.const_defined?(const, false) - end - end - - # Given +path+, a filesystem path to a ruby file, return an array of constant - # paths which would cause Dependencies to attempt to load this file. - def loadable_constants_for_path(path, bases = load_paths) - path = $1 if path =~ /\A(.*)\.rb\Z/ - expanded_path = File.expand_path(path) - - bases.collect do |root| - expanded_root = File.expand_path(root) - next unless %r{\A#{Regexp.escape(expanded_root)}(/|\\)} =~ expanded_path - - nesting = expanded_path[(expanded_root.size)..-1] - nesting = nesting[1..-1] if nesting && nesting[0] == ?/ - next if nesting.blank? - nesting_camel = nesting.camelize - begin - qualified_const_defined?(nesting_camel) - rescue NameError - next - end - [ nesting_camel ] - end.flatten.compact.uniq - end - - # Search for a file in load_paths matching the provided suffix. - def search_for_file(path_suffix) - path_suffix = path_suffix + '.rb' unless path_suffix.ends_with? '.rb' - load_paths.each do |root| - path = File.join(root, path_suffix) - return path if File.file? path - end - nil # Gee, I sure wish we had first_match ;-) - end - - # Does the provided path_suffix correspond to an autoloadable module? - # Instead of returning a boolean, the autoload base for this module is returned. - def autoloadable_module?(path_suffix) - load_paths.each do |load_path| - return load_path if File.directory? File.join(load_path, path_suffix) - end - nil - end - - def load_once_path?(path) - load_once_paths.any? { |base| path.starts_with? base } - end - - # Attempt to autoload the provided module name by searching for a directory - # matching the expect path suffix. If found, the module is created and assigned - # to +into+'s constants with the name +const_name+. Provided that the directory - # was loaded from a reloadable base path, it is added to the set of constants - # that are to be unloaded. - def autoload_module!(into, const_name, qualified_name, path_suffix) - return nil unless base_path = autoloadable_module?(path_suffix) - mod = Module.new - into.const_set const_name, mod - autoloaded_constants << qualified_name unless load_once_paths.include?(base_path) - return mod - end - - # Load the file at the provided path. +const_paths+ is a set of qualified - # constant names. When loading the file, Dependencies will watch for the - # addition of these constants. Each that is defined will be marked as - # autoloaded, and will be removed when Dependencies.clear is next called. - # - # If the second parameter is left off, then Dependencies will construct a set - # of names that the file at +path+ may define. See - # +loadable_constants_for_path+ for more details. - def load_file(path, const_paths = loadable_constants_for_path(path)) - log_call path, const_paths - const_paths = [const_paths].compact unless const_paths.is_a? Array - parent_paths = const_paths.collect { |const_path| /(.*)::[^:]+\Z/ =~ const_path ? $1 : :Object } - - result = nil - newly_defined_paths = new_constants_in(*parent_paths) do - result = load_without_new_constant_marking path - end - - autoloaded_constants.concat newly_defined_paths unless load_once_path?(path) - autoloaded_constants.uniq! - log "loading #{path} defined #{newly_defined_paths * ', '}" unless newly_defined_paths.empty? - return result - end - - # Return the constant path for the provided parent and constant name. - def qualified_name_for(mod, name) - mod_name = to_constant_name mod - (%w(Object Kernel).include? mod_name) ? name.to_s : "#{mod_name}::#{name}" - end - - # Load the constant named +const_name+ which is missing from +from_mod+. If - # it is not possible to load the constant into from_mod, try its parent module - # using const_missing. - def load_missing_constant(from_mod, const_name) - log_call from_mod, const_name - if from_mod == Kernel - if ::Object.const_defined?(const_name) - log "Returning Object::#{const_name} for Kernel::#{const_name}" - return ::Object.const_get(const_name) - else - log "Substituting Object for Kernel" - from_mod = Object - end - end - - # If we have an anonymous module, all we can do is attempt to load from Object. - from_mod = Object if from_mod.name.blank? - - unless qualified_const_defined?(from_mod.name) && from_mod.name.constantize.object_id == from_mod.object_id - raise ArgumentError, "A copy of #{from_mod} has been removed from the module tree but is still active!" - end - - raise ArgumentError, "#{from_mod} is not missing constant #{const_name}!" if uninherited_const_defined?(from_mod, const_name) - - qualified_name = qualified_name_for from_mod, const_name - path_suffix = qualified_name.underscore - name_error = NameError.new("uninitialized constant #{qualified_name}") - - file_path = search_for_file(path_suffix) - if file_path && ! loaded.include?(File.expand_path(file_path)) # We found a matching file to load - require_or_load file_path - raise LoadError, "Expected #{file_path} to define #{qualified_name}" unless uninherited_const_defined?(from_mod, const_name) - return from_mod.const_get(const_name) - elsif mod = autoload_module!(from_mod, const_name, qualified_name, path_suffix) - return mod - elsif (parent = from_mod.parent) && parent != from_mod && - ! from_mod.parents.any? { |p| uninherited_const_defined?(p, const_name) } - # If our parents do not have a constant named +const_name+ then we are free - # to attempt to load upwards. If they do have such a constant, then this - # const_missing must be due to from_mod::const_name, which should not - # return constants from from_mod's parents. - begin - return parent.const_missing(const_name) - rescue NameError => e - raise unless e.missing_name? qualified_name_for(parent, const_name) - raise name_error - end - else - raise name_error - end - end - - # Remove the constants that have been autoloaded, and those that have been - # marked for unloading. - def remove_unloadable_constants! - autoloaded_constants.each { |const| remove_constant const } - autoloaded_constants.clear - explicitly_unloadable_constants.each { |const| remove_constant const } - end - - # Determine if the given constant has been automatically loaded. - def autoloaded?(desc) - # No name => anonymous module. - return false if desc.is_a?(Module) && desc.name.blank? - name = to_constant_name desc - return false unless qualified_const_defined? name - return autoloaded_constants.include?(name) - end - - # Will the provided constant descriptor be unloaded? - def will_unload?(const_desc) - autoloaded?(const_desc) || - explicitly_unloadable_constants.include?(to_constant_name(const_desc)) - end - - # Mark the provided constant name for unloading. This constant will be - # unloaded on each request, not just the next one. - def mark_for_unload(const_desc) - name = to_constant_name const_desc - if explicitly_unloadable_constants.include? name - return false - else - explicitly_unloadable_constants << name - return true - end - end - - # Run the provided block and detect the new constants that were loaded during - # its execution. Constants may only be regarded as 'new' once -- so if the - # block calls +new_constants_in+ again, then the constants defined within the - # inner call will not be reported in this one. - # - # If the provided block does not run to completion, and instead raises an - # exception, any new constants are regarded as being only partially defined - # and will be removed immediately. - def new_constants_in(*descs) - log_call(*descs) - - # Build the watch frames. Each frame is a tuple of - # [module_name_as_string, constants_defined_elsewhere] - watch_frames = descs.collect do |desc| - if desc.is_a? Module - mod_name = desc.name - initial_constants = desc.local_constant_names - elsif desc.is_a?(String) || desc.is_a?(Symbol) - mod_name = desc.to_s - - # Handle the case where the module has yet to be defined. - initial_constants = if qualified_const_defined?(mod_name) - mod_name.constantize.local_constant_names - else - [] - end - else - raise Argument, "#{desc.inspect} does not describe a module!" - end - - [mod_name, initial_constants] - end - - constant_watch_stack_mutex.synchronize do - constant_watch_stack.concat watch_frames - end - - aborting = true - begin - yield # Now yield to the code that is to define new constants. - aborting = false - ensure - # Find the new constants. - new_constants = watch_frames.collect do |mod_name, prior_constants| - # Module still doesn't exist? Treat it as if it has no constants. - next [] unless qualified_const_defined?(mod_name) - - mod = mod_name.constantize - next [] unless mod.is_a? Module - new_constants = mod.local_constant_names - prior_constants - - # Make sure no other frames takes credit for these constants. - constant_watch_stack_mutex.synchronize do - constant_watch_stack.each do |frame_name, constants| - constants.concat new_constants if frame_name == mod_name - end - end - - new_constants.collect do |suffix| - mod_name == "Object" ? suffix : "#{mod_name}::#{suffix}" - end - end.flatten - - log "New constants: #{new_constants * ', '}" - - if aborting - log "Error during loading, removing partially loaded constants " - new_constants.each { |name| remove_constant name } - new_constants.clear - end - end - - return new_constants - ensure - # Remove the stack frames that we added. - if defined?(watch_frames) && ! watch_frames.blank? - frame_ids = watch_frames.collect { |frame| frame.object_id } - constant_watch_stack_mutex.synchronize do - constant_watch_stack.delete_if do |watch_frame| - frame_ids.include? watch_frame.object_id - end - end - end - end - - class LoadingModule #:nodoc: - # Old style environment.rb referenced this method directly. Please note, it doesn't - # actually *do* anything any more. - def self.root(*args) - if defined?(Rails) && Rails.logger - Rails.logger.warn "Your environment.rb uses the old syntax, it may not continue to work in future releases." - Rails.logger.warn "For upgrade instructions please see: http://manuals.rubyonrails.com/read/book/19" - end - end - end - - # Convert the provided const desc to a qualified constant name (as a string). - # A module, class, symbol, or string may be provided. - def to_constant_name(desc) #:nodoc: - name = case desc - when String then desc.starts_with?('::') ? desc[2..-1] : desc - when Symbol then desc.to_s - when Module - raise ArgumentError, "Anonymous modules have no name to be referenced by" if desc.name.blank? - desc.name - else raise TypeError, "Not a valid constant descriptor: #{desc.inspect}" - end - end - - def remove_constant(const) #:nodoc: - return false unless qualified_const_defined? const - - const = $1 if /\A::(.*)\Z/ =~ const.to_s - names = const.to_s.split('::') - if names.size == 1 # It's under Object - parent = Object - else - parent = (names[0..-2] * '::').constantize - end - - log "removing constant #{const}" - parent.instance_eval { remove_const names.last } - return true - end - - protected - def log_call(*args) - if logger && log_activity - arg_str = args.collect { |arg| arg.inspect } * ', ' - /in `([a-z_\?\!]+)'/ =~ caller(1).first - selector = $1 || '<unknown>' - log "called #{selector}(#{arg_str})" - end - end - - def log(msg) - if logger && log_activity - logger.debug "Dependencies: #{msg}" - end - end - end -end - -ActiveSupport::Dependencies.hook! diff --git a/vendor/rails/activesupport/lib/active_support/deprecation.rb b/vendor/rails/activesupport/lib/active_support/deprecation.rb deleted file mode 100644 index d201516..0000000 --- a/vendor/rails/activesupport/lib/active_support/deprecation.rb +++ /dev/null @@ -1,196 +0,0 @@ -require 'yaml' - -module ActiveSupport - module Deprecation #:nodoc: - mattr_accessor :debug - self.debug = false - - # Choose the default warn behavior according to RAILS_ENV. - # Ignore deprecation warnings in production. - DEFAULT_BEHAVIORS = { - 'test' => Proc.new { |message, callstack| - $stderr.puts(message) - $stderr.puts callstack.join("\n ") if debug - }, - 'development' => Proc.new { |message, callstack| - logger = defined?(Rails) ? Rails.logger : Logger.new($stderr) - logger.warn message - logger.debug callstack.join("\n ") if debug - } - } - - class << self - def warn(message = nil, callstack = caller) - behavior.call(deprecation_message(callstack, message), callstack) if behavior && !silenced? - end - - def default_behavior - if defined?(RAILS_ENV) - DEFAULT_BEHAVIORS[RAILS_ENV.to_s] - else - DEFAULT_BEHAVIORS['test'] - end - end - - # Have deprecations been silenced? - def silenced? - @silenced = false unless defined?(@silenced) - @silenced - end - - # Silence deprecation warnings within the block. - def silence - old_silenced, @silenced = @silenced, true - yield - ensure - @silenced = old_silenced - end - - attr_writer :silenced - - - private - def deprecation_message(callstack, message = nil) - message ||= "You are using deprecated behavior which will be removed from the next major or minor release." - "DEPRECATION WARNING: #{message}. #{deprecation_caller_message(callstack)}" - end - - def deprecation_caller_message(callstack) - file, line, method = extract_callstack(callstack) - if file - if line && method - "(called from #{method} at #{file}:#{line})" - else - "(called from #{file}:#{line})" - end - end - end - - def extract_callstack(callstack) - if md = callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/) - md.captures - else - callstack.first - end - end - end - - # Behavior is a block that takes a message argument. - mattr_accessor :behavior - self.behavior = default_behavior - - # Warnings are not silenced by default. - self.silenced = false - - module ClassMethods #:nodoc: - # Declare that a method has been deprecated. - def deprecate(*method_names) - options = method_names.extract_options! - method_names = method_names + options.keys - method_names.each do |method_name| - alias_method_chain(method_name, :deprecation) do |target, punctuation| - class_eval(<<-EOS, __FILE__, __LINE__) - def #{target}_with_deprecation#{punctuation}(*args, &block) # def generate_secret_with_deprecation(*args, &block) - ::ActiveSupport::Deprecation.warn( # ::ActiveSupport::Deprecation.warn( - self.class.deprecated_method_warning( # self.class.deprecated_method_warning( - :#{method_name}, # :generate_secret, - #{options[method_name].inspect}), # "You should use ActiveSupport::SecureRandom.hex(64)"), - caller # caller - ) # ) - #{target}_without_deprecation#{punctuation}(*args, &block) # generate_secret_without_deprecation(*args, &block) - end # end - EOS - end - end - end - - def deprecated_method_warning(method_name, message=nil) - warning = "#{method_name} is deprecated and will be removed from Rails #{deprecation_horizon}" - case message - when Symbol then "#{warning} (use #{message} instead)" - when String then "#{warning} (#{message})" - else warning - end - end - - def deprecation_horizon - '2.3' - end - end - - class DeprecationProxy #:nodoc: - silence_warnings do - instance_methods.each { |m| undef_method m unless m =~ /^__/ } - end - - # Don't give a deprecation warning on inspect since test/unit and error - # logs rely on it for diagnostics. - def inspect - target.inspect - end - - private - def method_missing(called, *args, &block) - warn caller, called, args - target.__send__(called, *args, &block) - end - end - - class DeprecatedObjectProxy < DeprecationProxy - def initialize(object, message) - @object = object - @message = message - end - - private - def target - @object - end - - def warn(callstack, called, args) - ActiveSupport::Deprecation.warn(@message, callstack) - end - end - - # Stand-in for <tt>@request</tt>, <tt>@attributes</tt>, <tt>@params</tt>, etc. - # which emits deprecation warnings on any method call (except +inspect+). - class DeprecatedInstanceVariableProxy < DeprecationProxy #:nodoc: - def initialize(instance, method, var = "@#{method}") - @instance, @method, @var = instance, method, var - end - - private - def target - @instance.__send__(@method) - end - - def warn(callstack, called, args) - ActiveSupport::Deprecation.warn("#{@var} is deprecated! Call #{@method}.#{called} instead of #{@var}.#{called}. Args: #{args.inspect}", callstack) - end - end - - class DeprecatedConstantProxy < DeprecationProxy #:nodoc: - def initialize(old_const, new_const) - @old_const = old_const - @new_const = new_const - end - - def class - target.class - end - - private - def target - @new_const.to_s.constantize - end - - def warn(callstack, called, args) - ActiveSupport::Deprecation.warn("#{@old_const} is deprecated! Use #{@new_const} instead.", callstack) - end - end - end -end - -class Module - include ActiveSupport::Deprecation::ClassMethods -end diff --git a/vendor/rails/activesupport/lib/active_support/duration.rb b/vendor/rails/activesupport/lib/active_support/duration.rb deleted file mode 100644 index f64661c..0000000 --- a/vendor/rails/activesupport/lib/active_support/duration.rb +++ /dev/null @@ -1,98 +0,0 @@ -require 'active_support/basic_object' - -module ActiveSupport - # Provides accurate date and time measurements using Date#advance and - # Time#advance, respectively. It mainly supports the methods on Numeric, - # such as in this example: - # - # 1.month.ago # equivalent to Time.now.advance(:months => -1) - class Duration < BasicObject - attr_accessor :value, :parts - - def initialize(value, parts) #:nodoc: - @value, @parts = value, parts - end - - # Adds another Duration or a Numeric to this Duration. Numeric values - # are treated as seconds. - def +(other) - if Duration === other - Duration.new(value + other.value, @parts + other.parts) - else - Duration.new(value + other, @parts + [[:seconds, other]]) - end - end - - # Subtracts another Duration or a Numeric from this Duration. Numeric - # values are treated as seconds. - def -(other) - self + (-other) - end - - def -@ #:nodoc: - Duration.new(-value, parts.map { |type,number| [type, -number] }) - end - - def is_a?(klass) #:nodoc: - klass == Duration || super - end - - # Returns true if <tt>other</tt> is also a Duration instance with the - # same <tt>value</tt>, or if <tt>other == value</tt>. - def ==(other) - if Duration === other - other.value == value - else - other == value - end - end - - def self.===(other) #:nodoc: - other.is_a?(Duration) rescue super - end - - # Calculates a new Time or Date that is as far in the future - # as this Duration represents. - def since(time = ::Time.current) - sum(1, time) - end - alias :from_now :since - - # Calculates a new Time or Date that is as far in the past - # as this Duration represents. - def ago(time = ::Time.current) - sum(-1, time) - end - alias :until :ago - - def inspect #:nodoc: - consolidated = parts.inject(::Hash.new(0)) { |h,part| h[part.first] += part.last; h } - [:years, :months, :days, :minutes, :seconds].map do |length| - n = consolidated[length] - "#{n} #{n == 1 ? length.to_s.singularize : length.to_s}" if n.nonzero? - end.compact.to_sentence(:locale => :en) - end - - protected - - def sum(sign, time = ::Time.current) #:nodoc: - parts.inject(time) do |t,(type,number)| - if t.acts_like?(:time) || t.acts_like?(:date) - if type == :seconds - t.since(sign * number) - else - t.advance(type => sign * number) - end - else - raise ::ArgumentError, "expected a time or date, got #{time.inspect}" - end - end - end - - private - - def method_missing(method, *args, &block) #:nodoc: - value.send(method, *args) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/gzip.rb b/vendor/rails/activesupport/lib/active_support/gzip.rb deleted file mode 100644 index 35a50e9..0000000 --- a/vendor/rails/activesupport/lib/active_support/gzip.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'zlib' -require 'stringio' - -module ActiveSupport - # A convenient wrapper for the zlib standard library that allows compression/decompression of strings with gzip. - module Gzip - class Stream < StringIO - def close; rewind; end - end - - # Decompresses a gzipped string. - def self.decompress(source) - Zlib::GzipReader.new(StringIO.new(source)).read - end - - # Compresses a string using gzip. - def self.compress(source) - output = Stream.new - gz = Zlib::GzipWriter.new(output) - gz.write(source) - gz.close - output.string - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/inflections.rb b/vendor/rails/activesupport/lib/active_support/inflections.rb deleted file mode 100644 index 8fb3fa9..0000000 --- a/vendor/rails/activesupport/lib/active_support/inflections.rb +++ /dev/null @@ -1,56 +0,0 @@ -module ActiveSupport - Inflector.inflections do |inflect| - inflect.plural(/$/, 's') - inflect.plural(/s$/i, 's') - inflect.plural(/(ax|test)is$/i, '\1es') - inflect.plural(/(octop|vir)us$/i, '\1i') - inflect.plural(/(alias|status)$/i, '\1es') - inflect.plural(/(bu)s$/i, '\1ses') - inflect.plural(/(buffal|tomat)o$/i, '\1oes') - inflect.plural(/([ti])um$/i, '\1a') - inflect.plural(/sis$/i, 'ses') - inflect.plural(/(?:([^f])fe|([lr])f)$/i, '\1\2ves') - inflect.plural(/(hive)$/i, '\1s') - inflect.plural(/([^aeiouy]|qu)y$/i, '\1ies') - inflect.plural(/(x|ch|ss|sh)$/i, '\1es') - inflect.plural(/(matr|vert|ind)(?:ix|ex)$/i, '\1ices') - inflect.plural(/([m|l])ouse$/i, '\1ice') - inflect.plural(/^(ox)$/i, '\1en') - inflect.plural(/(quiz)$/i, '\1zes') - - inflect.singular(/s$/i, '') - inflect.singular(/(n)ews$/i, '\1ews') - inflect.singular(/([ti])a$/i, '\1um') - inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i, '\1\2sis') - inflect.singular(/(^analy)ses$/i, '\1sis') - inflect.singular(/([^f])ves$/i, '\1fe') - inflect.singular(/(hive)s$/i, '\1') - inflect.singular(/(tive)s$/i, '\1') - inflect.singular(/([lr])ves$/i, '\1f') - inflect.singular(/([^aeiouy]|qu)ies$/i, '\1y') - inflect.singular(/(s)eries$/i, '\1eries') - inflect.singular(/(m)ovies$/i, '\1ovie') - inflect.singular(/(x|ch|ss|sh)es$/i, '\1') - inflect.singular(/([m|l])ice$/i, '\1ouse') - inflect.singular(/(bus)es$/i, '\1') - inflect.singular(/(o)es$/i, '\1') - inflect.singular(/(shoe)s$/i, '\1') - inflect.singular(/(cris|ax|test)es$/i, '\1is') - inflect.singular(/(octop|vir)i$/i, '\1us') - inflect.singular(/(alias|status)es$/i, '\1') - inflect.singular(/^(ox)en/i, '\1') - inflect.singular(/(vert|ind)ices$/i, '\1ex') - inflect.singular(/(matr)ices$/i, '\1ix') - inflect.singular(/(quiz)zes$/i, '\1') - inflect.singular(/(database)s$/i, '\1') - - inflect.irregular('person', 'people') - inflect.irregular('man', 'men') - inflect.irregular('child', 'children') - inflect.irregular('sex', 'sexes') - inflect.irregular('move', 'moves') - inflect.irregular('cow', 'kine') - - inflect.uncountable(%w(equipment information rice money species series fish sheep)) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/inflector.rb b/vendor/rails/activesupport/lib/active_support/inflector.rb deleted file mode 100644 index 3ed30bd..0000000 --- a/vendor/rails/activesupport/lib/active_support/inflector.rb +++ /dev/null @@ -1,406 +0,0 @@ -# encoding: utf-8 -require 'singleton' -require 'iconv' - -module ActiveSupport - # The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without, - # and class names to foreign keys. The default inflections for pluralization, singularization, and uncountable words are kept - # in inflections.rb. - # - # The Rails core team has stated patches for the inflections library will not be accepted - # in order to avoid breaking legacy applications which may be relying on errant inflections. - # If you discover an incorrect inflection and require it for your application, you'll need - # to correct it yourself (explained below). - module Inflector - extend self - - # A singleton instance of this class is yielded by Inflector.inflections, which can then be used to specify additional - # inflection rules. Examples: - # - # ActiveSupport::Inflector.inflections do |inflect| - # inflect.plural /^(ox)$/i, '\1\2en' - # inflect.singular /^(ox)en/i, '\1' - # - # inflect.irregular 'octopus', 'octopi' - # - # inflect.uncountable "equipment" - # end - # - # New rules are added at the top. So in the example above, the irregular rule for octopus will now be the first of the - # pluralization and singularization rules that is runs. This guarantees that your rules run before any of the rules that may - # already have been loaded. - class Inflections - include Singleton - - attr_reader :plurals, :singulars, :uncountables, :humans - - def initialize - @plurals, @singulars, @uncountables, @humans = [], [], [], [] - end - - # Specifies a new pluralization rule and its replacement. The rule can either be a string or a regular expression. - # The replacement should always be a string that may include references to the matched data from the rule. - def plural(rule, replacement) - @uncountables.delete(rule) if rule.is_a?(String) - @uncountables.delete(replacement) - @plurals.insert(0, [rule, replacement]) - end - - # Specifies a new singularization rule and its replacement. The rule can either be a string or a regular expression. - # The replacement should always be a string that may include references to the matched data from the rule. - def singular(rule, replacement) - @uncountables.delete(rule) if rule.is_a?(String) - @uncountables.delete(replacement) - @singulars.insert(0, [rule, replacement]) - end - - # Specifies a new irregular that applies to both pluralization and singularization at the same time. This can only be used - # for strings, not regular expressions. You simply pass the irregular in singular and plural form. - # - # Examples: - # irregular 'octopus', 'octopi' - # irregular 'person', 'people' - def irregular(singular, plural) - @uncountables.delete(singular) - @uncountables.delete(plural) - if singular[0,1].upcase == plural[0,1].upcase - plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + plural[1..-1]) - singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + singular[1..-1]) - else - plural(Regexp.new("#{singular[0,1].upcase}(?i)#{singular[1..-1]}$"), plural[0,1].upcase + plural[1..-1]) - plural(Regexp.new("#{singular[0,1].downcase}(?i)#{singular[1..-1]}$"), plural[0,1].downcase + plural[1..-1]) - singular(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), singular[0,1].upcase + singular[1..-1]) - singular(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), singular[0,1].downcase + singular[1..-1]) - end - end - - # Add uncountable words that shouldn't be attempted inflected. - # - # Examples: - # uncountable "money" - # uncountable "money", "information" - # uncountable %w( money information rice ) - def uncountable(*words) - (@uncountables << words).flatten! - end - - # Specifies a humanized form of a string by a regular expression rule or by a string mapping. - # When using a regular expression based replacement, the normal humanize formatting is called after the replacement. - # When a string is used, the human form should be specified as desired (example: 'The name', not 'the_name') - # - # Examples: - # human /_cnt$/i, '\1_count' - # human "legacy_col_person_name", "Name" - def human(rule, replacement) - @humans.insert(0, [rule, replacement]) - end - - # Clears the loaded inflections within a given scope (default is <tt>:all</tt>). - # Give the scope as a symbol of the inflection type, the options are: <tt>:plurals</tt>, - # <tt>:singulars</tt>, <tt>:uncountables</tt>, <tt>:humans</tt>. - # - # Examples: - # clear :all - # clear :plurals - def clear(scope = :all) - case scope - when :all - @plurals, @singulars, @uncountables = [], [], [] - else - instance_variable_set "@#{scope}", [] - end - end - end - - # Yields a singleton instance of Inflector::Inflections so you can specify additional - # inflector rules. - # - # Example: - # ActiveSupport::Inflector.inflections do |inflect| - # inflect.uncountable "rails" - # end - def inflections - if block_given? - yield Inflections.instance - else - Inflections.instance - end - end - - # Returns the plural form of the word in the string. - # - # Examples: - # "post".pluralize # => "posts" - # "octopus".pluralize # => "octopi" - # "sheep".pluralize # => "sheep" - # "words".pluralize # => "words" - # "CamelOctopus".pluralize # => "CamelOctopi" - def pluralize(word) - result = word.to_s.dup - - if word.empty? || inflections.uncountables.include?(result.downcase) - result - else - inflections.plurals.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } - result - end - end - - # The reverse of +pluralize+, returns the singular form of a word in a string. - # - # Examples: - # "posts".singularize # => "post" - # "octopi".singularize # => "octopus" - # "sheep".singluarize # => "sheep" - # "word".singularize # => "word" - # "CamelOctopi".singularize # => "CamelOctopus" - def singularize(word) - result = word.to_s.dup - - if inflections.uncountables.include?(result.downcase) - result - else - inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } - result - end - end - - # By default, +camelize+ converts strings to UpperCamelCase. If the argument to +camelize+ - # is set to <tt>:lower</tt> then +camelize+ produces lowerCamelCase. - # - # +camelize+ will also convert '/' to '::' which is useful for converting paths to namespaces. - # - # Examples: - # "active_record".camelize # => "ActiveRecord" - # "active_record".camelize(:lower) # => "activeRecord" - # "active_record/errors".camelize # => "ActiveRecord::Errors" - # "active_record/errors".camelize(:lower) # => "activeRecord::Errors" - def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) - if first_letter_in_uppercase - lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } - else - lower_case_and_underscored_word.first.downcase + camelize(lower_case_and_underscored_word)[1..-1] - end - end - - # Capitalizes all the words and replaces some characters in the string to create - # a nicer looking title. +titleize+ is meant for creating pretty output. It is not - # used in the Rails internals. - # - # +titleize+ is also aliased as as +titlecase+. - # - # Examples: - # "man from the boondocks".titleize # => "Man From The Boondocks" - # "x-men: the last stand".titleize # => "X Men: The Last Stand" - def titleize(word) - humanize(underscore(word)).gsub(/\b('?[a-z])/) { $1.capitalize } - end - - # The reverse of +camelize+. Makes an underscored, lowercase form from the expression in the string. - # - # Changes '::' to '/' to convert namespaces to paths. - # - # Examples: - # "ActiveRecord".underscore # => "active_record" - # "ActiveRecord::Errors".underscore # => active_record/errors - def underscore(camel_cased_word) - camel_cased_word.to_s.gsub(/::/, '/'). - gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). - gsub(/([a-z\d])([A-Z])/,'\1_\2'). - tr("-", "_"). - downcase - end - - # Replaces underscores with dashes in the string. - # - # Example: - # "puni_puni" # => "puni-puni" - def dasherize(underscored_word) - underscored_word.gsub(/_/, '-') - end - - # Capitalizes the first word and turns underscores into spaces and strips a - # trailing "_id", if any. Like +titleize+, this is meant for creating pretty output. - # - # Examples: - # "employee_salary" # => "Employee salary" - # "author_id" # => "Author" - def humanize(lower_case_and_underscored_word) - result = lower_case_and_underscored_word.to_s.dup - - inflections.humans.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } - result.gsub(/_id$/, "").gsub(/_/, " ").capitalize - end - - # Removes the module part from the expression in the string. - # - # Examples: - # "ActiveRecord::CoreExtensions::String::Inflections".demodulize # => "Inflections" - # "Inflections".demodulize # => "Inflections" - def demodulize(class_name_in_module) - class_name_in_module.to_s.gsub(/^.*::/, '') - end - - # Replaces special characters in a string so that it may be used as part of a 'pretty' URL. - # - # ==== Examples - # - # class Person - # def to_param - # "#{id}-#{name.parameterize}" - # end - # end - # - # @person = Person.find(1) - # # => #<Person id: 1, name: "Donald E. Knuth"> - # - # <%= link_to(@person.name, person_path(@person)) %> - # # => <a href="/person/1-donald-e-knuth">Donald E. Knuth</a> - def parameterize(string, sep = '-') - # replace accented chars with ther ascii equivalents - parameterized_string = transliterate(string) - # Turn unwanted chars into the seperator - parameterized_string.gsub!(/[^a-z0-9\-_\+]+/i, sep) - unless sep.blank? - re_sep = Regexp.escape(sep) - # No more than one of the separator in a row. - parameterized_string.gsub!(/#{re_sep}{2,}/, sep) - # Remove leading/trailing separator. - parameterized_string.gsub!(/^#{re_sep}|#{re_sep}$/i, '') - end - parameterized_string.downcase - end - - - # Replaces accented characters with their ascii equivalents. - def transliterate(string) - Iconv.iconv('ascii//ignore//translit', 'utf-8', string).to_s - end - - if RUBY_VERSION >= '1.9' - undef_method :transliterate - def transliterate(string) - warn "Ruby 1.9 doesn't support Unicode normalization yet" - string.dup - end - - # The iconv transliteration code doesn't function correctly - # on some platforms, but it's very fast where it does function. - elsif "foo" != (Inflector.transliterate("föö") rescue nil) - undef_method :transliterate - def transliterate(string) - string.mb_chars.normalize(:kd). # Decompose accented characters - gsub(/[^\x00-\x7F]+/, '') # Remove anything non-ASCII entirely (e.g. diacritics). - end - end - - # Create the name of a table like Rails does for models to table names. This method - # uses the +pluralize+ method on the last word in the string. - # - # Examples - # "RawScaledScorer".tableize # => "raw_scaled_scorers" - # "egg_and_ham".tableize # => "egg_and_hams" - # "fancyCategory".tableize # => "fancy_categories" - def tableize(class_name) - pluralize(underscore(class_name)) - end - - # Create a class name from a plural table name like Rails does for table names to models. - # Note that this returns a string and not a Class. (To convert to an actual class - # follow +classify+ with +constantize+.) - # - # Examples: - # "egg_and_hams".classify # => "EggAndHam" - # "posts".classify # => "Post" - # - # Singular names are not handled correctly: - # "business".classify # => "Busines" - def classify(table_name) - # strip out any leading schema name - camelize(singularize(table_name.to_s.sub(/.*\./, ''))) - end - - # Creates a foreign key name from a class name. - # +separate_class_name_and_id_with_underscore+ sets whether - # the method should put '_' between the name and 'id'. - # - # Examples: - # "Message".foreign_key # => "message_id" - # "Message".foreign_key(false) # => "messageid" - # "Admin::Post".foreign_key # => "post_id" - def foreign_key(class_name, separate_class_name_and_id_with_underscore = true) - underscore(demodulize(class_name)) + (separate_class_name_and_id_with_underscore ? "_id" : "id") - end - - # Ruby 1.9 introduces an inherit argument for Module#const_get and - # #const_defined? and changes their default behavior. - if Module.method(:const_get).arity == 1 - # Tries to find a constant with the name specified in the argument string: - # - # "Module".constantize # => Module - # "Test::Unit".constantize # => Test::Unit - # - # The name is assumed to be the one of a top-level constant, no matter whether - # it starts with "::" or not. No lexical context is taken into account: - # - # C = 'outside' - # module M - # C = 'inside' - # C # => 'inside' - # "C".constantize # => 'outside', same as ::C - # end - # - # NameError is raised when the name is not in CamelCase or the constant is - # unknown. - def constantize(camel_cased_word) - names = camel_cased_word.split('::') - names.shift if names.empty? || names.first.empty? - - constant = Object - names.each do |name| - constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) - end - constant - end - else - def constantize(camel_cased_word) #:nodoc: - names = camel_cased_word.split('::') - names.shift if names.empty? || names.first.empty? - - constant = Object - names.each do |name| - constant = constant.const_get(name, false) || constant.const_missing(name) - end - constant - end - end - - # Turns a number into an ordinal string used to denote the position in an - # ordered sequence such as 1st, 2nd, 3rd, 4th. - # - # Examples: - # ordinalize(1) # => "1st" - # ordinalize(2) # => "2nd" - # ordinalize(1002) # => "1002nd" - # ordinalize(1003) # => "1003rd" - def ordinalize(number) - if (11..13).include?(number.to_i % 100) - "#{number}th" - else - case number.to_i % 10 - when 1; "#{number}st" - when 2; "#{number}nd" - when 3; "#{number}rd" - else "#{number}th" - end - end - end - end -end - -# in case active_support/inflector is required without the rest of active_support -require 'active_support/inflections' -require 'active_support/core_ext/string/inflections' -unless String.included_modules.include?(ActiveSupport::CoreExtensions::String::Inflections) - String.send :include, ActiveSupport::CoreExtensions::String::Inflections -end diff --git a/vendor/rails/activesupport/lib/active_support/json.rb b/vendor/rails/activesupport/lib/active_support/json.rb deleted file mode 100644 index 2bdb4a7..0000000 --- a/vendor/rails/activesupport/lib/active_support/json.rb +++ /dev/null @@ -1,23 +0,0 @@ -module ActiveSupport - # If true, use ISO 8601 format for dates and times. Otherwise, fall back to the Active Support legacy format. - mattr_accessor :use_standard_json_time_format - - class << self - def escape_html_entities_in_json - @escape_html_entities_in_json - end - - def escape_html_entities_in_json=(value) - ActiveSupport::JSON::Encoding.escape_regex = \ - if value - /[\010\f\n\r\t"\\><&]/ - else - /[\010\f\n\r\t"\\]/ - end - @escape_html_entities_in_json = value - end - end -end - -require 'active_support/json/encoding' -require 'active_support/json/decoding' diff --git a/vendor/rails/activesupport/lib/active_support/json/decoding.rb b/vendor/rails/activesupport/lib/active_support/json/decoding.rb deleted file mode 100644 index 0e07934..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/decoding.rb +++ /dev/null @@ -1,82 +0,0 @@ -require 'yaml' -require 'strscan' - -module ActiveSupport - module JSON - class ParseError < StandardError - end - - class << self - # Converts a JSON string into a Ruby object. - def decode(json) - YAML.load(convert_json_to_yaml(json)) - rescue ArgumentError => e - raise ParseError, "Invalid JSON string" - end - - protected - # matches YAML-formatted dates - DATE_REGEX = /^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[ \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?)?)$/ - - # Ensure that ":" and "," are always followed by a space - def convert_json_to_yaml(json) #:nodoc: - scanner, quoting, marks, pos, times = StringScanner.new(json), false, [], nil, [] - while scanner.scan_until(/(\\['"]|['":,\\]|\\.)/) - case char = scanner[1] - when '"', "'" - if !quoting - quoting = char - pos = scanner.pos - elsif quoting == char - if json[pos..scanner.pos-2] =~ DATE_REGEX - # found a date, track the exact positions of the quotes so we can remove them later. - # oh, and increment them for each current mark, each one is an extra padded space that bumps - # the position in the final YAML output - total_marks = marks.size - times << pos+total_marks << scanner.pos+total_marks - end - quoting = false - end - when ":","," - marks << scanner.pos - 1 unless quoting - end - end - - if marks.empty? - json.gsub(/\\([\\\/]|u[[:xdigit:]]{4})/) do - ustr = $1 - if ustr.starts_with?('u') - [ustr[1..-1].to_i(16)].pack("U") - elsif ustr == '\\' - '\\\\' - else - ustr - end - end - else - left_pos = [-1].push(*marks) - right_pos = marks << scanner.pos + scanner.rest_size - output = [] - left_pos.each_with_index do |left, i| - scanner.pos = left.succ - output << scanner.peek(right_pos[i] - scanner.pos + 1).gsub(/\\([\\\/]|u[[:xdigit:]]{4})/) do - ustr = $1 - if ustr.starts_with?('u') - [ustr[1..-1].to_i(16)].pack("U") - elsif ustr == '\\' - '\\\\' - else - ustr - end - end - end - output = output * " " - - times.each { |i| output[i-1] = ' ' } - output.gsub!(/\\\//, '/') - output - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/date.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/date.rb deleted file mode 100644 index cc84de1..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/date.rb +++ /dev/null @@ -1,21 +0,0 @@ -class Date - # Returns a JSON string representing the date. If ActiveSupport.use_standard_json_time_format is set to true, the - # ISO 8601 format is used. - # - # ==== Examples - # - # # With ActiveSupport.use_standard_json_time_format = true - # Date.new(2005,2,1).to_json - # # => "2005-02-01" - # - # # With ActiveSupport.use_standard_json_time_format = false - # Date.new(2005,2,1).to_json - # # => "2005/02/01" - def to_json(options = nil) - if ActiveSupport.use_standard_json_time_format - %("#{strftime("%Y-%m-%d")}") - else - %("#{strftime("%Y/%m/%d")}") - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/date_time.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/date_time.rb deleted file mode 100644 index 6c85824..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/date_time.rb +++ /dev/null @@ -1,21 +0,0 @@ -class DateTime - # Returns a JSON string representing the datetime. If ActiveSupport.use_standard_json_time_format is set to true, the - # ISO 8601 format is used. - # - # ==== Examples - # - # # With ActiveSupport.use_standard_json_time_format = true - # DateTime.civil(2005,2,1,15,15,10).to_json - # # => "2005-02-01T15:15:10+00:00" - # - # # With ActiveSupport.use_standard_json_time_format = false - # DateTime.civil(2005,2,1,15,15,10).to_json - # # => "2005/02/01 15:15:10 +0000" - def to_json(options = nil) - if ActiveSupport.use_standard_json_time_format - xmlschema.inspect - else - strftime('"%Y/%m/%d %H:%M:%S %z"') - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb deleted file mode 100644 index 881b1d6..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Enumerable - # Returns a JSON string representing the enumerable. Any +options+ - # given will be passed on to its elements. For example: - # - # users = User.find(:all) - # # => users.to_json(:only => :name) - # - # will pass the <tt>:only => :name</tt> option to each user. - def to_json(options = {}) #:nodoc: - "[#{map { |value| ActiveSupport::JSON.encode(value, options) } * ', '}]" - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/false_class.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/false_class.rb deleted file mode 100644 index bf08443..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/false_class.rb +++ /dev/null @@ -1,5 +0,0 @@ -class FalseClass - def to_json(options = nil) #:nodoc: - 'false' - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/hash.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/hash.rb deleted file mode 100644 index e38b4f3..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/hash.rb +++ /dev/null @@ -1,46 +0,0 @@ -class Hash - # Returns a JSON string representing the hash. - # - # Without any +options+, the returned JSON string will include all - # the hash keys. For example: - # - # { :name => "Konata Izumi", 'age' => 16, 1 => 2 }.to_json - # # => {"name": "Konata Izumi", "1": 2, "age": 16} - # - # The keys in the JSON string are unordered due to the nature of hashes. - # - # The <tt>:only</tt> and <tt>:except</tt> options can be used to limit the - # attributes included, and will accept 1 or more hash keys to include/exclude. - # - # { :name => "Konata Izumi", 'age' => 16, 1 => 2 }.to_json(:only => [:name, 'age']) - # # => {"name": "Konata Izumi", "age": 16} - # - # { :name => "Konata Izumi", 'age' => 16, 1 => 2 }.to_json(:except => 1) - # # => {"name": "Konata Izumi", "age": 16} - # - # The +options+ also filter down to any hash values. This is particularly - # useful for converting hashes containing ActiveRecord objects or any object - # that responds to options in their <tt>to_json</tt> method. For example: - # - # users = User.find(:all) - # { :users => users, :count => users.size }.to_json(:include => :posts) - # - # would pass the <tt>:include => :posts</tt> option to <tt>users</tt>, - # allowing the posts association in the User model to be converted to JSON - # as well. - def to_json(options = {}) #:nodoc: - hash_keys = self.keys - - if except = options[:except] - hash_keys = hash_keys - Array.wrap(except) - elsif only = options[:only] - hash_keys = hash_keys & Array.wrap(only) - end - - result = '{' - result << hash_keys.map do |key| - "#{ActiveSupport::JSON.encode(key.to_s)}: #{ActiveSupport::JSON.encode(self[key], options)}" - end * ', ' - result << '}' - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/nil_class.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/nil_class.rb deleted file mode 100644 index 4763471..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/nil_class.rb +++ /dev/null @@ -1,5 +0,0 @@ -class NilClass - def to_json(options = nil) #:nodoc: - 'null' - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/numeric.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/numeric.rb deleted file mode 100644 index 38713fb..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/numeric.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Numeric - def to_json(options = nil) #:nodoc: - to_s - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/object.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/object.rb deleted file mode 100644 index ca215d4..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/object.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Object - # Dumps object in JSON (JavaScript Object Notation). See www.json.org for more info. - def to_json(options = {}) - ActiveSupport::JSON.encode(instance_values, options) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/regexp.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/regexp.rb deleted file mode 100644 index b6116b7..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/regexp.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Regexp - def to_json(options = nil) #:nodoc: - inspect - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/string.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/string.rb deleted file mode 100644 index 5ef7979..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/string.rb +++ /dev/null @@ -1,36 +0,0 @@ -module ActiveSupport - module JSON - module Encoding - mattr_accessor :escape_regex - - ESCAPED_CHARS = { - "\010" => '\b', - "\f" => '\f', - "\n" => '\n', - "\r" => '\r', - "\t" => '\t', - '"' => '\"', - '\\' => '\\\\', - '>' => '\u003E', - '<' => '\u003C', - '&' => '\u0026' - } - end - end -end - -ActiveSupport.escape_html_entities_in_json = true - -class String - def to_json(options = nil) #:nodoc: - json = '"' + gsub(ActiveSupport::JSON::Encoding.escape_regex) { |s| - ActiveSupport::JSON::Encoding::ESCAPED_CHARS[s] - } - json.force_encoding('ascii-8bit') if respond_to?(:force_encoding) - json.gsub(/([\xC0-\xDF][\x80-\xBF]| - [\xE0-\xEF][\x80-\xBF]{2}| - [\xF0-\xF7][\x80-\xBF]{3})+/nx) { |s| - s.unpack("U*").pack("n*").unpack("H*")[0].gsub(/.{4}/, '\\\\u\&') - } + '"' - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/symbol.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/symbol.rb deleted file mode 100644 index 485112f..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/symbol.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Symbol - def to_json(options = {}) #:nodoc: - ActiveSupport::JSON.encode(to_s, options) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/time.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/time.rb deleted file mode 100644 index f45a005..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/time.rb +++ /dev/null @@ -1,21 +0,0 @@ -class Time - # Returns a JSON string representing the time. If ActiveSupport.use_standard_json_time_format is set to true, the - # ISO 8601 format is used. - # - # ==== Examples - # - # # With ActiveSupport.use_standard_json_time_format = true - # Time.utc(2005,2,1,15,15,10).to_json - # # => "2005-02-01T15:15:10Z" - # - # # With ActiveSupport.use_standard_json_time_format = false - # Time.utc(2005,2,1,15,15,10).to_json - # # => "2005/02/01 15:15:10 +0000" - def to_json(options = nil) - if ActiveSupport.use_standard_json_time_format - xmlschema.inspect - else - %("#{strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}") - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoders/true_class.rb b/vendor/rails/activesupport/lib/active_support/json/encoders/true_class.rb deleted file mode 100644 index 037d812..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoders/true_class.rb +++ /dev/null @@ -1,5 +0,0 @@ -class TrueClass - def to_json(options = nil) #:nodoc: - 'true' - end -end diff --git a/vendor/rails/activesupport/lib/active_support/json/encoding.rb b/vendor/rails/activesupport/lib/active_support/json/encoding.rb deleted file mode 100644 index aaaa3cd..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/encoding.rb +++ /dev/null @@ -1,31 +0,0 @@ -module ActiveSupport - module JSON - class CircularReferenceError < StandardError - end - - # Converts a Ruby object into a JSON string. - def self.encode(value, options = {}) - seen = (options[:seen] ||= []) - raise CircularReferenceError, 'object references itself' if seen.include?(value) - seen << value - value.send(:to_json, options) - ensure - seen.pop - end - end -end - -require 'active_support/json/variable' -require 'active_support/json/encoders/date' -require 'active_support/json/encoders/date_time' -require 'active_support/json/encoders/enumerable' -require 'active_support/json/encoders/false_class' -require 'active_support/json/encoders/hash' -require 'active_support/json/encoders/nil_class' -require 'active_support/json/encoders/numeric' -require 'active_support/json/encoders/object' -require 'active_support/json/encoders/regexp' -require 'active_support/json/encoders/string' -require 'active_support/json/encoders/symbol' -require 'active_support/json/encoders/time' -require 'active_support/json/encoders/true_class' diff --git a/vendor/rails/activesupport/lib/active_support/json/variable.rb b/vendor/rails/activesupport/lib/active_support/json/variable.rb deleted file mode 100644 index 7fd23b0..0000000 --- a/vendor/rails/activesupport/lib/active_support/json/variable.rb +++ /dev/null @@ -1,10 +0,0 @@ -module ActiveSupport - module JSON - # A string that returns itself as its JSON-encoded form. - class Variable < String - def to_json(options=nil) - self - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/locale/en.yml b/vendor/rails/activesupport/lib/active_support/locale/en.yml deleted file mode 100644 index e604c9e..0000000 --- a/vendor/rails/activesupport/lib/active_support/locale/en.yml +++ /dev/null @@ -1,33 +0,0 @@ -en: - date: - formats: - # Use the strftime parameters for formats. - # When no format has been given, it uses default. - # You can provide other formats here if you like! - default: "%Y-%m-%d" - short: "%b %d" - long: "%B %d, %Y" - - day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday] - abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat] - - # Don't forget the nil at the beginning; there's no such thing as a 0th month - month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December] - abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec] - # Used in date_select and datime_select. - order: [ :year, :month, :day ] - - time: - formats: - default: "%a, %d %b %Y %H:%M:%S %z" - short: "%d %b %H:%M" - long: "%B %d, %Y %H:%M" - am: "am" - pm: "pm" - -# Used in array.to_sentence. - support: - array: - words_connector: ", " - two_words_connector: " and " - last_word_connector: ", and " diff --git a/vendor/rails/activesupport/lib/active_support/memoizable.rb b/vendor/rails/activesupport/lib/active_support/memoizable.rb deleted file mode 100644 index 71cfe61..0000000 --- a/vendor/rails/activesupport/lib/active_support/memoizable.rb +++ /dev/null @@ -1,100 +0,0 @@ -module ActiveSupport - module Memoizable - def self.memoized_ivar_for(symbol) - "@_memoized_#{symbol.to_s.sub(/\?\Z/, '_query').sub(/!\Z/, '_bang')}".to_sym - end - - module InstanceMethods - def self.included(base) - base.class_eval do - unless base.method_defined?(:freeze_without_memoizable) - alias_method_chain :freeze, :memoizable - end - end - end - - def freeze_with_memoizable - memoize_all unless frozen? - freeze_without_memoizable - end - - def memoize_all - prime_cache ".*" - end - - def unmemoize_all - flush_cache ".*" - end - - def prime_cache(*syms) - syms.each do |sym| - methods.each do |m| - if m.to_s =~ /^_unmemoized_(#{sym})/ - if method(m).arity == 0 - __send__($1) - else - ivar = ActiveSupport::Memoizable.memoized_ivar_for($1) - instance_variable_set(ivar, {}) - end - end - end - end - end - - def flush_cache(*syms, &block) - syms.each do |sym| - methods.each do |m| - if m.to_s =~ /^_unmemoized_(#{sym})/ - ivar = ActiveSupport::Memoizable.memoized_ivar_for($1) - instance_variable_get(ivar).clear if instance_variable_defined?(ivar) - end - end - end - end - end - - def memoize(*symbols) - symbols.each do |symbol| - original_method = :"_unmemoized_#{symbol}" - memoized_ivar = ActiveSupport::Memoizable.memoized_ivar_for(symbol) - - class_eval <<-EOS, __FILE__, __LINE__ - include InstanceMethods # include InstanceMethods - # - if method_defined?(:#{original_method}) # if method_defined?(:_unmemoized_mime_type) - raise "Already memoized #{symbol}" # raise "Already memoized mime_type" - end # end - alias #{original_method} #{symbol} # alias _unmemoized_mime_type mime_type - # - if instance_method(:#{symbol}).arity == 0 # if instance_method(:mime_type).arity == 0 - def #{symbol}(reload = false) # def mime_type(reload = false) - if reload || !defined?(#{memoized_ivar}) || #{memoized_ivar}.empty? # if reload || !defined?(@_memoized_mime_type) || @_memoized_mime_type.empty? - #{memoized_ivar} = [#{original_method}.freeze] # @_memoized_mime_type = [_unmemoized_mime_type.freeze] - end # end - #{memoized_ivar}[0] # @_memoized_mime_type[0] - end # end - else # else - def #{symbol}(*args) # def mime_type(*args) - #{memoized_ivar} ||= {} unless frozen? # @_memoized_mime_type ||= {} unless frozen? - reload = args.pop if args.last == true || args.last == :reload # reload = args.pop if args.last == true || args.last == :reload - # - if defined?(#{memoized_ivar}) && #{memoized_ivar} # if defined?(@_memoized_mime_type) && @_memoized_mime_type - if !reload && #{memoized_ivar}.has_key?(args) # if !reload && @_memoized_mime_type.has_key?(args) - #{memoized_ivar}[args] # @_memoized_mime_type[args] - elsif #{memoized_ivar} # elsif @_memoized_mime_type - #{memoized_ivar}[args] = #{original_method}(*args).freeze # @_memoized_mime_type[args] = _unmemoized_mime_type(*args).freeze - end # end - else # else - #{original_method}(*args) # _unmemoized_mime_type(*args) - end # end - end # end - end # end - # - if private_method_defined?(#{original_method.inspect}) # if private_method_defined?(:_unmemoized_mime_type) - private #{symbol.inspect} # private :mime_type - end # end - EOS - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/message_encryptor.rb b/vendor/rails/activesupport/lib/active_support/message_encryptor.rb deleted file mode 100644 index 347af9d..0000000 --- a/vendor/rails/activesupport/lib/active_support/message_encryptor.rb +++ /dev/null @@ -1,70 +0,0 @@ -require 'openssl' - -module ActiveSupport - # MessageEncryptor is a simple way to encrypt values which get stored somewhere - # you don't trust. - # - # The cipher text and initialization vector are base64 encoded and returned to you. - # - # This can be used in situations similar to the MessageVerifier, but where you don't - # want users to be able to determine the value of the payload. - class MessageEncryptor - class InvalidMessage < StandardError; end - OpenSSLCipherError = OpenSSL::Cipher.const_defined?(:CipherError) ? OpenSSL::Cipher::CipherError : OpenSSL::CipherError - - def initialize(secret, cipher = 'aes-256-cbc') - @secret = secret - @cipher = cipher - end - - def encrypt(value) - cipher = new_cipher - # Rely on OpenSSL for the initialization vector - iv = cipher.random_iv - - cipher.encrypt - cipher.key = @secret - cipher.iv = iv - - encrypted_data = cipher.update(Marshal.dump(value)) - encrypted_data << cipher.final - - [encrypted_data, iv].map {|v| ActiveSupport::Base64.encode64s(v)}.join("--") - end - - def decrypt(encrypted_message) - cipher = new_cipher - encrypted_data, iv = encrypted_message.split("--").map {|v| ActiveSupport::Base64.decode64(v)} - - cipher.decrypt - cipher.key = @secret - cipher.iv = iv - - decrypted_data = cipher.update(encrypted_data) - decrypted_data << cipher.final - - Marshal.load(decrypted_data) - rescue OpenSSLCipherError, TypeError - raise InvalidMessage - end - - def encrypt_and_sign(value) - verifier.generate(encrypt(value)) - end - - def decrypt_and_verify(value) - decrypt(verifier.verify(value)) - end - - - - private - def new_cipher - OpenSSL::Cipher::Cipher.new(@cipher) - end - - def verifier - MessageVerifier.new(@secret) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/message_verifier.rb b/vendor/rails/activesupport/lib/active_support/message_verifier.rb deleted file mode 100644 index b24acb9..0000000 --- a/vendor/rails/activesupport/lib/active_support/message_verifier.rb +++ /dev/null @@ -1,46 +0,0 @@ -module ActiveSupport - # MessageVerifier makes it easy to generate and verify messages which are signed - # to prevent tampering. - # - # This is useful for cases like remember-me tokens and auto-unsubscribe links where the - # session store isn't suitable or available. - # - # Remember Me: - # cookies[:remember_me] = @verifier.generate([@user.id, 2.weeks.from_now]) - # - # In the authentication filter: - # - # id, time = @verifier.verify(cookies[:remember_me]) - # if time < Time.now - # self.current_user = User.find(id) - # end - # - class MessageVerifier - class InvalidSignature < StandardError; end - - def initialize(secret, digest = 'SHA1') - @secret = secret - @digest = digest - end - - def verify(signed_message) - data, digest = signed_message.split("--") - if digest != generate_digest(data) - raise InvalidSignature - else - Marshal.load(ActiveSupport::Base64.decode64(data)) - end - end - - def generate(value) - data = ActiveSupport::Base64.encode64s(Marshal.dump(value)) - "#{data}--#{generate_digest(data)}" - end - - private - def generate_digest(data) - require 'openssl' unless defined?(OpenSSL) - OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new(@digest), @secret, data) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/multibyte.rb b/vendor/rails/activesupport/lib/active_support/multibyte.rb deleted file mode 100644 index 65a96af..0000000 --- a/vendor/rails/activesupport/lib/active_support/multibyte.rb +++ /dev/null @@ -1,33 +0,0 @@ -# encoding: utf-8 - -require 'active_support/multibyte/chars' -require 'active_support/multibyte/exceptions' -require 'active_support/multibyte/unicode_database' - -module ActiveSupport #:nodoc: - module Multibyte - # A list of all available normalization forms. See http://www.unicode.org/reports/tr15/tr15-29.html for more - # information about normalization. - NORMALIZATION_FORMS = [:c, :kc, :d, :kd] - - # The Unicode version that is supported by the implementation - UNICODE_VERSION = '5.1.0' - - # The default normalization used for operations that require normalization. It can be set to any of the - # normalizations in NORMALIZATION_FORMS. - # - # Example: - # ActiveSupport::Multibyte.default_normalization_form = :c - mattr_accessor :default_normalization_form - self.default_normalization_form = :kc - - # The proxy class returned when calling mb_chars. You can use this accessor to configure your own proxy - # class so you can support other encodings. See the ActiveSupport::Multibyte::Chars implementation for - # an example how to do this. - # - # Example: - # ActiveSupport::Multibyte.proxy_class = CharsForUTF32 - mattr_accessor :proxy_class - self.proxy_class = ActiveSupport::Multibyte::Chars - end -end diff --git a/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb b/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb deleted file mode 100644 index 60f082b..0000000 --- a/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb +++ /dev/null @@ -1,701 +0,0 @@ -# encoding: utf-8 - -module ActiveSupport #:nodoc: - module Multibyte #:nodoc: - # Chars enables you to work transparently with UTF-8 encoding in the Ruby String class without having extensive - # knowledge about the encoding. A Chars object accepts a string upon initialization and proxies String methods in an - # encoding safe manner. All the normal String methods are also implemented on the proxy. - # - # String methods are proxied through the Chars object, and can be accessed through the +mb_chars+ method. Methods - # which would normally return a String object now return a Chars object so methods can be chained. - # - # "The Perfect String ".mb_chars.downcase.strip.normalize #=> "the perfect string" - # - # Chars objects are perfectly interchangeable with String objects as long as no explicit class checks are made. - # If certain methods do explicitly check the class, call +to_s+ before you pass chars objects to them. - # - # bad.explicit_checking_method "T".mb_chars.downcase.to_s - # - # The default Chars implementation assumes that the encoding of the string is UTF-8, if you want to handle different - # encodings you can write your own multibyte string handler and configure it through - # ActiveSupport::Multibyte.proxy_class. - # - # class CharsForUTF32 - # def size - # @wrapped_string.size / 4 - # end - # - # def self.accepts?(string) - # string.length % 4 == 0 - # end - # end - # - # ActiveSupport::Multibyte.proxy_class = CharsForUTF32 - class Chars - # Hangul character boundaries and properties - HANGUL_SBASE = 0xAC00 - HANGUL_LBASE = 0x1100 - HANGUL_VBASE = 0x1161 - HANGUL_TBASE = 0x11A7 - HANGUL_LCOUNT = 19 - HANGUL_VCOUNT = 21 - HANGUL_TCOUNT = 28 - HANGUL_NCOUNT = HANGUL_VCOUNT * HANGUL_TCOUNT - HANGUL_SCOUNT = 11172 - HANGUL_SLAST = HANGUL_SBASE + HANGUL_SCOUNT - HANGUL_JAMO_FIRST = 0x1100 - HANGUL_JAMO_LAST = 0x11FF - - # All the unicode whitespace - UNICODE_WHITESPACE = [ - (0x0009..0x000D).to_a, # White_Space # Cc [5] <control-0009>..<control-000D> - 0x0020, # White_Space # Zs SPACE - 0x0085, # White_Space # Cc <control-0085> - 0x00A0, # White_Space # Zs NO-BREAK SPACE - 0x1680, # White_Space # Zs OGHAM SPACE MARK - 0x180E, # White_Space # Zs MONGOLIAN VOWEL SEPARATOR - (0x2000..0x200A).to_a, # White_Space # Zs [11] EN QUAD..HAIR SPACE - 0x2028, # White_Space # Zl LINE SEPARATOR - 0x2029, # White_Space # Zp PARAGRAPH SEPARATOR - 0x202F, # White_Space # Zs NARROW NO-BREAK SPACE - 0x205F, # White_Space # Zs MEDIUM MATHEMATICAL SPACE - 0x3000, # White_Space # Zs IDEOGRAPHIC SPACE - ].flatten.freeze - - # BOM (byte order mark) can also be seen as whitespace, it's a non-rendering character used to distinguish - # between little and big endian. This is not an issue in utf-8, so it must be ignored. - UNICODE_LEADERS_AND_TRAILERS = UNICODE_WHITESPACE + [65279] # ZERO-WIDTH NO-BREAK SPACE aka BOM - - # Returns a regular expression pattern that matches the passed Unicode codepoints - def self.codepoints_to_pattern(array_of_codepoints) #:nodoc: - array_of_codepoints.collect{ |e| [e].pack 'U*' }.join('|') - end - UNICODE_TRAILERS_PAT = /(#{codepoints_to_pattern(UNICODE_LEADERS_AND_TRAILERS)})+\Z/ - UNICODE_LEADERS_PAT = /\A(#{codepoints_to_pattern(UNICODE_LEADERS_AND_TRAILERS)})+/ - - # Borrowed from the Kconv library by Shinji KONO - (also as seen on the W3C site) - UTF8_PAT = /\A(?: - [\x00-\x7f] | - [\xc2-\xdf] [\x80-\xbf] | - \xe0 [\xa0-\xbf] [\x80-\xbf] | - [\xe1-\xef] [\x80-\xbf] [\x80-\xbf] | - \xf0 [\x90-\xbf] [\x80-\xbf] [\x80-\xbf] | - [\xf1-\xf3] [\x80-\xbf] [\x80-\xbf] [\x80-\xbf] | - \xf4 [\x80-\x8f] [\x80-\xbf] [\x80-\xbf] - )*\z/xn - - attr_reader :wrapped_string - alias to_s wrapped_string - alias to_str wrapped_string - - if '1.9'.respond_to?(:force_encoding) - # Creates a new Chars instance by wrapping _string_. - def initialize(string) - @wrapped_string = string - @wrapped_string.force_encoding(Encoding::UTF_8) unless @wrapped_string.frozen? - end - else - def initialize(string) #:nodoc: - @wrapped_string = string - end - end - - # Forward all undefined methods to the wrapped string. - def method_missing(method, *args, &block) - if method.to_s =~ /!$/ - @wrapped_string.__send__(method, *args, &block) - self - else - result = @wrapped_string.__send__(method, *args, &block) - result.kind_of?(String) ? chars(result) : result - end - end - - # Returns +true+ if _obj_ responds to the given method. Private methods are included in the search - # only if the optional second parameter evaluates to +true+. - def respond_to?(method, include_private=false) - super || @wrapped_string.respond_to?(method, include_private) || false - end - - # Enable more predictable duck-typing on String-like classes. See Object#acts_like?. - def acts_like_string? - true - end - - # Returns +true+ if the Chars class can and should act as a proxy for the string _string_. Returns - # +false+ otherwise. - def self.wants?(string) - $KCODE == 'UTF8' && consumes?(string) - end - - # Returns +true+ when the proxy class can handle the string. Returns +false+ otherwise. - def self.consumes?(string) - # Unpack is a little bit faster than regular expressions. - string.unpack('U*') - true - rescue ArgumentError - false - end - - include Comparable - - # Returns <tt>-1</tt>, <tt>0</tt> or <tt>+1</tt> depending on whether the Chars object is to be sorted before, - # equal or after the object on the right side of the operation. It accepts any object that implements +to_s+. - # See <tt>String#<=></tt> for more details. - # - # Example: - # 'é'.mb_chars <=> 'ü'.mb_chars #=> -1 - def <=>(other) - @wrapped_string <=> other.to_s - end - - # Returns a new Chars object containing the _other_ object concatenated to the string. - # - # Example: - # ('Café'.mb_chars + ' périferôl').to_s #=> "Café périferôl" - def +(other) - self << other - end - - # Like <tt>String#=~</tt> only it returns the character offset (in codepoints) instead of the byte offset. - # - # Example: - # 'Café périferôl'.mb_chars =~ /ô/ #=> 12 - def =~(other) - translate_offset(@wrapped_string =~ other) - end - - # Works just like <tt>String#split</tt>, with the exception that the items in the resulting list are Chars - # instances instead of String. This makes chaining methods easier. - # - # Example: - # 'Café périferôl'.mb_chars.split(/é/).map { |part| part.upcase.to_s } #=> ["CAF", " P", "RIFERÔL"] - def split(*args) - @wrapped_string.split(*args).map { |i| i.mb_chars } - end - - # Inserts the passed string at specified codepoint offsets. - # - # Example: - # 'Café'.mb_chars.insert(4, ' périferôl').to_s #=> "Café périferôl" - def insert(offset, fragment) - unpacked = self.class.u_unpack(@wrapped_string) - unless offset > unpacked.length - @wrapped_string.replace( - self.class.u_unpack(@wrapped_string).insert(offset, *self.class.u_unpack(fragment)).pack('U*') - ) - else - raise IndexError, "index #{offset} out of string" - end - self - end - - # Returns +true+ if contained string contains _other_. Returns +false+ otherwise. - # - # Example: - # 'Café'.mb_chars.include?('é') #=> true - def include?(other) - # We have to redefine this method because Enumerable defines it. - @wrapped_string.include?(other) - end - - # Returns the position _needle_ in the string, counting in codepoints. Returns +nil+ if _needle_ isn't found. - # - # Example: - # 'Café périferôl'.mb_chars.index('ô') #=> 12 - # 'Café périferôl'.mb_chars.index(/\w/u) #=> 0 - def index(needle, offset=0) - index = @wrapped_string.index(needle, offset) - index ? (self.class.u_unpack(@wrapped_string.slice(0...index)).size) : nil - end - - # Like <tt>String#[]=</tt>, except instead of byte offsets you specify character offsets. - # - # Example: - # - # s = "Müller" - # s.mb_chars[2] = "e" # Replace character with offset 2 - # s - # #=> "Müeler" - # - # s = "Müller" - # s.mb_chars[1, 2] = "ö" # Replace 2 characters at character offset 1 - # s - # #=> "Möler" - def []=(*args) - replace_by = args.pop - # Indexed replace with regular expressions already works - if args.first.is_a?(Regexp) - @wrapped_string[*args] = replace_by - else - result = self.class.u_unpack(@wrapped_string) - if args[0].is_a?(Fixnum) - raise IndexError, "index #{args[0]} out of string" if args[0] >= result.length - min = args[0] - max = args[1].nil? ? min : (min + args[1] - 1) - range = Range.new(min, max) - replace_by = [replace_by].pack('U') if replace_by.is_a?(Fixnum) - elsif args.first.is_a?(Range) - raise RangeError, "#{args[0]} out of range" if args[0].min >= result.length - range = args[0] - else - needle = args[0].to_s - min = index(needle) - max = min + self.class.u_unpack(needle).length - 1 - range = Range.new(min, max) - end - result[range] = self.class.u_unpack(replace_by) - @wrapped_string.replace(result.pack('U*')) - end - end - - # Works just like <tt>String#rjust</tt>, only integer specifies characters instead of bytes. - # - # Example: - # - # "¾ cup".mb_chars.rjust(8).to_s - # #=> " ¾ cup" - # - # "¾ cup".mb_chars.rjust(8, " ").to_s # Use non-breaking whitespace - # #=> "   ¾ cup" - def rjust(integer, padstr=' ') - justify(integer, :right, padstr) - end - - # Works just like <tt>String#ljust</tt>, only integer specifies characters instead of bytes. - # - # Example: - # - # "¾ cup".mb_chars.rjust(8).to_s - # #=> "¾ cup " - # - # "¾ cup".mb_chars.rjust(8, " ").to_s # Use non-breaking whitespace - # #=> "¾ cup   " - def ljust(integer, padstr=' ') - justify(integer, :left, padstr) - end - - # Works just like <tt>String#center</tt>, only integer specifies characters instead of bytes. - # - # Example: - # - # "¾ cup".mb_chars.center(8).to_s - # #=> " ¾ cup " - # - # "¾ cup".mb_chars.center(8, " ").to_s # Use non-breaking whitespace - # #=> " ¾ cup  " - def center(integer, padstr=' ') - justify(integer, :center, padstr) - end - - # Strips entire range of Unicode whitespace from the right of the string. - def rstrip - chars(@wrapped_string.gsub(UNICODE_TRAILERS_PAT, '')) - end - - # Strips entire range of Unicode whitespace from the left of the string. - def lstrip - chars(@wrapped_string.gsub(UNICODE_LEADERS_PAT, '')) - end - - # Strips entire range of Unicode whitespace from the right and left of the string. - def strip - rstrip.lstrip - end - - # Returns the number of codepoints in the string - def size - self.class.u_unpack(@wrapped_string).size - end - alias_method :length, :size - - # Reverses all characters in the string. - # - # Example: - # 'Café'.mb_chars.reverse.to_s #=> 'éfaC' - def reverse - chars(self.class.u_unpack(@wrapped_string).reverse.pack('U*')) - end - - # Implements Unicode-aware slice with codepoints. Slicing on one point returns the codepoints for that - # character. - # - # Example: - # 'こんにちは'.mb_chars.slice(2..3).to_s #=> "にち" - def slice(*args) - if args.size > 2 - raise ArgumentError, "wrong number of arguments (#{args.size} for 1)" # Do as if we were native - elsif (args.size == 2 && !(args.first.is_a?(Numeric) || args.first.is_a?(Regexp))) - raise TypeError, "cannot convert #{args.first.class} into Integer" # Do as if we were native - elsif (args.size == 2 && !args[1].is_a?(Numeric)) - raise TypeError, "cannot convert #{args[1].class} into Integer" # Do as if we were native - elsif args[0].kind_of? Range - cps = self.class.u_unpack(@wrapped_string).slice(*args) - result = cps.nil? ? nil : cps.pack('U*') - elsif args[0].kind_of? Regexp - result = @wrapped_string.slice(*args) - elsif args.size == 1 && args[0].kind_of?(Numeric) - character = self.class.u_unpack(@wrapped_string)[args[0]] - result = character.nil? ? nil : [character].pack('U') - else - result = self.class.u_unpack(@wrapped_string).slice(*args).pack('U*') - end - result.nil? ? nil : chars(result) - end - alias_method :[], :slice - - # Like <tt>String#slice!</tt>, except instead of byte offsets you specify character offsets. - # - # Example: - # s = 'こんにちは' - # s.mb_chars.slice!(2..3).to_s #=> "にち" - # s #=> "こんは" - def slice!(*args) - slice = self[*args] - self[*args] = '' - slice - end - - # Returns the codepoint of the first character in the string. - # - # Example: - # 'こんにちは'.mb_chars.ord #=> 12371 - def ord - self.class.u_unpack(@wrapped_string)[0] - end - - # Convert characters in the string to uppercase. - # - # Example: - # 'Laurent, òu sont les tests?'.mb_chars.upcase.to_s #=> "LAURENT, ÒU SONT LES TESTS?" - def upcase - apply_mapping :uppercase_mapping - end - - # Convert characters in the string to lowercase. - # - # Example: - # 'VĚDA A VÝZKUM'.mb_chars.downcase.to_s #=> "věda a výzkum" - def downcase - apply_mapping :lowercase_mapping - end - - # Converts the first character to uppercase and the remainder to lowercase. - # - # Example: - # 'über'.mb_chars.capitalize.to_s #=> "Über" - def capitalize - (slice(0) || chars('')).upcase + (slice(1..-1) || chars('')).downcase - end - - # Returns the KC normalization of the string by default. NFKC is considered the best normalization form for - # passing strings to databases and validations. - # - # * <tt>str</tt> - The string to perform normalization on. - # * <tt>form</tt> - The form you want to normalize in. Should be one of the following: - # <tt>:c</tt>, <tt>:kc</tt>, <tt>:d</tt>, or <tt>:kd</tt>. Default is - # ActiveSupport::Multibyte.default_normalization_form - def normalize(form=ActiveSupport::Multibyte.default_normalization_form) - # See http://www.unicode.org/reports/tr15, Table 1 - codepoints = self.class.u_unpack(@wrapped_string) - chars(case form - when :d - self.class.reorder_characters(self.class.decompose_codepoints(:canonical, codepoints)) - when :c - self.class.compose_codepoints(self.class.reorder_characters(self.class.decompose_codepoints(:canonical, codepoints))) - when :kd - self.class.reorder_characters(self.class.decompose_codepoints(:compatability, codepoints)) - when :kc - self.class.compose_codepoints(self.class.reorder_characters(self.class.decompose_codepoints(:compatability, codepoints))) - else - raise ArgumentError, "#{form} is not a valid normalization variant", caller - end.pack('U*')) - end - - # Performs canonical decomposition on all the characters. - # - # Example: - # 'é'.length #=> 2 - # 'é'.mb_chars.decompose.to_s.length #=> 3 - def decompose - chars(self.class.decompose_codepoints(:canonical, self.class.u_unpack(@wrapped_string)).pack('U*')) - end - - # Performs composition on all the characters. - # - # Example: - # 'é'.length #=> 3 - # 'é'.mb_chars.compose.to_s.length #=> 2 - def compose - chars(self.class.compose_codepoints(self.class.u_unpack(@wrapped_string)).pack('U*')) - end - - # Returns the number of grapheme clusters in the string. - # - # Example: - # 'क्षि'.mb_chars.length #=> 4 - # 'क्षि'.mb_chars.g_length #=> 3 - def g_length - self.class.g_unpack(@wrapped_string).length - end - - # Replaces all ISO-8859-1 or CP1252 characters by their UTF-8 equivalent resulting in a valid UTF-8 string. - def tidy_bytes - chars(self.class.tidy_bytes(@wrapped_string)) - end - - %w(lstrip rstrip strip reverse upcase downcase tidy_bytes capitalize).each do |method| - define_method("#{method}!") do |*args| - unless args.nil? - @wrapped_string = send(method, *args).to_s - else - @wrapped_string = send(method).to_s - end - self - end - end - - class << self - - # Unpack the string at codepoints boundaries. Raises an EncodingError when the encoding of the string isn't - # valid UTF-8. - # - # Example: - # Chars.u_unpack('Café') #=> [67, 97, 102, 233] - def u_unpack(string) - begin - string.unpack 'U*' - rescue ArgumentError - raise EncodingError, 'malformed UTF-8 character' - end - end - - # Detect whether the codepoint is in a certain character class. Returns +true+ when it's in the specified - # character class and +false+ otherwise. Valid character classes are: <tt>:cr</tt>, <tt>:lf</tt>, <tt>:l</tt>, - # <tt>:v</tt>, <tt>:lv</tt>, <tt>:lvt</tt> and <tt>:t</tt>. - # - # Primarily used by the grapheme cluster support. - def in_char_class?(codepoint, classes) - classes.detect { |c| UCD.boundary[c] === codepoint } ? true : false - end - - # Unpack the string at grapheme boundaries. Returns a list of character lists. - # - # Example: - # Chars.g_unpack('क्षि') #=> [[2325, 2381], [2359], [2367]] - # Chars.g_unpack('Café') #=> [[67], [97], [102], [233]] - def g_unpack(string) - codepoints = u_unpack(string) - unpacked = [] - pos = 0 - marker = 0 - eoc = codepoints.length - while(pos < eoc) - pos += 1 - previous = codepoints[pos-1] - current = codepoints[pos] - if ( - # CR X LF - one = ( previous == UCD.boundary[:cr] and current == UCD.boundary[:lf] ) or - # L X (L|V|LV|LVT) - two = ( UCD.boundary[:l] === previous and in_char_class?(current, [:l,:v,:lv,:lvt]) ) or - # (LV|V) X (V|T) - three = ( in_char_class?(previous, [:lv,:v]) and in_char_class?(current, [:v,:t]) ) or - # (LVT|T) X (T) - four = ( in_char_class?(previous, [:lvt,:t]) and UCD.boundary[:t] === current ) or - # X Extend - five = (UCD.boundary[:extend] === current) - ) - else - unpacked << codepoints[marker..pos-1] - marker = pos - end - end - unpacked - end - - # Reverse operation of g_unpack. - # - # Example: - # Chars.g_pack(Chars.g_unpack('क्षि')) #=> 'क्षि' - def g_pack(unpacked) - (unpacked.flatten).pack('U*') - end - - def padding(padsize, padstr=' ') #:nodoc: - if padsize != 0 - new(padstr * ((padsize / u_unpack(padstr).size) + 1)).slice(0, padsize) - else - '' - end - end - - # Re-order codepoints so the string becomes canonical. - def reorder_characters(codepoints) - length = codepoints.length- 1 - pos = 0 - while pos < length do - cp1, cp2 = UCD.codepoints[codepoints[pos]], UCD.codepoints[codepoints[pos+1]] - if (cp1.combining_class > cp2.combining_class) && (cp2.combining_class > 0) - codepoints[pos..pos+1] = cp2.code, cp1.code - pos += (pos > 0 ? -1 : 1) - else - pos += 1 - end - end - codepoints - end - - # Decompose composed characters to the decomposed form. - def decompose_codepoints(type, codepoints) - codepoints.inject([]) do |decomposed, cp| - # if it's a hangul syllable starter character - if HANGUL_SBASE <= cp and cp < HANGUL_SLAST - sindex = cp - HANGUL_SBASE - ncp = [] # new codepoints - ncp << HANGUL_LBASE + sindex / HANGUL_NCOUNT - ncp << HANGUL_VBASE + (sindex % HANGUL_NCOUNT) / HANGUL_TCOUNT - tindex = sindex % HANGUL_TCOUNT - ncp << (HANGUL_TBASE + tindex) unless tindex == 0 - decomposed.concat ncp - # if the codepoint is decomposable in with the current decomposition type - elsif (ncp = UCD.codepoints[cp].decomp_mapping) and (!UCD.codepoints[cp].decomp_type || type == :compatability) - decomposed.concat decompose_codepoints(type, ncp.dup) - else - decomposed << cp - end - end - end - - # Compose decomposed characters to the composed form. - def compose_codepoints(codepoints) - pos = 0 - eoa = codepoints.length - 1 - starter_pos = 0 - starter_char = codepoints[0] - previous_combining_class = -1 - while pos < eoa - pos += 1 - lindex = starter_char - HANGUL_LBASE - # -- Hangul - if 0 <= lindex and lindex < HANGUL_LCOUNT - vindex = codepoints[starter_pos+1] - HANGUL_VBASE rescue vindex = -1 - if 0 <= vindex and vindex < HANGUL_VCOUNT - tindex = codepoints[starter_pos+2] - HANGUL_TBASE rescue tindex = -1 - if 0 <= tindex and tindex < HANGUL_TCOUNT - j = starter_pos + 2 - eoa -= 2 - else - tindex = 0 - j = starter_pos + 1 - eoa -= 1 - end - codepoints[starter_pos..j] = (lindex * HANGUL_VCOUNT + vindex) * HANGUL_TCOUNT + tindex + HANGUL_SBASE - end - starter_pos += 1 - starter_char = codepoints[starter_pos] - # -- Other characters - else - current_char = codepoints[pos] - current = UCD.codepoints[current_char] - if current.combining_class > previous_combining_class - if ref = UCD.composition_map[starter_char] - composition = ref[current_char] - else - composition = nil - end - unless composition.nil? - codepoints[starter_pos] = composition - starter_char = composition - codepoints.delete_at pos - eoa -= 1 - pos -= 1 - previous_combining_class = -1 - else - previous_combining_class = current.combining_class - end - else - previous_combining_class = current.combining_class - end - if current.combining_class == 0 - starter_pos = pos - starter_char = codepoints[pos] - end - end - end - codepoints - end - - # Replaces all ISO-8859-1 or CP1252 characters by their UTF-8 equivalent resulting in a valid UTF-8 string. - def tidy_bytes(string) - string.split(//u).map do |c| - c.force_encoding(Encoding::ASCII) if c.respond_to?(:force_encoding) - - if !UTF8_PAT.match(c) - n = c.unpack('C')[0] - n < 128 ? n.chr : - n < 160 ? [UCD.cp1252[n] || n].pack('U') : - n < 192 ? "\xC2" + n.chr : "\xC3" + (n-64).chr - else - c - end - end.join - end - end - - protected - - def translate_offset(byte_offset) #:nodoc: - return nil if byte_offset.nil? - return 0 if @wrapped_string == '' - chunk = @wrapped_string[0..byte_offset] - begin - begin - chunk.unpack('U*').length - 1 - rescue ArgumentError => e - chunk = @wrapped_string[0..(byte_offset+=1)] - # Stop retrying at the end of the string - raise e unless byte_offset < chunk.length - # We damaged a character, retry - retry - end - # Catch the ArgumentError so we can throw our own - rescue ArgumentError - raise EncodingError, 'malformed UTF-8 character' - end - end - - def justify(integer, way, padstr=' ') #:nodoc: - raise ArgumentError, "zero width padding" if padstr.length == 0 - padsize = integer - size - padsize = padsize > 0 ? padsize : 0 - case way - when :right - result = @wrapped_string.dup.insert(0, self.class.padding(padsize, padstr)) - when :left - result = @wrapped_string.dup.insert(-1, self.class.padding(padsize, padstr)) - when :center - lpad = self.class.padding((padsize / 2.0).floor, padstr) - rpad = self.class.padding((padsize / 2.0).ceil, padstr) - result = @wrapped_string.dup.insert(0, lpad).insert(-1, rpad) - end - chars(result) - end - - def apply_mapping(mapping) #:nodoc: - chars(self.class.u_unpack(@wrapped_string).map do |codepoint| - cp = UCD.codepoints[codepoint] - if cp and (ncp = cp.send(mapping)) and ncp > 0 - ncp - else - codepoint - end - end.pack('U*')) - end - - def chars(string) #:nodoc: - self.class.new(string) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/multibyte/exceptions.rb b/vendor/rails/activesupport/lib/active_support/multibyte/exceptions.rb deleted file mode 100644 index 62066e3..0000000 --- a/vendor/rails/activesupport/lib/active_support/multibyte/exceptions.rb +++ /dev/null @@ -1,8 +0,0 @@ -# encoding: utf-8 - -module ActiveSupport #:nodoc: - module Multibyte #:nodoc: - # Raised when a problem with the encoding was found. - class EncodingError < StandardError; end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/multibyte/unicode_database.rb b/vendor/rails/activesupport/lib/active_support/multibyte/unicode_database.rb deleted file mode 100644 index a08f38c..0000000 --- a/vendor/rails/activesupport/lib/active_support/multibyte/unicode_database.rb +++ /dev/null @@ -1,71 +0,0 @@ -# encoding: utf-8 - -module ActiveSupport #:nodoc: - module Multibyte #:nodoc: - # Holds data about a codepoint in the Unicode database - class Codepoint - attr_accessor :code, :combining_class, :decomp_type, :decomp_mapping, :uppercase_mapping, :lowercase_mapping - end - - # Holds static data from the Unicode database - class UnicodeDatabase - ATTRIBUTES = :codepoints, :composition_exclusion, :composition_map, :boundary, :cp1252 - - attr_writer(*ATTRIBUTES) - - def initialize - @codepoints = Hash.new(Codepoint.new) - @composition_exclusion = [] - @composition_map = {} - @boundary = {} - @cp1252 = {} - end - - # Lazy load the Unicode database so it's only loaded when it's actually used - ATTRIBUTES.each do |attr_name| - class_eval(<<-EOS, __FILE__, __LINE__) - def #{attr_name} # def codepoints - load # load - @#{attr_name} # @codepoints - end # end - EOS - end - - # Loads the Unicode database and returns all the internal objects of UnicodeDatabase. - def load - begin - @codepoints, @composition_exclusion, @composition_map, @boundary, @cp1252 = File.open(self.class.filename, 'rb') { |f| Marshal.load f.read } - rescue Exception => e - raise IOError.new("Couldn't load the Unicode tables for UTF8Handler (#{e.message}), ActiveSupport::Multibyte is unusable") - end - - # Redefine the === method so we can write shorter rules for grapheme cluster breaks - @boundary.each do |k,_| - @boundary[k].instance_eval do - def ===(other) - detect { |i| i === other } ? true : false - end - end if @boundary[k].kind_of?(Array) - end - - # define attr_reader methods for the instance variables - class << self - attr_reader(*ATTRIBUTES) - end - end - - # Returns the directory in which the data files are stored - def self.dirname - File.dirname(__FILE__) + '/../values/' - end - - # Returns the filename for the data file for this version - def self.filename - File.expand_path File.join(dirname, "unicode_tables.dat") - end - end - - # UniCode Database - UCD = UnicodeDatabase.new - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/option_merger.rb b/vendor/rails/activesupport/lib/active_support/option_merger.rb deleted file mode 100644 index 63662b7..0000000 --- a/vendor/rails/activesupport/lib/active_support/option_merger.rb +++ /dev/null @@ -1,23 +0,0 @@ -module ActiveSupport - class OptionMerger #:nodoc: - instance_methods.each do |method| - undef_method(method) if method !~ /^(__|instance_eval|class|object_id)/ - end - - def initialize(context, options) - @context, @options = context, options - end - - private - def method_missing(method, *arguments, &block) - if arguments.last.is_a?(Proc) - proc = arguments.pop - arguments << lambda { |*args| @options.deep_merge(proc.call(*args)) } - else - arguments << (arguments.last.respond_to?(:to_hash) ? @options.deep_merge(arguments.pop) : @options.dup) - end - - @context.__send__(method, *arguments, &block) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/ordered_hash.rb b/vendor/rails/activesupport/lib/active_support/ordered_hash.rb deleted file mode 100644 index fed8094..0000000 --- a/vendor/rails/activesupport/lib/active_support/ordered_hash.rb +++ /dev/null @@ -1,106 +0,0 @@ -# OrderedHash is namespaced to prevent conflicts with other implementations -module ActiveSupport - # Hash is ordered in Ruby 1.9! - if RUBY_VERSION >= '1.9' - OrderedHash = ::Hash - else - class OrderedHash < Hash #:nodoc: - def initialize(*args, &block) - super - @keys = [] - end - - def initialize_copy(other) - super - # make a deep copy of keys - @keys = other.keys - end - - def []=(key, value) - @keys << key if !has_key?(key) - super - end - - def delete(key) - if has_key? key - index = @keys.index(key) - @keys.delete_at index - end - super - end - - def delete_if - super - sync_keys! - self - end - - def reject! - super - sync_keys! - self - end - - def reject(&block) - dup.reject!(&block) - end - - def keys - @keys.dup - end - - def values - @keys.collect { |key| self[key] } - end - - def to_hash - self - end - - def each_key - @keys.each { |key| yield key } - end - - def each_value - @keys.each { |key| yield self[key]} - end - - def each - @keys.each {|key| yield [key, self[key]]} - end - - alias_method :each_pair, :each - - def clear - super - @keys.clear - self - end - - def shift - k = @keys.first - v = delete(k) - [k, v] - end - - def merge!(other_hash) - other_hash.each {|k,v| self[k] = v } - self - end - - def merge(other_hash) - dup.merge!(other_hash) - end - - def inspect - "#<OrderedHash #{super}>" - end - - private - - def sync_keys! - @keys.delete_if {|k| !has_key?(k)} - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/ordered_options.rb b/vendor/rails/activesupport/lib/active_support/ordered_options.rb deleted file mode 100644 index 6420451..0000000 --- a/vendor/rails/activesupport/lib/active_support/ordered_options.rb +++ /dev/null @@ -1,19 +0,0 @@ -module ActiveSupport #:nodoc: - class OrderedOptions < OrderedHash #:nodoc: - def []=(key, value) - super(key.to_sym, value) - end - - def [](key) - super(key.to_sym) - end - - def method_missing(name, *args) - if name.to_s =~ /(.*)=$/ - self[$1.to_sym] = args.first - else - self[name] - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/rescuable.rb b/vendor/rails/activesupport/lib/active_support/rescuable.rb deleted file mode 100644 index c27c4dd..0000000 --- a/vendor/rails/activesupport/lib/active_support/rescuable.rb +++ /dev/null @@ -1,108 +0,0 @@ -module ActiveSupport - # Rescuable module adds support for easier exception handling. - module Rescuable - def self.included(base) # :nodoc: - base.class_inheritable_accessor :rescue_handlers - base.rescue_handlers = [] - - base.extend(ClassMethods) - end - - module ClassMethods - # Rescue exceptions raised in controller actions. - # - # <tt>rescue_from</tt> receives a series of exception classes or class - # names, and a trailing <tt>:with</tt> option with the name of a method - # or a Proc object to be called to handle them. Alternatively a block can - # be given. - # - # Handlers that take one argument will be called with the exception, so - # that the exception can be inspected when dealing with it. - # - # Handlers are inherited. They are searched from right to left, from - # bottom to top, and up the hierarchy. The handler of the first class for - # which <tt>exception.is_a?(klass)</tt> holds true is the one invoked, if - # any. - # - # class ApplicationController < ActionController::Base - # rescue_from User::NotAuthorized, :with => :deny_access # self defined exception - # rescue_from ActiveRecord::RecordInvalid, :with => :show_errors - # - # rescue_from 'MyAppError::Base' do |exception| - # render :xml => exception, :status => 500 - # end - # - # protected - # def deny_access - # ... - # end - # - # def show_errors(exception) - # exception.record.new_record? ? ... - # end - # end - def rescue_from(*klasses, &block) - options = klasses.extract_options! - - unless options.has_key?(:with) - if block_given? - options[:with] = block - else - raise ArgumentError, "Need a handler. Supply an options hash that has a :with key as the last argument." - end - end - - klasses.each do |klass| - key = if klass.is_a?(Class) && klass <= Exception - klass.name - elsif klass.is_a?(String) - klass - else - raise ArgumentError, "#{klass} is neither an Exception nor a String" - end - - # put the new handler at the end because the list is read in reverse - rescue_handlers << [key, options[:with]] - end - end - end - - # Tries to rescue the exception by looking up and calling a registered handler. - def rescue_with_handler(exception) - if handler = handler_for_rescue(exception) - handler.arity != 0 ? handler.call(exception) : handler.call - true # don't rely on the return value of the handler - end - end - - def handler_for_rescue(exception) - # We go from right to left because pairs are pushed onto rescue_handlers - # as rescue_from declarations are found. - _, rescuer = Array(rescue_handlers).reverse.detect do |klass_name, handler| - # The purpose of allowing strings in rescue_from is to support the - # declaration of handler associations for exception classes whose - # definition is yet unknown. - # - # Since this loop needs the constants it would be inconsistent to - # assume they should exist at this point. An early raised exception - # could trigger some other handler and the array could include - # precisely a string whose corresponding constant has not yet been - # seen. This is why we are tolerant to unknown constants. - # - # Note that this tolerance only matters if the exception was given as - # a string, otherwise a NameError will be raised by the interpreter - # itself when rescue_from CONSTANT is executed. - klass = self.class.const_get(klass_name) rescue nil - klass ||= klass_name.constantize rescue nil - exception.is_a?(klass) if klass - end - - case rescuer - when Symbol - method(rescuer) - when Proc - rescuer.bind(self) - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/secure_random.rb b/vendor/rails/activesupport/lib/active_support/secure_random.rb deleted file mode 100644 index cfbce4d..0000000 --- a/vendor/rails/activesupport/lib/active_support/secure_random.rb +++ /dev/null @@ -1,199 +0,0 @@ -begin - require 'securerandom' -rescue LoadError -end - -module ActiveSupport - if defined?(::SecureRandom) - # Use Ruby's SecureRandom library if available. - SecureRandom = ::SecureRandom # :nodoc: - else - # = Secure random number generator interface. - # - # This library is an interface for secure random number generator which is - # suitable for generating session key in HTTP cookies, etc. - # - # It supports following secure random number generators. - # - # * openssl - # * /dev/urandom - # * Win32 - # - # *Note*: This module is based on the SecureRandom library from Ruby 1.9, - # revision 18786, August 23 2008. It's 100% interface-compatible with Ruby 1.9's - # SecureRandom library. - # - # == Example - # - # # random hexadecimal string. - # p SecureRandom.hex(10) #=> "52750b30ffbc7de3b362" - # p SecureRandom.hex(10) #=> "92b15d6c8dc4beb5f559" - # p SecureRandom.hex(11) #=> "6aca1b5c58e4863e6b81b8" - # p SecureRandom.hex(12) #=> "94b2fff3e7fd9b9c391a2306" - # p SecureRandom.hex(13) #=> "39b290146bea6ce975c37cfc23" - # ... - # - # # random base64 string. - # p SecureRandom.base64(10) #=> "EcmTPZwWRAozdA==" - # p SecureRandom.base64(10) #=> "9b0nsevdwNuM/w==" - # p SecureRandom.base64(10) #=> "KO1nIU+p9DKxGg==" - # p SecureRandom.base64(11) #=> "l7XEiFja+8EKEtY=" - # p SecureRandom.base64(12) #=> "7kJSM/MzBJI+75j8" - # p SecureRandom.base64(13) #=> "vKLJ0tXBHqQOuIcSIg==" - # ... - # - # # random binary string. - # p SecureRandom.random_bytes(10) #=> "\016\t{\370g\310pbr\301" - # p SecureRandom.random_bytes(10) #=> "\323U\030TO\234\357\020\a\337" - # ... - module SecureRandom - # SecureRandom.random_bytes generates a random binary string. - # - # The argument n specifies the length of the result string. - # - # If n is not specified, 16 is assumed. - # It may be larger in future. - # - # If secure random number generator is not available, - # NotImplementedError is raised. - def self.random_bytes(n=nil) - n ||= 16 - - unless defined? OpenSSL - begin - require 'openssl' - rescue LoadError - end - end - - if defined? OpenSSL::Random - return OpenSSL::Random.random_bytes(n) - end - - if !defined?(@has_urandom) || @has_urandom - flags = File::RDONLY - flags |= File::NONBLOCK if defined? File::NONBLOCK - flags |= File::NOCTTY if defined? File::NOCTTY - flags |= File::NOFOLLOW if defined? File::NOFOLLOW - begin - File.open("/dev/urandom", flags) {|f| - unless f.stat.chardev? - raise Errno::ENOENT - end - @has_urandom = true - ret = f.readpartial(n) - if ret.length != n - raise NotImplementedError, "Unexpected partial read from random device" - end - return ret - } - rescue Errno::ENOENT - @has_urandom = false - end - end - - if !defined?(@has_win32) - begin - require 'Win32API' - - crypt_acquire_context = Win32API.new("advapi32", "CryptAcquireContext", 'PPPII', 'L') - @crypt_gen_random = Win32API.new("advapi32", "CryptGenRandom", 'LIP', 'L') - - hProvStr = " " * 4 - prov_rsa_full = 1 - crypt_verifycontext = 0xF0000000 - - if crypt_acquire_context.call(hProvStr, nil, nil, prov_rsa_full, crypt_verifycontext) == 0 - raise SystemCallError, "CryptAcquireContext failed: #{lastWin32ErrorMessage}" - end - @hProv, = hProvStr.unpack('L') - - @has_win32 = true - rescue LoadError - @has_win32 = false - end - end - if @has_win32 - bytes = " " * n - if @crypt_gen_random.call(@hProv, bytes.size, bytes) == 0 - raise SystemCallError, "CryptGenRandom failed: #{lastWin32ErrorMessage}" - end - return bytes - end - - raise NotImplementedError, "No random device" - end - - # SecureRandom.hex generates a random hex string. - # - # The argument n specifies the length of the random length. - # The length of the result string is twice of n. - # - # If n is not specified, 16 is assumed. - # It may be larger in future. - # - # If secure random number generator is not available, - # NotImplementedError is raised. - def self.hex(n=nil) - random_bytes(n).unpack("H*")[0] - end - - # SecureRandom.base64 generates a random base64 string. - # - # The argument n specifies the length of the random length. - # The length of the result string is about 4/3 of n. - # - # If n is not specified, 16 is assumed. - # It may be larger in future. - # - # If secure random number generator is not available, - # NotImplementedError is raised. - def self.base64(n=nil) - [random_bytes(n)].pack("m*").delete("\n") - end - - # SecureRandom.random_number generates a random number. - # - # If an positive integer is given as n, - # SecureRandom.random_number returns an integer: - # 0 <= SecureRandom.random_number(n) < n. - # - # If 0 is given or an argument is not given, - # SecureRandom.random_number returns an float: - # 0.0 <= SecureRandom.random_number() < 1.0. - def self.random_number(n=0) - if 0 < n - hex = n.to_s(16) - hex = '0' + hex if (hex.length & 1) == 1 - bin = [hex].pack("H*") - mask = bin[0] - mask |= mask >> 1 - mask |= mask >> 2 - mask |= mask >> 4 - begin - rnd = SecureRandom.random_bytes(bin.length) - rnd[0] = rnd[0] & mask - end until rnd < bin - rnd.unpack("H*")[0].hex - else - # assumption: Float::MANT_DIG <= 64 - i64 = SecureRandom.random_bytes(8).unpack("Q")[0] - Math.ldexp(i64 >> (64-Float::MANT_DIG), -Float::MANT_DIG) - end - end - - # Following code is based on David Garamond's GUID library for Ruby. - def self.lastWin32ErrorMessage # :nodoc: - get_last_error = Win32API.new("kernel32", "GetLastError", '', 'L') - format_message = Win32API.new("kernel32", "FormatMessageA", 'LPLLPLPPPPPPPP', 'L') - format_message_ignore_inserts = 0x00000200 - format_message_from_system = 0x00001000 - - code = get_last_error.call - msg = "\0" * 1024 - len = format_message.call(format_message_ignore_inserts + format_message_from_system, 0, code, 0, msg, 1024, nil, nil, nil, nil, nil, nil, nil, nil) - msg[0, len].tr("\r", '').chomp - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/string_inquirer.rb b/vendor/rails/activesupport/lib/active_support/string_inquirer.rb deleted file mode 100644 index e6b1f39..0000000 --- a/vendor/rails/activesupport/lib/active_support/string_inquirer.rb +++ /dev/null @@ -1,21 +0,0 @@ -module ActiveSupport - # Wrapping a string in this class gives you a prettier way to test - # for equality. The value returned by <tt>Rails.env</tt> is wrapped - # in a StringInquirer object so instead of calling this: - # - # Rails.env == "production" - # - # you can call this: - # - # Rails.env.production? - # - class StringInquirer < String - def method_missing(method_name, *arguments) - if method_name.to_s[-1,1] == "?" - self == method_name.to_s[0..-2] - else - super - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/test_case.rb b/vendor/rails/activesupport/lib/active_support/test_case.rb deleted file mode 100644 index f05d409..0000000 --- a/vendor/rails/activesupport/lib/active_support/test_case.rb +++ /dev/null @@ -1,39 +0,0 @@ -begin - gem 'mocha', '>= 0.9.3' - require 'mocha' -rescue LoadError - # Fake Mocha::ExpectationError so we can rescue it in #run. Bleh. - Object.const_set :Mocha, Module.new - Mocha.const_set :ExpectationError, Class.new(StandardError) -end - -require 'test/unit/testcase' -require 'active_support/testing/setup_and_teardown' -require 'active_support/testing/assertions' -require 'active_support/testing/deprecation' -require 'active_support/testing/declarative' - -module ActiveSupport - class TestCase < ::Test::Unit::TestCase - if defined? MiniTest - Assertion = MiniTest::Assertion - alias_method :method_name, :name - else - # TODO: Figure out how to get the Rails::BacktraceFilter into minitest/unit - if defined?(Rails) && ENV['BACKTRACE'].nil? - require 'rails/backtrace_cleaner' - Test::Unit::Util::BacktraceFilter.module_eval { include Rails::BacktraceFilterForTestUnit } - end - - Assertion = Test::Unit::AssertionFailedError - - require 'active_support/testing/default' - include ActiveSupport::Testing::Default - end - - include ActiveSupport::Testing::SetupAndTeardown - include ActiveSupport::Testing::Assertions - include ActiveSupport::Testing::Deprecation - extend ActiveSupport::Testing::Declarative - end -end diff --git a/vendor/rails/activesupport/lib/active_support/testing/assertions.rb b/vendor/rails/activesupport/lib/active_support/testing/assertions.rb deleted file mode 100644 index ca51adb..0000000 --- a/vendor/rails/activesupport/lib/active_support/testing/assertions.rb +++ /dev/null @@ -1,65 +0,0 @@ -module ActiveSupport - module Testing - module Assertions - # Test numeric difference between the return value of an expression as a result of what is evaluated - # in the yielded block. - # - # assert_difference 'Article.count' do - # post :create, :article => {...} - # end - # - # An arbitrary expression is passed in and evaluated. - # - # assert_difference 'assigns(:article).comments(:reload).size' do - # post :create, :comment => {...} - # end - # - # An arbitrary positive or negative difference can be specified. The default is +1. - # - # assert_difference 'Article.count', -1 do - # post :delete, :id => ... - # end - # - # An array of expressions can also be passed in and evaluated. - # - # assert_difference [ 'Article.count', 'Post.count' ], +2 do - # post :create, :article => {...} - # end - # - # A error message can be specified. - # - # assert_difference 'Article.count', -1, "An Article should be destroyed" do - # post :delete, :id => ... - # end - def assert_difference(expression, difference = 1, message = nil, &block) - b = block.send(:binding) - exps = Array.wrap(expression) - before = exps.map { |e| eval(e, b) } - - yield - - exps.each_with_index do |e, i| - error = "#{e.inspect} didn't change by #{difference}" - error = "#{message}.\n#{error}" if message - assert_equal(before[i] + difference, eval(e, b), error) - end - end - - # Assertion that the numeric result of evaluating an expression is not changed before and after - # invoking the passed in block. - # - # assert_no_difference 'Article.count' do - # post :create, :article => invalid_attributes - # end - # - # A error message can be specified. - # - # assert_no_difference 'Article.count', "An Article should not be destroyed" do - # post :create, :article => invalid_attributes - # end - def assert_no_difference(expression, message = nil, &block) - assert_difference expression, 0, message, &block - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/testing/declarative.rb b/vendor/rails/activesupport/lib/active_support/testing/declarative.rb deleted file mode 100644 index cb6a584..0000000 --- a/vendor/rails/activesupport/lib/active_support/testing/declarative.rb +++ /dev/null @@ -1,21 +0,0 @@ -module ActiveSupport - module Testing - module Declarative - # test "verify something" do - # ... - # end - def test(name, &block) - test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym - defined = instance_method(test_name) rescue false - raise "#{test_name} is already defined in #{self}" if defined - if block_given? - define_method(test_name, &block) - else - define_method(test_name) do - flunk "No implementation provided for #{name}" - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/testing/default.rb b/vendor/rails/activesupport/lib/active_support/testing/default.rb deleted file mode 100644 index a0bd630..0000000 --- a/vendor/rails/activesupport/lib/active_support/testing/default.rb +++ /dev/null @@ -1,9 +0,0 @@ -module ActiveSupport - module Testing - module Default #:nodoc: - # Placeholder so test/unit ignores test cases without any tests. - def default_test - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/testing/deprecation.rb b/vendor/rails/activesupport/lib/active_support/testing/deprecation.rb deleted file mode 100644 index e922060..0000000 --- a/vendor/rails/activesupport/lib/active_support/testing/deprecation.rb +++ /dev/null @@ -1,55 +0,0 @@ -module ActiveSupport - module Testing - module Deprecation #:nodoc: - def assert_deprecated(match = nil, &block) - result, warnings = collect_deprecations(&block) - assert !warnings.empty?, "Expected a deprecation warning within the block but received none" - if match - match = Regexp.new(Regexp.escape(match)) unless match.is_a?(Regexp) - assert warnings.any? { |w| w =~ match }, "No deprecation warning matched #{match}: #{warnings.join(', ')}" - end - result - end - - def assert_not_deprecated(&block) - result, deprecations = collect_deprecations(&block) - assert deprecations.empty?, "Expected no deprecation warning within the block but received #{deprecations.size}: \n #{deprecations * "\n "}" - result - end - - private - def collect_deprecations - old_behavior = ActiveSupport::Deprecation.behavior - deprecations = [] - ActiveSupport::Deprecation.behavior = Proc.new do |message, callstack| - deprecations << message - end - result = yield - [result, deprecations] - ensure - ActiveSupport::Deprecation.behavior = old_behavior - end - end - end -end - -begin - require 'test/unit/error' - - module Test - module Unit - class Error # :nodoc: - # Silence warnings when reporting test errors. - def message_with_silenced_deprecation - ActiveSupport::Deprecation.silence do - message_without_silenced_deprecation - end - end - - alias_method_chain :message, :silenced_deprecation - end - end - end -rescue LoadError - # Using miniunit, ignore. -end diff --git a/vendor/rails/activesupport/lib/active_support/testing/performance.rb b/vendor/rails/activesupport/lib/active_support/testing/performance.rb deleted file mode 100644 index f8d12e8..0000000 --- a/vendor/rails/activesupport/lib/active_support/testing/performance.rb +++ /dev/null @@ -1,452 +0,0 @@ -require 'rubygems' -gem 'ruby-prof', '>= 0.6.1' -require 'ruby-prof' - -require 'fileutils' -require 'rails/version' - -module ActiveSupport - module Testing - module Performance - DEFAULTS = - if benchmark = ARGV.include?('--benchmark') # HAX for rake test - { :benchmark => true, - :runs => 4, - :metrics => [:wall_time, :memory, :objects, :gc_runs, :gc_time], - :output => 'tmp/performance' } - else - { :benchmark => false, - :runs => 1, - :min_percent => 0.01, - :metrics => [:process_time, :memory, :objects], - :formats => [:flat, :graph_html, :call_tree], - :output => 'tmp/performance' } - end.freeze - - def self.included(base) - base.superclass_delegating_accessor :profile_options - base.profile_options = DEFAULTS - end - - def full_test_name - "#{self.class.name}##{method_name}" - end - - def run(result) - return if method_name =~ /^default_test$/ - - yield(self.class::STARTED, name) - @_result = result - - run_warmup - if profile_options && metrics = profile_options[:metrics] - metrics.each do |metric_name| - if klass = Metrics[metric_name.to_sym] - run_profile(klass.new) - result.add_run - end - end - end - - yield(self.class::FINISHED, name) - end - - def run_test(metric, mode) - run_callbacks :setup - setup - metric.send(mode) { __send__ @method_name } - rescue ::Test::Unit::AssertionFailedError => e - add_failure(e.message, e.backtrace) - rescue StandardError, ScriptError - add_error($!) - ensure - begin - teardown - run_callbacks :teardown, :enumerator => :reverse_each - rescue ::Test::Unit::AssertionFailedError => e - add_failure(e.message, e.backtrace) - rescue StandardError, ScriptError - add_error($!) - end - end - - protected - def run_warmup - GC.start - - time = Metrics::Time.new - run_test(time, :benchmark) - puts "%s (%s warmup)" % [full_test_name, time.format(time.total)] - - GC.start - end - - def run_profile(metric) - klass = profile_options[:benchmark] ? Benchmarker : Profiler - performer = klass.new(self, metric) - - performer.run - puts performer.report - performer.record - end - - class Performer - delegate :run_test, :profile_options, :full_test_name, :to => :@harness - - def initialize(harness, metric) - @harness, @metric = harness, metric - end - - def report - rate = @total / profile_options[:runs] - '%20s: %s' % [@metric.name, @metric.format(rate)] - end - - protected - def output_filename - "#{profile_options[:output]}/#{full_test_name}_#{@metric.name}" - end - end - - class Benchmarker < Performer - def run - profile_options[:runs].to_i.times { run_test(@metric, :benchmark) } - @total = @metric.total - end - - def record - avg = @metric.total / profile_options[:runs].to_i - now = Time.now.utc.xmlschema - with_output_file do |file| - file.puts "#{avg},#{now},#{environment}" - end - end - - def environment - unless defined? @env - app = "#{$1}.#{$2}" if File.directory?('.git') && `git branch -v` =~ /^\* (\S+)\s+(\S+)/ - - rails = Rails::VERSION::STRING - if File.directory?('vendor/rails/.git') - Dir.chdir('vendor/rails') do - rails += ".#{$1}.#{$2}" if `git branch -v` =~ /^\* (\S+)\s+(\S+)/ - end - end - - ruby = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby' - ruby += "-#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}" - - @env = [app, rails, ruby, RUBY_PLATFORM] * ',' - end - - @env - end - - protected - HEADER = 'measurement,created_at,app,rails,ruby,platform' - - def with_output_file - fname = output_filename - - if new = !File.exist?(fname) - FileUtils.mkdir_p(File.dirname(fname)) - end - - File.open(fname, 'ab') do |file| - file.puts(HEADER) if new - yield file - end - end - - def output_filename - "#{super}.csv" - end - end - - class Profiler < Performer - def initialize(*args) - super - @supported = @metric.measure_mode rescue false - end - - def run - return unless @supported - - RubyProf.measure_mode = @metric.measure_mode - RubyProf.start - RubyProf.pause - profile_options[:runs].to_i.times { run_test(@metric, :profile) } - @data = RubyProf.stop - @total = @data.threads.values.sum(0) { |method_infos| method_infos.sort.last.total_time } - end - - def report - if @supported - super - else - '%20s: unsupported' % @metric.name - end - end - - def record - return unless @supported - - klasses = profile_options[:formats].map { |f| RubyProf.const_get("#{f.to_s.camelize}Printer") }.compact - - klasses.each do |klass| - fname = output_filename(klass) - FileUtils.mkdir_p(File.dirname(fname)) - File.open(fname, 'wb') do |file| - klass.new(@data).print(file, profile_options.slice(:min_percent)) - end - end - end - - protected - def output_filename(printer_class) - suffix = - case printer_class.name.demodulize - when 'FlatPrinter'; 'flat.txt' - when 'GraphPrinter'; 'graph.txt' - when 'GraphHtmlPrinter'; 'graph.html' - when 'CallTreePrinter'; 'tree.txt' - else printer_class.name.sub(/Printer$/, '').underscore - end - - "#{super()}_#{suffix}" - end - end - - module Metrics - def self.[](name) - const_get(name.to_s.camelize) - rescue NameError - nil - end - - class Base - attr_reader :total - - def initialize - @total = 0 - end - - def name - @name ||= self.class.name.demodulize.underscore - end - - def measure_mode - self.class::Mode - end - - def measure - 0 - end - - def benchmark - with_gc_stats do - before = measure - yield - @total += (measure - before) - end - end - - def profile - RubyProf.resume - yield - ensure - RubyProf.pause - end - - protected - if GC.respond_to?(:enable_stats) - def with_gc_stats - GC.enable_stats - yield - ensure - GC.disable_stats - end - elsif defined?(GC::Profiler) - def with_gc_stats - GC.start - GC.disable - GC::Profiler.enable - yield - ensure - GC::Profiler.disable - GC.enable - end - else - def with_gc_stats - yield - end - end - end - - class Time < Base - def measure - ::Time.now.to_f - end - - def format(measurement) - if measurement < 2 - '%d ms' % (measurement * 1000) - else - '%.2f sec' % measurement - end - end - end - - class ProcessTime < Time - Mode = RubyProf::PROCESS_TIME - - def measure - RubyProf.measure_process_time - end - end - - class WallTime < Time - Mode = RubyProf::WALL_TIME - - def measure - RubyProf.measure_wall_time - end - end - - class CpuTime < Time - Mode = RubyProf::CPU_TIME if RubyProf.const_defined?(:CPU_TIME) - - def initialize(*args) - # FIXME: yeah my CPU is 2.33 GHz - RubyProf.cpu_frequency = 2.33e9 - super - end - - def measure - RubyProf.measure_cpu_time - end - end - - class Memory < Base - Mode = RubyProf::MEMORY if RubyProf.const_defined?(:MEMORY) - - # ruby-prof wrapper - if RubyProf.respond_to?(:measure_memory) - def measure - RubyProf.measure_memory / 1024.0 - end - - # Ruby 1.8 + railsbench patch - elsif GC.respond_to?(:allocated_size) - def measure - GC.allocated_size / 1024.0 - end - - # Ruby 1.8 + lloyd patch - elsif GC.respond_to?(:heap_info) - def measure - GC.heap_info['heap_current_memory'] / 1024.0 - end - - # Ruby 1.9 with total_malloc_allocated_size patch - elsif GC.respond_to?(:malloc_total_allocated_size) - def measure - GC.total_malloc_allocated_size / 1024.0 - end - - # Ruby 1.9 unpatched - elsif GC.respond_to?(:malloc_allocated_size) - def measure - GC.malloc_allocated_size / 1024.0 - end - - # Ruby 1.9 + GC profiler patch - elsif defined?(GC::Profiler) - def measure - GC.enable - GC.start - kb = GC::Profiler.data.last[:HEAP_USE_SIZE] / 1024.0 - GC.disable - kb - end - end - - def format(measurement) - '%.2f KB' % measurement - end - end - - class Objects < Base - Mode = RubyProf::ALLOCATIONS if RubyProf.const_defined?(:ALLOCATIONS) - - if RubyProf.respond_to?(:measure_allocations) - def measure - RubyProf.measure_allocations - end - - # Ruby 1.8 + railsbench patch - elsif ObjectSpace.respond_to?(:allocated_objects) - def measure - ObjectSpace.allocated_objects - end - - # Ruby 1.9 + GC profiler patch - elsif defined?(GC::Profiler) - def measure - GC.enable - GC.start - last = GC::Profiler.data.last - count = last[:HEAP_LIVE_OBJECTS] + last[:HEAP_FREE_OBJECTS] - GC.disable - count - end - end - - def format(measurement) - measurement.to_i.to_s - end - end - - class GcRuns < Base - Mode = RubyProf::GC_RUNS if RubyProf.const_defined?(:GC_RUNS) - - if RubyProf.respond_to?(:measure_gc_runs) - def measure - RubyProf.measure_gc_runs - end - elsif GC.respond_to?(:collections) - def measure - GC.collections - end - elsif GC.respond_to?(:heap_info) - def measure - GC.heap_info['num_gc_passes'] - end - end - - def format(measurement) - measurement.to_i.to_s - end - end - - class GcTime < Base - Mode = RubyProf::GC_TIME if RubyProf.const_defined?(:GC_TIME) - - if RubyProf.respond_to?(:measure_gc_time) - def measure - RubyProf.measure_gc_time - end - elsif GC.respond_to?(:time) - def measure - GC.time - end - end - - def format(measurement) - '%d ms' % (measurement / 1000) - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb b/vendor/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb deleted file mode 100644 index aaf9f8f..0000000 --- a/vendor/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'active_support/callbacks' - -module ActiveSupport - module Testing - module SetupAndTeardown - def self.included(base) - base.class_eval do - include ActiveSupport::Callbacks - define_callbacks :setup, :teardown - - if defined?(MiniTest::Assertions) && TestCase < MiniTest::Assertions - include ForMiniTest - else - include ForClassicTestUnit - end - end - end - - module ForMiniTest - def run(runner) - result = '.' - begin - run_callbacks :setup - result = super - rescue Exception => e - result = runner.puke(self.class, self.name, e) - ensure - begin - run_callbacks :teardown, :enumerator => :reverse_each - rescue Exception => e - result = runner.puke(self.class, self.name, e) - end - end - result - end - end - - module ForClassicTestUnit - # For compatibility with Ruby < 1.8.6 - PASSTHROUGH_EXCEPTIONS = Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS rescue [NoMemoryError, SignalException, Interrupt, SystemExit] - - # This redefinition is unfortunate but test/unit shows us no alternative. - # Doubly unfortunate: hax to support Mocha's hax. - def run(result) - return if @method_name.to_s == "default_test" - - if using_mocha = respond_to?(:mocha_verify) - assertion_counter_klass = if defined?(Mocha::TestCaseAdapter::AssertionCounter) - Mocha::TestCaseAdapter::AssertionCounter - else - Mocha::Integration::TestUnit::AssertionCounter - end - assertion_counter = assertion_counter_klass.new(result) - end - - yield(Test::Unit::TestCase::STARTED, name) - @_result = result - begin - begin - run_callbacks :setup - setup - __send__(@method_name) - mocha_verify(assertion_counter) if using_mocha - rescue Mocha::ExpectationError => e - add_failure(e.message, e.backtrace) - rescue Test::Unit::AssertionFailedError => e - add_failure(e.message, e.backtrace) - rescue Exception => e - raise if PASSTHROUGH_EXCEPTIONS.include?(e.class) - add_error(e) - ensure - begin - teardown - run_callbacks :teardown, :enumerator => :reverse_each - rescue Test::Unit::AssertionFailedError => e - add_failure(e.message, e.backtrace) - rescue Exception => e - raise if PASSTHROUGH_EXCEPTIONS.include?(e.class) - add_error(e) - end - end - ensure - mocha_teardown if using_mocha - end - result.add_run - yield(Test::Unit::TestCase::FINISHED, name) - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/time_with_zone.rb b/vendor/rails/activesupport/lib/active_support/time_with_zone.rb deleted file mode 100644 index 518ca77..0000000 --- a/vendor/rails/activesupport/lib/active_support/time_with_zone.rb +++ /dev/null @@ -1,334 +0,0 @@ -require 'tzinfo' - -module ActiveSupport - # A Time-like class that can represent a time in any time zone. Necessary because standard Ruby Time instances are - # limited to UTC and the system's <tt>ENV['TZ']</tt> zone. - # - # You shouldn't ever need to create a TimeWithZone instance directly via <tt>new</tt> -- instead, Rails provides the methods - # +local+, +parse+, +at+ and +now+ on TimeZone instances, and +in_time_zone+ on Time and DateTime instances, for a more - # user-friendly syntax. Examples: - # - # Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)' - # Time.zone.local(2007, 2, 10, 15, 30, 45) # => Sat, 10 Feb 2007 15:30:45 EST -05:00 - # Time.zone.parse('2007-02-01 15:30:45') # => Sat, 10 Feb 2007 15:30:45 EST -05:00 - # Time.zone.at(1170361845) # => Sat, 10 Feb 2007 15:30:45 EST -05:00 - # Time.zone.now # => Sun, 18 May 2008 13:07:55 EDT -04:00 - # Time.utc(2007, 2, 10, 20, 30, 45).in_time_zone # => Sat, 10 Feb 2007 15:30:45 EST -05:00 - # - # See TimeZone and ActiveSupport::CoreExtensions::Time::Zones for further documentation for these methods. - # - # TimeWithZone instances implement the same API as Ruby Time instances, so that Time and TimeWithZone instances are interchangable. Examples: - # - # t = Time.zone.now # => Sun, 18 May 2008 13:27:25 EDT -04:00 - # t.hour # => 13 - # t.dst? # => true - # t.utc_offset # => -14400 - # t.zone # => "EDT" - # t.to_s(:rfc822) # => "Sun, 18 May 2008 13:27:25 -0400" - # t + 1.day # => Mon, 19 May 2008 13:27:25 EDT -04:00 - # t.beginning_of_year # => Tue, 01 Jan 2008 00:00:00 EST -05:00 - # t > Time.utc(1999) # => true - # t.is_a?(Time) # => true - # t.is_a?(ActiveSupport::TimeWithZone) # => true - class TimeWithZone - include Comparable - attr_reader :time_zone - - def initialize(utc_time, time_zone, local_time = nil, period = nil) - @utc, @time_zone, @time = utc_time, time_zone, local_time - @period = @utc ? period : get_period_and_ensure_valid_local_time - end - - # Returns a Time or DateTime instance that represents the time in +time_zone+. - def time - @time ||= period.to_local(@utc) - end - - # Returns a Time or DateTime instance that represents the time in UTC. - def utc - @utc ||= period.to_utc(@time) - end - alias_method :comparable_time, :utc - alias_method :getgm, :utc - alias_method :getutc, :utc - alias_method :gmtime, :utc - - # Returns the underlying TZInfo::TimezonePeriod. - def period - @period ||= time_zone.period_for_utc(@utc) - end - - # Returns the simultaneous time in <tt>Time.zone</tt>, or the specified zone. - def in_time_zone(new_zone = ::Time.zone) - return self if time_zone == new_zone - utc.in_time_zone(new_zone) - end - - # Returns a <tt>Time.local()</tt> instance of the simultaneous time in your system's <tt>ENV['TZ']</tt> zone - def localtime - utc.getlocal - end - alias_method :getlocal, :localtime - - def dst? - period.dst? - end - alias_method :isdst, :dst? - - def utc? - time_zone.name == 'UTC' - end - alias_method :gmt?, :utc? - - def utc_offset - period.utc_total_offset - end - alias_method :gmt_offset, :utc_offset - alias_method :gmtoff, :utc_offset - - def formatted_offset(colon = true, alternate_utc_string = nil) - utc? && alternate_utc_string || utc_offset.to_utc_offset_s(colon) - end - - # Time uses +zone+ to display the time zone abbreviation, so we're duck-typing it. - def zone - period.zone_identifier.to_s - end - - def inspect - "#{time.strftime('%a, %d %b %Y %H:%M:%S')} #{zone} #{formatted_offset}" - end - - def xmlschema(fraction_digits = 0) - fraction = if fraction_digits > 0 - ".%i" % time.usec.to_s[0, fraction_digits] - end - - "#{time.strftime("%Y-%m-%dT%H:%M:%S")}#{fraction}#{formatted_offset(true, 'Z')}" - end - alias_method :iso8601, :xmlschema - - # Returns a JSON string representing the TimeWithZone. If ActiveSupport.use_standard_json_time_format is set to - # true, the ISO 8601 format is used. - # - # ==== Examples - # - # # With ActiveSupport.use_standard_json_time_format = true - # Time.utc(2005,2,1,15,15,10).in_time_zone.to_json - # # => "2005-02-01T15:15:10Z" - # - # # With ActiveSupport.use_standard_json_time_format = false - # Time.utc(2005,2,1,15,15,10).in_time_zone.to_json - # # => "2005/02/01 15:15:10 +0000" - def to_json(options = nil) - if ActiveSupport.use_standard_json_time_format - xmlschema.inspect - else - %("#{time.strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}") - end - end - - def to_yaml(options = {}) - if options.kind_of?(YAML::Emitter) - utc.to_yaml(options) - else - time.to_yaml(options).gsub('Z', formatted_offset(true, 'Z')) - end - end - - def httpdate - utc.httpdate - end - - def rfc2822 - to_s(:rfc822) - end - alias_method :rfc822, :rfc2822 - - # <tt>:db</tt> format outputs time in UTC; all others output time in local. - # Uses TimeWithZone's +strftime+, so <tt>%Z</tt> and <tt>%z</tt> work correctly. - def to_s(format = :default) - return utc.to_s(format) if format == :db - if formatter = ::Time::DATE_FORMATS[format] - formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter) - else - "#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset(false, 'UTC')}" # mimicking Ruby 1.9 Time#to_s format - end - end - alias_method :to_formatted_s, :to_s - - # Replaces <tt>%Z</tt> and <tt>%z</tt> directives with +zone+ and +formatted_offset+, respectively, before passing to - # Time#strftime, so that zone information is correct - def strftime(format) - format = format.gsub('%Z', zone).gsub('%z', formatted_offset(false)) - time.strftime(format) - end - - # Use the time in UTC for comparisons. - def <=>(other) - utc <=> other - end - - def between?(min, max) - utc.between?(min, max) - end - - def past? - utc.past? - end - - def today? - time.today? - end - - def future? - utc.future? - end - - def eql?(other) - utc == other - end - - def +(other) - # If we're adding a Duration of variable length (i.e., years, months, days), move forward from #time, - # otherwise move forward from #utc, for accuracy when moving across DST boundaries - if duration_of_variable_length?(other) - method_missing(:+, other) - else - result = utc.acts_like?(:date) ? utc.since(other) : utc + other rescue utc.since(other) - result.in_time_zone(time_zone) - end - end - - def -(other) - # If we're subtracting a Duration of variable length (i.e., years, months, days), move backwards from #time, - # otherwise move backwards #utc, for accuracy when moving across DST boundaries - if other.acts_like?(:time) - utc.to_f - other.to_f - elsif duration_of_variable_length?(other) - method_missing(:-, other) - else - result = utc.acts_like?(:date) ? utc.ago(other) : utc - other rescue utc.ago(other) - result.in_time_zone(time_zone) - end - end - - def since(other) - # If we're adding a Duration of variable length (i.e., years, months, days), move forward from #time, - # otherwise move forward from #utc, for accuracy when moving across DST boundaries - if duration_of_variable_length?(other) - method_missing(:since, other) - else - utc.since(other).in_time_zone(time_zone) - end - end - - def ago(other) - since(-other) - end - - def advance(options) - # If we're advancing a value of variable length (i.e., years, weeks, months, days), advance from #time, - # otherwise advance from #utc, for accuracy when moving across DST boundaries - if options.values_at(:years, :weeks, :months, :days).any? - method_missing(:advance, options) - else - utc.advance(options).in_time_zone(time_zone) - end - end - - %w(year mon month day mday wday yday hour min sec to_date).each do |method_name| - class_eval <<-EOV - def #{method_name} # def year - time.#{method_name} # time.year - end # end - EOV - end - - def usec - time.respond_to?(:usec) ? time.usec : 0 - end - - def to_a - [time.sec, time.min, time.hour, time.day, time.mon, time.year, time.wday, time.yday, dst?, zone] - end - - def to_f - utc.to_f - end - - def to_i - utc.to_i - end - alias_method :hash, :to_i - alias_method :tv_sec, :to_i - - # A TimeWithZone acts like a Time, so just return +self+. - def to_time - self - end - - def to_datetime - utc.to_datetime.new_offset(Rational(utc_offset, 86_400)) - end - - # So that +self+ <tt>acts_like?(:time)</tt>. - def acts_like_time? - true - end - - # Say we're a Time to thwart type checking. - def is_a?(klass) - klass == ::Time || super - end - alias_method :kind_of?, :is_a? - - def freeze - period; utc; time # preload instance variables before freezing - super - end - - def marshal_dump - [utc, time_zone.name, time] - end - - def marshal_load(variables) - initialize(variables[0].utc, ::Time.__send__(:get_zone, variables[1]), variables[2].utc) - end - - # Ensure proxy class responds to all methods that underlying time instance responds to. - def respond_to?(sym, include_priv = false) - # consistently respond false to acts_like?(:date), regardless of whether #time is a Time or DateTime - return false if sym.to_s == 'acts_like_date?' - super || time.respond_to?(sym, include_priv) - end - - # Send the missing method to +time+ instance, and wrap result in a new TimeWithZone with the existing +time_zone+. - def method_missing(sym, *args, &block) - result = time.__send__(sym, *args, &block) - result.acts_like?(:time) ? self.class.new(nil, time_zone, result) : result - end - - private - def get_period_and_ensure_valid_local_time - # we don't want a Time.local instance enforcing its own DST rules as well, - # so transfer time values to a utc constructor if necessary - @time = transfer_time_values_to_utc_constructor(@time) unless @time.utc? - begin - @time_zone.period_for_local(@time) - rescue ::TZInfo::PeriodNotFound - # time is in the "spring forward" hour gap, so we're moving the time forward one hour and trying again - @time += 1.hour - retry - end - end - - def transfer_time_values_to_utc_constructor(time) - ::Time.utc_time(time.year, time.month, time.day, time.hour, time.min, time.sec, time.respond_to?(:usec) ? time.usec : 0) - end - - def duration_of_variable_length?(obj) - ActiveSupport::Duration === obj && obj.parts.any? {|p| [:years, :months, :days].include? p[0] } - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/values/time_zone.rb b/vendor/rails/activesupport/lib/active_support/values/time_zone.rb deleted file mode 100644 index 836f469..0000000 --- a/vendor/rails/activesupport/lib/active_support/values/time_zone.rb +++ /dev/null @@ -1,404 +0,0 @@ -# The TimeZone class serves as a wrapper around TZInfo::Timezone instances. It allows us to do the following: -# -# * Limit the set of zones provided by TZInfo to a meaningful subset of 142 zones. -# * Retrieve and display zones with a friendlier name (e.g., "Eastern Time (US & Canada)" instead of "America/New_York"). -# * Lazily load TZInfo::Timezone instances only when they're needed. -# * Create ActiveSupport::TimeWithZone instances via TimeZone's +local+, +parse+, +at+ and +now+ methods. -# -# If you set <tt>config.time_zone</tt> in the Rails Initializer, you can access this TimeZone object via <tt>Time.zone</tt>: -# -# # environment.rb: -# Rails::Initializer.run do |config| -# config.time_zone = "Eastern Time (US & Canada)" -# end -# -# Time.zone # => #<TimeZone:0x514834...> -# Time.zone.name # => "Eastern Time (US & Canada)" -# Time.zone.now # => Sun, 18 May 2008 14:30:44 EDT -04:00 -# -# The version of TZInfo bundled with Active Support only includes the definitions necessary to support the zones -# defined by the TimeZone class. If you need to use zones that aren't defined by TimeZone, you'll need to install the TZInfo gem -# (if a recent version of the gem is installed locally, this will be used instead of the bundled version.) -module ActiveSupport - class TimeZone - unless const_defined?(:MAPPING) - # Keys are Rails TimeZone names, values are TZInfo identifiers - MAPPING = { - "International Date Line West" => "Pacific/Midway", - "Midway Island" => "Pacific/Midway", - "Samoa" => "Pacific/Pago_Pago", - "Hawaii" => "Pacific/Honolulu", - "Alaska" => "America/Juneau", - "Pacific Time (US & Canada)" => "America/Los_Angeles", - "Tijuana" => "America/Tijuana", - "Mountain Time (US & Canada)" => "America/Denver", - "Arizona" => "America/Phoenix", - "Chihuahua" => "America/Chihuahua", - "Mazatlan" => "America/Mazatlan", - "Central Time (US & Canada)" => "America/Chicago", - "Saskatchewan" => "America/Regina", - "Guadalajara" => "America/Mexico_City", - "Mexico City" => "America/Mexico_City", - "Monterrey" => "America/Monterrey", - "Central America" => "America/Guatemala", - "Eastern Time (US & Canada)" => "America/New_York", - "Indiana (East)" => "America/Indiana/Indianapolis", - "Bogota" => "America/Bogota", - "Lima" => "America/Lima", - "Quito" => "America/Lima", - "Atlantic Time (Canada)" => "America/Halifax", - "Caracas" => "America/Caracas", - "La Paz" => "America/La_Paz", - "Santiago" => "America/Santiago", - "Newfoundland" => "America/St_Johns", - "Brasilia" => "America/Sao_Paulo", - "Buenos Aires" => "America/Argentina/Buenos_Aires", - "Georgetown" => "America/Argentina/San_Juan", - "Greenland" => "America/Godthab", - "Mid-Atlantic" => "Atlantic/South_Georgia", - "Azores" => "Atlantic/Azores", - "Cape Verde Is." => "Atlantic/Cape_Verde", - "Dublin" => "Europe/Dublin", - "Edinburgh" => "Europe/Dublin", - "Lisbon" => "Europe/Lisbon", - "London" => "Europe/London", - "Casablanca" => "Africa/Casablanca", - "Monrovia" => "Africa/Monrovia", - "UTC" => "Etc/UTC", - "Belgrade" => "Europe/Belgrade", - "Bratislava" => "Europe/Bratislava", - "Budapest" => "Europe/Budapest", - "Ljubljana" => "Europe/Ljubljana", - "Prague" => "Europe/Prague", - "Sarajevo" => "Europe/Sarajevo", - "Skopje" => "Europe/Skopje", - "Warsaw" => "Europe/Warsaw", - "Zagreb" => "Europe/Zagreb", - "Brussels" => "Europe/Brussels", - "Copenhagen" => "Europe/Copenhagen", - "Madrid" => "Europe/Madrid", - "Paris" => "Europe/Paris", - "Amsterdam" => "Europe/Amsterdam", - "Berlin" => "Europe/Berlin", - "Bern" => "Europe/Berlin", - "Rome" => "Europe/Rome", - "Stockholm" => "Europe/Stockholm", - "Vienna" => "Europe/Vienna", - "West Central Africa" => "Africa/Algiers", - "Bucharest" => "Europe/Bucharest", - "Cairo" => "Africa/Cairo", - "Helsinki" => "Europe/Helsinki", - "Kyev" => "Europe/Kiev", - "Riga" => "Europe/Riga", - "Sofia" => "Europe/Sofia", - "Tallinn" => "Europe/Tallinn", - "Vilnius" => "Europe/Vilnius", - "Athens" => "Europe/Athens", - "Istanbul" => "Europe/Istanbul", - "Minsk" => "Europe/Minsk", - "Jerusalem" => "Asia/Jerusalem", - "Harare" => "Africa/Harare", - "Pretoria" => "Africa/Johannesburg", - "Moscow" => "Europe/Moscow", - "St. Petersburg" => "Europe/Moscow", - "Volgograd" => "Europe/Moscow", - "Kuwait" => "Asia/Kuwait", - "Riyadh" => "Asia/Riyadh", - "Nairobi" => "Africa/Nairobi", - "Baghdad" => "Asia/Baghdad", - "Tehran" => "Asia/Tehran", - "Abu Dhabi" => "Asia/Muscat", - "Muscat" => "Asia/Muscat", - "Baku" => "Asia/Baku", - "Tbilisi" => "Asia/Tbilisi", - "Yerevan" => "Asia/Yerevan", - "Kabul" => "Asia/Kabul", - "Ekaterinburg" => "Asia/Yekaterinburg", - "Islamabad" => "Asia/Karachi", - "Karachi" => "Asia/Karachi", - "Tashkent" => "Asia/Tashkent", - "Chennai" => "Asia/Kolkata", - "Kolkata" => "Asia/Kolkata", - "Mumbai" => "Asia/Kolkata", - "New Delhi" => "Asia/Kolkata", - "Kathmandu" => "Asia/Katmandu", - "Astana" => "Asia/Dhaka", - "Dhaka" => "Asia/Dhaka", - "Sri Jayawardenepura" => "Asia/Colombo", - "Almaty" => "Asia/Almaty", - "Novosibirsk" => "Asia/Novosibirsk", - "Rangoon" => "Asia/Rangoon", - "Bangkok" => "Asia/Bangkok", - "Hanoi" => "Asia/Bangkok", - "Jakarta" => "Asia/Jakarta", - "Krasnoyarsk" => "Asia/Krasnoyarsk", - "Beijing" => "Asia/Shanghai", - "Chongqing" => "Asia/Chongqing", - "Hong Kong" => "Asia/Hong_Kong", - "Urumqi" => "Asia/Urumqi", - "Kuala Lumpur" => "Asia/Kuala_Lumpur", - "Singapore" => "Asia/Singapore", - "Taipei" => "Asia/Taipei", - "Perth" => "Australia/Perth", - "Irkutsk" => "Asia/Irkutsk", - "Ulaan Bataar" => "Asia/Ulaanbaatar", - "Seoul" => "Asia/Seoul", - "Osaka" => "Asia/Tokyo", - "Sapporo" => "Asia/Tokyo", - "Tokyo" => "Asia/Tokyo", - "Yakutsk" => "Asia/Yakutsk", - "Darwin" => "Australia/Darwin", - "Adelaide" => "Australia/Adelaide", - "Canberra" => "Australia/Melbourne", - "Melbourne" => "Australia/Melbourne", - "Sydney" => "Australia/Sydney", - "Brisbane" => "Australia/Brisbane", - "Hobart" => "Australia/Hobart", - "Vladivostok" => "Asia/Vladivostok", - "Guam" => "Pacific/Guam", - "Port Moresby" => "Pacific/Port_Moresby", - "Magadan" => "Asia/Magadan", - "Solomon Is." => "Asia/Magadan", - "New Caledonia" => "Pacific/Noumea", - "Fiji" => "Pacific/Fiji", - "Kamchatka" => "Asia/Kamchatka", - "Marshall Is." => "Pacific/Majuro", - "Auckland" => "Pacific/Auckland", - "Wellington" => "Pacific/Auckland", - "Nuku'alofa" => "Pacific/Tongatapu" - }.each { |name, zone| name.freeze; zone.freeze } - MAPPING.freeze - end - - include Comparable - attr_reader :name - - # Create a new TimeZone object with the given name and offset. The - # offset is the number of seconds that this time zone is offset from UTC - # (GMT). Seconds were chosen as the offset unit because that is the unit that - # Ruby uses to represent time zone offsets (see Time#utc_offset). - def initialize(name, utc_offset, tzinfo = nil) - @name = name - @utc_offset = utc_offset - @tzinfo = tzinfo - end - - def utc_offset - @utc_offset ||= tzinfo.current_period.utc_offset - end - - # Returns the offset of this time zone as a formatted string, of the - # format "+HH:MM". - def formatted_offset(colon=true, alternate_utc_string = nil) - utc_offset == 0 && alternate_utc_string || utc_offset.to_utc_offset_s(colon) - end - - # Compare this time zone to the parameter. The two are comapred first on - # their offsets, and then by name. - def <=>(zone) - result = (utc_offset <=> zone.utc_offset) - result = (name <=> zone.name) if result == 0 - result - end - - # Compare #name and TZInfo identifier to a supplied regexp, returning true - # if a match is found. - def =~(re) - return true if name =~ re || MAPPING[name] =~ re - end - - # Returns a textual representation of this time zone. - def to_s - "(GMT#{formatted_offset}) #{name}" - end - - # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from given values. Example: - # - # Time.zone = "Hawaii" # => "Hawaii" - # Time.zone.local(2007, 2, 1, 15, 30, 45) # => Thu, 01 Feb 2007 15:30:45 HST -10:00 - def local(*args) - time = Time.utc_time(*args) - ActiveSupport::TimeWithZone.new(nil, self, time) - end - - # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from number of seconds since the Unix epoch. Example: - # - # Time.zone = "Hawaii" # => "Hawaii" - # Time.utc(2000).to_f # => 946684800.0 - # Time.zone.at(946684800.0) # => Fri, 31 Dec 1999 14:00:00 HST -10:00 - def at(secs) - utc = Time.at(secs).utc rescue DateTime.civil(1970).since(secs) - utc.in_time_zone(self) - end - - # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from parsed string. Example: - # - # Time.zone = "Hawaii" # => "Hawaii" - # Time.zone.parse('1999-12-31 14:00:00') # => Fri, 31 Dec 1999 14:00:00 HST -10:00 - # - # If upper components are missing from the string, they are supplied from TimeZone#now: - # - # Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00 - # Time.zone.parse('22:30:00') # => Fri, 31 Dec 1999 22:30:00 HST -10:00 - def parse(str, now=now) - date_parts = Date._parse(str) - return if date_parts.blank? - time = Time.parse(str, now) rescue DateTime.parse(str) - if date_parts[:offset].nil? - ActiveSupport::TimeWithZone.new(nil, self, time) - else - time.in_time_zone(self) - end - end - - # Returns an ActiveSupport::TimeWithZone instance representing the current time - # in the time zone represented by +self+. Example: - # - # Time.zone = 'Hawaii' # => "Hawaii" - # Time.zone.now # => Wed, 23 Jan 2008 20:24:27 HST -10:00 - def now - Time.now.utc.in_time_zone(self) - end - - # Return the current date in this time zone. - def today - tzinfo.now.to_date - end - - # Adjust the given time to the simultaneous time in the time zone represented by +self+. Returns a - # Time.utc() instance -- if you want an ActiveSupport::TimeWithZone instance, use Time#in_time_zone() instead. - def utc_to_local(time) - tzinfo.utc_to_local(time) - end - - # Adjust the given time to the simultaneous time in UTC. Returns a Time.utc() instance. - def local_to_utc(time, dst=true) - tzinfo.local_to_utc(time, dst) - end - - # Available so that TimeZone instances respond like TZInfo::Timezone instances - def period_for_utc(time) - tzinfo.period_for_utc(time) - end - - # Available so that TimeZone instances respond like TZInfo::Timezone instances - def period_for_local(time, dst=true) - tzinfo.period_for_local(time, dst) - end - - # TODO: Preload instead of lazy load for thread safety - def tzinfo - require 'tzinfo' unless defined?(TZInfo) - @tzinfo ||= TZInfo::Timezone.get(MAPPING[name]) - end - - unless const_defined?(:ZONES) - ZONES = [] - ZONES_MAP = {} - [[-39_600, "International Date Line West", "Midway Island", "Samoa" ], - [-36_000, "Hawaii" ], - [-32_400, "Alaska" ], - [-28_800, "Pacific Time (US & Canada)", "Tijuana" ], - [-25_200, "Mountain Time (US & Canada)", "Chihuahua", "Mazatlan", - "Arizona" ], - [-21_600, "Central Time (US & Canada)", "Saskatchewan", "Guadalajara", - "Mexico City", "Monterrey", "Central America" ], - [-18_000, "Eastern Time (US & Canada)", "Indiana (East)", "Bogota", - "Lima", "Quito" ], - [-16_200, "Caracas" ], - [-14_400, "Atlantic Time (Canada)", "La Paz", "Santiago" ], - [-12_600, "Newfoundland" ], - [-10_800, "Brasilia", "Buenos Aires", "Georgetown", "Greenland" ], - [ -7_200, "Mid-Atlantic" ], - [ -3_600, "Azores", "Cape Verde Is." ], - [ 0, "Dublin", "Edinburgh", "Lisbon", "London", "Casablanca", - "Monrovia", "UTC" ], - [ 3_600, "Belgrade", "Bratislava", "Budapest", "Ljubljana", "Prague", - "Sarajevo", "Skopje", "Warsaw", "Zagreb", "Brussels", - "Copenhagen", "Madrid", "Paris", "Amsterdam", "Berlin", - "Bern", "Rome", "Stockholm", "Vienna", - "West Central Africa" ], - [ 7_200, "Bucharest", "Cairo", "Helsinki", "Kyev", "Riga", "Sofia", - "Tallinn", "Vilnius", "Athens", "Istanbul", "Minsk", - "Jerusalem", "Harare", "Pretoria" ], - [ 10_800, "Moscow", "St. Petersburg", "Volgograd", "Kuwait", "Riyadh", - "Nairobi", "Baghdad" ], - [ 12_600, "Tehran" ], - [ 14_400, "Abu Dhabi", "Muscat", "Baku", "Tbilisi", "Yerevan" ], - [ 16_200, "Kabul" ], - [ 18_000, "Ekaterinburg", "Islamabad", "Karachi", "Tashkent" ], - [ 19_800, "Chennai", "Kolkata", "Mumbai", "New Delhi", "Sri Jayawardenepura" ], - [ 20_700, "Kathmandu" ], - [ 21_600, "Astana", "Dhaka", "Almaty", - "Novosibirsk" ], - [ 23_400, "Rangoon" ], - [ 25_200, "Bangkok", "Hanoi", "Jakarta", "Krasnoyarsk" ], - [ 28_800, "Beijing", "Chongqing", "Hong Kong", "Urumqi", - "Kuala Lumpur", "Singapore", "Taipei", "Perth", "Irkutsk", - "Ulaan Bataar" ], - [ 32_400, "Seoul", "Osaka", "Sapporo", "Tokyo", "Yakutsk" ], - [ 34_200, "Darwin", "Adelaide" ], - [ 36_000, "Canberra", "Melbourne", "Sydney", "Brisbane", "Hobart", - "Vladivostok", "Guam", "Port Moresby" ], - [ 39_600, "Magadan", "Solomon Is.", "New Caledonia" ], - [ 43_200, "Fiji", "Kamchatka", "Marshall Is.", "Auckland", - "Wellington" ], - [ 46_800, "Nuku'alofa" ]]. - each do |offset, *places| - places.each do |place| - place.freeze - zone = new(place, offset) - ZONES << zone - ZONES_MAP[place] = zone - end - end - ZONES.sort! - ZONES.freeze - ZONES_MAP.freeze - - US_ZONES = ZONES.find_all { |z| z.name =~ /US|Arizona|Indiana|Hawaii|Alaska/ } - US_ZONES.freeze - end - - class << self - alias_method :create, :new - - # Return a TimeZone instance with the given name, or +nil+ if no - # such TimeZone instance exists. (This exists to support the use of - # this class with the +composed_of+ macro.) - def new(name) - self[name] - end - - # Return an array of all TimeZone objects. There are multiple - # TimeZone objects per time zone, in many cases, to make it easier - # for users to find their own time zone. - def all - ZONES - end - - # Locate a specific time zone object. If the argument is a string, it - # is interpreted to mean the name of the timezone to locate. If it is a - # numeric value it is either the hour offset, or the second offset, of the - # timezone to find. (The first one with that offset will be returned.) - # Returns +nil+ if no such time zone is known to the system. - def [](arg) - case arg - when String - ZONES_MAP[arg] - when Numeric, ActiveSupport::Duration - arg *= 3600 if arg.abs <= 13 - all.find { |z| z.utc_offset == arg.to_i } - else - raise ArgumentError, "invalid argument to TimeZone[]: #{arg.inspect}" - end - end - - # A convenience method for returning a collection of TimeZone objects - # for time zones in the USA. - def us_zones - US_ZONES - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/values/unicode_tables.dat b/vendor/rails/activesupport/lib/active_support/values/unicode_tables.dat deleted file mode 100644 index 74b333d..0000000 Binary files a/vendor/rails/activesupport/lib/active_support/values/unicode_tables.dat and /dev/null differ diff --git a/vendor/rails/activesupport/lib/active_support/vendor.rb b/vendor/rails/activesupport/lib/active_support/vendor.rb deleted file mode 100644 index 28852e6..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor.rb +++ /dev/null @@ -1,29 +0,0 @@ -# Prefer gems to the bundled libs. -require 'rubygems' - -begin - gem 'builder', '~> 2.1.2' -rescue Gem::LoadError - $:.unshift "#{File.dirname(__FILE__)}/vendor/builder-2.1.2" -end -require 'builder' - -begin - gem 'memcache-client', '>= 1.6.5' -rescue Gem::LoadError - $:.unshift "#{File.dirname(__FILE__)}/vendor/memcache-client-1.6.5" -end - -begin - gem 'tzinfo', '~> 0.3.12' -rescue Gem::LoadError - $:.unshift "#{File.dirname(__FILE__)}/vendor/tzinfo-0.3.12" -end - -# TODO I18n gem has not been released yet -# begin -# gem 'i18n', '~> 0.1.3' -# rescue Gem::LoadError - $:.unshift "#{File.dirname(__FILE__)}/vendor/i18n-0.1.3/lib" - require 'i18n' -# end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/blankslate.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/blankslate.rb deleted file mode 100644 index da6034d..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/blankslate.rb +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env ruby -#-- -# Copyright 2004, 2006 by Jim Weirich (jim@weirichhouse.org). -# All rights reserved. - -# Permission is granted for use, copying, modification, distribution, -# and distribution of modified versions of this work as long as the -# above copyright notice is included. -#++ - -###################################################################### -# BlankSlate provides an abstract base class with no predefined -# methods (except for <tt>\_\_send__</tt> and <tt>\_\_id__</tt>). -# BlankSlate is useful as a base class when writing classes that -# depend upon <tt>method_missing</tt> (e.g. dynamic proxies). -# -class BlankSlate - class << self - - # Hide the method named +name+ in the BlankSlate class. Don't - # hide +instance_eval+ or any method beginning with "__". - def hide(name) - if instance_methods.include?(name.to_s) and - name !~ /^(__|instance_eval)/ - @hidden_methods ||= {} - @hidden_methods[name.to_sym] = instance_method(name) - undef_method name - end - end - - def find_hidden_method(name) - @hidden_methods ||= {} - @hidden_methods[name] || superclass.find_hidden_method(name) - end - - # Redefine a previously hidden method so that it may be called on a blank - # slate object. - def reveal(name) - bound_method = nil - unbound_method = find_hidden_method(name) - fail "Don't know how to reveal method '#{name}'" unless unbound_method - define_method(name) do |*args| - bound_method ||= unbound_method.bind(self) - bound_method.call(*args) - end - end - end - - instance_methods.each { |m| hide(m) } -end - -###################################################################### -# Since Ruby is very dynamic, methods added to the ancestors of -# BlankSlate <em>after BlankSlate is defined</em> will show up in the -# list of available BlankSlate methods. We handle this by defining a -# hook in the Object and Kernel classes that will hide any method -# defined after BlankSlate has been loaded. -# -module Kernel - class << self - alias_method :blank_slate_method_added, :method_added - - # Detect method additions to Kernel and remove them in the - # BlankSlate class. - def method_added(name) - result = blank_slate_method_added(name) - return result if self != Kernel - BlankSlate.hide(name) - result - end - end -end - -###################################################################### -# Same as above, except in Object. -# -class Object - class << self - alias_method :blank_slate_method_added, :method_added - - # Detect method additions to Object and remove them in the - # BlankSlate class. - def method_added(name) - result = blank_slate_method_added(name) - return result if self != Object - BlankSlate.hide(name) - result - end - - def find_hidden_method(name) - nil - end - end -end - -###################################################################### -# Also, modules included into Object need to be scanned and have their -# instance methods removed from blank slate. In theory, modules -# included into Kernel would have to be removed as well, but a -# "feature" of Ruby prevents late includes into modules from being -# exposed in the first place. -# -class Module - alias blankslate_original_append_features append_features - def append_features(mod) - result = blankslate_original_append_features(mod) - return result if mod != Object - instance_methods.each do |name| - BlankSlate.hide(name) - end - result - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder.rb deleted file mode 100644 index 9719277..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder.rb +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env ruby - -#-- -# Copyright 2004 by Jim Weirich (jim@weirichhouse.org). -# All rights reserved. - -# Permission is granted for use, copying, modification, distribution, -# and distribution of modified versions of this work as long as the -# above copyright notice is included. -#++ - -require 'builder/xmlmarkup' -require 'builder/xmlevents' diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb deleted file mode 100644 index 2935b6f..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env ruby -#-- -# Copyright 2004, 2006 by Jim Weirich (jim@weirichhouse.org). -# All rights reserved. - -# Permission is granted for use, copying, modification, distribution, -# and distribution of modified versions of this work as long as the -# above copyright notice is included. -#++ - -require 'blankslate' - -###################################################################### -# BlankSlate has been promoted to a top level name and is now -# available as a standalone gem. We make the name available in the -# Builder namespace for compatibility. -# -module Builder - BlankSlate = ::BlankSlate -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb deleted file mode 100644 index e086a1b..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb +++ /dev/null @@ -1,250 +0,0 @@ -#!/usr/bin/env ruby -#-- -# Copyright 2004, 2005 by Jim Weirich (jim@weirichhouse.org). -# Copyright 2005 by Scott Barron (scott@elitists.net). -# All rights reserved. -# -# Permission is granted for use, copying, modification, distribution, -# and distribution of modified versions of this work as long as the -# above copyright notice is included. -# -# Much of this is taken from Jim's work in xmlbase.rb and xmlmarkup.rb. -# Documentation has also been copied and pasted and modified to reflect -# that we're building CSS here instead of XML. Jim is conducting the -# orchestra here and I'm just off in the corner playing a flute. -#++ - -# Provide a flexible and easy to use Builder for creating Cascading -# Style Sheets (CSS). - - -require 'builder/blankslate' - -module Builder - - # Create a Cascading Style Sheet (CSS) using Ruby. - # - # Example usage: - # - # css = Builder::CSS.new - # - # text_color = '#7F7F7F' - # preferred_fonts = 'Helvetica, Arial, sans_serif' - # - # css.comment! 'This is our stylesheet' - # css.body { - # background_color '#FAFAFA' - # font_size 'small' - # font_family preferred_fonts - # color text_color - # } - # - # css.id!('navbar') { - # width '500px' - # } - # - # css.class!('navitem') { - # color 'red' - # } - # - # css.a :hover { - # text_decoration 'underline' - # } - # - # css.div(:id => 'menu') { - # background 'green' - # } - # - # css.div(:class => 'foo') { - # background 'red' - # } - # - # This will yield the following stylesheet: - # - # /* This is our stylesheet */ - # body { - # background_color: #FAFAFA; - # font_size: small; - # font_family: Helvetica, Arial, sans_serif; - # color: #7F7F7F; - # } - # - # #navbar { - # width: 500px; - # } - # - # .navitem { - # color: red; - # } - # - # a:hover { - # text_decoration: underline; - # } - # - # div#menu { - # background: green; - # } - # - # div.foo { - # background: red; - # } - # - class CSS < BlankSlate - - # Create a CSS builder. - # - # out:: Object receiving the markup.1 +out+ must respond to - # <tt><<</tt>. - # indent:: Number of spaces used for indentation (0 implies no - # indentation and no line breaks). - # - def initialize(indent=2) - @indent = indent - @target = [] - @parts = [] - @library = {} - end - - def +(part) - _join_with_op! '+' - self - end - - def >>(part) - _join_with_op! '' - self - end - - def >(part) - _join_with_op! '>' - self - end - - def |(part) - _join_with_op! ',' - self - end - - # Return the target of the builder - def target! - @target * '' - end - - # Create a comment string in the output. - def comment!(comment_text) - @target << "/* #{comment_text} */\n" - end - - def id!(arg, &block) - _start_container('#'+arg.to_s, nil, block_given?) - _css_block(block) if block - _unify_block - self - end - - def class!(arg, &block) - _start_container('.'+arg.to_s, nil, block_given?) - _css_block(block) if block - _unify_block - self - end - - def store!(sym, &block) - @library[sym] = block.to_proc - end - - def group!(*args, &block) - args.each do |arg| - if arg.is_a?(Symbol) - instance_eval(&@library[arg]) - else - instance_eval(&arg) - end - _text ', ' unless arg == args.last - end - if block - _css_block(block) - _unify_block - end - end - - def method_missing(sym, *args, &block) - sym = "#{sym}:#{args.shift}" if args.first.kind_of?(Symbol) - if block - _start_container(sym, args.first) - _css_block(block) - _unify_block - elsif @in_block - _indent - _css_line(sym, *args) - _newline - return self - else - _start_container(sym, args.first, false) - _unify_block - end - self - end - - # "Cargo culted" from Jim who also "cargo culted" it. See xmlbase.rb. - def nil? - false - end - - private - def _unify_block - @target << @parts * '' - @parts = [] - end - - def _join_with_op!(op) - rhs, lhs = @target.pop, @target.pop - @target << "#{lhs} #{op} #{rhs}" - end - - def _text(text) - @parts << text - end - - def _css_block(block) - _newline - _nested_structures(block) - _end_container - _end_block - end - - def _end_block - _newline - _newline - end - - def _newline - _text "\n" - end - - def _indent - _text ' ' * @indent - end - - def _nested_structures(block) - @in_block = true - self.instance_eval(&block) - @in_block = false - end - - def _start_container(sym, atts = {}, with_bracket = true) - selector = sym.to_s - selector << ".#{atts[:class]}" if atts && atts[:class] - selector << '#' + "#{atts[:id]}" if atts && atts[:id] - @parts << "#{selector}#{with_bracket ? ' {' : ''}" - end - - def _end_container - @parts << "}" - end - - def _css_line(sym, *args) - _text("#{sym.to_s.gsub('_','-')}: #{args * ' '};") - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb deleted file mode 100644 index 8bdbd05..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env ruby - -# The XChar library is provided courtesy of Sam Ruby (See -# http://intertwingly.net/stories/2005/09/28/xchar.rb) - -# -------------------------------------------------------------------- - -# If the Builder::XChar module is not currently defined, fail on any -# name clashes in standard library classes. - -module Builder - def self.check_for_name_collision(klass, method_name, defined_constant=nil) - if klass.instance_methods.include?(method_name.to_s) - fail RuntimeError, - "Name Collision: Method '#{method_name}' is already defined in #{klass}" - end - end -end - -if ! defined?(Builder::XChar) - Builder.check_for_name_collision(String, "to_xs") - Builder.check_for_name_collision(Fixnum, "xchr") -end - -###################################################################### -module Builder - - #################################################################### - # XML Character converter, from Sam Ruby: - # (see http://intertwingly.net/stories/2005/09/28/xchar.rb). - # - module XChar # :nodoc: - - # See - # http://intertwingly.net/stories/2004/04/14/i18n.html#CleaningWindows - # for details. - CP1252 = { # :nodoc: - 128 => 8364, # euro sign - 130 => 8218, # single low-9 quotation mark - 131 => 402, # latin small letter f with hook - 132 => 8222, # double low-9 quotation mark - 133 => 8230, # horizontal ellipsis - 134 => 8224, # dagger - 135 => 8225, # double dagger - 136 => 710, # modifier letter circumflex accent - 137 => 8240, # per mille sign - 138 => 352, # latin capital letter s with caron - 139 => 8249, # single left-pointing angle quotation mark - 140 => 338, # latin capital ligature oe - 142 => 381, # latin capital letter z with caron - 145 => 8216, # left single quotation mark - 146 => 8217, # right single quotation mark - 147 => 8220, # left double quotation mark - 148 => 8221, # right double quotation mark - 149 => 8226, # bullet - 150 => 8211, # en dash - 151 => 8212, # em dash - 152 => 732, # small tilde - 153 => 8482, # trade mark sign - 154 => 353, # latin small letter s with caron - 155 => 8250, # single right-pointing angle quotation mark - 156 => 339, # latin small ligature oe - 158 => 382, # latin small letter z with caron - 159 => 376, # latin capital letter y with diaeresis - } - - # See http://www.w3.org/TR/REC-xml/#dt-chardata for details. - PREDEFINED = { - 38 => '&amp;', # ampersand - 60 => '&lt;', # left angle bracket - 62 => '&gt;', # right angle bracket - } - - # See http://www.w3.org/TR/REC-xml/#charsets for details. - VALID = [ - 0x9, 0xA, 0xD, - (0x20..0xD7FF), - (0xE000..0xFFFD), - (0x10000..0x10FFFF) - ] - end - -end - - -###################################################################### -# Enhance the Fixnum class with a XML escaped character conversion. -# -class Fixnum - XChar = Builder::XChar if ! defined?(XChar) - - # XML escaped version of chr - def xchr - n = XChar::CP1252[self] || self - case n when *XChar::VALID - XChar::PREDEFINED[n] or (n<128 ? n.chr : "&##{n};") - else - '*' - end - end -end - - -###################################################################### -# Enhance the String class with a XML escaped character version of -# to_s. -# -class String - # XML escaped version of to_s - def to_xs - unpack('U*').map {|n| n.xchr}.join # ASCII, UTF-8 - rescue - unpack('C*').map {|n| n.xchr}.join # ISO-8859-1, WIN-1252 - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb deleted file mode 100644 index ace4b56..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb +++ /dev/null @@ -1,139 +0,0 @@ -#!/usr/bin/env ruby - -require 'builder/blankslate' - -module Builder - - # Generic error for builder - class IllegalBlockError < RuntimeError; end - - # XmlBase is a base class for building XML builders. See - # Builder::XmlMarkup and Builder::XmlEvents for examples. - class XmlBase < BlankSlate - - # Create an XML markup builder. - # - # out:: Object receiving the markup. +out+ must respond to - # <tt><<</tt>. - # indent:: Number of spaces used for indentation (0 implies no - # indentation and no line breaks). - # initial:: Level of initial indentation. - # - def initialize(indent=0, initial=0) - @indent = indent - @level = initial - end - - # Create a tag named +sym+. Other than the first argument which - # is the tag name, the arguments are the same as the tags - # implemented via <tt>method_missing</tt>. - def tag!(sym, *args, &block) - method_missing(sym.to_sym, *args, &block) - end - - # Create XML markup based on the name of the method. This method - # is never invoked directly, but is called for each markup method - # in the markup block. - def method_missing(sym, *args, &block) - text = nil - attrs = nil - sym = "#{sym}:#{args.shift}" if args.first.kind_of?(Symbol) - args.each do |arg| - case arg - when Hash - attrs ||= {} - attrs.merge!(arg) - else - text ||= '' - text << arg.to_s - end - end - if block - unless text.nil? - raise ArgumentError, "XmlMarkup cannot mix a text argument with a block" - end - _indent - _start_tag(sym, attrs) - _newline - _nested_structures(block) - _indent - _end_tag(sym) - _newline - elsif text.nil? - _indent - _start_tag(sym, attrs, true) - _newline - else - _indent - _start_tag(sym, attrs) - text! text - _end_tag(sym) - _newline - end - @target - end - - # Append text to the output target. Escape any markup. May be - # used within the markup brackets as: - # - # builder.p { |b| b.br; b.text! "HI" } #=> <p><br/>HI</p> - def text!(text) - _text(_escape(text)) - end - - # Append text to the output target without escaping any markup. - # May be used within the markup brackets as: - # - # builder.p { |x| x << "<br/>HI" } #=> <p><br/>HI</p> - # - # This is useful when using non-builder enabled software that - # generates strings. Just insert the string directly into the - # builder without changing the inserted markup. - # - # It is also useful for stacking builder objects. Builders only - # use <tt><<</tt> to append to the target, so by supporting this - # method/operation builders can use other builders as their - # targets. - def <<(text) - _text(text) - end - - # For some reason, nil? is sent to the XmlMarkup object. If nil? - # is not defined and method_missing is invoked, some strange kind - # of recursion happens. Since nil? won't ever be an XML tag, it - # is pretty safe to define it here. (Note: this is an example of - # cargo cult programming, - # cf. http://fishbowl.pastiche.org/2004/10/13/cargo_cult_programming). - def nil? - false - end - - private - - require 'builder/xchar' - def _escape(text) - text.to_xs - end - - def _escape_quote(text) - _escape(text).gsub(%r{"}, '&quot;') # " WART - end - - def _newline - return if @indent == 0 - text! "\n" - end - - def _indent - return if @indent == 0 || @level == 0 - text!(" " * (@level * @indent)) - end - - def _nested_structures(block) - @level += 1 - block.call(self) - ensure - @level -= 1 - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb deleted file mode 100644 index b373e4d..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env ruby - -#-- -# Copyright 2004 by Jim Weirich (jim@weirichhouse.org). -# All rights reserved. - -# Permission is granted for use, copying, modification, distribution, -# and distribution of modified versions of this work as long as the -# above copyright notice is included. -#++ - -require 'builder/xmlmarkup' - -module Builder - - # Create a series of SAX-like XML events (e.g. start_tag, end_tag) - # from the markup code. XmlEvent objects are used in a way similar - # to XmlMarkup objects, except that a series of events are generated - # and passed to a handler rather than generating character-based - # markup. - # - # Usage: - # xe = Builder::XmlEvents.new(handler) - # xe.title("HI") # Sends start_tag/end_tag/text messages to the handler. - # - # Indentation may also be selected by providing value for the - # indentation size and initial indentation level. - # - # xe = Builder::XmlEvents.new(handler, indent_size, initial_indent_level) - # - # == XML Event Handler - # - # The handler object must expect the following events. - # - # [<tt>start_tag(tag, attrs)</tt>] - # Announces that a new tag has been found. +tag+ is the name of - # the tag and +attrs+ is a hash of attributes for the tag. - # - # [<tt>end_tag(tag)</tt>] - # Announces that an end tag for +tag+ has been found. - # - # [<tt>text(text)</tt>] - # Announces that a string of characters (+text+) has been found. - # A series of characters may be broken up into more than one - # +text+ call, so the client cannot assume that a single - # callback contains all the text data. - # - class XmlEvents < XmlMarkup - def text!(text) - @target.text(text) - end - - def _start_tag(sym, attrs, end_too=false) - @target.start_tag(sym, attrs) - _end_tag(sym) if end_too - end - - def _end_tag(sym) - @target.end_tag(sym) - end - end - -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb b/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb deleted file mode 100644 index ec59ddd..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb +++ /dev/null @@ -1,328 +0,0 @@ -#!/usr/bin/env ruby -#-- -# Copyright 2004, 2005 by Jim Weirich (jim@weirichhouse.org). -# All rights reserved. - -# Permission is granted for use, copying, modification, distribution, -# and distribution of modified versions of this work as long as the -# above copyright notice is included. -#++ - -# Provide a flexible and easy to use Builder for creating XML markup. -# See XmlBuilder for usage details. - -require 'builder/xmlbase' - -module Builder - - # Create XML markup easily. All (well, almost all) methods sent to - # an XmlMarkup object will be translated to the equivalent XML - # markup. Any method with a block will be treated as an XML markup - # tag with nested markup in the block. - # - # Examples will demonstrate this easier than words. In the - # following, +xm+ is an +XmlMarkup+ object. - # - # xm.em("emphasized") # => <em>emphasized</em> - # xm.em { xmm.b("emp & bold") } # => <em><b>emph &amp; bold</b></em> - # xm.a("A Link", "href"=>"http://onestepback.org") - # # => <a href="http://onestepback.org">A Link</a> - # xm.div { br } # => <div><br/></div> - # xm.target("name"=>"compile", "option"=>"fast") - # # => <target option="fast" name="compile"\> - # # NOTE: order of attributes is not specified. - # - # xm.instruct! # <?xml version="1.0" encoding="UTF-8"?> - # xm.html { # <html> - # xm.head { # <head> - # xm.title("History") # <title>History</title> - # } # </head> - # xm.body { # <body> - # xm.comment! "HI" # <! -- HI --> - # xm.h1("Header") # <h1>Header</h1> - # xm.p("paragraph") # <p>paragraph</p> - # } # </body> - # } # </html> - # - # == Notes: - # - # * The order that attributes are inserted in markup tags is - # undefined. - # - # * Sometimes you wish to insert text without enclosing tags. Use - # the <tt>text!</tt> method to accomplish this. - # - # Example: - # - # xm.div { # <div> - # xm.text! "line"; xm.br # line<br/> - # xm.text! "another line"; xmbr # another line<br/> - # } # </div> - # - # * The special XML characters <, >, and & are converted to &lt;, - # &gt; and &amp; automatically. Use the <tt><<</tt> operation to - # insert text without modification. - # - # * Sometimes tags use special characters not allowed in ruby - # identifiers. Use the <tt>tag!</tt> method to handle these - # cases. - # - # Example: - # - # xml.tag!("SOAP:Envelope") { ... } - # - # will produce ... - # - # <SOAP:Envelope> ... </SOAP:Envelope>" - # - # <tt>tag!</tt> will also take text and attribute arguments (after - # the tag name) like normal markup methods. (But see the next - # bullet item for a better way to handle XML namespaces). - # - # * Direct support for XML namespaces is now available. If the - # first argument to a tag call is a symbol, it will be joined to - # the tag to produce a namespace:tag combination. It is easier to - # show this than describe it. - # - # xml.SOAP :Envelope do ... end - # - # Just put a space before the colon in a namespace to produce the - # right form for builder (e.g. "<tt>SOAP:Envelope</tt>" => - # "<tt>xml.SOAP :Envelope</tt>") - # - # * XmlMarkup builds the markup in any object (called a _target_) - # that accepts the <tt><<</tt> method. If no target is given, - # then XmlMarkup defaults to a string target. - # - # Examples: - # - # xm = Builder::XmlMarkup.new - # result = xm.title("yada") - # # result is a string containing the markup. - # - # buffer = "" - # xm = Builder::XmlMarkup.new(buffer) - # # The markup is appended to buffer (using <<) - # - # xm = Builder::XmlMarkup.new(STDOUT) - # # The markup is written to STDOUT (using <<) - # - # xm = Builder::XmlMarkup.new - # x2 = Builder::XmlMarkup.new(:target=>xm) - # # Markup written to +x2+ will be send to +xm+. - # - # * Indentation is enabled by providing the number of spaces to - # indent for each level as a second argument to XmlBuilder.new. - # Initial indentation may be specified using a third parameter. - # - # Example: - # - # xm = Builder.new(:indent=>2) - # # xm will produce nicely formatted and indented XML. - # - # xm = Builder.new(:indent=>2, :margin=>4) - # # xm will produce nicely formatted and indented XML with 2 - # # spaces per indent and an over all indentation level of 4. - # - # builder = Builder::XmlMarkup.new(:target=>$stdout, :indent=>2) - # builder.name { |b| b.first("Jim"); b.last("Weirich) } - # # prints: - # # <name> - # # <first>Jim</first> - # # <last>Weirich</last> - # # </name> - # - # * The instance_eval implementation which forces self to refer to - # the message receiver as self is now obsolete. We now use normal - # block calls to execute the markup block. This means that all - # markup methods must now be explicitly send to the xml builder. - # For instance, instead of - # - # xml.div { strong("text") } - # - # you need to write: - # - # xml.div { xml.strong("text") } - # - # Although more verbose, the subtle change in semantics within the - # block was found to be prone to error. To make this change a - # little less cumbersome, the markup block now gets the markup - # object sent as an argument, allowing you to use a shorter alias - # within the block. - # - # For example: - # - # xml_builder = Builder::XmlMarkup.new - # xml_builder.div { |xml| - # xml.stong("text") - # } - # - class XmlMarkup < XmlBase - - # Create an XML markup builder. Parameters are specified by an - # option hash. - # - # :target=><em>target_object</em>:: - # Object receiving the markup. +out+ must respond to the - # <tt><<</tt> operator. The default is a plain string target. - # - # :indent=><em>indentation</em>:: - # Number of spaces used for indentation. The default is no - # indentation and no line breaks. - # - # :margin=><em>initial_indentation_level</em>:: - # Amount of initial indentation (specified in levels, not - # spaces). - # - # :escape_attrs=><b>OBSOLETE</em>:: - # The :escape_attrs option is no longer supported by builder - # (and will be quietly ignored). String attribute values are - # now automatically escaped. If you need unescaped attribute - # values (perhaps you are using entities in the attribute - # values), then give the value as a Symbol. This allows much - # finer control over escaping attribute values. - # - def initialize(options={}) - indent = options[:indent] || 0 - margin = options[:margin] || 0 - super(indent, margin) - @target = options[:target] || "" - end - - # Return the target of the builder. - def target! - @target - end - - def comment!(comment_text) - _ensure_no_block block_given? - _special("<!-- ", " -->", comment_text, nil) - end - - # Insert an XML declaration into the XML markup. - # - # For example: - # - # xml.declare! :ELEMENT, :blah, "yada" - # # => <!ELEMENT blah "yada"> - def declare!(inst, *args, &block) - _indent - @target << "<!#{inst}" - args.each do |arg| - case arg - when String - @target << %{ "#{arg}"} # " WART - when Symbol - @target << " #{arg}" - end - end - if block_given? - @target << " [" - _newline - _nested_structures(block) - @target << "]" - end - @target << ">" - _newline - end - - # Insert a processing instruction into the XML markup. E.g. - # - # For example: - # - # xml.instruct! - # #=> <?xml version="1.0" encoding="UTF-8"?> - # xml.instruct! :aaa, :bbb=>"ccc" - # #=> <?aaa bbb="ccc"?> - # - def instruct!(directive_tag=:xml, attrs={}) - _ensure_no_block block_given? - if directive_tag == :xml - a = { :version=>"1.0", :encoding=>"UTF-8" } - attrs = a.merge attrs - end - _special( - "<?#{directive_tag}", - "?>", - nil, - attrs, - [:version, :encoding, :standalone]) - end - - # Insert a CDATA section into the XML markup. - # - # For example: - # - # xml.cdata!("text to be included in cdata") - # #=> <![CDATA[text to be included in cdata]]> - # - def cdata!(text) - _ensure_no_block block_given? - _special("<![CDATA[", "]]>", text, nil) - end - - private - - # NOTE: All private methods of a builder object are prefixed when - # a "_" character to avoid possible conflict with XML tag names. - - # Insert text directly in to the builder's target. - def _text(text) - @target << text - end - - # Insert special instruction. - def _special(open, close, data=nil, attrs=nil, order=[]) - _indent - @target << open - @target << data if data - _insert_attributes(attrs, order) if attrs - @target << close - _newline - end - - # Start an XML tag. If <tt>end_too</tt> is true, then the start - # tag is also the end tag (e.g. <br/> - def _start_tag(sym, attrs, end_too=false) - @target << "<#{sym}" - _insert_attributes(attrs) - @target << "/" if end_too - @target << ">" - end - - # Insert an ending tag. - def _end_tag(sym) - @target << "</#{sym}>" - end - - # Insert the attributes (given in the hash). - def _insert_attributes(attrs, order=[]) - return if attrs.nil? - order.each do |k| - v = attrs[k] - @target << %{ #{k}="#{_attr_value(v)}"} if v # " WART - end - attrs.each do |k, v| - @target << %{ #{k}="#{_attr_value(v)}"} unless order.member?(k) # " WART - end - end - - def _attr_value(value) - case value - when Symbol - value.to_s - else - _escape_quote(value.to_s) - end - end - - def _ensure_no_block(got_block) - if got_block - fail IllegalBlockError, - "Blocks are not allowed on XML instructions" - end - end - - end - -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE deleted file mode 100755 index ed8e9ee..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2008 The Ruby I18n team - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/README.textile b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/README.textile deleted file mode 100644 index a07fc84..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/README.textile +++ /dev/null @@ -1,20 +0,0 @@ -h1. Ruby I18n gem - -I18n and localization solution for Ruby. - -For information please refer to http://rails-i18n.org - -h2. Authors - -* "Matt Aimonetti":http://railsontherun.com -* "Sven Fuchs":http://www.artweb-design.de -* "Joshua Harvey":http://www.workingwithrails.com/person/759-joshua-harvey -* "Saimon Moore":http://saimonmoore.net -* "Stephan Soller":http://www.arkanis-development.de - -h2. License - -MIT License. See the included MIT-LICENCE file. - - - diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/Rakefile b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/Rakefile deleted file mode 100644 index 2164e13..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/Rakefile +++ /dev/null @@ -1,5 +0,0 @@ -task :default => [:test] - -task :test do - ruby "test/all.rb" -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec deleted file mode 100644 index f102689..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +++ /dev/null @@ -1,27 +0,0 @@ -Gem::Specification.new do |s| - s.name = "i18n" - s.version = "0.1.3" - s.date = "2009-01-09" - s.summary = "Internationalization support for Ruby" - s.email = "rails-i18n@googlegroups.com" - s.homepage = "http://rails-i18n.org" - s.description = "Add Internationalization support to your Ruby application." - s.has_rdoc = false - s.authors = ['Sven Fuchs', 'Joshua Harvey', 'Matt Aimonetti', 'Stephan Soller', 'Saimon Moore'] - s.files = [ - 'i18n.gemspec', - 'lib/i18n/backend/simple.rb', - 'lib/i18n/exceptions.rb', - 'lib/i18n.rb', - 'MIT-LICENSE', - 'README.textile' - ] - s.test_files = [ - 'test/all.rb', - 'test/i18n_exceptions_test.rb', - 'test/i18n_test.rb', - 'test/locale/en.rb', - 'test/locale/en.yml', - 'test/simple_backend_test.rb' - ] -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb deleted file mode 100755 index 76361be..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +++ /dev/null @@ -1,199 +0,0 @@ -# Authors:: Matt Aimonetti (http://railsontherun.com/), -# Sven Fuchs (http://www.artweb-design.de), -# Joshua Harvey (http://www.workingwithrails.com/person/759-joshua-harvey), -# Saimon Moore (http://saimonmoore.net), -# Stephan Soller (http://www.arkanis-development.de/) -# Copyright:: Copyright (c) 2008 The Ruby i18n Team -# License:: MIT -require 'i18n/backend/simple' -require 'i18n/exceptions' - -module I18n - @@backend = nil - @@load_path = nil - @@default_locale = :'en' - @@exception_handler = :default_exception_handler - - class << self - # Returns the current backend. Defaults to +Backend::Simple+. - def backend - @@backend ||= Backend::Simple.new - end - - # Sets the current backend. Used to set a custom backend. - def backend=(backend) - @@backend = backend - end - - # Returns the current default locale. Defaults to :'en' - def default_locale - @@default_locale - end - - # Sets the current default locale. Used to set a custom default locale. - def default_locale=(locale) - @@default_locale = locale - end - - # Returns the current locale. Defaults to I18n.default_locale. - def locale - Thread.current[:locale] ||= default_locale - end - - # Sets the current locale pseudo-globally, i.e. in the Thread.current hash. - def locale=(locale) - Thread.current[:locale] = locale - end - - # Returns an array of locales for which translations are available - def available_locales - backend.available_locales - end - - # Sets the exception handler. - def exception_handler=(exception_handler) - @@exception_handler = exception_handler - end - - # Allow clients to register paths providing translation data sources. The - # backend defines acceptable sources. - # - # E.g. the provided SimpleBackend accepts a list of paths to translation - # files which are either named *.rb and contain plain Ruby Hashes or are - # named *.yml and contain YAML data. So for the SimpleBackend clients may - # register translation files like this: - # I18n.load_path << 'path/to/locale/en.yml' - def load_path - @@load_path ||= [] - end - - # Sets the load path instance. Custom implementations are expected to - # behave like a Ruby Array. - def load_path=(load_path) - @@load_path = load_path - end - - # Tells the backend to reload translations. Used in situations like the - # Rails development environment. Backends can implement whatever strategy - # is useful. - def reload! - backend.reload! - end - - # Translates, pluralizes and interpolates a given key using a given locale, - # scope, and default, as well as interpolation values. - # - # *LOOKUP* - # - # Translation data is organized as a nested hash using the upper-level keys - # as namespaces. <em>E.g.</em>, ActionView ships with the translation: - # <tt>:date => {:formats => {:short => "%b %d"}}</tt>. - # - # Translations can be looked up at any level of this hash using the key argument - # and the scope option. <em>E.g.</em>, in this example <tt>I18n.t :date</tt> - # returns the whole translations hash <tt>{:formats => {:short => "%b %d"}}</tt>. - # - # Key can be either a single key or a dot-separated key (both Strings and Symbols - # work). <em>E.g.</em>, the short format can be looked up using both: - # I18n.t 'date.formats.short' - # I18n.t :'date.formats.short' - # - # Scope can be either a single key, a dot-separated key or an array of keys - # or dot-separated keys. Keys and scopes can be combined freely. So these - # examples will all look up the same short date format: - # I18n.t 'date.formats.short' - # I18n.t 'formats.short', :scope => 'date' - # I18n.t 'short', :scope => 'date.formats' - # I18n.t 'short', :scope => %w(date formats) - # - # *INTERPOLATION* - # - # Translations can contain interpolation variables which will be replaced by - # values passed to #translate as part of the options hash, with the keys matching - # the interpolation variable names. - # - # <em>E.g.</em>, with a translation <tt>:foo => "foo {{bar}}"</tt> the option - # value for the key +bar+ will be interpolated into the translation: - # I18n.t :foo, :bar => 'baz' # => 'foo baz' - # - # *PLURALIZATION* - # - # Translation data can contain pluralized translations. Pluralized translations - # are arrays of singluar/plural versions of translations like <tt>['Foo', 'Foos']</tt>. - # - # Note that <tt>I18n::Backend::Simple</tt> only supports an algorithm for English - # pluralization rules. Other algorithms can be supported by custom backends. - # - # This returns the singular version of a pluralized translation: - # I18n.t :foo, :count => 1 # => 'Foo' - # - # These both return the plural version of a pluralized translation: - # I18n.t :foo, :count => 0 # => 'Foos' - # I18n.t :foo, :count => 2 # => 'Foos' - # - # The <tt>:count</tt> option can be used both for pluralization and interpolation. - # <em>E.g.</em>, with the translation - # <tt>:foo => ['{{count}} foo', '{{count}} foos']</tt>, count will - # be interpolated to the pluralized translation: - # I18n.t :foo, :count => 1 # => '1 foo' - # - # *DEFAULTS* - # - # This returns the translation for <tt>:foo</tt> or <tt>default</tt> if no translation was found: - # I18n.t :foo, :default => 'default' - # - # This returns the translation for <tt>:foo</tt> or the translation for <tt>:bar</tt> if no - # translation for <tt>:foo</tt> was found: - # I18n.t :foo, :default => :bar - # - # Returns the translation for <tt>:foo</tt> or the translation for <tt>:bar</tt> - # or <tt>default</tt> if no translations for <tt>:foo</tt> and <tt>:bar</tt> were found. - # I18n.t :foo, :default => [:bar, 'default'] - # - # <b>BULK LOOKUP</b> - # - # This returns an array with the translations for <tt>:foo</tt> and <tt>:bar</tt>. - # I18n.t [:foo, :bar] - # - # Can be used with dot-separated nested keys: - # I18n.t [:'baz.foo', :'baz.bar'] - # - # Which is the same as using a scope option: - # I18n.t [:foo, :bar], :scope => :baz - def translate(key, options = {}) - locale = options.delete(:locale) || I18n.locale - backend.translate(locale, key, options) - rescue I18n::ArgumentError => e - raise e if options[:raise] - send(@@exception_handler, e, locale, key, options) - end - alias :t :translate - - # Localizes certain objects, such as dates and numbers to local formatting. - def localize(object, options = {}) - locale = options[:locale] || I18n.locale - format = options[:format] || :default - backend.localize(locale, object, format) - end - alias :l :localize - - protected - # Handles exceptions raised in the backend. All exceptions except for - # MissingTranslationData exceptions are re-raised. When a MissingTranslationData - # was caught and the option :raise is not set the handler returns an error - # message string containing the key/scope. - def default_exception_handler(exception, locale, key, options) - return exception.message if MissingTranslationData === exception - raise exception - end - - # Merges the given locale, key and scope into a single array of keys. - # Splits keys that contain dots into multiple keys. Makes sure all - # keys are Symbols. - def normalize_translation_keys(locale, key, scope) - keys = [locale] + Array(scope) + [key] - keys = keys.map { |k| k.to_s.split(/\./) } - keys.flatten.map { |k| k.to_sym } - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb deleted file mode 100644 index c09acd7..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +++ /dev/null @@ -1,214 +0,0 @@ -require 'yaml' - -module I18n - module Backend - class Simple - INTERPOLATION_RESERVED_KEYS = %w(scope default) - MATCH = /(\\\\)?\{\{([^\}]+)\}\}/ - - # Accepts a list of paths to translation files. Loads translations from - # plain Ruby (*.rb) or YAML files (*.yml). See #load_rb and #load_yml - # for details. - def load_translations(*filenames) - filenames.each { |filename| load_file(filename) } - end - - # Stores translations for the given locale in memory. - # This uses a deep merge for the translations hash, so existing - # translations will be overwritten by new ones only at the deepest - # level of the hash. - def store_translations(locale, data) - merge_translations(locale, data) - end - - def translate(locale, key, options = {}) - raise InvalidLocale.new(locale) if locale.nil? - return key.map { |k| translate(locale, k, options) } if key.is_a? Array - - reserved = :scope, :default - count, scope, default = options.values_at(:count, *reserved) - options.delete(:default) - values = options.reject { |name, value| reserved.include?(name) } - - entry = lookup(locale, key, scope) - if entry.nil? - entry = default(locale, default, options) - if entry.nil? - raise(I18n::MissingTranslationData.new(locale, key, options)) - end - end - entry = pluralize(locale, entry, count) - entry = interpolate(locale, entry, values) - entry - end - - # Acts the same as +strftime+, but returns a localized version of the - # formatted date string. Takes a key from the date/time formats - # translations as a format argument (<em>e.g.</em>, <tt>:short</tt> in <tt>:'date.formats'</tt>). - def localize(locale, object, format = :default) - raise ArgumentError, "Object must be a Date, DateTime or Time object. #{object.inspect} given." unless object.respond_to?(:strftime) - - type = object.respond_to?(:sec) ? 'time' : 'date' - # TODO only translate these if format is a String? - formats = translate(locale, :"#{type}.formats") - format = formats[format.to_sym] if formats && formats[format.to_sym] - # TODO raise exception unless format found? - format = format.to_s.dup - - # TODO only translate these if the format string is actually present - # TODO check which format strings are present, then bulk translate then, then replace them - format.gsub!(/%a/, translate(locale, :"date.abbr_day_names")[object.wday]) - format.gsub!(/%A/, translate(locale, :"date.day_names")[object.wday]) - format.gsub!(/%b/, translate(locale, :"date.abbr_month_names")[object.mon]) - format.gsub!(/%B/, translate(locale, :"date.month_names")[object.mon]) - format.gsub!(/%p/, translate(locale, :"time.#{object.hour < 12 ? :am : :pm}")) if object.respond_to? :hour - object.strftime(format) - end - - def initialized? - @initialized ||= false - end - - # Returns an array of locales for which translations are available - def available_locales - init_translations unless initialized? - translations.keys - end - - def reload! - @initialized = false - @translations = nil - end - - protected - def init_translations - load_translations(*I18n.load_path.flatten) - @initialized = true - end - - def translations - @translations ||= {} - end - - # Looks up a translation from the translations hash. Returns nil if - # eiher key is nil, or locale, scope or key do not exist as a key in the - # nested translations hash. Splits keys or scopes containing dots - # into multiple keys, i.e. <tt>currency.format</tt> is regarded the same as - # <tt>%w(currency format)</tt>. - def lookup(locale, key, scope = []) - return unless key - init_translations unless initialized? - keys = I18n.send(:normalize_translation_keys, locale, key, scope) - keys.inject(translations) do |result, k| - if (x = result[k.to_sym]).nil? - return nil - else - x - end - end - end - - # Evaluates a default translation. - # If the given default is a String it is used literally. If it is a Symbol - # it will be translated with the given options. If it is an Array the first - # translation yielded will be returned. - # - # <em>I.e.</em>, <tt>default(locale, [:foo, 'default'])</tt> will return +default+ if - # <tt>translate(locale, :foo)</tt> does not yield a result. - def default(locale, default, options = {}) - case default - when String then default - when Symbol then translate locale, default, options - when Array then default.each do |obj| - result = default(locale, obj, options.dup) and return result - end and nil - end - rescue MissingTranslationData - nil - end - - # Picks a translation from an array according to English pluralization - # rules. It will pick the first translation if count is not equal to 1 - # and the second translation if it is equal to 1. Other backends can - # implement more flexible or complex pluralization rules. - def pluralize(locale, entry, count) - return entry unless entry.is_a?(Hash) and count - # raise InvalidPluralizationData.new(entry, count) unless entry.is_a?(Hash) - key = :zero if count == 0 && entry.has_key?(:zero) - key ||= count == 1 ? :one : :other - raise InvalidPluralizationData.new(entry, count) unless entry.has_key?(key) - entry[key] - end - - # Interpolates values into a given string. - # - # interpolate "file {{file}} opened by \\{{user}}", :file => 'test.txt', :user => 'Mr. X' - # # => "file test.txt opened by {{user}}" - # - # Note that you have to double escape the <tt>\\</tt> when you want to escape - # the <tt>{{...}}</tt> key in a string (once for the string and once for the - # interpolation). - def interpolate(locale, string, values = {}) - return string unless string.is_a?(String) - - string.gsub(MATCH) do - escaped, pattern, key = $1, $2, $2.to_sym - - if escaped - pattern - elsif INTERPOLATION_RESERVED_KEYS.include?(pattern) - raise ReservedInterpolationKey.new(pattern, string) - elsif !values.include?(key) - raise MissingInterpolationArgument.new(pattern, string) - else - values[key].to_s - end - end - end - - # Loads a single translations file by delegating to #load_rb or - # #load_yml depending on the file extension and directly merges the - # data to the existing translations. Raises I18n::UnknownFileType - # for all other file extensions. - def load_file(filename) - type = File.extname(filename).tr('.', '').downcase - raise UnknownFileType.new(type, filename) unless respond_to?(:"load_#{type}") - data = send :"load_#{type}", filename # TODO raise a meaningful exception if this does not yield a Hash - data.each { |locale, d| merge_translations(locale, d) } - end - - # Loads a plain Ruby translations file. eval'ing the file must yield - # a Hash containing translation data with locales as toplevel keys. - def load_rb(filename) - eval(IO.read(filename), binding, filename) - end - - # Loads a YAML translations file. The data must have locales as - # toplevel keys. - def load_yml(filename) - YAML::load(IO.read(filename)) - end - - # Deep merges the given translations hash with the existing translations - # for the given locale - def merge_translations(locale, data) - locale = locale.to_sym - translations[locale] ||= {} - data = deep_symbolize_keys(data) - - # deep_merge by Stefan Rusterholz, see http://www.ruby-forum.com/topic/142809 - merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 } - translations[locale].merge!(data, &merger) - end - - # Return a new hash with all keys and nested keys converted to symbols. - def deep_symbolize_keys(hash) - hash.inject({}) { |result, (key, value)| - value = deep_symbolize_keys(value) if value.is_a? Hash - result[(key.to_sym rescue key) || key] = value - result - } - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb deleted file mode 100644 index b5cea7a..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +++ /dev/null @@ -1,53 +0,0 @@ -module I18n - class ArgumentError < ::ArgumentError; end - - class InvalidLocale < ArgumentError - attr_reader :locale - def initialize(locale) - @locale = locale - super "#{locale.inspect} is not a valid locale" - end - end - - class MissingTranslationData < ArgumentError - attr_reader :locale, :key, :options - def initialize(locale, key, options) - @key, @locale, @options = key, locale, options - keys = I18n.send(:normalize_translation_keys, locale, key, options[:scope]) - keys << 'no key' if keys.size < 2 - super "translation missing: #{keys.join(', ')}" - end - end - - class InvalidPluralizationData < ArgumentError - attr_reader :entry, :count - def initialize(entry, count) - @entry, @count = entry, count - super "translation data #{entry.inspect} can not be used with :count => #{count}" - end - end - - class MissingInterpolationArgument < ArgumentError - attr_reader :key, :string - def initialize(key, string) - @key, @string = key, string - super "interpolation argument #{key} missing in #{string.inspect}" - end - end - - class ReservedInterpolationKey < ArgumentError - attr_reader :key, :string - def initialize(key, string) - @key, @string = key, string - super "reserved key #{key.inspect} used in #{string.inspect}" - end - end - - class UnknownFileType < ArgumentError - attr_reader :type, :filename - def initialize(type, filename) - @type, @filename = type, filename - super "can not load translations from #{filename}, the file type #{type} is not known" - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/all.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/all.rb deleted file mode 100644 index 353712d..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/all.rb +++ /dev/null @@ -1,5 +0,0 @@ -dir = File.dirname(__FILE__) -require dir + '/i18n_test.rb' -require dir + '/simple_backend_test.rb' -require dir + '/i18n_exceptions_test.rb' -# *require* dir + '/custom_backend_test.rb' \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb deleted file mode 100644 index dfcba69..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +++ /dev/null @@ -1,100 +0,0 @@ -$:.unshift "lib" - -require 'rubygems' -require 'test/unit' -require 'mocha' -require 'i18n' -require 'active_support' - -class I18nExceptionsTest < Test::Unit::TestCase - def test_invalid_locale_stores_locale - force_invalid_locale - rescue I18n::ArgumentError => e - assert_nil e.locale - end - - def test_invalid_locale_message - force_invalid_locale - rescue I18n::ArgumentError => e - assert_equal 'nil is not a valid locale', e.message - end - - def test_missing_translation_data_stores_locale_key_and_options - force_missing_translation_data - rescue I18n::ArgumentError => e - options = {:scope => :bar} - assert_equal 'de', e.locale - assert_equal :foo, e.key - assert_equal options, e.options - end - - def test_missing_translation_data_message - force_missing_translation_data - rescue I18n::ArgumentError => e - assert_equal 'translation missing: de, bar, foo', e.message - end - - def test_invalid_pluralization_data_stores_entry_and_count - force_invalid_pluralization_data - rescue I18n::ArgumentError => e - assert_equal [:bar], e.entry - assert_equal 1, e.count - end - - def test_invalid_pluralization_data_message - force_invalid_pluralization_data - rescue I18n::ArgumentError => e - assert_equal 'translation data [:bar] can not be used with :count => 1', e.message - end - - def test_missing_interpolation_argument_stores_key_and_string - force_missing_interpolation_argument - rescue I18n::ArgumentError => e - assert_equal 'bar', e.key - assert_equal "{{bar}}", e.string - end - - def test_missing_interpolation_argument_message - force_missing_interpolation_argument - rescue I18n::ArgumentError => e - assert_equal 'interpolation argument bar missing in "{{bar}}"', e.message - end - - def test_reserved_interpolation_key_stores_key_and_string - force_reserved_interpolation_key - rescue I18n::ArgumentError => e - assert_equal 'scope', e.key - assert_equal "{{scope}}", e.string - end - - def test_reserved_interpolation_key_message - force_reserved_interpolation_key - rescue I18n::ArgumentError => e - assert_equal 'reserved key "scope" used in "{{scope}}"', e.message - end - - private - def force_invalid_locale - I18n.backend.translate nil, :foo - end - - def force_missing_translation_data - I18n.backend.store_translations 'de', :bar => nil - I18n.backend.translate 'de', :foo, :scope => :bar - end - - def force_invalid_pluralization_data - I18n.backend.store_translations 'de', :foo => [:bar] - I18n.backend.translate 'de', :foo, :count => 1 - end - - def force_missing_interpolation_argument - I18n.backend.store_translations 'de', :foo => "{{bar}}" - I18n.backend.translate 'de', :foo, :baz => 'baz' - end - - def force_reserved_interpolation_key - I18n.backend.store_translations 'de', :foo => "{{scope}}" - I18n.backend.translate 'de', :foo, :baz => 'baz' - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb deleted file mode 100644 index 50d6832..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +++ /dev/null @@ -1,125 +0,0 @@ -$:.unshift "lib" - -require 'rubygems' -require 'test/unit' -require 'mocha' -require 'i18n' -require 'active_support' - -class I18nTest < Test::Unit::TestCase - def setup - I18n.backend.store_translations :'en', { - :currency => { - :format => { - :separator => '.', - :delimiter => ',', - } - } - } - end - - def test_uses_simple_backend_set_by_default - assert I18n.backend.is_a?(I18n::Backend::Simple) - end - - def test_can_set_backend - assert_nothing_raised{ I18n.backend = self } - assert_equal self, I18n.backend - I18n.backend = I18n::Backend::Simple.new - end - - def test_uses_en_us_as_default_locale_by_default - assert_equal 'en', I18n.default_locale - end - - def test_can_set_default_locale - assert_nothing_raised{ I18n.default_locale = 'de' } - assert_equal 'de', I18n.default_locale - I18n.default_locale = 'en' - end - - def test_uses_default_locale_as_locale_by_default - assert_equal I18n.default_locale, I18n.locale - end - - def test_can_set_locale_to_thread_current - assert_nothing_raised{ I18n.locale = 'de' } - assert_equal 'de', I18n.locale - assert_equal 'de', Thread.current[:locale] - I18n.locale = 'en' - end - - def test_can_set_exception_handler - assert_nothing_raised{ I18n.exception_handler = :custom_exception_handler } - I18n.exception_handler = :default_exception_handler # revert it - end - - def test_uses_custom_exception_handler - I18n.exception_handler = :custom_exception_handler - I18n.expects(:custom_exception_handler) - I18n.translate :bogus - I18n.exception_handler = :default_exception_handler # revert it - end - - def test_delegates_translate_to_backend - I18n.backend.expects(:translate).with 'de', :foo, {} - I18n.translate :foo, :locale => 'de' - end - - def test_delegates_localize_to_backend - I18n.backend.expects(:localize).with 'de', :whatever, :default - I18n.localize :whatever, :locale => 'de' - end - - def test_translate_given_no_locale_uses_i18n_locale - I18n.backend.expects(:translate).with 'en', :foo, {} - I18n.translate :foo - end - - def test_translate_on_nested_symbol_keys_works - assert_equal ".", I18n.t(:'currency.format.separator') - end - - def test_translate_with_nested_string_keys_works - assert_equal ".", I18n.t('currency.format.separator') - end - - def test_translate_with_array_as_scope_works - assert_equal ".", I18n.t(:separator, :scope => ['currency.format']) - end - - def test_translate_with_array_containing_dot_separated_strings_as_scope_works - assert_equal ".", I18n.t(:separator, :scope => ['currency.format']) - end - - def test_translate_with_key_array_and_dot_separated_scope_works - assert_equal [".", ","], I18n.t(%w(separator delimiter), :scope => 'currency.format') - end - - def test_translate_with_dot_separated_key_array_and_scope_works - assert_equal [".", ","], I18n.t(%w(format.separator format.delimiter), :scope => 'currency') - end - - def test_translate_with_options_using_scope_works - I18n.backend.expects(:translate).with('de', :precision, :scope => :"currency.format") - I18n.with_options :locale => 'de', :scope => :'currency.format' do |locale| - locale.t :precision - end - end - - # def test_translate_given_no_args_raises_missing_translation_data - # assert_equal "translation missing: en, no key", I18n.t - # end - - def test_translate_given_a_bogus_key_raises_missing_translation_data - assert_equal "translation missing: en, bogus", I18n.t(:bogus) - end - - def test_localize_nil_raises_argument_error - assert_raise(I18n::ArgumentError) { I18n.l nil } - end - - def test_localize_object_raises_argument_error - assert_raise(I18n::ArgumentError) { I18n.l Object.new } - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb deleted file mode 100644 index 6044ce1..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +++ /dev/null @@ -1 +0,0 @@ -{:'en-Ruby' => {:foo => {:bar => "baz"}}} \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml deleted file mode 100644 index 0b298c9..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +++ /dev/null @@ -1,3 +0,0 @@ -en-Yaml: - foo: - bar: baz \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb b/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb deleted file mode 100644 index 65f3ac1..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +++ /dev/null @@ -1,568 +0,0 @@ -# encoding: utf-8 -$:.unshift "lib" - -require 'rubygems' -require 'test/unit' -require 'mocha' -require 'i18n' -require 'time' -require 'yaml' - -module I18nSimpleBackendTestSetup - def setup_backend - # backend_reset_translations! - @backend = I18n::Backend::Simple.new - @backend.store_translations 'en', :foo => {:bar => 'bar', :baz => 'baz'} - @locale_dir = File.dirname(__FILE__) + '/locale' - end - alias :setup :setup_backend - - # def backend_reset_translations! - # I18n::Backend::Simple::ClassMethods.send :class_variable_set, :@@translations, {} - # end - - def backend_get_translations - # I18n::Backend::Simple::ClassMethods.send :class_variable_get, :@@translations - @backend.instance_variable_get :@translations - end - - def add_datetime_translations - @backend.store_translations :'de', { - :date => { - :formats => { - :default => "%d.%m.%Y", - :short => "%d. %b", - :long => "%d. %B %Y", - }, - :day_names => %w(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag), - :abbr_day_names => %w(So Mo Di Mi Do Fr Sa), - :month_names => %w(Januar Februar März April Mai Juni Juli August September Oktober November Dezember).unshift(nil), - :abbr_month_names => %w(Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez).unshift(nil), - :order => [:day, :month, :year] - }, - :time => { - :formats => { - :default => "%a, %d. %b %Y %H:%M:%S %z", - :short => "%d. %b %H:%M", - :long => "%d. %B %Y %H:%M", - }, - :am => 'am', - :pm => 'pm' - }, - :datetime => { - :distance_in_words => { - :half_a_minute => 'half a minute', - :less_than_x_seconds => { - :one => 'less than 1 second', - :other => 'less than {{count}} seconds' - }, - :x_seconds => { - :one => '1 second', - :other => '{{count}} seconds' - }, - :less_than_x_minutes => { - :one => 'less than a minute', - :other => 'less than {{count}} minutes' - }, - :x_minutes => { - :one => '1 minute', - :other => '{{count}} minutes' - }, - :about_x_hours => { - :one => 'about 1 hour', - :other => 'about {{count}} hours' - }, - :x_days => { - :one => '1 day', - :other => '{{count}} days' - }, - :about_x_months => { - :one => 'about 1 month', - :other => 'about {{count}} months' - }, - :x_months => { - :one => '1 month', - :other => '{{count}} months' - }, - :about_x_years => { - :one => 'about 1 year', - :other => 'about {{count}} year' - }, - :over_x_years => { - :one => 'over 1 year', - :other => 'over {{count}} years' - } - } - } - } - end -end - -class I18nSimpleBackendTranslationsTest < Test::Unit::TestCase - include I18nSimpleBackendTestSetup - - def test_store_translations_adds_translations # no, really :-) - @backend.store_translations :'en', :foo => 'bar' - assert_equal Hash[:'en', {:foo => 'bar'}], backend_get_translations - end - - def test_store_translations_deep_merges_translations - @backend.store_translations :'en', :foo => {:bar => 'bar'} - @backend.store_translations :'en', :foo => {:baz => 'baz'} - assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], backend_get_translations - end - - def test_store_translations_forces_locale_to_sym - @backend.store_translations 'en', :foo => 'bar' - assert_equal Hash[:'en', {:foo => 'bar'}], backend_get_translations - end - - def test_store_translations_converts_keys_to_symbols - # backend_reset_translations! - @backend.store_translations 'en', 'foo' => {'bar' => 'bar', 'baz' => 'baz'} - assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], backend_get_translations - end -end - -class I18nSimpleBackendAvailableLocalesTest < Test::Unit::TestCase - def test_available_locales - @backend = I18n::Backend::Simple.new - @backend.store_translations 'de', :foo => 'bar' - @backend.store_translations 'en', :foo => 'foo' - - assert_equal ['de', 'en'], @backend.available_locales.map{|locale| locale.to_s }.sort - end -end - -class I18nSimpleBackendTranslateTest < Test::Unit::TestCase - include I18nSimpleBackendTestSetup - - def test_translate_calls_lookup_with_locale_given - @backend.expects(:lookup).with('de', :bar, [:foo]).returns 'bar' - @backend.translate 'de', :bar, :scope => [:foo] - end - - def test_given_no_keys_it_returns_the_default - assert_equal 'default', @backend.translate('en', nil, :default => 'default') - end - - def test_translate_given_a_symbol_as_a_default_translates_the_symbol - assert_equal 'bar', @backend.translate('en', nil, :scope => [:foo], :default => :bar) - end - - def test_translate_given_an_array_as_default_uses_the_first_match - assert_equal 'bar', @backend.translate('en', :does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :bar]) - end - - def test_translate_given_an_array_of_inexistent_keys_it_raises_missing_translation_data - assert_raise I18n::MissingTranslationData do - @backend.translate('en', :does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :does_not_exist_3]) - end - end - - def test_translate_an_array_of_keys_translates_all_of_them - assert_equal %w(bar baz), @backend.translate('en', [:bar, :baz], :scope => [:foo]) - end - - def test_translate_calls_pluralize - @backend.expects(:pluralize).with 'en', 'bar', 1 - @backend.translate 'en', :bar, :scope => [:foo], :count => 1 - end - - def test_translate_calls_interpolate - @backend.expects(:interpolate).with 'en', 'bar', {} - @backend.translate 'en', :bar, :scope => [:foo] - end - - def test_translate_calls_interpolate_including_count_as_a_value - @backend.expects(:interpolate).with 'en', 'bar', {:count => 1} - @backend.translate 'en', :bar, :scope => [:foo], :count => 1 - end - - def test_translate_given_nil_as_a_locale_raises_an_argument_error - assert_raise(I18n::InvalidLocale){ @backend.translate nil, :bar } - end - - def test_translate_with_a_bogus_key_and_no_default_raises_missing_translation_data - assert_raise(I18n::MissingTranslationData){ @backend.translate 'de', :bogus } - end -end - -class I18nSimpleBackendLookupTest < Test::Unit::TestCase - include I18nSimpleBackendTestSetup - - # useful because this way we can use the backend with no key for interpolation/pluralization - def test_lookup_given_nil_as_a_key_returns_nil - assert_nil @backend.send(:lookup, 'en', nil) - end - - def test_lookup_given_nested_keys_looks_up_a_nested_hash_value - assert_equal 'bar', @backend.send(:lookup, 'en', :bar, [:foo]) - end -end - -class I18nSimpleBackendPluralizeTest < Test::Unit::TestCase - include I18nSimpleBackendTestSetup - - def test_pluralize_given_nil_returns_the_given_entry - entry = {:one => 'bar', :other => 'bars'} - assert_equal entry, @backend.send(:pluralize, nil, entry, nil) - end - - def test_pluralize_given_0_returns_zero_string_if_zero_key_given - assert_equal 'zero', @backend.send(:pluralize, nil, {:zero => 'zero', :one => 'bar', :other => 'bars'}, 0) - end - - def test_pluralize_given_0_returns_plural_string_if_no_zero_key_given - assert_equal 'bars', @backend.send(:pluralize, nil, {:one => 'bar', :other => 'bars'}, 0) - end - - def test_pluralize_given_1_returns_singular_string - assert_equal 'bar', @backend.send(:pluralize, nil, {:one => 'bar', :other => 'bars'}, 1) - end - - def test_pluralize_given_2_returns_plural_string - assert_equal 'bars', @backend.send(:pluralize, nil, {:one => 'bar', :other => 'bars'}, 2) - end - - def test_pluralize_given_3_returns_plural_string - assert_equal 'bars', @backend.send(:pluralize, nil, {:one => 'bar', :other => 'bars'}, 3) - end - - def test_interpolate_given_incomplete_pluralization_data_raises_invalid_pluralization_data - assert_raise(I18n::InvalidPluralizationData){ @backend.send(:pluralize, nil, {:one => 'bar'}, 2) } - end - - # def test_interpolate_given_a_string_raises_invalid_pluralization_data - # assert_raise(I18n::InvalidPluralizationData){ @backend.send(:pluralize, nil, 'bar', 2) } - # end - # - # def test_interpolate_given_an_array_raises_invalid_pluralization_data - # assert_raise(I18n::InvalidPluralizationData){ @backend.send(:pluralize, nil, ['bar'], 2) } - # end -end - -class I18nSimpleBackendInterpolateTest < Test::Unit::TestCase - include I18nSimpleBackendTestSetup - - def test_interpolate_given_a_value_hash_interpolates_the_values_to_the_string - assert_equal 'Hi David!', @backend.send(:interpolate, nil, 'Hi {{name}}!', :name => 'David') - end - - def test_interpolate_given_a_value_hash_interpolates_into_unicode_string - assert_equal 'Häi David!', @backend.send(:interpolate, nil, 'Häi {{name}}!', :name => 'David') - end - - def test_interpolate_given_an_unicode_value_hash_interpolates_to_the_string - assert_equal 'Hi ゆきひろ!', @backend.send(:interpolate, nil, 'Hi {{name}}!', :name => 'ゆきひろ') - end - - def test_interpolate_given_an_unicode_value_hash_interpolates_into_unicode_string - assert_equal 'こんにちは、ゆきひろさん!', @backend.send(:interpolate, nil, 'こんにちは、{{name}}さん!', :name => 'ゆきひろ') - end - - if Kernel.const_defined?(:Encoding) - def test_interpolate_given_a_non_unicode_multibyte_value_hash_interpolates_into_a_string_with_the_same_encoding - assert_equal euc_jp('Hi ゆきひろ!'), @backend.send(:interpolate, nil, 'Hi {{name}}!', :name => euc_jp('ゆきひろ')) - end - - def test_interpolate_given_an_unicode_value_hash_into_a_non_unicode_multibyte_string_raises_encoding_compatibility_error - assert_raise(Encoding::CompatibilityError) do - @backend.send(:interpolate, nil, euc_jp('こんにちは、{{name}}さん!'), :name => 'ゆきひろ') - end - end - - def test_interpolate_given_a_non_unicode_multibyte_value_hash_into_an_unicode_string_raises_encoding_compatibility_error - assert_raise(Encoding::CompatibilityError) do - @backend.send(:interpolate, nil, 'こんにちは、{{name}}さん!', :name => euc_jp('ゆきひろ')) - end - end - end - - def test_interpolate_given_nil_as_a_string_returns_nil - assert_nil @backend.send(:interpolate, nil, nil, :name => 'David') - end - - def test_interpolate_given_an_non_string_as_a_string_returns_nil - assert_equal [], @backend.send(:interpolate, nil, [], :name => 'David') - end - - def test_interpolate_given_a_values_hash_with_nil_values_interpolates_the_string - assert_equal 'Hi !', @backend.send(:interpolate, nil, 'Hi {{name}}!', {:name => nil}) - end - - def test_interpolate_given_an_empty_values_hash_raises_missing_interpolation_argument - assert_raise(I18n::MissingInterpolationArgument) { @backend.send(:interpolate, nil, 'Hi {{name}}!', {}) } - end - - def test_interpolate_given_a_string_containing_a_reserved_key_raises_reserved_interpolation_key - assert_raise(I18n::ReservedInterpolationKey) { @backend.send(:interpolate, nil, '{{default}}', {:default => nil}) } - end - - private - - def euc_jp(string) - string.encode!(Encoding::EUC_JP) - end -end - -class I18nSimpleBackendLocalizeDateTest < Test::Unit::TestCase - include I18nSimpleBackendTestSetup - - def setup - @backend = I18n::Backend::Simple.new - add_datetime_translations - @date = Date.new 2008, 1, 1 - end - - def test_translate_given_the_short_format_it_uses_it - assert_equal '01. Jan', @backend.localize('de', @date, :short) - end - - def test_translate_given_the_long_format_it_uses_it - assert_equal '01. Januar 2008', @backend.localize('de', @date, :long) - end - - def test_translate_given_the_default_format_it_uses_it - assert_equal '01.01.2008', @backend.localize('de', @date, :default) - end - - def test_translate_given_a_day_name_format_it_returns_a_day_name - assert_equal 'Dienstag', @backend.localize('de', @date, '%A') - end - - def test_translate_given_an_abbr_day_name_format_it_returns_an_abbrevated_day_name - assert_equal 'Di', @backend.localize('de', @date, '%a') - end - - def test_translate_given_a_month_name_format_it_returns_a_month_name - assert_equal 'Januar', @backend.localize('de', @date, '%B') - end - - def test_translate_given_an_abbr_month_name_format_it_returns_an_abbrevated_month_name - assert_equal 'Jan', @backend.localize('de', @date, '%b') - end - - def test_translate_given_no_format_it_does_not_fail - assert_nothing_raised{ @backend.localize 'de', @date } - end - - def test_translate_given_an_unknown_format_it_does_not_fail - assert_nothing_raised{ @backend.localize 'de', @date, '%x' } - end - - def test_localize_nil_raises_argument_error - assert_raise(I18n::ArgumentError) { @backend.localize 'de', nil } - end - - def test_localize_object_raises_argument_error - assert_raise(I18n::ArgumentError) { @backend.localize 'de', Object.new } - end -end - -class I18nSimpleBackendLocalizeDateTimeTest < Test::Unit::TestCase - include I18nSimpleBackendTestSetup - - def setup - @backend = I18n::Backend::Simple.new - add_datetime_translations - @morning = DateTime.new 2008, 1, 1, 6 - @evening = DateTime.new 2008, 1, 1, 18 - end - - def test_translate_given_the_short_format_it_uses_it - assert_equal '01. Jan 06:00', @backend.localize('de', @morning, :short) - end - - def test_translate_given_the_long_format_it_uses_it - assert_equal '01. Januar 2008 06:00', @backend.localize('de', @morning, :long) - end - - def test_translate_given_the_default_format_it_uses_it - assert_equal 'Di, 01. Jan 2008 06:00:00 +0000', @backend.localize('de', @morning, :default) - end - - def test_translate_given_a_day_name_format_it_returns_the_correct_day_name - assert_equal 'Dienstag', @backend.localize('de', @morning, '%A') - end - - def test_translate_given_an_abbr_day_name_format_it_returns_the_correct_abbrevated_day_name - assert_equal 'Di', @backend.localize('de', @morning, '%a') - end - - def test_translate_given_a_month_name_format_it_returns_the_correct_month_name - assert_equal 'Januar', @backend.localize('de', @morning, '%B') - end - - def test_translate_given_an_abbr_month_name_format_it_returns_the_correct_abbrevated_month_name - assert_equal 'Jan', @backend.localize('de', @morning, '%b') - end - - def test_translate_given_a_meridian_indicator_format_it_returns_the_correct_meridian_indicator - assert_equal 'am', @backend.localize('de', @morning, '%p') - assert_equal 'pm', @backend.localize('de', @evening, '%p') - end - - def test_translate_given_no_format_it_does_not_fail - assert_nothing_raised{ @backend.localize 'de', @morning } - end - - def test_translate_given_an_unknown_format_it_does_not_fail - assert_nothing_raised{ @backend.localize 'de', @morning, '%x' } - end -end - -class I18nSimpleBackendLocalizeTimeTest < Test::Unit::TestCase - include I18nSimpleBackendTestSetup - - def setup - @old_timezone, ENV['TZ'] = ENV['TZ'], 'UTC' - @backend = I18n::Backend::Simple.new - add_datetime_translations - @morning = Time.parse '2008-01-01 6:00 UTC' - @evening = Time.parse '2008-01-01 18:00 UTC' - end - - def teardown - @old_timezone ? ENV['TZ'] = @old_timezone : ENV.delete('TZ') - end - - def test_translate_given_the_short_format_it_uses_it - assert_equal '01. Jan 06:00', @backend.localize('de', @morning, :short) - end - - def test_translate_given_the_long_format_it_uses_it - assert_equal '01. Januar 2008 06:00', @backend.localize('de', @morning, :long) - end - - # TODO Seems to break on Windows because ENV['TZ'] is ignored. What's a better way to do this? - # def test_translate_given_the_default_format_it_uses_it - # assert_equal 'Di, 01. Jan 2008 06:00:00 +0000', @backend.localize('de', @morning, :default) - # end - - def test_translate_given_a_day_name_format_it_returns_the_correct_day_name - assert_equal 'Dienstag', @backend.localize('de', @morning, '%A') - end - - def test_translate_given_an_abbr_day_name_format_it_returns_the_correct_abbrevated_day_name - assert_equal 'Di', @backend.localize('de', @morning, '%a') - end - - def test_translate_given_a_month_name_format_it_returns_the_correct_month_name - assert_equal 'Januar', @backend.localize('de', @morning, '%B') - end - - def test_translate_given_an_abbr_month_name_format_it_returns_the_correct_abbrevated_month_name - assert_equal 'Jan', @backend.localize('de', @morning, '%b') - end - - def test_translate_given_a_meridian_indicator_format_it_returns_the_correct_meridian_indicator - assert_equal 'am', @backend.localize('de', @morning, '%p') - assert_equal 'pm', @backend.localize('de', @evening, '%p') - end - - def test_translate_given_no_format_it_does_not_fail - assert_nothing_raised{ @backend.localize 'de', @morning } - end - - def test_translate_given_an_unknown_format_it_does_not_fail - assert_nothing_raised{ @backend.localize 'de', @morning, '%x' } - end -end - -class I18nSimpleBackendHelperMethodsTest < Test::Unit::TestCase - def setup - @backend = I18n::Backend::Simple.new - end - - def test_deep_symbolize_keys_works - result = @backend.send :deep_symbolize_keys, 'foo' => {'bar' => {'baz' => 'bar'}} - expected = {:foo => {:bar => {:baz => 'bar'}}} - assert_equal expected, result - end -end - -class I18nSimpleBackendLoadTranslationsTest < Test::Unit::TestCase - include I18nSimpleBackendTestSetup - - def test_load_translations_with_unknown_file_type_raises_exception - assert_raise(I18n::UnknownFileType) { @backend.load_translations "#{@locale_dir}/en.xml" } - end - - def test_load_translations_with_ruby_file_type_does_not_raise_exception - assert_nothing_raised { @backend.load_translations "#{@locale_dir}/en.rb" } - end - - def test_load_rb_loads_data_from_ruby_file - data = @backend.send :load_rb, "#{@locale_dir}/en.rb" - assert_equal({:'en-Ruby' => {:foo => {:bar => "baz"}}}, data) - end - - def test_load_rb_loads_data_from_yaml_file - data = @backend.send :load_yml, "#{@locale_dir}/en.yml" - assert_equal({'en-Yaml' => {'foo' => {'bar' => 'baz'}}}, data) - end - - def test_load_translations_loads_from_different_file_formats - @backend = I18n::Backend::Simple.new - @backend.load_translations "#{@locale_dir}/en.rb", "#{@locale_dir}/en.yml" - expected = { - :'en-Ruby' => {:foo => {:bar => "baz"}}, - :'en-Yaml' => {:foo => {:bar => "baz"}} - } - assert_equal expected, backend_get_translations - end -end - -class I18nSimpleBackendLoadPathTest < Test::Unit::TestCase - include I18nSimpleBackendTestSetup - - def teardown - I18n.load_path = [] - end - - def test_nested_load_paths_do_not_break_locale_loading - @backend = I18n::Backend::Simple.new - I18n.load_path = [[File.dirname(__FILE__) + '/locale/en.yml']] - assert_nil backend_get_translations - assert_nothing_raised { @backend.send :init_translations } - assert_not_nil backend_get_translations - end - - def test_adding_arrays_of_filenames_to_load_path_do_not_break_locale_loading - @backend = I18n::Backend::Simple.new - I18n.load_path << Dir[File.dirname(__FILE__) + '/locale/*.{rb,yml}'] - assert_nil backend_get_translations - assert_nothing_raised { @backend.send :init_translations } - assert_not_nil backend_get_translations - end -end - -class I18nSimpleBackendReloadTranslationsTest < Test::Unit::TestCase - include I18nSimpleBackendTestSetup - - def setup - @backend = I18n::Backend::Simple.new - I18n.load_path = [File.dirname(__FILE__) + '/locale/en.yml'] - assert_nil backend_get_translations - @backend.send :init_translations - end - - def teardown - I18n.load_path = [] - end - - def test_setup - assert_not_nil backend_get_translations - end - - def test_reload_translations_unloads_translations - @backend.reload! - assert_nil backend_get_translations - end - - def test_reload_translations_uninitializes_translations - @backend.reload! - assert_equal @backend.initialized?, false - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/memcache-client-1.6.5/memcache.rb b/vendor/rails/activesupport/lib/active_support/vendor/memcache-client-1.6.5/memcache.rb deleted file mode 100644 index 4d594c2..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/memcache-client-1.6.5/memcache.rb +++ /dev/null @@ -1,935 +0,0 @@ -$TESTING = defined?($TESTING) && $TESTING - -require 'socket' -require 'thread' -require 'timeout' -require 'zlib' -require 'digest/sha1' - -## -# A Ruby client library for memcached. -# - -class MemCache - - ## - # The version of MemCache you are using. - - VERSION = '1.6.4.99' - - ## - # Default options for the cache object. - - DEFAULT_OPTIONS = { - :namespace => nil, - :readonly => false, - :multithread => true, - :failover => true, - :timeout => 0.5, - :logger => nil, - } - - ## - # Default memcached port. - - DEFAULT_PORT = 11211 - - ## - # Default memcached server weight. - - DEFAULT_WEIGHT = 1 - - ## - # The namespace for this instance - - attr_reader :namespace - - ## - # The multithread setting for this instance - - attr_reader :multithread - - ## - # The servers this client talks to. Play at your own peril. - - attr_reader :servers - - ## - # Socket timeout limit with this client, defaults to 0.5 sec. - # Set to nil to disable timeouts. - - attr_reader :timeout - - ## - # Should the client try to failover to another server if the - # first server is down? Defaults to true. - - attr_reader :failover - - ## - # Log debug/info/warn/error to the given Logger, defaults to nil. - - attr_reader :logger - - ## - # Accepts a list of +servers+ and a list of +opts+. +servers+ may be - # omitted. See +servers=+ for acceptable server list arguments. - # - # Valid options for +opts+ are: - # - # [:namespace] Prepends this value to all keys added or retrieved. - # [:readonly] Raises an exception on cache writes when true. - # [:multithread] Wraps cache access in a Mutex for thread safety. - # [:failover] Should the client try to failover to another server if the - # first server is down? Defaults to true. - # [:timeout] Time to use as the socket read timeout. Defaults to 0.5 sec, - # set to nil to disable timeouts (this is a major performance penalty in Ruby 1.8). - # [:logger] Logger to use for info/debug output, defaults to nil - # Other options are ignored. - - def initialize(*args) - servers = [] - opts = {} - - case args.length - when 0 then # NOP - when 1 then - arg = args.shift - case arg - when Hash then opts = arg - when Array then servers = arg - when String then servers = [arg] - else raise ArgumentError, 'first argument must be Array, Hash or String' - end - when 2 then - servers, opts = args - else - raise ArgumentError, "wrong number of arguments (#{args.length} for 2)" - end - - opts = DEFAULT_OPTIONS.merge opts - @namespace = opts[:namespace] - @readonly = opts[:readonly] - @multithread = opts[:multithread] - @timeout = opts[:timeout] - @failover = opts[:failover] - @logger = opts[:logger] - @mutex = Mutex.new if @multithread - - logger.info { "memcache-client #{VERSION} #{Array(servers).inspect}" } if logger - - Thread.current[:memcache_client] = self.object_id if !@multithread - - self.servers = servers - end - - ## - # Returns a string representation of the cache object. - - def inspect - "<MemCache: %d servers, ns: %p, ro: %p>" % - [@servers.length, @namespace, @readonly] - end - - ## - # Returns whether there is at least one active server for the object. - - def active? - not @servers.empty? - end - - ## - # Returns whether or not the cache object was created read only. - - def readonly? - @readonly - end - - ## - # Set the servers that the requests will be distributed between. Entries - # can be either strings of the form "hostname:port" or - # "hostname:port:weight" or MemCache::Server objects. - # - def servers=(servers) - # Create the server objects. - @servers = Array(servers).collect do |server| - case server - when String - host, port, weight = server.split ':', 3 - port ||= DEFAULT_PORT - weight ||= DEFAULT_WEIGHT - Server.new self, host, port, weight - else - server - end - end - - logger.debug { "Servers now: #{@servers.inspect}" } if logger - - # There's no point in doing this if there's only one server - @continuum = create_continuum_for(@servers) if @servers.size > 1 - - @servers - end - - ## - # Decrements the value for +key+ by +amount+ and returns the new value. - # +key+ must already exist. If +key+ is not an integer, it is assumed to be - # 0. +key+ can not be decremented below 0. - - def decr(key, amount = 1) - raise MemCacheError, "Update of readonly cache" if @readonly - with_server(key) do |server, cache_key| - cache_decr server, cache_key, amount - end - rescue TypeError => err - handle_error nil, err - end - - ## - # Retrieves +key+ from memcache. If +raw+ is false, the value will be - # unmarshalled. - - def get(key, raw = false) - with_server(key) do |server, cache_key| - value = cache_get server, cache_key - logger.debug { "GET #{key} from #{server.inspect}: #{value ? value.to_s.size : 'nil'}" } if logger - return nil if value.nil? - value = Marshal.load value unless raw - return value - end - rescue TypeError => err - handle_error nil, err - end - - ## - # Retrieves multiple values from memcached in parallel, if possible. - # - # The memcached protocol supports the ability to retrieve multiple - # keys in a single request. Pass in an array of keys to this method - # and it will: - # - # 1. map the key to the appropriate memcached server - # 2. send a single request to each server that has one or more key values - # - # Returns a hash of values. - # - # cache["a"] = 1 - # cache["b"] = 2 - # cache.get_multi "a", "b" # => { "a" => 1, "b" => 2 } - # - # Note that get_multi assumes the values are marshalled. - - def get_multi(*keys) - raise MemCacheError, 'No active servers' unless active? - - keys.flatten! - key_count = keys.length - cache_keys = {} - server_keys = Hash.new { |h,k| h[k] = [] } - - # map keys to servers - keys.each do |key| - server, cache_key = request_setup key - cache_keys[cache_key] = key - server_keys[server] << cache_key - end - - results = {} - - server_keys.each do |server, keys_for_server| - keys_for_server_str = keys_for_server.join ' ' - begin - values = cache_get_multi server, keys_for_server_str - values.each do |key, value| - results[cache_keys[key]] = Marshal.load value - end - rescue IndexError => e - # Ignore this server and try the others - logger.warn { "Unable to retrieve #{keys_for_server.size} elements from #{server.inspect}: #{e.message}"} if logger - end - end - - return results - rescue TypeError => err - handle_error nil, err - end - - ## - # Increments the value for +key+ by +amount+ and returns the new value. - # +key+ must already exist. If +key+ is not an integer, it is assumed to be - # 0. - - def incr(key, amount = 1) - raise MemCacheError, "Update of readonly cache" if @readonly - with_server(key) do |server, cache_key| - cache_incr server, cache_key, amount - end - rescue TypeError => err - handle_error nil, err - end - - ## - # Add +key+ to the cache with value +value+ that expires in +expiry+ - # seconds. If +raw+ is true, +value+ will not be Marshalled. - # - # Warning: Readers should not call this method in the event of a cache miss; - # see MemCache#add. - - ONE_MB = 1024 * 1024 - - def set(key, value, expiry = 0, raw = false) - raise MemCacheError, "Update of readonly cache" if @readonly - with_server(key) do |server, cache_key| - - value = Marshal.dump value unless raw - logger.debug { "SET #{key} to #{server.inspect}: #{value ? value.to_s.size : 'nil'}" } if logger - - data = value.to_s - raise MemCacheError, "Value too large, memcached can only store 1MB of data per key" if data.size > ONE_MB - - command = "set #{cache_key} 0 #{expiry} #{data.size}\r\n#{data}\r\n" - - with_socket_management(server) do |socket| - socket.write command - result = socket.gets - raise_on_error_response! result - - if result.nil? - server.close - raise MemCacheError, "lost connection to #{server.host}:#{server.port}" - end - - result - end - end - end - - ## - # Add +key+ to the cache with value +value+ that expires in +expiry+ - # seconds, but only if +key+ does not already exist in the cache. - # If +raw+ is true, +value+ will not be Marshalled. - # - # Readers should call this method in the event of a cache miss, not - # MemCache#set or MemCache#[]=. - - def add(key, value, expiry = 0, raw = false) - raise MemCacheError, "Update of readonly cache" if @readonly - with_server(key) do |server, cache_key| - value = Marshal.dump value unless raw - logger.debug { "ADD #{key} to #{server}: #{value ? value.to_s.size : 'nil'}" } if logger - command = "add #{cache_key} 0 #{expiry} #{value.to_s.size}\r\n#{value}\r\n" - - with_socket_management(server) do |socket| - socket.write command - result = socket.gets - raise_on_error_response! result - result - end - end - end - - ## - # Removes +key+ from the cache in +expiry+ seconds. - - def delete(key, expiry = 0) - raise MemCacheError, "Update of readonly cache" if @readonly - with_server(key) do |server, cache_key| - with_socket_management(server) do |socket| - socket.write "delete #{cache_key} #{expiry}\r\n" - result = socket.gets - raise_on_error_response! result - result - end - end - end - - ## - # Flush the cache from all memcache servers. - - def flush_all - raise MemCacheError, 'No active servers' unless active? - raise MemCacheError, "Update of readonly cache" if @readonly - - begin - @servers.each do |server| - with_socket_management(server) do |socket| - socket.write "flush_all\r\n" - result = socket.gets - raise_on_error_response! result - result - end - end - rescue IndexError => err - handle_error nil, err - end - end - - ## - # Reset the connection to all memcache servers. This should be called if - # there is a problem with a cache lookup that might have left the connection - # in a corrupted state. - - def reset - @servers.each { |server| server.close } - end - - ## - # Returns statistics for each memcached server. An explanation of the - # statistics can be found in the memcached docs: - # - # http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt - # - # Example: - # - # >> pp CACHE.stats - # {"localhost:11211"=> - # {"bytes"=>4718, - # "pid"=>20188, - # "connection_structures"=>4, - # "time"=>1162278121, - # "pointer_size"=>32, - # "limit_maxbytes"=>67108864, - # "cmd_get"=>14532, - # "version"=>"1.2.0", - # "bytes_written"=>432583, - # "cmd_set"=>32, - # "get_misses"=>0, - # "total_connections"=>19, - # "curr_connections"=>3, - # "curr_items"=>4, - # "uptime"=>1557, - # "get_hits"=>14532, - # "total_items"=>32, - # "rusage_system"=>0.313952, - # "rusage_user"=>0.119981, - # "bytes_read"=>190619}} - # => nil - - def stats - raise MemCacheError, "No active servers" unless active? - server_stats = {} - - @servers.each do |server| - next unless server.alive? - - with_socket_management(server) do |socket| - value = nil - socket.write "stats\r\n" - stats = {} - while line = socket.gets do - raise_on_error_response! line - break if line == "END\r\n" - if line =~ /\ASTAT ([\S]+) ([\w\.\:]+)/ then - name, value = $1, $2 - stats[name] = case name - when 'version' - value - when 'rusage_user', 'rusage_system' then - seconds, microseconds = value.split(/:/, 2) - microseconds ||= 0 - Float(seconds) + (Float(microseconds) / 1_000_000) - else - if value =~ /\A\d+\Z/ then - value.to_i - else - value - end - end - end - end - server_stats["#{server.host}:#{server.port}"] = stats - end - end - - raise MemCacheError, "No active servers" if server_stats.empty? - server_stats - end - - ## - # Shortcut to get a value from the cache. - - alias [] get - - ## - # Shortcut to save a value in the cache. This method does not set an - # expiration on the entry. Use set to specify an explicit expiry. - - def []=(key, value) - set key, value - end - - protected unless $TESTING - - ## - # Create a key for the cache, incorporating the namespace qualifier if - # requested. - - def make_cache_key(key) - if namespace.nil? then - key - else - "#{@namespace}:#{key}" - end - end - - ## - # Returns an interoperable hash value for +key+. (I think, docs are - # sketchy for down servers). - - def hash_for(key) - Zlib.crc32(key) - end - - ## - # Pick a server to handle the request based on a hash of the key. - - def get_server_for_key(key, options = {}) - raise ArgumentError, "illegal character in key #{key.inspect}" if - key =~ /\s/ - raise ArgumentError, "key too long #{key.inspect}" if key.length > 250 - raise MemCacheError, "No servers available" if @servers.empty? - return @servers.first if @servers.length == 1 - - hkey = hash_for(key) - - 20.times do |try| - entryidx = Continuum.binary_search(@continuum, hkey) - server = @continuum[entryidx].server - return server if server.alive? - break unless failover - hkey = hash_for "#{try}#{key}" - end - - raise MemCacheError, "No servers available" - end - - ## - # Performs a raw decr for +cache_key+ from +server+. Returns nil if not - # found. - - def cache_decr(server, cache_key, amount) - with_socket_management(server) do |socket| - socket.write "decr #{cache_key} #{amount}\r\n" - text = socket.gets - raise_on_error_response! text - return nil if text == "NOT_FOUND\r\n" - return text.to_i - end - end - - ## - # Fetches the raw data for +cache_key+ from +server+. Returns nil on cache - # miss. - - def cache_get(server, cache_key) - with_socket_management(server) do |socket| - socket.write "get #{cache_key}\r\n" - keyline = socket.gets # "VALUE <key> <flags> <bytes>\r\n" - - if keyline.nil? then - server.close - raise MemCacheError, "lost connection to #{server.host}:#{server.port}" - end - - raise_on_error_response! keyline - return nil if keyline == "END\r\n" - - unless keyline =~ /(\d+)\r/ then - server.close - raise MemCacheError, "unexpected response #{keyline.inspect}" - end - value = socket.read $1.to_i - socket.read 2 # "\r\n" - socket.gets # "END\r\n" - return value - end - end - - ## - # Fetches +cache_keys+ from +server+ using a multi-get. - - def cache_get_multi(server, cache_keys) - with_socket_management(server) do |socket| - values = {} - socket.write "get #{cache_keys}\r\n" - - while keyline = socket.gets do - return values if keyline == "END\r\n" - raise_on_error_response! keyline - - unless keyline =~ /\AVALUE (.+) (.+) (.+)/ then - server.close - raise MemCacheError, "unexpected response #{keyline.inspect}" - end - - key, data_length = $1, $3 - values[$1] = socket.read data_length.to_i - socket.read(2) # "\r\n" - end - - server.close - raise MemCacheError, "lost connection to #{server.host}:#{server.port}" # TODO: retry here too - end - end - - ## - # Performs a raw incr for +cache_key+ from +server+. Returns nil if not - # found. - - def cache_incr(server, cache_key, amount) - with_socket_management(server) do |socket| - socket.write "incr #{cache_key} #{amount}\r\n" - text = socket.gets - raise_on_error_response! text - return nil if text == "NOT_FOUND\r\n" - return text.to_i - end - end - - ## - # Gets or creates a socket connected to the given server, and yields it - # to the block, wrapped in a mutex synchronization if @multithread is true. - # - # If a socket error (SocketError, SystemCallError, IOError) or protocol error - # (MemCacheError) is raised by the block, closes the socket, attempts to - # connect again, and retries the block (once). If an error is again raised, - # reraises it as MemCacheError. - # - # If unable to connect to the server (or if in the reconnect wait period), - # raises MemCacheError. Note that the socket connect code marks a server - # dead for a timeout period, so retrying does not apply to connection attempt - # failures (but does still apply to unexpectedly lost connections etc.). - - def with_socket_management(server, &block) - check_multithread_status! - - @mutex.lock if @multithread - retried = false - - begin - socket = server.socket - - # Raise an IndexError to show this server is out of whack. If were inside - # a with_server block, we'll catch it and attempt to restart the operation. - - raise IndexError, "No connection to server (#{server.status})" if socket.nil? - - block.call(socket) - - rescue SocketError => err - logger.warn { "Socket failure: #{err.message}" } if logger - server.mark_dead(err) - handle_error(server, err) - - rescue MemCacheError, SystemCallError, IOError => err - logger.warn { "Generic failure: #{err.class.name}: #{err.message}" } if logger - handle_error(server, err) if retried || socket.nil? - retried = true - retry - end - ensure - @mutex.unlock if @multithread - end - - def with_server(key) - retried = false - begin - server, cache_key = request_setup(key) - yield server, cache_key - rescue IndexError => e - logger.warn { "Server failed: #{e.class.name}: #{e.message}" } if logger - if !retried && @servers.size > 1 - logger.info { "Connection to server #{server.inspect} DIED! Retrying operation..." } if logger - retried = true - retry - end - handle_error(nil, e) - end - end - - ## - # Handles +error+ from +server+. - - def handle_error(server, error) - raise error if error.is_a?(MemCacheError) - server.close if server - new_error = MemCacheError.new error.message - new_error.set_backtrace error.backtrace - raise new_error - end - - ## - # Performs setup for making a request with +key+ from memcached. Returns - # the server to fetch the key from and the complete key to use. - - def request_setup(key) - raise MemCacheError, 'No active servers' unless active? - cache_key = make_cache_key key - server = get_server_for_key cache_key - return server, cache_key - end - - def raise_on_error_response!(response) - if response =~ /\A(?:CLIENT_|SERVER_)?ERROR(.*)/ - raise MemCacheError, $1.strip - end - end - - def create_continuum_for(servers) - total_weight = servers.inject(0) { |memo, srv| memo + srv.weight } - continuum = [] - - servers.each do |server| - entry_count_for(server, servers.size, total_weight).times do |idx| - hash = Digest::SHA1.hexdigest("#{server.host}:#{server.port}:#{idx}") - value = Integer("0x#{hash[0..7]}") - continuum << Continuum::Entry.new(value, server) - end - end - - continuum.sort { |a, b| a.value <=> b.value } - end - - def entry_count_for(server, total_servers, total_weight) - ((total_servers * Continuum::POINTS_PER_SERVER * server.weight) / Float(total_weight)).floor - end - - def check_multithread_status! - return if @multithread - - if Thread.current[:memcache_client] != self.object_id - raise MemCacheError, <<-EOM - You are accessing this memcache-client instance from multiple threads but have not enabled multithread support. - Normally: MemCache.new(['localhost:11211'], :multithread => true) - In Rails: config.cache_store = [:mem_cache_store, 'localhost:11211', { :multithread => true }] - EOM - end - end - - ## - # This class represents a memcached server instance. - - class Server - - ## - # The amount of time to wait to establish a connection with a memcached - # server. If a connection cannot be established within this time limit, - # the server will be marked as down. - - CONNECT_TIMEOUT = 0.25 - - ## - # The amount of time to wait before attempting to re-establish a - # connection with a server that is marked dead. - - RETRY_DELAY = 30.0 - - ## - # The host the memcached server is running on. - - attr_reader :host - - ## - # The port the memcached server is listening on. - - attr_reader :port - - ## - # The weight given to the server. - - attr_reader :weight - - ## - # The time of next retry if the connection is dead. - - attr_reader :retry - - ## - # A text status string describing the state of the server. - - attr_reader :status - - attr_reader :logger - - ## - # Create a new MemCache::Server object for the memcached instance - # listening on the given host and port, weighted by the given weight. - - def initialize(memcache, host, port = DEFAULT_PORT, weight = DEFAULT_WEIGHT) - raise ArgumentError, "No host specified" if host.nil? or host.empty? - raise ArgumentError, "No port specified" if port.nil? or port.to_i.zero? - - @host = host - @port = port.to_i - @weight = weight.to_i - - @sock = nil - @retry = nil - @status = 'NOT CONNECTED' - @timeout = memcache.timeout - @logger = memcache.logger - end - - ## - # Return a string representation of the server object. - - def inspect - "<MemCache::Server: %s:%d [%d] (%s)>" % [@host, @port, @weight, @status] - end - - ## - # Check whether the server connection is alive. This will cause the - # socket to attempt to connect if it isn't already connected and or if - # the server was previously marked as down and the retry time has - # been exceeded. - - def alive? - !!socket - end - - ## - # Try to connect to the memcached server targeted by this object. - # Returns the connected socket object on success or nil on failure. - - def socket - return @sock if @sock and not @sock.closed? - - @sock = nil - - # If the host was dead, don't retry for a while. - return if @retry and @retry > Time.now - - # Attempt to connect if not already connected. - begin - @sock = @timeout ? TCPTimeoutSocket.new(@host, @port, @timeout) : TCPSocket.new(@host, @port) - - if Socket.constants.include? 'TCP_NODELAY' then - @sock.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1 - end - @retry = nil - @status = 'CONNECTED' - rescue SocketError, SystemCallError, IOError, Timeout::Error => err - logger.warn { "Unable to open socket: #{err.class.name}, #{err.message}" } if logger - mark_dead err - end - - return @sock - end - - ## - # Close the connection to the memcached server targeted by this - # object. The server is not considered dead. - - def close - @sock.close if @sock && !@sock.closed? - @sock = nil - @retry = nil - @status = "NOT CONNECTED" - end - - ## - # Mark the server as dead and close its socket. - - def mark_dead(error) - @sock.close if @sock && !@sock.closed? - @sock = nil - @retry = Time.now + RETRY_DELAY - - reason = "#{error.class.name}: #{error.message}" - @status = sprintf "%s:%s DEAD (%s), will retry at %s", @host, @port, reason, @retry - @logger.info { @status } if @logger - end - - end - - ## - # Base MemCache exception class. - - class MemCacheError < RuntimeError; end - -end - -# TCPSocket facade class which implements timeouts. -class TCPTimeoutSocket - - def initialize(host, port, timeout) - Timeout::timeout(MemCache::Server::CONNECT_TIMEOUT, SocketError) do - @sock = TCPSocket.new(host, port) - @len = timeout - end - end - - def write(*args) - Timeout::timeout(@len, SocketError) do - @sock.write(*args) - end - end - - def gets(*args) - Timeout::timeout(@len, SocketError) do - @sock.gets(*args) - end - end - - def read(*args) - Timeout::timeout(@len, SocketError) do - @sock.read(*args) - end - end - - def _socket - @sock - end - - def method_missing(meth, *args) - @sock.__send__(meth, *args) - end - - def closed? - @sock.closed? - end - - def close - @sock.close - end -end - -module Continuum - POINTS_PER_SERVER = 160 # this is the default in libmemcached - - # Find the closest index in Continuum with value <= the given value - def self.binary_search(ary, value, &block) - upper = ary.size - 1 - lower = 0 - idx = 0 - - while(lower <= upper) do - idx = (lower + upper) / 2 - comp = ary[idx].value <=> value - - if comp == 0 - return idx - elsif comp > 0 - upper = idx - 1 - else - lower = idx + 1 - end - end - return upper - end - - class Entry - attr_reader :value - attr_reader :server - - def initialize(val, srv) - @value = val - @server = srv - end - - def inspect - "<#{value}, #{server.host}:#{server.port}>" - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo.rb deleted file mode 100644 index c8bdbee..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo.rb +++ /dev/null @@ -1,33 +0,0 @@ -#-- -# Copyright (c) 2005-2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -# Add the directory containing this file to the start of the load path if it -# isn't there already. -$:.unshift(File.dirname(__FILE__)) unless - $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) - -require 'tzinfo/timezone' -# require 'tzinfo/country' -# require 'tzinfo/tzdataparser' -# require 'tzinfo/timezone_proxy' -require 'tzinfo/data_timezone' -require 'tzinfo/linked_timezone' \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone.rb deleted file mode 100644 index 5eccbdf..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone.rb +++ /dev/null @@ -1,47 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'tzinfo/info_timezone' - -module TZInfo - - # A Timezone based on a DataTimezoneInfo. - class DataTimezone < InfoTimezone #:nodoc: - - # Returns the TimezonePeriod for the given UTC time. utc can either be - # a DateTime, Time or integer timestamp (Time.to_i). Any timezone - # information in utc is ignored (it is treated as a UTC time). - # - # If no TimezonePeriod could be found, PeriodNotFound is raised. - def period_for_utc(utc) - info.period_for_utc(utc) - end - - # Returns the set of TimezonePeriod instances that are valid for the given - # local time as an array. If you just want a single period, use - # period_for_local instead and specify how abiguities should be resolved. - # Raises PeriodNotFound if no periods are found for the given time. - def periods_for_local(local) - info.periods_for_local(local) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone_info.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone_info.rb deleted file mode 100644 index a45d945..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone_info.rb +++ /dev/null @@ -1,228 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'tzinfo/time_or_datetime' -require 'tzinfo/timezone_info' -require 'tzinfo/timezone_offset_info' -require 'tzinfo/timezone_period' -require 'tzinfo/timezone_transition_info' - -module TZInfo - # Thrown if no offsets have been defined when calling period_for_utc or - # periods_for_local. Indicates an error in the timezone data. - class NoOffsetsDefined < StandardError - end - - # Represents a (non-linked) timezone defined in a data module. - class DataTimezoneInfo < TimezoneInfo #:nodoc: - - # Constructs a new TimezoneInfo with its identifier. - def initialize(identifier) - super(identifier) - @offsets = {} - @transitions = [] - @previous_offset = nil - @transitions_index = nil - end - - # Defines a offset. The id uniquely identifies this offset within the - # timezone. utc_offset and std_offset define the offset in seconds of - # standard time from UTC and daylight savings from standard time - # respectively. abbreviation describes the timezone offset (e.g. GMT, BST, - # EST or EDT). - # - # The first offset to be defined is treated as the offset that applies - # until the first transition. This will usually be in Local Mean Time (LMT). - # - # ArgumentError will be raised if the id is already defined. - def offset(id, utc_offset, std_offset, abbreviation) - raise ArgumentError, 'Offset already defined' if @offsets.has_key?(id) - - offset = TimezoneOffsetInfo.new(utc_offset, std_offset, abbreviation) - @offsets[id] = offset - @previous_offset = offset unless @previous_offset - end - - # Defines a transition. Transitions must be defined in chronological order. - # ArgumentError will be raised if a transition is added out of order. - # offset_id refers to an id defined with offset. ArgumentError will be - # raised if the offset_id cannot be found. numerator_or_time and - # denomiator specify the time the transition occurs as. See - # TimezoneTransitionInfo for more detail about specifying times. - def transition(year, month, offset_id, numerator_or_time, denominator = nil) - offset = @offsets[offset_id] - raise ArgumentError, 'Offset not found' unless offset - - if @transitions_index - if year < @last_year || (year == @last_year && month < @last_month) - raise ArgumentError, 'Transitions must be increasing date order' - end - - # Record the position of the first transition with this index. - index = transition_index(year, month) - @transitions_index[index] ||= @transitions.length - - # Fill in any gaps - (index - 1).downto(0) do |i| - break if @transitions_index[i] - @transitions_index[i] = @transitions.length - end - else - @transitions_index = [@transitions.length] - @start_year = year - @start_month = month - end - - @transitions << TimezoneTransitionInfo.new(offset, @previous_offset, - numerator_or_time, denominator) - @last_year = year - @last_month = month - @previous_offset = offset - end - - # Returns the TimezonePeriod for the given UTC time. - # Raises NoOffsetsDefined if no offsets have been defined. - def period_for_utc(utc) - unless @transitions.empty? - utc = TimeOrDateTime.wrap(utc) - index = transition_index(utc.year, utc.mon) - - start_transition = nil - start = transition_before_end(index) - if start - start.downto(0) do |i| - if @transitions[i].at <= utc - start_transition = @transitions[i] - break - end - end - end - - end_transition = nil - start = transition_after_start(index) - if start - start.upto(@transitions.length - 1) do |i| - if @transitions[i].at > utc - end_transition = @transitions[i] - break - end - end - end - - if start_transition || end_transition - TimezonePeriod.new(start_transition, end_transition) - else - # Won't happen since there are transitions. Must always find one - # transition that is either >= or < the specified time. - raise 'No transitions found in search' - end - else - raise NoOffsetsDefined, 'No offsets have been defined' unless @previous_offset - TimezonePeriod.new(nil, nil, @previous_offset) - end - end - - # Returns the set of TimezonePeriods for the given local time as an array. - # Results returned are ordered by increasing UTC start date. - # Returns an empty array if no periods are found for the given time. - # Raises NoOffsetsDefined if no offsets have been defined. - def periods_for_local(local) - unless @transitions.empty? - local = TimeOrDateTime.wrap(local) - index = transition_index(local.year, local.mon) - - result = [] - - start_index = transition_after_start(index - 1) - if start_index && @transitions[start_index].local_end > local - if start_index > 0 - if @transitions[start_index - 1].local_start <= local - result << TimezonePeriod.new(@transitions[start_index - 1], @transitions[start_index]) - end - else - result << TimezonePeriod.new(nil, @transitions[start_index]) - end - end - - end_index = transition_before_end(index + 1) - - if end_index - start_index = end_index unless start_index - - start_index.upto(transition_before_end(index + 1)) do |i| - if @transitions[i].local_start <= local - if i + 1 < @transitions.length - if @transitions[i + 1].local_end > local - result << TimezonePeriod.new(@transitions[i], @transitions[i + 1]) - end - else - result << TimezonePeriod.new(@transitions[i], nil) - end - end - end - end - - result - else - raise NoOffsetsDefined, 'No offsets have been defined' unless @previous_offset - [TimezonePeriod.new(nil, nil, @previous_offset)] - end - end - - private - # Returns the index into the @transitions_index array for a given year - # and month. - def transition_index(year, month) - index = (year - @start_year) * 2 - index += 1 if month > 6 - index -= 1 if @start_month > 6 - index - end - - # Returns the index into @transitions of the first transition that occurs - # on or after the start of the given index into @transitions_index. - # Returns nil if there are no such transitions. - def transition_after_start(index) - if index >= @transitions_index.length - nil - else - index = 0 if index < 0 - @transitions_index[index] - end - end - - # Returns the index into @transitions of the first transition that occurs - # before the end of the given index into @transitions_index. - # Returns nil if there are no such transitions. - def transition_before_end(index) - index = index + 1 - - if index <= 0 - nil - elsif index >= @transitions_index.length - @transitions.length - 1 - else - @transitions_index[index] - 1 - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Algiers.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Algiers.rb deleted file mode 100644 index 8c5f255..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Algiers.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Africa - module Algiers - include TimezoneDefinition - - timezone 'Africa/Algiers' do |tz| - tz.offset :o0, 732, 0, :LMT - tz.offset :o1, 561, 0, :PMT - tz.offset :o2, 0, 0, :WET - tz.offset :o3, 0, 3600, :WEST - tz.offset :o4, 3600, 0, :CET - tz.offset :o5, 3600, 3600, :CEST - - tz.transition 1891, 3, :o1, 2170625843, 900 - tz.transition 1911, 3, :o2, 69670267013, 28800 - tz.transition 1916, 6, :o3, 58104707, 24 - tz.transition 1916, 10, :o2, 58107323, 24 - tz.transition 1917, 3, :o3, 58111499, 24 - tz.transition 1917, 10, :o2, 58116227, 24 - tz.transition 1918, 3, :o3, 58119899, 24 - tz.transition 1918, 10, :o2, 58124963, 24 - tz.transition 1919, 3, :o3, 58128467, 24 - tz.transition 1919, 10, :o2, 58133699, 24 - tz.transition 1920, 2, :o3, 58136867, 24 - tz.transition 1920, 10, :o2, 58142915, 24 - tz.transition 1921, 3, :o3, 58146323, 24 - tz.transition 1921, 6, :o2, 58148699, 24 - tz.transition 1939, 9, :o3, 58308443, 24 - tz.transition 1939, 11, :o2, 4859173, 2 - tz.transition 1940, 2, :o4, 29156215, 12 - tz.transition 1944, 4, :o5, 58348405, 24 - tz.transition 1944, 10, :o4, 4862743, 2 - tz.transition 1945, 4, :o5, 58357141, 24 - tz.transition 1945, 9, :o4, 58361147, 24 - tz.transition 1946, 10, :o2, 58370411, 24 - tz.transition 1956, 1, :o4, 4871003, 2 - tz.transition 1963, 4, :o2, 58515203, 24 - tz.transition 1971, 4, :o3, 41468400 - tz.transition 1971, 9, :o2, 54774000 - tz.transition 1977, 5, :o3, 231724800 - tz.transition 1977, 10, :o4, 246236400 - tz.transition 1978, 3, :o5, 259545600 - tz.transition 1978, 9, :o4, 275274000 - tz.transition 1979, 10, :o2, 309740400 - tz.transition 1980, 4, :o3, 325468800 - tz.transition 1980, 10, :o2, 341802000 - tz.transition 1981, 5, :o4, 357523200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Cairo.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Cairo.rb deleted file mode 100644 index 6e6daf3..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Cairo.rb +++ /dev/null @@ -1,219 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Africa - module Cairo - include TimezoneDefinition - - timezone 'Africa/Cairo' do |tz| - tz.offset :o0, 7500, 0, :LMT - tz.offset :o1, 7200, 0, :EET - tz.offset :o2, 7200, 3600, :EEST - - tz.transition 1900, 9, :o1, 695604503, 288 - tz.transition 1940, 7, :o2, 29157905, 12 - tz.transition 1940, 9, :o1, 19439227, 8 - tz.transition 1941, 4, :o2, 29161193, 12 - tz.transition 1941, 9, :o1, 19442027, 8 - tz.transition 1942, 3, :o2, 29165405, 12 - tz.transition 1942, 10, :o1, 19445275, 8 - tz.transition 1943, 3, :o2, 29169785, 12 - tz.transition 1943, 10, :o1, 19448235, 8 - tz.transition 1944, 3, :o2, 29174177, 12 - tz.transition 1944, 10, :o1, 19451163, 8 - tz.transition 1945, 4, :o2, 29178737, 12 - tz.transition 1945, 10, :o1, 19454083, 8 - tz.transition 1957, 5, :o2, 29231621, 12 - tz.transition 1957, 9, :o1, 19488899, 8 - tz.transition 1958, 4, :o2, 29235893, 12 - tz.transition 1958, 9, :o1, 19491819, 8 - tz.transition 1959, 4, :o2, 58480547, 24 - tz.transition 1959, 9, :o1, 4873683, 2 - tz.transition 1960, 4, :o2, 58489331, 24 - tz.transition 1960, 9, :o1, 4874415, 2 - tz.transition 1961, 4, :o2, 58498091, 24 - tz.transition 1961, 9, :o1, 4875145, 2 - tz.transition 1962, 4, :o2, 58506851, 24 - tz.transition 1962, 9, :o1, 4875875, 2 - tz.transition 1963, 4, :o2, 58515611, 24 - tz.transition 1963, 9, :o1, 4876605, 2 - tz.transition 1964, 4, :o2, 58524395, 24 - tz.transition 1964, 9, :o1, 4877337, 2 - tz.transition 1965, 4, :o2, 58533155, 24 - tz.transition 1965, 9, :o1, 4878067, 2 - tz.transition 1966, 4, :o2, 58541915, 24 - tz.transition 1966, 10, :o1, 4878799, 2 - tz.transition 1967, 4, :o2, 58550675, 24 - tz.transition 1967, 10, :o1, 4879529, 2 - tz.transition 1968, 4, :o2, 58559459, 24 - tz.transition 1968, 10, :o1, 4880261, 2 - tz.transition 1969, 4, :o2, 58568219, 24 - tz.transition 1969, 10, :o1, 4880991, 2 - tz.transition 1970, 4, :o2, 10364400 - tz.transition 1970, 10, :o1, 23587200 - tz.transition 1971, 4, :o2, 41900400 - tz.transition 1971, 10, :o1, 55123200 - tz.transition 1972, 4, :o2, 73522800 - tz.transition 1972, 10, :o1, 86745600 - tz.transition 1973, 4, :o2, 105058800 - tz.transition 1973, 10, :o1, 118281600 - tz.transition 1974, 4, :o2, 136594800 - tz.transition 1974, 10, :o1, 149817600 - tz.transition 1975, 4, :o2, 168130800 - tz.transition 1975, 10, :o1, 181353600 - tz.transition 1976, 4, :o2, 199753200 - tz.transition 1976, 10, :o1, 212976000 - tz.transition 1977, 4, :o2, 231289200 - tz.transition 1977, 10, :o1, 244512000 - tz.transition 1978, 4, :o2, 262825200 - tz.transition 1978, 10, :o1, 276048000 - tz.transition 1979, 4, :o2, 294361200 - tz.transition 1979, 10, :o1, 307584000 - tz.transition 1980, 4, :o2, 325983600 - tz.transition 1980, 10, :o1, 339206400 - tz.transition 1981, 4, :o2, 357519600 - tz.transition 1981, 10, :o1, 370742400 - tz.transition 1982, 7, :o2, 396399600 - tz.transition 1982, 10, :o1, 402278400 - tz.transition 1983, 7, :o2, 426812400 - tz.transition 1983, 10, :o1, 433814400 - tz.transition 1984, 4, :o2, 452214000 - tz.transition 1984, 10, :o1, 465436800 - tz.transition 1985, 4, :o2, 483750000 - tz.transition 1985, 10, :o1, 496972800 - tz.transition 1986, 4, :o2, 515286000 - tz.transition 1986, 10, :o1, 528508800 - tz.transition 1987, 4, :o2, 546822000 - tz.transition 1987, 10, :o1, 560044800 - tz.transition 1988, 4, :o2, 578444400 - tz.transition 1988, 10, :o1, 591667200 - tz.transition 1989, 5, :o2, 610412400 - tz.transition 1989, 10, :o1, 623203200 - tz.transition 1990, 4, :o2, 641516400 - tz.transition 1990, 10, :o1, 654739200 - tz.transition 1991, 4, :o2, 673052400 - tz.transition 1991, 10, :o1, 686275200 - tz.transition 1992, 4, :o2, 704674800 - tz.transition 1992, 10, :o1, 717897600 - tz.transition 1993, 4, :o2, 736210800 - tz.transition 1993, 10, :o1, 749433600 - tz.transition 1994, 4, :o2, 767746800 - tz.transition 1994, 10, :o1, 780969600 - tz.transition 1995, 4, :o2, 799020000 - tz.transition 1995, 9, :o1, 812322000 - tz.transition 1996, 4, :o2, 830469600 - tz.transition 1996, 9, :o1, 843771600 - tz.transition 1997, 4, :o2, 861919200 - tz.transition 1997, 9, :o1, 875221200 - tz.transition 1998, 4, :o2, 893368800 - tz.transition 1998, 9, :o1, 906670800 - tz.transition 1999, 4, :o2, 925423200 - tz.transition 1999, 9, :o1, 938725200 - tz.transition 2000, 4, :o2, 956872800 - tz.transition 2000, 9, :o1, 970174800 - tz.transition 2001, 4, :o2, 988322400 - tz.transition 2001, 9, :o1, 1001624400 - tz.transition 2002, 4, :o2, 1019772000 - tz.transition 2002, 9, :o1, 1033074000 - tz.transition 2003, 4, :o2, 1051221600 - tz.transition 2003, 9, :o1, 1064523600 - tz.transition 2004, 4, :o2, 1083276000 - tz.transition 2004, 9, :o1, 1096578000 - tz.transition 2005, 4, :o2, 1114725600 - tz.transition 2005, 9, :o1, 1128027600 - tz.transition 2006, 4, :o2, 1146175200 - tz.transition 2006, 9, :o1, 1158872400 - tz.transition 2007, 4, :o2, 1177624800 - tz.transition 2007, 9, :o1, 1189112400 - tz.transition 2008, 4, :o2, 1209074400 - tz.transition 2008, 8, :o1, 1219957200 - tz.transition 2009, 4, :o2, 1240524000 - tz.transition 2009, 8, :o1, 1251406800 - tz.transition 2010, 4, :o2, 1272578400 - tz.transition 2010, 8, :o1, 1282856400 - tz.transition 2011, 4, :o2, 1304028000 - tz.transition 2011, 8, :o1, 1314306000 - tz.transition 2012, 4, :o2, 1335477600 - tz.transition 2012, 8, :o1, 1346360400 - tz.transition 2013, 4, :o2, 1366927200 - tz.transition 2013, 8, :o1, 1377810000 - tz.transition 2014, 4, :o2, 1398376800 - tz.transition 2014, 8, :o1, 1409259600 - tz.transition 2015, 4, :o2, 1429826400 - tz.transition 2015, 8, :o1, 1440709200 - tz.transition 2016, 4, :o2, 1461880800 - tz.transition 2016, 8, :o1, 1472158800 - tz.transition 2017, 4, :o2, 1493330400 - tz.transition 2017, 8, :o1, 1504213200 - tz.transition 2018, 4, :o2, 1524780000 - tz.transition 2018, 8, :o1, 1535662800 - tz.transition 2019, 4, :o2, 1556229600 - tz.transition 2019, 8, :o1, 1567112400 - tz.transition 2020, 4, :o2, 1587679200 - tz.transition 2020, 8, :o1, 1598562000 - tz.transition 2021, 4, :o2, 1619733600 - tz.transition 2021, 8, :o1, 1630011600 - tz.transition 2022, 4, :o2, 1651183200 - tz.transition 2022, 8, :o1, 1661461200 - tz.transition 2023, 4, :o2, 1682632800 - tz.transition 2023, 8, :o1, 1693515600 - tz.transition 2024, 4, :o2, 1714082400 - tz.transition 2024, 8, :o1, 1724965200 - tz.transition 2025, 4, :o2, 1745532000 - tz.transition 2025, 8, :o1, 1756414800 - tz.transition 2026, 4, :o2, 1776981600 - tz.transition 2026, 8, :o1, 1787864400 - tz.transition 2027, 4, :o2, 1809036000 - tz.transition 2027, 8, :o1, 1819314000 - tz.transition 2028, 4, :o2, 1840485600 - tz.transition 2028, 8, :o1, 1851368400 - tz.transition 2029, 4, :o2, 1871935200 - tz.transition 2029, 8, :o1, 1882818000 - tz.transition 2030, 4, :o2, 1903384800 - tz.transition 2030, 8, :o1, 1914267600 - tz.transition 2031, 4, :o2, 1934834400 - tz.transition 2031, 8, :o1, 1945717200 - tz.transition 2032, 4, :o2, 1966888800 - tz.transition 2032, 8, :o1, 1977166800 - tz.transition 2033, 4, :o2, 1998338400 - tz.transition 2033, 8, :o1, 2008616400 - tz.transition 2034, 4, :o2, 2029788000 - tz.transition 2034, 8, :o1, 2040670800 - tz.transition 2035, 4, :o2, 2061237600 - tz.transition 2035, 8, :o1, 2072120400 - tz.transition 2036, 4, :o2, 2092687200 - tz.transition 2036, 8, :o1, 2103570000 - tz.transition 2037, 4, :o2, 2124136800 - tz.transition 2037, 8, :o1, 2135019600 - tz.transition 2038, 4, :o2, 29586521, 12 - tz.transition 2038, 8, :o1, 19725299, 8 - tz.transition 2039, 4, :o2, 29590889, 12 - tz.transition 2039, 8, :o1, 19728211, 8 - tz.transition 2040, 4, :o2, 29595257, 12 - tz.transition 2040, 8, :o1, 19731179, 8 - tz.transition 2041, 4, :o2, 29599625, 12 - tz.transition 2041, 8, :o1, 19734091, 8 - tz.transition 2042, 4, :o2, 29603993, 12 - tz.transition 2042, 8, :o1, 19737003, 8 - tz.transition 2043, 4, :o2, 29608361, 12 - tz.transition 2043, 8, :o1, 19739915, 8 - tz.transition 2044, 4, :o2, 29612813, 12 - tz.transition 2044, 8, :o1, 19742827, 8 - tz.transition 2045, 4, :o2, 29617181, 12 - tz.transition 2045, 8, :o1, 19745795, 8 - tz.transition 2046, 4, :o2, 29621549, 12 - tz.transition 2046, 8, :o1, 19748707, 8 - tz.transition 2047, 4, :o2, 29625917, 12 - tz.transition 2047, 8, :o1, 19751619, 8 - tz.transition 2048, 4, :o2, 29630285, 12 - tz.transition 2048, 8, :o1, 19754531, 8 - tz.transition 2049, 4, :o2, 29634737, 12 - tz.transition 2049, 8, :o1, 19757443, 8 - tz.transition 2050, 4, :o2, 29639105, 12 - tz.transition 2050, 8, :o1, 19760355, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Casablanca.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Casablanca.rb deleted file mode 100644 index d1eb5c5..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Casablanca.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Africa - module Casablanca - include TimezoneDefinition - - timezone 'Africa/Casablanca' do |tz| - tz.offset :o0, -1820, 0, :LMT - tz.offset :o1, 0, 0, :WET - tz.offset :o2, 0, 3600, :WEST - tz.offset :o3, 3600, 0, :CET - - tz.transition 1913, 10, :o1, 10454687371, 4320 - tz.transition 1939, 9, :o2, 4859037, 2 - tz.transition 1939, 11, :o1, 58310075, 24 - tz.transition 1940, 2, :o2, 4859369, 2 - tz.transition 1945, 11, :o1, 58362659, 24 - tz.transition 1950, 6, :o2, 4866887, 2 - tz.transition 1950, 10, :o1, 58406003, 24 - tz.transition 1967, 6, :o2, 2439645, 1 - tz.transition 1967, 9, :o1, 58554347, 24 - tz.transition 1974, 6, :o2, 141264000 - tz.transition 1974, 8, :o1, 147222000 - tz.transition 1976, 5, :o2, 199756800 - tz.transition 1976, 7, :o1, 207702000 - tz.transition 1977, 5, :o2, 231292800 - tz.transition 1977, 9, :o1, 244249200 - tz.transition 1978, 6, :o2, 265507200 - tz.transition 1978, 8, :o1, 271033200 - tz.transition 1984, 3, :o3, 448243200 - tz.transition 1985, 12, :o1, 504918000 - tz.transition 2008, 6, :o2, 1212278400 - tz.transition 2008, 8, :o1, 1220223600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Harare.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Harare.rb deleted file mode 100644 index 070c95a..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Harare.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Africa - module Harare - include TimezoneDefinition - - timezone 'Africa/Harare' do |tz| - tz.offset :o0, 7452, 0, :LMT - tz.offset :o1, 7200, 0, :CAT - - tz.transition 1903, 2, :o1, 1932939531, 800 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Johannesburg.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Johannesburg.rb deleted file mode 100644 index f0af0d8..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Johannesburg.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Africa - module Johannesburg - include TimezoneDefinition - - timezone 'Africa/Johannesburg' do |tz| - tz.offset :o0, 6720, 0, :LMT - tz.offset :o1, 5400, 0, :SAST - tz.offset :o2, 7200, 0, :SAST - tz.offset :o3, 7200, 3600, :SAST - - tz.transition 1892, 2, :o1, 108546139, 45 - tz.transition 1903, 2, :o2, 38658791, 16 - tz.transition 1942, 9, :o3, 4861245, 2 - tz.transition 1943, 3, :o2, 58339307, 24 - tz.transition 1943, 9, :o3, 4861973, 2 - tz.transition 1944, 3, :o2, 58348043, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Monrovia.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Monrovia.rb deleted file mode 100644 index 40e711f..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Monrovia.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Africa - module Monrovia - include TimezoneDefinition - - timezone 'Africa/Monrovia' do |tz| - tz.offset :o0, -2588, 0, :LMT - tz.offset :o1, -2588, 0, :MMT - tz.offset :o2, -2670, 0, :LRT - tz.offset :o3, 0, 0, :GMT - - tz.transition 1882, 1, :o1, 52022445047, 21600 - tz.transition 1919, 3, :o2, 52315600247, 21600 - tz.transition 1972, 5, :o3, 73529070 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Nairobi.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Nairobi.rb deleted file mode 100644 index 7b0a2f4..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Nairobi.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Africa - module Nairobi - include TimezoneDefinition - - timezone 'Africa/Nairobi' do |tz| - tz.offset :o0, 8836, 0, :LMT - tz.offset :o1, 10800, 0, :EAT - tz.offset :o2, 9000, 0, :BEAT - tz.offset :o3, 9885, 0, :BEAUT - - tz.transition 1928, 6, :o1, 52389253391, 21600 - tz.transition 1929, 12, :o2, 19407819, 8 - tz.transition 1939, 12, :o3, 116622211, 48 - tz.transition 1959, 12, :o1, 14036742061, 5760 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/Buenos_Aires.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/Buenos_Aires.rb deleted file mode 100644 index 8f4dd31..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +++ /dev/null @@ -1,166 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Argentina - module Buenos_Aires - include TimezoneDefinition - - timezone 'America/Argentina/Buenos_Aires' do |tz| - tz.offset :o0, -14028, 0, :LMT - tz.offset :o1, -15408, 0, :CMT - tz.offset :o2, -14400, 0, :ART - tz.offset :o3, -14400, 3600, :ARST - tz.offset :o4, -10800, 0, :ART - tz.offset :o5, -10800, 3600, :ARST - - tz.transition 1894, 10, :o1, 17374555169, 7200 - tz.transition 1920, 5, :o2, 1453467407, 600 - tz.transition 1930, 12, :o3, 7278935, 3 - tz.transition 1931, 4, :o2, 19411461, 8 - tz.transition 1931, 10, :o3, 7279889, 3 - tz.transition 1932, 3, :o2, 19414141, 8 - tz.transition 1932, 11, :o3, 7281038, 3 - tz.transition 1933, 3, :o2, 19417061, 8 - tz.transition 1933, 11, :o3, 7282133, 3 - tz.transition 1934, 3, :o2, 19419981, 8 - tz.transition 1934, 11, :o3, 7283228, 3 - tz.transition 1935, 3, :o2, 19422901, 8 - tz.transition 1935, 11, :o3, 7284323, 3 - tz.transition 1936, 3, :o2, 19425829, 8 - tz.transition 1936, 11, :o3, 7285421, 3 - tz.transition 1937, 3, :o2, 19428749, 8 - tz.transition 1937, 11, :o3, 7286516, 3 - tz.transition 1938, 3, :o2, 19431669, 8 - tz.transition 1938, 11, :o3, 7287611, 3 - tz.transition 1939, 3, :o2, 19434589, 8 - tz.transition 1939, 11, :o3, 7288706, 3 - tz.transition 1940, 3, :o2, 19437517, 8 - tz.transition 1940, 7, :o3, 7289435, 3 - tz.transition 1941, 6, :o2, 19441285, 8 - tz.transition 1941, 10, :o3, 7290848, 3 - tz.transition 1943, 8, :o2, 19447501, 8 - tz.transition 1943, 10, :o3, 7293038, 3 - tz.transition 1946, 3, :o2, 19455045, 8 - tz.transition 1946, 10, :o3, 7296284, 3 - tz.transition 1963, 10, :o2, 19506429, 8 - tz.transition 1963, 12, :o3, 7315136, 3 - tz.transition 1964, 3, :o2, 19507645, 8 - tz.transition 1964, 10, :o3, 7316051, 3 - tz.transition 1965, 3, :o2, 19510565, 8 - tz.transition 1965, 10, :o3, 7317146, 3 - tz.transition 1966, 3, :o2, 19513485, 8 - tz.transition 1966, 10, :o3, 7318241, 3 - tz.transition 1967, 4, :o2, 19516661, 8 - tz.transition 1967, 10, :o3, 7319294, 3 - tz.transition 1968, 4, :o2, 19519629, 8 - tz.transition 1968, 10, :o3, 7320407, 3 - tz.transition 1969, 4, :o2, 19522541, 8 - tz.transition 1969, 10, :o4, 7321499, 3 - tz.transition 1974, 1, :o5, 128142000 - tz.transition 1974, 5, :o4, 136605600 - tz.transition 1988, 12, :o5, 596948400 - tz.transition 1989, 3, :o4, 605066400 - tz.transition 1989, 10, :o5, 624423600 - tz.transition 1990, 3, :o4, 636516000 - tz.transition 1990, 10, :o5, 656478000 - tz.transition 1991, 3, :o4, 667965600 - tz.transition 1991, 10, :o5, 687927600 - tz.transition 1992, 3, :o4, 699415200 - tz.transition 1992, 10, :o5, 719377200 - tz.transition 1993, 3, :o4, 731469600 - tz.transition 1999, 10, :o3, 938919600 - tz.transition 2000, 3, :o4, 952052400 - tz.transition 2007, 12, :o5, 1198983600 - tz.transition 2008, 3, :o4, 1205632800 - tz.transition 2008, 10, :o5, 1224385200 - tz.transition 2009, 3, :o4, 1237082400 - tz.transition 2009, 10, :o5, 1255834800 - tz.transition 2010, 3, :o4, 1269136800 - tz.transition 2010, 10, :o5, 1287284400 - tz.transition 2011, 3, :o4, 1300586400 - tz.transition 2011, 10, :o5, 1318734000 - tz.transition 2012, 3, :o4, 1332036000 - tz.transition 2012, 10, :o5, 1350788400 - tz.transition 2013, 3, :o4, 1363485600 - tz.transition 2013, 10, :o5, 1382238000 - tz.transition 2014, 3, :o4, 1394935200 - tz.transition 2014, 10, :o5, 1413687600 - tz.transition 2015, 3, :o4, 1426384800 - tz.transition 2015, 10, :o5, 1445137200 - tz.transition 2016, 3, :o4, 1458439200 - tz.transition 2016, 10, :o5, 1476586800 - tz.transition 2017, 3, :o4, 1489888800 - tz.transition 2017, 10, :o5, 1508036400 - tz.transition 2018, 3, :o4, 1521338400 - tz.transition 2018, 10, :o5, 1540090800 - tz.transition 2019, 3, :o4, 1552788000 - tz.transition 2019, 10, :o5, 1571540400 - tz.transition 2020, 3, :o4, 1584237600 - tz.transition 2020, 10, :o5, 1602990000 - tz.transition 2021, 3, :o4, 1616292000 - tz.transition 2021, 10, :o5, 1634439600 - tz.transition 2022, 3, :o4, 1647741600 - tz.transition 2022, 10, :o5, 1665889200 - tz.transition 2023, 3, :o4, 1679191200 - tz.transition 2023, 10, :o5, 1697338800 - tz.transition 2024, 3, :o4, 1710640800 - tz.transition 2024, 10, :o5, 1729393200 - tz.transition 2025, 3, :o4, 1742090400 - tz.transition 2025, 10, :o5, 1760842800 - tz.transition 2026, 3, :o4, 1773540000 - tz.transition 2026, 10, :o5, 1792292400 - tz.transition 2027, 3, :o4, 1805594400 - tz.transition 2027, 10, :o5, 1823742000 - tz.transition 2028, 3, :o4, 1837044000 - tz.transition 2028, 10, :o5, 1855191600 - tz.transition 2029, 3, :o4, 1868493600 - tz.transition 2029, 10, :o5, 1887246000 - tz.transition 2030, 3, :o4, 1899943200 - tz.transition 2030, 10, :o5, 1918695600 - tz.transition 2031, 3, :o4, 1931392800 - tz.transition 2031, 10, :o5, 1950145200 - tz.transition 2032, 3, :o4, 1963447200 - tz.transition 2032, 10, :o5, 1981594800 - tz.transition 2033, 3, :o4, 1994896800 - tz.transition 2033, 10, :o5, 2013044400 - tz.transition 2034, 3, :o4, 2026346400 - tz.transition 2034, 10, :o5, 2044494000 - tz.transition 2035, 3, :o4, 2057796000 - tz.transition 2035, 10, :o5, 2076548400 - tz.transition 2036, 3, :o4, 2089245600 - tz.transition 2036, 10, :o5, 2107998000 - tz.transition 2037, 3, :o4, 2120695200 - tz.transition 2037, 10, :o5, 2139447600 - tz.transition 2038, 3, :o4, 29586043, 12 - tz.transition 2038, 10, :o5, 19725709, 8 - tz.transition 2039, 3, :o4, 29590411, 12 - tz.transition 2039, 10, :o5, 19728621, 8 - tz.transition 2040, 3, :o4, 29594779, 12 - tz.transition 2040, 10, :o5, 19731589, 8 - tz.transition 2041, 3, :o4, 29599147, 12 - tz.transition 2041, 10, :o5, 19734501, 8 - tz.transition 2042, 3, :o4, 29603515, 12 - tz.transition 2042, 10, :o5, 19737413, 8 - tz.transition 2043, 3, :o4, 29607883, 12 - tz.transition 2043, 10, :o5, 19740325, 8 - tz.transition 2044, 3, :o4, 29612335, 12 - tz.transition 2044, 10, :o5, 19743237, 8 - tz.transition 2045, 3, :o4, 29616703, 12 - tz.transition 2045, 10, :o5, 19746149, 8 - tz.transition 2046, 3, :o4, 29621071, 12 - tz.transition 2046, 10, :o5, 19749117, 8 - tz.transition 2047, 3, :o4, 29625439, 12 - tz.transition 2047, 10, :o5, 19752029, 8 - tz.transition 2048, 3, :o4, 29629807, 12 - tz.transition 2048, 10, :o5, 19754941, 8 - tz.transition 2049, 3, :o4, 29634259, 12 - tz.transition 2049, 10, :o5, 19757853, 8 - tz.transition 2050, 3, :o4, 29638627, 12 - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb deleted file mode 100644 index ba8be47..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +++ /dev/null @@ -1,86 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Argentina - module San_Juan - include TimezoneDefinition - - timezone 'America/Argentina/San_Juan' do |tz| - tz.offset :o0, -16444, 0, :LMT - tz.offset :o1, -15408, 0, :CMT - tz.offset :o2, -14400, 0, :ART - tz.offset :o3, -14400, 3600, :ARST - tz.offset :o4, -10800, 0, :ART - tz.offset :o5, -10800, 3600, :ARST - tz.offset :o6, -14400, 0, :WART - - tz.transition 1894, 10, :o1, 52123666111, 21600 - tz.transition 1920, 5, :o2, 1453467407, 600 - tz.transition 1930, 12, :o3, 7278935, 3 - tz.transition 1931, 4, :o2, 19411461, 8 - tz.transition 1931, 10, :o3, 7279889, 3 - tz.transition 1932, 3, :o2, 19414141, 8 - tz.transition 1932, 11, :o3, 7281038, 3 - tz.transition 1933, 3, :o2, 19417061, 8 - tz.transition 1933, 11, :o3, 7282133, 3 - tz.transition 1934, 3, :o2, 19419981, 8 - tz.transition 1934, 11, :o3, 7283228, 3 - tz.transition 1935, 3, :o2, 19422901, 8 - tz.transition 1935, 11, :o3, 7284323, 3 - tz.transition 1936, 3, :o2, 19425829, 8 - tz.transition 1936, 11, :o3, 7285421, 3 - tz.transition 1937, 3, :o2, 19428749, 8 - tz.transition 1937, 11, :o3, 7286516, 3 - tz.transition 1938, 3, :o2, 19431669, 8 - tz.transition 1938, 11, :o3, 7287611, 3 - tz.transition 1939, 3, :o2, 19434589, 8 - tz.transition 1939, 11, :o3, 7288706, 3 - tz.transition 1940, 3, :o2, 19437517, 8 - tz.transition 1940, 7, :o3, 7289435, 3 - tz.transition 1941, 6, :o2, 19441285, 8 - tz.transition 1941, 10, :o3, 7290848, 3 - tz.transition 1943, 8, :o2, 19447501, 8 - tz.transition 1943, 10, :o3, 7293038, 3 - tz.transition 1946, 3, :o2, 19455045, 8 - tz.transition 1946, 10, :o3, 7296284, 3 - tz.transition 1963, 10, :o2, 19506429, 8 - tz.transition 1963, 12, :o3, 7315136, 3 - tz.transition 1964, 3, :o2, 19507645, 8 - tz.transition 1964, 10, :o3, 7316051, 3 - tz.transition 1965, 3, :o2, 19510565, 8 - tz.transition 1965, 10, :o3, 7317146, 3 - tz.transition 1966, 3, :o2, 19513485, 8 - tz.transition 1966, 10, :o3, 7318241, 3 - tz.transition 1967, 4, :o2, 19516661, 8 - tz.transition 1967, 10, :o3, 7319294, 3 - tz.transition 1968, 4, :o2, 19519629, 8 - tz.transition 1968, 10, :o3, 7320407, 3 - tz.transition 1969, 4, :o2, 19522541, 8 - tz.transition 1969, 10, :o4, 7321499, 3 - tz.transition 1974, 1, :o5, 128142000 - tz.transition 1974, 5, :o4, 136605600 - tz.transition 1988, 12, :o5, 596948400 - tz.transition 1989, 3, :o4, 605066400 - tz.transition 1989, 10, :o5, 624423600 - tz.transition 1990, 3, :o4, 636516000 - tz.transition 1990, 10, :o5, 656478000 - tz.transition 1991, 3, :o6, 667792800 - tz.transition 1991, 5, :o4, 673588800 - tz.transition 1991, 10, :o5, 687927600 - tz.transition 1992, 3, :o4, 699415200 - tz.transition 1992, 10, :o5, 719377200 - tz.transition 1993, 3, :o4, 731469600 - tz.transition 1999, 10, :o3, 938919600 - tz.transition 2000, 3, :o4, 952052400 - tz.transition 2004, 5, :o6, 1085972400 - tz.transition 2004, 7, :o4, 1090728000 - tz.transition 2007, 12, :o5, 1198983600 - tz.transition 2008, 3, :o4, 1205632800 - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Bogota.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Bogota.rb deleted file mode 100644 index ef96435..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Bogota.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Bogota - include TimezoneDefinition - - timezone 'America/Bogota' do |tz| - tz.offset :o0, -17780, 0, :LMT - tz.offset :o1, -17780, 0, :BMT - tz.offset :o2, -18000, 0, :COT - tz.offset :o3, -18000, 3600, :COST - - tz.transition 1884, 3, :o1, 10407954409, 4320 - tz.transition 1914, 11, :o2, 10456385929, 4320 - tz.transition 1992, 5, :o3, 704869200 - tz.transition 1993, 4, :o2, 733896000 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Caracas.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Caracas.rb deleted file mode 100644 index 27392a5..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Caracas.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Caracas - include TimezoneDefinition - - timezone 'America/Caracas' do |tz| - tz.offset :o0, -16064, 0, :LMT - tz.offset :o1, -16060, 0, :CMT - tz.offset :o2, -16200, 0, :VET - tz.offset :o3, -14400, 0, :VET - - tz.transition 1890, 1, :o1, 1627673863, 675 - tz.transition 1912, 2, :o2, 10452001043, 4320 - tz.transition 1965, 1, :o3, 39020187, 16 - tz.transition 2007, 12, :o2, 1197183600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chicago.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chicago.rb deleted file mode 100644 index 0996857..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chicago.rb +++ /dev/null @@ -1,283 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Chicago - include TimezoneDefinition - - timezone 'America/Chicago' do |tz| - tz.offset :o0, -21036, 0, :LMT - tz.offset :o1, -21600, 0, :CST - tz.offset :o2, -21600, 3600, :CDT - tz.offset :o3, -18000, 0, :EST - tz.offset :o4, -21600, 3600, :CWT - tz.offset :o5, -21600, 3600, :CPT - - tz.transition 1883, 11, :o1, 9636533, 4 - tz.transition 1918, 3, :o2, 14530103, 6 - tz.transition 1918, 10, :o1, 58125451, 24 - tz.transition 1919, 3, :o2, 14532287, 6 - tz.transition 1919, 10, :o1, 58134187, 24 - tz.transition 1920, 6, :o2, 14534933, 6 - tz.transition 1920, 10, :o1, 58143091, 24 - tz.transition 1921, 3, :o2, 14536655, 6 - tz.transition 1921, 10, :o1, 58151827, 24 - tz.transition 1922, 4, :o2, 14539049, 6 - tz.transition 1922, 9, :o1, 58159723, 24 - tz.transition 1923, 4, :o2, 14541233, 6 - tz.transition 1923, 9, :o1, 58168627, 24 - tz.transition 1924, 4, :o2, 14543417, 6 - tz.transition 1924, 9, :o1, 58177363, 24 - tz.transition 1925, 4, :o2, 14545601, 6 - tz.transition 1925, 9, :o1, 58186099, 24 - tz.transition 1926, 4, :o2, 14547785, 6 - tz.transition 1926, 9, :o1, 58194835, 24 - tz.transition 1927, 4, :o2, 14549969, 6 - tz.transition 1927, 9, :o1, 58203571, 24 - tz.transition 1928, 4, :o2, 14552195, 6 - tz.transition 1928, 9, :o1, 58212475, 24 - tz.transition 1929, 4, :o2, 14554379, 6 - tz.transition 1929, 9, :o1, 58221211, 24 - tz.transition 1930, 4, :o2, 14556563, 6 - tz.transition 1930, 9, :o1, 58229947, 24 - tz.transition 1931, 4, :o2, 14558747, 6 - tz.transition 1931, 9, :o1, 58238683, 24 - tz.transition 1932, 4, :o2, 14560931, 6 - tz.transition 1932, 9, :o1, 58247419, 24 - tz.transition 1933, 4, :o2, 14563157, 6 - tz.transition 1933, 9, :o1, 58256155, 24 - tz.transition 1934, 4, :o2, 14565341, 6 - tz.transition 1934, 9, :o1, 58265059, 24 - tz.transition 1935, 4, :o2, 14567525, 6 - tz.transition 1935, 9, :o1, 58273795, 24 - tz.transition 1936, 3, :o3, 14569373, 6 - tz.transition 1936, 11, :o1, 58283707, 24 - tz.transition 1937, 4, :o2, 14571893, 6 - tz.transition 1937, 9, :o1, 58291267, 24 - tz.transition 1938, 4, :o2, 14574077, 6 - tz.transition 1938, 9, :o1, 58300003, 24 - tz.transition 1939, 4, :o2, 14576303, 6 - tz.transition 1939, 9, :o1, 58308739, 24 - tz.transition 1940, 4, :o2, 14578487, 6 - tz.transition 1940, 9, :o1, 58317643, 24 - tz.transition 1941, 4, :o2, 14580671, 6 - tz.transition 1941, 9, :o1, 58326379, 24 - tz.transition 1942, 2, :o4, 14582399, 6 - tz.transition 1945, 8, :o5, 58360379, 24 - tz.transition 1945, 9, :o1, 58361491, 24 - tz.transition 1946, 4, :o2, 14591633, 6 - tz.transition 1946, 9, :o1, 58370227, 24 - tz.transition 1947, 4, :o2, 14593817, 6 - tz.transition 1947, 9, :o1, 58378963, 24 - tz.transition 1948, 4, :o2, 14596001, 6 - tz.transition 1948, 9, :o1, 58387699, 24 - tz.transition 1949, 4, :o2, 14598185, 6 - tz.transition 1949, 9, :o1, 58396435, 24 - tz.transition 1950, 4, :o2, 14600411, 6 - tz.transition 1950, 9, :o1, 58405171, 24 - tz.transition 1951, 4, :o2, 14602595, 6 - tz.transition 1951, 9, :o1, 58414075, 24 - tz.transition 1952, 4, :o2, 14604779, 6 - tz.transition 1952, 9, :o1, 58422811, 24 - tz.transition 1953, 4, :o2, 14606963, 6 - tz.transition 1953, 9, :o1, 58431547, 24 - tz.transition 1954, 4, :o2, 14609147, 6 - tz.transition 1954, 9, :o1, 58440283, 24 - tz.transition 1955, 4, :o2, 14611331, 6 - tz.transition 1955, 10, :o1, 58449859, 24 - tz.transition 1956, 4, :o2, 14613557, 6 - tz.transition 1956, 10, :o1, 58458595, 24 - tz.transition 1957, 4, :o2, 14615741, 6 - tz.transition 1957, 10, :o1, 58467331, 24 - tz.transition 1958, 4, :o2, 14617925, 6 - tz.transition 1958, 10, :o1, 58476067, 24 - tz.transition 1959, 4, :o2, 14620109, 6 - tz.transition 1959, 10, :o1, 58484803, 24 - tz.transition 1960, 4, :o2, 14622293, 6 - tz.transition 1960, 10, :o1, 58493707, 24 - tz.transition 1961, 4, :o2, 14624519, 6 - tz.transition 1961, 10, :o1, 58502443, 24 - tz.transition 1962, 4, :o2, 14626703, 6 - tz.transition 1962, 10, :o1, 58511179, 24 - tz.transition 1963, 4, :o2, 14628887, 6 - tz.transition 1963, 10, :o1, 58519915, 24 - tz.transition 1964, 4, :o2, 14631071, 6 - tz.transition 1964, 10, :o1, 58528651, 24 - tz.transition 1965, 4, :o2, 14633255, 6 - tz.transition 1965, 10, :o1, 58537555, 24 - tz.transition 1966, 4, :o2, 14635439, 6 - tz.transition 1966, 10, :o1, 58546291, 24 - tz.transition 1967, 4, :o2, 14637665, 6 - tz.transition 1967, 10, :o1, 58555027, 24 - tz.transition 1968, 4, :o2, 14639849, 6 - tz.transition 1968, 10, :o1, 58563763, 24 - tz.transition 1969, 4, :o2, 14642033, 6 - tz.transition 1969, 10, :o1, 58572499, 24 - tz.transition 1970, 4, :o2, 9964800 - tz.transition 1970, 10, :o1, 25686000 - tz.transition 1971, 4, :o2, 41414400 - tz.transition 1971, 10, :o1, 57740400 - tz.transition 1972, 4, :o2, 73468800 - tz.transition 1972, 10, :o1, 89190000 - tz.transition 1973, 4, :o2, 104918400 - tz.transition 1973, 10, :o1, 120639600 - tz.transition 1974, 1, :o2, 126691200 - tz.transition 1974, 10, :o1, 152089200 - tz.transition 1975, 2, :o2, 162374400 - tz.transition 1975, 10, :o1, 183538800 - tz.transition 1976, 4, :o2, 199267200 - tz.transition 1976, 10, :o1, 215593200 - tz.transition 1977, 4, :o2, 230716800 - tz.transition 1977, 10, :o1, 247042800 - tz.transition 1978, 4, :o2, 262771200 - tz.transition 1978, 10, :o1, 278492400 - tz.transition 1979, 4, :o2, 294220800 - tz.transition 1979, 10, :o1, 309942000 - tz.transition 1980, 4, :o2, 325670400 - tz.transition 1980, 10, :o1, 341391600 - tz.transition 1981, 4, :o2, 357120000 - tz.transition 1981, 10, :o1, 372841200 - tz.transition 1982, 4, :o2, 388569600 - tz.transition 1982, 10, :o1, 404895600 - tz.transition 1983, 4, :o2, 420019200 - tz.transition 1983, 10, :o1, 436345200 - tz.transition 1984, 4, :o2, 452073600 - tz.transition 1984, 10, :o1, 467794800 - tz.transition 1985, 4, :o2, 483523200 - tz.transition 1985, 10, :o1, 499244400 - tz.transition 1986, 4, :o2, 514972800 - tz.transition 1986, 10, :o1, 530694000 - tz.transition 1987, 4, :o2, 544608000 - tz.transition 1987, 10, :o1, 562143600 - tz.transition 1988, 4, :o2, 576057600 - tz.transition 1988, 10, :o1, 594198000 - tz.transition 1989, 4, :o2, 607507200 - tz.transition 1989, 10, :o1, 625647600 - tz.transition 1990, 4, :o2, 638956800 - tz.transition 1990, 10, :o1, 657097200 - tz.transition 1991, 4, :o2, 671011200 - tz.transition 1991, 10, :o1, 688546800 - tz.transition 1992, 4, :o2, 702460800 - tz.transition 1992, 10, :o1, 719996400 - tz.transition 1993, 4, :o2, 733910400 - tz.transition 1993, 10, :o1, 752050800 - tz.transition 1994, 4, :o2, 765360000 - tz.transition 1994, 10, :o1, 783500400 - tz.transition 1995, 4, :o2, 796809600 - tz.transition 1995, 10, :o1, 814950000 - tz.transition 1996, 4, :o2, 828864000 - tz.transition 1996, 10, :o1, 846399600 - tz.transition 1997, 4, :o2, 860313600 - tz.transition 1997, 10, :o1, 877849200 - tz.transition 1998, 4, :o2, 891763200 - tz.transition 1998, 10, :o1, 909298800 - tz.transition 1999, 4, :o2, 923212800 - tz.transition 1999, 10, :o1, 941353200 - tz.transition 2000, 4, :o2, 954662400 - tz.transition 2000, 10, :o1, 972802800 - tz.transition 2001, 4, :o2, 986112000 - tz.transition 2001, 10, :o1, 1004252400 - tz.transition 2002, 4, :o2, 1018166400 - tz.transition 2002, 10, :o1, 1035702000 - tz.transition 2003, 4, :o2, 1049616000 - tz.transition 2003, 10, :o1, 1067151600 - tz.transition 2004, 4, :o2, 1081065600 - tz.transition 2004, 10, :o1, 1099206000 - tz.transition 2005, 4, :o2, 1112515200 - tz.transition 2005, 10, :o1, 1130655600 - tz.transition 2006, 4, :o2, 1143964800 - tz.transition 2006, 10, :o1, 1162105200 - tz.transition 2007, 3, :o2, 1173600000 - tz.transition 2007, 11, :o1, 1194159600 - tz.transition 2008, 3, :o2, 1205049600 - tz.transition 2008, 11, :o1, 1225609200 - tz.transition 2009, 3, :o2, 1236499200 - tz.transition 2009, 11, :o1, 1257058800 - tz.transition 2010, 3, :o2, 1268553600 - tz.transition 2010, 11, :o1, 1289113200 - tz.transition 2011, 3, :o2, 1300003200 - tz.transition 2011, 11, :o1, 1320562800 - tz.transition 2012, 3, :o2, 1331452800 - tz.transition 2012, 11, :o1, 1352012400 - tz.transition 2013, 3, :o2, 1362902400 - tz.transition 2013, 11, :o1, 1383462000 - tz.transition 2014, 3, :o2, 1394352000 - tz.transition 2014, 11, :o1, 1414911600 - tz.transition 2015, 3, :o2, 1425801600 - tz.transition 2015, 11, :o1, 1446361200 - tz.transition 2016, 3, :o2, 1457856000 - tz.transition 2016, 11, :o1, 1478415600 - tz.transition 2017, 3, :o2, 1489305600 - tz.transition 2017, 11, :o1, 1509865200 - tz.transition 2018, 3, :o2, 1520755200 - tz.transition 2018, 11, :o1, 1541314800 - tz.transition 2019, 3, :o2, 1552204800 - tz.transition 2019, 11, :o1, 1572764400 - tz.transition 2020, 3, :o2, 1583654400 - tz.transition 2020, 11, :o1, 1604214000 - tz.transition 2021, 3, :o2, 1615708800 - tz.transition 2021, 11, :o1, 1636268400 - tz.transition 2022, 3, :o2, 1647158400 - tz.transition 2022, 11, :o1, 1667718000 - tz.transition 2023, 3, :o2, 1678608000 - tz.transition 2023, 11, :o1, 1699167600 - tz.transition 2024, 3, :o2, 1710057600 - tz.transition 2024, 11, :o1, 1730617200 - tz.transition 2025, 3, :o2, 1741507200 - tz.transition 2025, 11, :o1, 1762066800 - tz.transition 2026, 3, :o2, 1772956800 - tz.transition 2026, 11, :o1, 1793516400 - tz.transition 2027, 3, :o2, 1805011200 - tz.transition 2027, 11, :o1, 1825570800 - tz.transition 2028, 3, :o2, 1836460800 - tz.transition 2028, 11, :o1, 1857020400 - tz.transition 2029, 3, :o2, 1867910400 - tz.transition 2029, 11, :o1, 1888470000 - tz.transition 2030, 3, :o2, 1899360000 - tz.transition 2030, 11, :o1, 1919919600 - tz.transition 2031, 3, :o2, 1930809600 - tz.transition 2031, 11, :o1, 1951369200 - tz.transition 2032, 3, :o2, 1962864000 - tz.transition 2032, 11, :o1, 1983423600 - tz.transition 2033, 3, :o2, 1994313600 - tz.transition 2033, 11, :o1, 2014873200 - tz.transition 2034, 3, :o2, 2025763200 - tz.transition 2034, 11, :o1, 2046322800 - tz.transition 2035, 3, :o2, 2057212800 - tz.transition 2035, 11, :o1, 2077772400 - tz.transition 2036, 3, :o2, 2088662400 - tz.transition 2036, 11, :o1, 2109222000 - tz.transition 2037, 3, :o2, 2120112000 - tz.transition 2037, 11, :o1, 2140671600 - tz.transition 2038, 3, :o2, 14792981, 6 - tz.transition 2038, 11, :o1, 59177635, 24 - tz.transition 2039, 3, :o2, 14795165, 6 - tz.transition 2039, 11, :o1, 59186371, 24 - tz.transition 2040, 3, :o2, 14797349, 6 - tz.transition 2040, 11, :o1, 59195107, 24 - tz.transition 2041, 3, :o2, 14799533, 6 - tz.transition 2041, 11, :o1, 59203843, 24 - tz.transition 2042, 3, :o2, 14801717, 6 - tz.transition 2042, 11, :o1, 59212579, 24 - tz.transition 2043, 3, :o2, 14803901, 6 - tz.transition 2043, 11, :o1, 59221315, 24 - tz.transition 2044, 3, :o2, 14806127, 6 - tz.transition 2044, 11, :o1, 59230219, 24 - tz.transition 2045, 3, :o2, 14808311, 6 - tz.transition 2045, 11, :o1, 59238955, 24 - tz.transition 2046, 3, :o2, 14810495, 6 - tz.transition 2046, 11, :o1, 59247691, 24 - tz.transition 2047, 3, :o2, 14812679, 6 - tz.transition 2047, 11, :o1, 59256427, 24 - tz.transition 2048, 3, :o2, 14814863, 6 - tz.transition 2048, 11, :o1, 59265163, 24 - tz.transition 2049, 3, :o2, 14817089, 6 - tz.transition 2049, 11, :o1, 59274067, 24 - tz.transition 2050, 3, :o2, 14819273, 6 - tz.transition 2050, 11, :o1, 59282803, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chihuahua.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chihuahua.rb deleted file mode 100644 index 1710b57..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chihuahua.rb +++ /dev/null @@ -1,136 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Chihuahua - include TimezoneDefinition - - timezone 'America/Chihuahua' do |tz| - tz.offset :o0, -25460, 0, :LMT - tz.offset :o1, -25200, 0, :MST - tz.offset :o2, -21600, 0, :CST - tz.offset :o3, -21600, 3600, :CDT - tz.offset :o4, -25200, 3600, :MDT - - tz.transition 1922, 1, :o1, 58153339, 24 - tz.transition 1927, 6, :o2, 9700171, 4 - tz.transition 1930, 11, :o1, 9705183, 4 - tz.transition 1931, 5, :o2, 9705855, 4 - tz.transition 1931, 10, :o1, 9706463, 4 - tz.transition 1932, 4, :o2, 58243171, 24 - tz.transition 1996, 4, :o3, 828864000 - tz.transition 1996, 10, :o2, 846399600 - tz.transition 1997, 4, :o3, 860313600 - tz.transition 1997, 10, :o2, 877849200 - tz.transition 1998, 4, :o4, 891766800 - tz.transition 1998, 10, :o1, 909302400 - tz.transition 1999, 4, :o4, 923216400 - tz.transition 1999, 10, :o1, 941356800 - tz.transition 2000, 4, :o4, 954666000 - tz.transition 2000, 10, :o1, 972806400 - tz.transition 2001, 5, :o4, 989139600 - tz.transition 2001, 9, :o1, 1001836800 - tz.transition 2002, 4, :o4, 1018170000 - tz.transition 2002, 10, :o1, 1035705600 - tz.transition 2003, 4, :o4, 1049619600 - tz.transition 2003, 10, :o1, 1067155200 - tz.transition 2004, 4, :o4, 1081069200 - tz.transition 2004, 10, :o1, 1099209600 - tz.transition 2005, 4, :o4, 1112518800 - tz.transition 2005, 10, :o1, 1130659200 - tz.transition 2006, 4, :o4, 1143968400 - tz.transition 2006, 10, :o1, 1162108800 - tz.transition 2007, 4, :o4, 1175418000 - tz.transition 2007, 10, :o1, 1193558400 - tz.transition 2008, 4, :o4, 1207472400 - tz.transition 2008, 10, :o1, 1225008000 - tz.transition 2009, 4, :o4, 1238922000 - tz.transition 2009, 10, :o1, 1256457600 - tz.transition 2010, 4, :o4, 1270371600 - tz.transition 2010, 10, :o1, 1288512000 - tz.transition 2011, 4, :o4, 1301821200 - tz.transition 2011, 10, :o1, 1319961600 - tz.transition 2012, 4, :o4, 1333270800 - tz.transition 2012, 10, :o1, 1351411200 - tz.transition 2013, 4, :o4, 1365325200 - tz.transition 2013, 10, :o1, 1382860800 - tz.transition 2014, 4, :o4, 1396774800 - tz.transition 2014, 10, :o1, 1414310400 - tz.transition 2015, 4, :o4, 1428224400 - tz.transition 2015, 10, :o1, 1445760000 - tz.transition 2016, 4, :o4, 1459674000 - tz.transition 2016, 10, :o1, 1477814400 - tz.transition 2017, 4, :o4, 1491123600 - tz.transition 2017, 10, :o1, 1509264000 - tz.transition 2018, 4, :o4, 1522573200 - tz.transition 2018, 10, :o1, 1540713600 - tz.transition 2019, 4, :o4, 1554627600 - tz.transition 2019, 10, :o1, 1572163200 - tz.transition 2020, 4, :o4, 1586077200 - tz.transition 2020, 10, :o1, 1603612800 - tz.transition 2021, 4, :o4, 1617526800 - tz.transition 2021, 10, :o1, 1635667200 - tz.transition 2022, 4, :o4, 1648976400 - tz.transition 2022, 10, :o1, 1667116800 - tz.transition 2023, 4, :o4, 1680426000 - tz.transition 2023, 10, :o1, 1698566400 - tz.transition 2024, 4, :o4, 1712480400 - tz.transition 2024, 10, :o1, 1730016000 - tz.transition 2025, 4, :o4, 1743930000 - tz.transition 2025, 10, :o1, 1761465600 - tz.transition 2026, 4, :o4, 1775379600 - tz.transition 2026, 10, :o1, 1792915200 - tz.transition 2027, 4, :o4, 1806829200 - tz.transition 2027, 10, :o1, 1824969600 - tz.transition 2028, 4, :o4, 1838278800 - tz.transition 2028, 10, :o1, 1856419200 - tz.transition 2029, 4, :o4, 1869728400 - tz.transition 2029, 10, :o1, 1887868800 - tz.transition 2030, 4, :o4, 1901782800 - tz.transition 2030, 10, :o1, 1919318400 - tz.transition 2031, 4, :o4, 1933232400 - tz.transition 2031, 10, :o1, 1950768000 - tz.transition 2032, 4, :o4, 1964682000 - tz.transition 2032, 10, :o1, 1982822400 - tz.transition 2033, 4, :o4, 1996131600 - tz.transition 2033, 10, :o1, 2014272000 - tz.transition 2034, 4, :o4, 2027581200 - tz.transition 2034, 10, :o1, 2045721600 - tz.transition 2035, 4, :o4, 2059030800 - tz.transition 2035, 10, :o1, 2077171200 - tz.transition 2036, 4, :o4, 2091085200 - tz.transition 2036, 10, :o1, 2108620800 - tz.transition 2037, 4, :o4, 2122534800 - tz.transition 2037, 10, :o1, 2140070400 - tz.transition 2038, 4, :o4, 19724143, 8 - tz.transition 2038, 10, :o1, 14794367, 6 - tz.transition 2039, 4, :o4, 19727055, 8 - tz.transition 2039, 10, :o1, 14796551, 6 - tz.transition 2040, 4, :o4, 19729967, 8 - tz.transition 2040, 10, :o1, 14798735, 6 - tz.transition 2041, 4, :o4, 19732935, 8 - tz.transition 2041, 10, :o1, 14800919, 6 - tz.transition 2042, 4, :o4, 19735847, 8 - tz.transition 2042, 10, :o1, 14803103, 6 - tz.transition 2043, 4, :o4, 19738759, 8 - tz.transition 2043, 10, :o1, 14805287, 6 - tz.transition 2044, 4, :o4, 19741671, 8 - tz.transition 2044, 10, :o1, 14807513, 6 - tz.transition 2045, 4, :o4, 19744583, 8 - tz.transition 2045, 10, :o1, 14809697, 6 - tz.transition 2046, 4, :o4, 19747495, 8 - tz.transition 2046, 10, :o1, 14811881, 6 - tz.transition 2047, 4, :o4, 19750463, 8 - tz.transition 2047, 10, :o1, 14814065, 6 - tz.transition 2048, 4, :o4, 19753375, 8 - tz.transition 2048, 10, :o1, 14816249, 6 - tz.transition 2049, 4, :o4, 19756287, 8 - tz.transition 2049, 10, :o1, 14818475, 6 - tz.transition 2050, 4, :o4, 19759199, 8 - tz.transition 2050, 10, :o1, 14820659, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Denver.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Denver.rb deleted file mode 100644 index 1c1efb5..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Denver.rb +++ /dev/null @@ -1,204 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Denver - include TimezoneDefinition - - timezone 'America/Denver' do |tz| - tz.offset :o0, -25196, 0, :LMT - tz.offset :o1, -25200, 0, :MST - tz.offset :o2, -25200, 3600, :MDT - tz.offset :o3, -25200, 3600, :MWT - tz.offset :o4, -25200, 3600, :MPT - - tz.transition 1883, 11, :o1, 57819199, 24 - tz.transition 1918, 3, :o2, 19373471, 8 - tz.transition 1918, 10, :o1, 14531363, 6 - tz.transition 1919, 3, :o2, 19376383, 8 - tz.transition 1919, 10, :o1, 14533547, 6 - tz.transition 1920, 3, :o2, 19379295, 8 - tz.transition 1920, 10, :o1, 14535773, 6 - tz.transition 1921, 3, :o2, 19382207, 8 - tz.transition 1921, 5, :o1, 14536991, 6 - tz.transition 1942, 2, :o3, 19443199, 8 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o1, 14590373, 6 - tz.transition 1965, 4, :o2, 19511007, 8 - tz.transition 1965, 10, :o1, 14634389, 6 - tz.transition 1966, 4, :o2, 19513919, 8 - tz.transition 1966, 10, :o1, 14636573, 6 - tz.transition 1967, 4, :o2, 19516887, 8 - tz.transition 1967, 10, :o1, 14638757, 6 - tz.transition 1968, 4, :o2, 19519799, 8 - tz.transition 1968, 10, :o1, 14640941, 6 - tz.transition 1969, 4, :o2, 19522711, 8 - tz.transition 1969, 10, :o1, 14643125, 6 - tz.transition 1970, 4, :o2, 9968400 - tz.transition 1970, 10, :o1, 25689600 - tz.transition 1971, 4, :o2, 41418000 - tz.transition 1971, 10, :o1, 57744000 - tz.transition 1972, 4, :o2, 73472400 - tz.transition 1972, 10, :o1, 89193600 - tz.transition 1973, 4, :o2, 104922000 - tz.transition 1973, 10, :o1, 120643200 - tz.transition 1974, 1, :o2, 126694800 - tz.transition 1974, 10, :o1, 152092800 - tz.transition 1975, 2, :o2, 162378000 - tz.transition 1975, 10, :o1, 183542400 - tz.transition 1976, 4, :o2, 199270800 - tz.transition 1976, 10, :o1, 215596800 - tz.transition 1977, 4, :o2, 230720400 - tz.transition 1977, 10, :o1, 247046400 - tz.transition 1978, 4, :o2, 262774800 - tz.transition 1978, 10, :o1, 278496000 - tz.transition 1979, 4, :o2, 294224400 - tz.transition 1979, 10, :o1, 309945600 - tz.transition 1980, 4, :o2, 325674000 - tz.transition 1980, 10, :o1, 341395200 - tz.transition 1981, 4, :o2, 357123600 - tz.transition 1981, 10, :o1, 372844800 - tz.transition 1982, 4, :o2, 388573200 - tz.transition 1982, 10, :o1, 404899200 - tz.transition 1983, 4, :o2, 420022800 - tz.transition 1983, 10, :o1, 436348800 - tz.transition 1984, 4, :o2, 452077200 - tz.transition 1984, 10, :o1, 467798400 - tz.transition 1985, 4, :o2, 483526800 - tz.transition 1985, 10, :o1, 499248000 - tz.transition 1986, 4, :o2, 514976400 - tz.transition 1986, 10, :o1, 530697600 - tz.transition 1987, 4, :o2, 544611600 - tz.transition 1987, 10, :o1, 562147200 - tz.transition 1988, 4, :o2, 576061200 - tz.transition 1988, 10, :o1, 594201600 - tz.transition 1989, 4, :o2, 607510800 - tz.transition 1989, 10, :o1, 625651200 - tz.transition 1990, 4, :o2, 638960400 - tz.transition 1990, 10, :o1, 657100800 - tz.transition 1991, 4, :o2, 671014800 - tz.transition 1991, 10, :o1, 688550400 - tz.transition 1992, 4, :o2, 702464400 - tz.transition 1992, 10, :o1, 720000000 - tz.transition 1993, 4, :o2, 733914000 - tz.transition 1993, 10, :o1, 752054400 - tz.transition 1994, 4, :o2, 765363600 - tz.transition 1994, 10, :o1, 783504000 - tz.transition 1995, 4, :o2, 796813200 - tz.transition 1995, 10, :o1, 814953600 - tz.transition 1996, 4, :o2, 828867600 - tz.transition 1996, 10, :o1, 846403200 - tz.transition 1997, 4, :o2, 860317200 - tz.transition 1997, 10, :o1, 877852800 - tz.transition 1998, 4, :o2, 891766800 - tz.transition 1998, 10, :o1, 909302400 - tz.transition 1999, 4, :o2, 923216400 - tz.transition 1999, 10, :o1, 941356800 - tz.transition 2000, 4, :o2, 954666000 - tz.transition 2000, 10, :o1, 972806400 - tz.transition 2001, 4, :o2, 986115600 - tz.transition 2001, 10, :o1, 1004256000 - tz.transition 2002, 4, :o2, 1018170000 - tz.transition 2002, 10, :o1, 1035705600 - tz.transition 2003, 4, :o2, 1049619600 - tz.transition 2003, 10, :o1, 1067155200 - tz.transition 2004, 4, :o2, 1081069200 - tz.transition 2004, 10, :o1, 1099209600 - tz.transition 2005, 4, :o2, 1112518800 - tz.transition 2005, 10, :o1, 1130659200 - tz.transition 2006, 4, :o2, 1143968400 - tz.transition 2006, 10, :o1, 1162108800 - tz.transition 2007, 3, :o2, 1173603600 - tz.transition 2007, 11, :o1, 1194163200 - tz.transition 2008, 3, :o2, 1205053200 - tz.transition 2008, 11, :o1, 1225612800 - tz.transition 2009, 3, :o2, 1236502800 - tz.transition 2009, 11, :o1, 1257062400 - tz.transition 2010, 3, :o2, 1268557200 - tz.transition 2010, 11, :o1, 1289116800 - tz.transition 2011, 3, :o2, 1300006800 - tz.transition 2011, 11, :o1, 1320566400 - tz.transition 2012, 3, :o2, 1331456400 - tz.transition 2012, 11, :o1, 1352016000 - tz.transition 2013, 3, :o2, 1362906000 - tz.transition 2013, 11, :o1, 1383465600 - tz.transition 2014, 3, :o2, 1394355600 - tz.transition 2014, 11, :o1, 1414915200 - tz.transition 2015, 3, :o2, 1425805200 - tz.transition 2015, 11, :o1, 1446364800 - tz.transition 2016, 3, :o2, 1457859600 - tz.transition 2016, 11, :o1, 1478419200 - tz.transition 2017, 3, :o2, 1489309200 - tz.transition 2017, 11, :o1, 1509868800 - tz.transition 2018, 3, :o2, 1520758800 - tz.transition 2018, 11, :o1, 1541318400 - tz.transition 2019, 3, :o2, 1552208400 - tz.transition 2019, 11, :o1, 1572768000 - tz.transition 2020, 3, :o2, 1583658000 - tz.transition 2020, 11, :o1, 1604217600 - tz.transition 2021, 3, :o2, 1615712400 - tz.transition 2021, 11, :o1, 1636272000 - tz.transition 2022, 3, :o2, 1647162000 - tz.transition 2022, 11, :o1, 1667721600 - tz.transition 2023, 3, :o2, 1678611600 - tz.transition 2023, 11, :o1, 1699171200 - tz.transition 2024, 3, :o2, 1710061200 - tz.transition 2024, 11, :o1, 1730620800 - tz.transition 2025, 3, :o2, 1741510800 - tz.transition 2025, 11, :o1, 1762070400 - tz.transition 2026, 3, :o2, 1772960400 - tz.transition 2026, 11, :o1, 1793520000 - tz.transition 2027, 3, :o2, 1805014800 - tz.transition 2027, 11, :o1, 1825574400 - tz.transition 2028, 3, :o2, 1836464400 - tz.transition 2028, 11, :o1, 1857024000 - tz.transition 2029, 3, :o2, 1867914000 - tz.transition 2029, 11, :o1, 1888473600 - tz.transition 2030, 3, :o2, 1899363600 - tz.transition 2030, 11, :o1, 1919923200 - tz.transition 2031, 3, :o2, 1930813200 - tz.transition 2031, 11, :o1, 1951372800 - tz.transition 2032, 3, :o2, 1962867600 - tz.transition 2032, 11, :o1, 1983427200 - tz.transition 2033, 3, :o2, 1994317200 - tz.transition 2033, 11, :o1, 2014876800 - tz.transition 2034, 3, :o2, 2025766800 - tz.transition 2034, 11, :o1, 2046326400 - tz.transition 2035, 3, :o2, 2057216400 - tz.transition 2035, 11, :o1, 2077776000 - tz.transition 2036, 3, :o2, 2088666000 - tz.transition 2036, 11, :o1, 2109225600 - tz.transition 2037, 3, :o2, 2120115600 - tz.transition 2037, 11, :o1, 2140675200 - tz.transition 2038, 3, :o2, 19723975, 8 - tz.transition 2038, 11, :o1, 14794409, 6 - tz.transition 2039, 3, :o2, 19726887, 8 - tz.transition 2039, 11, :o1, 14796593, 6 - tz.transition 2040, 3, :o2, 19729799, 8 - tz.transition 2040, 11, :o1, 14798777, 6 - tz.transition 2041, 3, :o2, 19732711, 8 - tz.transition 2041, 11, :o1, 14800961, 6 - tz.transition 2042, 3, :o2, 19735623, 8 - tz.transition 2042, 11, :o1, 14803145, 6 - tz.transition 2043, 3, :o2, 19738535, 8 - tz.transition 2043, 11, :o1, 14805329, 6 - tz.transition 2044, 3, :o2, 19741503, 8 - tz.transition 2044, 11, :o1, 14807555, 6 - tz.transition 2045, 3, :o2, 19744415, 8 - tz.transition 2045, 11, :o1, 14809739, 6 - tz.transition 2046, 3, :o2, 19747327, 8 - tz.transition 2046, 11, :o1, 14811923, 6 - tz.transition 2047, 3, :o2, 19750239, 8 - tz.transition 2047, 11, :o1, 14814107, 6 - tz.transition 2048, 3, :o2, 19753151, 8 - tz.transition 2048, 11, :o1, 14816291, 6 - tz.transition 2049, 3, :o2, 19756119, 8 - tz.transition 2049, 11, :o1, 14818517, 6 - tz.transition 2050, 3, :o2, 19759031, 8 - tz.transition 2050, 11, :o1, 14820701, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Godthab.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Godthab.rb deleted file mode 100644 index 1e05518..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Godthab.rb +++ /dev/null @@ -1,161 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Godthab - include TimezoneDefinition - - timezone 'America/Godthab' do |tz| - tz.offset :o0, -12416, 0, :LMT - tz.offset :o1, -10800, 0, :WGT - tz.offset :o2, -10800, 3600, :WGST - - tz.transition 1916, 7, :o1, 3268448069, 1350 - tz.transition 1980, 4, :o2, 323845200 - tz.transition 1980, 9, :o1, 338950800 - tz.transition 1981, 3, :o2, 354675600 - tz.transition 1981, 9, :o1, 370400400 - tz.transition 1982, 3, :o2, 386125200 - tz.transition 1982, 9, :o1, 401850000 - tz.transition 1983, 3, :o2, 417574800 - tz.transition 1983, 9, :o1, 433299600 - tz.transition 1984, 3, :o2, 449024400 - tz.transition 1984, 9, :o1, 465354000 - tz.transition 1985, 3, :o2, 481078800 - tz.transition 1985, 9, :o1, 496803600 - tz.transition 1986, 3, :o2, 512528400 - tz.transition 1986, 9, :o1, 528253200 - tz.transition 1987, 3, :o2, 543978000 - tz.transition 1987, 9, :o1, 559702800 - tz.transition 1988, 3, :o2, 575427600 - tz.transition 1988, 9, :o1, 591152400 - tz.transition 1989, 3, :o2, 606877200 - tz.transition 1989, 9, :o1, 622602000 - tz.transition 1990, 3, :o2, 638326800 - tz.transition 1990, 9, :o1, 654656400 - tz.transition 1991, 3, :o2, 670381200 - tz.transition 1991, 9, :o1, 686106000 - tz.transition 1992, 3, :o2, 701830800 - tz.transition 1992, 9, :o1, 717555600 - tz.transition 1993, 3, :o2, 733280400 - tz.transition 1993, 9, :o1, 749005200 - tz.transition 1994, 3, :o2, 764730000 - tz.transition 1994, 9, :o1, 780454800 - tz.transition 1995, 3, :o2, 796179600 - tz.transition 1995, 9, :o1, 811904400 - tz.transition 1996, 3, :o2, 828234000 - tz.transition 1996, 10, :o1, 846378000 - tz.transition 1997, 3, :o2, 859683600 - tz.transition 1997, 10, :o1, 877827600 - tz.transition 1998, 3, :o2, 891133200 - tz.transition 1998, 10, :o1, 909277200 - tz.transition 1999, 3, :o2, 922582800 - tz.transition 1999, 10, :o1, 941331600 - tz.transition 2000, 3, :o2, 954032400 - tz.transition 2000, 10, :o1, 972781200 - tz.transition 2001, 3, :o2, 985482000 - tz.transition 2001, 10, :o1, 1004230800 - tz.transition 2002, 3, :o2, 1017536400 - tz.transition 2002, 10, :o1, 1035680400 - tz.transition 2003, 3, :o2, 1048986000 - tz.transition 2003, 10, :o1, 1067130000 - tz.transition 2004, 3, :o2, 1080435600 - tz.transition 2004, 10, :o1, 1099184400 - tz.transition 2005, 3, :o2, 1111885200 - tz.transition 2005, 10, :o1, 1130634000 - tz.transition 2006, 3, :o2, 1143334800 - tz.transition 2006, 10, :o1, 1162083600 - tz.transition 2007, 3, :o2, 1174784400 - tz.transition 2007, 10, :o1, 1193533200 - tz.transition 2008, 3, :o2, 1206838800 - tz.transition 2008, 10, :o1, 1224982800 - tz.transition 2009, 3, :o2, 1238288400 - tz.transition 2009, 10, :o1, 1256432400 - tz.transition 2010, 3, :o2, 1269738000 - tz.transition 2010, 10, :o1, 1288486800 - tz.transition 2011, 3, :o2, 1301187600 - tz.transition 2011, 10, :o1, 1319936400 - tz.transition 2012, 3, :o2, 1332637200 - tz.transition 2012, 10, :o1, 1351386000 - tz.transition 2013, 3, :o2, 1364691600 - tz.transition 2013, 10, :o1, 1382835600 - tz.transition 2014, 3, :o2, 1396141200 - tz.transition 2014, 10, :o1, 1414285200 - tz.transition 2015, 3, :o2, 1427590800 - tz.transition 2015, 10, :o1, 1445734800 - tz.transition 2016, 3, :o2, 1459040400 - tz.transition 2016, 10, :o1, 1477789200 - tz.transition 2017, 3, :o2, 1490490000 - tz.transition 2017, 10, :o1, 1509238800 - tz.transition 2018, 3, :o2, 1521939600 - tz.transition 2018, 10, :o1, 1540688400 - tz.transition 2019, 3, :o2, 1553994000 - tz.transition 2019, 10, :o1, 1572138000 - tz.transition 2020, 3, :o2, 1585443600 - tz.transition 2020, 10, :o1, 1603587600 - tz.transition 2021, 3, :o2, 1616893200 - tz.transition 2021, 10, :o1, 1635642000 - tz.transition 2022, 3, :o2, 1648342800 - tz.transition 2022, 10, :o1, 1667091600 - tz.transition 2023, 3, :o2, 1679792400 - tz.transition 2023, 10, :o1, 1698541200 - tz.transition 2024, 3, :o2, 1711846800 - tz.transition 2024, 10, :o1, 1729990800 - tz.transition 2025, 3, :o2, 1743296400 - tz.transition 2025, 10, :o1, 1761440400 - tz.transition 2026, 3, :o2, 1774746000 - tz.transition 2026, 10, :o1, 1792890000 - tz.transition 2027, 3, :o2, 1806195600 - tz.transition 2027, 10, :o1, 1824944400 - tz.transition 2028, 3, :o2, 1837645200 - tz.transition 2028, 10, :o1, 1856394000 - tz.transition 2029, 3, :o2, 1869094800 - tz.transition 2029, 10, :o1, 1887843600 - tz.transition 2030, 3, :o2, 1901149200 - tz.transition 2030, 10, :o1, 1919293200 - tz.transition 2031, 3, :o2, 1932598800 - tz.transition 2031, 10, :o1, 1950742800 - tz.transition 2032, 3, :o2, 1964048400 - tz.transition 2032, 10, :o1, 1982797200 - tz.transition 2033, 3, :o2, 1995498000 - tz.transition 2033, 10, :o1, 2014246800 - tz.transition 2034, 3, :o2, 2026947600 - tz.transition 2034, 10, :o1, 2045696400 - tz.transition 2035, 3, :o2, 2058397200 - tz.transition 2035, 10, :o1, 2077146000 - tz.transition 2036, 3, :o2, 2090451600 - tz.transition 2036, 10, :o1, 2108595600 - tz.transition 2037, 3, :o2, 2121901200 - tz.transition 2037, 10, :o1, 2140045200 - tz.transition 2038, 3, :o2, 59172253, 24 - tz.transition 2038, 10, :o1, 59177461, 24 - tz.transition 2039, 3, :o2, 59180989, 24 - tz.transition 2039, 10, :o1, 59186197, 24 - tz.transition 2040, 3, :o2, 59189725, 24 - tz.transition 2040, 10, :o1, 59194933, 24 - tz.transition 2041, 3, :o2, 59198629, 24 - tz.transition 2041, 10, :o1, 59203669, 24 - tz.transition 2042, 3, :o2, 59207365, 24 - tz.transition 2042, 10, :o1, 59212405, 24 - tz.transition 2043, 3, :o2, 59216101, 24 - tz.transition 2043, 10, :o1, 59221141, 24 - tz.transition 2044, 3, :o2, 59224837, 24 - tz.transition 2044, 10, :o1, 59230045, 24 - tz.transition 2045, 3, :o2, 59233573, 24 - tz.transition 2045, 10, :o1, 59238781, 24 - tz.transition 2046, 3, :o2, 59242309, 24 - tz.transition 2046, 10, :o1, 59247517, 24 - tz.transition 2047, 3, :o2, 59251213, 24 - tz.transition 2047, 10, :o1, 59256253, 24 - tz.transition 2048, 3, :o2, 59259949, 24 - tz.transition 2048, 10, :o1, 59264989, 24 - tz.transition 2049, 3, :o2, 59268685, 24 - tz.transition 2049, 10, :o1, 59273893, 24 - tz.transition 2050, 3, :o2, 59277421, 24 - tz.transition 2050, 10, :o1, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Guatemala.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Guatemala.rb deleted file mode 100644 index a2bf734..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Guatemala.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Guatemala - include TimezoneDefinition - - timezone 'America/Guatemala' do |tz| - tz.offset :o0, -21724, 0, :LMT - tz.offset :o1, -21600, 0, :CST - tz.offset :o2, -21600, 3600, :CDT - - tz.transition 1918, 10, :o1, 52312429831, 21600 - tz.transition 1973, 11, :o2, 123055200 - tz.transition 1974, 2, :o1, 130914000 - tz.transition 1983, 5, :o2, 422344800 - tz.transition 1983, 9, :o1, 433054800 - tz.transition 1991, 3, :o2, 669708000 - tz.transition 1991, 9, :o1, 684219600 - tz.transition 2006, 4, :o2, 1146376800 - tz.transition 2006, 10, :o1, 1159678800 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Halifax.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Halifax.rb deleted file mode 100644 index d25ae77..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Halifax.rb +++ /dev/null @@ -1,274 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Halifax - include TimezoneDefinition - - timezone 'America/Halifax' do |tz| - tz.offset :o0, -15264, 0, :LMT - tz.offset :o1, -14400, 0, :AST - tz.offset :o2, -14400, 3600, :ADT - tz.offset :o3, -14400, 3600, :AWT - tz.offset :o4, -14400, 3600, :APT - - tz.transition 1902, 6, :o1, 724774703, 300 - tz.transition 1916, 4, :o2, 7262864, 3 - tz.transition 1916, 10, :o1, 19369101, 8 - tz.transition 1918, 4, :o2, 9686791, 4 - tz.transition 1918, 10, :o1, 58125545, 24 - tz.transition 1920, 5, :o2, 7267361, 3 - tz.transition 1920, 8, :o1, 19380525, 8 - tz.transition 1921, 5, :o2, 7268447, 3 - tz.transition 1921, 9, :o1, 19383501, 8 - tz.transition 1922, 4, :o2, 7269524, 3 - tz.transition 1922, 9, :o1, 19386421, 8 - tz.transition 1923, 5, :o2, 7270637, 3 - tz.transition 1923, 9, :o1, 19389333, 8 - tz.transition 1924, 5, :o2, 7271729, 3 - tz.transition 1924, 9, :o1, 19392349, 8 - tz.transition 1925, 5, :o2, 7272821, 3 - tz.transition 1925, 9, :o1, 19395373, 8 - tz.transition 1926, 5, :o2, 7273955, 3 - tz.transition 1926, 9, :o1, 19398173, 8 - tz.transition 1927, 5, :o2, 7275005, 3 - tz.transition 1927, 9, :o1, 19401197, 8 - tz.transition 1928, 5, :o2, 7276139, 3 - tz.transition 1928, 9, :o1, 19403989, 8 - tz.transition 1929, 5, :o2, 7277231, 3 - tz.transition 1929, 9, :o1, 19406861, 8 - tz.transition 1930, 5, :o2, 7278323, 3 - tz.transition 1930, 9, :o1, 19409877, 8 - tz.transition 1931, 5, :o2, 7279415, 3 - tz.transition 1931, 9, :o1, 19412901, 8 - tz.transition 1932, 5, :o2, 7280486, 3 - tz.transition 1932, 9, :o1, 19415813, 8 - tz.transition 1933, 4, :o2, 7281578, 3 - tz.transition 1933, 10, :o1, 19418781, 8 - tz.transition 1934, 5, :o2, 7282733, 3 - tz.transition 1934, 9, :o1, 19421573, 8 - tz.transition 1935, 6, :o2, 7283867, 3 - tz.transition 1935, 9, :o1, 19424605, 8 - tz.transition 1936, 6, :o2, 7284962, 3 - tz.transition 1936, 9, :o1, 19427405, 8 - tz.transition 1937, 5, :o2, 7285967, 3 - tz.transition 1937, 9, :o1, 19430429, 8 - tz.transition 1938, 5, :o2, 7287059, 3 - tz.transition 1938, 9, :o1, 19433341, 8 - tz.transition 1939, 5, :o2, 7288235, 3 - tz.transition 1939, 9, :o1, 19436253, 8 - tz.transition 1940, 5, :o2, 7289264, 3 - tz.transition 1940, 9, :o1, 19439221, 8 - tz.transition 1941, 5, :o2, 7290356, 3 - tz.transition 1941, 9, :o1, 19442133, 8 - tz.transition 1942, 2, :o3, 9721599, 4 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o1, 58361489, 24 - tz.transition 1946, 4, :o2, 9727755, 4 - tz.transition 1946, 9, :o1, 58370225, 24 - tz.transition 1947, 4, :o2, 9729211, 4 - tz.transition 1947, 9, :o1, 58378961, 24 - tz.transition 1948, 4, :o2, 9730667, 4 - tz.transition 1948, 9, :o1, 58387697, 24 - tz.transition 1949, 4, :o2, 9732123, 4 - tz.transition 1949, 9, :o1, 58396433, 24 - tz.transition 1951, 4, :o2, 9735063, 4 - tz.transition 1951, 9, :o1, 58414073, 24 - tz.transition 1952, 4, :o2, 9736519, 4 - tz.transition 1952, 9, :o1, 58422809, 24 - tz.transition 1953, 4, :o2, 9737975, 4 - tz.transition 1953, 9, :o1, 58431545, 24 - tz.transition 1954, 4, :o2, 9739431, 4 - tz.transition 1954, 9, :o1, 58440281, 24 - tz.transition 1956, 4, :o2, 9742371, 4 - tz.transition 1956, 9, :o1, 58457921, 24 - tz.transition 1957, 4, :o2, 9743827, 4 - tz.transition 1957, 9, :o1, 58466657, 24 - tz.transition 1958, 4, :o2, 9745283, 4 - tz.transition 1958, 9, :o1, 58475393, 24 - tz.transition 1959, 4, :o2, 9746739, 4 - tz.transition 1959, 9, :o1, 58484129, 24 - tz.transition 1962, 4, :o2, 9751135, 4 - tz.transition 1962, 10, :o1, 58511177, 24 - tz.transition 1963, 4, :o2, 9752591, 4 - tz.transition 1963, 10, :o1, 58519913, 24 - tz.transition 1964, 4, :o2, 9754047, 4 - tz.transition 1964, 10, :o1, 58528649, 24 - tz.transition 1965, 4, :o2, 9755503, 4 - tz.transition 1965, 10, :o1, 58537553, 24 - tz.transition 1966, 4, :o2, 9756959, 4 - tz.transition 1966, 10, :o1, 58546289, 24 - tz.transition 1967, 4, :o2, 9758443, 4 - tz.transition 1967, 10, :o1, 58555025, 24 - tz.transition 1968, 4, :o2, 9759899, 4 - tz.transition 1968, 10, :o1, 58563761, 24 - tz.transition 1969, 4, :o2, 9761355, 4 - tz.transition 1969, 10, :o1, 58572497, 24 - tz.transition 1970, 4, :o2, 9957600 - tz.transition 1970, 10, :o1, 25678800 - tz.transition 1971, 4, :o2, 41407200 - tz.transition 1971, 10, :o1, 57733200 - tz.transition 1972, 4, :o2, 73461600 - tz.transition 1972, 10, :o1, 89182800 - tz.transition 1973, 4, :o2, 104911200 - tz.transition 1973, 10, :o1, 120632400 - tz.transition 1974, 4, :o2, 136360800 - tz.transition 1974, 10, :o1, 152082000 - tz.transition 1975, 4, :o2, 167810400 - tz.transition 1975, 10, :o1, 183531600 - tz.transition 1976, 4, :o2, 199260000 - tz.transition 1976, 10, :o1, 215586000 - tz.transition 1977, 4, :o2, 230709600 - tz.transition 1977, 10, :o1, 247035600 - tz.transition 1978, 4, :o2, 262764000 - tz.transition 1978, 10, :o1, 278485200 - tz.transition 1979, 4, :o2, 294213600 - tz.transition 1979, 10, :o1, 309934800 - tz.transition 1980, 4, :o2, 325663200 - tz.transition 1980, 10, :o1, 341384400 - tz.transition 1981, 4, :o2, 357112800 - tz.transition 1981, 10, :o1, 372834000 - tz.transition 1982, 4, :o2, 388562400 - tz.transition 1982, 10, :o1, 404888400 - tz.transition 1983, 4, :o2, 420012000 - tz.transition 1983, 10, :o1, 436338000 - tz.transition 1984, 4, :o2, 452066400 - tz.transition 1984, 10, :o1, 467787600 - tz.transition 1985, 4, :o2, 483516000 - tz.transition 1985, 10, :o1, 499237200 - tz.transition 1986, 4, :o2, 514965600 - tz.transition 1986, 10, :o1, 530686800 - tz.transition 1987, 4, :o2, 544600800 - tz.transition 1987, 10, :o1, 562136400 - tz.transition 1988, 4, :o2, 576050400 - tz.transition 1988, 10, :o1, 594190800 - tz.transition 1989, 4, :o2, 607500000 - tz.transition 1989, 10, :o1, 625640400 - tz.transition 1990, 4, :o2, 638949600 - tz.transition 1990, 10, :o1, 657090000 - tz.transition 1991, 4, :o2, 671004000 - tz.transition 1991, 10, :o1, 688539600 - tz.transition 1992, 4, :o2, 702453600 - tz.transition 1992, 10, :o1, 719989200 - tz.transition 1993, 4, :o2, 733903200 - tz.transition 1993, 10, :o1, 752043600 - tz.transition 1994, 4, :o2, 765352800 - tz.transition 1994, 10, :o1, 783493200 - tz.transition 1995, 4, :o2, 796802400 - tz.transition 1995, 10, :o1, 814942800 - tz.transition 1996, 4, :o2, 828856800 - tz.transition 1996, 10, :o1, 846392400 - tz.transition 1997, 4, :o2, 860306400 - tz.transition 1997, 10, :o1, 877842000 - tz.transition 1998, 4, :o2, 891756000 - tz.transition 1998, 10, :o1, 909291600 - tz.transition 1999, 4, :o2, 923205600 - tz.transition 1999, 10, :o1, 941346000 - tz.transition 2000, 4, :o2, 954655200 - tz.transition 2000, 10, :o1, 972795600 - tz.transition 2001, 4, :o2, 986104800 - tz.transition 2001, 10, :o1, 1004245200 - tz.transition 2002, 4, :o2, 1018159200 - tz.transition 2002, 10, :o1, 1035694800 - tz.transition 2003, 4, :o2, 1049608800 - tz.transition 2003, 10, :o1, 1067144400 - tz.transition 2004, 4, :o2, 1081058400 - tz.transition 2004, 10, :o1, 1099198800 - tz.transition 2005, 4, :o2, 1112508000 - tz.transition 2005, 10, :o1, 1130648400 - tz.transition 2006, 4, :o2, 1143957600 - tz.transition 2006, 10, :o1, 1162098000 - tz.transition 2007, 3, :o2, 1173592800 - tz.transition 2007, 11, :o1, 1194152400 - tz.transition 2008, 3, :o2, 1205042400 - tz.transition 2008, 11, :o1, 1225602000 - tz.transition 2009, 3, :o2, 1236492000 - tz.transition 2009, 11, :o1, 1257051600 - tz.transition 2010, 3, :o2, 1268546400 - tz.transition 2010, 11, :o1, 1289106000 - tz.transition 2011, 3, :o2, 1299996000 - tz.transition 2011, 11, :o1, 1320555600 - tz.transition 2012, 3, :o2, 1331445600 - tz.transition 2012, 11, :o1, 1352005200 - tz.transition 2013, 3, :o2, 1362895200 - tz.transition 2013, 11, :o1, 1383454800 - tz.transition 2014, 3, :o2, 1394344800 - tz.transition 2014, 11, :o1, 1414904400 - tz.transition 2015, 3, :o2, 1425794400 - tz.transition 2015, 11, :o1, 1446354000 - tz.transition 2016, 3, :o2, 1457848800 - tz.transition 2016, 11, :o1, 1478408400 - tz.transition 2017, 3, :o2, 1489298400 - tz.transition 2017, 11, :o1, 1509858000 - tz.transition 2018, 3, :o2, 1520748000 - tz.transition 2018, 11, :o1, 1541307600 - tz.transition 2019, 3, :o2, 1552197600 - tz.transition 2019, 11, :o1, 1572757200 - tz.transition 2020, 3, :o2, 1583647200 - tz.transition 2020, 11, :o1, 1604206800 - tz.transition 2021, 3, :o2, 1615701600 - tz.transition 2021, 11, :o1, 1636261200 - tz.transition 2022, 3, :o2, 1647151200 - tz.transition 2022, 11, :o1, 1667710800 - tz.transition 2023, 3, :o2, 1678600800 - tz.transition 2023, 11, :o1, 1699160400 - tz.transition 2024, 3, :o2, 1710050400 - tz.transition 2024, 11, :o1, 1730610000 - tz.transition 2025, 3, :o2, 1741500000 - tz.transition 2025, 11, :o1, 1762059600 - tz.transition 2026, 3, :o2, 1772949600 - tz.transition 2026, 11, :o1, 1793509200 - tz.transition 2027, 3, :o2, 1805004000 - tz.transition 2027, 11, :o1, 1825563600 - tz.transition 2028, 3, :o2, 1836453600 - tz.transition 2028, 11, :o1, 1857013200 - tz.transition 2029, 3, :o2, 1867903200 - tz.transition 2029, 11, :o1, 1888462800 - tz.transition 2030, 3, :o2, 1899352800 - tz.transition 2030, 11, :o1, 1919912400 - tz.transition 2031, 3, :o2, 1930802400 - tz.transition 2031, 11, :o1, 1951362000 - tz.transition 2032, 3, :o2, 1962856800 - tz.transition 2032, 11, :o1, 1983416400 - tz.transition 2033, 3, :o2, 1994306400 - tz.transition 2033, 11, :o1, 2014866000 - tz.transition 2034, 3, :o2, 2025756000 - tz.transition 2034, 11, :o1, 2046315600 - tz.transition 2035, 3, :o2, 2057205600 - tz.transition 2035, 11, :o1, 2077765200 - tz.transition 2036, 3, :o2, 2088655200 - tz.transition 2036, 11, :o1, 2109214800 - tz.transition 2037, 3, :o2, 2120104800 - tz.transition 2037, 11, :o1, 2140664400 - tz.transition 2038, 3, :o2, 9861987, 4 - tz.transition 2038, 11, :o1, 59177633, 24 - tz.transition 2039, 3, :o2, 9863443, 4 - tz.transition 2039, 11, :o1, 59186369, 24 - tz.transition 2040, 3, :o2, 9864899, 4 - tz.transition 2040, 11, :o1, 59195105, 24 - tz.transition 2041, 3, :o2, 9866355, 4 - tz.transition 2041, 11, :o1, 59203841, 24 - tz.transition 2042, 3, :o2, 9867811, 4 - tz.transition 2042, 11, :o1, 59212577, 24 - tz.transition 2043, 3, :o2, 9869267, 4 - tz.transition 2043, 11, :o1, 59221313, 24 - tz.transition 2044, 3, :o2, 9870751, 4 - tz.transition 2044, 11, :o1, 59230217, 24 - tz.transition 2045, 3, :o2, 9872207, 4 - tz.transition 2045, 11, :o1, 59238953, 24 - tz.transition 2046, 3, :o2, 9873663, 4 - tz.transition 2046, 11, :o1, 59247689, 24 - tz.transition 2047, 3, :o2, 9875119, 4 - tz.transition 2047, 11, :o1, 59256425, 24 - tz.transition 2048, 3, :o2, 9876575, 4 - tz.transition 2048, 11, :o1, 59265161, 24 - tz.transition 2049, 3, :o2, 9878059, 4 - tz.transition 2049, 11, :o1, 59274065, 24 - tz.transition 2050, 3, :o2, 9879515, 4 - tz.transition 2050, 11, :o1, 59282801, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Indiana/Indianapolis.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Indiana/Indianapolis.rb deleted file mode 100644 index f1430f6..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Indiana/Indianapolis.rb +++ /dev/null @@ -1,149 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Indiana - module Indianapolis - include TimezoneDefinition - - timezone 'America/Indiana/Indianapolis' do |tz| - tz.offset :o0, -20678, 0, :LMT - tz.offset :o1, -21600, 0, :CST - tz.offset :o2, -21600, 3600, :CDT - tz.offset :o3, -21600, 3600, :CWT - tz.offset :o4, -21600, 3600, :CPT - tz.offset :o5, -18000, 0, :EST - tz.offset :o6, -18000, 3600, :EDT - - tz.transition 1883, 11, :o1, 9636533, 4 - tz.transition 1918, 3, :o2, 14530103, 6 - tz.transition 1918, 10, :o1, 58125451, 24 - tz.transition 1919, 3, :o2, 14532287, 6 - tz.transition 1919, 10, :o1, 58134187, 24 - tz.transition 1941, 6, :o2, 14581007, 6 - tz.transition 1941, 9, :o1, 58326379, 24 - tz.transition 1942, 2, :o3, 14582399, 6 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o1, 58361491, 24 - tz.transition 1946, 4, :o2, 14591633, 6 - tz.transition 1946, 9, :o1, 58370227, 24 - tz.transition 1947, 4, :o2, 14593817, 6 - tz.transition 1947, 9, :o1, 58378963, 24 - tz.transition 1948, 4, :o2, 14596001, 6 - tz.transition 1948, 9, :o1, 58387699, 24 - tz.transition 1949, 4, :o2, 14598185, 6 - tz.transition 1949, 9, :o1, 58396435, 24 - tz.transition 1950, 4, :o2, 14600411, 6 - tz.transition 1950, 9, :o1, 58405171, 24 - tz.transition 1951, 4, :o2, 14602595, 6 - tz.transition 1951, 9, :o1, 58414075, 24 - tz.transition 1952, 4, :o2, 14604779, 6 - tz.transition 1952, 9, :o1, 58422811, 24 - tz.transition 1953, 4, :o2, 14606963, 6 - tz.transition 1953, 9, :o1, 58431547, 24 - tz.transition 1954, 4, :o2, 14609147, 6 - tz.transition 1954, 9, :o1, 58440283, 24 - tz.transition 1955, 4, :o5, 14611331, 6 - tz.transition 1957, 9, :o1, 58466659, 24 - tz.transition 1958, 4, :o5, 14617925, 6 - tz.transition 1969, 4, :o6, 58568131, 24 - tz.transition 1969, 10, :o5, 9762083, 4 - tz.transition 1970, 4, :o6, 9961200 - tz.transition 1970, 10, :o5, 25682400 - tz.transition 2006, 4, :o6, 1143961200 - tz.transition 2006, 10, :o5, 1162101600 - tz.transition 2007, 3, :o6, 1173596400 - tz.transition 2007, 11, :o5, 1194156000 - tz.transition 2008, 3, :o6, 1205046000 - tz.transition 2008, 11, :o5, 1225605600 - tz.transition 2009, 3, :o6, 1236495600 - tz.transition 2009, 11, :o5, 1257055200 - tz.transition 2010, 3, :o6, 1268550000 - tz.transition 2010, 11, :o5, 1289109600 - tz.transition 2011, 3, :o6, 1299999600 - tz.transition 2011, 11, :o5, 1320559200 - tz.transition 2012, 3, :o6, 1331449200 - tz.transition 2012, 11, :o5, 1352008800 - tz.transition 2013, 3, :o6, 1362898800 - tz.transition 2013, 11, :o5, 1383458400 - tz.transition 2014, 3, :o6, 1394348400 - tz.transition 2014, 11, :o5, 1414908000 - tz.transition 2015, 3, :o6, 1425798000 - tz.transition 2015, 11, :o5, 1446357600 - tz.transition 2016, 3, :o6, 1457852400 - tz.transition 2016, 11, :o5, 1478412000 - tz.transition 2017, 3, :o6, 1489302000 - tz.transition 2017, 11, :o5, 1509861600 - tz.transition 2018, 3, :o6, 1520751600 - tz.transition 2018, 11, :o5, 1541311200 - tz.transition 2019, 3, :o6, 1552201200 - tz.transition 2019, 11, :o5, 1572760800 - tz.transition 2020, 3, :o6, 1583650800 - tz.transition 2020, 11, :o5, 1604210400 - tz.transition 2021, 3, :o6, 1615705200 - tz.transition 2021, 11, :o5, 1636264800 - tz.transition 2022, 3, :o6, 1647154800 - tz.transition 2022, 11, :o5, 1667714400 - tz.transition 2023, 3, :o6, 1678604400 - tz.transition 2023, 11, :o5, 1699164000 - tz.transition 2024, 3, :o6, 1710054000 - tz.transition 2024, 11, :o5, 1730613600 - tz.transition 2025, 3, :o6, 1741503600 - tz.transition 2025, 11, :o5, 1762063200 - tz.transition 2026, 3, :o6, 1772953200 - tz.transition 2026, 11, :o5, 1793512800 - tz.transition 2027, 3, :o6, 1805007600 - tz.transition 2027, 11, :o5, 1825567200 - tz.transition 2028, 3, :o6, 1836457200 - tz.transition 2028, 11, :o5, 1857016800 - tz.transition 2029, 3, :o6, 1867906800 - tz.transition 2029, 11, :o5, 1888466400 - tz.transition 2030, 3, :o6, 1899356400 - tz.transition 2030, 11, :o5, 1919916000 - tz.transition 2031, 3, :o6, 1930806000 - tz.transition 2031, 11, :o5, 1951365600 - tz.transition 2032, 3, :o6, 1962860400 - tz.transition 2032, 11, :o5, 1983420000 - tz.transition 2033, 3, :o6, 1994310000 - tz.transition 2033, 11, :o5, 2014869600 - tz.transition 2034, 3, :o6, 2025759600 - tz.transition 2034, 11, :o5, 2046319200 - tz.transition 2035, 3, :o6, 2057209200 - tz.transition 2035, 11, :o5, 2077768800 - tz.transition 2036, 3, :o6, 2088658800 - tz.transition 2036, 11, :o5, 2109218400 - tz.transition 2037, 3, :o6, 2120108400 - tz.transition 2037, 11, :o5, 2140668000 - tz.transition 2038, 3, :o6, 59171923, 24 - tz.transition 2038, 11, :o5, 9862939, 4 - tz.transition 2039, 3, :o6, 59180659, 24 - tz.transition 2039, 11, :o5, 9864395, 4 - tz.transition 2040, 3, :o6, 59189395, 24 - tz.transition 2040, 11, :o5, 9865851, 4 - tz.transition 2041, 3, :o6, 59198131, 24 - tz.transition 2041, 11, :o5, 9867307, 4 - tz.transition 2042, 3, :o6, 59206867, 24 - tz.transition 2042, 11, :o5, 9868763, 4 - tz.transition 2043, 3, :o6, 59215603, 24 - tz.transition 2043, 11, :o5, 9870219, 4 - tz.transition 2044, 3, :o6, 59224507, 24 - tz.transition 2044, 11, :o5, 9871703, 4 - tz.transition 2045, 3, :o6, 59233243, 24 - tz.transition 2045, 11, :o5, 9873159, 4 - tz.transition 2046, 3, :o6, 59241979, 24 - tz.transition 2046, 11, :o5, 9874615, 4 - tz.transition 2047, 3, :o6, 59250715, 24 - tz.transition 2047, 11, :o5, 9876071, 4 - tz.transition 2048, 3, :o6, 59259451, 24 - tz.transition 2048, 11, :o5, 9877527, 4 - tz.transition 2049, 3, :o6, 59268355, 24 - tz.transition 2049, 11, :o5, 9879011, 4 - tz.transition 2050, 3, :o6, 59277091, 24 - tz.transition 2050, 11, :o5, 9880467, 4 - end - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Juneau.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Juneau.rb deleted file mode 100644 index f646f3f..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Juneau.rb +++ /dev/null @@ -1,194 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Juneau - include TimezoneDefinition - - timezone 'America/Juneau' do |tz| - tz.offset :o0, 54139, 0, :LMT - tz.offset :o1, -32261, 0, :LMT - tz.offset :o2, -28800, 0, :PST - tz.offset :o3, -28800, 3600, :PWT - tz.offset :o4, -28800, 3600, :PPT - tz.offset :o5, -28800, 3600, :PDT - tz.offset :o6, -32400, 0, :YST - tz.offset :o7, -32400, 0, :AKST - tz.offset :o8, -32400, 3600, :AKDT - - tz.transition 1867, 10, :o1, 207641393861, 86400 - tz.transition 1900, 8, :o2, 208677805061, 86400 - tz.transition 1942, 2, :o3, 29164799, 12 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o2, 19453831, 8 - tz.transition 1969, 4, :o5, 29284067, 12 - tz.transition 1969, 10, :o2, 19524167, 8 - tz.transition 1970, 4, :o5, 9972000 - tz.transition 1970, 10, :o2, 25693200 - tz.transition 1971, 4, :o5, 41421600 - tz.transition 1971, 10, :o2, 57747600 - tz.transition 1972, 4, :o5, 73476000 - tz.transition 1972, 10, :o2, 89197200 - tz.transition 1973, 4, :o5, 104925600 - tz.transition 1973, 10, :o2, 120646800 - tz.transition 1974, 1, :o5, 126698400 - tz.transition 1974, 10, :o2, 152096400 - tz.transition 1975, 2, :o5, 162381600 - tz.transition 1975, 10, :o2, 183546000 - tz.transition 1976, 4, :o5, 199274400 - tz.transition 1976, 10, :o2, 215600400 - tz.transition 1977, 4, :o5, 230724000 - tz.transition 1977, 10, :o2, 247050000 - tz.transition 1978, 4, :o5, 262778400 - tz.transition 1978, 10, :o2, 278499600 - tz.transition 1979, 4, :o5, 294228000 - tz.transition 1979, 10, :o2, 309949200 - tz.transition 1980, 4, :o5, 325677600 - tz.transition 1980, 10, :o2, 341398800 - tz.transition 1981, 4, :o5, 357127200 - tz.transition 1981, 10, :o2, 372848400 - tz.transition 1982, 4, :o5, 388576800 - tz.transition 1982, 10, :o2, 404902800 - tz.transition 1983, 4, :o5, 420026400 - tz.transition 1983, 10, :o6, 436352400 - tz.transition 1983, 11, :o7, 439030800 - tz.transition 1984, 4, :o8, 452084400 - tz.transition 1984, 10, :o7, 467805600 - tz.transition 1985, 4, :o8, 483534000 - tz.transition 1985, 10, :o7, 499255200 - tz.transition 1986, 4, :o8, 514983600 - tz.transition 1986, 10, :o7, 530704800 - tz.transition 1987, 4, :o8, 544618800 - tz.transition 1987, 10, :o7, 562154400 - tz.transition 1988, 4, :o8, 576068400 - tz.transition 1988, 10, :o7, 594208800 - tz.transition 1989, 4, :o8, 607518000 - tz.transition 1989, 10, :o7, 625658400 - tz.transition 1990, 4, :o8, 638967600 - tz.transition 1990, 10, :o7, 657108000 - tz.transition 1991, 4, :o8, 671022000 - tz.transition 1991, 10, :o7, 688557600 - tz.transition 1992, 4, :o8, 702471600 - tz.transition 1992, 10, :o7, 720007200 - tz.transition 1993, 4, :o8, 733921200 - tz.transition 1993, 10, :o7, 752061600 - tz.transition 1994, 4, :o8, 765370800 - tz.transition 1994, 10, :o7, 783511200 - tz.transition 1995, 4, :o8, 796820400 - tz.transition 1995, 10, :o7, 814960800 - tz.transition 1996, 4, :o8, 828874800 - tz.transition 1996, 10, :o7, 846410400 - tz.transition 1997, 4, :o8, 860324400 - tz.transition 1997, 10, :o7, 877860000 - tz.transition 1998, 4, :o8, 891774000 - tz.transition 1998, 10, :o7, 909309600 - tz.transition 1999, 4, :o8, 923223600 - tz.transition 1999, 10, :o7, 941364000 - tz.transition 2000, 4, :o8, 954673200 - tz.transition 2000, 10, :o7, 972813600 - tz.transition 2001, 4, :o8, 986122800 - tz.transition 2001, 10, :o7, 1004263200 - tz.transition 2002, 4, :o8, 1018177200 - tz.transition 2002, 10, :o7, 1035712800 - tz.transition 2003, 4, :o8, 1049626800 - tz.transition 2003, 10, :o7, 1067162400 - tz.transition 2004, 4, :o8, 1081076400 - tz.transition 2004, 10, :o7, 1099216800 - tz.transition 2005, 4, :o8, 1112526000 - tz.transition 2005, 10, :o7, 1130666400 - tz.transition 2006, 4, :o8, 1143975600 - tz.transition 2006, 10, :o7, 1162116000 - tz.transition 2007, 3, :o8, 1173610800 - tz.transition 2007, 11, :o7, 1194170400 - tz.transition 2008, 3, :o8, 1205060400 - tz.transition 2008, 11, :o7, 1225620000 - tz.transition 2009, 3, :o8, 1236510000 - tz.transition 2009, 11, :o7, 1257069600 - tz.transition 2010, 3, :o8, 1268564400 - tz.transition 2010, 11, :o7, 1289124000 - tz.transition 2011, 3, :o8, 1300014000 - tz.transition 2011, 11, :o7, 1320573600 - tz.transition 2012, 3, :o8, 1331463600 - tz.transition 2012, 11, :o7, 1352023200 - tz.transition 2013, 3, :o8, 1362913200 - tz.transition 2013, 11, :o7, 1383472800 - tz.transition 2014, 3, :o8, 1394362800 - tz.transition 2014, 11, :o7, 1414922400 - tz.transition 2015, 3, :o8, 1425812400 - tz.transition 2015, 11, :o7, 1446372000 - tz.transition 2016, 3, :o8, 1457866800 - tz.transition 2016, 11, :o7, 1478426400 - tz.transition 2017, 3, :o8, 1489316400 - tz.transition 2017, 11, :o7, 1509876000 - tz.transition 2018, 3, :o8, 1520766000 - tz.transition 2018, 11, :o7, 1541325600 - tz.transition 2019, 3, :o8, 1552215600 - tz.transition 2019, 11, :o7, 1572775200 - tz.transition 2020, 3, :o8, 1583665200 - tz.transition 2020, 11, :o7, 1604224800 - tz.transition 2021, 3, :o8, 1615719600 - tz.transition 2021, 11, :o7, 1636279200 - tz.transition 2022, 3, :o8, 1647169200 - tz.transition 2022, 11, :o7, 1667728800 - tz.transition 2023, 3, :o8, 1678618800 - tz.transition 2023, 11, :o7, 1699178400 - tz.transition 2024, 3, :o8, 1710068400 - tz.transition 2024, 11, :o7, 1730628000 - tz.transition 2025, 3, :o8, 1741518000 - tz.transition 2025, 11, :o7, 1762077600 - tz.transition 2026, 3, :o8, 1772967600 - tz.transition 2026, 11, :o7, 1793527200 - tz.transition 2027, 3, :o8, 1805022000 - tz.transition 2027, 11, :o7, 1825581600 - tz.transition 2028, 3, :o8, 1836471600 - tz.transition 2028, 11, :o7, 1857031200 - tz.transition 2029, 3, :o8, 1867921200 - tz.transition 2029, 11, :o7, 1888480800 - tz.transition 2030, 3, :o8, 1899370800 - tz.transition 2030, 11, :o7, 1919930400 - tz.transition 2031, 3, :o8, 1930820400 - tz.transition 2031, 11, :o7, 1951380000 - tz.transition 2032, 3, :o8, 1962874800 - tz.transition 2032, 11, :o7, 1983434400 - tz.transition 2033, 3, :o8, 1994324400 - tz.transition 2033, 11, :o7, 2014884000 - tz.transition 2034, 3, :o8, 2025774000 - tz.transition 2034, 11, :o7, 2046333600 - tz.transition 2035, 3, :o8, 2057223600 - tz.transition 2035, 11, :o7, 2077783200 - tz.transition 2036, 3, :o8, 2088673200 - tz.transition 2036, 11, :o7, 2109232800 - tz.transition 2037, 3, :o8, 2120122800 - tz.transition 2037, 11, :o7, 2140682400 - tz.transition 2038, 3, :o8, 59171927, 24 - tz.transition 2038, 11, :o7, 29588819, 12 - tz.transition 2039, 3, :o8, 59180663, 24 - tz.transition 2039, 11, :o7, 29593187, 12 - tz.transition 2040, 3, :o8, 59189399, 24 - tz.transition 2040, 11, :o7, 29597555, 12 - tz.transition 2041, 3, :o8, 59198135, 24 - tz.transition 2041, 11, :o7, 29601923, 12 - tz.transition 2042, 3, :o8, 59206871, 24 - tz.transition 2042, 11, :o7, 29606291, 12 - tz.transition 2043, 3, :o8, 59215607, 24 - tz.transition 2043, 11, :o7, 29610659, 12 - tz.transition 2044, 3, :o8, 59224511, 24 - tz.transition 2044, 11, :o7, 29615111, 12 - tz.transition 2045, 3, :o8, 59233247, 24 - tz.transition 2045, 11, :o7, 29619479, 12 - tz.transition 2046, 3, :o8, 59241983, 24 - tz.transition 2046, 11, :o7, 29623847, 12 - tz.transition 2047, 3, :o8, 59250719, 24 - tz.transition 2047, 11, :o7, 29628215, 12 - tz.transition 2048, 3, :o8, 59259455, 24 - tz.transition 2048, 11, :o7, 29632583, 12 - tz.transition 2049, 3, :o8, 59268359, 24 - tz.transition 2049, 11, :o7, 29637035, 12 - tz.transition 2050, 3, :o8, 59277095, 24 - tz.transition 2050, 11, :o7, 29641403, 12 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/La_Paz.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/La_Paz.rb deleted file mode 100644 index 45c9078..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/La_Paz.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module La_Paz - include TimezoneDefinition - - timezone 'America/La_Paz' do |tz| - tz.offset :o0, -16356, 0, :LMT - tz.offset :o1, -16356, 0, :CMT - tz.offset :o2, -16356, 3600, :BOST - tz.offset :o3, -14400, 0, :BOT - - tz.transition 1890, 1, :o1, 17361854563, 7200 - tz.transition 1931, 10, :o2, 17471733763, 7200 - tz.transition 1932, 3, :o3, 17472871063, 7200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Lima.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Lima.rb deleted file mode 100644 index af68ac2..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Lima.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Lima - include TimezoneDefinition - - timezone 'America/Lima' do |tz| - tz.offset :o0, -18492, 0, :LMT - tz.offset :o1, -18516, 0, :LMT - tz.offset :o2, -18000, 0, :PET - tz.offset :o3, -18000, 3600, :PEST - - tz.transition 1890, 1, :o1, 17361854741, 7200 - tz.transition 1908, 7, :o2, 17410685143, 7200 - tz.transition 1938, 1, :o3, 58293593, 24 - tz.transition 1938, 4, :o2, 7286969, 3 - tz.transition 1938, 9, :o3, 58300001, 24 - tz.transition 1939, 3, :o2, 7288046, 3 - tz.transition 1939, 9, :o3, 58308737, 24 - tz.transition 1940, 3, :o2, 7289138, 3 - tz.transition 1986, 1, :o3, 504939600 - tz.transition 1986, 4, :o2, 512712000 - tz.transition 1987, 1, :o3, 536475600 - tz.transition 1987, 4, :o2, 544248000 - tz.transition 1990, 1, :o3, 631170000 - tz.transition 1990, 4, :o2, 638942400 - tz.transition 1994, 1, :o3, 757400400 - tz.transition 1994, 4, :o2, 765172800 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Los_Angeles.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Los_Angeles.rb deleted file mode 100644 index 16007fd..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Los_Angeles.rb +++ /dev/null @@ -1,232 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Los_Angeles - include TimezoneDefinition - - timezone 'America/Los_Angeles' do |tz| - tz.offset :o0, -28378, 0, :LMT - tz.offset :o1, -28800, 0, :PST - tz.offset :o2, -28800, 3600, :PDT - tz.offset :o3, -28800, 3600, :PWT - tz.offset :o4, -28800, 3600, :PPT - - tz.transition 1883, 11, :o1, 7227400, 3 - tz.transition 1918, 3, :o2, 29060207, 12 - tz.transition 1918, 10, :o1, 19375151, 8 - tz.transition 1919, 3, :o2, 29064575, 12 - tz.transition 1919, 10, :o1, 19378063, 8 - tz.transition 1942, 2, :o3, 29164799, 12 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o1, 19453831, 8 - tz.transition 1948, 3, :o2, 29191499, 12 - tz.transition 1949, 1, :o1, 19463343, 8 - tz.transition 1950, 4, :o2, 29200823, 12 - tz.transition 1950, 9, :o1, 19468391, 8 - tz.transition 1951, 4, :o2, 29205191, 12 - tz.transition 1951, 9, :o1, 19471359, 8 - tz.transition 1952, 4, :o2, 29209559, 12 - tz.transition 1952, 9, :o1, 19474271, 8 - tz.transition 1953, 4, :o2, 29213927, 12 - tz.transition 1953, 9, :o1, 19477183, 8 - tz.transition 1954, 4, :o2, 29218295, 12 - tz.transition 1954, 9, :o1, 19480095, 8 - tz.transition 1955, 4, :o2, 29222663, 12 - tz.transition 1955, 9, :o1, 19483007, 8 - tz.transition 1956, 4, :o2, 29227115, 12 - tz.transition 1956, 9, :o1, 19485975, 8 - tz.transition 1957, 4, :o2, 29231483, 12 - tz.transition 1957, 9, :o1, 19488887, 8 - tz.transition 1958, 4, :o2, 29235851, 12 - tz.transition 1958, 9, :o1, 19491799, 8 - tz.transition 1959, 4, :o2, 29240219, 12 - tz.transition 1959, 9, :o1, 19494711, 8 - tz.transition 1960, 4, :o2, 29244587, 12 - tz.transition 1960, 9, :o1, 19497623, 8 - tz.transition 1961, 4, :o2, 29249039, 12 - tz.transition 1961, 9, :o1, 19500535, 8 - tz.transition 1962, 4, :o2, 29253407, 12 - tz.transition 1962, 10, :o1, 19503727, 8 - tz.transition 1963, 4, :o2, 29257775, 12 - tz.transition 1963, 10, :o1, 19506639, 8 - tz.transition 1964, 4, :o2, 29262143, 12 - tz.transition 1964, 10, :o1, 19509551, 8 - tz.transition 1965, 4, :o2, 29266511, 12 - tz.transition 1965, 10, :o1, 19512519, 8 - tz.transition 1966, 4, :o2, 29270879, 12 - tz.transition 1966, 10, :o1, 19515431, 8 - tz.transition 1967, 4, :o2, 29275331, 12 - tz.transition 1967, 10, :o1, 19518343, 8 - tz.transition 1968, 4, :o2, 29279699, 12 - tz.transition 1968, 10, :o1, 19521255, 8 - tz.transition 1969, 4, :o2, 29284067, 12 - tz.transition 1969, 10, :o1, 19524167, 8 - tz.transition 1970, 4, :o2, 9972000 - tz.transition 1970, 10, :o1, 25693200 - tz.transition 1971, 4, :o2, 41421600 - tz.transition 1971, 10, :o1, 57747600 - tz.transition 1972, 4, :o2, 73476000 - tz.transition 1972, 10, :o1, 89197200 - tz.transition 1973, 4, :o2, 104925600 - tz.transition 1973, 10, :o1, 120646800 - tz.transition 1974, 1, :o2, 126698400 - tz.transition 1974, 10, :o1, 152096400 - tz.transition 1975, 2, :o2, 162381600 - tz.transition 1975, 10, :o1, 183546000 - tz.transition 1976, 4, :o2, 199274400 - tz.transition 1976, 10, :o1, 215600400 - tz.transition 1977, 4, :o2, 230724000 - tz.transition 1977, 10, :o1, 247050000 - tz.transition 1978, 4, :o2, 262778400 - tz.transition 1978, 10, :o1, 278499600 - tz.transition 1979, 4, :o2, 294228000 - tz.transition 1979, 10, :o1, 309949200 - tz.transition 1980, 4, :o2, 325677600 - tz.transition 1980, 10, :o1, 341398800 - tz.transition 1981, 4, :o2, 357127200 - tz.transition 1981, 10, :o1, 372848400 - tz.transition 1982, 4, :o2, 388576800 - tz.transition 1982, 10, :o1, 404902800 - tz.transition 1983, 4, :o2, 420026400 - tz.transition 1983, 10, :o1, 436352400 - tz.transition 1984, 4, :o2, 452080800 - tz.transition 1984, 10, :o1, 467802000 - tz.transition 1985, 4, :o2, 483530400 - tz.transition 1985, 10, :o1, 499251600 - tz.transition 1986, 4, :o2, 514980000 - tz.transition 1986, 10, :o1, 530701200 - tz.transition 1987, 4, :o2, 544615200 - tz.transition 1987, 10, :o1, 562150800 - tz.transition 1988, 4, :o2, 576064800 - tz.transition 1988, 10, :o1, 594205200 - tz.transition 1989, 4, :o2, 607514400 - tz.transition 1989, 10, :o1, 625654800 - tz.transition 1990, 4, :o2, 638964000 - tz.transition 1990, 10, :o1, 657104400 - tz.transition 1991, 4, :o2, 671018400 - tz.transition 1991, 10, :o1, 688554000 - tz.transition 1992, 4, :o2, 702468000 - tz.transition 1992, 10, :o1, 720003600 - tz.transition 1993, 4, :o2, 733917600 - tz.transition 1993, 10, :o1, 752058000 - tz.transition 1994, 4, :o2, 765367200 - tz.transition 1994, 10, :o1, 783507600 - tz.transition 1995, 4, :o2, 796816800 - tz.transition 1995, 10, :o1, 814957200 - tz.transition 1996, 4, :o2, 828871200 - tz.transition 1996, 10, :o1, 846406800 - tz.transition 1997, 4, :o2, 860320800 - tz.transition 1997, 10, :o1, 877856400 - tz.transition 1998, 4, :o2, 891770400 - tz.transition 1998, 10, :o1, 909306000 - tz.transition 1999, 4, :o2, 923220000 - tz.transition 1999, 10, :o1, 941360400 - tz.transition 2000, 4, :o2, 954669600 - tz.transition 2000, 10, :o1, 972810000 - tz.transition 2001, 4, :o2, 986119200 - tz.transition 2001, 10, :o1, 1004259600 - tz.transition 2002, 4, :o2, 1018173600 - tz.transition 2002, 10, :o1, 1035709200 - tz.transition 2003, 4, :o2, 1049623200 - tz.transition 2003, 10, :o1, 1067158800 - tz.transition 2004, 4, :o2, 1081072800 - tz.transition 2004, 10, :o1, 1099213200 - tz.transition 2005, 4, :o2, 1112522400 - tz.transition 2005, 10, :o1, 1130662800 - tz.transition 2006, 4, :o2, 1143972000 - tz.transition 2006, 10, :o1, 1162112400 - tz.transition 2007, 3, :o2, 1173607200 - tz.transition 2007, 11, :o1, 1194166800 - tz.transition 2008, 3, :o2, 1205056800 - tz.transition 2008, 11, :o1, 1225616400 - tz.transition 2009, 3, :o2, 1236506400 - tz.transition 2009, 11, :o1, 1257066000 - tz.transition 2010, 3, :o2, 1268560800 - tz.transition 2010, 11, :o1, 1289120400 - tz.transition 2011, 3, :o2, 1300010400 - tz.transition 2011, 11, :o1, 1320570000 - tz.transition 2012, 3, :o2, 1331460000 - tz.transition 2012, 11, :o1, 1352019600 - tz.transition 2013, 3, :o2, 1362909600 - tz.transition 2013, 11, :o1, 1383469200 - tz.transition 2014, 3, :o2, 1394359200 - tz.transition 2014, 11, :o1, 1414918800 - tz.transition 2015, 3, :o2, 1425808800 - tz.transition 2015, 11, :o1, 1446368400 - tz.transition 2016, 3, :o2, 1457863200 - tz.transition 2016, 11, :o1, 1478422800 - tz.transition 2017, 3, :o2, 1489312800 - tz.transition 2017, 11, :o1, 1509872400 - tz.transition 2018, 3, :o2, 1520762400 - tz.transition 2018, 11, :o1, 1541322000 - tz.transition 2019, 3, :o2, 1552212000 - tz.transition 2019, 11, :o1, 1572771600 - tz.transition 2020, 3, :o2, 1583661600 - tz.transition 2020, 11, :o1, 1604221200 - tz.transition 2021, 3, :o2, 1615716000 - tz.transition 2021, 11, :o1, 1636275600 - tz.transition 2022, 3, :o2, 1647165600 - tz.transition 2022, 11, :o1, 1667725200 - tz.transition 2023, 3, :o2, 1678615200 - tz.transition 2023, 11, :o1, 1699174800 - tz.transition 2024, 3, :o2, 1710064800 - tz.transition 2024, 11, :o1, 1730624400 - tz.transition 2025, 3, :o2, 1741514400 - tz.transition 2025, 11, :o1, 1762074000 - tz.transition 2026, 3, :o2, 1772964000 - tz.transition 2026, 11, :o1, 1793523600 - tz.transition 2027, 3, :o2, 1805018400 - tz.transition 2027, 11, :o1, 1825578000 - tz.transition 2028, 3, :o2, 1836468000 - tz.transition 2028, 11, :o1, 1857027600 - tz.transition 2029, 3, :o2, 1867917600 - tz.transition 2029, 11, :o1, 1888477200 - tz.transition 2030, 3, :o2, 1899367200 - tz.transition 2030, 11, :o1, 1919926800 - tz.transition 2031, 3, :o2, 1930816800 - tz.transition 2031, 11, :o1, 1951376400 - tz.transition 2032, 3, :o2, 1962871200 - tz.transition 2032, 11, :o1, 1983430800 - tz.transition 2033, 3, :o2, 1994320800 - tz.transition 2033, 11, :o1, 2014880400 - tz.transition 2034, 3, :o2, 2025770400 - tz.transition 2034, 11, :o1, 2046330000 - tz.transition 2035, 3, :o2, 2057220000 - tz.transition 2035, 11, :o1, 2077779600 - tz.transition 2036, 3, :o2, 2088669600 - tz.transition 2036, 11, :o1, 2109229200 - tz.transition 2037, 3, :o2, 2120119200 - tz.transition 2037, 11, :o1, 2140678800 - tz.transition 2038, 3, :o2, 29585963, 12 - tz.transition 2038, 11, :o1, 19725879, 8 - tz.transition 2039, 3, :o2, 29590331, 12 - tz.transition 2039, 11, :o1, 19728791, 8 - tz.transition 2040, 3, :o2, 29594699, 12 - tz.transition 2040, 11, :o1, 19731703, 8 - tz.transition 2041, 3, :o2, 29599067, 12 - tz.transition 2041, 11, :o1, 19734615, 8 - tz.transition 2042, 3, :o2, 29603435, 12 - tz.transition 2042, 11, :o1, 19737527, 8 - tz.transition 2043, 3, :o2, 29607803, 12 - tz.transition 2043, 11, :o1, 19740439, 8 - tz.transition 2044, 3, :o2, 29612255, 12 - tz.transition 2044, 11, :o1, 19743407, 8 - tz.transition 2045, 3, :o2, 29616623, 12 - tz.transition 2045, 11, :o1, 19746319, 8 - tz.transition 2046, 3, :o2, 29620991, 12 - tz.transition 2046, 11, :o1, 19749231, 8 - tz.transition 2047, 3, :o2, 29625359, 12 - tz.transition 2047, 11, :o1, 19752143, 8 - tz.transition 2048, 3, :o2, 29629727, 12 - tz.transition 2048, 11, :o1, 19755055, 8 - tz.transition 2049, 3, :o2, 29634179, 12 - tz.transition 2049, 11, :o1, 19758023, 8 - tz.transition 2050, 3, :o2, 29638547, 12 - tz.transition 2050, 11, :o1, 19760935, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mazatlan.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mazatlan.rb deleted file mode 100644 index ba9e6ef..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mazatlan.rb +++ /dev/null @@ -1,139 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Mazatlan - include TimezoneDefinition - - timezone 'America/Mazatlan' do |tz| - tz.offset :o0, -25540, 0, :LMT - tz.offset :o1, -25200, 0, :MST - tz.offset :o2, -21600, 0, :CST - tz.offset :o3, -28800, 0, :PST - tz.offset :o4, -25200, 3600, :MDT - - tz.transition 1922, 1, :o1, 58153339, 24 - tz.transition 1927, 6, :o2, 9700171, 4 - tz.transition 1930, 11, :o1, 9705183, 4 - tz.transition 1931, 5, :o2, 9705855, 4 - tz.transition 1931, 10, :o1, 9706463, 4 - tz.transition 1932, 4, :o2, 58243171, 24 - tz.transition 1942, 4, :o1, 9721895, 4 - tz.transition 1949, 1, :o3, 58390339, 24 - tz.transition 1970, 1, :o1, 28800 - tz.transition 1996, 4, :o4, 828867600 - tz.transition 1996, 10, :o1, 846403200 - tz.transition 1997, 4, :o4, 860317200 - tz.transition 1997, 10, :o1, 877852800 - tz.transition 1998, 4, :o4, 891766800 - tz.transition 1998, 10, :o1, 909302400 - tz.transition 1999, 4, :o4, 923216400 - tz.transition 1999, 10, :o1, 941356800 - tz.transition 2000, 4, :o4, 954666000 - tz.transition 2000, 10, :o1, 972806400 - tz.transition 2001, 5, :o4, 989139600 - tz.transition 2001, 9, :o1, 1001836800 - tz.transition 2002, 4, :o4, 1018170000 - tz.transition 2002, 10, :o1, 1035705600 - tz.transition 2003, 4, :o4, 1049619600 - tz.transition 2003, 10, :o1, 1067155200 - tz.transition 2004, 4, :o4, 1081069200 - tz.transition 2004, 10, :o1, 1099209600 - tz.transition 2005, 4, :o4, 1112518800 - tz.transition 2005, 10, :o1, 1130659200 - tz.transition 2006, 4, :o4, 1143968400 - tz.transition 2006, 10, :o1, 1162108800 - tz.transition 2007, 4, :o4, 1175418000 - tz.transition 2007, 10, :o1, 1193558400 - tz.transition 2008, 4, :o4, 1207472400 - tz.transition 2008, 10, :o1, 1225008000 - tz.transition 2009, 4, :o4, 1238922000 - tz.transition 2009, 10, :o1, 1256457600 - tz.transition 2010, 4, :o4, 1270371600 - tz.transition 2010, 10, :o1, 1288512000 - tz.transition 2011, 4, :o4, 1301821200 - tz.transition 2011, 10, :o1, 1319961600 - tz.transition 2012, 4, :o4, 1333270800 - tz.transition 2012, 10, :o1, 1351411200 - tz.transition 2013, 4, :o4, 1365325200 - tz.transition 2013, 10, :o1, 1382860800 - tz.transition 2014, 4, :o4, 1396774800 - tz.transition 2014, 10, :o1, 1414310400 - tz.transition 2015, 4, :o4, 1428224400 - tz.transition 2015, 10, :o1, 1445760000 - tz.transition 2016, 4, :o4, 1459674000 - tz.transition 2016, 10, :o1, 1477814400 - tz.transition 2017, 4, :o4, 1491123600 - tz.transition 2017, 10, :o1, 1509264000 - tz.transition 2018, 4, :o4, 1522573200 - tz.transition 2018, 10, :o1, 1540713600 - tz.transition 2019, 4, :o4, 1554627600 - tz.transition 2019, 10, :o1, 1572163200 - tz.transition 2020, 4, :o4, 1586077200 - tz.transition 2020, 10, :o1, 1603612800 - tz.transition 2021, 4, :o4, 1617526800 - tz.transition 2021, 10, :o1, 1635667200 - tz.transition 2022, 4, :o4, 1648976400 - tz.transition 2022, 10, :o1, 1667116800 - tz.transition 2023, 4, :o4, 1680426000 - tz.transition 2023, 10, :o1, 1698566400 - tz.transition 2024, 4, :o4, 1712480400 - tz.transition 2024, 10, :o1, 1730016000 - tz.transition 2025, 4, :o4, 1743930000 - tz.transition 2025, 10, :o1, 1761465600 - tz.transition 2026, 4, :o4, 1775379600 - tz.transition 2026, 10, :o1, 1792915200 - tz.transition 2027, 4, :o4, 1806829200 - tz.transition 2027, 10, :o1, 1824969600 - tz.transition 2028, 4, :o4, 1838278800 - tz.transition 2028, 10, :o1, 1856419200 - tz.transition 2029, 4, :o4, 1869728400 - tz.transition 2029, 10, :o1, 1887868800 - tz.transition 2030, 4, :o4, 1901782800 - tz.transition 2030, 10, :o1, 1919318400 - tz.transition 2031, 4, :o4, 1933232400 - tz.transition 2031, 10, :o1, 1950768000 - tz.transition 2032, 4, :o4, 1964682000 - tz.transition 2032, 10, :o1, 1982822400 - tz.transition 2033, 4, :o4, 1996131600 - tz.transition 2033, 10, :o1, 2014272000 - tz.transition 2034, 4, :o4, 2027581200 - tz.transition 2034, 10, :o1, 2045721600 - tz.transition 2035, 4, :o4, 2059030800 - tz.transition 2035, 10, :o1, 2077171200 - tz.transition 2036, 4, :o4, 2091085200 - tz.transition 2036, 10, :o1, 2108620800 - tz.transition 2037, 4, :o4, 2122534800 - tz.transition 2037, 10, :o1, 2140070400 - tz.transition 2038, 4, :o4, 19724143, 8 - tz.transition 2038, 10, :o1, 14794367, 6 - tz.transition 2039, 4, :o4, 19727055, 8 - tz.transition 2039, 10, :o1, 14796551, 6 - tz.transition 2040, 4, :o4, 19729967, 8 - tz.transition 2040, 10, :o1, 14798735, 6 - tz.transition 2041, 4, :o4, 19732935, 8 - tz.transition 2041, 10, :o1, 14800919, 6 - tz.transition 2042, 4, :o4, 19735847, 8 - tz.transition 2042, 10, :o1, 14803103, 6 - tz.transition 2043, 4, :o4, 19738759, 8 - tz.transition 2043, 10, :o1, 14805287, 6 - tz.transition 2044, 4, :o4, 19741671, 8 - tz.transition 2044, 10, :o1, 14807513, 6 - tz.transition 2045, 4, :o4, 19744583, 8 - tz.transition 2045, 10, :o1, 14809697, 6 - tz.transition 2046, 4, :o4, 19747495, 8 - tz.transition 2046, 10, :o1, 14811881, 6 - tz.transition 2047, 4, :o4, 19750463, 8 - tz.transition 2047, 10, :o1, 14814065, 6 - tz.transition 2048, 4, :o4, 19753375, 8 - tz.transition 2048, 10, :o1, 14816249, 6 - tz.transition 2049, 4, :o4, 19756287, 8 - tz.transition 2049, 10, :o1, 14818475, 6 - tz.transition 2050, 4, :o4, 19759199, 8 - tz.transition 2050, 10, :o1, 14820659, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mexico_City.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mexico_City.rb deleted file mode 100644 index 2347fce..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mexico_City.rb +++ /dev/null @@ -1,144 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Mexico_City - include TimezoneDefinition - - timezone 'America/Mexico_City' do |tz| - tz.offset :o0, -23796, 0, :LMT - tz.offset :o1, -25200, 0, :MST - tz.offset :o2, -21600, 0, :CST - tz.offset :o3, -21600, 3600, :CDT - tz.offset :o4, -21600, 3600, :CWT - - tz.transition 1922, 1, :o1, 58153339, 24 - tz.transition 1927, 6, :o2, 9700171, 4 - tz.transition 1930, 11, :o1, 9705183, 4 - tz.transition 1931, 5, :o2, 9705855, 4 - tz.transition 1931, 10, :o1, 9706463, 4 - tz.transition 1932, 4, :o2, 58243171, 24 - tz.transition 1939, 2, :o3, 9717199, 4 - tz.transition 1939, 6, :o2, 58306553, 24 - tz.transition 1940, 12, :o3, 9719891, 4 - tz.transition 1941, 4, :o2, 58322057, 24 - tz.transition 1943, 12, :o4, 9724299, 4 - tz.transition 1944, 5, :o2, 58349081, 24 - tz.transition 1950, 2, :o3, 9733299, 4 - tz.transition 1950, 7, :o2, 58403825, 24 - tz.transition 1996, 4, :o3, 828864000 - tz.transition 1996, 10, :o2, 846399600 - tz.transition 1997, 4, :o3, 860313600 - tz.transition 1997, 10, :o2, 877849200 - tz.transition 1998, 4, :o3, 891763200 - tz.transition 1998, 10, :o2, 909298800 - tz.transition 1999, 4, :o3, 923212800 - tz.transition 1999, 10, :o2, 941353200 - tz.transition 2000, 4, :o3, 954662400 - tz.transition 2000, 10, :o2, 972802800 - tz.transition 2001, 5, :o3, 989136000 - tz.transition 2001, 9, :o2, 1001833200 - tz.transition 2002, 4, :o3, 1018166400 - tz.transition 2002, 10, :o2, 1035702000 - tz.transition 2003, 4, :o3, 1049616000 - tz.transition 2003, 10, :o2, 1067151600 - tz.transition 2004, 4, :o3, 1081065600 - tz.transition 2004, 10, :o2, 1099206000 - tz.transition 2005, 4, :o3, 1112515200 - tz.transition 2005, 10, :o2, 1130655600 - tz.transition 2006, 4, :o3, 1143964800 - tz.transition 2006, 10, :o2, 1162105200 - tz.transition 2007, 4, :o3, 1175414400 - tz.transition 2007, 10, :o2, 1193554800 - tz.transition 2008, 4, :o3, 1207468800 - tz.transition 2008, 10, :o2, 1225004400 - tz.transition 2009, 4, :o3, 1238918400 - tz.transition 2009, 10, :o2, 1256454000 - tz.transition 2010, 4, :o3, 1270368000 - tz.transition 2010, 10, :o2, 1288508400 - tz.transition 2011, 4, :o3, 1301817600 - tz.transition 2011, 10, :o2, 1319958000 - tz.transition 2012, 4, :o3, 1333267200 - tz.transition 2012, 10, :o2, 1351407600 - tz.transition 2013, 4, :o3, 1365321600 - tz.transition 2013, 10, :o2, 1382857200 - tz.transition 2014, 4, :o3, 1396771200 - tz.transition 2014, 10, :o2, 1414306800 - tz.transition 2015, 4, :o3, 1428220800 - tz.transition 2015, 10, :o2, 1445756400 - tz.transition 2016, 4, :o3, 1459670400 - tz.transition 2016, 10, :o2, 1477810800 - tz.transition 2017, 4, :o3, 1491120000 - tz.transition 2017, 10, :o2, 1509260400 - tz.transition 2018, 4, :o3, 1522569600 - tz.transition 2018, 10, :o2, 1540710000 - tz.transition 2019, 4, :o3, 1554624000 - tz.transition 2019, 10, :o2, 1572159600 - tz.transition 2020, 4, :o3, 1586073600 - tz.transition 2020, 10, :o2, 1603609200 - tz.transition 2021, 4, :o3, 1617523200 - tz.transition 2021, 10, :o2, 1635663600 - tz.transition 2022, 4, :o3, 1648972800 - tz.transition 2022, 10, :o2, 1667113200 - tz.transition 2023, 4, :o3, 1680422400 - tz.transition 2023, 10, :o2, 1698562800 - tz.transition 2024, 4, :o3, 1712476800 - tz.transition 2024, 10, :o2, 1730012400 - tz.transition 2025, 4, :o3, 1743926400 - tz.transition 2025, 10, :o2, 1761462000 - tz.transition 2026, 4, :o3, 1775376000 - tz.transition 2026, 10, :o2, 1792911600 - tz.transition 2027, 4, :o3, 1806825600 - tz.transition 2027, 10, :o2, 1824966000 - tz.transition 2028, 4, :o3, 1838275200 - tz.transition 2028, 10, :o2, 1856415600 - tz.transition 2029, 4, :o3, 1869724800 - tz.transition 2029, 10, :o2, 1887865200 - tz.transition 2030, 4, :o3, 1901779200 - tz.transition 2030, 10, :o2, 1919314800 - tz.transition 2031, 4, :o3, 1933228800 - tz.transition 2031, 10, :o2, 1950764400 - tz.transition 2032, 4, :o3, 1964678400 - tz.transition 2032, 10, :o2, 1982818800 - tz.transition 2033, 4, :o3, 1996128000 - tz.transition 2033, 10, :o2, 2014268400 - tz.transition 2034, 4, :o3, 2027577600 - tz.transition 2034, 10, :o2, 2045718000 - tz.transition 2035, 4, :o3, 2059027200 - tz.transition 2035, 10, :o2, 2077167600 - tz.transition 2036, 4, :o3, 2091081600 - tz.transition 2036, 10, :o2, 2108617200 - tz.transition 2037, 4, :o3, 2122531200 - tz.transition 2037, 10, :o2, 2140066800 - tz.transition 2038, 4, :o3, 14793107, 6 - tz.transition 2038, 10, :o2, 59177467, 24 - tz.transition 2039, 4, :o3, 14795291, 6 - tz.transition 2039, 10, :o2, 59186203, 24 - tz.transition 2040, 4, :o3, 14797475, 6 - tz.transition 2040, 10, :o2, 59194939, 24 - tz.transition 2041, 4, :o3, 14799701, 6 - tz.transition 2041, 10, :o2, 59203675, 24 - tz.transition 2042, 4, :o3, 14801885, 6 - tz.transition 2042, 10, :o2, 59212411, 24 - tz.transition 2043, 4, :o3, 14804069, 6 - tz.transition 2043, 10, :o2, 59221147, 24 - tz.transition 2044, 4, :o3, 14806253, 6 - tz.transition 2044, 10, :o2, 59230051, 24 - tz.transition 2045, 4, :o3, 14808437, 6 - tz.transition 2045, 10, :o2, 59238787, 24 - tz.transition 2046, 4, :o3, 14810621, 6 - tz.transition 2046, 10, :o2, 59247523, 24 - tz.transition 2047, 4, :o3, 14812847, 6 - tz.transition 2047, 10, :o2, 59256259, 24 - tz.transition 2048, 4, :o3, 14815031, 6 - tz.transition 2048, 10, :o2, 59264995, 24 - tz.transition 2049, 4, :o3, 14817215, 6 - tz.transition 2049, 10, :o2, 59273899, 24 - tz.transition 2050, 4, :o3, 14819399, 6 - tz.transition 2050, 10, :o2, 59282635, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Monterrey.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Monterrey.rb deleted file mode 100644 index 5816a9e..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Monterrey.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Monterrey - include TimezoneDefinition - - timezone 'America/Monterrey' do |tz| - tz.offset :o0, -24076, 0, :LMT - tz.offset :o1, -21600, 0, :CST - tz.offset :o2, -21600, 3600, :CDT - - tz.transition 1922, 1, :o1, 9692223, 4 - tz.transition 1988, 4, :o2, 576057600 - tz.transition 1988, 10, :o1, 594198000 - tz.transition 1996, 4, :o2, 828864000 - tz.transition 1996, 10, :o1, 846399600 - tz.transition 1997, 4, :o2, 860313600 - tz.transition 1997, 10, :o1, 877849200 - tz.transition 1998, 4, :o2, 891763200 - tz.transition 1998, 10, :o1, 909298800 - tz.transition 1999, 4, :o2, 923212800 - tz.transition 1999, 10, :o1, 941353200 - tz.transition 2000, 4, :o2, 954662400 - tz.transition 2000, 10, :o1, 972802800 - tz.transition 2001, 5, :o2, 989136000 - tz.transition 2001, 9, :o1, 1001833200 - tz.transition 2002, 4, :o2, 1018166400 - tz.transition 2002, 10, :o1, 1035702000 - tz.transition 2003, 4, :o2, 1049616000 - tz.transition 2003, 10, :o1, 1067151600 - tz.transition 2004, 4, :o2, 1081065600 - tz.transition 2004, 10, :o1, 1099206000 - tz.transition 2005, 4, :o2, 1112515200 - tz.transition 2005, 10, :o1, 1130655600 - tz.transition 2006, 4, :o2, 1143964800 - tz.transition 2006, 10, :o1, 1162105200 - tz.transition 2007, 4, :o2, 1175414400 - tz.transition 2007, 10, :o1, 1193554800 - tz.transition 2008, 4, :o2, 1207468800 - tz.transition 2008, 10, :o1, 1225004400 - tz.transition 2009, 4, :o2, 1238918400 - tz.transition 2009, 10, :o1, 1256454000 - tz.transition 2010, 4, :o2, 1270368000 - tz.transition 2010, 10, :o1, 1288508400 - tz.transition 2011, 4, :o2, 1301817600 - tz.transition 2011, 10, :o1, 1319958000 - tz.transition 2012, 4, :o2, 1333267200 - tz.transition 2012, 10, :o1, 1351407600 - tz.transition 2013, 4, :o2, 1365321600 - tz.transition 2013, 10, :o1, 1382857200 - tz.transition 2014, 4, :o2, 1396771200 - tz.transition 2014, 10, :o1, 1414306800 - tz.transition 2015, 4, :o2, 1428220800 - tz.transition 2015, 10, :o1, 1445756400 - tz.transition 2016, 4, :o2, 1459670400 - tz.transition 2016, 10, :o1, 1477810800 - tz.transition 2017, 4, :o2, 1491120000 - tz.transition 2017, 10, :o1, 1509260400 - tz.transition 2018, 4, :o2, 1522569600 - tz.transition 2018, 10, :o1, 1540710000 - tz.transition 2019, 4, :o2, 1554624000 - tz.transition 2019, 10, :o1, 1572159600 - tz.transition 2020, 4, :o2, 1586073600 - tz.transition 2020, 10, :o1, 1603609200 - tz.transition 2021, 4, :o2, 1617523200 - tz.transition 2021, 10, :o1, 1635663600 - tz.transition 2022, 4, :o2, 1648972800 - tz.transition 2022, 10, :o1, 1667113200 - tz.transition 2023, 4, :o2, 1680422400 - tz.transition 2023, 10, :o1, 1698562800 - tz.transition 2024, 4, :o2, 1712476800 - tz.transition 2024, 10, :o1, 1730012400 - tz.transition 2025, 4, :o2, 1743926400 - tz.transition 2025, 10, :o1, 1761462000 - tz.transition 2026, 4, :o2, 1775376000 - tz.transition 2026, 10, :o1, 1792911600 - tz.transition 2027, 4, :o2, 1806825600 - tz.transition 2027, 10, :o1, 1824966000 - tz.transition 2028, 4, :o2, 1838275200 - tz.transition 2028, 10, :o1, 1856415600 - tz.transition 2029, 4, :o2, 1869724800 - tz.transition 2029, 10, :o1, 1887865200 - tz.transition 2030, 4, :o2, 1901779200 - tz.transition 2030, 10, :o1, 1919314800 - tz.transition 2031, 4, :o2, 1933228800 - tz.transition 2031, 10, :o1, 1950764400 - tz.transition 2032, 4, :o2, 1964678400 - tz.transition 2032, 10, :o1, 1982818800 - tz.transition 2033, 4, :o2, 1996128000 - tz.transition 2033, 10, :o1, 2014268400 - tz.transition 2034, 4, :o2, 2027577600 - tz.transition 2034, 10, :o1, 2045718000 - tz.transition 2035, 4, :o2, 2059027200 - tz.transition 2035, 10, :o1, 2077167600 - tz.transition 2036, 4, :o2, 2091081600 - tz.transition 2036, 10, :o1, 2108617200 - tz.transition 2037, 4, :o2, 2122531200 - tz.transition 2037, 10, :o1, 2140066800 - tz.transition 2038, 4, :o2, 14793107, 6 - tz.transition 2038, 10, :o1, 59177467, 24 - tz.transition 2039, 4, :o2, 14795291, 6 - tz.transition 2039, 10, :o1, 59186203, 24 - tz.transition 2040, 4, :o2, 14797475, 6 - tz.transition 2040, 10, :o1, 59194939, 24 - tz.transition 2041, 4, :o2, 14799701, 6 - tz.transition 2041, 10, :o1, 59203675, 24 - tz.transition 2042, 4, :o2, 14801885, 6 - tz.transition 2042, 10, :o1, 59212411, 24 - tz.transition 2043, 4, :o2, 14804069, 6 - tz.transition 2043, 10, :o1, 59221147, 24 - tz.transition 2044, 4, :o2, 14806253, 6 - tz.transition 2044, 10, :o1, 59230051, 24 - tz.transition 2045, 4, :o2, 14808437, 6 - tz.transition 2045, 10, :o1, 59238787, 24 - tz.transition 2046, 4, :o2, 14810621, 6 - tz.transition 2046, 10, :o1, 59247523, 24 - tz.transition 2047, 4, :o2, 14812847, 6 - tz.transition 2047, 10, :o1, 59256259, 24 - tz.transition 2048, 4, :o2, 14815031, 6 - tz.transition 2048, 10, :o1, 59264995, 24 - tz.transition 2049, 4, :o2, 14817215, 6 - tz.transition 2049, 10, :o1, 59273899, 24 - tz.transition 2050, 4, :o2, 14819399, 6 - tz.transition 2050, 10, :o1, 59282635, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/New_York.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/New_York.rb deleted file mode 100644 index 7d802bd..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/New_York.rb +++ /dev/null @@ -1,282 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module New_York - include TimezoneDefinition - - timezone 'America/New_York' do |tz| - tz.offset :o0, -17762, 0, :LMT - tz.offset :o1, -18000, 0, :EST - tz.offset :o2, -18000, 3600, :EDT - tz.offset :o3, -18000, 3600, :EWT - tz.offset :o4, -18000, 3600, :EPT - - tz.transition 1883, 11, :o1, 57819197, 24 - tz.transition 1918, 3, :o2, 58120411, 24 - tz.transition 1918, 10, :o1, 9687575, 4 - tz.transition 1919, 3, :o2, 58129147, 24 - tz.transition 1919, 10, :o1, 9689031, 4 - tz.transition 1920, 3, :o2, 58137883, 24 - tz.transition 1920, 10, :o1, 9690515, 4 - tz.transition 1921, 4, :o2, 58147291, 24 - tz.transition 1921, 9, :o1, 9691831, 4 - tz.transition 1922, 4, :o2, 58156195, 24 - tz.transition 1922, 9, :o1, 9693287, 4 - tz.transition 1923, 4, :o2, 58164931, 24 - tz.transition 1923, 9, :o1, 9694771, 4 - tz.transition 1924, 4, :o2, 58173667, 24 - tz.transition 1924, 9, :o1, 9696227, 4 - tz.transition 1925, 4, :o2, 58182403, 24 - tz.transition 1925, 9, :o1, 9697683, 4 - tz.transition 1926, 4, :o2, 58191139, 24 - tz.transition 1926, 9, :o1, 9699139, 4 - tz.transition 1927, 4, :o2, 58199875, 24 - tz.transition 1927, 9, :o1, 9700595, 4 - tz.transition 1928, 4, :o2, 58208779, 24 - tz.transition 1928, 9, :o1, 9702079, 4 - tz.transition 1929, 4, :o2, 58217515, 24 - tz.transition 1929, 9, :o1, 9703535, 4 - tz.transition 1930, 4, :o2, 58226251, 24 - tz.transition 1930, 9, :o1, 9704991, 4 - tz.transition 1931, 4, :o2, 58234987, 24 - tz.transition 1931, 9, :o1, 9706447, 4 - tz.transition 1932, 4, :o2, 58243723, 24 - tz.transition 1932, 9, :o1, 9707903, 4 - tz.transition 1933, 4, :o2, 58252627, 24 - tz.transition 1933, 9, :o1, 9709359, 4 - tz.transition 1934, 4, :o2, 58261363, 24 - tz.transition 1934, 9, :o1, 9710843, 4 - tz.transition 1935, 4, :o2, 58270099, 24 - tz.transition 1935, 9, :o1, 9712299, 4 - tz.transition 1936, 4, :o2, 58278835, 24 - tz.transition 1936, 9, :o1, 9713755, 4 - tz.transition 1937, 4, :o2, 58287571, 24 - tz.transition 1937, 9, :o1, 9715211, 4 - tz.transition 1938, 4, :o2, 58296307, 24 - tz.transition 1938, 9, :o1, 9716667, 4 - tz.transition 1939, 4, :o2, 58305211, 24 - tz.transition 1939, 9, :o1, 9718123, 4 - tz.transition 1940, 4, :o2, 58313947, 24 - tz.transition 1940, 9, :o1, 9719607, 4 - tz.transition 1941, 4, :o2, 58322683, 24 - tz.transition 1941, 9, :o1, 9721063, 4 - tz.transition 1942, 2, :o3, 58329595, 24 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o1, 9726915, 4 - tz.transition 1946, 4, :o2, 58366531, 24 - tz.transition 1946, 9, :o1, 9728371, 4 - tz.transition 1947, 4, :o2, 58375267, 24 - tz.transition 1947, 9, :o1, 9729827, 4 - tz.transition 1948, 4, :o2, 58384003, 24 - tz.transition 1948, 9, :o1, 9731283, 4 - tz.transition 1949, 4, :o2, 58392739, 24 - tz.transition 1949, 9, :o1, 9732739, 4 - tz.transition 1950, 4, :o2, 58401643, 24 - tz.transition 1950, 9, :o1, 9734195, 4 - tz.transition 1951, 4, :o2, 58410379, 24 - tz.transition 1951, 9, :o1, 9735679, 4 - tz.transition 1952, 4, :o2, 58419115, 24 - tz.transition 1952, 9, :o1, 9737135, 4 - tz.transition 1953, 4, :o2, 58427851, 24 - tz.transition 1953, 9, :o1, 9738591, 4 - tz.transition 1954, 4, :o2, 58436587, 24 - tz.transition 1954, 9, :o1, 9740047, 4 - tz.transition 1955, 4, :o2, 58445323, 24 - tz.transition 1955, 10, :o1, 9741643, 4 - tz.transition 1956, 4, :o2, 58454227, 24 - tz.transition 1956, 10, :o1, 9743099, 4 - tz.transition 1957, 4, :o2, 58462963, 24 - tz.transition 1957, 10, :o1, 9744555, 4 - tz.transition 1958, 4, :o2, 58471699, 24 - tz.transition 1958, 10, :o1, 9746011, 4 - tz.transition 1959, 4, :o2, 58480435, 24 - tz.transition 1959, 10, :o1, 9747467, 4 - tz.transition 1960, 4, :o2, 58489171, 24 - tz.transition 1960, 10, :o1, 9748951, 4 - tz.transition 1961, 4, :o2, 58498075, 24 - tz.transition 1961, 10, :o1, 9750407, 4 - tz.transition 1962, 4, :o2, 58506811, 24 - tz.transition 1962, 10, :o1, 9751863, 4 - tz.transition 1963, 4, :o2, 58515547, 24 - tz.transition 1963, 10, :o1, 9753319, 4 - tz.transition 1964, 4, :o2, 58524283, 24 - tz.transition 1964, 10, :o1, 9754775, 4 - tz.transition 1965, 4, :o2, 58533019, 24 - tz.transition 1965, 10, :o1, 9756259, 4 - tz.transition 1966, 4, :o2, 58541755, 24 - tz.transition 1966, 10, :o1, 9757715, 4 - tz.transition 1967, 4, :o2, 58550659, 24 - tz.transition 1967, 10, :o1, 9759171, 4 - tz.transition 1968, 4, :o2, 58559395, 24 - tz.transition 1968, 10, :o1, 9760627, 4 - tz.transition 1969, 4, :o2, 58568131, 24 - tz.transition 1969, 10, :o1, 9762083, 4 - tz.transition 1970, 4, :o2, 9961200 - tz.transition 1970, 10, :o1, 25682400 - tz.transition 1971, 4, :o2, 41410800 - tz.transition 1971, 10, :o1, 57736800 - tz.transition 1972, 4, :o2, 73465200 - tz.transition 1972, 10, :o1, 89186400 - tz.transition 1973, 4, :o2, 104914800 - tz.transition 1973, 10, :o1, 120636000 - tz.transition 1974, 1, :o2, 126687600 - tz.transition 1974, 10, :o1, 152085600 - tz.transition 1975, 2, :o2, 162370800 - tz.transition 1975, 10, :o1, 183535200 - tz.transition 1976, 4, :o2, 199263600 - tz.transition 1976, 10, :o1, 215589600 - tz.transition 1977, 4, :o2, 230713200 - tz.transition 1977, 10, :o1, 247039200 - tz.transition 1978, 4, :o2, 262767600 - tz.transition 1978, 10, :o1, 278488800 - tz.transition 1979, 4, :o2, 294217200 - tz.transition 1979, 10, :o1, 309938400 - tz.transition 1980, 4, :o2, 325666800 - tz.transition 1980, 10, :o1, 341388000 - tz.transition 1981, 4, :o2, 357116400 - tz.transition 1981, 10, :o1, 372837600 - tz.transition 1982, 4, :o2, 388566000 - tz.transition 1982, 10, :o1, 404892000 - tz.transition 1983, 4, :o2, 420015600 - tz.transition 1983, 10, :o1, 436341600 - tz.transition 1984, 4, :o2, 452070000 - tz.transition 1984, 10, :o1, 467791200 - tz.transition 1985, 4, :o2, 483519600 - tz.transition 1985, 10, :o1, 499240800 - tz.transition 1986, 4, :o2, 514969200 - tz.transition 1986, 10, :o1, 530690400 - tz.transition 1987, 4, :o2, 544604400 - tz.transition 1987, 10, :o1, 562140000 - tz.transition 1988, 4, :o2, 576054000 - tz.transition 1988, 10, :o1, 594194400 - tz.transition 1989, 4, :o2, 607503600 - tz.transition 1989, 10, :o1, 625644000 - tz.transition 1990, 4, :o2, 638953200 - tz.transition 1990, 10, :o1, 657093600 - tz.transition 1991, 4, :o2, 671007600 - tz.transition 1991, 10, :o1, 688543200 - tz.transition 1992, 4, :o2, 702457200 - tz.transition 1992, 10, :o1, 719992800 - tz.transition 1993, 4, :o2, 733906800 - tz.transition 1993, 10, :o1, 752047200 - tz.transition 1994, 4, :o2, 765356400 - tz.transition 1994, 10, :o1, 783496800 - tz.transition 1995, 4, :o2, 796806000 - tz.transition 1995, 10, :o1, 814946400 - tz.transition 1996, 4, :o2, 828860400 - tz.transition 1996, 10, :o1, 846396000 - tz.transition 1997, 4, :o2, 860310000 - tz.transition 1997, 10, :o1, 877845600 - tz.transition 1998, 4, :o2, 891759600 - tz.transition 1998, 10, :o1, 909295200 - tz.transition 1999, 4, :o2, 923209200 - tz.transition 1999, 10, :o1, 941349600 - tz.transition 2000, 4, :o2, 954658800 - tz.transition 2000, 10, :o1, 972799200 - tz.transition 2001, 4, :o2, 986108400 - tz.transition 2001, 10, :o1, 1004248800 - tz.transition 2002, 4, :o2, 1018162800 - tz.transition 2002, 10, :o1, 1035698400 - tz.transition 2003, 4, :o2, 1049612400 - tz.transition 2003, 10, :o1, 1067148000 - tz.transition 2004, 4, :o2, 1081062000 - tz.transition 2004, 10, :o1, 1099202400 - tz.transition 2005, 4, :o2, 1112511600 - tz.transition 2005, 10, :o1, 1130652000 - tz.transition 2006, 4, :o2, 1143961200 - tz.transition 2006, 10, :o1, 1162101600 - tz.transition 2007, 3, :o2, 1173596400 - tz.transition 2007, 11, :o1, 1194156000 - tz.transition 2008, 3, :o2, 1205046000 - tz.transition 2008, 11, :o1, 1225605600 - tz.transition 2009, 3, :o2, 1236495600 - tz.transition 2009, 11, :o1, 1257055200 - tz.transition 2010, 3, :o2, 1268550000 - tz.transition 2010, 11, :o1, 1289109600 - tz.transition 2011, 3, :o2, 1299999600 - tz.transition 2011, 11, :o1, 1320559200 - tz.transition 2012, 3, :o2, 1331449200 - tz.transition 2012, 11, :o1, 1352008800 - tz.transition 2013, 3, :o2, 1362898800 - tz.transition 2013, 11, :o1, 1383458400 - tz.transition 2014, 3, :o2, 1394348400 - tz.transition 2014, 11, :o1, 1414908000 - tz.transition 2015, 3, :o2, 1425798000 - tz.transition 2015, 11, :o1, 1446357600 - tz.transition 2016, 3, :o2, 1457852400 - tz.transition 2016, 11, :o1, 1478412000 - tz.transition 2017, 3, :o2, 1489302000 - tz.transition 2017, 11, :o1, 1509861600 - tz.transition 2018, 3, :o2, 1520751600 - tz.transition 2018, 11, :o1, 1541311200 - tz.transition 2019, 3, :o2, 1552201200 - tz.transition 2019, 11, :o1, 1572760800 - tz.transition 2020, 3, :o2, 1583650800 - tz.transition 2020, 11, :o1, 1604210400 - tz.transition 2021, 3, :o2, 1615705200 - tz.transition 2021, 11, :o1, 1636264800 - tz.transition 2022, 3, :o2, 1647154800 - tz.transition 2022, 11, :o1, 1667714400 - tz.transition 2023, 3, :o2, 1678604400 - tz.transition 2023, 11, :o1, 1699164000 - tz.transition 2024, 3, :o2, 1710054000 - tz.transition 2024, 11, :o1, 1730613600 - tz.transition 2025, 3, :o2, 1741503600 - tz.transition 2025, 11, :o1, 1762063200 - tz.transition 2026, 3, :o2, 1772953200 - tz.transition 2026, 11, :o1, 1793512800 - tz.transition 2027, 3, :o2, 1805007600 - tz.transition 2027, 11, :o1, 1825567200 - tz.transition 2028, 3, :o2, 1836457200 - tz.transition 2028, 11, :o1, 1857016800 - tz.transition 2029, 3, :o2, 1867906800 - tz.transition 2029, 11, :o1, 1888466400 - tz.transition 2030, 3, :o2, 1899356400 - tz.transition 2030, 11, :o1, 1919916000 - tz.transition 2031, 3, :o2, 1930806000 - tz.transition 2031, 11, :o1, 1951365600 - tz.transition 2032, 3, :o2, 1962860400 - tz.transition 2032, 11, :o1, 1983420000 - tz.transition 2033, 3, :o2, 1994310000 - tz.transition 2033, 11, :o1, 2014869600 - tz.transition 2034, 3, :o2, 2025759600 - tz.transition 2034, 11, :o1, 2046319200 - tz.transition 2035, 3, :o2, 2057209200 - tz.transition 2035, 11, :o1, 2077768800 - tz.transition 2036, 3, :o2, 2088658800 - tz.transition 2036, 11, :o1, 2109218400 - tz.transition 2037, 3, :o2, 2120108400 - tz.transition 2037, 11, :o1, 2140668000 - tz.transition 2038, 3, :o2, 59171923, 24 - tz.transition 2038, 11, :o1, 9862939, 4 - tz.transition 2039, 3, :o2, 59180659, 24 - tz.transition 2039, 11, :o1, 9864395, 4 - tz.transition 2040, 3, :o2, 59189395, 24 - tz.transition 2040, 11, :o1, 9865851, 4 - tz.transition 2041, 3, :o2, 59198131, 24 - tz.transition 2041, 11, :o1, 9867307, 4 - tz.transition 2042, 3, :o2, 59206867, 24 - tz.transition 2042, 11, :o1, 9868763, 4 - tz.transition 2043, 3, :o2, 59215603, 24 - tz.transition 2043, 11, :o1, 9870219, 4 - tz.transition 2044, 3, :o2, 59224507, 24 - tz.transition 2044, 11, :o1, 9871703, 4 - tz.transition 2045, 3, :o2, 59233243, 24 - tz.transition 2045, 11, :o1, 9873159, 4 - tz.transition 2046, 3, :o2, 59241979, 24 - tz.transition 2046, 11, :o1, 9874615, 4 - tz.transition 2047, 3, :o2, 59250715, 24 - tz.transition 2047, 11, :o1, 9876071, 4 - tz.transition 2048, 3, :o2, 59259451, 24 - tz.transition 2048, 11, :o1, 9877527, 4 - tz.transition 2049, 3, :o2, 59268355, 24 - tz.transition 2049, 11, :o1, 9879011, 4 - tz.transition 2050, 3, :o2, 59277091, 24 - tz.transition 2050, 11, :o1, 9880467, 4 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Phoenix.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Phoenix.rb deleted file mode 100644 index b514e0c..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Phoenix.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Phoenix - include TimezoneDefinition - - timezone 'America/Phoenix' do |tz| - tz.offset :o0, -26898, 0, :LMT - tz.offset :o1, -25200, 0, :MST - tz.offset :o2, -25200, 3600, :MDT - tz.offset :o3, -25200, 3600, :MWT - - tz.transition 1883, 11, :o1, 57819199, 24 - tz.transition 1918, 3, :o2, 19373471, 8 - tz.transition 1918, 10, :o1, 14531363, 6 - tz.transition 1919, 3, :o2, 19376383, 8 - tz.transition 1919, 10, :o1, 14533547, 6 - tz.transition 1942, 2, :o3, 19443199, 8 - tz.transition 1944, 1, :o1, 3500770681, 1440 - tz.transition 1944, 4, :o3, 3500901781, 1440 - tz.transition 1944, 10, :o1, 3501165241, 1440 - tz.transition 1967, 4, :o2, 19516887, 8 - tz.transition 1967, 10, :o1, 14638757, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Regina.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Regina.rb deleted file mode 100644 index ebdb688..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Regina.rb +++ /dev/null @@ -1,74 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Regina - include TimezoneDefinition - - timezone 'America/Regina' do |tz| - tz.offset :o0, -25116, 0, :LMT - tz.offset :o1, -25200, 0, :MST - tz.offset :o2, -25200, 3600, :MDT - tz.offset :o3, -25200, 3600, :MWT - tz.offset :o4, -25200, 3600, :MPT - tz.offset :o5, -21600, 0, :CST - - tz.transition 1905, 9, :o1, 17403046493, 7200 - tz.transition 1918, 4, :o2, 19373583, 8 - tz.transition 1918, 10, :o1, 14531387, 6 - tz.transition 1930, 5, :o2, 58226419, 24 - tz.transition 1930, 10, :o1, 9705019, 4 - tz.transition 1931, 5, :o2, 58235155, 24 - tz.transition 1931, 10, :o1, 9706475, 4 - tz.transition 1932, 5, :o2, 58243891, 24 - tz.transition 1932, 10, :o1, 9707931, 4 - tz.transition 1933, 5, :o2, 58252795, 24 - tz.transition 1933, 10, :o1, 9709387, 4 - tz.transition 1934, 5, :o2, 58261531, 24 - tz.transition 1934, 10, :o1, 9710871, 4 - tz.transition 1937, 4, :o2, 58287235, 24 - tz.transition 1937, 10, :o1, 9715267, 4 - tz.transition 1938, 4, :o2, 58295971, 24 - tz.transition 1938, 10, :o1, 9716695, 4 - tz.transition 1939, 4, :o2, 58304707, 24 - tz.transition 1939, 10, :o1, 9718179, 4 - tz.transition 1940, 4, :o2, 58313611, 24 - tz.transition 1940, 10, :o1, 9719663, 4 - tz.transition 1941, 4, :o2, 58322347, 24 - tz.transition 1941, 10, :o1, 9721119, 4 - tz.transition 1942, 2, :o3, 19443199, 8 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o1, 14590373, 6 - tz.transition 1946, 4, :o2, 19455399, 8 - tz.transition 1946, 10, :o1, 14592641, 6 - tz.transition 1947, 4, :o2, 19458423, 8 - tz.transition 1947, 9, :o1, 14594741, 6 - tz.transition 1948, 4, :o2, 19461335, 8 - tz.transition 1948, 9, :o1, 14596925, 6 - tz.transition 1949, 4, :o2, 19464247, 8 - tz.transition 1949, 9, :o1, 14599109, 6 - tz.transition 1950, 4, :o2, 19467215, 8 - tz.transition 1950, 9, :o1, 14601293, 6 - tz.transition 1951, 4, :o2, 19470127, 8 - tz.transition 1951, 9, :o1, 14603519, 6 - tz.transition 1952, 4, :o2, 19473039, 8 - tz.transition 1952, 9, :o1, 14605703, 6 - tz.transition 1953, 4, :o2, 19475951, 8 - tz.transition 1953, 9, :o1, 14607887, 6 - tz.transition 1954, 4, :o2, 19478863, 8 - tz.transition 1954, 9, :o1, 14610071, 6 - tz.transition 1955, 4, :o2, 19481775, 8 - tz.transition 1955, 9, :o1, 14612255, 6 - tz.transition 1956, 4, :o2, 19484743, 8 - tz.transition 1956, 9, :o1, 14614481, 6 - tz.transition 1957, 4, :o2, 19487655, 8 - tz.transition 1957, 9, :o1, 14616665, 6 - tz.transition 1959, 4, :o2, 19493479, 8 - tz.transition 1959, 10, :o1, 14621201, 6 - tz.transition 1960, 4, :o5, 19496391, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Santiago.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Santiago.rb deleted file mode 100644 index 0287c9e..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Santiago.rb +++ /dev/null @@ -1,205 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Santiago - include TimezoneDefinition - - timezone 'America/Santiago' do |tz| - tz.offset :o0, -16966, 0, :LMT - tz.offset :o1, -16966, 0, :SMT - tz.offset :o2, -18000, 0, :CLT - tz.offset :o3, -14400, 0, :CLT - tz.offset :o4, -18000, 3600, :CLST - tz.offset :o5, -14400, 3600, :CLST - - tz.transition 1890, 1, :o1, 104171127683, 43200 - tz.transition 1910, 1, :o2, 104486660483, 43200 - tz.transition 1916, 7, :o1, 58105097, 24 - tz.transition 1918, 9, :o3, 104623388483, 43200 - tz.transition 1919, 7, :o1, 7266422, 3 - tz.transition 1927, 9, :o4, 104765386883, 43200 - tz.transition 1928, 4, :o2, 7276013, 3 - tz.transition 1928, 9, :o4, 58211777, 24 - tz.transition 1929, 4, :o2, 7277108, 3 - tz.transition 1929, 9, :o4, 58220537, 24 - tz.transition 1930, 4, :o2, 7278203, 3 - tz.transition 1930, 9, :o4, 58229297, 24 - tz.transition 1931, 4, :o2, 7279298, 3 - tz.transition 1931, 9, :o4, 58238057, 24 - tz.transition 1932, 4, :o2, 7280396, 3 - tz.transition 1932, 9, :o4, 58246841, 24 - tz.transition 1942, 6, :o2, 7291535, 3 - tz.transition 1942, 8, :o4, 58333745, 24 - tz.transition 1946, 9, :o2, 19456517, 8 - tz.transition 1947, 5, :o3, 58375865, 24 - tz.transition 1968, 11, :o5, 7320491, 3 - tz.transition 1969, 3, :o3, 19522485, 8 - tz.transition 1969, 11, :o5, 7321646, 3 - tz.transition 1970, 3, :o3, 7527600 - tz.transition 1970, 10, :o5, 24465600 - tz.transition 1971, 3, :o3, 37767600 - tz.transition 1971, 10, :o5, 55915200 - tz.transition 1972, 3, :o3, 69217200 - tz.transition 1972, 10, :o5, 87969600 - tz.transition 1973, 3, :o3, 100666800 - tz.transition 1973, 9, :o5, 118209600 - tz.transition 1974, 3, :o3, 132116400 - tz.transition 1974, 10, :o5, 150868800 - tz.transition 1975, 3, :o3, 163566000 - tz.transition 1975, 10, :o5, 182318400 - tz.transition 1976, 3, :o3, 195620400 - tz.transition 1976, 10, :o5, 213768000 - tz.transition 1977, 3, :o3, 227070000 - tz.transition 1977, 10, :o5, 245217600 - tz.transition 1978, 3, :o3, 258519600 - tz.transition 1978, 10, :o5, 277272000 - tz.transition 1979, 3, :o3, 289969200 - tz.transition 1979, 10, :o5, 308721600 - tz.transition 1980, 3, :o3, 321418800 - tz.transition 1980, 10, :o5, 340171200 - tz.transition 1981, 3, :o3, 353473200 - tz.transition 1981, 10, :o5, 371620800 - tz.transition 1982, 3, :o3, 384922800 - tz.transition 1982, 10, :o5, 403070400 - tz.transition 1983, 3, :o3, 416372400 - tz.transition 1983, 10, :o5, 434520000 - tz.transition 1984, 3, :o3, 447822000 - tz.transition 1984, 10, :o5, 466574400 - tz.transition 1985, 3, :o3, 479271600 - tz.transition 1985, 10, :o5, 498024000 - tz.transition 1986, 3, :o3, 510721200 - tz.transition 1986, 10, :o5, 529473600 - tz.transition 1987, 4, :o3, 545194800 - tz.transition 1987, 10, :o5, 560923200 - tz.transition 1988, 3, :o3, 574225200 - tz.transition 1988, 10, :o5, 591768000 - tz.transition 1989, 3, :o3, 605674800 - tz.transition 1989, 10, :o5, 624427200 - tz.transition 1990, 3, :o3, 637729200 - tz.transition 1990, 9, :o5, 653457600 - tz.transition 1991, 3, :o3, 668574000 - tz.transition 1991, 10, :o5, 687326400 - tz.transition 1992, 3, :o3, 700628400 - tz.transition 1992, 10, :o5, 718776000 - tz.transition 1993, 3, :o3, 732078000 - tz.transition 1993, 10, :o5, 750225600 - tz.transition 1994, 3, :o3, 763527600 - tz.transition 1994, 10, :o5, 781675200 - tz.transition 1995, 3, :o3, 794977200 - tz.transition 1995, 10, :o5, 813729600 - tz.transition 1996, 3, :o3, 826426800 - tz.transition 1996, 10, :o5, 845179200 - tz.transition 1997, 3, :o3, 859690800 - tz.transition 1997, 10, :o5, 876628800 - tz.transition 1998, 3, :o3, 889930800 - tz.transition 1998, 9, :o5, 906868800 - tz.transition 1999, 4, :o3, 923194800 - tz.transition 1999, 10, :o5, 939528000 - tz.transition 2000, 3, :o3, 952830000 - tz.transition 2000, 10, :o5, 971582400 - tz.transition 2001, 3, :o3, 984279600 - tz.transition 2001, 10, :o5, 1003032000 - tz.transition 2002, 3, :o3, 1015729200 - tz.transition 2002, 10, :o5, 1034481600 - tz.transition 2003, 3, :o3, 1047178800 - tz.transition 2003, 10, :o5, 1065931200 - tz.transition 2004, 3, :o3, 1079233200 - tz.transition 2004, 10, :o5, 1097380800 - tz.transition 2005, 3, :o3, 1110682800 - tz.transition 2005, 10, :o5, 1128830400 - tz.transition 2006, 3, :o3, 1142132400 - tz.transition 2006, 10, :o5, 1160884800 - tz.transition 2007, 3, :o3, 1173582000 - tz.transition 2007, 10, :o5, 1192334400 - tz.transition 2008, 3, :o3, 1206846000 - tz.transition 2008, 10, :o5, 1223784000 - tz.transition 2009, 3, :o3, 1237086000 - tz.transition 2009, 10, :o5, 1255233600 - tz.transition 2010, 3, :o3, 1268535600 - tz.transition 2010, 10, :o5, 1286683200 - tz.transition 2011, 3, :o3, 1299985200 - tz.transition 2011, 10, :o5, 1318132800 - tz.transition 2012, 3, :o3, 1331434800 - tz.transition 2012, 10, :o5, 1350187200 - tz.transition 2013, 3, :o3, 1362884400 - tz.transition 2013, 10, :o5, 1381636800 - tz.transition 2014, 3, :o3, 1394334000 - tz.transition 2014, 10, :o5, 1413086400 - tz.transition 2015, 3, :o3, 1426388400 - tz.transition 2015, 10, :o5, 1444536000 - tz.transition 2016, 3, :o3, 1457838000 - tz.transition 2016, 10, :o5, 1475985600 - tz.transition 2017, 3, :o3, 1489287600 - tz.transition 2017, 10, :o5, 1508040000 - tz.transition 2018, 3, :o3, 1520737200 - tz.transition 2018, 10, :o5, 1539489600 - tz.transition 2019, 3, :o3, 1552186800 - tz.transition 2019, 10, :o5, 1570939200 - tz.transition 2020, 3, :o3, 1584241200 - tz.transition 2020, 10, :o5, 1602388800 - tz.transition 2021, 3, :o3, 1615690800 - tz.transition 2021, 10, :o5, 1633838400 - tz.transition 2022, 3, :o3, 1647140400 - tz.transition 2022, 10, :o5, 1665288000 - tz.transition 2023, 3, :o3, 1678590000 - tz.transition 2023, 10, :o5, 1697342400 - tz.transition 2024, 3, :o3, 1710039600 - tz.transition 2024, 10, :o5, 1728792000 - tz.transition 2025, 3, :o3, 1741489200 - tz.transition 2025, 10, :o5, 1760241600 - tz.transition 2026, 3, :o3, 1773543600 - tz.transition 2026, 10, :o5, 1791691200 - tz.transition 2027, 3, :o3, 1804993200 - tz.transition 2027, 10, :o5, 1823140800 - tz.transition 2028, 3, :o3, 1836442800 - tz.transition 2028, 10, :o5, 1855195200 - tz.transition 2029, 3, :o3, 1867892400 - tz.transition 2029, 10, :o5, 1886644800 - tz.transition 2030, 3, :o3, 1899342000 - tz.transition 2030, 10, :o5, 1918094400 - tz.transition 2031, 3, :o3, 1930791600 - tz.transition 2031, 10, :o5, 1949544000 - tz.transition 2032, 3, :o3, 1962846000 - tz.transition 2032, 10, :o5, 1980993600 - tz.transition 2033, 3, :o3, 1994295600 - tz.transition 2033, 10, :o5, 2012443200 - tz.transition 2034, 3, :o3, 2025745200 - tz.transition 2034, 10, :o5, 2044497600 - tz.transition 2035, 3, :o3, 2057194800 - tz.transition 2035, 10, :o5, 2075947200 - tz.transition 2036, 3, :o3, 2088644400 - tz.transition 2036, 10, :o5, 2107396800 - tz.transition 2037, 3, :o3, 2120698800 - tz.transition 2037, 10, :o5, 2138846400 - tz.transition 2038, 3, :o3, 19723973, 8 - tz.transition 2038, 10, :o5, 7397120, 3 - tz.transition 2039, 3, :o3, 19726885, 8 - tz.transition 2039, 10, :o5, 7398212, 3 - tz.transition 2040, 3, :o3, 19729797, 8 - tz.transition 2040, 10, :o5, 7399325, 3 - tz.transition 2041, 3, :o3, 19732709, 8 - tz.transition 2041, 10, :o5, 7400417, 3 - tz.transition 2042, 3, :o3, 19735621, 8 - tz.transition 2042, 10, :o5, 7401509, 3 - tz.transition 2043, 3, :o3, 19738589, 8 - tz.transition 2043, 10, :o5, 7402601, 3 - tz.transition 2044, 3, :o3, 19741501, 8 - tz.transition 2044, 10, :o5, 7403693, 3 - tz.transition 2045, 3, :o3, 19744413, 8 - tz.transition 2045, 10, :o5, 7404806, 3 - tz.transition 2046, 3, :o3, 19747325, 8 - tz.transition 2046, 10, :o5, 7405898, 3 - tz.transition 2047, 3, :o3, 19750237, 8 - tz.transition 2047, 10, :o5, 7406990, 3 - tz.transition 2048, 3, :o3, 19753205, 8 - tz.transition 2048, 10, :o5, 7408082, 3 - tz.transition 2049, 3, :o3, 19756117, 8 - tz.transition 2049, 10, :o5, 7409174, 3 - tz.transition 2050, 3, :o3, 19759029, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Sao_Paulo.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Sao_Paulo.rb deleted file mode 100644 index 0524f81..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Sao_Paulo.rb +++ /dev/null @@ -1,171 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Sao_Paulo - include TimezoneDefinition - - timezone 'America/Sao_Paulo' do |tz| - tz.offset :o0, -11188, 0, :LMT - tz.offset :o1, -10800, 0, :BRT - tz.offset :o2, -10800, 3600, :BRST - - tz.transition 1914, 1, :o1, 52274886397, 21600 - tz.transition 1931, 10, :o2, 29119417, 12 - tz.transition 1932, 4, :o1, 29121583, 12 - tz.transition 1932, 10, :o2, 19415869, 8 - tz.transition 1933, 4, :o1, 29125963, 12 - tz.transition 1949, 12, :o2, 19466013, 8 - tz.transition 1950, 4, :o1, 19467101, 8 - tz.transition 1950, 12, :o2, 19468933, 8 - tz.transition 1951, 4, :o1, 29204851, 12 - tz.transition 1951, 12, :o2, 19471853, 8 - tz.transition 1952, 4, :o1, 29209243, 12 - tz.transition 1952, 12, :o2, 19474781, 8 - tz.transition 1953, 3, :o1, 29213251, 12 - tz.transition 1963, 10, :o2, 19506605, 8 - tz.transition 1964, 3, :o1, 29261467, 12 - tz.transition 1965, 1, :o2, 19510333, 8 - tz.transition 1965, 3, :o1, 29266207, 12 - tz.transition 1965, 12, :o2, 19512765, 8 - tz.transition 1966, 3, :o1, 29270227, 12 - tz.transition 1966, 11, :o2, 19515445, 8 - tz.transition 1967, 3, :o1, 29274607, 12 - tz.transition 1967, 11, :o2, 19518365, 8 - tz.transition 1968, 3, :o1, 29278999, 12 - tz.transition 1985, 11, :o2, 499748400 - tz.transition 1986, 3, :o1, 511236000 - tz.transition 1986, 10, :o2, 530593200 - tz.transition 1987, 2, :o1, 540266400 - tz.transition 1987, 10, :o2, 562129200 - tz.transition 1988, 2, :o1, 571197600 - tz.transition 1988, 10, :o2, 592974000 - tz.transition 1989, 1, :o1, 602042400 - tz.transition 1989, 10, :o2, 624423600 - tz.transition 1990, 2, :o1, 634701600 - tz.transition 1990, 10, :o2, 656478000 - tz.transition 1991, 2, :o1, 666756000 - tz.transition 1991, 10, :o2, 687927600 - tz.transition 1992, 2, :o1, 697600800 - tz.transition 1992, 10, :o2, 719982000 - tz.transition 1993, 1, :o1, 728445600 - tz.transition 1993, 10, :o2, 750826800 - tz.transition 1994, 2, :o1, 761709600 - tz.transition 1994, 10, :o2, 782276400 - tz.transition 1995, 2, :o1, 793159200 - tz.transition 1995, 10, :o2, 813726000 - tz.transition 1996, 2, :o1, 824004000 - tz.transition 1996, 10, :o2, 844570800 - tz.transition 1997, 2, :o1, 856058400 - tz.transition 1997, 10, :o2, 876106800 - tz.transition 1998, 3, :o1, 888717600 - tz.transition 1998, 10, :o2, 908074800 - tz.transition 1999, 2, :o1, 919562400 - tz.transition 1999, 10, :o2, 938919600 - tz.transition 2000, 2, :o1, 951616800 - tz.transition 2000, 10, :o2, 970974000 - tz.transition 2001, 2, :o1, 982461600 - tz.transition 2001, 10, :o2, 1003028400 - tz.transition 2002, 2, :o1, 1013911200 - tz.transition 2002, 11, :o2, 1036292400 - tz.transition 2003, 2, :o1, 1045360800 - tz.transition 2003, 10, :o2, 1066532400 - tz.transition 2004, 2, :o1, 1076810400 - tz.transition 2004, 11, :o2, 1099364400 - tz.transition 2005, 2, :o1, 1108864800 - tz.transition 2005, 10, :o2, 1129431600 - tz.transition 2006, 2, :o1, 1140314400 - tz.transition 2006, 11, :o2, 1162695600 - tz.transition 2007, 2, :o1, 1172368800 - tz.transition 2007, 10, :o2, 1192330800 - tz.transition 2008, 2, :o1, 1203213600 - tz.transition 2008, 10, :o2, 1224385200 - tz.transition 2009, 2, :o1, 1234663200 - tz.transition 2009, 10, :o2, 1255834800 - tz.transition 2010, 2, :o1, 1266717600 - tz.transition 2010, 10, :o2, 1287284400 - tz.transition 2011, 2, :o1, 1298167200 - tz.transition 2011, 10, :o2, 1318734000 - tz.transition 2012, 2, :o1, 1330221600 - tz.transition 2012, 10, :o2, 1350788400 - tz.transition 2013, 2, :o1, 1361066400 - tz.transition 2013, 10, :o2, 1382238000 - tz.transition 2014, 2, :o1, 1392516000 - tz.transition 2014, 10, :o2, 1413687600 - tz.transition 2015, 2, :o1, 1424570400 - tz.transition 2015, 10, :o2, 1445137200 - tz.transition 2016, 2, :o1, 1456020000 - tz.transition 2016, 10, :o2, 1476586800 - tz.transition 2017, 2, :o1, 1487469600 - tz.transition 2017, 10, :o2, 1508036400 - tz.transition 2018, 2, :o1, 1518919200 - tz.transition 2018, 10, :o2, 1540090800 - tz.transition 2019, 2, :o1, 1550368800 - tz.transition 2019, 10, :o2, 1571540400 - tz.transition 2020, 2, :o1, 1581818400 - tz.transition 2020, 10, :o2, 1602990000 - tz.transition 2021, 2, :o1, 1613872800 - tz.transition 2021, 10, :o2, 1634439600 - tz.transition 2022, 2, :o1, 1645322400 - tz.transition 2022, 10, :o2, 1665889200 - tz.transition 2023, 2, :o1, 1677376800 - tz.transition 2023, 10, :o2, 1697338800 - tz.transition 2024, 2, :o1, 1708221600 - tz.transition 2024, 10, :o2, 1729393200 - tz.transition 2025, 2, :o1, 1739671200 - tz.transition 2025, 10, :o2, 1760842800 - tz.transition 2026, 2, :o1, 1771725600 - tz.transition 2026, 10, :o2, 1792292400 - tz.transition 2027, 2, :o1, 1803175200 - tz.transition 2027, 10, :o2, 1823742000 - tz.transition 2028, 2, :o1, 1834624800 - tz.transition 2028, 10, :o2, 1855191600 - tz.transition 2029, 2, :o1, 1866074400 - tz.transition 2029, 10, :o2, 1887246000 - tz.transition 2030, 2, :o1, 1897524000 - tz.transition 2030, 10, :o2, 1918695600 - tz.transition 2031, 2, :o1, 1928973600 - tz.transition 2031, 10, :o2, 1950145200 - tz.transition 2032, 2, :o1, 1960423200 - tz.transition 2032, 10, :o2, 1981594800 - tz.transition 2033, 2, :o1, 1992477600 - tz.transition 2033, 10, :o2, 2013044400 - tz.transition 2034, 2, :o1, 2024532000 - tz.transition 2034, 10, :o2, 2044494000 - tz.transition 2035, 2, :o1, 2055376800 - tz.transition 2035, 10, :o2, 2076548400 - tz.transition 2036, 2, :o1, 2086826400 - tz.transition 2036, 10, :o2, 2107998000 - tz.transition 2037, 2, :o1, 2118880800 - tz.transition 2037, 10, :o2, 2139447600 - tz.transition 2038, 2, :o1, 29585707, 12 - tz.transition 2038, 10, :o2, 19725709, 8 - tz.transition 2039, 2, :o1, 29590075, 12 - tz.transition 2039, 10, :o2, 19728621, 8 - tz.transition 2040, 2, :o1, 29594443, 12 - tz.transition 2040, 10, :o2, 19731589, 8 - tz.transition 2041, 2, :o1, 29598811, 12 - tz.transition 2041, 10, :o2, 19734501, 8 - tz.transition 2042, 2, :o1, 29603179, 12 - tz.transition 2042, 10, :o2, 19737413, 8 - tz.transition 2043, 2, :o1, 29607547, 12 - tz.transition 2043, 10, :o2, 19740325, 8 - tz.transition 2044, 2, :o1, 29611999, 12 - tz.transition 2044, 10, :o2, 19743237, 8 - tz.transition 2045, 2, :o1, 29616367, 12 - tz.transition 2045, 10, :o2, 19746149, 8 - tz.transition 2046, 2, :o1, 29620735, 12 - tz.transition 2046, 10, :o2, 19749117, 8 - tz.transition 2047, 2, :o1, 29625103, 12 - tz.transition 2047, 10, :o2, 19752029, 8 - tz.transition 2048, 2, :o1, 29629471, 12 - tz.transition 2048, 10, :o2, 19754941, 8 - tz.transition 2049, 2, :o1, 29633923, 12 - tz.transition 2049, 10, :o2, 19757853, 8 - tz.transition 2050, 2, :o1, 29638291, 12 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/St_Johns.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/St_Johns.rb deleted file mode 100644 index e4a3599..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/St_Johns.rb +++ /dev/null @@ -1,288 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module St_Johns - include TimezoneDefinition - - timezone 'America/St_Johns' do |tz| - tz.offset :o0, -12652, 0, :LMT - tz.offset :o1, -12652, 0, :NST - tz.offset :o2, -12652, 3600, :NDT - tz.offset :o3, -12600, 0, :NST - tz.offset :o4, -12600, 3600, :NDT - tz.offset :o5, -12600, 3600, :NWT - tz.offset :o6, -12600, 3600, :NPT - tz.offset :o7, -12600, 7200, :NDDT - - tz.transition 1884, 1, :o1, 52038215563, 21600 - tz.transition 1917, 4, :o2, 52300657363, 21600 - tz.transition 1917, 9, :o1, 52304155663, 21600 - tz.transition 1918, 4, :o2, 52308670963, 21600 - tz.transition 1918, 10, :o1, 52312990063, 21600 - tz.transition 1919, 5, :o2, 52317027463, 21600 - tz.transition 1919, 8, :o1, 52319164963, 21600 - tz.transition 1920, 5, :o2, 52324868263, 21600 - tz.transition 1920, 11, :o1, 52328798563, 21600 - tz.transition 1921, 5, :o2, 52332730663, 21600 - tz.transition 1921, 10, :o1, 52336660963, 21600 - tz.transition 1922, 5, :o2, 52340744263, 21600 - tz.transition 1922, 10, :o1, 52344523363, 21600 - tz.transition 1923, 5, :o2, 52348606663, 21600 - tz.transition 1923, 10, :o1, 52352385763, 21600 - tz.transition 1924, 5, :o2, 52356469063, 21600 - tz.transition 1924, 10, :o1, 52360248163, 21600 - tz.transition 1925, 5, :o2, 52364331463, 21600 - tz.transition 1925, 10, :o1, 52368110563, 21600 - tz.transition 1926, 5, :o2, 52372193863, 21600 - tz.transition 1926, 11, :o1, 52376124163, 21600 - tz.transition 1927, 5, :o2, 52380056263, 21600 - tz.transition 1927, 10, :o1, 52383986563, 21600 - tz.transition 1928, 5, :o2, 52388069863, 21600 - tz.transition 1928, 10, :o1, 52391848963, 21600 - tz.transition 1929, 5, :o2, 52395932263, 21600 - tz.transition 1929, 10, :o1, 52399711363, 21600 - tz.transition 1930, 5, :o2, 52403794663, 21600 - tz.transition 1930, 10, :o1, 52407573763, 21600 - tz.transition 1931, 5, :o2, 52411657063, 21600 - tz.transition 1931, 10, :o1, 52415436163, 21600 - tz.transition 1932, 5, :o2, 52419519463, 21600 - tz.transition 1932, 10, :o1, 52423449763, 21600 - tz.transition 1933, 5, :o2, 52427533063, 21600 - tz.transition 1933, 10, :o1, 52431312163, 21600 - tz.transition 1934, 5, :o2, 52435395463, 21600 - tz.transition 1934, 10, :o1, 52439174563, 21600 - tz.transition 1935, 3, :o3, 52442459563, 21600 - tz.transition 1935, 5, :o4, 116540573, 48 - tz.transition 1935, 10, :o3, 38849657, 16 - tz.transition 1936, 5, :o4, 116558383, 48 - tz.transition 1936, 10, :o3, 116565437, 48 - tz.transition 1937, 5, :o4, 116575855, 48 - tz.transition 1937, 10, :o3, 116582909, 48 - tz.transition 1938, 5, :o4, 116593327, 48 - tz.transition 1938, 10, :o3, 116600381, 48 - tz.transition 1939, 5, :o4, 116611135, 48 - tz.transition 1939, 10, :o3, 116617853, 48 - tz.transition 1940, 5, :o4, 116628607, 48 - tz.transition 1940, 10, :o3, 116635661, 48 - tz.transition 1941, 5, :o4, 116646079, 48 - tz.transition 1941, 10, :o3, 116653133, 48 - tz.transition 1942, 5, :o5, 116663551, 48 - tz.transition 1945, 8, :o6, 58360379, 24 - tz.transition 1945, 9, :o3, 38907659, 16 - tz.transition 1946, 5, :o4, 116733731, 48 - tz.transition 1946, 10, :o3, 38913595, 16 - tz.transition 1947, 5, :o4, 116751203, 48 - tz.transition 1947, 10, :o3, 38919419, 16 - tz.transition 1948, 5, :o4, 116768675, 48 - tz.transition 1948, 10, :o3, 38925243, 16 - tz.transition 1949, 5, :o4, 116786147, 48 - tz.transition 1949, 10, :o3, 38931067, 16 - tz.transition 1950, 5, :o4, 116803955, 48 - tz.transition 1950, 10, :o3, 38937003, 16 - tz.transition 1951, 4, :o4, 116820755, 48 - tz.transition 1951, 9, :o3, 38942715, 16 - tz.transition 1952, 4, :o4, 116838227, 48 - tz.transition 1952, 9, :o3, 38948539, 16 - tz.transition 1953, 4, :o4, 116855699, 48 - tz.transition 1953, 9, :o3, 38954363, 16 - tz.transition 1954, 4, :o4, 116873171, 48 - tz.transition 1954, 9, :o3, 38960187, 16 - tz.transition 1955, 4, :o4, 116890643, 48 - tz.transition 1955, 9, :o3, 38966011, 16 - tz.transition 1956, 4, :o4, 116908451, 48 - tz.transition 1956, 9, :o3, 38971947, 16 - tz.transition 1957, 4, :o4, 116925923, 48 - tz.transition 1957, 9, :o3, 38977771, 16 - tz.transition 1958, 4, :o4, 116943395, 48 - tz.transition 1958, 9, :o3, 38983595, 16 - tz.transition 1959, 4, :o4, 116960867, 48 - tz.transition 1959, 9, :o3, 38989419, 16 - tz.transition 1960, 4, :o4, 116978339, 48 - tz.transition 1960, 10, :o3, 38995803, 16 - tz.transition 1961, 4, :o4, 116996147, 48 - tz.transition 1961, 10, :o3, 39001627, 16 - tz.transition 1962, 4, :o4, 117013619, 48 - tz.transition 1962, 10, :o3, 39007451, 16 - tz.transition 1963, 4, :o4, 117031091, 48 - tz.transition 1963, 10, :o3, 39013275, 16 - tz.transition 1964, 4, :o4, 117048563, 48 - tz.transition 1964, 10, :o3, 39019099, 16 - tz.transition 1965, 4, :o4, 117066035, 48 - tz.transition 1965, 10, :o3, 39025035, 16 - tz.transition 1966, 4, :o4, 117083507, 48 - tz.transition 1966, 10, :o3, 39030859, 16 - tz.transition 1967, 4, :o4, 117101315, 48 - tz.transition 1967, 10, :o3, 39036683, 16 - tz.transition 1968, 4, :o4, 117118787, 48 - tz.transition 1968, 10, :o3, 39042507, 16 - tz.transition 1969, 4, :o4, 117136259, 48 - tz.transition 1969, 10, :o3, 39048331, 16 - tz.transition 1970, 4, :o4, 9955800 - tz.transition 1970, 10, :o3, 25677000 - tz.transition 1971, 4, :o4, 41405400 - tz.transition 1971, 10, :o3, 57731400 - tz.transition 1972, 4, :o4, 73459800 - tz.transition 1972, 10, :o3, 89181000 - tz.transition 1973, 4, :o4, 104909400 - tz.transition 1973, 10, :o3, 120630600 - tz.transition 1974, 4, :o4, 136359000 - tz.transition 1974, 10, :o3, 152080200 - tz.transition 1975, 4, :o4, 167808600 - tz.transition 1975, 10, :o3, 183529800 - tz.transition 1976, 4, :o4, 199258200 - tz.transition 1976, 10, :o3, 215584200 - tz.transition 1977, 4, :o4, 230707800 - tz.transition 1977, 10, :o3, 247033800 - tz.transition 1978, 4, :o4, 262762200 - tz.transition 1978, 10, :o3, 278483400 - tz.transition 1979, 4, :o4, 294211800 - tz.transition 1979, 10, :o3, 309933000 - tz.transition 1980, 4, :o4, 325661400 - tz.transition 1980, 10, :o3, 341382600 - tz.transition 1981, 4, :o4, 357111000 - tz.transition 1981, 10, :o3, 372832200 - tz.transition 1982, 4, :o4, 388560600 - tz.transition 1982, 10, :o3, 404886600 - tz.transition 1983, 4, :o4, 420010200 - tz.transition 1983, 10, :o3, 436336200 - tz.transition 1984, 4, :o4, 452064600 - tz.transition 1984, 10, :o3, 467785800 - tz.transition 1985, 4, :o4, 483514200 - tz.transition 1985, 10, :o3, 499235400 - tz.transition 1986, 4, :o4, 514963800 - tz.transition 1986, 10, :o3, 530685000 - tz.transition 1987, 4, :o4, 544591860 - tz.transition 1987, 10, :o3, 562127460 - tz.transition 1988, 4, :o7, 576041460 - tz.transition 1988, 10, :o3, 594178260 - tz.transition 1989, 4, :o4, 607491060 - tz.transition 1989, 10, :o3, 625631460 - tz.transition 1990, 4, :o4, 638940660 - tz.transition 1990, 10, :o3, 657081060 - tz.transition 1991, 4, :o4, 670995060 - tz.transition 1991, 10, :o3, 688530660 - tz.transition 1992, 4, :o4, 702444660 - tz.transition 1992, 10, :o3, 719980260 - tz.transition 1993, 4, :o4, 733894260 - tz.transition 1993, 10, :o3, 752034660 - tz.transition 1994, 4, :o4, 765343860 - tz.transition 1994, 10, :o3, 783484260 - tz.transition 1995, 4, :o4, 796793460 - tz.transition 1995, 10, :o3, 814933860 - tz.transition 1996, 4, :o4, 828847860 - tz.transition 1996, 10, :o3, 846383460 - tz.transition 1997, 4, :o4, 860297460 - tz.transition 1997, 10, :o3, 877833060 - tz.transition 1998, 4, :o4, 891747060 - tz.transition 1998, 10, :o3, 909282660 - tz.transition 1999, 4, :o4, 923196660 - tz.transition 1999, 10, :o3, 941337060 - tz.transition 2000, 4, :o4, 954646260 - tz.transition 2000, 10, :o3, 972786660 - tz.transition 2001, 4, :o4, 986095860 - tz.transition 2001, 10, :o3, 1004236260 - tz.transition 2002, 4, :o4, 1018150260 - tz.transition 2002, 10, :o3, 1035685860 - tz.transition 2003, 4, :o4, 1049599860 - tz.transition 2003, 10, :o3, 1067135460 - tz.transition 2004, 4, :o4, 1081049460 - tz.transition 2004, 10, :o3, 1099189860 - tz.transition 2005, 4, :o4, 1112499060 - tz.transition 2005, 10, :o3, 1130639460 - tz.transition 2006, 4, :o4, 1143948660 - tz.transition 2006, 10, :o3, 1162089060 - tz.transition 2007, 3, :o4, 1173583860 - tz.transition 2007, 11, :o3, 1194143460 - tz.transition 2008, 3, :o4, 1205033460 - tz.transition 2008, 11, :o3, 1225593060 - tz.transition 2009, 3, :o4, 1236483060 - tz.transition 2009, 11, :o3, 1257042660 - tz.transition 2010, 3, :o4, 1268537460 - tz.transition 2010, 11, :o3, 1289097060 - tz.transition 2011, 3, :o4, 1299987060 - tz.transition 2011, 11, :o3, 1320546660 - tz.transition 2012, 3, :o4, 1331436660 - tz.transition 2012, 11, :o3, 1351996260 - tz.transition 2013, 3, :o4, 1362886260 - tz.transition 2013, 11, :o3, 1383445860 - tz.transition 2014, 3, :o4, 1394335860 - tz.transition 2014, 11, :o3, 1414895460 - tz.transition 2015, 3, :o4, 1425785460 - tz.transition 2015, 11, :o3, 1446345060 - tz.transition 2016, 3, :o4, 1457839860 - tz.transition 2016, 11, :o3, 1478399460 - tz.transition 2017, 3, :o4, 1489289460 - tz.transition 2017, 11, :o3, 1509849060 - tz.transition 2018, 3, :o4, 1520739060 - tz.transition 2018, 11, :o3, 1541298660 - tz.transition 2019, 3, :o4, 1552188660 - tz.transition 2019, 11, :o3, 1572748260 - tz.transition 2020, 3, :o4, 1583638260 - tz.transition 2020, 11, :o3, 1604197860 - tz.transition 2021, 3, :o4, 1615692660 - tz.transition 2021, 11, :o3, 1636252260 - tz.transition 2022, 3, :o4, 1647142260 - tz.transition 2022, 11, :o3, 1667701860 - tz.transition 2023, 3, :o4, 1678591860 - tz.transition 2023, 11, :o3, 1699151460 - tz.transition 2024, 3, :o4, 1710041460 - tz.transition 2024, 11, :o3, 1730601060 - tz.transition 2025, 3, :o4, 1741491060 - tz.transition 2025, 11, :o3, 1762050660 - tz.transition 2026, 3, :o4, 1772940660 - tz.transition 2026, 11, :o3, 1793500260 - tz.transition 2027, 3, :o4, 1804995060 - tz.transition 2027, 11, :o3, 1825554660 - tz.transition 2028, 3, :o4, 1836444660 - tz.transition 2028, 11, :o3, 1857004260 - tz.transition 2029, 3, :o4, 1867894260 - tz.transition 2029, 11, :o3, 1888453860 - tz.transition 2030, 3, :o4, 1899343860 - tz.transition 2030, 11, :o3, 1919903460 - tz.transition 2031, 3, :o4, 1930793460 - tz.transition 2031, 11, :o3, 1951353060 - tz.transition 2032, 3, :o4, 1962847860 - tz.transition 2032, 11, :o3, 1983407460 - tz.transition 2033, 3, :o4, 1994297460 - tz.transition 2033, 11, :o3, 2014857060 - tz.transition 2034, 3, :o4, 2025747060 - tz.transition 2034, 11, :o3, 2046306660 - tz.transition 2035, 3, :o4, 2057196660 - tz.transition 2035, 11, :o3, 2077756260 - tz.transition 2036, 3, :o4, 2088646260 - tz.transition 2036, 11, :o3, 2109205860 - tz.transition 2037, 3, :o4, 2120095860 - tz.transition 2037, 11, :o3, 2140655460 - tz.transition 2038, 3, :o4, 3550315171, 1440 - tz.transition 2038, 11, :o3, 3550657831, 1440 - tz.transition 2039, 3, :o4, 3550839331, 1440 - tz.transition 2039, 11, :o3, 3551181991, 1440 - tz.transition 2040, 3, :o4, 3551363491, 1440 - tz.transition 2040, 11, :o3, 3551706151, 1440 - tz.transition 2041, 3, :o4, 3551887651, 1440 - tz.transition 2041, 11, :o3, 3552230311, 1440 - tz.transition 2042, 3, :o4, 3552411811, 1440 - tz.transition 2042, 11, :o3, 3552754471, 1440 - tz.transition 2043, 3, :o4, 3552935971, 1440 - tz.transition 2043, 11, :o3, 3553278631, 1440 - tz.transition 2044, 3, :o4, 3553470211, 1440 - tz.transition 2044, 11, :o3, 3553812871, 1440 - tz.transition 2045, 3, :o4, 3553994371, 1440 - tz.transition 2045, 11, :o3, 3554337031, 1440 - tz.transition 2046, 3, :o4, 3554518531, 1440 - tz.transition 2046, 11, :o3, 3554861191, 1440 - tz.transition 2047, 3, :o4, 3555042691, 1440 - tz.transition 2047, 11, :o3, 3555385351, 1440 - tz.transition 2048, 3, :o4, 3555566851, 1440 - tz.transition 2048, 11, :o3, 3555909511, 1440 - tz.transition 2049, 3, :o4, 3556101091, 1440 - tz.transition 2049, 11, :o3, 3556443751, 1440 - tz.transition 2050, 3, :o4, 3556625251, 1440 - tz.transition 2050, 11, :o3, 3556967911, 1440 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Tijuana.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Tijuana.rb deleted file mode 100644 index 423059d..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Tijuana.rb +++ /dev/null @@ -1,196 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module America - module Tijuana - include TimezoneDefinition - - timezone 'America/Tijuana' do |tz| - tz.offset :o0, -28084, 0, :LMT - tz.offset :o1, -25200, 0, :MST - tz.offset :o2, -28800, 0, :PST - tz.offset :o3, -28800, 3600, :PDT - tz.offset :o4, -28800, 3600, :PWT - tz.offset :o5, -28800, 3600, :PPT - - tz.transition 1922, 1, :o1, 14538335, 6 - tz.transition 1924, 1, :o2, 58170859, 24 - tz.transition 1927, 6, :o1, 58201027, 24 - tz.transition 1930, 11, :o2, 58231099, 24 - tz.transition 1931, 4, :o3, 14558597, 6 - tz.transition 1931, 9, :o2, 58238755, 24 - tz.transition 1942, 4, :o4, 14582843, 6 - tz.transition 1945, 8, :o5, 58360379, 24 - tz.transition 1945, 11, :o2, 58362523, 24 - tz.transition 1948, 4, :o3, 14595881, 6 - tz.transition 1949, 1, :o2, 58390339, 24 - tz.transition 1954, 4, :o3, 29218295, 12 - tz.transition 1954, 9, :o2, 19480095, 8 - tz.transition 1955, 4, :o3, 29222663, 12 - tz.transition 1955, 9, :o2, 19483007, 8 - tz.transition 1956, 4, :o3, 29227115, 12 - tz.transition 1956, 9, :o2, 19485975, 8 - tz.transition 1957, 4, :o3, 29231483, 12 - tz.transition 1957, 9, :o2, 19488887, 8 - tz.transition 1958, 4, :o3, 29235851, 12 - tz.transition 1958, 9, :o2, 19491799, 8 - tz.transition 1959, 4, :o3, 29240219, 12 - tz.transition 1959, 9, :o2, 19494711, 8 - tz.transition 1960, 4, :o3, 29244587, 12 - tz.transition 1960, 9, :o2, 19497623, 8 - tz.transition 1976, 4, :o3, 199274400 - tz.transition 1976, 10, :o2, 215600400 - tz.transition 1977, 4, :o3, 230724000 - tz.transition 1977, 10, :o2, 247050000 - tz.transition 1978, 4, :o3, 262778400 - tz.transition 1978, 10, :o2, 278499600 - tz.transition 1979, 4, :o3, 294228000 - tz.transition 1979, 10, :o2, 309949200 - tz.transition 1980, 4, :o3, 325677600 - tz.transition 1980, 10, :o2, 341398800 - tz.transition 1981, 4, :o3, 357127200 - tz.transition 1981, 10, :o2, 372848400 - tz.transition 1982, 4, :o3, 388576800 - tz.transition 1982, 10, :o2, 404902800 - tz.transition 1983, 4, :o3, 420026400 - tz.transition 1983, 10, :o2, 436352400 - tz.transition 1984, 4, :o3, 452080800 - tz.transition 1984, 10, :o2, 467802000 - tz.transition 1985, 4, :o3, 483530400 - tz.transition 1985, 10, :o2, 499251600 - tz.transition 1986, 4, :o3, 514980000 - tz.transition 1986, 10, :o2, 530701200 - tz.transition 1987, 4, :o3, 544615200 - tz.transition 1987, 10, :o2, 562150800 - tz.transition 1988, 4, :o3, 576064800 - tz.transition 1988, 10, :o2, 594205200 - tz.transition 1989, 4, :o3, 607514400 - tz.transition 1989, 10, :o2, 625654800 - tz.transition 1990, 4, :o3, 638964000 - tz.transition 1990, 10, :o2, 657104400 - tz.transition 1991, 4, :o3, 671018400 - tz.transition 1991, 10, :o2, 688554000 - tz.transition 1992, 4, :o3, 702468000 - tz.transition 1992, 10, :o2, 720003600 - tz.transition 1993, 4, :o3, 733917600 - tz.transition 1993, 10, :o2, 752058000 - tz.transition 1994, 4, :o3, 765367200 - tz.transition 1994, 10, :o2, 783507600 - tz.transition 1995, 4, :o3, 796816800 - tz.transition 1995, 10, :o2, 814957200 - tz.transition 1996, 4, :o3, 828871200 - tz.transition 1996, 10, :o2, 846406800 - tz.transition 1997, 4, :o3, 860320800 - tz.transition 1997, 10, :o2, 877856400 - tz.transition 1998, 4, :o3, 891770400 - tz.transition 1998, 10, :o2, 909306000 - tz.transition 1999, 4, :o3, 923220000 - tz.transition 1999, 10, :o2, 941360400 - tz.transition 2000, 4, :o3, 954669600 - tz.transition 2000, 10, :o2, 972810000 - tz.transition 2001, 4, :o3, 986119200 - tz.transition 2001, 10, :o2, 1004259600 - tz.transition 2002, 4, :o3, 1018173600 - tz.transition 2002, 10, :o2, 1035709200 - tz.transition 2003, 4, :o3, 1049623200 - tz.transition 2003, 10, :o2, 1067158800 - tz.transition 2004, 4, :o3, 1081072800 - tz.transition 2004, 10, :o2, 1099213200 - tz.transition 2005, 4, :o3, 1112522400 - tz.transition 2005, 10, :o2, 1130662800 - tz.transition 2006, 4, :o3, 1143972000 - tz.transition 2006, 10, :o2, 1162112400 - tz.transition 2007, 4, :o3, 1175421600 - tz.transition 2007, 10, :o2, 1193562000 - tz.transition 2008, 4, :o3, 1207476000 - tz.transition 2008, 10, :o2, 1225011600 - tz.transition 2009, 4, :o3, 1238925600 - tz.transition 2009, 10, :o2, 1256461200 - tz.transition 2010, 4, :o3, 1270375200 - tz.transition 2010, 10, :o2, 1288515600 - tz.transition 2011, 4, :o3, 1301824800 - tz.transition 2011, 10, :o2, 1319965200 - tz.transition 2012, 4, :o3, 1333274400 - tz.transition 2012, 10, :o2, 1351414800 - tz.transition 2013, 4, :o3, 1365328800 - tz.transition 2013, 10, :o2, 1382864400 - tz.transition 2014, 4, :o3, 1396778400 - tz.transition 2014, 10, :o2, 1414314000 - tz.transition 2015, 4, :o3, 1428228000 - tz.transition 2015, 10, :o2, 1445763600 - tz.transition 2016, 4, :o3, 1459677600 - tz.transition 2016, 10, :o2, 1477818000 - tz.transition 2017, 4, :o3, 1491127200 - tz.transition 2017, 10, :o2, 1509267600 - tz.transition 2018, 4, :o3, 1522576800 - tz.transition 2018, 10, :o2, 1540717200 - tz.transition 2019, 4, :o3, 1554631200 - tz.transition 2019, 10, :o2, 1572166800 - tz.transition 2020, 4, :o3, 1586080800 - tz.transition 2020, 10, :o2, 1603616400 - tz.transition 2021, 4, :o3, 1617530400 - tz.transition 2021, 10, :o2, 1635670800 - tz.transition 2022, 4, :o3, 1648980000 - tz.transition 2022, 10, :o2, 1667120400 - tz.transition 2023, 4, :o3, 1680429600 - tz.transition 2023, 10, :o2, 1698570000 - tz.transition 2024, 4, :o3, 1712484000 - tz.transition 2024, 10, :o2, 1730019600 - tz.transition 2025, 4, :o3, 1743933600 - tz.transition 2025, 10, :o2, 1761469200 - tz.transition 2026, 4, :o3, 1775383200 - tz.transition 2026, 10, :o2, 1792918800 - tz.transition 2027, 4, :o3, 1806832800 - tz.transition 2027, 10, :o2, 1824973200 - tz.transition 2028, 4, :o3, 1838282400 - tz.transition 2028, 10, :o2, 1856422800 - tz.transition 2029, 4, :o3, 1869732000 - tz.transition 2029, 10, :o2, 1887872400 - tz.transition 2030, 4, :o3, 1901786400 - tz.transition 2030, 10, :o2, 1919322000 - tz.transition 2031, 4, :o3, 1933236000 - tz.transition 2031, 10, :o2, 1950771600 - tz.transition 2032, 4, :o3, 1964685600 - tz.transition 2032, 10, :o2, 1982826000 - tz.transition 2033, 4, :o3, 1996135200 - tz.transition 2033, 10, :o2, 2014275600 - tz.transition 2034, 4, :o3, 2027584800 - tz.transition 2034, 10, :o2, 2045725200 - tz.transition 2035, 4, :o3, 2059034400 - tz.transition 2035, 10, :o2, 2077174800 - tz.transition 2036, 4, :o3, 2091088800 - tz.transition 2036, 10, :o2, 2108624400 - tz.transition 2037, 4, :o3, 2122538400 - tz.transition 2037, 10, :o2, 2140074000 - tz.transition 2038, 4, :o3, 29586215, 12 - tz.transition 2038, 10, :o2, 19725823, 8 - tz.transition 2039, 4, :o3, 29590583, 12 - tz.transition 2039, 10, :o2, 19728735, 8 - tz.transition 2040, 4, :o3, 29594951, 12 - tz.transition 2040, 10, :o2, 19731647, 8 - tz.transition 2041, 4, :o3, 29599403, 12 - tz.transition 2041, 10, :o2, 19734559, 8 - tz.transition 2042, 4, :o3, 29603771, 12 - tz.transition 2042, 10, :o2, 19737471, 8 - tz.transition 2043, 4, :o3, 29608139, 12 - tz.transition 2043, 10, :o2, 19740383, 8 - tz.transition 2044, 4, :o3, 29612507, 12 - tz.transition 2044, 10, :o2, 19743351, 8 - tz.transition 2045, 4, :o3, 29616875, 12 - tz.transition 2045, 10, :o2, 19746263, 8 - tz.transition 2046, 4, :o3, 29621243, 12 - tz.transition 2046, 10, :o2, 19749175, 8 - tz.transition 2047, 4, :o3, 29625695, 12 - tz.transition 2047, 10, :o2, 19752087, 8 - tz.transition 2048, 4, :o3, 29630063, 12 - tz.transition 2048, 10, :o2, 19754999, 8 - tz.transition 2049, 4, :o3, 29634431, 12 - tz.transition 2049, 10, :o2, 19757967, 8 - tz.transition 2050, 4, :o3, 29638799, 12 - tz.transition 2050, 10, :o2, 19760879, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Almaty.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Almaty.rb deleted file mode 100644 index 9ee1897..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Almaty.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Almaty - include TimezoneDefinition - - timezone 'Asia/Almaty' do |tz| - tz.offset :o0, 18468, 0, :LMT - tz.offset :o1, 18000, 0, :ALMT - tz.offset :o2, 21600, 0, :ALMT - tz.offset :o3, 21600, 3600, :ALMST - - tz.transition 1924, 5, :o1, 1939125829, 800 - tz.transition 1930, 6, :o2, 58227559, 24 - tz.transition 1981, 3, :o3, 354909600 - tz.transition 1981, 9, :o2, 370717200 - tz.transition 1982, 3, :o3, 386445600 - tz.transition 1982, 9, :o2, 402253200 - tz.transition 1983, 3, :o3, 417981600 - tz.transition 1983, 9, :o2, 433789200 - tz.transition 1984, 3, :o3, 449604000 - tz.transition 1984, 9, :o2, 465336000 - tz.transition 1985, 3, :o3, 481060800 - tz.transition 1985, 9, :o2, 496785600 - tz.transition 1986, 3, :o3, 512510400 - tz.transition 1986, 9, :o2, 528235200 - tz.transition 1987, 3, :o3, 543960000 - tz.transition 1987, 9, :o2, 559684800 - tz.transition 1988, 3, :o3, 575409600 - tz.transition 1988, 9, :o2, 591134400 - tz.transition 1989, 3, :o3, 606859200 - tz.transition 1989, 9, :o2, 622584000 - tz.transition 1990, 3, :o3, 638308800 - tz.transition 1990, 9, :o2, 654638400 - tz.transition 1992, 3, :o3, 701802000 - tz.transition 1992, 9, :o2, 717523200 - tz.transition 1993, 3, :o3, 733262400 - tz.transition 1993, 9, :o2, 748987200 - tz.transition 1994, 3, :o3, 764712000 - tz.transition 1994, 9, :o2, 780436800 - tz.transition 1995, 3, :o3, 796161600 - tz.transition 1995, 9, :o2, 811886400 - tz.transition 1996, 3, :o3, 828216000 - tz.transition 1996, 10, :o2, 846360000 - tz.transition 1997, 3, :o3, 859665600 - tz.transition 1997, 10, :o2, 877809600 - tz.transition 1998, 3, :o3, 891115200 - tz.transition 1998, 10, :o2, 909259200 - tz.transition 1999, 3, :o3, 922564800 - tz.transition 1999, 10, :o2, 941313600 - tz.transition 2000, 3, :o3, 954014400 - tz.transition 2000, 10, :o2, 972763200 - tz.transition 2001, 3, :o3, 985464000 - tz.transition 2001, 10, :o2, 1004212800 - tz.transition 2002, 3, :o3, 1017518400 - tz.transition 2002, 10, :o2, 1035662400 - tz.transition 2003, 3, :o3, 1048968000 - tz.transition 2003, 10, :o2, 1067112000 - tz.transition 2004, 3, :o3, 1080417600 - tz.transition 2004, 10, :o2, 1099166400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baghdad.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baghdad.rb deleted file mode 100644 index 774dca1..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baghdad.rb +++ /dev/null @@ -1,73 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Baghdad - include TimezoneDefinition - - timezone 'Asia/Baghdad' do |tz| - tz.offset :o0, 10660, 0, :LMT - tz.offset :o1, 10656, 0, :BMT - tz.offset :o2, 10800, 0, :AST - tz.offset :o3, 10800, 3600, :ADT - - tz.transition 1889, 12, :o1, 10417111387, 4320 - tz.transition 1917, 12, :o2, 726478313, 300 - tz.transition 1982, 4, :o3, 389048400 - tz.transition 1982, 9, :o2, 402264000 - tz.transition 1983, 3, :o3, 417906000 - tz.transition 1983, 9, :o2, 433800000 - tz.transition 1984, 3, :o3, 449614800 - tz.transition 1984, 9, :o2, 465422400 - tz.transition 1985, 3, :o3, 481150800 - tz.transition 1985, 9, :o2, 496792800 - tz.transition 1986, 3, :o3, 512517600 - tz.transition 1986, 9, :o2, 528242400 - tz.transition 1987, 3, :o3, 543967200 - tz.transition 1987, 9, :o2, 559692000 - tz.transition 1988, 3, :o3, 575416800 - tz.transition 1988, 9, :o2, 591141600 - tz.transition 1989, 3, :o3, 606866400 - tz.transition 1989, 9, :o2, 622591200 - tz.transition 1990, 3, :o3, 638316000 - tz.transition 1990, 9, :o2, 654645600 - tz.transition 1991, 4, :o3, 670464000 - tz.transition 1991, 10, :o2, 686275200 - tz.transition 1992, 4, :o3, 702086400 - tz.transition 1992, 10, :o2, 717897600 - tz.transition 1993, 4, :o3, 733622400 - tz.transition 1993, 10, :o2, 749433600 - tz.transition 1994, 4, :o3, 765158400 - tz.transition 1994, 10, :o2, 780969600 - tz.transition 1995, 4, :o3, 796694400 - tz.transition 1995, 10, :o2, 812505600 - tz.transition 1996, 4, :o3, 828316800 - tz.transition 1996, 10, :o2, 844128000 - tz.transition 1997, 4, :o3, 859852800 - tz.transition 1997, 10, :o2, 875664000 - tz.transition 1998, 4, :o3, 891388800 - tz.transition 1998, 10, :o2, 907200000 - tz.transition 1999, 4, :o3, 922924800 - tz.transition 1999, 10, :o2, 938736000 - tz.transition 2000, 4, :o3, 954547200 - tz.transition 2000, 10, :o2, 970358400 - tz.transition 2001, 4, :o3, 986083200 - tz.transition 2001, 10, :o2, 1001894400 - tz.transition 2002, 4, :o3, 1017619200 - tz.transition 2002, 10, :o2, 1033430400 - tz.transition 2003, 4, :o3, 1049155200 - tz.transition 2003, 10, :o2, 1064966400 - tz.transition 2004, 4, :o3, 1080777600 - tz.transition 2004, 10, :o2, 1096588800 - tz.transition 2005, 4, :o3, 1112313600 - tz.transition 2005, 10, :o2, 1128124800 - tz.transition 2006, 4, :o3, 1143849600 - tz.transition 2006, 10, :o2, 1159660800 - tz.transition 2007, 4, :o3, 1175385600 - tz.transition 2007, 10, :o2, 1191196800 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baku.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baku.rb deleted file mode 100644 index e86340e..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baku.rb +++ /dev/null @@ -1,161 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Baku - include TimezoneDefinition - - timezone 'Asia/Baku' do |tz| - tz.offset :o0, 11964, 0, :LMT - tz.offset :o1, 10800, 0, :BAKT - tz.offset :o2, 14400, 0, :BAKT - tz.offset :o3, 14400, 3600, :BAKST - tz.offset :o4, 10800, 3600, :BAKST - tz.offset :o5, 10800, 3600, :AZST - tz.offset :o6, 10800, 0, :AZT - tz.offset :o7, 14400, 0, :AZT - tz.offset :o8, 14400, 3600, :AZST - - tz.transition 1924, 5, :o1, 17452133003, 7200 - tz.transition 1957, 2, :o2, 19487187, 8 - tz.transition 1981, 3, :o3, 354916800 - tz.transition 1981, 9, :o2, 370724400 - tz.transition 1982, 3, :o3, 386452800 - tz.transition 1982, 9, :o2, 402260400 - tz.transition 1983, 3, :o3, 417988800 - tz.transition 1983, 9, :o2, 433796400 - tz.transition 1984, 3, :o3, 449611200 - tz.transition 1984, 9, :o2, 465343200 - tz.transition 1985, 3, :o3, 481068000 - tz.transition 1985, 9, :o2, 496792800 - tz.transition 1986, 3, :o3, 512517600 - tz.transition 1986, 9, :o2, 528242400 - tz.transition 1987, 3, :o3, 543967200 - tz.transition 1987, 9, :o2, 559692000 - tz.transition 1988, 3, :o3, 575416800 - tz.transition 1988, 9, :o2, 591141600 - tz.transition 1989, 3, :o3, 606866400 - tz.transition 1989, 9, :o2, 622591200 - tz.transition 1990, 3, :o3, 638316000 - tz.transition 1990, 9, :o2, 654645600 - tz.transition 1991, 3, :o4, 670370400 - tz.transition 1991, 8, :o5, 683496000 - tz.transition 1991, 9, :o6, 686098800 - tz.transition 1992, 3, :o5, 701812800 - tz.transition 1992, 9, :o7, 717534000 - tz.transition 1996, 3, :o8, 828234000 - tz.transition 1996, 10, :o7, 846378000 - tz.transition 1997, 3, :o8, 859680000 - tz.transition 1997, 10, :o7, 877824000 - tz.transition 1998, 3, :o8, 891129600 - tz.transition 1998, 10, :o7, 909273600 - tz.transition 1999, 3, :o8, 922579200 - tz.transition 1999, 10, :o7, 941328000 - tz.transition 2000, 3, :o8, 954028800 - tz.transition 2000, 10, :o7, 972777600 - tz.transition 2001, 3, :o8, 985478400 - tz.transition 2001, 10, :o7, 1004227200 - tz.transition 2002, 3, :o8, 1017532800 - tz.transition 2002, 10, :o7, 1035676800 - tz.transition 2003, 3, :o8, 1048982400 - tz.transition 2003, 10, :o7, 1067126400 - tz.transition 2004, 3, :o8, 1080432000 - tz.transition 2004, 10, :o7, 1099180800 - tz.transition 2005, 3, :o8, 1111881600 - tz.transition 2005, 10, :o7, 1130630400 - tz.transition 2006, 3, :o8, 1143331200 - tz.transition 2006, 10, :o7, 1162080000 - tz.transition 2007, 3, :o8, 1174780800 - tz.transition 2007, 10, :o7, 1193529600 - tz.transition 2008, 3, :o8, 1206835200 - tz.transition 2008, 10, :o7, 1224979200 - tz.transition 2009, 3, :o8, 1238284800 - tz.transition 2009, 10, :o7, 1256428800 - tz.transition 2010, 3, :o8, 1269734400 - tz.transition 2010, 10, :o7, 1288483200 - tz.transition 2011, 3, :o8, 1301184000 - tz.transition 2011, 10, :o7, 1319932800 - tz.transition 2012, 3, :o8, 1332633600 - tz.transition 2012, 10, :o7, 1351382400 - tz.transition 2013, 3, :o8, 1364688000 - tz.transition 2013, 10, :o7, 1382832000 - tz.transition 2014, 3, :o8, 1396137600 - tz.transition 2014, 10, :o7, 1414281600 - tz.transition 2015, 3, :o8, 1427587200 - tz.transition 2015, 10, :o7, 1445731200 - tz.transition 2016, 3, :o8, 1459036800 - tz.transition 2016, 10, :o7, 1477785600 - tz.transition 2017, 3, :o8, 1490486400 - tz.transition 2017, 10, :o7, 1509235200 - tz.transition 2018, 3, :o8, 1521936000 - tz.transition 2018, 10, :o7, 1540684800 - tz.transition 2019, 3, :o8, 1553990400 - tz.transition 2019, 10, :o7, 1572134400 - tz.transition 2020, 3, :o8, 1585440000 - tz.transition 2020, 10, :o7, 1603584000 - tz.transition 2021, 3, :o8, 1616889600 - tz.transition 2021, 10, :o7, 1635638400 - tz.transition 2022, 3, :o8, 1648339200 - tz.transition 2022, 10, :o7, 1667088000 - tz.transition 2023, 3, :o8, 1679788800 - tz.transition 2023, 10, :o7, 1698537600 - tz.transition 2024, 3, :o8, 1711843200 - tz.transition 2024, 10, :o7, 1729987200 - tz.transition 2025, 3, :o8, 1743292800 - tz.transition 2025, 10, :o7, 1761436800 - tz.transition 2026, 3, :o8, 1774742400 - tz.transition 2026, 10, :o7, 1792886400 - tz.transition 2027, 3, :o8, 1806192000 - tz.transition 2027, 10, :o7, 1824940800 - tz.transition 2028, 3, :o8, 1837641600 - tz.transition 2028, 10, :o7, 1856390400 - tz.transition 2029, 3, :o8, 1869091200 - tz.transition 2029, 10, :o7, 1887840000 - tz.transition 2030, 3, :o8, 1901145600 - tz.transition 2030, 10, :o7, 1919289600 - tz.transition 2031, 3, :o8, 1932595200 - tz.transition 2031, 10, :o7, 1950739200 - tz.transition 2032, 3, :o8, 1964044800 - tz.transition 2032, 10, :o7, 1982793600 - tz.transition 2033, 3, :o8, 1995494400 - tz.transition 2033, 10, :o7, 2014243200 - tz.transition 2034, 3, :o8, 2026944000 - tz.transition 2034, 10, :o7, 2045692800 - tz.transition 2035, 3, :o8, 2058393600 - tz.transition 2035, 10, :o7, 2077142400 - tz.transition 2036, 3, :o8, 2090448000 - tz.transition 2036, 10, :o7, 2108592000 - tz.transition 2037, 3, :o8, 2121897600 - tz.transition 2037, 10, :o7, 2140041600 - tz.transition 2038, 3, :o8, 4931021, 2 - tz.transition 2038, 10, :o7, 4931455, 2 - tz.transition 2039, 3, :o8, 4931749, 2 - tz.transition 2039, 10, :o7, 4932183, 2 - tz.transition 2040, 3, :o8, 4932477, 2 - tz.transition 2040, 10, :o7, 4932911, 2 - tz.transition 2041, 3, :o8, 4933219, 2 - tz.transition 2041, 10, :o7, 4933639, 2 - tz.transition 2042, 3, :o8, 4933947, 2 - tz.transition 2042, 10, :o7, 4934367, 2 - tz.transition 2043, 3, :o8, 4934675, 2 - tz.transition 2043, 10, :o7, 4935095, 2 - tz.transition 2044, 3, :o8, 4935403, 2 - tz.transition 2044, 10, :o7, 4935837, 2 - tz.transition 2045, 3, :o8, 4936131, 2 - tz.transition 2045, 10, :o7, 4936565, 2 - tz.transition 2046, 3, :o8, 4936859, 2 - tz.transition 2046, 10, :o7, 4937293, 2 - tz.transition 2047, 3, :o8, 4937601, 2 - tz.transition 2047, 10, :o7, 4938021, 2 - tz.transition 2048, 3, :o8, 4938329, 2 - tz.transition 2048, 10, :o7, 4938749, 2 - tz.transition 2049, 3, :o8, 4939057, 2 - tz.transition 2049, 10, :o7, 4939491, 2 - tz.transition 2050, 3, :o8, 4939785, 2 - tz.transition 2050, 10, :o7, 4940219, 2 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Bangkok.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Bangkok.rb deleted file mode 100644 index 139194e..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Bangkok.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Bangkok - include TimezoneDefinition - - timezone 'Asia/Bangkok' do |tz| - tz.offset :o0, 24124, 0, :LMT - tz.offset :o1, 24124, 0, :BMT - tz.offset :o2, 25200, 0, :ICT - - tz.transition 1879, 12, :o1, 52006648769, 21600 - tz.transition 1920, 3, :o2, 52324168769, 21600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Chongqing.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Chongqing.rb deleted file mode 100644 index 8c94b4b..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Chongqing.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Chongqing - include TimezoneDefinition - - timezone 'Asia/Chongqing' do |tz| - tz.offset :o0, 25580, 0, :LMT - tz.offset :o1, 25200, 0, :LONT - tz.offset :o2, 28800, 0, :CST - tz.offset :o3, 28800, 3600, :CDT - - tz.transition 1927, 12, :o1, 10477063601, 4320 - tz.transition 1980, 4, :o2, 325962000 - tz.transition 1986, 5, :o3, 515520000 - tz.transition 1986, 9, :o2, 527007600 - tz.transition 1987, 4, :o3, 545155200 - tz.transition 1987, 9, :o2, 558457200 - tz.transition 1988, 4, :o3, 576604800 - tz.transition 1988, 9, :o2, 589906800 - tz.transition 1989, 4, :o3, 608659200 - tz.transition 1989, 9, :o2, 621961200 - tz.transition 1990, 4, :o3, 640108800 - tz.transition 1990, 9, :o2, 653410800 - tz.transition 1991, 4, :o3, 671558400 - tz.transition 1991, 9, :o2, 684860400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb deleted file mode 100644 index f6531fa..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Colombo - include TimezoneDefinition - - timezone 'Asia/Colombo' do |tz| - tz.offset :o0, 19164, 0, :LMT - tz.offset :o1, 19172, 0, :MMT - tz.offset :o2, 19800, 0, :IST - tz.offset :o3, 19800, 1800, :IHST - tz.offset :o4, 19800, 3600, :IST - tz.offset :o5, 23400, 0, :LKT - tz.offset :o6, 21600, 0, :LKT - - tz.transition 1879, 12, :o1, 17335550003, 7200 - tz.transition 1905, 12, :o2, 52211763607, 21600 - tz.transition 1942, 1, :o3, 116657485, 48 - tz.transition 1942, 8, :o4, 9722413, 4 - tz.transition 1945, 10, :o2, 38907909, 16 - tz.transition 1996, 5, :o5, 832962600 - tz.transition 1996, 10, :o6, 846266400 - tz.transition 2006, 4, :o2, 1145039400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Dhaka.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Dhaka.rb deleted file mode 100644 index ccd0265..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Dhaka.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Dhaka - include TimezoneDefinition - - timezone 'Asia/Dhaka' do |tz| - tz.offset :o0, 21700, 0, :LMT - tz.offset :o1, 21200, 0, :HMT - tz.offset :o2, 23400, 0, :BURT - tz.offset :o3, 19800, 0, :IST - tz.offset :o4, 21600, 0, :DACT - tz.offset :o5, 21600, 0, :BDT - - tz.transition 1889, 12, :o1, 2083422167, 864 - tz.transition 1941, 9, :o2, 524937943, 216 - tz.transition 1942, 5, :o3, 116663723, 48 - tz.transition 1942, 8, :o2, 116668957, 48 - tz.transition 1951, 9, :o4, 116828123, 48 - tz.transition 1971, 3, :o5, 38772000 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Hong_Kong.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Hong_Kong.rb deleted file mode 100644 index f1edd75..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Hong_Kong.rb +++ /dev/null @@ -1,87 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Hong_Kong - include TimezoneDefinition - - timezone 'Asia/Hong_Kong' do |tz| - tz.offset :o0, 27396, 0, :LMT - tz.offset :o1, 28800, 0, :HKT - tz.offset :o2, 28800, 3600, :HKST - - tz.transition 1904, 10, :o1, 5800279639, 2400 - tz.transition 1946, 4, :o2, 38910885, 16 - tz.transition 1946, 11, :o1, 116743453, 48 - tz.transition 1947, 4, :o2, 38916613, 16 - tz.transition 1947, 12, :o1, 116762365, 48 - tz.transition 1948, 5, :o2, 38922773, 16 - tz.transition 1948, 10, :o1, 116777053, 48 - tz.transition 1949, 4, :o2, 38928149, 16 - tz.transition 1949, 10, :o1, 116794525, 48 - tz.transition 1950, 4, :o2, 38933973, 16 - tz.transition 1950, 10, :o1, 116811997, 48 - tz.transition 1951, 3, :o2, 38939797, 16 - tz.transition 1951, 10, :o1, 116829469, 48 - tz.transition 1952, 4, :o2, 38945733, 16 - tz.transition 1952, 10, :o1, 116846941, 48 - tz.transition 1953, 4, :o2, 38951557, 16 - tz.transition 1953, 10, :o1, 116864749, 48 - tz.transition 1954, 3, :o2, 38957157, 16 - tz.transition 1954, 10, :o1, 116882221, 48 - tz.transition 1955, 3, :o2, 38962981, 16 - tz.transition 1955, 11, :o1, 116900029, 48 - tz.transition 1956, 3, :o2, 38968805, 16 - tz.transition 1956, 11, :o1, 116917501, 48 - tz.transition 1957, 3, :o2, 38974741, 16 - tz.transition 1957, 11, :o1, 116934973, 48 - tz.transition 1958, 3, :o2, 38980565, 16 - tz.transition 1958, 11, :o1, 116952445, 48 - tz.transition 1959, 3, :o2, 38986389, 16 - tz.transition 1959, 10, :o1, 116969917, 48 - tz.transition 1960, 3, :o2, 38992213, 16 - tz.transition 1960, 11, :o1, 116987725, 48 - tz.transition 1961, 3, :o2, 38998037, 16 - tz.transition 1961, 11, :o1, 117005197, 48 - tz.transition 1962, 3, :o2, 39003861, 16 - tz.transition 1962, 11, :o1, 117022669, 48 - tz.transition 1963, 3, :o2, 39009797, 16 - tz.transition 1963, 11, :o1, 117040141, 48 - tz.transition 1964, 3, :o2, 39015621, 16 - tz.transition 1964, 10, :o1, 117057613, 48 - tz.transition 1965, 4, :o2, 39021893, 16 - tz.transition 1965, 10, :o1, 117074413, 48 - tz.transition 1966, 4, :o2, 39027717, 16 - tz.transition 1966, 10, :o1, 117091885, 48 - tz.transition 1967, 4, :o2, 39033541, 16 - tz.transition 1967, 10, :o1, 117109693, 48 - tz.transition 1968, 4, :o2, 39039477, 16 - tz.transition 1968, 10, :o1, 117127165, 48 - tz.transition 1969, 4, :o2, 39045301, 16 - tz.transition 1969, 10, :o1, 117144637, 48 - tz.transition 1970, 4, :o2, 9315000 - tz.transition 1970, 10, :o1, 25036200 - tz.transition 1971, 4, :o2, 40764600 - tz.transition 1971, 10, :o1, 56485800 - tz.transition 1972, 4, :o2, 72214200 - tz.transition 1972, 10, :o1, 88540200 - tz.transition 1973, 4, :o2, 104268600 - tz.transition 1973, 10, :o1, 119989800 - tz.transition 1974, 4, :o2, 135718200 - tz.transition 1974, 10, :o1, 151439400 - tz.transition 1975, 4, :o2, 167167800 - tz.transition 1975, 10, :o1, 182889000 - tz.transition 1976, 4, :o2, 198617400 - tz.transition 1976, 10, :o1, 214338600 - tz.transition 1977, 4, :o2, 230067000 - tz.transition 1977, 10, :o1, 245788200 - tz.transition 1979, 5, :o2, 295385400 - tz.transition 1979, 10, :o1, 309292200 - tz.transition 1980, 5, :o2, 326835000 - tz.transition 1980, 10, :o1, 340741800 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Irkutsk.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Irkutsk.rb deleted file mode 100644 index 2d47d95..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Irkutsk.rb +++ /dev/null @@ -1,165 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Irkutsk - include TimezoneDefinition - - timezone 'Asia/Irkutsk' do |tz| - tz.offset :o0, 25040, 0, :LMT - tz.offset :o1, 25040, 0, :IMT - tz.offset :o2, 25200, 0, :IRKT - tz.offset :o3, 28800, 0, :IRKT - tz.offset :o4, 28800, 3600, :IRKST - tz.offset :o5, 25200, 3600, :IRKST - - tz.transition 1879, 12, :o1, 2600332427, 1080 - tz.transition 1920, 1, :o2, 2616136067, 1080 - tz.transition 1930, 6, :o3, 58227557, 24 - tz.transition 1981, 3, :o4, 354902400 - tz.transition 1981, 9, :o3, 370710000 - tz.transition 1982, 3, :o4, 386438400 - tz.transition 1982, 9, :o3, 402246000 - tz.transition 1983, 3, :o4, 417974400 - tz.transition 1983, 9, :o3, 433782000 - tz.transition 1984, 3, :o4, 449596800 - tz.transition 1984, 9, :o3, 465328800 - tz.transition 1985, 3, :o4, 481053600 - tz.transition 1985, 9, :o3, 496778400 - tz.transition 1986, 3, :o4, 512503200 - tz.transition 1986, 9, :o3, 528228000 - tz.transition 1987, 3, :o4, 543952800 - tz.transition 1987, 9, :o3, 559677600 - tz.transition 1988, 3, :o4, 575402400 - tz.transition 1988, 9, :o3, 591127200 - tz.transition 1989, 3, :o4, 606852000 - tz.transition 1989, 9, :o3, 622576800 - tz.transition 1990, 3, :o4, 638301600 - tz.transition 1990, 9, :o3, 654631200 - tz.transition 1991, 3, :o5, 670356000 - tz.transition 1991, 9, :o2, 686084400 - tz.transition 1992, 1, :o3, 695761200 - tz.transition 1992, 3, :o4, 701794800 - tz.transition 1992, 9, :o3, 717516000 - tz.transition 1993, 3, :o4, 733255200 - tz.transition 1993, 9, :o3, 748980000 - tz.transition 1994, 3, :o4, 764704800 - tz.transition 1994, 9, :o3, 780429600 - tz.transition 1995, 3, :o4, 796154400 - tz.transition 1995, 9, :o3, 811879200 - tz.transition 1996, 3, :o4, 828208800 - tz.transition 1996, 10, :o3, 846352800 - tz.transition 1997, 3, :o4, 859658400 - tz.transition 1997, 10, :o3, 877802400 - tz.transition 1998, 3, :o4, 891108000 - tz.transition 1998, 10, :o3, 909252000 - tz.transition 1999, 3, :o4, 922557600 - tz.transition 1999, 10, :o3, 941306400 - tz.transition 2000, 3, :o4, 954007200 - tz.transition 2000, 10, :o3, 972756000 - tz.transition 2001, 3, :o4, 985456800 - tz.transition 2001, 10, :o3, 1004205600 - tz.transition 2002, 3, :o4, 1017511200 - tz.transition 2002, 10, :o3, 1035655200 - tz.transition 2003, 3, :o4, 1048960800 - tz.transition 2003, 10, :o3, 1067104800 - tz.transition 2004, 3, :o4, 1080410400 - tz.transition 2004, 10, :o3, 1099159200 - tz.transition 2005, 3, :o4, 1111860000 - tz.transition 2005, 10, :o3, 1130608800 - tz.transition 2006, 3, :o4, 1143309600 - tz.transition 2006, 10, :o3, 1162058400 - tz.transition 2007, 3, :o4, 1174759200 - tz.transition 2007, 10, :o3, 1193508000 - tz.transition 2008, 3, :o4, 1206813600 - tz.transition 2008, 10, :o3, 1224957600 - tz.transition 2009, 3, :o4, 1238263200 - tz.transition 2009, 10, :o3, 1256407200 - tz.transition 2010, 3, :o4, 1269712800 - tz.transition 2010, 10, :o3, 1288461600 - tz.transition 2011, 3, :o4, 1301162400 - tz.transition 2011, 10, :o3, 1319911200 - tz.transition 2012, 3, :o4, 1332612000 - tz.transition 2012, 10, :o3, 1351360800 - tz.transition 2013, 3, :o4, 1364666400 - tz.transition 2013, 10, :o3, 1382810400 - tz.transition 2014, 3, :o4, 1396116000 - tz.transition 2014, 10, :o3, 1414260000 - tz.transition 2015, 3, :o4, 1427565600 - tz.transition 2015, 10, :o3, 1445709600 - tz.transition 2016, 3, :o4, 1459015200 - tz.transition 2016, 10, :o3, 1477764000 - tz.transition 2017, 3, :o4, 1490464800 - tz.transition 2017, 10, :o3, 1509213600 - tz.transition 2018, 3, :o4, 1521914400 - tz.transition 2018, 10, :o3, 1540663200 - tz.transition 2019, 3, :o4, 1553968800 - tz.transition 2019, 10, :o3, 1572112800 - tz.transition 2020, 3, :o4, 1585418400 - tz.transition 2020, 10, :o3, 1603562400 - tz.transition 2021, 3, :o4, 1616868000 - tz.transition 2021, 10, :o3, 1635616800 - tz.transition 2022, 3, :o4, 1648317600 - tz.transition 2022, 10, :o3, 1667066400 - tz.transition 2023, 3, :o4, 1679767200 - tz.transition 2023, 10, :o3, 1698516000 - tz.transition 2024, 3, :o4, 1711821600 - tz.transition 2024, 10, :o3, 1729965600 - tz.transition 2025, 3, :o4, 1743271200 - tz.transition 2025, 10, :o3, 1761415200 - tz.transition 2026, 3, :o4, 1774720800 - tz.transition 2026, 10, :o3, 1792864800 - tz.transition 2027, 3, :o4, 1806170400 - tz.transition 2027, 10, :o3, 1824919200 - tz.transition 2028, 3, :o4, 1837620000 - tz.transition 2028, 10, :o3, 1856368800 - tz.transition 2029, 3, :o4, 1869069600 - tz.transition 2029, 10, :o3, 1887818400 - tz.transition 2030, 3, :o4, 1901124000 - tz.transition 2030, 10, :o3, 1919268000 - tz.transition 2031, 3, :o4, 1932573600 - tz.transition 2031, 10, :o3, 1950717600 - tz.transition 2032, 3, :o4, 1964023200 - tz.transition 2032, 10, :o3, 1982772000 - tz.transition 2033, 3, :o4, 1995472800 - tz.transition 2033, 10, :o3, 2014221600 - tz.transition 2034, 3, :o4, 2026922400 - tz.transition 2034, 10, :o3, 2045671200 - tz.transition 2035, 3, :o4, 2058372000 - tz.transition 2035, 10, :o3, 2077120800 - tz.transition 2036, 3, :o4, 2090426400 - tz.transition 2036, 10, :o3, 2108570400 - tz.transition 2037, 3, :o4, 2121876000 - tz.transition 2037, 10, :o3, 2140020000 - tz.transition 2038, 3, :o4, 9862041, 4 - tz.transition 2038, 10, :o3, 9862909, 4 - tz.transition 2039, 3, :o4, 9863497, 4 - tz.transition 2039, 10, :o3, 9864365, 4 - tz.transition 2040, 3, :o4, 9864953, 4 - tz.transition 2040, 10, :o3, 9865821, 4 - tz.transition 2041, 3, :o4, 9866437, 4 - tz.transition 2041, 10, :o3, 9867277, 4 - tz.transition 2042, 3, :o4, 9867893, 4 - tz.transition 2042, 10, :o3, 9868733, 4 - tz.transition 2043, 3, :o4, 9869349, 4 - tz.transition 2043, 10, :o3, 9870189, 4 - tz.transition 2044, 3, :o4, 9870805, 4 - tz.transition 2044, 10, :o3, 9871673, 4 - tz.transition 2045, 3, :o4, 9872261, 4 - tz.transition 2045, 10, :o3, 9873129, 4 - tz.transition 2046, 3, :o4, 9873717, 4 - tz.transition 2046, 10, :o3, 9874585, 4 - tz.transition 2047, 3, :o4, 9875201, 4 - tz.transition 2047, 10, :o3, 9876041, 4 - tz.transition 2048, 3, :o4, 9876657, 4 - tz.transition 2048, 10, :o3, 9877497, 4 - tz.transition 2049, 3, :o4, 9878113, 4 - tz.transition 2049, 10, :o3, 9878981, 4 - tz.transition 2050, 3, :o4, 9879569, 4 - tz.transition 2050, 10, :o3, 9880437, 4 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jakarta.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jakarta.rb deleted file mode 100644 index cc58fa1..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jakarta.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Jakarta - include TimezoneDefinition - - timezone 'Asia/Jakarta' do |tz| - tz.offset :o0, 25632, 0, :LMT - tz.offset :o1, 25632, 0, :JMT - tz.offset :o2, 26400, 0, :JAVT - tz.offset :o3, 27000, 0, :WIT - tz.offset :o4, 32400, 0, :JST - tz.offset :o5, 28800, 0, :WIT - tz.offset :o6, 25200, 0, :WIT - - tz.transition 1867, 8, :o1, 720956461, 300 - tz.transition 1923, 12, :o2, 87256267, 36 - tz.transition 1932, 10, :o3, 87372439, 36 - tz.transition 1942, 3, :o4, 38887059, 16 - tz.transition 1945, 9, :o3, 19453769, 8 - tz.transition 1948, 4, :o5, 38922755, 16 - tz.transition 1950, 4, :o3, 14600413, 6 - tz.transition 1963, 12, :o6, 39014323, 16 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jerusalem.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jerusalem.rb deleted file mode 100644 index 9b737b8..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jerusalem.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Jerusalem - include TimezoneDefinition - - timezone 'Asia/Jerusalem' do |tz| - tz.offset :o0, 8456, 0, :LMT - tz.offset :o1, 8440, 0, :JMT - tz.offset :o2, 7200, 0, :IST - tz.offset :o3, 7200, 3600, :IDT - tz.offset :o4, 7200, 7200, :IDDT - - tz.transition 1879, 12, :o1, 26003326343, 10800 - tz.transition 1917, 12, :o2, 5230643909, 2160 - tz.transition 1940, 5, :o3, 29157377, 12 - tz.transition 1942, 10, :o2, 19445315, 8 - tz.transition 1943, 4, :o3, 4861631, 2 - tz.transition 1943, 10, :o2, 19448235, 8 - tz.transition 1944, 3, :o3, 29174177, 12 - tz.transition 1944, 10, :o2, 19451163, 8 - tz.transition 1945, 4, :o3, 29178737, 12 - tz.transition 1945, 10, :o2, 58362251, 24 - tz.transition 1946, 4, :o3, 4863853, 2 - tz.transition 1946, 10, :o2, 19457003, 8 - tz.transition 1948, 5, :o4, 29192333, 12 - tz.transition 1948, 8, :o3, 7298386, 3 - tz.transition 1948, 10, :o2, 58388555, 24 - tz.transition 1949, 4, :o3, 29196449, 12 - tz.transition 1949, 10, :o2, 58397315, 24 - tz.transition 1950, 4, :o3, 29200649, 12 - tz.transition 1950, 9, :o2, 4867079, 2 - tz.transition 1951, 3, :o3, 29204849, 12 - tz.transition 1951, 11, :o2, 4867923, 2 - tz.transition 1952, 4, :o3, 4868245, 2 - tz.transition 1952, 10, :o2, 4868609, 2 - tz.transition 1953, 4, :o3, 4868959, 2 - tz.transition 1953, 9, :o2, 4869267, 2 - tz.transition 1954, 6, :o3, 29218877, 12 - tz.transition 1954, 9, :o2, 19479979, 8 - tz.transition 1955, 6, :o3, 4870539, 2 - tz.transition 1955, 9, :o2, 19482891, 8 - tz.transition 1956, 6, :o3, 29227529, 12 - tz.transition 1956, 9, :o2, 4871493, 2 - tz.transition 1957, 4, :o3, 4871915, 2 - tz.transition 1957, 9, :o2, 19488827, 8 - tz.transition 1974, 7, :o3, 142380000 - tz.transition 1974, 10, :o2, 150843600 - tz.transition 1975, 4, :o3, 167176800 - tz.transition 1975, 8, :o2, 178664400 - tz.transition 1985, 4, :o3, 482277600 - tz.transition 1985, 9, :o2, 495579600 - tz.transition 1986, 5, :o3, 516751200 - tz.transition 1986, 9, :o2, 526424400 - tz.transition 1987, 4, :o3, 545436000 - tz.transition 1987, 9, :o2, 558478800 - tz.transition 1988, 4, :o3, 576540000 - tz.transition 1988, 9, :o2, 589237200 - tz.transition 1989, 4, :o3, 609890400 - tz.transition 1989, 9, :o2, 620773200 - tz.transition 1990, 3, :o3, 638316000 - tz.transition 1990, 8, :o2, 651618000 - tz.transition 1991, 3, :o3, 669765600 - tz.transition 1991, 8, :o2, 683672400 - tz.transition 1992, 3, :o3, 701820000 - tz.transition 1992, 9, :o2, 715726800 - tz.transition 1993, 4, :o3, 733701600 - tz.transition 1993, 9, :o2, 747176400 - tz.transition 1994, 3, :o3, 765151200 - tz.transition 1994, 8, :o2, 778021200 - tz.transition 1995, 3, :o3, 796600800 - tz.transition 1995, 9, :o2, 810075600 - tz.transition 1996, 3, :o3, 826840800 - tz.transition 1996, 9, :o2, 842821200 - tz.transition 1997, 3, :o3, 858895200 - tz.transition 1997, 9, :o2, 874184400 - tz.transition 1998, 3, :o3, 890344800 - tz.transition 1998, 9, :o2, 905029200 - tz.transition 1999, 4, :o3, 923011200 - tz.transition 1999, 9, :o2, 936313200 - tz.transition 2000, 4, :o3, 955670400 - tz.transition 2000, 10, :o2, 970783200 - tz.transition 2001, 4, :o3, 986770800 - tz.transition 2001, 9, :o2, 1001282400 - tz.transition 2002, 3, :o3, 1017356400 - tz.transition 2002, 10, :o2, 1033941600 - tz.transition 2003, 3, :o3, 1048806000 - tz.transition 2003, 10, :o2, 1065132000 - tz.transition 2004, 4, :o3, 1081292400 - tz.transition 2004, 9, :o2, 1095804000 - tz.transition 2005, 4, :o3, 1112313600 - tz.transition 2005, 10, :o2, 1128812400 - tz.transition 2006, 3, :o3, 1143763200 - tz.transition 2006, 9, :o2, 1159657200 - tz.transition 2007, 3, :o3, 1175212800 - tz.transition 2007, 9, :o2, 1189897200 - tz.transition 2008, 3, :o3, 1206662400 - tz.transition 2008, 10, :o2, 1223161200 - tz.transition 2009, 3, :o3, 1238112000 - tz.transition 2009, 9, :o2, 1254006000 - tz.transition 2010, 3, :o3, 1269561600 - tz.transition 2010, 9, :o2, 1284246000 - tz.transition 2011, 4, :o3, 1301616000 - tz.transition 2011, 10, :o2, 1317510000 - tz.transition 2012, 3, :o3, 1333065600 - tz.transition 2012, 9, :o2, 1348354800 - tz.transition 2013, 3, :o3, 1364515200 - tz.transition 2013, 9, :o2, 1378594800 - tz.transition 2014, 3, :o3, 1395964800 - tz.transition 2014, 9, :o2, 1411858800 - tz.transition 2015, 3, :o3, 1427414400 - tz.transition 2015, 9, :o2, 1442703600 - tz.transition 2016, 4, :o3, 1459468800 - tz.transition 2016, 10, :o2, 1475967600 - tz.transition 2017, 3, :o3, 1490918400 - tz.transition 2017, 9, :o2, 1506207600 - tz.transition 2018, 3, :o3, 1522368000 - tz.transition 2018, 9, :o2, 1537052400 - tz.transition 2019, 3, :o3, 1553817600 - tz.transition 2019, 10, :o2, 1570316400 - tz.transition 2020, 3, :o3, 1585267200 - tz.transition 2020, 9, :o2, 1601161200 - tz.transition 2021, 3, :o3, 1616716800 - tz.transition 2021, 9, :o2, 1631401200 - tz.transition 2022, 4, :o3, 1648771200 - tz.transition 2022, 10, :o2, 1664665200 - tz.transition 2023, 3, :o3, 1680220800 - tz.transition 2023, 9, :o2, 1695510000 - tz.transition 2024, 3, :o3, 1711670400 - tz.transition 2024, 10, :o2, 1728169200 - tz.transition 2025, 3, :o3, 1743120000 - tz.transition 2025, 9, :o2, 1759014000 - tz.transition 2026, 3, :o3, 1774569600 - tz.transition 2026, 9, :o2, 1789858800 - tz.transition 2027, 3, :o3, 1806019200 - tz.transition 2027, 10, :o2, 1823122800 - tz.transition 2028, 3, :o3, 1838073600 - tz.transition 2028, 9, :o2, 1853362800 - tz.transition 2029, 3, :o3, 1869523200 - tz.transition 2029, 9, :o2, 1884207600 - tz.transition 2030, 3, :o3, 1900972800 - tz.transition 2030, 10, :o2, 1917471600 - tz.transition 2031, 3, :o3, 1932422400 - tz.transition 2031, 9, :o2, 1947711600 - tz.transition 2032, 3, :o3, 1963872000 - tz.transition 2032, 9, :o2, 1978556400 - tz.transition 2033, 4, :o3, 1995926400 - tz.transition 2033, 10, :o2, 2011820400 - tz.transition 2034, 3, :o3, 2027376000 - tz.transition 2034, 9, :o2, 2042060400 - tz.transition 2035, 3, :o3, 2058825600 - tz.transition 2035, 10, :o2, 2075324400 - tz.transition 2036, 3, :o3, 2090275200 - tz.transition 2036, 9, :o2, 2106169200 - tz.transition 2037, 3, :o3, 2121724800 - tz.transition 2037, 9, :o2, 2136409200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kabul.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kabul.rb deleted file mode 100644 index 669c097..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kabul.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Kabul - include TimezoneDefinition - - timezone 'Asia/Kabul' do |tz| - tz.offset :o0, 16608, 0, :LMT - tz.offset :o1, 14400, 0, :AFT - tz.offset :o2, 16200, 0, :AFT - - tz.transition 1889, 12, :o1, 2170231477, 900 - tz.transition 1944, 12, :o2, 7294369, 3 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kamchatka.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kamchatka.rb deleted file mode 100644 index 2f1690b..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kamchatka.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Kamchatka - include TimezoneDefinition - - timezone 'Asia/Kamchatka' do |tz| - tz.offset :o0, 38076, 0, :LMT - tz.offset :o1, 39600, 0, :PETT - tz.offset :o2, 43200, 0, :PETT - tz.offset :o3, 43200, 3600, :PETST - tz.offset :o4, 39600, 3600, :PETST - - tz.transition 1922, 11, :o1, 17448250027, 7200 - tz.transition 1930, 6, :o2, 58227553, 24 - tz.transition 1981, 3, :o3, 354888000 - tz.transition 1981, 9, :o2, 370695600 - tz.transition 1982, 3, :o3, 386424000 - tz.transition 1982, 9, :o2, 402231600 - tz.transition 1983, 3, :o3, 417960000 - tz.transition 1983, 9, :o2, 433767600 - tz.transition 1984, 3, :o3, 449582400 - tz.transition 1984, 9, :o2, 465314400 - tz.transition 1985, 3, :o3, 481039200 - tz.transition 1985, 9, :o2, 496764000 - tz.transition 1986, 3, :o3, 512488800 - tz.transition 1986, 9, :o2, 528213600 - tz.transition 1987, 3, :o3, 543938400 - tz.transition 1987, 9, :o2, 559663200 - tz.transition 1988, 3, :o3, 575388000 - tz.transition 1988, 9, :o2, 591112800 - tz.transition 1989, 3, :o3, 606837600 - tz.transition 1989, 9, :o2, 622562400 - tz.transition 1990, 3, :o3, 638287200 - tz.transition 1990, 9, :o2, 654616800 - tz.transition 1991, 3, :o4, 670341600 - tz.transition 1991, 9, :o1, 686070000 - tz.transition 1992, 1, :o2, 695746800 - tz.transition 1992, 3, :o3, 701780400 - tz.transition 1992, 9, :o2, 717501600 - tz.transition 1993, 3, :o3, 733240800 - tz.transition 1993, 9, :o2, 748965600 - tz.transition 1994, 3, :o3, 764690400 - tz.transition 1994, 9, :o2, 780415200 - tz.transition 1995, 3, :o3, 796140000 - tz.transition 1995, 9, :o2, 811864800 - tz.transition 1996, 3, :o3, 828194400 - tz.transition 1996, 10, :o2, 846338400 - tz.transition 1997, 3, :o3, 859644000 - tz.transition 1997, 10, :o2, 877788000 - tz.transition 1998, 3, :o3, 891093600 - tz.transition 1998, 10, :o2, 909237600 - tz.transition 1999, 3, :o3, 922543200 - tz.transition 1999, 10, :o2, 941292000 - tz.transition 2000, 3, :o3, 953992800 - tz.transition 2000, 10, :o2, 972741600 - tz.transition 2001, 3, :o3, 985442400 - tz.transition 2001, 10, :o2, 1004191200 - tz.transition 2002, 3, :o3, 1017496800 - tz.transition 2002, 10, :o2, 1035640800 - tz.transition 2003, 3, :o3, 1048946400 - tz.transition 2003, 10, :o2, 1067090400 - tz.transition 2004, 3, :o3, 1080396000 - tz.transition 2004, 10, :o2, 1099144800 - tz.transition 2005, 3, :o3, 1111845600 - tz.transition 2005, 10, :o2, 1130594400 - tz.transition 2006, 3, :o3, 1143295200 - tz.transition 2006, 10, :o2, 1162044000 - tz.transition 2007, 3, :o3, 1174744800 - tz.transition 2007, 10, :o2, 1193493600 - tz.transition 2008, 3, :o3, 1206799200 - tz.transition 2008, 10, :o2, 1224943200 - tz.transition 2009, 3, :o3, 1238248800 - tz.transition 2009, 10, :o2, 1256392800 - tz.transition 2010, 3, :o3, 1269698400 - tz.transition 2010, 10, :o2, 1288447200 - tz.transition 2011, 3, :o3, 1301148000 - tz.transition 2011, 10, :o2, 1319896800 - tz.transition 2012, 3, :o3, 1332597600 - tz.transition 2012, 10, :o2, 1351346400 - tz.transition 2013, 3, :o3, 1364652000 - tz.transition 2013, 10, :o2, 1382796000 - tz.transition 2014, 3, :o3, 1396101600 - tz.transition 2014, 10, :o2, 1414245600 - tz.transition 2015, 3, :o3, 1427551200 - tz.transition 2015, 10, :o2, 1445695200 - tz.transition 2016, 3, :o3, 1459000800 - tz.transition 2016, 10, :o2, 1477749600 - tz.transition 2017, 3, :o3, 1490450400 - tz.transition 2017, 10, :o2, 1509199200 - tz.transition 2018, 3, :o3, 1521900000 - tz.transition 2018, 10, :o2, 1540648800 - tz.transition 2019, 3, :o3, 1553954400 - tz.transition 2019, 10, :o2, 1572098400 - tz.transition 2020, 3, :o3, 1585404000 - tz.transition 2020, 10, :o2, 1603548000 - tz.transition 2021, 3, :o3, 1616853600 - tz.transition 2021, 10, :o2, 1635602400 - tz.transition 2022, 3, :o3, 1648303200 - tz.transition 2022, 10, :o2, 1667052000 - tz.transition 2023, 3, :o3, 1679752800 - tz.transition 2023, 10, :o2, 1698501600 - tz.transition 2024, 3, :o3, 1711807200 - tz.transition 2024, 10, :o2, 1729951200 - tz.transition 2025, 3, :o3, 1743256800 - tz.transition 2025, 10, :o2, 1761400800 - tz.transition 2026, 3, :o3, 1774706400 - tz.transition 2026, 10, :o2, 1792850400 - tz.transition 2027, 3, :o3, 1806156000 - tz.transition 2027, 10, :o2, 1824904800 - tz.transition 2028, 3, :o3, 1837605600 - tz.transition 2028, 10, :o2, 1856354400 - tz.transition 2029, 3, :o3, 1869055200 - tz.transition 2029, 10, :o2, 1887804000 - tz.transition 2030, 3, :o3, 1901109600 - tz.transition 2030, 10, :o2, 1919253600 - tz.transition 2031, 3, :o3, 1932559200 - tz.transition 2031, 10, :o2, 1950703200 - tz.transition 2032, 3, :o3, 1964008800 - tz.transition 2032, 10, :o2, 1982757600 - tz.transition 2033, 3, :o3, 1995458400 - tz.transition 2033, 10, :o2, 2014207200 - tz.transition 2034, 3, :o3, 2026908000 - tz.transition 2034, 10, :o2, 2045656800 - tz.transition 2035, 3, :o3, 2058357600 - tz.transition 2035, 10, :o2, 2077106400 - tz.transition 2036, 3, :o3, 2090412000 - tz.transition 2036, 10, :o2, 2108556000 - tz.transition 2037, 3, :o3, 2121861600 - tz.transition 2037, 10, :o2, 2140005600 - tz.transition 2038, 3, :o3, 29586121, 12 - tz.transition 2038, 10, :o2, 29588725, 12 - tz.transition 2039, 3, :o3, 29590489, 12 - tz.transition 2039, 10, :o2, 29593093, 12 - tz.transition 2040, 3, :o3, 29594857, 12 - tz.transition 2040, 10, :o2, 29597461, 12 - tz.transition 2041, 3, :o3, 29599309, 12 - tz.transition 2041, 10, :o2, 29601829, 12 - tz.transition 2042, 3, :o3, 29603677, 12 - tz.transition 2042, 10, :o2, 29606197, 12 - tz.transition 2043, 3, :o3, 29608045, 12 - tz.transition 2043, 10, :o2, 29610565, 12 - tz.transition 2044, 3, :o3, 29612413, 12 - tz.transition 2044, 10, :o2, 29615017, 12 - tz.transition 2045, 3, :o3, 29616781, 12 - tz.transition 2045, 10, :o2, 29619385, 12 - tz.transition 2046, 3, :o3, 29621149, 12 - tz.transition 2046, 10, :o2, 29623753, 12 - tz.transition 2047, 3, :o3, 29625601, 12 - tz.transition 2047, 10, :o2, 29628121, 12 - tz.transition 2048, 3, :o3, 29629969, 12 - tz.transition 2048, 10, :o2, 29632489, 12 - tz.transition 2049, 3, :o3, 29634337, 12 - tz.transition 2049, 10, :o2, 29636941, 12 - tz.transition 2050, 3, :o3, 29638705, 12 - tz.transition 2050, 10, :o2, 29641309, 12 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Karachi.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Karachi.rb deleted file mode 100644 index b906cc9..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Karachi.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Karachi - include TimezoneDefinition - - timezone 'Asia/Karachi' do |tz| - tz.offset :o0, 16092, 0, :LMT - tz.offset :o1, 19800, 0, :IST - tz.offset :o2, 19800, 3600, :IST - tz.offset :o3, 18000, 0, :KART - tz.offset :o4, 18000, 0, :PKT - tz.offset :o5, 18000, 3600, :PKST - - tz.transition 1906, 12, :o1, 1934061051, 800 - tz.transition 1942, 8, :o2, 116668957, 48 - tz.transition 1945, 10, :o1, 116723675, 48 - tz.transition 1951, 9, :o3, 116828125, 48 - tz.transition 1971, 3, :o4, 38775600 - tz.transition 2002, 4, :o5, 1018119660 - tz.transition 2002, 10, :o4, 1033840860 - tz.transition 2008, 5, :o5, 1212260400 - tz.transition 2008, 10, :o4, 1225476000 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Katmandu.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Katmandu.rb deleted file mode 100644 index 37dbea1..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Katmandu.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Katmandu - include TimezoneDefinition - - timezone 'Asia/Katmandu' do |tz| - tz.offset :o0, 20476, 0, :LMT - tz.offset :o1, 19800, 0, :IST - tz.offset :o2, 20700, 0, :NPT - - tz.transition 1919, 12, :o1, 52322204081, 21600 - tz.transition 1985, 12, :o2, 504901800 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kolkata.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kolkata.rb deleted file mode 100644 index 1b6ffbd..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kolkata.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Kolkata - include TimezoneDefinition - - timezone 'Asia/Kolkata' do |tz| - tz.offset :o0, 21208, 0, :LMT - tz.offset :o1, 21200, 0, :HMT - tz.offset :o2, 23400, 0, :BURT - tz.offset :o3, 19800, 0, :IST - tz.offset :o4, 19800, 3600, :IST - - tz.transition 1879, 12, :o1, 26003324749, 10800 - tz.transition 1941, 9, :o2, 524937943, 216 - tz.transition 1942, 5, :o3, 116663723, 48 - tz.transition 1942, 8, :o4, 116668957, 48 - tz.transition 1945, 10, :o3, 116723675, 48 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Krasnoyarsk.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Krasnoyarsk.rb deleted file mode 100644 index d6c503c..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Krasnoyarsk.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Krasnoyarsk - include TimezoneDefinition - - timezone 'Asia/Krasnoyarsk' do |tz| - tz.offset :o0, 22280, 0, :LMT - tz.offset :o1, 21600, 0, :KRAT - tz.offset :o2, 25200, 0, :KRAT - tz.offset :o3, 25200, 3600, :KRAST - tz.offset :o4, 21600, 3600, :KRAST - - tz.transition 1920, 1, :o1, 5232231163, 2160 - tz.transition 1930, 6, :o2, 9704593, 4 - tz.transition 1981, 3, :o3, 354906000 - tz.transition 1981, 9, :o2, 370713600 - tz.transition 1982, 3, :o3, 386442000 - tz.transition 1982, 9, :o2, 402249600 - tz.transition 1983, 3, :o3, 417978000 - tz.transition 1983, 9, :o2, 433785600 - tz.transition 1984, 3, :o3, 449600400 - tz.transition 1984, 9, :o2, 465332400 - tz.transition 1985, 3, :o3, 481057200 - tz.transition 1985, 9, :o2, 496782000 - tz.transition 1986, 3, :o3, 512506800 - tz.transition 1986, 9, :o2, 528231600 - tz.transition 1987, 3, :o3, 543956400 - tz.transition 1987, 9, :o2, 559681200 - tz.transition 1988, 3, :o3, 575406000 - tz.transition 1988, 9, :o2, 591130800 - tz.transition 1989, 3, :o3, 606855600 - tz.transition 1989, 9, :o2, 622580400 - tz.transition 1990, 3, :o3, 638305200 - tz.transition 1990, 9, :o2, 654634800 - tz.transition 1991, 3, :o4, 670359600 - tz.transition 1991, 9, :o1, 686088000 - tz.transition 1992, 1, :o2, 695764800 - tz.transition 1992, 3, :o3, 701798400 - tz.transition 1992, 9, :o2, 717519600 - tz.transition 1993, 3, :o3, 733258800 - tz.transition 1993, 9, :o2, 748983600 - tz.transition 1994, 3, :o3, 764708400 - tz.transition 1994, 9, :o2, 780433200 - tz.transition 1995, 3, :o3, 796158000 - tz.transition 1995, 9, :o2, 811882800 - tz.transition 1996, 3, :o3, 828212400 - tz.transition 1996, 10, :o2, 846356400 - tz.transition 1997, 3, :o3, 859662000 - tz.transition 1997, 10, :o2, 877806000 - tz.transition 1998, 3, :o3, 891111600 - tz.transition 1998, 10, :o2, 909255600 - tz.transition 1999, 3, :o3, 922561200 - tz.transition 1999, 10, :o2, 941310000 - tz.transition 2000, 3, :o3, 954010800 - tz.transition 2000, 10, :o2, 972759600 - tz.transition 2001, 3, :o3, 985460400 - tz.transition 2001, 10, :o2, 1004209200 - tz.transition 2002, 3, :o3, 1017514800 - tz.transition 2002, 10, :o2, 1035658800 - tz.transition 2003, 3, :o3, 1048964400 - tz.transition 2003, 10, :o2, 1067108400 - tz.transition 2004, 3, :o3, 1080414000 - tz.transition 2004, 10, :o2, 1099162800 - tz.transition 2005, 3, :o3, 1111863600 - tz.transition 2005, 10, :o2, 1130612400 - tz.transition 2006, 3, :o3, 1143313200 - tz.transition 2006, 10, :o2, 1162062000 - tz.transition 2007, 3, :o3, 1174762800 - tz.transition 2007, 10, :o2, 1193511600 - tz.transition 2008, 3, :o3, 1206817200 - tz.transition 2008, 10, :o2, 1224961200 - tz.transition 2009, 3, :o3, 1238266800 - tz.transition 2009, 10, :o2, 1256410800 - tz.transition 2010, 3, :o3, 1269716400 - tz.transition 2010, 10, :o2, 1288465200 - tz.transition 2011, 3, :o3, 1301166000 - tz.transition 2011, 10, :o2, 1319914800 - tz.transition 2012, 3, :o3, 1332615600 - tz.transition 2012, 10, :o2, 1351364400 - tz.transition 2013, 3, :o3, 1364670000 - tz.transition 2013, 10, :o2, 1382814000 - tz.transition 2014, 3, :o3, 1396119600 - tz.transition 2014, 10, :o2, 1414263600 - tz.transition 2015, 3, :o3, 1427569200 - tz.transition 2015, 10, :o2, 1445713200 - tz.transition 2016, 3, :o3, 1459018800 - tz.transition 2016, 10, :o2, 1477767600 - tz.transition 2017, 3, :o3, 1490468400 - tz.transition 2017, 10, :o2, 1509217200 - tz.transition 2018, 3, :o3, 1521918000 - tz.transition 2018, 10, :o2, 1540666800 - tz.transition 2019, 3, :o3, 1553972400 - tz.transition 2019, 10, :o2, 1572116400 - tz.transition 2020, 3, :o3, 1585422000 - tz.transition 2020, 10, :o2, 1603566000 - tz.transition 2021, 3, :o3, 1616871600 - tz.transition 2021, 10, :o2, 1635620400 - tz.transition 2022, 3, :o3, 1648321200 - tz.transition 2022, 10, :o2, 1667070000 - tz.transition 2023, 3, :o3, 1679770800 - tz.transition 2023, 10, :o2, 1698519600 - tz.transition 2024, 3, :o3, 1711825200 - tz.transition 2024, 10, :o2, 1729969200 - tz.transition 2025, 3, :o3, 1743274800 - tz.transition 2025, 10, :o2, 1761418800 - tz.transition 2026, 3, :o3, 1774724400 - tz.transition 2026, 10, :o2, 1792868400 - tz.transition 2027, 3, :o3, 1806174000 - tz.transition 2027, 10, :o2, 1824922800 - tz.transition 2028, 3, :o3, 1837623600 - tz.transition 2028, 10, :o2, 1856372400 - tz.transition 2029, 3, :o3, 1869073200 - tz.transition 2029, 10, :o2, 1887822000 - tz.transition 2030, 3, :o3, 1901127600 - tz.transition 2030, 10, :o2, 1919271600 - tz.transition 2031, 3, :o3, 1932577200 - tz.transition 2031, 10, :o2, 1950721200 - tz.transition 2032, 3, :o3, 1964026800 - tz.transition 2032, 10, :o2, 1982775600 - tz.transition 2033, 3, :o3, 1995476400 - tz.transition 2033, 10, :o2, 2014225200 - tz.transition 2034, 3, :o3, 2026926000 - tz.transition 2034, 10, :o2, 2045674800 - tz.transition 2035, 3, :o3, 2058375600 - tz.transition 2035, 10, :o2, 2077124400 - tz.transition 2036, 3, :o3, 2090430000 - tz.transition 2036, 10, :o2, 2108574000 - tz.transition 2037, 3, :o3, 2121879600 - tz.transition 2037, 10, :o2, 2140023600 - tz.transition 2038, 3, :o3, 59172247, 24 - tz.transition 2038, 10, :o2, 59177455, 24 - tz.transition 2039, 3, :o3, 59180983, 24 - tz.transition 2039, 10, :o2, 59186191, 24 - tz.transition 2040, 3, :o3, 59189719, 24 - tz.transition 2040, 10, :o2, 59194927, 24 - tz.transition 2041, 3, :o3, 59198623, 24 - tz.transition 2041, 10, :o2, 59203663, 24 - tz.transition 2042, 3, :o3, 59207359, 24 - tz.transition 2042, 10, :o2, 59212399, 24 - tz.transition 2043, 3, :o3, 59216095, 24 - tz.transition 2043, 10, :o2, 59221135, 24 - tz.transition 2044, 3, :o3, 59224831, 24 - tz.transition 2044, 10, :o2, 59230039, 24 - tz.transition 2045, 3, :o3, 59233567, 24 - tz.transition 2045, 10, :o2, 59238775, 24 - tz.transition 2046, 3, :o3, 59242303, 24 - tz.transition 2046, 10, :o2, 59247511, 24 - tz.transition 2047, 3, :o3, 59251207, 24 - tz.transition 2047, 10, :o2, 59256247, 24 - tz.transition 2048, 3, :o3, 59259943, 24 - tz.transition 2048, 10, :o2, 59264983, 24 - tz.transition 2049, 3, :o3, 59268679, 24 - tz.transition 2049, 10, :o2, 59273887, 24 - tz.transition 2050, 3, :o3, 59277415, 24 - tz.transition 2050, 10, :o2, 59282623, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuala_Lumpur.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuala_Lumpur.rb deleted file mode 100644 index 77a0c20..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuala_Lumpur.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Kuala_Lumpur - include TimezoneDefinition - - timezone 'Asia/Kuala_Lumpur' do |tz| - tz.offset :o0, 24406, 0, :LMT - tz.offset :o1, 24925, 0, :SMT - tz.offset :o2, 25200, 0, :MALT - tz.offset :o3, 25200, 1200, :MALST - tz.offset :o4, 26400, 0, :MALT - tz.offset :o5, 27000, 0, :MALT - tz.offset :o6, 32400, 0, :JST - tz.offset :o7, 28800, 0, :MYT - - tz.transition 1900, 12, :o1, 104344641397, 43200 - tz.transition 1905, 5, :o2, 8353142363, 3456 - tz.transition 1932, 12, :o3, 58249757, 24 - tz.transition 1935, 12, :o4, 87414055, 36 - tz.transition 1941, 8, :o5, 87488575, 36 - tz.transition 1942, 2, :o6, 38886499, 16 - tz.transition 1945, 9, :o5, 19453681, 8 - tz.transition 1981, 12, :o7, 378664200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuwait.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuwait.rb deleted file mode 100644 index 5bd5283..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuwait.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Kuwait - include TimezoneDefinition - - timezone 'Asia/Kuwait' do |tz| - tz.offset :o0, 11516, 0, :LMT - tz.offset :o1, 10800, 0, :AST - - tz.transition 1949, 12, :o1, 52558899121, 21600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Magadan.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Magadan.rb deleted file mode 100644 index 3020936..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Magadan.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Magadan - include TimezoneDefinition - - timezone 'Asia/Magadan' do |tz| - tz.offset :o0, 36192, 0, :LMT - tz.offset :o1, 36000, 0, :MAGT - tz.offset :o2, 39600, 0, :MAGT - tz.offset :o3, 39600, 3600, :MAGST - tz.offset :o4, 36000, 3600, :MAGST - - tz.transition 1924, 5, :o1, 2181516373, 900 - tz.transition 1930, 6, :o2, 29113777, 12 - tz.transition 1981, 3, :o3, 354891600 - tz.transition 1981, 9, :o2, 370699200 - tz.transition 1982, 3, :o3, 386427600 - tz.transition 1982, 9, :o2, 402235200 - tz.transition 1983, 3, :o3, 417963600 - tz.transition 1983, 9, :o2, 433771200 - tz.transition 1984, 3, :o3, 449586000 - tz.transition 1984, 9, :o2, 465318000 - tz.transition 1985, 3, :o3, 481042800 - tz.transition 1985, 9, :o2, 496767600 - tz.transition 1986, 3, :o3, 512492400 - tz.transition 1986, 9, :o2, 528217200 - tz.transition 1987, 3, :o3, 543942000 - tz.transition 1987, 9, :o2, 559666800 - tz.transition 1988, 3, :o3, 575391600 - tz.transition 1988, 9, :o2, 591116400 - tz.transition 1989, 3, :o3, 606841200 - tz.transition 1989, 9, :o2, 622566000 - tz.transition 1990, 3, :o3, 638290800 - tz.transition 1990, 9, :o2, 654620400 - tz.transition 1991, 3, :o4, 670345200 - tz.transition 1991, 9, :o1, 686073600 - tz.transition 1992, 1, :o2, 695750400 - tz.transition 1992, 3, :o3, 701784000 - tz.transition 1992, 9, :o2, 717505200 - tz.transition 1993, 3, :o3, 733244400 - tz.transition 1993, 9, :o2, 748969200 - tz.transition 1994, 3, :o3, 764694000 - tz.transition 1994, 9, :o2, 780418800 - tz.transition 1995, 3, :o3, 796143600 - tz.transition 1995, 9, :o2, 811868400 - tz.transition 1996, 3, :o3, 828198000 - tz.transition 1996, 10, :o2, 846342000 - tz.transition 1997, 3, :o3, 859647600 - tz.transition 1997, 10, :o2, 877791600 - tz.transition 1998, 3, :o3, 891097200 - tz.transition 1998, 10, :o2, 909241200 - tz.transition 1999, 3, :o3, 922546800 - tz.transition 1999, 10, :o2, 941295600 - tz.transition 2000, 3, :o3, 953996400 - tz.transition 2000, 10, :o2, 972745200 - tz.transition 2001, 3, :o3, 985446000 - tz.transition 2001, 10, :o2, 1004194800 - tz.transition 2002, 3, :o3, 1017500400 - tz.transition 2002, 10, :o2, 1035644400 - tz.transition 2003, 3, :o3, 1048950000 - tz.transition 2003, 10, :o2, 1067094000 - tz.transition 2004, 3, :o3, 1080399600 - tz.transition 2004, 10, :o2, 1099148400 - tz.transition 2005, 3, :o3, 1111849200 - tz.transition 2005, 10, :o2, 1130598000 - tz.transition 2006, 3, :o3, 1143298800 - tz.transition 2006, 10, :o2, 1162047600 - tz.transition 2007, 3, :o3, 1174748400 - tz.transition 2007, 10, :o2, 1193497200 - tz.transition 2008, 3, :o3, 1206802800 - tz.transition 2008, 10, :o2, 1224946800 - tz.transition 2009, 3, :o3, 1238252400 - tz.transition 2009, 10, :o2, 1256396400 - tz.transition 2010, 3, :o3, 1269702000 - tz.transition 2010, 10, :o2, 1288450800 - tz.transition 2011, 3, :o3, 1301151600 - tz.transition 2011, 10, :o2, 1319900400 - tz.transition 2012, 3, :o3, 1332601200 - tz.transition 2012, 10, :o2, 1351350000 - tz.transition 2013, 3, :o3, 1364655600 - tz.transition 2013, 10, :o2, 1382799600 - tz.transition 2014, 3, :o3, 1396105200 - tz.transition 2014, 10, :o2, 1414249200 - tz.transition 2015, 3, :o3, 1427554800 - tz.transition 2015, 10, :o2, 1445698800 - tz.transition 2016, 3, :o3, 1459004400 - tz.transition 2016, 10, :o2, 1477753200 - tz.transition 2017, 3, :o3, 1490454000 - tz.transition 2017, 10, :o2, 1509202800 - tz.transition 2018, 3, :o3, 1521903600 - tz.transition 2018, 10, :o2, 1540652400 - tz.transition 2019, 3, :o3, 1553958000 - tz.transition 2019, 10, :o2, 1572102000 - tz.transition 2020, 3, :o3, 1585407600 - tz.transition 2020, 10, :o2, 1603551600 - tz.transition 2021, 3, :o3, 1616857200 - tz.transition 2021, 10, :o2, 1635606000 - tz.transition 2022, 3, :o3, 1648306800 - tz.transition 2022, 10, :o2, 1667055600 - tz.transition 2023, 3, :o3, 1679756400 - tz.transition 2023, 10, :o2, 1698505200 - tz.transition 2024, 3, :o3, 1711810800 - tz.transition 2024, 10, :o2, 1729954800 - tz.transition 2025, 3, :o3, 1743260400 - tz.transition 2025, 10, :o2, 1761404400 - tz.transition 2026, 3, :o3, 1774710000 - tz.transition 2026, 10, :o2, 1792854000 - tz.transition 2027, 3, :o3, 1806159600 - tz.transition 2027, 10, :o2, 1824908400 - tz.transition 2028, 3, :o3, 1837609200 - tz.transition 2028, 10, :o2, 1856358000 - tz.transition 2029, 3, :o3, 1869058800 - tz.transition 2029, 10, :o2, 1887807600 - tz.transition 2030, 3, :o3, 1901113200 - tz.transition 2030, 10, :o2, 1919257200 - tz.transition 2031, 3, :o3, 1932562800 - tz.transition 2031, 10, :o2, 1950706800 - tz.transition 2032, 3, :o3, 1964012400 - tz.transition 2032, 10, :o2, 1982761200 - tz.transition 2033, 3, :o3, 1995462000 - tz.transition 2033, 10, :o2, 2014210800 - tz.transition 2034, 3, :o3, 2026911600 - tz.transition 2034, 10, :o2, 2045660400 - tz.transition 2035, 3, :o3, 2058361200 - tz.transition 2035, 10, :o2, 2077110000 - tz.transition 2036, 3, :o3, 2090415600 - tz.transition 2036, 10, :o2, 2108559600 - tz.transition 2037, 3, :o3, 2121865200 - tz.transition 2037, 10, :o2, 2140009200 - tz.transition 2038, 3, :o3, 19724081, 8 - tz.transition 2038, 10, :o2, 19725817, 8 - tz.transition 2039, 3, :o3, 19726993, 8 - tz.transition 2039, 10, :o2, 19728729, 8 - tz.transition 2040, 3, :o3, 19729905, 8 - tz.transition 2040, 10, :o2, 19731641, 8 - tz.transition 2041, 3, :o3, 19732873, 8 - tz.transition 2041, 10, :o2, 19734553, 8 - tz.transition 2042, 3, :o3, 19735785, 8 - tz.transition 2042, 10, :o2, 19737465, 8 - tz.transition 2043, 3, :o3, 19738697, 8 - tz.transition 2043, 10, :o2, 19740377, 8 - tz.transition 2044, 3, :o3, 19741609, 8 - tz.transition 2044, 10, :o2, 19743345, 8 - tz.transition 2045, 3, :o3, 19744521, 8 - tz.transition 2045, 10, :o2, 19746257, 8 - tz.transition 2046, 3, :o3, 19747433, 8 - tz.transition 2046, 10, :o2, 19749169, 8 - tz.transition 2047, 3, :o3, 19750401, 8 - tz.transition 2047, 10, :o2, 19752081, 8 - tz.transition 2048, 3, :o3, 19753313, 8 - tz.transition 2048, 10, :o2, 19754993, 8 - tz.transition 2049, 3, :o3, 19756225, 8 - tz.transition 2049, 10, :o2, 19757961, 8 - tz.transition 2050, 3, :o3, 19759137, 8 - tz.transition 2050, 10, :o2, 19760873, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Muscat.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Muscat.rb deleted file mode 100644 index 604f651..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Muscat.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Muscat - include TimezoneDefinition - - timezone 'Asia/Muscat' do |tz| - tz.offset :o0, 14060, 0, :LMT - tz.offset :o1, 14400, 0, :GST - - tz.transition 1919, 12, :o1, 10464441137, 4320 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Novosibirsk.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Novosibirsk.rb deleted file mode 100644 index a4e7796..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Novosibirsk.rb +++ /dev/null @@ -1,164 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Novosibirsk - include TimezoneDefinition - - timezone 'Asia/Novosibirsk' do |tz| - tz.offset :o0, 19900, 0, :LMT - tz.offset :o1, 21600, 0, :NOVT - tz.offset :o2, 25200, 0, :NOVT - tz.offset :o3, 25200, 3600, :NOVST - tz.offset :o4, 21600, 3600, :NOVST - - tz.transition 1919, 12, :o1, 2092872833, 864 - tz.transition 1930, 6, :o2, 9704593, 4 - tz.transition 1981, 3, :o3, 354906000 - tz.transition 1981, 9, :o2, 370713600 - tz.transition 1982, 3, :o3, 386442000 - tz.transition 1982, 9, :o2, 402249600 - tz.transition 1983, 3, :o3, 417978000 - tz.transition 1983, 9, :o2, 433785600 - tz.transition 1984, 3, :o3, 449600400 - tz.transition 1984, 9, :o2, 465332400 - tz.transition 1985, 3, :o3, 481057200 - tz.transition 1985, 9, :o2, 496782000 - tz.transition 1986, 3, :o3, 512506800 - tz.transition 1986, 9, :o2, 528231600 - tz.transition 1987, 3, :o3, 543956400 - tz.transition 1987, 9, :o2, 559681200 - tz.transition 1988, 3, :o3, 575406000 - tz.transition 1988, 9, :o2, 591130800 - tz.transition 1989, 3, :o3, 606855600 - tz.transition 1989, 9, :o2, 622580400 - tz.transition 1990, 3, :o3, 638305200 - tz.transition 1990, 9, :o2, 654634800 - tz.transition 1991, 3, :o4, 670359600 - tz.transition 1991, 9, :o1, 686088000 - tz.transition 1992, 1, :o2, 695764800 - tz.transition 1992, 3, :o3, 701798400 - tz.transition 1992, 9, :o2, 717519600 - tz.transition 1993, 3, :o3, 733258800 - tz.transition 1993, 5, :o4, 738086400 - tz.transition 1993, 9, :o1, 748987200 - tz.transition 1994, 3, :o4, 764712000 - tz.transition 1994, 9, :o1, 780436800 - tz.transition 1995, 3, :o4, 796161600 - tz.transition 1995, 9, :o1, 811886400 - tz.transition 1996, 3, :o4, 828216000 - tz.transition 1996, 10, :o1, 846360000 - tz.transition 1997, 3, :o4, 859665600 - tz.transition 1997, 10, :o1, 877809600 - tz.transition 1998, 3, :o4, 891115200 - tz.transition 1998, 10, :o1, 909259200 - tz.transition 1999, 3, :o4, 922564800 - tz.transition 1999, 10, :o1, 941313600 - tz.transition 2000, 3, :o4, 954014400 - tz.transition 2000, 10, :o1, 972763200 - tz.transition 2001, 3, :o4, 985464000 - tz.transition 2001, 10, :o1, 1004212800 - tz.transition 2002, 3, :o4, 1017518400 - tz.transition 2002, 10, :o1, 1035662400 - tz.transition 2003, 3, :o4, 1048968000 - tz.transition 2003, 10, :o1, 1067112000 - tz.transition 2004, 3, :o4, 1080417600 - tz.transition 2004, 10, :o1, 1099166400 - tz.transition 2005, 3, :o4, 1111867200 - tz.transition 2005, 10, :o1, 1130616000 - tz.transition 2006, 3, :o4, 1143316800 - tz.transition 2006, 10, :o1, 1162065600 - tz.transition 2007, 3, :o4, 1174766400 - tz.transition 2007, 10, :o1, 1193515200 - tz.transition 2008, 3, :o4, 1206820800 - tz.transition 2008, 10, :o1, 1224964800 - tz.transition 2009, 3, :o4, 1238270400 - tz.transition 2009, 10, :o1, 1256414400 - tz.transition 2010, 3, :o4, 1269720000 - tz.transition 2010, 10, :o1, 1288468800 - tz.transition 2011, 3, :o4, 1301169600 - tz.transition 2011, 10, :o1, 1319918400 - tz.transition 2012, 3, :o4, 1332619200 - tz.transition 2012, 10, :o1, 1351368000 - tz.transition 2013, 3, :o4, 1364673600 - tz.transition 2013, 10, :o1, 1382817600 - tz.transition 2014, 3, :o4, 1396123200 - tz.transition 2014, 10, :o1, 1414267200 - tz.transition 2015, 3, :o4, 1427572800 - tz.transition 2015, 10, :o1, 1445716800 - tz.transition 2016, 3, :o4, 1459022400 - tz.transition 2016, 10, :o1, 1477771200 - tz.transition 2017, 3, :o4, 1490472000 - tz.transition 2017, 10, :o1, 1509220800 - tz.transition 2018, 3, :o4, 1521921600 - tz.transition 2018, 10, :o1, 1540670400 - tz.transition 2019, 3, :o4, 1553976000 - tz.transition 2019, 10, :o1, 1572120000 - tz.transition 2020, 3, :o4, 1585425600 - tz.transition 2020, 10, :o1, 1603569600 - tz.transition 2021, 3, :o4, 1616875200 - tz.transition 2021, 10, :o1, 1635624000 - tz.transition 2022, 3, :o4, 1648324800 - tz.transition 2022, 10, :o1, 1667073600 - tz.transition 2023, 3, :o4, 1679774400 - tz.transition 2023, 10, :o1, 1698523200 - tz.transition 2024, 3, :o4, 1711828800 - tz.transition 2024, 10, :o1, 1729972800 - tz.transition 2025, 3, :o4, 1743278400 - tz.transition 2025, 10, :o1, 1761422400 - tz.transition 2026, 3, :o4, 1774728000 - tz.transition 2026, 10, :o1, 1792872000 - tz.transition 2027, 3, :o4, 1806177600 - tz.transition 2027, 10, :o1, 1824926400 - tz.transition 2028, 3, :o4, 1837627200 - tz.transition 2028, 10, :o1, 1856376000 - tz.transition 2029, 3, :o4, 1869076800 - tz.transition 2029, 10, :o1, 1887825600 - tz.transition 2030, 3, :o4, 1901131200 - tz.transition 2030, 10, :o1, 1919275200 - tz.transition 2031, 3, :o4, 1932580800 - tz.transition 2031, 10, :o1, 1950724800 - tz.transition 2032, 3, :o4, 1964030400 - tz.transition 2032, 10, :o1, 1982779200 - tz.transition 2033, 3, :o4, 1995480000 - tz.transition 2033, 10, :o1, 2014228800 - tz.transition 2034, 3, :o4, 2026929600 - tz.transition 2034, 10, :o1, 2045678400 - tz.transition 2035, 3, :o4, 2058379200 - tz.transition 2035, 10, :o1, 2077128000 - tz.transition 2036, 3, :o4, 2090433600 - tz.transition 2036, 10, :o1, 2108577600 - tz.transition 2037, 3, :o4, 2121883200 - tz.transition 2037, 10, :o1, 2140027200 - tz.transition 2038, 3, :o4, 7396531, 3 - tz.transition 2038, 10, :o1, 7397182, 3 - tz.transition 2039, 3, :o4, 7397623, 3 - tz.transition 2039, 10, :o1, 7398274, 3 - tz.transition 2040, 3, :o4, 7398715, 3 - tz.transition 2040, 10, :o1, 7399366, 3 - tz.transition 2041, 3, :o4, 7399828, 3 - tz.transition 2041, 10, :o1, 7400458, 3 - tz.transition 2042, 3, :o4, 7400920, 3 - tz.transition 2042, 10, :o1, 7401550, 3 - tz.transition 2043, 3, :o4, 7402012, 3 - tz.transition 2043, 10, :o1, 7402642, 3 - tz.transition 2044, 3, :o4, 7403104, 3 - tz.transition 2044, 10, :o1, 7403755, 3 - tz.transition 2045, 3, :o4, 7404196, 3 - tz.transition 2045, 10, :o1, 7404847, 3 - tz.transition 2046, 3, :o4, 7405288, 3 - tz.transition 2046, 10, :o1, 7405939, 3 - tz.transition 2047, 3, :o4, 7406401, 3 - tz.transition 2047, 10, :o1, 7407031, 3 - tz.transition 2048, 3, :o4, 7407493, 3 - tz.transition 2048, 10, :o1, 7408123, 3 - tz.transition 2049, 3, :o4, 7408585, 3 - tz.transition 2049, 10, :o1, 7409236, 3 - tz.transition 2050, 3, :o4, 7409677, 3 - tz.transition 2050, 10, :o1, 7410328, 3 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Rangoon.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Rangoon.rb deleted file mode 100644 index 759b82d..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Rangoon.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Rangoon - include TimezoneDefinition - - timezone 'Asia/Rangoon' do |tz| - tz.offset :o0, 23080, 0, :LMT - tz.offset :o1, 23076, 0, :RMT - tz.offset :o2, 23400, 0, :BURT - tz.offset :o3, 32400, 0, :JST - tz.offset :o4, 23400, 0, :MMT - - tz.transition 1879, 12, :o1, 5200664903, 2160 - tz.transition 1919, 12, :o2, 5813578159, 2400 - tz.transition 1942, 4, :o3, 116663051, 48 - tz.transition 1945, 5, :o4, 19452625, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Riyadh.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Riyadh.rb deleted file mode 100644 index 7add410..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Riyadh.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Riyadh - include TimezoneDefinition - - timezone 'Asia/Riyadh' do |tz| - tz.offset :o0, 11212, 0, :LMT - tz.offset :o1, 10800, 0, :AST - - tz.transition 1949, 12, :o1, 52558899197, 21600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Seoul.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Seoul.rb deleted file mode 100644 index 795d2a7..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Seoul.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Seoul - include TimezoneDefinition - - timezone 'Asia/Seoul' do |tz| - tz.offset :o0, 30472, 0, :LMT - tz.offset :o1, 30600, 0, :KST - tz.offset :o2, 32400, 0, :KST - tz.offset :o3, 28800, 0, :KST - tz.offset :o4, 28800, 3600, :KDT - tz.offset :o5, 32400, 3600, :KDT - - tz.transition 1889, 12, :o1, 26042775991, 10800 - tz.transition 1904, 11, :o2, 116007127, 48 - tz.transition 1927, 12, :o1, 19401969, 8 - tz.transition 1931, 12, :o2, 116481943, 48 - tz.transition 1954, 3, :o3, 19478577, 8 - tz.transition 1960, 5, :o4, 14622415, 6 - tz.transition 1960, 9, :o3, 19497521, 8 - tz.transition 1961, 8, :o1, 14625127, 6 - tz.transition 1968, 9, :o2, 117126247, 48 - tz.transition 1987, 5, :o5, 547570800 - tz.transition 1987, 10, :o2, 560872800 - tz.transition 1988, 5, :o5, 579020400 - tz.transition 1988, 10, :o2, 592322400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Shanghai.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Shanghai.rb deleted file mode 100644 index 34b13d5..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Shanghai.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Shanghai - include TimezoneDefinition - - timezone 'Asia/Shanghai' do |tz| - tz.offset :o0, 29152, 0, :LMT - tz.offset :o1, 28800, 0, :CST - tz.offset :o2, 28800, 3600, :CDT - - tz.transition 1927, 12, :o1, 6548164639, 2700 - tz.transition 1940, 6, :o2, 14578699, 6 - tz.transition 1940, 9, :o1, 19439225, 8 - tz.transition 1941, 3, :o2, 14580415, 6 - tz.transition 1941, 9, :o1, 19442145, 8 - tz.transition 1986, 5, :o2, 515520000 - tz.transition 1986, 9, :o1, 527007600 - tz.transition 1987, 4, :o2, 545155200 - tz.transition 1987, 9, :o1, 558457200 - tz.transition 1988, 4, :o2, 576604800 - tz.transition 1988, 9, :o1, 589906800 - tz.transition 1989, 4, :o2, 608659200 - tz.transition 1989, 9, :o1, 621961200 - tz.transition 1990, 4, :o2, 640108800 - tz.transition 1990, 9, :o1, 653410800 - tz.transition 1991, 4, :o2, 671558400 - tz.transition 1991, 9, :o1, 684860400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Singapore.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Singapore.rb deleted file mode 100644 index b323a78..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Singapore.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Singapore - include TimezoneDefinition - - timezone 'Asia/Singapore' do |tz| - tz.offset :o0, 24925, 0, :LMT - tz.offset :o1, 24925, 0, :SMT - tz.offset :o2, 25200, 0, :MALT - tz.offset :o3, 25200, 1200, :MALST - tz.offset :o4, 26400, 0, :MALT - tz.offset :o5, 27000, 0, :MALT - tz.offset :o6, 32400, 0, :JST - tz.offset :o7, 27000, 0, :SGT - tz.offset :o8, 28800, 0, :SGT - - tz.transition 1900, 12, :o1, 8347571291, 3456 - tz.transition 1905, 5, :o2, 8353142363, 3456 - tz.transition 1932, 12, :o3, 58249757, 24 - tz.transition 1935, 12, :o4, 87414055, 36 - tz.transition 1941, 8, :o5, 87488575, 36 - tz.transition 1942, 2, :o6, 38886499, 16 - tz.transition 1945, 9, :o5, 19453681, 8 - tz.transition 1965, 8, :o7, 39023699, 16 - tz.transition 1981, 12, :o8, 378664200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Taipei.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Taipei.rb deleted file mode 100644 index 3ba1210..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Taipei.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Taipei - include TimezoneDefinition - - timezone 'Asia/Taipei' do |tz| - tz.offset :o0, 29160, 0, :LMT - tz.offset :o1, 28800, 0, :CST - tz.offset :o2, 28800, 3600, :CDT - - tz.transition 1895, 12, :o1, 193084733, 80 - tz.transition 1945, 4, :o2, 14589457, 6 - tz.transition 1945, 9, :o1, 19453833, 8 - tz.transition 1946, 4, :o2, 14591647, 6 - tz.transition 1946, 9, :o1, 19456753, 8 - tz.transition 1947, 4, :o2, 14593837, 6 - tz.transition 1947, 9, :o1, 19459673, 8 - tz.transition 1948, 4, :o2, 14596033, 6 - tz.transition 1948, 9, :o1, 19462601, 8 - tz.transition 1949, 4, :o2, 14598223, 6 - tz.transition 1949, 9, :o1, 19465521, 8 - tz.transition 1950, 4, :o2, 14600413, 6 - tz.transition 1950, 9, :o1, 19468441, 8 - tz.transition 1951, 4, :o2, 14602603, 6 - tz.transition 1951, 9, :o1, 19471361, 8 - tz.transition 1952, 2, :o2, 14604433, 6 - tz.transition 1952, 10, :o1, 19474537, 8 - tz.transition 1953, 3, :o2, 14606809, 6 - tz.transition 1953, 10, :o1, 19477457, 8 - tz.transition 1954, 3, :o2, 14608999, 6 - tz.transition 1954, 10, :o1, 19480377, 8 - tz.transition 1955, 3, :o2, 14611189, 6 - tz.transition 1955, 9, :o1, 19483049, 8 - tz.transition 1956, 3, :o2, 14613385, 6 - tz.transition 1956, 9, :o1, 19485977, 8 - tz.transition 1957, 3, :o2, 14615575, 6 - tz.transition 1957, 9, :o1, 19488897, 8 - tz.transition 1958, 3, :o2, 14617765, 6 - tz.transition 1958, 9, :o1, 19491817, 8 - tz.transition 1959, 3, :o2, 14619955, 6 - tz.transition 1959, 9, :o1, 19494737, 8 - tz.transition 1960, 5, :o2, 14622517, 6 - tz.transition 1960, 9, :o1, 19497665, 8 - tz.transition 1961, 5, :o2, 14624707, 6 - tz.transition 1961, 9, :o1, 19500585, 8 - tz.transition 1974, 3, :o2, 133977600 - tz.transition 1974, 9, :o1, 149785200 - tz.transition 1975, 3, :o2, 165513600 - tz.transition 1975, 9, :o1, 181321200 - tz.transition 1980, 6, :o2, 331142400 - tz.transition 1980, 9, :o1, 339087600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tashkent.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tashkent.rb deleted file mode 100644 index c205c79..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tashkent.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Tashkent - include TimezoneDefinition - - timezone 'Asia/Tashkent' do |tz| - tz.offset :o0, 16632, 0, :LMT - tz.offset :o1, 18000, 0, :TAST - tz.offset :o2, 21600, 0, :TAST - tz.offset :o3, 21600, 3600, :TASST - tz.offset :o4, 18000, 3600, :TASST - tz.offset :o5, 18000, 3600, :UZST - tz.offset :o6, 18000, 0, :UZT - - tz.transition 1924, 5, :o1, 969562923, 400 - tz.transition 1930, 6, :o2, 58227559, 24 - tz.transition 1981, 3, :o3, 354909600 - tz.transition 1981, 9, :o2, 370717200 - tz.transition 1982, 3, :o3, 386445600 - tz.transition 1982, 9, :o2, 402253200 - tz.transition 1983, 3, :o3, 417981600 - tz.transition 1983, 9, :o2, 433789200 - tz.transition 1984, 3, :o3, 449604000 - tz.transition 1984, 9, :o2, 465336000 - tz.transition 1985, 3, :o3, 481060800 - tz.transition 1985, 9, :o2, 496785600 - tz.transition 1986, 3, :o3, 512510400 - tz.transition 1986, 9, :o2, 528235200 - tz.transition 1987, 3, :o3, 543960000 - tz.transition 1987, 9, :o2, 559684800 - tz.transition 1988, 3, :o3, 575409600 - tz.transition 1988, 9, :o2, 591134400 - tz.transition 1989, 3, :o3, 606859200 - tz.transition 1989, 9, :o2, 622584000 - tz.transition 1990, 3, :o3, 638308800 - tz.transition 1990, 9, :o2, 654638400 - tz.transition 1991, 3, :o4, 670363200 - tz.transition 1991, 8, :o5, 683661600 - tz.transition 1991, 9, :o6, 686091600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tbilisi.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tbilisi.rb deleted file mode 100644 index 15792a5..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tbilisi.rb +++ /dev/null @@ -1,78 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Tbilisi - include TimezoneDefinition - - timezone 'Asia/Tbilisi' do |tz| - tz.offset :o0, 10756, 0, :LMT - tz.offset :o1, 10756, 0, :TBMT - tz.offset :o2, 10800, 0, :TBIT - tz.offset :o3, 14400, 0, :TBIT - tz.offset :o4, 14400, 3600, :TBIST - tz.offset :o5, 10800, 3600, :TBIST - tz.offset :o6, 10800, 3600, :GEST - tz.offset :o7, 10800, 0, :GET - tz.offset :o8, 14400, 0, :GET - tz.offset :o9, 14400, 3600, :GEST - - tz.transition 1879, 12, :o1, 52006652111, 21600 - tz.transition 1924, 5, :o2, 52356399311, 21600 - tz.transition 1957, 2, :o3, 19487187, 8 - tz.transition 1981, 3, :o4, 354916800 - tz.transition 1981, 9, :o3, 370724400 - tz.transition 1982, 3, :o4, 386452800 - tz.transition 1982, 9, :o3, 402260400 - tz.transition 1983, 3, :o4, 417988800 - tz.transition 1983, 9, :o3, 433796400 - tz.transition 1984, 3, :o4, 449611200 - tz.transition 1984, 9, :o3, 465343200 - tz.transition 1985, 3, :o4, 481068000 - tz.transition 1985, 9, :o3, 496792800 - tz.transition 1986, 3, :o4, 512517600 - tz.transition 1986, 9, :o3, 528242400 - tz.transition 1987, 3, :o4, 543967200 - tz.transition 1987, 9, :o3, 559692000 - tz.transition 1988, 3, :o4, 575416800 - tz.transition 1988, 9, :o3, 591141600 - tz.transition 1989, 3, :o4, 606866400 - tz.transition 1989, 9, :o3, 622591200 - tz.transition 1990, 3, :o4, 638316000 - tz.transition 1990, 9, :o3, 654645600 - tz.transition 1991, 3, :o5, 670370400 - tz.transition 1991, 4, :o6, 671140800 - tz.transition 1991, 9, :o7, 686098800 - tz.transition 1992, 3, :o6, 701816400 - tz.transition 1992, 9, :o7, 717537600 - tz.transition 1993, 3, :o6, 733266000 - tz.transition 1993, 9, :o7, 748987200 - tz.transition 1994, 3, :o6, 764715600 - tz.transition 1994, 9, :o8, 780436800 - tz.transition 1995, 3, :o9, 796161600 - tz.transition 1995, 9, :o8, 811882800 - tz.transition 1996, 3, :o9, 828216000 - tz.transition 1997, 3, :o9, 859662000 - tz.transition 1997, 10, :o8, 877806000 - tz.transition 1998, 3, :o9, 891115200 - tz.transition 1998, 10, :o8, 909255600 - tz.transition 1999, 3, :o9, 922564800 - tz.transition 1999, 10, :o8, 941310000 - tz.transition 2000, 3, :o9, 954014400 - tz.transition 2000, 10, :o8, 972759600 - tz.transition 2001, 3, :o9, 985464000 - tz.transition 2001, 10, :o8, 1004209200 - tz.transition 2002, 3, :o9, 1017518400 - tz.transition 2002, 10, :o8, 1035658800 - tz.transition 2003, 3, :o9, 1048968000 - tz.transition 2003, 10, :o8, 1067108400 - tz.transition 2004, 3, :o9, 1080417600 - tz.transition 2004, 6, :o6, 1088276400 - tz.transition 2004, 10, :o7, 1099177200 - tz.transition 2005, 3, :o8, 1111878000 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tehran.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tehran.rb deleted file mode 100644 index d8df964..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tehran.rb +++ /dev/null @@ -1,121 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Tehran - include TimezoneDefinition - - timezone 'Asia/Tehran' do |tz| - tz.offset :o0, 12344, 0, :LMT - tz.offset :o1, 12344, 0, :TMT - tz.offset :o2, 12600, 0, :IRST - tz.offset :o3, 14400, 0, :IRST - tz.offset :o4, 14400, 3600, :IRDT - tz.offset :o5, 12600, 3600, :IRDT - - tz.transition 1915, 12, :o1, 26145324257, 10800 - tz.transition 1945, 12, :o2, 26263670657, 10800 - tz.transition 1977, 10, :o3, 247177800 - tz.transition 1978, 3, :o4, 259272000 - tz.transition 1978, 10, :o3, 277758000 - tz.transition 1978, 12, :o2, 283982400 - tz.transition 1979, 3, :o5, 290809800 - tz.transition 1979, 9, :o2, 306531000 - tz.transition 1980, 3, :o5, 322432200 - tz.transition 1980, 9, :o2, 338499000 - tz.transition 1991, 5, :o5, 673216200 - tz.transition 1991, 9, :o2, 685481400 - tz.transition 1992, 3, :o5, 701209800 - tz.transition 1992, 9, :o2, 717103800 - tz.transition 1993, 3, :o5, 732745800 - tz.transition 1993, 9, :o2, 748639800 - tz.transition 1994, 3, :o5, 764281800 - tz.transition 1994, 9, :o2, 780175800 - tz.transition 1995, 3, :o5, 795817800 - tz.transition 1995, 9, :o2, 811711800 - tz.transition 1996, 3, :o5, 827353800 - tz.transition 1996, 9, :o2, 843247800 - tz.transition 1997, 3, :o5, 858976200 - tz.transition 1997, 9, :o2, 874870200 - tz.transition 1998, 3, :o5, 890512200 - tz.transition 1998, 9, :o2, 906406200 - tz.transition 1999, 3, :o5, 922048200 - tz.transition 1999, 9, :o2, 937942200 - tz.transition 2000, 3, :o5, 953584200 - tz.transition 2000, 9, :o2, 969478200 - tz.transition 2001, 3, :o5, 985206600 - tz.transition 2001, 9, :o2, 1001100600 - tz.transition 2002, 3, :o5, 1016742600 - tz.transition 2002, 9, :o2, 1032636600 - tz.transition 2003, 3, :o5, 1048278600 - tz.transition 2003, 9, :o2, 1064172600 - tz.transition 2004, 3, :o5, 1079814600 - tz.transition 2004, 9, :o2, 1095708600 - tz.transition 2005, 3, :o5, 1111437000 - tz.transition 2005, 9, :o2, 1127331000 - tz.transition 2008, 3, :o5, 1206045000 - tz.transition 2008, 9, :o2, 1221939000 - tz.transition 2009, 3, :o5, 1237667400 - tz.transition 2009, 9, :o2, 1253561400 - tz.transition 2010, 3, :o5, 1269203400 - tz.transition 2010, 9, :o2, 1285097400 - tz.transition 2011, 3, :o5, 1300739400 - tz.transition 2011, 9, :o2, 1316633400 - tz.transition 2012, 3, :o5, 1332275400 - tz.transition 2012, 9, :o2, 1348169400 - tz.transition 2013, 3, :o5, 1363897800 - tz.transition 2013, 9, :o2, 1379791800 - tz.transition 2014, 3, :o5, 1395433800 - tz.transition 2014, 9, :o2, 1411327800 - tz.transition 2015, 3, :o5, 1426969800 - tz.transition 2015, 9, :o2, 1442863800 - tz.transition 2016, 3, :o5, 1458505800 - tz.transition 2016, 9, :o2, 1474399800 - tz.transition 2017, 3, :o5, 1490128200 - tz.transition 2017, 9, :o2, 1506022200 - tz.transition 2018, 3, :o5, 1521664200 - tz.transition 2018, 9, :o2, 1537558200 - tz.transition 2019, 3, :o5, 1553200200 - tz.transition 2019, 9, :o2, 1569094200 - tz.transition 2020, 3, :o5, 1584736200 - tz.transition 2020, 9, :o2, 1600630200 - tz.transition 2021, 3, :o5, 1616358600 - tz.transition 2021, 9, :o2, 1632252600 - tz.transition 2022, 3, :o5, 1647894600 - tz.transition 2022, 9, :o2, 1663788600 - tz.transition 2023, 3, :o5, 1679430600 - tz.transition 2023, 9, :o2, 1695324600 - tz.transition 2024, 3, :o5, 1710966600 - tz.transition 2024, 9, :o2, 1726860600 - tz.transition 2025, 3, :o5, 1742589000 - tz.transition 2025, 9, :o2, 1758483000 - tz.transition 2026, 3, :o5, 1774125000 - tz.transition 2026, 9, :o2, 1790019000 - tz.transition 2027, 3, :o5, 1805661000 - tz.transition 2027, 9, :o2, 1821555000 - tz.transition 2028, 3, :o5, 1837197000 - tz.transition 2028, 9, :o2, 1853091000 - tz.transition 2029, 3, :o5, 1868733000 - tz.transition 2029, 9, :o2, 1884627000 - tz.transition 2030, 3, :o5, 1900355400 - tz.transition 2030, 9, :o2, 1916249400 - tz.transition 2031, 3, :o5, 1931891400 - tz.transition 2031, 9, :o2, 1947785400 - tz.transition 2032, 3, :o5, 1963427400 - tz.transition 2032, 9, :o2, 1979321400 - tz.transition 2033, 3, :o5, 1994963400 - tz.transition 2033, 9, :o2, 2010857400 - tz.transition 2034, 3, :o5, 2026585800 - tz.transition 2034, 9, :o2, 2042479800 - tz.transition 2035, 3, :o5, 2058121800 - tz.transition 2035, 9, :o2, 2074015800 - tz.transition 2036, 3, :o5, 2089657800 - tz.transition 2036, 9, :o2, 2105551800 - tz.transition 2037, 3, :o5, 2121193800 - tz.transition 2037, 9, :o2, 2137087800 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tokyo.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tokyo.rb deleted file mode 100644 index 51c9e16..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tokyo.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Tokyo - include TimezoneDefinition - - timezone 'Asia/Tokyo' do |tz| - tz.offset :o0, 33539, 0, :LMT - tz.offset :o1, 32400, 0, :JST - tz.offset :o2, 32400, 0, :CJT - tz.offset :o3, 32400, 3600, :JDT - - tz.transition 1887, 12, :o1, 19285097, 8 - tz.transition 1895, 12, :o2, 19308473, 8 - tz.transition 1937, 12, :o1, 19431193, 8 - tz.transition 1948, 5, :o3, 58384157, 24 - tz.transition 1948, 9, :o1, 14596831, 6 - tz.transition 1949, 4, :o3, 58392221, 24 - tz.transition 1949, 9, :o1, 14599015, 6 - tz.transition 1950, 5, :o3, 58401797, 24 - tz.transition 1950, 9, :o1, 14601199, 6 - tz.transition 1951, 5, :o3, 58410533, 24 - tz.transition 1951, 9, :o1, 14603383, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Ulaanbaatar.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Ulaanbaatar.rb deleted file mode 100644 index 2854f5c..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Ulaanbaatar.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Ulaanbaatar - include TimezoneDefinition - - timezone 'Asia/Ulaanbaatar' do |tz| - tz.offset :o0, 25652, 0, :LMT - tz.offset :o1, 25200, 0, :ULAT - tz.offset :o2, 28800, 0, :ULAT - tz.offset :o3, 28800, 3600, :ULAST - - tz.transition 1905, 7, :o1, 52208457187, 21600 - tz.transition 1977, 12, :o2, 252435600 - tz.transition 1983, 3, :o3, 417974400 - tz.transition 1983, 9, :o2, 433782000 - tz.transition 1984, 3, :o3, 449596800 - tz.transition 1984, 9, :o2, 465318000 - tz.transition 1985, 3, :o3, 481046400 - tz.transition 1985, 9, :o2, 496767600 - tz.transition 1986, 3, :o3, 512496000 - tz.transition 1986, 9, :o2, 528217200 - tz.transition 1987, 3, :o3, 543945600 - tz.transition 1987, 9, :o2, 559666800 - tz.transition 1988, 3, :o3, 575395200 - tz.transition 1988, 9, :o2, 591116400 - tz.transition 1989, 3, :o3, 606844800 - tz.transition 1989, 9, :o2, 622566000 - tz.transition 1990, 3, :o3, 638294400 - tz.transition 1990, 9, :o2, 654620400 - tz.transition 1991, 3, :o3, 670348800 - tz.transition 1991, 9, :o2, 686070000 - tz.transition 1992, 3, :o3, 701798400 - tz.transition 1992, 9, :o2, 717519600 - tz.transition 1993, 3, :o3, 733248000 - tz.transition 1993, 9, :o2, 748969200 - tz.transition 1994, 3, :o3, 764697600 - tz.transition 1994, 9, :o2, 780418800 - tz.transition 1995, 3, :o3, 796147200 - tz.transition 1995, 9, :o2, 811868400 - tz.transition 1996, 3, :o3, 828201600 - tz.transition 1996, 9, :o2, 843922800 - tz.transition 1997, 3, :o3, 859651200 - tz.transition 1997, 9, :o2, 875372400 - tz.transition 1998, 3, :o3, 891100800 - tz.transition 1998, 9, :o2, 906822000 - tz.transition 2001, 4, :o3, 988394400 - tz.transition 2001, 9, :o2, 1001696400 - tz.transition 2002, 3, :o3, 1017424800 - tz.transition 2002, 9, :o2, 1033146000 - tz.transition 2003, 3, :o3, 1048874400 - tz.transition 2003, 9, :o2, 1064595600 - tz.transition 2004, 3, :o3, 1080324000 - tz.transition 2004, 9, :o2, 1096045200 - tz.transition 2005, 3, :o3, 1111773600 - tz.transition 2005, 9, :o2, 1127494800 - tz.transition 2006, 3, :o3, 1143223200 - tz.transition 2006, 9, :o2, 1159549200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Urumqi.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Urumqi.rb deleted file mode 100644 index d793ff1..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Urumqi.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Urumqi - include TimezoneDefinition - - timezone 'Asia/Urumqi' do |tz| - tz.offset :o0, 21020, 0, :LMT - tz.offset :o1, 21600, 0, :URUT - tz.offset :o2, 28800, 0, :CST - tz.offset :o3, 28800, 3600, :CDT - - tz.transition 1927, 12, :o1, 10477063829, 4320 - tz.transition 1980, 4, :o2, 325965600 - tz.transition 1986, 5, :o3, 515520000 - tz.transition 1986, 9, :o2, 527007600 - tz.transition 1987, 4, :o3, 545155200 - tz.transition 1987, 9, :o2, 558457200 - tz.transition 1988, 4, :o3, 576604800 - tz.transition 1988, 9, :o2, 589906800 - tz.transition 1989, 4, :o3, 608659200 - tz.transition 1989, 9, :o2, 621961200 - tz.transition 1990, 4, :o3, 640108800 - tz.transition 1990, 9, :o2, 653410800 - tz.transition 1991, 4, :o3, 671558400 - tz.transition 1991, 9, :o2, 684860400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Vladivostok.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Vladivostok.rb deleted file mode 100644 index bd9e3d6..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Vladivostok.rb +++ /dev/null @@ -1,164 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Vladivostok - include TimezoneDefinition - - timezone 'Asia/Vladivostok' do |tz| - tz.offset :o0, 31664, 0, :LMT - tz.offset :o1, 32400, 0, :VLAT - tz.offset :o2, 36000, 0, :VLAT - tz.offset :o3, 36000, 3600, :VLAST - tz.offset :o4, 32400, 3600, :VLASST - tz.offset :o5, 32400, 0, :VLAST - - tz.transition 1922, 11, :o1, 13086214921, 5400 - tz.transition 1930, 6, :o2, 19409185, 8 - tz.transition 1981, 3, :o3, 354895200 - tz.transition 1981, 9, :o2, 370702800 - tz.transition 1982, 3, :o3, 386431200 - tz.transition 1982, 9, :o2, 402238800 - tz.transition 1983, 3, :o3, 417967200 - tz.transition 1983, 9, :o2, 433774800 - tz.transition 1984, 3, :o3, 449589600 - tz.transition 1984, 9, :o2, 465321600 - tz.transition 1985, 3, :o3, 481046400 - tz.transition 1985, 9, :o2, 496771200 - tz.transition 1986, 3, :o3, 512496000 - tz.transition 1986, 9, :o2, 528220800 - tz.transition 1987, 3, :o3, 543945600 - tz.transition 1987, 9, :o2, 559670400 - tz.transition 1988, 3, :o3, 575395200 - tz.transition 1988, 9, :o2, 591120000 - tz.transition 1989, 3, :o3, 606844800 - tz.transition 1989, 9, :o2, 622569600 - tz.transition 1990, 3, :o3, 638294400 - tz.transition 1990, 9, :o2, 654624000 - tz.transition 1991, 3, :o4, 670348800 - tz.transition 1991, 9, :o5, 686077200 - tz.transition 1992, 1, :o2, 695754000 - tz.transition 1992, 3, :o3, 701787600 - tz.transition 1992, 9, :o2, 717508800 - tz.transition 1993, 3, :o3, 733248000 - tz.transition 1993, 9, :o2, 748972800 - tz.transition 1994, 3, :o3, 764697600 - tz.transition 1994, 9, :o2, 780422400 - tz.transition 1995, 3, :o3, 796147200 - tz.transition 1995, 9, :o2, 811872000 - tz.transition 1996, 3, :o3, 828201600 - tz.transition 1996, 10, :o2, 846345600 - tz.transition 1997, 3, :o3, 859651200 - tz.transition 1997, 10, :o2, 877795200 - tz.transition 1998, 3, :o3, 891100800 - tz.transition 1998, 10, :o2, 909244800 - tz.transition 1999, 3, :o3, 922550400 - tz.transition 1999, 10, :o2, 941299200 - tz.transition 2000, 3, :o3, 954000000 - tz.transition 2000, 10, :o2, 972748800 - tz.transition 2001, 3, :o3, 985449600 - tz.transition 2001, 10, :o2, 1004198400 - tz.transition 2002, 3, :o3, 1017504000 - tz.transition 2002, 10, :o2, 1035648000 - tz.transition 2003, 3, :o3, 1048953600 - tz.transition 2003, 10, :o2, 1067097600 - tz.transition 2004, 3, :o3, 1080403200 - tz.transition 2004, 10, :o2, 1099152000 - tz.transition 2005, 3, :o3, 1111852800 - tz.transition 2005, 10, :o2, 1130601600 - tz.transition 2006, 3, :o3, 1143302400 - tz.transition 2006, 10, :o2, 1162051200 - tz.transition 2007, 3, :o3, 1174752000 - tz.transition 2007, 10, :o2, 1193500800 - tz.transition 2008, 3, :o3, 1206806400 - tz.transition 2008, 10, :o2, 1224950400 - tz.transition 2009, 3, :o3, 1238256000 - tz.transition 2009, 10, :o2, 1256400000 - tz.transition 2010, 3, :o3, 1269705600 - tz.transition 2010, 10, :o2, 1288454400 - tz.transition 2011, 3, :o3, 1301155200 - tz.transition 2011, 10, :o2, 1319904000 - tz.transition 2012, 3, :o3, 1332604800 - tz.transition 2012, 10, :o2, 1351353600 - tz.transition 2013, 3, :o3, 1364659200 - tz.transition 2013, 10, :o2, 1382803200 - tz.transition 2014, 3, :o3, 1396108800 - tz.transition 2014, 10, :o2, 1414252800 - tz.transition 2015, 3, :o3, 1427558400 - tz.transition 2015, 10, :o2, 1445702400 - tz.transition 2016, 3, :o3, 1459008000 - tz.transition 2016, 10, :o2, 1477756800 - tz.transition 2017, 3, :o3, 1490457600 - tz.transition 2017, 10, :o2, 1509206400 - tz.transition 2018, 3, :o3, 1521907200 - tz.transition 2018, 10, :o2, 1540656000 - tz.transition 2019, 3, :o3, 1553961600 - tz.transition 2019, 10, :o2, 1572105600 - tz.transition 2020, 3, :o3, 1585411200 - tz.transition 2020, 10, :o2, 1603555200 - tz.transition 2021, 3, :o3, 1616860800 - tz.transition 2021, 10, :o2, 1635609600 - tz.transition 2022, 3, :o3, 1648310400 - tz.transition 2022, 10, :o2, 1667059200 - tz.transition 2023, 3, :o3, 1679760000 - tz.transition 2023, 10, :o2, 1698508800 - tz.transition 2024, 3, :o3, 1711814400 - tz.transition 2024, 10, :o2, 1729958400 - tz.transition 2025, 3, :o3, 1743264000 - tz.transition 2025, 10, :o2, 1761408000 - tz.transition 2026, 3, :o3, 1774713600 - tz.transition 2026, 10, :o2, 1792857600 - tz.transition 2027, 3, :o3, 1806163200 - tz.transition 2027, 10, :o2, 1824912000 - tz.transition 2028, 3, :o3, 1837612800 - tz.transition 2028, 10, :o2, 1856361600 - tz.transition 2029, 3, :o3, 1869062400 - tz.transition 2029, 10, :o2, 1887811200 - tz.transition 2030, 3, :o3, 1901116800 - tz.transition 2030, 10, :o2, 1919260800 - tz.transition 2031, 3, :o3, 1932566400 - tz.transition 2031, 10, :o2, 1950710400 - tz.transition 2032, 3, :o3, 1964016000 - tz.transition 2032, 10, :o2, 1982764800 - tz.transition 2033, 3, :o3, 1995465600 - tz.transition 2033, 10, :o2, 2014214400 - tz.transition 2034, 3, :o3, 2026915200 - tz.transition 2034, 10, :o2, 2045664000 - tz.transition 2035, 3, :o3, 2058364800 - tz.transition 2035, 10, :o2, 2077113600 - tz.transition 2036, 3, :o3, 2090419200 - tz.transition 2036, 10, :o2, 2108563200 - tz.transition 2037, 3, :o3, 2121868800 - tz.transition 2037, 10, :o2, 2140012800 - tz.transition 2038, 3, :o3, 14793061, 6 - tz.transition 2038, 10, :o2, 14794363, 6 - tz.transition 2039, 3, :o3, 14795245, 6 - tz.transition 2039, 10, :o2, 14796547, 6 - tz.transition 2040, 3, :o3, 14797429, 6 - tz.transition 2040, 10, :o2, 14798731, 6 - tz.transition 2041, 3, :o3, 14799655, 6 - tz.transition 2041, 10, :o2, 14800915, 6 - tz.transition 2042, 3, :o3, 14801839, 6 - tz.transition 2042, 10, :o2, 14803099, 6 - tz.transition 2043, 3, :o3, 14804023, 6 - tz.transition 2043, 10, :o2, 14805283, 6 - tz.transition 2044, 3, :o3, 14806207, 6 - tz.transition 2044, 10, :o2, 14807509, 6 - tz.transition 2045, 3, :o3, 14808391, 6 - tz.transition 2045, 10, :o2, 14809693, 6 - tz.transition 2046, 3, :o3, 14810575, 6 - tz.transition 2046, 10, :o2, 14811877, 6 - tz.transition 2047, 3, :o3, 14812801, 6 - tz.transition 2047, 10, :o2, 14814061, 6 - tz.transition 2048, 3, :o3, 14814985, 6 - tz.transition 2048, 10, :o2, 14816245, 6 - tz.transition 2049, 3, :o3, 14817169, 6 - tz.transition 2049, 10, :o2, 14818471, 6 - tz.transition 2050, 3, :o3, 14819353, 6 - tz.transition 2050, 10, :o2, 14820655, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yakutsk.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yakutsk.rb deleted file mode 100644 index 56435a7..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yakutsk.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Yakutsk - include TimezoneDefinition - - timezone 'Asia/Yakutsk' do |tz| - tz.offset :o0, 31120, 0, :LMT - tz.offset :o1, 28800, 0, :YAKT - tz.offset :o2, 32400, 0, :YAKT - tz.offset :o3, 32400, 3600, :YAKST - tz.offset :o4, 28800, 3600, :YAKST - - tz.transition 1919, 12, :o1, 2616091711, 1080 - tz.transition 1930, 6, :o2, 14556889, 6 - tz.transition 1981, 3, :o3, 354898800 - tz.transition 1981, 9, :o2, 370706400 - tz.transition 1982, 3, :o3, 386434800 - tz.transition 1982, 9, :o2, 402242400 - tz.transition 1983, 3, :o3, 417970800 - tz.transition 1983, 9, :o2, 433778400 - tz.transition 1984, 3, :o3, 449593200 - tz.transition 1984, 9, :o2, 465325200 - tz.transition 1985, 3, :o3, 481050000 - tz.transition 1985, 9, :o2, 496774800 - tz.transition 1986, 3, :o3, 512499600 - tz.transition 1986, 9, :o2, 528224400 - tz.transition 1987, 3, :o3, 543949200 - tz.transition 1987, 9, :o2, 559674000 - tz.transition 1988, 3, :o3, 575398800 - tz.transition 1988, 9, :o2, 591123600 - tz.transition 1989, 3, :o3, 606848400 - tz.transition 1989, 9, :o2, 622573200 - tz.transition 1990, 3, :o3, 638298000 - tz.transition 1990, 9, :o2, 654627600 - tz.transition 1991, 3, :o4, 670352400 - tz.transition 1991, 9, :o1, 686080800 - tz.transition 1992, 1, :o2, 695757600 - tz.transition 1992, 3, :o3, 701791200 - tz.transition 1992, 9, :o2, 717512400 - tz.transition 1993, 3, :o3, 733251600 - tz.transition 1993, 9, :o2, 748976400 - tz.transition 1994, 3, :o3, 764701200 - tz.transition 1994, 9, :o2, 780426000 - tz.transition 1995, 3, :o3, 796150800 - tz.transition 1995, 9, :o2, 811875600 - tz.transition 1996, 3, :o3, 828205200 - tz.transition 1996, 10, :o2, 846349200 - tz.transition 1997, 3, :o3, 859654800 - tz.transition 1997, 10, :o2, 877798800 - tz.transition 1998, 3, :o3, 891104400 - tz.transition 1998, 10, :o2, 909248400 - tz.transition 1999, 3, :o3, 922554000 - tz.transition 1999, 10, :o2, 941302800 - tz.transition 2000, 3, :o3, 954003600 - tz.transition 2000, 10, :o2, 972752400 - tz.transition 2001, 3, :o3, 985453200 - tz.transition 2001, 10, :o2, 1004202000 - tz.transition 2002, 3, :o3, 1017507600 - tz.transition 2002, 10, :o2, 1035651600 - tz.transition 2003, 3, :o3, 1048957200 - tz.transition 2003, 10, :o2, 1067101200 - tz.transition 2004, 3, :o3, 1080406800 - tz.transition 2004, 10, :o2, 1099155600 - tz.transition 2005, 3, :o3, 1111856400 - tz.transition 2005, 10, :o2, 1130605200 - tz.transition 2006, 3, :o3, 1143306000 - tz.transition 2006, 10, :o2, 1162054800 - tz.transition 2007, 3, :o3, 1174755600 - tz.transition 2007, 10, :o2, 1193504400 - tz.transition 2008, 3, :o3, 1206810000 - tz.transition 2008, 10, :o2, 1224954000 - tz.transition 2009, 3, :o3, 1238259600 - tz.transition 2009, 10, :o2, 1256403600 - tz.transition 2010, 3, :o3, 1269709200 - tz.transition 2010, 10, :o2, 1288458000 - tz.transition 2011, 3, :o3, 1301158800 - tz.transition 2011, 10, :o2, 1319907600 - tz.transition 2012, 3, :o3, 1332608400 - tz.transition 2012, 10, :o2, 1351357200 - tz.transition 2013, 3, :o3, 1364662800 - tz.transition 2013, 10, :o2, 1382806800 - tz.transition 2014, 3, :o3, 1396112400 - tz.transition 2014, 10, :o2, 1414256400 - tz.transition 2015, 3, :o3, 1427562000 - tz.transition 2015, 10, :o2, 1445706000 - tz.transition 2016, 3, :o3, 1459011600 - tz.transition 2016, 10, :o2, 1477760400 - tz.transition 2017, 3, :o3, 1490461200 - tz.transition 2017, 10, :o2, 1509210000 - tz.transition 2018, 3, :o3, 1521910800 - tz.transition 2018, 10, :o2, 1540659600 - tz.transition 2019, 3, :o3, 1553965200 - tz.transition 2019, 10, :o2, 1572109200 - tz.transition 2020, 3, :o3, 1585414800 - tz.transition 2020, 10, :o2, 1603558800 - tz.transition 2021, 3, :o3, 1616864400 - tz.transition 2021, 10, :o2, 1635613200 - tz.transition 2022, 3, :o3, 1648314000 - tz.transition 2022, 10, :o2, 1667062800 - tz.transition 2023, 3, :o3, 1679763600 - tz.transition 2023, 10, :o2, 1698512400 - tz.transition 2024, 3, :o3, 1711818000 - tz.transition 2024, 10, :o2, 1729962000 - tz.transition 2025, 3, :o3, 1743267600 - tz.transition 2025, 10, :o2, 1761411600 - tz.transition 2026, 3, :o3, 1774717200 - tz.transition 2026, 10, :o2, 1792861200 - tz.transition 2027, 3, :o3, 1806166800 - tz.transition 2027, 10, :o2, 1824915600 - tz.transition 2028, 3, :o3, 1837616400 - tz.transition 2028, 10, :o2, 1856365200 - tz.transition 2029, 3, :o3, 1869066000 - tz.transition 2029, 10, :o2, 1887814800 - tz.transition 2030, 3, :o3, 1901120400 - tz.transition 2030, 10, :o2, 1919264400 - tz.transition 2031, 3, :o3, 1932570000 - tz.transition 2031, 10, :o2, 1950714000 - tz.transition 2032, 3, :o3, 1964019600 - tz.transition 2032, 10, :o2, 1982768400 - tz.transition 2033, 3, :o3, 1995469200 - tz.transition 2033, 10, :o2, 2014218000 - tz.transition 2034, 3, :o3, 2026918800 - tz.transition 2034, 10, :o2, 2045667600 - tz.transition 2035, 3, :o3, 2058368400 - tz.transition 2035, 10, :o2, 2077117200 - tz.transition 2036, 3, :o3, 2090422800 - tz.transition 2036, 10, :o2, 2108566800 - tz.transition 2037, 3, :o3, 2121872400 - tz.transition 2037, 10, :o2, 2140016400 - tz.transition 2038, 3, :o3, 59172245, 24 - tz.transition 2038, 10, :o2, 59177453, 24 - tz.transition 2039, 3, :o3, 59180981, 24 - tz.transition 2039, 10, :o2, 59186189, 24 - tz.transition 2040, 3, :o3, 59189717, 24 - tz.transition 2040, 10, :o2, 59194925, 24 - tz.transition 2041, 3, :o3, 59198621, 24 - tz.transition 2041, 10, :o2, 59203661, 24 - tz.transition 2042, 3, :o3, 59207357, 24 - tz.transition 2042, 10, :o2, 59212397, 24 - tz.transition 2043, 3, :o3, 59216093, 24 - tz.transition 2043, 10, :o2, 59221133, 24 - tz.transition 2044, 3, :o3, 59224829, 24 - tz.transition 2044, 10, :o2, 59230037, 24 - tz.transition 2045, 3, :o3, 59233565, 24 - tz.transition 2045, 10, :o2, 59238773, 24 - tz.transition 2046, 3, :o3, 59242301, 24 - tz.transition 2046, 10, :o2, 59247509, 24 - tz.transition 2047, 3, :o3, 59251205, 24 - tz.transition 2047, 10, :o2, 59256245, 24 - tz.transition 2048, 3, :o3, 59259941, 24 - tz.transition 2048, 10, :o2, 59264981, 24 - tz.transition 2049, 3, :o3, 59268677, 24 - tz.transition 2049, 10, :o2, 59273885, 24 - tz.transition 2050, 3, :o3, 59277413, 24 - tz.transition 2050, 10, :o2, 59282621, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yekaterinburg.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yekaterinburg.rb deleted file mode 100644 index 8ef8df4..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yekaterinburg.rb +++ /dev/null @@ -1,165 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Yekaterinburg - include TimezoneDefinition - - timezone 'Asia/Yekaterinburg' do |tz| - tz.offset :o0, 14544, 0, :LMT - tz.offset :o1, 14400, 0, :SVET - tz.offset :o2, 18000, 0, :SVET - tz.offset :o3, 18000, 3600, :SVEST - tz.offset :o4, 14400, 3600, :SVEST - tz.offset :o5, 18000, 0, :YEKT - tz.offset :o6, 18000, 3600, :YEKST - - tz.transition 1919, 7, :o1, 1453292699, 600 - tz.transition 1930, 6, :o2, 7278445, 3 - tz.transition 1981, 3, :o3, 354913200 - tz.transition 1981, 9, :o2, 370720800 - tz.transition 1982, 3, :o3, 386449200 - tz.transition 1982, 9, :o2, 402256800 - tz.transition 1983, 3, :o3, 417985200 - tz.transition 1983, 9, :o2, 433792800 - tz.transition 1984, 3, :o3, 449607600 - tz.transition 1984, 9, :o2, 465339600 - tz.transition 1985, 3, :o3, 481064400 - tz.transition 1985, 9, :o2, 496789200 - tz.transition 1986, 3, :o3, 512514000 - tz.transition 1986, 9, :o2, 528238800 - tz.transition 1987, 3, :o3, 543963600 - tz.transition 1987, 9, :o2, 559688400 - tz.transition 1988, 3, :o3, 575413200 - tz.transition 1988, 9, :o2, 591138000 - tz.transition 1989, 3, :o3, 606862800 - tz.transition 1989, 9, :o2, 622587600 - tz.transition 1990, 3, :o3, 638312400 - tz.transition 1990, 9, :o2, 654642000 - tz.transition 1991, 3, :o4, 670366800 - tz.transition 1991, 9, :o1, 686095200 - tz.transition 1992, 1, :o5, 695772000 - tz.transition 1992, 3, :o6, 701805600 - tz.transition 1992, 9, :o5, 717526800 - tz.transition 1993, 3, :o6, 733266000 - tz.transition 1993, 9, :o5, 748990800 - tz.transition 1994, 3, :o6, 764715600 - tz.transition 1994, 9, :o5, 780440400 - tz.transition 1995, 3, :o6, 796165200 - tz.transition 1995, 9, :o5, 811890000 - tz.transition 1996, 3, :o6, 828219600 - tz.transition 1996, 10, :o5, 846363600 - tz.transition 1997, 3, :o6, 859669200 - tz.transition 1997, 10, :o5, 877813200 - tz.transition 1998, 3, :o6, 891118800 - tz.transition 1998, 10, :o5, 909262800 - tz.transition 1999, 3, :o6, 922568400 - tz.transition 1999, 10, :o5, 941317200 - tz.transition 2000, 3, :o6, 954018000 - tz.transition 2000, 10, :o5, 972766800 - tz.transition 2001, 3, :o6, 985467600 - tz.transition 2001, 10, :o5, 1004216400 - tz.transition 2002, 3, :o6, 1017522000 - tz.transition 2002, 10, :o5, 1035666000 - tz.transition 2003, 3, :o6, 1048971600 - tz.transition 2003, 10, :o5, 1067115600 - tz.transition 2004, 3, :o6, 1080421200 - tz.transition 2004, 10, :o5, 1099170000 - tz.transition 2005, 3, :o6, 1111870800 - tz.transition 2005, 10, :o5, 1130619600 - tz.transition 2006, 3, :o6, 1143320400 - tz.transition 2006, 10, :o5, 1162069200 - tz.transition 2007, 3, :o6, 1174770000 - tz.transition 2007, 10, :o5, 1193518800 - tz.transition 2008, 3, :o6, 1206824400 - tz.transition 2008, 10, :o5, 1224968400 - tz.transition 2009, 3, :o6, 1238274000 - tz.transition 2009, 10, :o5, 1256418000 - tz.transition 2010, 3, :o6, 1269723600 - tz.transition 2010, 10, :o5, 1288472400 - tz.transition 2011, 3, :o6, 1301173200 - tz.transition 2011, 10, :o5, 1319922000 - tz.transition 2012, 3, :o6, 1332622800 - tz.transition 2012, 10, :o5, 1351371600 - tz.transition 2013, 3, :o6, 1364677200 - tz.transition 2013, 10, :o5, 1382821200 - tz.transition 2014, 3, :o6, 1396126800 - tz.transition 2014, 10, :o5, 1414270800 - tz.transition 2015, 3, :o6, 1427576400 - tz.transition 2015, 10, :o5, 1445720400 - tz.transition 2016, 3, :o6, 1459026000 - tz.transition 2016, 10, :o5, 1477774800 - tz.transition 2017, 3, :o6, 1490475600 - tz.transition 2017, 10, :o5, 1509224400 - tz.transition 2018, 3, :o6, 1521925200 - tz.transition 2018, 10, :o5, 1540674000 - tz.transition 2019, 3, :o6, 1553979600 - tz.transition 2019, 10, :o5, 1572123600 - tz.transition 2020, 3, :o6, 1585429200 - tz.transition 2020, 10, :o5, 1603573200 - tz.transition 2021, 3, :o6, 1616878800 - tz.transition 2021, 10, :o5, 1635627600 - tz.transition 2022, 3, :o6, 1648328400 - tz.transition 2022, 10, :o5, 1667077200 - tz.transition 2023, 3, :o6, 1679778000 - tz.transition 2023, 10, :o5, 1698526800 - tz.transition 2024, 3, :o6, 1711832400 - tz.transition 2024, 10, :o5, 1729976400 - tz.transition 2025, 3, :o6, 1743282000 - tz.transition 2025, 10, :o5, 1761426000 - tz.transition 2026, 3, :o6, 1774731600 - tz.transition 2026, 10, :o5, 1792875600 - tz.transition 2027, 3, :o6, 1806181200 - tz.transition 2027, 10, :o5, 1824930000 - tz.transition 2028, 3, :o6, 1837630800 - tz.transition 2028, 10, :o5, 1856379600 - tz.transition 2029, 3, :o6, 1869080400 - tz.transition 2029, 10, :o5, 1887829200 - tz.transition 2030, 3, :o6, 1901134800 - tz.transition 2030, 10, :o5, 1919278800 - tz.transition 2031, 3, :o6, 1932584400 - tz.transition 2031, 10, :o5, 1950728400 - tz.transition 2032, 3, :o6, 1964034000 - tz.transition 2032, 10, :o5, 1982782800 - tz.transition 2033, 3, :o6, 1995483600 - tz.transition 2033, 10, :o5, 2014232400 - tz.transition 2034, 3, :o6, 2026933200 - tz.transition 2034, 10, :o5, 2045682000 - tz.transition 2035, 3, :o6, 2058382800 - tz.transition 2035, 10, :o5, 2077131600 - tz.transition 2036, 3, :o6, 2090437200 - tz.transition 2036, 10, :o5, 2108581200 - tz.transition 2037, 3, :o6, 2121886800 - tz.transition 2037, 10, :o5, 2140030800 - tz.transition 2038, 3, :o6, 19724083, 8 - tz.transition 2038, 10, :o5, 19725819, 8 - tz.transition 2039, 3, :o6, 19726995, 8 - tz.transition 2039, 10, :o5, 19728731, 8 - tz.transition 2040, 3, :o6, 19729907, 8 - tz.transition 2040, 10, :o5, 19731643, 8 - tz.transition 2041, 3, :o6, 19732875, 8 - tz.transition 2041, 10, :o5, 19734555, 8 - tz.transition 2042, 3, :o6, 19735787, 8 - tz.transition 2042, 10, :o5, 19737467, 8 - tz.transition 2043, 3, :o6, 19738699, 8 - tz.transition 2043, 10, :o5, 19740379, 8 - tz.transition 2044, 3, :o6, 19741611, 8 - tz.transition 2044, 10, :o5, 19743347, 8 - tz.transition 2045, 3, :o6, 19744523, 8 - tz.transition 2045, 10, :o5, 19746259, 8 - tz.transition 2046, 3, :o6, 19747435, 8 - tz.transition 2046, 10, :o5, 19749171, 8 - tz.transition 2047, 3, :o6, 19750403, 8 - tz.transition 2047, 10, :o5, 19752083, 8 - tz.transition 2048, 3, :o6, 19753315, 8 - tz.transition 2048, 10, :o5, 19754995, 8 - tz.transition 2049, 3, :o6, 19756227, 8 - tz.transition 2049, 10, :o5, 19757963, 8 - tz.transition 2050, 3, :o6, 19759139, 8 - tz.transition 2050, 10, :o5, 19760875, 8 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yerevan.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yerevan.rb deleted file mode 100644 index e7f1608..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yerevan.rb +++ /dev/null @@ -1,165 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Asia - module Yerevan - include TimezoneDefinition - - timezone 'Asia/Yerevan' do |tz| - tz.offset :o0, 10680, 0, :LMT - tz.offset :o1, 10800, 0, :YERT - tz.offset :o2, 14400, 0, :YERT - tz.offset :o3, 14400, 3600, :YERST - tz.offset :o4, 10800, 3600, :YERST - tz.offset :o5, 10800, 3600, :AMST - tz.offset :o6, 10800, 0, :AMT - tz.offset :o7, 14400, 0, :AMT - tz.offset :o8, 14400, 3600, :AMST - - tz.transition 1924, 5, :o1, 1745213311, 720 - tz.transition 1957, 2, :o2, 19487187, 8 - tz.transition 1981, 3, :o3, 354916800 - tz.transition 1981, 9, :o2, 370724400 - tz.transition 1982, 3, :o3, 386452800 - tz.transition 1982, 9, :o2, 402260400 - tz.transition 1983, 3, :o3, 417988800 - tz.transition 1983, 9, :o2, 433796400 - tz.transition 1984, 3, :o3, 449611200 - tz.transition 1984, 9, :o2, 465343200 - tz.transition 1985, 3, :o3, 481068000 - tz.transition 1985, 9, :o2, 496792800 - tz.transition 1986, 3, :o3, 512517600 - tz.transition 1986, 9, :o2, 528242400 - tz.transition 1987, 3, :o3, 543967200 - tz.transition 1987, 9, :o2, 559692000 - tz.transition 1988, 3, :o3, 575416800 - tz.transition 1988, 9, :o2, 591141600 - tz.transition 1989, 3, :o3, 606866400 - tz.transition 1989, 9, :o2, 622591200 - tz.transition 1990, 3, :o3, 638316000 - tz.transition 1990, 9, :o2, 654645600 - tz.transition 1991, 3, :o4, 670370400 - tz.transition 1991, 9, :o5, 685569600 - tz.transition 1991, 9, :o6, 686098800 - tz.transition 1992, 3, :o5, 701812800 - tz.transition 1992, 9, :o6, 717534000 - tz.transition 1993, 3, :o5, 733273200 - tz.transition 1993, 9, :o6, 748998000 - tz.transition 1994, 3, :o5, 764722800 - tz.transition 1994, 9, :o6, 780447600 - tz.transition 1995, 3, :o5, 796172400 - tz.transition 1995, 9, :o7, 811897200 - tz.transition 1997, 3, :o8, 859672800 - tz.transition 1997, 10, :o7, 877816800 - tz.transition 1998, 3, :o8, 891122400 - tz.transition 1998, 10, :o7, 909266400 - tz.transition 1999, 3, :o8, 922572000 - tz.transition 1999, 10, :o7, 941320800 - tz.transition 2000, 3, :o8, 954021600 - tz.transition 2000, 10, :o7, 972770400 - tz.transition 2001, 3, :o8, 985471200 - tz.transition 2001, 10, :o7, 1004220000 - tz.transition 2002, 3, :o8, 1017525600 - tz.transition 2002, 10, :o7, 1035669600 - tz.transition 2003, 3, :o8, 1048975200 - tz.transition 2003, 10, :o7, 1067119200 - tz.transition 2004, 3, :o8, 1080424800 - tz.transition 2004, 10, :o7, 1099173600 - tz.transition 2005, 3, :o8, 1111874400 - tz.transition 2005, 10, :o7, 1130623200 - tz.transition 2006, 3, :o8, 1143324000 - tz.transition 2006, 10, :o7, 1162072800 - tz.transition 2007, 3, :o8, 1174773600 - tz.transition 2007, 10, :o7, 1193522400 - tz.transition 2008, 3, :o8, 1206828000 - tz.transition 2008, 10, :o7, 1224972000 - tz.transition 2009, 3, :o8, 1238277600 - tz.transition 2009, 10, :o7, 1256421600 - tz.transition 2010, 3, :o8, 1269727200 - tz.transition 2010, 10, :o7, 1288476000 - tz.transition 2011, 3, :o8, 1301176800 - tz.transition 2011, 10, :o7, 1319925600 - tz.transition 2012, 3, :o8, 1332626400 - tz.transition 2012, 10, :o7, 1351375200 - tz.transition 2013, 3, :o8, 1364680800 - tz.transition 2013, 10, :o7, 1382824800 - tz.transition 2014, 3, :o8, 1396130400 - tz.transition 2014, 10, :o7, 1414274400 - tz.transition 2015, 3, :o8, 1427580000 - tz.transition 2015, 10, :o7, 1445724000 - tz.transition 2016, 3, :o8, 1459029600 - tz.transition 2016, 10, :o7, 1477778400 - tz.transition 2017, 3, :o8, 1490479200 - tz.transition 2017, 10, :o7, 1509228000 - tz.transition 2018, 3, :o8, 1521928800 - tz.transition 2018, 10, :o7, 1540677600 - tz.transition 2019, 3, :o8, 1553983200 - tz.transition 2019, 10, :o7, 1572127200 - tz.transition 2020, 3, :o8, 1585432800 - tz.transition 2020, 10, :o7, 1603576800 - tz.transition 2021, 3, :o8, 1616882400 - tz.transition 2021, 10, :o7, 1635631200 - tz.transition 2022, 3, :o8, 1648332000 - tz.transition 2022, 10, :o7, 1667080800 - tz.transition 2023, 3, :o8, 1679781600 - tz.transition 2023, 10, :o7, 1698530400 - tz.transition 2024, 3, :o8, 1711836000 - tz.transition 2024, 10, :o7, 1729980000 - tz.transition 2025, 3, :o8, 1743285600 - tz.transition 2025, 10, :o7, 1761429600 - tz.transition 2026, 3, :o8, 1774735200 - tz.transition 2026, 10, :o7, 1792879200 - tz.transition 2027, 3, :o8, 1806184800 - tz.transition 2027, 10, :o7, 1824933600 - tz.transition 2028, 3, :o8, 1837634400 - tz.transition 2028, 10, :o7, 1856383200 - tz.transition 2029, 3, :o8, 1869084000 - tz.transition 2029, 10, :o7, 1887832800 - tz.transition 2030, 3, :o8, 1901138400 - tz.transition 2030, 10, :o7, 1919282400 - tz.transition 2031, 3, :o8, 1932588000 - tz.transition 2031, 10, :o7, 1950732000 - tz.transition 2032, 3, :o8, 1964037600 - tz.transition 2032, 10, :o7, 1982786400 - tz.transition 2033, 3, :o8, 1995487200 - tz.transition 2033, 10, :o7, 2014236000 - tz.transition 2034, 3, :o8, 2026936800 - tz.transition 2034, 10, :o7, 2045685600 - tz.transition 2035, 3, :o8, 2058386400 - tz.transition 2035, 10, :o7, 2077135200 - tz.transition 2036, 3, :o8, 2090440800 - tz.transition 2036, 10, :o7, 2108584800 - tz.transition 2037, 3, :o8, 2121890400 - tz.transition 2037, 10, :o7, 2140034400 - tz.transition 2038, 3, :o8, 29586125, 12 - tz.transition 2038, 10, :o7, 29588729, 12 - tz.transition 2039, 3, :o8, 29590493, 12 - tz.transition 2039, 10, :o7, 29593097, 12 - tz.transition 2040, 3, :o8, 29594861, 12 - tz.transition 2040, 10, :o7, 29597465, 12 - tz.transition 2041, 3, :o8, 29599313, 12 - tz.transition 2041, 10, :o7, 29601833, 12 - tz.transition 2042, 3, :o8, 29603681, 12 - tz.transition 2042, 10, :o7, 29606201, 12 - tz.transition 2043, 3, :o8, 29608049, 12 - tz.transition 2043, 10, :o7, 29610569, 12 - tz.transition 2044, 3, :o8, 29612417, 12 - tz.transition 2044, 10, :o7, 29615021, 12 - tz.transition 2045, 3, :o8, 29616785, 12 - tz.transition 2045, 10, :o7, 29619389, 12 - tz.transition 2046, 3, :o8, 29621153, 12 - tz.transition 2046, 10, :o7, 29623757, 12 - tz.transition 2047, 3, :o8, 29625605, 12 - tz.transition 2047, 10, :o7, 29628125, 12 - tz.transition 2048, 3, :o8, 29629973, 12 - tz.transition 2048, 10, :o7, 29632493, 12 - tz.transition 2049, 3, :o8, 29634341, 12 - tz.transition 2049, 10, :o7, 29636945, 12 - tz.transition 2050, 3, :o8, 29638709, 12 - tz.transition 2050, 10, :o7, 29641313, 12 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Azores.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Azores.rb deleted file mode 100644 index 1bd16a7..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Azores.rb +++ /dev/null @@ -1,270 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Atlantic - module Azores - include TimezoneDefinition - - timezone 'Atlantic/Azores' do |tz| - tz.offset :o0, -6160, 0, :LMT - tz.offset :o1, -6872, 0, :HMT - tz.offset :o2, -7200, 0, :AZOT - tz.offset :o3, -7200, 3600, :AZOST - tz.offset :o4, -7200, 7200, :AZOMT - tz.offset :o5, -3600, 0, :AZOT - tz.offset :o6, -3600, 3600, :AZOST - tz.offset :o7, 0, 0, :WET - - tz.transition 1884, 1, :o1, 2601910697, 1080 - tz.transition 1911, 5, :o2, 26127150259, 10800 - tz.transition 1916, 6, :o3, 58104781, 24 - tz.transition 1916, 11, :o2, 29054023, 12 - tz.transition 1917, 3, :o3, 58110925, 24 - tz.transition 1917, 10, :o2, 58116397, 24 - tz.transition 1918, 3, :o3, 58119709, 24 - tz.transition 1918, 10, :o2, 58125157, 24 - tz.transition 1919, 3, :o3, 58128445, 24 - tz.transition 1919, 10, :o2, 58133917, 24 - tz.transition 1920, 3, :o3, 58137229, 24 - tz.transition 1920, 10, :o2, 58142701, 24 - tz.transition 1921, 3, :o3, 58145989, 24 - tz.transition 1921, 10, :o2, 58151461, 24 - tz.transition 1924, 4, :o3, 58173421, 24 - tz.transition 1924, 10, :o2, 58177765, 24 - tz.transition 1926, 4, :o3, 58190965, 24 - tz.transition 1926, 10, :o2, 58194997, 24 - tz.transition 1927, 4, :o3, 58199533, 24 - tz.transition 1927, 10, :o2, 58203733, 24 - tz.transition 1928, 4, :o3, 58208437, 24 - tz.transition 1928, 10, :o2, 58212637, 24 - tz.transition 1929, 4, :o3, 58217341, 24 - tz.transition 1929, 10, :o2, 58221373, 24 - tz.transition 1931, 4, :o3, 58234813, 24 - tz.transition 1931, 10, :o2, 58238845, 24 - tz.transition 1932, 4, :o3, 58243213, 24 - tz.transition 1932, 10, :o2, 58247581, 24 - tz.transition 1934, 4, :o3, 58260853, 24 - tz.transition 1934, 10, :o2, 58265221, 24 - tz.transition 1935, 3, :o3, 58269421, 24 - tz.transition 1935, 10, :o2, 58273957, 24 - tz.transition 1936, 4, :o3, 58278661, 24 - tz.transition 1936, 10, :o2, 58282693, 24 - tz.transition 1937, 4, :o3, 58287061, 24 - tz.transition 1937, 10, :o2, 58291429, 24 - tz.transition 1938, 3, :o3, 58295629, 24 - tz.transition 1938, 10, :o2, 58300165, 24 - tz.transition 1939, 4, :o3, 58304869, 24 - tz.transition 1939, 11, :o2, 58310077, 24 - tz.transition 1940, 2, :o3, 58312429, 24 - tz.transition 1940, 10, :o2, 58317805, 24 - tz.transition 1941, 4, :o3, 58322173, 24 - tz.transition 1941, 10, :o2, 58326565, 24 - tz.transition 1942, 3, :o3, 58330405, 24 - tz.transition 1942, 4, :o4, 4860951, 2 - tz.transition 1942, 8, :o3, 4861175, 2 - tz.transition 1942, 10, :o2, 58335781, 24 - tz.transition 1943, 3, :o3, 58339141, 24 - tz.transition 1943, 4, :o4, 4861665, 2 - tz.transition 1943, 8, :o3, 4861931, 2 - tz.transition 1943, 10, :o2, 58344685, 24 - tz.transition 1944, 3, :o3, 58347877, 24 - tz.transition 1944, 4, :o4, 4862407, 2 - tz.transition 1944, 8, :o3, 4862659, 2 - tz.transition 1944, 10, :o2, 58353421, 24 - tz.transition 1945, 3, :o3, 58356613, 24 - tz.transition 1945, 4, :o4, 4863135, 2 - tz.transition 1945, 8, :o3, 4863387, 2 - tz.transition 1945, 10, :o2, 58362157, 24 - tz.transition 1946, 4, :o3, 58366021, 24 - tz.transition 1946, 10, :o2, 58370389, 24 - tz.transition 1947, 4, :o3, 7296845, 3 - tz.transition 1947, 10, :o2, 7297391, 3 - tz.transition 1948, 4, :o3, 7297937, 3 - tz.transition 1948, 10, :o2, 7298483, 3 - tz.transition 1949, 4, :o3, 7299029, 3 - tz.transition 1949, 10, :o2, 7299575, 3 - tz.transition 1951, 4, :o3, 7301213, 3 - tz.transition 1951, 10, :o2, 7301780, 3 - tz.transition 1952, 4, :o3, 7302326, 3 - tz.transition 1952, 10, :o2, 7302872, 3 - tz.transition 1953, 4, :o3, 7303418, 3 - tz.transition 1953, 10, :o2, 7303964, 3 - tz.transition 1954, 4, :o3, 7304510, 3 - tz.transition 1954, 10, :o2, 7305056, 3 - tz.transition 1955, 4, :o3, 7305602, 3 - tz.transition 1955, 10, :o2, 7306148, 3 - tz.transition 1956, 4, :o3, 7306694, 3 - tz.transition 1956, 10, :o2, 7307261, 3 - tz.transition 1957, 4, :o3, 7307807, 3 - tz.transition 1957, 10, :o2, 7308353, 3 - tz.transition 1958, 4, :o3, 7308899, 3 - tz.transition 1958, 10, :o2, 7309445, 3 - tz.transition 1959, 4, :o3, 7309991, 3 - tz.transition 1959, 10, :o2, 7310537, 3 - tz.transition 1960, 4, :o3, 7311083, 3 - tz.transition 1960, 10, :o2, 7311629, 3 - tz.transition 1961, 4, :o3, 7312175, 3 - tz.transition 1961, 10, :o2, 7312721, 3 - tz.transition 1962, 4, :o3, 7313267, 3 - tz.transition 1962, 10, :o2, 7313834, 3 - tz.transition 1963, 4, :o3, 7314380, 3 - tz.transition 1963, 10, :o2, 7314926, 3 - tz.transition 1964, 4, :o3, 7315472, 3 - tz.transition 1964, 10, :o2, 7316018, 3 - tz.transition 1965, 4, :o3, 7316564, 3 - tz.transition 1965, 10, :o2, 7317110, 3 - tz.transition 1966, 4, :o5, 7317656, 3 - tz.transition 1977, 3, :o6, 228272400 - tz.transition 1977, 9, :o5, 243997200 - tz.transition 1978, 4, :o6, 260326800 - tz.transition 1978, 10, :o5, 276051600 - tz.transition 1979, 4, :o6, 291776400 - tz.transition 1979, 9, :o5, 307504800 - tz.transition 1980, 3, :o6, 323226000 - tz.transition 1980, 9, :o5, 338954400 - tz.transition 1981, 3, :o6, 354679200 - tz.transition 1981, 9, :o5, 370404000 - tz.transition 1982, 3, :o6, 386128800 - tz.transition 1982, 9, :o5, 401853600 - tz.transition 1983, 3, :o6, 417582000 - tz.transition 1983, 9, :o5, 433303200 - tz.transition 1984, 3, :o6, 449028000 - tz.transition 1984, 9, :o5, 465357600 - tz.transition 1985, 3, :o6, 481082400 - tz.transition 1985, 9, :o5, 496807200 - tz.transition 1986, 3, :o6, 512532000 - tz.transition 1986, 9, :o5, 528256800 - tz.transition 1987, 3, :o6, 543981600 - tz.transition 1987, 9, :o5, 559706400 - tz.transition 1988, 3, :o6, 575431200 - tz.transition 1988, 9, :o5, 591156000 - tz.transition 1989, 3, :o6, 606880800 - tz.transition 1989, 9, :o5, 622605600 - tz.transition 1990, 3, :o6, 638330400 - tz.transition 1990, 9, :o5, 654660000 - tz.transition 1991, 3, :o6, 670384800 - tz.transition 1991, 9, :o5, 686109600 - tz.transition 1992, 3, :o6, 701834400 - tz.transition 1992, 9, :o7, 717559200 - tz.transition 1993, 3, :o6, 733280400 - tz.transition 1993, 9, :o5, 749005200 - tz.transition 1994, 3, :o6, 764730000 - tz.transition 1994, 9, :o5, 780454800 - tz.transition 1995, 3, :o6, 796179600 - tz.transition 1995, 9, :o5, 811904400 - tz.transition 1996, 3, :o6, 828234000 - tz.transition 1996, 10, :o5, 846378000 - tz.transition 1997, 3, :o6, 859683600 - tz.transition 1997, 10, :o5, 877827600 - tz.transition 1998, 3, :o6, 891133200 - tz.transition 1998, 10, :o5, 909277200 - tz.transition 1999, 3, :o6, 922582800 - tz.transition 1999, 10, :o5, 941331600 - tz.transition 2000, 3, :o6, 954032400 - tz.transition 2000, 10, :o5, 972781200 - tz.transition 2001, 3, :o6, 985482000 - tz.transition 2001, 10, :o5, 1004230800 - tz.transition 2002, 3, :o6, 1017536400 - tz.transition 2002, 10, :o5, 1035680400 - tz.transition 2003, 3, :o6, 1048986000 - tz.transition 2003, 10, :o5, 1067130000 - tz.transition 2004, 3, :o6, 1080435600 - tz.transition 2004, 10, :o5, 1099184400 - tz.transition 2005, 3, :o6, 1111885200 - tz.transition 2005, 10, :o5, 1130634000 - tz.transition 2006, 3, :o6, 1143334800 - tz.transition 2006, 10, :o5, 1162083600 - tz.transition 2007, 3, :o6, 1174784400 - tz.transition 2007, 10, :o5, 1193533200 - tz.transition 2008, 3, :o6, 1206838800 - tz.transition 2008, 10, :o5, 1224982800 - tz.transition 2009, 3, :o6, 1238288400 - tz.transition 2009, 10, :o5, 1256432400 - tz.transition 2010, 3, :o6, 1269738000 - tz.transition 2010, 10, :o5, 1288486800 - tz.transition 2011, 3, :o6, 1301187600 - tz.transition 2011, 10, :o5, 1319936400 - tz.transition 2012, 3, :o6, 1332637200 - tz.transition 2012, 10, :o5, 1351386000 - tz.transition 2013, 3, :o6, 1364691600 - tz.transition 2013, 10, :o5, 1382835600 - tz.transition 2014, 3, :o6, 1396141200 - tz.transition 2014, 10, :o5, 1414285200 - tz.transition 2015, 3, :o6, 1427590800 - tz.transition 2015, 10, :o5, 1445734800 - tz.transition 2016, 3, :o6, 1459040400 - tz.transition 2016, 10, :o5, 1477789200 - tz.transition 2017, 3, :o6, 1490490000 - tz.transition 2017, 10, :o5, 1509238800 - tz.transition 2018, 3, :o6, 1521939600 - tz.transition 2018, 10, :o5, 1540688400 - tz.transition 2019, 3, :o6, 1553994000 - tz.transition 2019, 10, :o5, 1572138000 - tz.transition 2020, 3, :o6, 1585443600 - tz.transition 2020, 10, :o5, 1603587600 - tz.transition 2021, 3, :o6, 1616893200 - tz.transition 2021, 10, :o5, 1635642000 - tz.transition 2022, 3, :o6, 1648342800 - tz.transition 2022, 10, :o5, 1667091600 - tz.transition 2023, 3, :o6, 1679792400 - tz.transition 2023, 10, :o5, 1698541200 - tz.transition 2024, 3, :o6, 1711846800 - tz.transition 2024, 10, :o5, 1729990800 - tz.transition 2025, 3, :o6, 1743296400 - tz.transition 2025, 10, :o5, 1761440400 - tz.transition 2026, 3, :o6, 1774746000 - tz.transition 2026, 10, :o5, 1792890000 - tz.transition 2027, 3, :o6, 1806195600 - tz.transition 2027, 10, :o5, 1824944400 - tz.transition 2028, 3, :o6, 1837645200 - tz.transition 2028, 10, :o5, 1856394000 - tz.transition 2029, 3, :o6, 1869094800 - tz.transition 2029, 10, :o5, 1887843600 - tz.transition 2030, 3, :o6, 1901149200 - tz.transition 2030, 10, :o5, 1919293200 - tz.transition 2031, 3, :o6, 1932598800 - tz.transition 2031, 10, :o5, 1950742800 - tz.transition 2032, 3, :o6, 1964048400 - tz.transition 2032, 10, :o5, 1982797200 - tz.transition 2033, 3, :o6, 1995498000 - tz.transition 2033, 10, :o5, 2014246800 - tz.transition 2034, 3, :o6, 2026947600 - tz.transition 2034, 10, :o5, 2045696400 - tz.transition 2035, 3, :o6, 2058397200 - tz.transition 2035, 10, :o5, 2077146000 - tz.transition 2036, 3, :o6, 2090451600 - tz.transition 2036, 10, :o5, 2108595600 - tz.transition 2037, 3, :o6, 2121901200 - tz.transition 2037, 10, :o5, 2140045200 - tz.transition 2038, 3, :o6, 59172253, 24 - tz.transition 2038, 10, :o5, 59177461, 24 - tz.transition 2039, 3, :o6, 59180989, 24 - tz.transition 2039, 10, :o5, 59186197, 24 - tz.transition 2040, 3, :o6, 59189725, 24 - tz.transition 2040, 10, :o5, 59194933, 24 - tz.transition 2041, 3, :o6, 59198629, 24 - tz.transition 2041, 10, :o5, 59203669, 24 - tz.transition 2042, 3, :o6, 59207365, 24 - tz.transition 2042, 10, :o5, 59212405, 24 - tz.transition 2043, 3, :o6, 59216101, 24 - tz.transition 2043, 10, :o5, 59221141, 24 - tz.transition 2044, 3, :o6, 59224837, 24 - tz.transition 2044, 10, :o5, 59230045, 24 - tz.transition 2045, 3, :o6, 59233573, 24 - tz.transition 2045, 10, :o5, 59238781, 24 - tz.transition 2046, 3, :o6, 59242309, 24 - tz.transition 2046, 10, :o5, 59247517, 24 - tz.transition 2047, 3, :o6, 59251213, 24 - tz.transition 2047, 10, :o5, 59256253, 24 - tz.transition 2048, 3, :o6, 59259949, 24 - tz.transition 2048, 10, :o5, 59264989, 24 - tz.transition 2049, 3, :o6, 59268685, 24 - tz.transition 2049, 10, :o5, 59273893, 24 - tz.transition 2050, 3, :o6, 59277421, 24 - tz.transition 2050, 10, :o5, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Cape_Verde.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Cape_Verde.rb deleted file mode 100644 index 61c8c15..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Cape_Verde.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Atlantic - module Cape_Verde - include TimezoneDefinition - - timezone 'Atlantic/Cape_Verde' do |tz| - tz.offset :o0, -5644, 0, :LMT - tz.offset :o1, -7200, 0, :CVT - tz.offset :o2, -7200, 3600, :CVST - tz.offset :o3, -3600, 0, :CVT - - tz.transition 1907, 1, :o1, 52219653811, 21600 - tz.transition 1942, 9, :o2, 29167243, 12 - tz.transition 1945, 10, :o1, 58361845, 24 - tz.transition 1975, 11, :o3, 186120000 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/South_Georgia.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/South_Georgia.rb deleted file mode 100644 index 6a4cbaf..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/South_Georgia.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Atlantic - module South_Georgia - include TimezoneDefinition - - timezone 'Atlantic/South_Georgia' do |tz| - tz.offset :o0, -8768, 0, :LMT - tz.offset :o1, -7200, 0, :GST - - tz.transition 1890, 1, :o1, 1627673806, 675 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Adelaide.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Adelaide.rb deleted file mode 100644 index c5d561c..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Adelaide.rb +++ /dev/null @@ -1,187 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Australia - module Adelaide - include TimezoneDefinition - - timezone 'Australia/Adelaide' do |tz| - tz.offset :o0, 33260, 0, :LMT - tz.offset :o1, 32400, 0, :CST - tz.offset :o2, 34200, 0, :CST - tz.offset :o3, 34200, 3600, :CST - - tz.transition 1895, 1, :o1, 10425132497, 4320 - tz.transition 1899, 4, :o2, 19318201, 8 - tz.transition 1916, 12, :o3, 3486569911, 1440 - tz.transition 1917, 3, :o2, 116222983, 48 - tz.transition 1941, 12, :o3, 38885763, 16 - tz.transition 1942, 3, :o2, 116661463, 48 - tz.transition 1942, 9, :o3, 38890067, 16 - tz.transition 1943, 3, :o2, 116678935, 48 - tz.transition 1943, 10, :o3, 38896003, 16 - tz.transition 1944, 3, :o2, 116696407, 48 - tz.transition 1971, 10, :o3, 57688200 - tz.transition 1972, 2, :o2, 67969800 - tz.transition 1972, 10, :o3, 89137800 - tz.transition 1973, 3, :o2, 100024200 - tz.transition 1973, 10, :o3, 120587400 - tz.transition 1974, 3, :o2, 131473800 - tz.transition 1974, 10, :o3, 152037000 - tz.transition 1975, 3, :o2, 162923400 - tz.transition 1975, 10, :o3, 183486600 - tz.transition 1976, 3, :o2, 194977800 - tz.transition 1976, 10, :o3, 215541000 - tz.transition 1977, 3, :o2, 226427400 - tz.transition 1977, 10, :o3, 246990600 - tz.transition 1978, 3, :o2, 257877000 - tz.transition 1978, 10, :o3, 278440200 - tz.transition 1979, 3, :o2, 289326600 - tz.transition 1979, 10, :o3, 309889800 - tz.transition 1980, 3, :o2, 320776200 - tz.transition 1980, 10, :o3, 341339400 - tz.transition 1981, 2, :o2, 352225800 - tz.transition 1981, 10, :o3, 372789000 - tz.transition 1982, 3, :o2, 384280200 - tz.transition 1982, 10, :o3, 404843400 - tz.transition 1983, 3, :o2, 415729800 - tz.transition 1983, 10, :o3, 436293000 - tz.transition 1984, 3, :o2, 447179400 - tz.transition 1984, 10, :o3, 467742600 - tz.transition 1985, 3, :o2, 478629000 - tz.transition 1985, 10, :o3, 499192200 - tz.transition 1986, 3, :o2, 511288200 - tz.transition 1986, 10, :o3, 530037000 - tz.transition 1987, 3, :o2, 542737800 - tz.transition 1987, 10, :o3, 562091400 - tz.transition 1988, 3, :o2, 574792200 - tz.transition 1988, 10, :o3, 594145800 - tz.transition 1989, 3, :o2, 606241800 - tz.transition 1989, 10, :o3, 625595400 - tz.transition 1990, 3, :o2, 637691400 - tz.transition 1990, 10, :o3, 657045000 - tz.transition 1991, 3, :o2, 667931400 - tz.transition 1991, 10, :o3, 688494600 - tz.transition 1992, 3, :o2, 701195400 - tz.transition 1992, 10, :o3, 719944200 - tz.transition 1993, 3, :o2, 731435400 - tz.transition 1993, 10, :o3, 751998600 - tz.transition 1994, 3, :o2, 764094600 - tz.transition 1994, 10, :o3, 783448200 - tz.transition 1995, 3, :o2, 796149000 - tz.transition 1995, 10, :o3, 814897800 - tz.transition 1996, 3, :o2, 828203400 - tz.transition 1996, 10, :o3, 846347400 - tz.transition 1997, 3, :o2, 859653000 - tz.transition 1997, 10, :o3, 877797000 - tz.transition 1998, 3, :o2, 891102600 - tz.transition 1998, 10, :o3, 909246600 - tz.transition 1999, 3, :o2, 922552200 - tz.transition 1999, 10, :o3, 941301000 - tz.transition 2000, 3, :o2, 954001800 - tz.transition 2000, 10, :o3, 972750600 - tz.transition 2001, 3, :o2, 985451400 - tz.transition 2001, 10, :o3, 1004200200 - tz.transition 2002, 3, :o2, 1017505800 - tz.transition 2002, 10, :o3, 1035649800 - tz.transition 2003, 3, :o2, 1048955400 - tz.transition 2003, 10, :o3, 1067099400 - tz.transition 2004, 3, :o2, 1080405000 - tz.transition 2004, 10, :o3, 1099153800 - tz.transition 2005, 3, :o2, 1111854600 - tz.transition 2005, 10, :o3, 1130603400 - tz.transition 2006, 4, :o2, 1143909000 - tz.transition 2006, 10, :o3, 1162053000 - tz.transition 2007, 3, :o2, 1174753800 - tz.transition 2007, 10, :o3, 1193502600 - tz.transition 2008, 4, :o2, 1207413000 - tz.transition 2008, 10, :o3, 1223137800 - tz.transition 2009, 4, :o2, 1238862600 - tz.transition 2009, 10, :o3, 1254587400 - tz.transition 2010, 4, :o2, 1270312200 - tz.transition 2010, 10, :o3, 1286037000 - tz.transition 2011, 4, :o2, 1301761800 - tz.transition 2011, 10, :o3, 1317486600 - tz.transition 2012, 3, :o2, 1333211400 - tz.transition 2012, 10, :o3, 1349541000 - tz.transition 2013, 4, :o2, 1365265800 - tz.transition 2013, 10, :o3, 1380990600 - tz.transition 2014, 4, :o2, 1396715400 - tz.transition 2014, 10, :o3, 1412440200 - tz.transition 2015, 4, :o2, 1428165000 - tz.transition 2015, 10, :o3, 1443889800 - tz.transition 2016, 4, :o2, 1459614600 - tz.transition 2016, 10, :o3, 1475339400 - tz.transition 2017, 4, :o2, 1491064200 - tz.transition 2017, 9, :o3, 1506789000 - tz.transition 2018, 3, :o2, 1522513800 - tz.transition 2018, 10, :o3, 1538843400 - tz.transition 2019, 4, :o2, 1554568200 - tz.transition 2019, 10, :o3, 1570293000 - tz.transition 2020, 4, :o2, 1586017800 - tz.transition 2020, 10, :o3, 1601742600 - tz.transition 2021, 4, :o2, 1617467400 - tz.transition 2021, 10, :o3, 1633192200 - tz.transition 2022, 4, :o2, 1648917000 - tz.transition 2022, 10, :o3, 1664641800 - tz.transition 2023, 4, :o2, 1680366600 - tz.transition 2023, 9, :o3, 1696091400 - tz.transition 2024, 4, :o2, 1712421000 - tz.transition 2024, 10, :o3, 1728145800 - tz.transition 2025, 4, :o2, 1743870600 - tz.transition 2025, 10, :o3, 1759595400 - tz.transition 2026, 4, :o2, 1775320200 - tz.transition 2026, 10, :o3, 1791045000 - tz.transition 2027, 4, :o2, 1806769800 - tz.transition 2027, 10, :o3, 1822494600 - tz.transition 2028, 4, :o2, 1838219400 - tz.transition 2028, 9, :o3, 1853944200 - tz.transition 2029, 3, :o2, 1869669000 - tz.transition 2029, 10, :o3, 1885998600 - tz.transition 2030, 4, :o2, 1901723400 - tz.transition 2030, 10, :o3, 1917448200 - tz.transition 2031, 4, :o2, 1933173000 - tz.transition 2031, 10, :o3, 1948897800 - tz.transition 2032, 4, :o2, 1964622600 - tz.transition 2032, 10, :o3, 1980347400 - tz.transition 2033, 4, :o2, 1996072200 - tz.transition 2033, 10, :o3, 2011797000 - tz.transition 2034, 4, :o2, 2027521800 - tz.transition 2034, 9, :o3, 2043246600 - tz.transition 2035, 3, :o2, 2058971400 - tz.transition 2035, 10, :o3, 2075301000 - tz.transition 2036, 4, :o2, 2091025800 - tz.transition 2036, 10, :o3, 2106750600 - tz.transition 2037, 4, :o2, 2122475400 - tz.transition 2037, 10, :o3, 2138200200 - tz.transition 2038, 4, :o2, 39448275, 16 - tz.transition 2038, 10, :o3, 39451187, 16 - tz.transition 2039, 4, :o2, 39454099, 16 - tz.transition 2039, 10, :o3, 39457011, 16 - tz.transition 2040, 3, :o2, 39459923, 16 - tz.transition 2040, 10, :o3, 39462947, 16 - tz.transition 2041, 4, :o2, 39465859, 16 - tz.transition 2041, 10, :o3, 39468771, 16 - tz.transition 2042, 4, :o2, 39471683, 16 - tz.transition 2042, 10, :o3, 39474595, 16 - tz.transition 2043, 4, :o2, 39477507, 16 - tz.transition 2043, 10, :o3, 39480419, 16 - tz.transition 2044, 4, :o2, 39483331, 16 - tz.transition 2044, 10, :o3, 39486243, 16 - tz.transition 2045, 4, :o2, 39489155, 16 - tz.transition 2045, 9, :o3, 39492067, 16 - tz.transition 2046, 3, :o2, 39494979, 16 - tz.transition 2046, 10, :o3, 39498003, 16 - tz.transition 2047, 4, :o2, 39500915, 16 - tz.transition 2047, 10, :o3, 39503827, 16 - tz.transition 2048, 4, :o2, 39506739, 16 - tz.transition 2048, 10, :o3, 39509651, 16 - tz.transition 2049, 4, :o2, 39512563, 16 - tz.transition 2049, 10, :o3, 39515475, 16 - tz.transition 2050, 4, :o2, 39518387, 16 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Brisbane.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Brisbane.rb deleted file mode 100644 index dd85dda..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Brisbane.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Australia - module Brisbane - include TimezoneDefinition - - timezone 'Australia/Brisbane' do |tz| - tz.offset :o0, 36728, 0, :LMT - tz.offset :o1, 36000, 0, :EST - tz.offset :o2, 36000, 3600, :EST - - tz.transition 1894, 12, :o1, 26062496009, 10800 - tz.transition 1916, 12, :o2, 3486569881, 1440 - tz.transition 1917, 3, :o1, 19370497, 8 - tz.transition 1941, 12, :o2, 14582161, 6 - tz.transition 1942, 3, :o1, 19443577, 8 - tz.transition 1942, 9, :o2, 14583775, 6 - tz.transition 1943, 3, :o1, 19446489, 8 - tz.transition 1943, 10, :o2, 14586001, 6 - tz.transition 1944, 3, :o1, 19449401, 8 - tz.transition 1971, 10, :o2, 57686400 - tz.transition 1972, 2, :o1, 67968000 - tz.transition 1989, 10, :o2, 625593600 - tz.transition 1990, 3, :o1, 636480000 - tz.transition 1990, 10, :o2, 657043200 - tz.transition 1991, 3, :o1, 667929600 - tz.transition 1991, 10, :o2, 688492800 - tz.transition 1992, 2, :o1, 699379200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Darwin.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Darwin.rb deleted file mode 100644 index 17de881..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Darwin.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Australia - module Darwin - include TimezoneDefinition - - timezone 'Australia/Darwin' do |tz| - tz.offset :o0, 31400, 0, :LMT - tz.offset :o1, 32400, 0, :CST - tz.offset :o2, 34200, 0, :CST - tz.offset :o3, 34200, 3600, :CST - - tz.transition 1895, 1, :o1, 1042513259, 432 - tz.transition 1899, 4, :o2, 19318201, 8 - tz.transition 1916, 12, :o3, 3486569911, 1440 - tz.transition 1917, 3, :o2, 116222983, 48 - tz.transition 1941, 12, :o3, 38885763, 16 - tz.transition 1942, 3, :o2, 116661463, 48 - tz.transition 1942, 9, :o3, 38890067, 16 - tz.transition 1943, 3, :o2, 116678935, 48 - tz.transition 1943, 10, :o3, 38896003, 16 - tz.transition 1944, 3, :o2, 116696407, 48 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Hobart.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Hobart.rb deleted file mode 100644 index 11384b9..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Hobart.rb +++ /dev/null @@ -1,193 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Australia - module Hobart - include TimezoneDefinition - - timezone 'Australia/Hobart' do |tz| - tz.offset :o0, 35356, 0, :LMT - tz.offset :o1, 36000, 0, :EST - tz.offset :o2, 36000, 3600, :EST - - tz.transition 1895, 8, :o1, 52130241161, 21600 - tz.transition 1916, 9, :o2, 14526823, 6 - tz.transition 1917, 3, :o1, 19370497, 8 - tz.transition 1941, 12, :o2, 14582161, 6 - tz.transition 1942, 3, :o1, 19443577, 8 - tz.transition 1942, 9, :o2, 14583775, 6 - tz.transition 1943, 3, :o1, 19446489, 8 - tz.transition 1943, 10, :o2, 14586001, 6 - tz.transition 1944, 3, :o1, 19449401, 8 - tz.transition 1967, 9, :o2, 14638585, 6 - tz.transition 1968, 3, :o1, 14639677, 6 - tz.transition 1968, 10, :o2, 14640937, 6 - tz.transition 1969, 3, :o1, 14641735, 6 - tz.transition 1969, 10, :o2, 14643121, 6 - tz.transition 1970, 3, :o1, 5673600 - tz.transition 1970, 10, :o2, 25632000 - tz.transition 1971, 3, :o1, 37728000 - tz.transition 1971, 10, :o2, 57686400 - tz.transition 1972, 2, :o1, 67968000 - tz.transition 1972, 10, :o2, 89136000 - tz.transition 1973, 3, :o1, 100022400 - tz.transition 1973, 10, :o2, 120585600 - tz.transition 1974, 3, :o1, 131472000 - tz.transition 1974, 10, :o2, 152035200 - tz.transition 1975, 3, :o1, 162921600 - tz.transition 1975, 10, :o2, 183484800 - tz.transition 1976, 3, :o1, 194976000 - tz.transition 1976, 10, :o2, 215539200 - tz.transition 1977, 3, :o1, 226425600 - tz.transition 1977, 10, :o2, 246988800 - tz.transition 1978, 3, :o1, 257875200 - tz.transition 1978, 10, :o2, 278438400 - tz.transition 1979, 3, :o1, 289324800 - tz.transition 1979, 10, :o2, 309888000 - tz.transition 1980, 3, :o1, 320774400 - tz.transition 1980, 10, :o2, 341337600 - tz.transition 1981, 2, :o1, 352224000 - tz.transition 1981, 10, :o2, 372787200 - tz.transition 1982, 3, :o1, 386092800 - tz.transition 1982, 10, :o2, 404841600 - tz.transition 1983, 3, :o1, 417542400 - tz.transition 1983, 10, :o2, 436291200 - tz.transition 1984, 3, :o1, 447177600 - tz.transition 1984, 10, :o2, 467740800 - tz.transition 1985, 3, :o1, 478627200 - tz.transition 1985, 10, :o2, 499190400 - tz.transition 1986, 3, :o1, 510076800 - tz.transition 1986, 10, :o2, 530035200 - tz.transition 1987, 3, :o1, 542736000 - tz.transition 1987, 10, :o2, 562089600 - tz.transition 1988, 3, :o1, 574790400 - tz.transition 1988, 10, :o2, 594144000 - tz.transition 1989, 3, :o1, 606240000 - tz.transition 1989, 10, :o2, 625593600 - tz.transition 1990, 3, :o1, 637689600 - tz.transition 1990, 10, :o2, 657043200 - tz.transition 1991, 3, :o1, 670348800 - tz.transition 1991, 10, :o2, 686678400 - tz.transition 1992, 3, :o1, 701798400 - tz.transition 1992, 10, :o2, 718128000 - tz.transition 1993, 3, :o1, 733248000 - tz.transition 1993, 10, :o2, 749577600 - tz.transition 1994, 3, :o1, 764697600 - tz.transition 1994, 10, :o2, 781027200 - tz.transition 1995, 3, :o1, 796147200 - tz.transition 1995, 9, :o2, 812476800 - tz.transition 1996, 3, :o1, 828201600 - tz.transition 1996, 10, :o2, 844531200 - tz.transition 1997, 3, :o1, 859651200 - tz.transition 1997, 10, :o2, 875980800 - tz.transition 1998, 3, :o1, 891100800 - tz.transition 1998, 10, :o2, 907430400 - tz.transition 1999, 3, :o1, 922550400 - tz.transition 1999, 10, :o2, 938880000 - tz.transition 2000, 3, :o1, 954000000 - tz.transition 2000, 8, :o2, 967305600 - tz.transition 2001, 3, :o1, 985449600 - tz.transition 2001, 10, :o2, 1002384000 - tz.transition 2002, 3, :o1, 1017504000 - tz.transition 2002, 10, :o2, 1033833600 - tz.transition 2003, 3, :o1, 1048953600 - tz.transition 2003, 10, :o2, 1065283200 - tz.transition 2004, 3, :o1, 1080403200 - tz.transition 2004, 10, :o2, 1096732800 - tz.transition 2005, 3, :o1, 1111852800 - tz.transition 2005, 10, :o2, 1128182400 - tz.transition 2006, 4, :o1, 1143907200 - tz.transition 2006, 9, :o2, 1159632000 - tz.transition 2007, 3, :o1, 1174752000 - tz.transition 2007, 10, :o2, 1191686400 - tz.transition 2008, 4, :o1, 1207411200 - tz.transition 2008, 10, :o2, 1223136000 - tz.transition 2009, 4, :o1, 1238860800 - tz.transition 2009, 10, :o2, 1254585600 - tz.transition 2010, 4, :o1, 1270310400 - tz.transition 2010, 10, :o2, 1286035200 - tz.transition 2011, 4, :o1, 1301760000 - tz.transition 2011, 10, :o2, 1317484800 - tz.transition 2012, 3, :o1, 1333209600 - tz.transition 2012, 10, :o2, 1349539200 - tz.transition 2013, 4, :o1, 1365264000 - tz.transition 2013, 10, :o2, 1380988800 - tz.transition 2014, 4, :o1, 1396713600 - tz.transition 2014, 10, :o2, 1412438400 - tz.transition 2015, 4, :o1, 1428163200 - tz.transition 2015, 10, :o2, 1443888000 - tz.transition 2016, 4, :o1, 1459612800 - tz.transition 2016, 10, :o2, 1475337600 - tz.transition 2017, 4, :o1, 1491062400 - tz.transition 2017, 9, :o2, 1506787200 - tz.transition 2018, 3, :o1, 1522512000 - tz.transition 2018, 10, :o2, 1538841600 - tz.transition 2019, 4, :o1, 1554566400 - tz.transition 2019, 10, :o2, 1570291200 - tz.transition 2020, 4, :o1, 1586016000 - tz.transition 2020, 10, :o2, 1601740800 - tz.transition 2021, 4, :o1, 1617465600 - tz.transition 2021, 10, :o2, 1633190400 - tz.transition 2022, 4, :o1, 1648915200 - tz.transition 2022, 10, :o2, 1664640000 - tz.transition 2023, 4, :o1, 1680364800 - tz.transition 2023, 9, :o2, 1696089600 - tz.transition 2024, 4, :o1, 1712419200 - tz.transition 2024, 10, :o2, 1728144000 - tz.transition 2025, 4, :o1, 1743868800 - tz.transition 2025, 10, :o2, 1759593600 - tz.transition 2026, 4, :o1, 1775318400 - tz.transition 2026, 10, :o2, 1791043200 - tz.transition 2027, 4, :o1, 1806768000 - tz.transition 2027, 10, :o2, 1822492800 - tz.transition 2028, 4, :o1, 1838217600 - tz.transition 2028, 9, :o2, 1853942400 - tz.transition 2029, 3, :o1, 1869667200 - tz.transition 2029, 10, :o2, 1885996800 - tz.transition 2030, 4, :o1, 1901721600 - tz.transition 2030, 10, :o2, 1917446400 - tz.transition 2031, 4, :o1, 1933171200 - tz.transition 2031, 10, :o2, 1948896000 - tz.transition 2032, 4, :o1, 1964620800 - tz.transition 2032, 10, :o2, 1980345600 - tz.transition 2033, 4, :o1, 1996070400 - tz.transition 2033, 10, :o2, 2011795200 - tz.transition 2034, 4, :o1, 2027520000 - tz.transition 2034, 9, :o2, 2043244800 - tz.transition 2035, 3, :o1, 2058969600 - tz.transition 2035, 10, :o2, 2075299200 - tz.transition 2036, 4, :o1, 2091024000 - tz.transition 2036, 10, :o2, 2106748800 - tz.transition 2037, 4, :o1, 2122473600 - tz.transition 2037, 10, :o2, 2138198400 - tz.transition 2038, 4, :o1, 14793103, 6 - tz.transition 2038, 10, :o2, 14794195, 6 - tz.transition 2039, 4, :o1, 14795287, 6 - tz.transition 2039, 10, :o2, 14796379, 6 - tz.transition 2040, 3, :o1, 14797471, 6 - tz.transition 2040, 10, :o2, 14798605, 6 - tz.transition 2041, 4, :o1, 14799697, 6 - tz.transition 2041, 10, :o2, 14800789, 6 - tz.transition 2042, 4, :o1, 14801881, 6 - tz.transition 2042, 10, :o2, 14802973, 6 - tz.transition 2043, 4, :o1, 14804065, 6 - tz.transition 2043, 10, :o2, 14805157, 6 - tz.transition 2044, 4, :o1, 14806249, 6 - tz.transition 2044, 10, :o2, 14807341, 6 - tz.transition 2045, 4, :o1, 14808433, 6 - tz.transition 2045, 9, :o2, 14809525, 6 - tz.transition 2046, 3, :o1, 14810617, 6 - tz.transition 2046, 10, :o2, 14811751, 6 - tz.transition 2047, 4, :o1, 14812843, 6 - tz.transition 2047, 10, :o2, 14813935, 6 - tz.transition 2048, 4, :o1, 14815027, 6 - tz.transition 2048, 10, :o2, 14816119, 6 - tz.transition 2049, 4, :o1, 14817211, 6 - tz.transition 2049, 10, :o2, 14818303, 6 - tz.transition 2050, 4, :o1, 14819395, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Melbourne.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Melbourne.rb deleted file mode 100644 index c130448..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Melbourne.rb +++ /dev/null @@ -1,185 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Australia - module Melbourne - include TimezoneDefinition - - timezone 'Australia/Melbourne' do |tz| - tz.offset :o0, 34792, 0, :LMT - tz.offset :o1, 36000, 0, :EST - tz.offset :o2, 36000, 3600, :EST - - tz.transition 1895, 1, :o1, 26062831051, 10800 - tz.transition 1916, 12, :o2, 3486569881, 1440 - tz.transition 1917, 3, :o1, 19370497, 8 - tz.transition 1941, 12, :o2, 14582161, 6 - tz.transition 1942, 3, :o1, 19443577, 8 - tz.transition 1942, 9, :o2, 14583775, 6 - tz.transition 1943, 3, :o1, 19446489, 8 - tz.transition 1943, 10, :o2, 14586001, 6 - tz.transition 1944, 3, :o1, 19449401, 8 - tz.transition 1971, 10, :o2, 57686400 - tz.transition 1972, 2, :o1, 67968000 - tz.transition 1972, 10, :o2, 89136000 - tz.transition 1973, 3, :o1, 100022400 - tz.transition 1973, 10, :o2, 120585600 - tz.transition 1974, 3, :o1, 131472000 - tz.transition 1974, 10, :o2, 152035200 - tz.transition 1975, 3, :o1, 162921600 - tz.transition 1975, 10, :o2, 183484800 - tz.transition 1976, 3, :o1, 194976000 - tz.transition 1976, 10, :o2, 215539200 - tz.transition 1977, 3, :o1, 226425600 - tz.transition 1977, 10, :o2, 246988800 - tz.transition 1978, 3, :o1, 257875200 - tz.transition 1978, 10, :o2, 278438400 - tz.transition 1979, 3, :o1, 289324800 - tz.transition 1979, 10, :o2, 309888000 - tz.transition 1980, 3, :o1, 320774400 - tz.transition 1980, 10, :o2, 341337600 - tz.transition 1981, 2, :o1, 352224000 - tz.transition 1981, 10, :o2, 372787200 - tz.transition 1982, 3, :o1, 384278400 - tz.transition 1982, 10, :o2, 404841600 - tz.transition 1983, 3, :o1, 415728000 - tz.transition 1983, 10, :o2, 436291200 - tz.transition 1984, 3, :o1, 447177600 - tz.transition 1984, 10, :o2, 467740800 - tz.transition 1985, 3, :o1, 478627200 - tz.transition 1985, 10, :o2, 499190400 - tz.transition 1986, 3, :o1, 511286400 - tz.transition 1986, 10, :o2, 530035200 - tz.transition 1987, 3, :o1, 542736000 - tz.transition 1987, 10, :o2, 561484800 - tz.transition 1988, 3, :o1, 574790400 - tz.transition 1988, 10, :o2, 594144000 - tz.transition 1989, 3, :o1, 606240000 - tz.transition 1989, 10, :o2, 625593600 - tz.transition 1990, 3, :o1, 637689600 - tz.transition 1990, 10, :o2, 657043200 - tz.transition 1991, 3, :o1, 667929600 - tz.transition 1991, 10, :o2, 688492800 - tz.transition 1992, 2, :o1, 699379200 - tz.transition 1992, 10, :o2, 719942400 - tz.transition 1993, 3, :o1, 731433600 - tz.transition 1993, 10, :o2, 751996800 - tz.transition 1994, 3, :o1, 762883200 - tz.transition 1994, 10, :o2, 783446400 - tz.transition 1995, 3, :o1, 796147200 - tz.transition 1995, 10, :o2, 814896000 - tz.transition 1996, 3, :o1, 828201600 - tz.transition 1996, 10, :o2, 846345600 - tz.transition 1997, 3, :o1, 859651200 - tz.transition 1997, 10, :o2, 877795200 - tz.transition 1998, 3, :o1, 891100800 - tz.transition 1998, 10, :o2, 909244800 - tz.transition 1999, 3, :o1, 922550400 - tz.transition 1999, 10, :o2, 941299200 - tz.transition 2000, 3, :o1, 954000000 - tz.transition 2000, 8, :o2, 967305600 - tz.transition 2001, 3, :o1, 985449600 - tz.transition 2001, 10, :o2, 1004198400 - tz.transition 2002, 3, :o1, 1017504000 - tz.transition 2002, 10, :o2, 1035648000 - tz.transition 2003, 3, :o1, 1048953600 - tz.transition 2003, 10, :o2, 1067097600 - tz.transition 2004, 3, :o1, 1080403200 - tz.transition 2004, 10, :o2, 1099152000 - tz.transition 2005, 3, :o1, 1111852800 - tz.transition 2005, 10, :o2, 1130601600 - tz.transition 2006, 4, :o1, 1143907200 - tz.transition 2006, 10, :o2, 1162051200 - tz.transition 2007, 3, :o1, 1174752000 - tz.transition 2007, 10, :o2, 1193500800 - tz.transition 2008, 4, :o1, 1207411200 - tz.transition 2008, 10, :o2, 1223136000 - tz.transition 2009, 4, :o1, 1238860800 - tz.transition 2009, 10, :o2, 1254585600 - tz.transition 2010, 4, :o1, 1270310400 - tz.transition 2010, 10, :o2, 1286035200 - tz.transition 2011, 4, :o1, 1301760000 - tz.transition 2011, 10, :o2, 1317484800 - tz.transition 2012, 3, :o1, 1333209600 - tz.transition 2012, 10, :o2, 1349539200 - tz.transition 2013, 4, :o1, 1365264000 - tz.transition 2013, 10, :o2, 1380988800 - tz.transition 2014, 4, :o1, 1396713600 - tz.transition 2014, 10, :o2, 1412438400 - tz.transition 2015, 4, :o1, 1428163200 - tz.transition 2015, 10, :o2, 1443888000 - tz.transition 2016, 4, :o1, 1459612800 - tz.transition 2016, 10, :o2, 1475337600 - tz.transition 2017, 4, :o1, 1491062400 - tz.transition 2017, 9, :o2, 1506787200 - tz.transition 2018, 3, :o1, 1522512000 - tz.transition 2018, 10, :o2, 1538841600 - tz.transition 2019, 4, :o1, 1554566400 - tz.transition 2019, 10, :o2, 1570291200 - tz.transition 2020, 4, :o1, 1586016000 - tz.transition 2020, 10, :o2, 1601740800 - tz.transition 2021, 4, :o1, 1617465600 - tz.transition 2021, 10, :o2, 1633190400 - tz.transition 2022, 4, :o1, 1648915200 - tz.transition 2022, 10, :o2, 1664640000 - tz.transition 2023, 4, :o1, 1680364800 - tz.transition 2023, 9, :o2, 1696089600 - tz.transition 2024, 4, :o1, 1712419200 - tz.transition 2024, 10, :o2, 1728144000 - tz.transition 2025, 4, :o1, 1743868800 - tz.transition 2025, 10, :o2, 1759593600 - tz.transition 2026, 4, :o1, 1775318400 - tz.transition 2026, 10, :o2, 1791043200 - tz.transition 2027, 4, :o1, 1806768000 - tz.transition 2027, 10, :o2, 1822492800 - tz.transition 2028, 4, :o1, 1838217600 - tz.transition 2028, 9, :o2, 1853942400 - tz.transition 2029, 3, :o1, 1869667200 - tz.transition 2029, 10, :o2, 1885996800 - tz.transition 2030, 4, :o1, 1901721600 - tz.transition 2030, 10, :o2, 1917446400 - tz.transition 2031, 4, :o1, 1933171200 - tz.transition 2031, 10, :o2, 1948896000 - tz.transition 2032, 4, :o1, 1964620800 - tz.transition 2032, 10, :o2, 1980345600 - tz.transition 2033, 4, :o1, 1996070400 - tz.transition 2033, 10, :o2, 2011795200 - tz.transition 2034, 4, :o1, 2027520000 - tz.transition 2034, 9, :o2, 2043244800 - tz.transition 2035, 3, :o1, 2058969600 - tz.transition 2035, 10, :o2, 2075299200 - tz.transition 2036, 4, :o1, 2091024000 - tz.transition 2036, 10, :o2, 2106748800 - tz.transition 2037, 4, :o1, 2122473600 - tz.transition 2037, 10, :o2, 2138198400 - tz.transition 2038, 4, :o1, 14793103, 6 - tz.transition 2038, 10, :o2, 14794195, 6 - tz.transition 2039, 4, :o1, 14795287, 6 - tz.transition 2039, 10, :o2, 14796379, 6 - tz.transition 2040, 3, :o1, 14797471, 6 - tz.transition 2040, 10, :o2, 14798605, 6 - tz.transition 2041, 4, :o1, 14799697, 6 - tz.transition 2041, 10, :o2, 14800789, 6 - tz.transition 2042, 4, :o1, 14801881, 6 - tz.transition 2042, 10, :o2, 14802973, 6 - tz.transition 2043, 4, :o1, 14804065, 6 - tz.transition 2043, 10, :o2, 14805157, 6 - tz.transition 2044, 4, :o1, 14806249, 6 - tz.transition 2044, 10, :o2, 14807341, 6 - tz.transition 2045, 4, :o1, 14808433, 6 - tz.transition 2045, 9, :o2, 14809525, 6 - tz.transition 2046, 3, :o1, 14810617, 6 - tz.transition 2046, 10, :o2, 14811751, 6 - tz.transition 2047, 4, :o1, 14812843, 6 - tz.transition 2047, 10, :o2, 14813935, 6 - tz.transition 2048, 4, :o1, 14815027, 6 - tz.transition 2048, 10, :o2, 14816119, 6 - tz.transition 2049, 4, :o1, 14817211, 6 - tz.transition 2049, 10, :o2, 14818303, 6 - tz.transition 2050, 4, :o1, 14819395, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Perth.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Perth.rb deleted file mode 100644 index d9e66f1..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Perth.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Australia - module Perth - include TimezoneDefinition - - timezone 'Australia/Perth' do |tz| - tz.offset :o0, 27804, 0, :LMT - tz.offset :o1, 28800, 0, :WST - tz.offset :o2, 28800, 3600, :WST - - tz.transition 1895, 11, :o1, 17377402883, 7200 - tz.transition 1916, 12, :o2, 3486570001, 1440 - tz.transition 1917, 3, :o1, 58111493, 24 - tz.transition 1941, 12, :o2, 9721441, 4 - tz.transition 1942, 3, :o1, 58330733, 24 - tz.transition 1942, 9, :o2, 9722517, 4 - tz.transition 1943, 3, :o1, 58339469, 24 - tz.transition 1974, 10, :o2, 152042400 - tz.transition 1975, 3, :o1, 162928800 - tz.transition 1983, 10, :o2, 436298400 - tz.transition 1984, 3, :o1, 447184800 - tz.transition 1991, 11, :o2, 690314400 - tz.transition 1992, 2, :o1, 699386400 - tz.transition 2006, 12, :o2, 1165082400 - tz.transition 2007, 3, :o1, 1174759200 - tz.transition 2007, 10, :o2, 1193508000 - tz.transition 2008, 3, :o1, 1206813600 - tz.transition 2008, 10, :o2, 1224957600 - tz.transition 2009, 3, :o1, 1238263200 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Sydney.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Sydney.rb deleted file mode 100644 index 9062bd7..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Sydney.rb +++ /dev/null @@ -1,185 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Australia - module Sydney - include TimezoneDefinition - - timezone 'Australia/Sydney' do |tz| - tz.offset :o0, 36292, 0, :LMT - tz.offset :o1, 36000, 0, :EST - tz.offset :o2, 36000, 3600, :EST - - tz.transition 1895, 1, :o1, 52125661727, 21600 - tz.transition 1916, 12, :o2, 3486569881, 1440 - tz.transition 1917, 3, :o1, 19370497, 8 - tz.transition 1941, 12, :o2, 14582161, 6 - tz.transition 1942, 3, :o1, 19443577, 8 - tz.transition 1942, 9, :o2, 14583775, 6 - tz.transition 1943, 3, :o1, 19446489, 8 - tz.transition 1943, 10, :o2, 14586001, 6 - tz.transition 1944, 3, :o1, 19449401, 8 - tz.transition 1971, 10, :o2, 57686400 - tz.transition 1972, 2, :o1, 67968000 - tz.transition 1972, 10, :o2, 89136000 - tz.transition 1973, 3, :o1, 100022400 - tz.transition 1973, 10, :o2, 120585600 - tz.transition 1974, 3, :o1, 131472000 - tz.transition 1974, 10, :o2, 152035200 - tz.transition 1975, 3, :o1, 162921600 - tz.transition 1975, 10, :o2, 183484800 - tz.transition 1976, 3, :o1, 194976000 - tz.transition 1976, 10, :o2, 215539200 - tz.transition 1977, 3, :o1, 226425600 - tz.transition 1977, 10, :o2, 246988800 - tz.transition 1978, 3, :o1, 257875200 - tz.transition 1978, 10, :o2, 278438400 - tz.transition 1979, 3, :o1, 289324800 - tz.transition 1979, 10, :o2, 309888000 - tz.transition 1980, 3, :o1, 320774400 - tz.transition 1980, 10, :o2, 341337600 - tz.transition 1981, 2, :o1, 352224000 - tz.transition 1981, 10, :o2, 372787200 - tz.transition 1982, 4, :o1, 386697600 - tz.transition 1982, 10, :o2, 404841600 - tz.transition 1983, 3, :o1, 415728000 - tz.transition 1983, 10, :o2, 436291200 - tz.transition 1984, 3, :o1, 447177600 - tz.transition 1984, 10, :o2, 467740800 - tz.transition 1985, 3, :o1, 478627200 - tz.transition 1985, 10, :o2, 499190400 - tz.transition 1986, 3, :o1, 511286400 - tz.transition 1986, 10, :o2, 530035200 - tz.transition 1987, 3, :o1, 542736000 - tz.transition 1987, 10, :o2, 562089600 - tz.transition 1988, 3, :o1, 574790400 - tz.transition 1988, 10, :o2, 594144000 - tz.transition 1989, 3, :o1, 606240000 - tz.transition 1989, 10, :o2, 625593600 - tz.transition 1990, 3, :o1, 636480000 - tz.transition 1990, 10, :o2, 657043200 - tz.transition 1991, 3, :o1, 667929600 - tz.transition 1991, 10, :o2, 688492800 - tz.transition 1992, 2, :o1, 699379200 - tz.transition 1992, 10, :o2, 719942400 - tz.transition 1993, 3, :o1, 731433600 - tz.transition 1993, 10, :o2, 751996800 - tz.transition 1994, 3, :o1, 762883200 - tz.transition 1994, 10, :o2, 783446400 - tz.transition 1995, 3, :o1, 794332800 - tz.transition 1995, 10, :o2, 814896000 - tz.transition 1996, 3, :o1, 828201600 - tz.transition 1996, 10, :o2, 846345600 - tz.transition 1997, 3, :o1, 859651200 - tz.transition 1997, 10, :o2, 877795200 - tz.transition 1998, 3, :o1, 891100800 - tz.transition 1998, 10, :o2, 909244800 - tz.transition 1999, 3, :o1, 922550400 - tz.transition 1999, 10, :o2, 941299200 - tz.transition 2000, 3, :o1, 954000000 - tz.transition 2000, 8, :o2, 967305600 - tz.transition 2001, 3, :o1, 985449600 - tz.transition 2001, 10, :o2, 1004198400 - tz.transition 2002, 3, :o1, 1017504000 - tz.transition 2002, 10, :o2, 1035648000 - tz.transition 2003, 3, :o1, 1048953600 - tz.transition 2003, 10, :o2, 1067097600 - tz.transition 2004, 3, :o1, 1080403200 - tz.transition 2004, 10, :o2, 1099152000 - tz.transition 2005, 3, :o1, 1111852800 - tz.transition 2005, 10, :o2, 1130601600 - tz.transition 2006, 4, :o1, 1143907200 - tz.transition 2006, 10, :o2, 1162051200 - tz.transition 2007, 3, :o1, 1174752000 - tz.transition 2007, 10, :o2, 1193500800 - tz.transition 2008, 4, :o1, 1207411200 - tz.transition 2008, 10, :o2, 1223136000 - tz.transition 2009, 4, :o1, 1238860800 - tz.transition 2009, 10, :o2, 1254585600 - tz.transition 2010, 4, :o1, 1270310400 - tz.transition 2010, 10, :o2, 1286035200 - tz.transition 2011, 4, :o1, 1301760000 - tz.transition 2011, 10, :o2, 1317484800 - tz.transition 2012, 3, :o1, 1333209600 - tz.transition 2012, 10, :o2, 1349539200 - tz.transition 2013, 4, :o1, 1365264000 - tz.transition 2013, 10, :o2, 1380988800 - tz.transition 2014, 4, :o1, 1396713600 - tz.transition 2014, 10, :o2, 1412438400 - tz.transition 2015, 4, :o1, 1428163200 - tz.transition 2015, 10, :o2, 1443888000 - tz.transition 2016, 4, :o1, 1459612800 - tz.transition 2016, 10, :o2, 1475337600 - tz.transition 2017, 4, :o1, 1491062400 - tz.transition 2017, 9, :o2, 1506787200 - tz.transition 2018, 3, :o1, 1522512000 - tz.transition 2018, 10, :o2, 1538841600 - tz.transition 2019, 4, :o1, 1554566400 - tz.transition 2019, 10, :o2, 1570291200 - tz.transition 2020, 4, :o1, 1586016000 - tz.transition 2020, 10, :o2, 1601740800 - tz.transition 2021, 4, :o1, 1617465600 - tz.transition 2021, 10, :o2, 1633190400 - tz.transition 2022, 4, :o1, 1648915200 - tz.transition 2022, 10, :o2, 1664640000 - tz.transition 2023, 4, :o1, 1680364800 - tz.transition 2023, 9, :o2, 1696089600 - tz.transition 2024, 4, :o1, 1712419200 - tz.transition 2024, 10, :o2, 1728144000 - tz.transition 2025, 4, :o1, 1743868800 - tz.transition 2025, 10, :o2, 1759593600 - tz.transition 2026, 4, :o1, 1775318400 - tz.transition 2026, 10, :o2, 1791043200 - tz.transition 2027, 4, :o1, 1806768000 - tz.transition 2027, 10, :o2, 1822492800 - tz.transition 2028, 4, :o1, 1838217600 - tz.transition 2028, 9, :o2, 1853942400 - tz.transition 2029, 3, :o1, 1869667200 - tz.transition 2029, 10, :o2, 1885996800 - tz.transition 2030, 4, :o1, 1901721600 - tz.transition 2030, 10, :o2, 1917446400 - tz.transition 2031, 4, :o1, 1933171200 - tz.transition 2031, 10, :o2, 1948896000 - tz.transition 2032, 4, :o1, 1964620800 - tz.transition 2032, 10, :o2, 1980345600 - tz.transition 2033, 4, :o1, 1996070400 - tz.transition 2033, 10, :o2, 2011795200 - tz.transition 2034, 4, :o1, 2027520000 - tz.transition 2034, 9, :o2, 2043244800 - tz.transition 2035, 3, :o1, 2058969600 - tz.transition 2035, 10, :o2, 2075299200 - tz.transition 2036, 4, :o1, 2091024000 - tz.transition 2036, 10, :o2, 2106748800 - tz.transition 2037, 4, :o1, 2122473600 - tz.transition 2037, 10, :o2, 2138198400 - tz.transition 2038, 4, :o1, 14793103, 6 - tz.transition 2038, 10, :o2, 14794195, 6 - tz.transition 2039, 4, :o1, 14795287, 6 - tz.transition 2039, 10, :o2, 14796379, 6 - tz.transition 2040, 3, :o1, 14797471, 6 - tz.transition 2040, 10, :o2, 14798605, 6 - tz.transition 2041, 4, :o1, 14799697, 6 - tz.transition 2041, 10, :o2, 14800789, 6 - tz.transition 2042, 4, :o1, 14801881, 6 - tz.transition 2042, 10, :o2, 14802973, 6 - tz.transition 2043, 4, :o1, 14804065, 6 - tz.transition 2043, 10, :o2, 14805157, 6 - tz.transition 2044, 4, :o1, 14806249, 6 - tz.transition 2044, 10, :o2, 14807341, 6 - tz.transition 2045, 4, :o1, 14808433, 6 - tz.transition 2045, 9, :o2, 14809525, 6 - tz.transition 2046, 3, :o1, 14810617, 6 - tz.transition 2046, 10, :o2, 14811751, 6 - tz.transition 2047, 4, :o1, 14812843, 6 - tz.transition 2047, 10, :o2, 14813935, 6 - tz.transition 2048, 4, :o1, 14815027, 6 - tz.transition 2048, 10, :o2, 14816119, 6 - tz.transition 2049, 4, :o1, 14817211, 6 - tz.transition 2049, 10, :o2, 14818303, 6 - tz.transition 2050, 4, :o1, 14819395, 6 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Etc/UTC.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Etc/UTC.rb deleted file mode 100644 index 28b2c6a..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Etc/UTC.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Etc - module UTC - include TimezoneDefinition - - timezone 'Etc/UTC' do |tz| - tz.offset :o0, 0, 0, :UTC - - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Amsterdam.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Amsterdam.rb deleted file mode 100644 index 2d0c95c..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Amsterdam.rb +++ /dev/null @@ -1,228 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Amsterdam - include TimezoneDefinition - - timezone 'Europe/Amsterdam' do |tz| - tz.offset :o0, 1172, 0, :LMT - tz.offset :o1, 1172, 0, :AMT - tz.offset :o2, 1172, 3600, :NST - tz.offset :o3, 1200, 3600, :NEST - tz.offset :o4, 1200, 0, :NET - tz.offset :o5, 3600, 3600, :CEST - tz.offset :o6, 3600, 0, :CET - - tz.transition 1834, 12, :o1, 51651636907, 21600 - tz.transition 1916, 4, :o2, 52293264907, 21600 - tz.transition 1916, 9, :o1, 52296568807, 21600 - tz.transition 1917, 4, :o2, 52300826707, 21600 - tz.transition 1917, 9, :o1, 52304153107, 21600 - tz.transition 1918, 4, :o2, 52308386707, 21600 - tz.transition 1918, 9, :o1, 52312317907, 21600 - tz.transition 1919, 4, :o2, 52316400307, 21600 - tz.transition 1919, 9, :o1, 52320180307, 21600 - tz.transition 1920, 4, :o2, 52324262707, 21600 - tz.transition 1920, 9, :o1, 52328042707, 21600 - tz.transition 1921, 4, :o2, 52332125107, 21600 - tz.transition 1921, 9, :o1, 52335905107, 21600 - tz.transition 1922, 3, :o2, 52339814707, 21600 - tz.transition 1922, 10, :o1, 52344048307, 21600 - tz.transition 1923, 6, :o2, 52349145907, 21600 - tz.transition 1923, 10, :o1, 52351910707, 21600 - tz.transition 1924, 3, :o2, 52355690707, 21600 - tz.transition 1924, 10, :o1, 52359773107, 21600 - tz.transition 1925, 6, :o2, 52365021907, 21600 - tz.transition 1925, 10, :o1, 52367635507, 21600 - tz.transition 1926, 5, :o2, 52372452307, 21600 - tz.transition 1926, 10, :o1, 52375497907, 21600 - tz.transition 1927, 5, :o2, 52380336307, 21600 - tz.transition 1927, 10, :o1, 52383360307, 21600 - tz.transition 1928, 5, :o2, 52388241907, 21600 - tz.transition 1928, 10, :o1, 52391373907, 21600 - tz.transition 1929, 5, :o2, 52396125907, 21600 - tz.transition 1929, 10, :o1, 52399236307, 21600 - tz.transition 1930, 5, :o2, 52404009907, 21600 - tz.transition 1930, 10, :o1, 52407098707, 21600 - tz.transition 1931, 5, :o2, 52411893907, 21600 - tz.transition 1931, 10, :o1, 52414961107, 21600 - tz.transition 1932, 5, :o2, 52419950707, 21600 - tz.transition 1932, 10, :o1, 52422823507, 21600 - tz.transition 1933, 5, :o2, 52427683507, 21600 - tz.transition 1933, 10, :o1, 52430837107, 21600 - tz.transition 1934, 5, :o2, 52435567507, 21600 - tz.transition 1934, 10, :o1, 52438699507, 21600 - tz.transition 1935, 5, :o2, 52443451507, 21600 - tz.transition 1935, 10, :o1, 52446561907, 21600 - tz.transition 1936, 5, :o2, 52451357107, 21600 - tz.transition 1936, 10, :o1, 52454424307, 21600 - tz.transition 1937, 5, :o2, 52459392307, 21600 - tz.transition 1937, 6, :o3, 52460253607, 21600 - tz.transition 1937, 10, :o4, 174874289, 72 - tz.transition 1938, 5, :o3, 174890417, 72 - tz.transition 1938, 10, :o4, 174900497, 72 - tz.transition 1939, 5, :o3, 174916697, 72 - tz.transition 1939, 10, :o4, 174927209, 72 - tz.transition 1940, 5, :o5, 174943115, 72 - tz.transition 1942, 11, :o6, 58335973, 24 - tz.transition 1943, 3, :o5, 58339501, 24 - tz.transition 1943, 10, :o6, 58344037, 24 - tz.transition 1944, 4, :o5, 58348405, 24 - tz.transition 1944, 10, :o6, 58352773, 24 - tz.transition 1945, 4, :o5, 58357141, 24 - tz.transition 1945, 9, :o6, 58361149, 24 - tz.transition 1977, 4, :o5, 228877200 - tz.transition 1977, 9, :o6, 243997200 - tz.transition 1978, 4, :o5, 260326800 - tz.transition 1978, 10, :o6, 276051600 - tz.transition 1979, 4, :o5, 291776400 - tz.transition 1979, 9, :o6, 307501200 - tz.transition 1980, 4, :o5, 323830800 - tz.transition 1980, 9, :o6, 338950800 - tz.transition 1981, 3, :o5, 354675600 - tz.transition 1981, 9, :o6, 370400400 - tz.transition 1982, 3, :o5, 386125200 - tz.transition 1982, 9, :o6, 401850000 - tz.transition 1983, 3, :o5, 417574800 - tz.transition 1983, 9, :o6, 433299600 - tz.transition 1984, 3, :o5, 449024400 - tz.transition 1984, 9, :o6, 465354000 - tz.transition 1985, 3, :o5, 481078800 - tz.transition 1985, 9, :o6, 496803600 - tz.transition 1986, 3, :o5, 512528400 - tz.transition 1986, 9, :o6, 528253200 - tz.transition 1987, 3, :o5, 543978000 - tz.transition 1987, 9, :o6, 559702800 - tz.transition 1988, 3, :o5, 575427600 - tz.transition 1988, 9, :o6, 591152400 - tz.transition 1989, 3, :o5, 606877200 - tz.transition 1989, 9, :o6, 622602000 - tz.transition 1990, 3, :o5, 638326800 - tz.transition 1990, 9, :o6, 654656400 - tz.transition 1991, 3, :o5, 670381200 - tz.transition 1991, 9, :o6, 686106000 - tz.transition 1992, 3, :o5, 701830800 - tz.transition 1992, 9, :o6, 717555600 - tz.transition 1993, 3, :o5, 733280400 - tz.transition 1993, 9, :o6, 749005200 - tz.transition 1994, 3, :o5, 764730000 - tz.transition 1994, 9, :o6, 780454800 - tz.transition 1995, 3, :o5, 796179600 - tz.transition 1995, 9, :o6, 811904400 - tz.transition 1996, 3, :o5, 828234000 - tz.transition 1996, 10, :o6, 846378000 - tz.transition 1997, 3, :o5, 859683600 - tz.transition 1997, 10, :o6, 877827600 - tz.transition 1998, 3, :o5, 891133200 - tz.transition 1998, 10, :o6, 909277200 - tz.transition 1999, 3, :o5, 922582800 - tz.transition 1999, 10, :o6, 941331600 - tz.transition 2000, 3, :o5, 954032400 - tz.transition 2000, 10, :o6, 972781200 - tz.transition 2001, 3, :o5, 985482000 - tz.transition 2001, 10, :o6, 1004230800 - tz.transition 2002, 3, :o5, 1017536400 - tz.transition 2002, 10, :o6, 1035680400 - tz.transition 2003, 3, :o5, 1048986000 - tz.transition 2003, 10, :o6, 1067130000 - tz.transition 2004, 3, :o5, 1080435600 - tz.transition 2004, 10, :o6, 1099184400 - tz.transition 2005, 3, :o5, 1111885200 - tz.transition 2005, 10, :o6, 1130634000 - tz.transition 2006, 3, :o5, 1143334800 - tz.transition 2006, 10, :o6, 1162083600 - tz.transition 2007, 3, :o5, 1174784400 - tz.transition 2007, 10, :o6, 1193533200 - tz.transition 2008, 3, :o5, 1206838800 - tz.transition 2008, 10, :o6, 1224982800 - tz.transition 2009, 3, :o5, 1238288400 - tz.transition 2009, 10, :o6, 1256432400 - tz.transition 2010, 3, :o5, 1269738000 - tz.transition 2010, 10, :o6, 1288486800 - tz.transition 2011, 3, :o5, 1301187600 - tz.transition 2011, 10, :o6, 1319936400 - tz.transition 2012, 3, :o5, 1332637200 - tz.transition 2012, 10, :o6, 1351386000 - tz.transition 2013, 3, :o5, 1364691600 - tz.transition 2013, 10, :o6, 1382835600 - tz.transition 2014, 3, :o5, 1396141200 - tz.transition 2014, 10, :o6, 1414285200 - tz.transition 2015, 3, :o5, 1427590800 - tz.transition 2015, 10, :o6, 1445734800 - tz.transition 2016, 3, :o5, 1459040400 - tz.transition 2016, 10, :o6, 1477789200 - tz.transition 2017, 3, :o5, 1490490000 - tz.transition 2017, 10, :o6, 1509238800 - tz.transition 2018, 3, :o5, 1521939600 - tz.transition 2018, 10, :o6, 1540688400 - tz.transition 2019, 3, :o5, 1553994000 - tz.transition 2019, 10, :o6, 1572138000 - tz.transition 2020, 3, :o5, 1585443600 - tz.transition 2020, 10, :o6, 1603587600 - tz.transition 2021, 3, :o5, 1616893200 - tz.transition 2021, 10, :o6, 1635642000 - tz.transition 2022, 3, :o5, 1648342800 - tz.transition 2022, 10, :o6, 1667091600 - tz.transition 2023, 3, :o5, 1679792400 - tz.transition 2023, 10, :o6, 1698541200 - tz.transition 2024, 3, :o5, 1711846800 - tz.transition 2024, 10, :o6, 1729990800 - tz.transition 2025, 3, :o5, 1743296400 - tz.transition 2025, 10, :o6, 1761440400 - tz.transition 2026, 3, :o5, 1774746000 - tz.transition 2026, 10, :o6, 1792890000 - tz.transition 2027, 3, :o5, 1806195600 - tz.transition 2027, 10, :o6, 1824944400 - tz.transition 2028, 3, :o5, 1837645200 - tz.transition 2028, 10, :o6, 1856394000 - tz.transition 2029, 3, :o5, 1869094800 - tz.transition 2029, 10, :o6, 1887843600 - tz.transition 2030, 3, :o5, 1901149200 - tz.transition 2030, 10, :o6, 1919293200 - tz.transition 2031, 3, :o5, 1932598800 - tz.transition 2031, 10, :o6, 1950742800 - tz.transition 2032, 3, :o5, 1964048400 - tz.transition 2032, 10, :o6, 1982797200 - tz.transition 2033, 3, :o5, 1995498000 - tz.transition 2033, 10, :o6, 2014246800 - tz.transition 2034, 3, :o5, 2026947600 - tz.transition 2034, 10, :o6, 2045696400 - tz.transition 2035, 3, :o5, 2058397200 - tz.transition 2035, 10, :o6, 2077146000 - tz.transition 2036, 3, :o5, 2090451600 - tz.transition 2036, 10, :o6, 2108595600 - tz.transition 2037, 3, :o5, 2121901200 - tz.transition 2037, 10, :o6, 2140045200 - tz.transition 2038, 3, :o5, 59172253, 24 - tz.transition 2038, 10, :o6, 59177461, 24 - tz.transition 2039, 3, :o5, 59180989, 24 - tz.transition 2039, 10, :o6, 59186197, 24 - tz.transition 2040, 3, :o5, 59189725, 24 - tz.transition 2040, 10, :o6, 59194933, 24 - tz.transition 2041, 3, :o5, 59198629, 24 - tz.transition 2041, 10, :o6, 59203669, 24 - tz.transition 2042, 3, :o5, 59207365, 24 - tz.transition 2042, 10, :o6, 59212405, 24 - tz.transition 2043, 3, :o5, 59216101, 24 - tz.transition 2043, 10, :o6, 59221141, 24 - tz.transition 2044, 3, :o5, 59224837, 24 - tz.transition 2044, 10, :o6, 59230045, 24 - tz.transition 2045, 3, :o5, 59233573, 24 - tz.transition 2045, 10, :o6, 59238781, 24 - tz.transition 2046, 3, :o5, 59242309, 24 - tz.transition 2046, 10, :o6, 59247517, 24 - tz.transition 2047, 3, :o5, 59251213, 24 - tz.transition 2047, 10, :o6, 59256253, 24 - tz.transition 2048, 3, :o5, 59259949, 24 - tz.transition 2048, 10, :o6, 59264989, 24 - tz.transition 2049, 3, :o5, 59268685, 24 - tz.transition 2049, 10, :o6, 59273893, 24 - tz.transition 2050, 3, :o5, 59277421, 24 - tz.transition 2050, 10, :o6, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Athens.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Athens.rb deleted file mode 100644 index 4e21e53..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Athens.rb +++ /dev/null @@ -1,185 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Athens - include TimezoneDefinition - - timezone 'Europe/Athens' do |tz| - tz.offset :o0, 5692, 0, :LMT - tz.offset :o1, 5692, 0, :AMT - tz.offset :o2, 7200, 0, :EET - tz.offset :o3, 7200, 3600, :EEST - tz.offset :o4, 3600, 3600, :CEST - tz.offset :o5, 3600, 0, :CET - - tz.transition 1895, 9, :o1, 52130529377, 21600 - tz.transition 1916, 7, :o2, 3268447787, 1350 - tz.transition 1932, 7, :o3, 29122745, 12 - tz.transition 1932, 8, :o2, 19415611, 8 - tz.transition 1941, 4, :o3, 29161097, 12 - tz.transition 1941, 4, :o4, 19440915, 8 - tz.transition 1942, 11, :o5, 58335973, 24 - tz.transition 1943, 3, :o4, 58339523, 24 - tz.transition 1943, 10, :o5, 29172017, 12 - tz.transition 1944, 4, :o2, 58348427, 24 - tz.transition 1952, 6, :o3, 29210333, 12 - tz.transition 1952, 11, :o2, 19474547, 8 - tz.transition 1975, 4, :o3, 166485600 - tz.transition 1975, 11, :o2, 186184800 - tz.transition 1976, 4, :o3, 198028800 - tz.transition 1976, 10, :o2, 213753600 - tz.transition 1977, 4, :o3, 228873600 - tz.transition 1977, 9, :o2, 244080000 - tz.transition 1978, 4, :o3, 260323200 - tz.transition 1978, 9, :o2, 275446800 - tz.transition 1979, 4, :o3, 291798000 - tz.transition 1979, 9, :o2, 307407600 - tz.transition 1980, 3, :o3, 323388000 - tz.transition 1980, 9, :o2, 338936400 - tz.transition 1981, 3, :o3, 354675600 - tz.transition 1981, 9, :o2, 370400400 - tz.transition 1982, 3, :o3, 386125200 - tz.transition 1982, 9, :o2, 401850000 - tz.transition 1983, 3, :o3, 417574800 - tz.transition 1983, 9, :o2, 433299600 - tz.transition 1984, 3, :o3, 449024400 - tz.transition 1984, 9, :o2, 465354000 - tz.transition 1985, 3, :o3, 481078800 - tz.transition 1985, 9, :o2, 496803600 - tz.transition 1986, 3, :o3, 512528400 - tz.transition 1986, 9, :o2, 528253200 - tz.transition 1987, 3, :o3, 543978000 - tz.transition 1987, 9, :o2, 559702800 - tz.transition 1988, 3, :o3, 575427600 - tz.transition 1988, 9, :o2, 591152400 - tz.transition 1989, 3, :o3, 606877200 - tz.transition 1989, 9, :o2, 622602000 - tz.transition 1990, 3, :o3, 638326800 - tz.transition 1990, 9, :o2, 654656400 - tz.transition 1991, 3, :o3, 670381200 - tz.transition 1991, 9, :o2, 686106000 - tz.transition 1992, 3, :o3, 701830800 - tz.transition 1992, 9, :o2, 717555600 - tz.transition 1993, 3, :o3, 733280400 - tz.transition 1993, 9, :o2, 749005200 - tz.transition 1994, 3, :o3, 764730000 - tz.transition 1994, 9, :o2, 780454800 - tz.transition 1995, 3, :o3, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o3, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Belgrade.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Belgrade.rb deleted file mode 100644 index 4dbd893..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Belgrade.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Belgrade - include TimezoneDefinition - - timezone 'Europe/Belgrade' do |tz| - tz.offset :o0, 4920, 0, :LMT - tz.offset :o1, 3600, 0, :CET - tz.offset :o2, 3600, 3600, :CEST - - tz.transition 1883, 12, :o1, 1734607039, 720 - tz.transition 1941, 4, :o2, 29161241, 12 - tz.transition 1942, 11, :o1, 58335973, 24 - tz.transition 1943, 3, :o2, 58339501, 24 - tz.transition 1943, 10, :o1, 58344037, 24 - tz.transition 1944, 4, :o2, 58348405, 24 - tz.transition 1944, 10, :o1, 58352773, 24 - tz.transition 1945, 5, :o2, 58358005, 24 - tz.transition 1945, 9, :o1, 58361149, 24 - tz.transition 1983, 3, :o2, 417574800 - tz.transition 1983, 9, :o1, 433299600 - tz.transition 1984, 3, :o2, 449024400 - tz.transition 1984, 9, :o1, 465354000 - tz.transition 1985, 3, :o2, 481078800 - tz.transition 1985, 9, :o1, 496803600 - tz.transition 1986, 3, :o2, 512528400 - tz.transition 1986, 9, :o1, 528253200 - tz.transition 1987, 3, :o2, 543978000 - tz.transition 1987, 9, :o1, 559702800 - tz.transition 1988, 3, :o2, 575427600 - tz.transition 1988, 9, :o1, 591152400 - tz.transition 1989, 3, :o2, 606877200 - tz.transition 1989, 9, :o1, 622602000 - tz.transition 1990, 3, :o2, 638326800 - tz.transition 1990, 9, :o1, 654656400 - tz.transition 1991, 3, :o2, 670381200 - tz.transition 1991, 9, :o1, 686106000 - tz.transition 1992, 3, :o2, 701830800 - tz.transition 1992, 9, :o1, 717555600 - tz.transition 1993, 3, :o2, 733280400 - tz.transition 1993, 9, :o1, 749005200 - tz.transition 1994, 3, :o2, 764730000 - tz.transition 1994, 9, :o1, 780454800 - tz.transition 1995, 3, :o2, 796179600 - tz.transition 1995, 9, :o1, 811904400 - tz.transition 1996, 3, :o2, 828234000 - tz.transition 1996, 10, :o1, 846378000 - tz.transition 1997, 3, :o2, 859683600 - tz.transition 1997, 10, :o1, 877827600 - tz.transition 1998, 3, :o2, 891133200 - tz.transition 1998, 10, :o1, 909277200 - tz.transition 1999, 3, :o2, 922582800 - tz.transition 1999, 10, :o1, 941331600 - tz.transition 2000, 3, :o2, 954032400 - tz.transition 2000, 10, :o1, 972781200 - tz.transition 2001, 3, :o2, 985482000 - tz.transition 2001, 10, :o1, 1004230800 - tz.transition 2002, 3, :o2, 1017536400 - tz.transition 2002, 10, :o1, 1035680400 - tz.transition 2003, 3, :o2, 1048986000 - tz.transition 2003, 10, :o1, 1067130000 - tz.transition 2004, 3, :o2, 1080435600 - tz.transition 2004, 10, :o1, 1099184400 - tz.transition 2005, 3, :o2, 1111885200 - tz.transition 2005, 10, :o1, 1130634000 - tz.transition 2006, 3, :o2, 1143334800 - tz.transition 2006, 10, :o1, 1162083600 - tz.transition 2007, 3, :o2, 1174784400 - tz.transition 2007, 10, :o1, 1193533200 - tz.transition 2008, 3, :o2, 1206838800 - tz.transition 2008, 10, :o1, 1224982800 - tz.transition 2009, 3, :o2, 1238288400 - tz.transition 2009, 10, :o1, 1256432400 - tz.transition 2010, 3, :o2, 1269738000 - tz.transition 2010, 10, :o1, 1288486800 - tz.transition 2011, 3, :o2, 1301187600 - tz.transition 2011, 10, :o1, 1319936400 - tz.transition 2012, 3, :o2, 1332637200 - tz.transition 2012, 10, :o1, 1351386000 - tz.transition 2013, 3, :o2, 1364691600 - tz.transition 2013, 10, :o1, 1382835600 - tz.transition 2014, 3, :o2, 1396141200 - tz.transition 2014, 10, :o1, 1414285200 - tz.transition 2015, 3, :o2, 1427590800 - tz.transition 2015, 10, :o1, 1445734800 - tz.transition 2016, 3, :o2, 1459040400 - tz.transition 2016, 10, :o1, 1477789200 - tz.transition 2017, 3, :o2, 1490490000 - tz.transition 2017, 10, :o1, 1509238800 - tz.transition 2018, 3, :o2, 1521939600 - tz.transition 2018, 10, :o1, 1540688400 - tz.transition 2019, 3, :o2, 1553994000 - tz.transition 2019, 10, :o1, 1572138000 - tz.transition 2020, 3, :o2, 1585443600 - tz.transition 2020, 10, :o1, 1603587600 - tz.transition 2021, 3, :o2, 1616893200 - tz.transition 2021, 10, :o1, 1635642000 - tz.transition 2022, 3, :o2, 1648342800 - tz.transition 2022, 10, :o1, 1667091600 - tz.transition 2023, 3, :o2, 1679792400 - tz.transition 2023, 10, :o1, 1698541200 - tz.transition 2024, 3, :o2, 1711846800 - tz.transition 2024, 10, :o1, 1729990800 - tz.transition 2025, 3, :o2, 1743296400 - tz.transition 2025, 10, :o1, 1761440400 - tz.transition 2026, 3, :o2, 1774746000 - tz.transition 2026, 10, :o1, 1792890000 - tz.transition 2027, 3, :o2, 1806195600 - tz.transition 2027, 10, :o1, 1824944400 - tz.transition 2028, 3, :o2, 1837645200 - tz.transition 2028, 10, :o1, 1856394000 - tz.transition 2029, 3, :o2, 1869094800 - tz.transition 2029, 10, :o1, 1887843600 - tz.transition 2030, 3, :o2, 1901149200 - tz.transition 2030, 10, :o1, 1919293200 - tz.transition 2031, 3, :o2, 1932598800 - tz.transition 2031, 10, :o1, 1950742800 - tz.transition 2032, 3, :o2, 1964048400 - tz.transition 2032, 10, :o1, 1982797200 - tz.transition 2033, 3, :o2, 1995498000 - tz.transition 2033, 10, :o1, 2014246800 - tz.transition 2034, 3, :o2, 2026947600 - tz.transition 2034, 10, :o1, 2045696400 - tz.transition 2035, 3, :o2, 2058397200 - tz.transition 2035, 10, :o1, 2077146000 - tz.transition 2036, 3, :o2, 2090451600 - tz.transition 2036, 10, :o1, 2108595600 - tz.transition 2037, 3, :o2, 2121901200 - tz.transition 2037, 10, :o1, 2140045200 - tz.transition 2038, 3, :o2, 59172253, 24 - tz.transition 2038, 10, :o1, 59177461, 24 - tz.transition 2039, 3, :o2, 59180989, 24 - tz.transition 2039, 10, :o1, 59186197, 24 - tz.transition 2040, 3, :o2, 59189725, 24 - tz.transition 2040, 10, :o1, 59194933, 24 - tz.transition 2041, 3, :o2, 59198629, 24 - tz.transition 2041, 10, :o1, 59203669, 24 - tz.transition 2042, 3, :o2, 59207365, 24 - tz.transition 2042, 10, :o1, 59212405, 24 - tz.transition 2043, 3, :o2, 59216101, 24 - tz.transition 2043, 10, :o1, 59221141, 24 - tz.transition 2044, 3, :o2, 59224837, 24 - tz.transition 2044, 10, :o1, 59230045, 24 - tz.transition 2045, 3, :o2, 59233573, 24 - tz.transition 2045, 10, :o1, 59238781, 24 - tz.transition 2046, 3, :o2, 59242309, 24 - tz.transition 2046, 10, :o1, 59247517, 24 - tz.transition 2047, 3, :o2, 59251213, 24 - tz.transition 2047, 10, :o1, 59256253, 24 - tz.transition 2048, 3, :o2, 59259949, 24 - tz.transition 2048, 10, :o1, 59264989, 24 - tz.transition 2049, 3, :o2, 59268685, 24 - tz.transition 2049, 10, :o1, 59273893, 24 - tz.transition 2050, 3, :o2, 59277421, 24 - tz.transition 2050, 10, :o1, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Berlin.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Berlin.rb deleted file mode 100644 index 7210542..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Berlin.rb +++ /dev/null @@ -1,188 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Berlin - include TimezoneDefinition - - timezone 'Europe/Berlin' do |tz| - tz.offset :o0, 3208, 0, :LMT - tz.offset :o1, 3600, 0, :CET - tz.offset :o2, 3600, 3600, :CEST - tz.offset :o3, 3600, 7200, :CEMT - - tz.transition 1893, 3, :o1, 26055588199, 10800 - tz.transition 1916, 4, :o2, 29051813, 12 - tz.transition 1916, 9, :o1, 58107299, 24 - tz.transition 1917, 4, :o2, 58112029, 24 - tz.transition 1917, 9, :o1, 58115725, 24 - tz.transition 1918, 4, :o2, 58120765, 24 - tz.transition 1918, 9, :o1, 58124461, 24 - tz.transition 1940, 4, :o2, 58313293, 24 - tz.transition 1942, 11, :o1, 58335973, 24 - tz.transition 1943, 3, :o2, 58339501, 24 - tz.transition 1943, 10, :o1, 58344037, 24 - tz.transition 1944, 4, :o2, 58348405, 24 - tz.transition 1944, 10, :o1, 58352773, 24 - tz.transition 1945, 4, :o2, 58357141, 24 - tz.transition 1945, 5, :o3, 4863199, 2 - tz.transition 1945, 9, :o2, 4863445, 2 - tz.transition 1945, 11, :o1, 58362661, 24 - tz.transition 1946, 4, :o2, 58366189, 24 - tz.transition 1946, 10, :o1, 58370413, 24 - tz.transition 1947, 4, :o2, 29187379, 12 - tz.transition 1947, 5, :o3, 58375597, 24 - tz.transition 1947, 6, :o2, 4864731, 2 - tz.transition 1947, 10, :o1, 58379125, 24 - tz.transition 1948, 4, :o2, 58383829, 24 - tz.transition 1948, 10, :o1, 58387861, 24 - tz.transition 1949, 4, :o2, 58392397, 24 - tz.transition 1949, 10, :o1, 58396597, 24 - tz.transition 1980, 4, :o2, 323830800 - tz.transition 1980, 9, :o1, 338950800 - tz.transition 1981, 3, :o2, 354675600 - tz.transition 1981, 9, :o1, 370400400 - tz.transition 1982, 3, :o2, 386125200 - tz.transition 1982, 9, :o1, 401850000 - tz.transition 1983, 3, :o2, 417574800 - tz.transition 1983, 9, :o1, 433299600 - tz.transition 1984, 3, :o2, 449024400 - tz.transition 1984, 9, :o1, 465354000 - tz.transition 1985, 3, :o2, 481078800 - tz.transition 1985, 9, :o1, 496803600 - tz.transition 1986, 3, :o2, 512528400 - tz.transition 1986, 9, :o1, 528253200 - tz.transition 1987, 3, :o2, 543978000 - tz.transition 1987, 9, :o1, 559702800 - tz.transition 1988, 3, :o2, 575427600 - tz.transition 1988, 9, :o1, 591152400 - tz.transition 1989, 3, :o2, 606877200 - tz.transition 1989, 9, :o1, 622602000 - tz.transition 1990, 3, :o2, 638326800 - tz.transition 1990, 9, :o1, 654656400 - tz.transition 1991, 3, :o2, 670381200 - tz.transition 1991, 9, :o1, 686106000 - tz.transition 1992, 3, :o2, 701830800 - tz.transition 1992, 9, :o1, 717555600 - tz.transition 1993, 3, :o2, 733280400 - tz.transition 1993, 9, :o1, 749005200 - tz.transition 1994, 3, :o2, 764730000 - tz.transition 1994, 9, :o1, 780454800 - tz.transition 1995, 3, :o2, 796179600 - tz.transition 1995, 9, :o1, 811904400 - tz.transition 1996, 3, :o2, 828234000 - tz.transition 1996, 10, :o1, 846378000 - tz.transition 1997, 3, :o2, 859683600 - tz.transition 1997, 10, :o1, 877827600 - tz.transition 1998, 3, :o2, 891133200 - tz.transition 1998, 10, :o1, 909277200 - tz.transition 1999, 3, :o2, 922582800 - tz.transition 1999, 10, :o1, 941331600 - tz.transition 2000, 3, :o2, 954032400 - tz.transition 2000, 10, :o1, 972781200 - tz.transition 2001, 3, :o2, 985482000 - tz.transition 2001, 10, :o1, 1004230800 - tz.transition 2002, 3, :o2, 1017536400 - tz.transition 2002, 10, :o1, 1035680400 - tz.transition 2003, 3, :o2, 1048986000 - tz.transition 2003, 10, :o1, 1067130000 - tz.transition 2004, 3, :o2, 1080435600 - tz.transition 2004, 10, :o1, 1099184400 - tz.transition 2005, 3, :o2, 1111885200 - tz.transition 2005, 10, :o1, 1130634000 - tz.transition 2006, 3, :o2, 1143334800 - tz.transition 2006, 10, :o1, 1162083600 - tz.transition 2007, 3, :o2, 1174784400 - tz.transition 2007, 10, :o1, 1193533200 - tz.transition 2008, 3, :o2, 1206838800 - tz.transition 2008, 10, :o1, 1224982800 - tz.transition 2009, 3, :o2, 1238288400 - tz.transition 2009, 10, :o1, 1256432400 - tz.transition 2010, 3, :o2, 1269738000 - tz.transition 2010, 10, :o1, 1288486800 - tz.transition 2011, 3, :o2, 1301187600 - tz.transition 2011, 10, :o1, 1319936400 - tz.transition 2012, 3, :o2, 1332637200 - tz.transition 2012, 10, :o1, 1351386000 - tz.transition 2013, 3, :o2, 1364691600 - tz.transition 2013, 10, :o1, 1382835600 - tz.transition 2014, 3, :o2, 1396141200 - tz.transition 2014, 10, :o1, 1414285200 - tz.transition 2015, 3, :o2, 1427590800 - tz.transition 2015, 10, :o1, 1445734800 - tz.transition 2016, 3, :o2, 1459040400 - tz.transition 2016, 10, :o1, 1477789200 - tz.transition 2017, 3, :o2, 1490490000 - tz.transition 2017, 10, :o1, 1509238800 - tz.transition 2018, 3, :o2, 1521939600 - tz.transition 2018, 10, :o1, 1540688400 - tz.transition 2019, 3, :o2, 1553994000 - tz.transition 2019, 10, :o1, 1572138000 - tz.transition 2020, 3, :o2, 1585443600 - tz.transition 2020, 10, :o1, 1603587600 - tz.transition 2021, 3, :o2, 1616893200 - tz.transition 2021, 10, :o1, 1635642000 - tz.transition 2022, 3, :o2, 1648342800 - tz.transition 2022, 10, :o1, 1667091600 - tz.transition 2023, 3, :o2, 1679792400 - tz.transition 2023, 10, :o1, 1698541200 - tz.transition 2024, 3, :o2, 1711846800 - tz.transition 2024, 10, :o1, 1729990800 - tz.transition 2025, 3, :o2, 1743296400 - tz.transition 2025, 10, :o1, 1761440400 - tz.transition 2026, 3, :o2, 1774746000 - tz.transition 2026, 10, :o1, 1792890000 - tz.transition 2027, 3, :o2, 1806195600 - tz.transition 2027, 10, :o1, 1824944400 - tz.transition 2028, 3, :o2, 1837645200 - tz.transition 2028, 10, :o1, 1856394000 - tz.transition 2029, 3, :o2, 1869094800 - tz.transition 2029, 10, :o1, 1887843600 - tz.transition 2030, 3, :o2, 1901149200 - tz.transition 2030, 10, :o1, 1919293200 - tz.transition 2031, 3, :o2, 1932598800 - tz.transition 2031, 10, :o1, 1950742800 - tz.transition 2032, 3, :o2, 1964048400 - tz.transition 2032, 10, :o1, 1982797200 - tz.transition 2033, 3, :o2, 1995498000 - tz.transition 2033, 10, :o1, 2014246800 - tz.transition 2034, 3, :o2, 2026947600 - tz.transition 2034, 10, :o1, 2045696400 - tz.transition 2035, 3, :o2, 2058397200 - tz.transition 2035, 10, :o1, 2077146000 - tz.transition 2036, 3, :o2, 2090451600 - tz.transition 2036, 10, :o1, 2108595600 - tz.transition 2037, 3, :o2, 2121901200 - tz.transition 2037, 10, :o1, 2140045200 - tz.transition 2038, 3, :o2, 59172253, 24 - tz.transition 2038, 10, :o1, 59177461, 24 - tz.transition 2039, 3, :o2, 59180989, 24 - tz.transition 2039, 10, :o1, 59186197, 24 - tz.transition 2040, 3, :o2, 59189725, 24 - tz.transition 2040, 10, :o1, 59194933, 24 - tz.transition 2041, 3, :o2, 59198629, 24 - tz.transition 2041, 10, :o1, 59203669, 24 - tz.transition 2042, 3, :o2, 59207365, 24 - tz.transition 2042, 10, :o1, 59212405, 24 - tz.transition 2043, 3, :o2, 59216101, 24 - tz.transition 2043, 10, :o1, 59221141, 24 - tz.transition 2044, 3, :o2, 59224837, 24 - tz.transition 2044, 10, :o1, 59230045, 24 - tz.transition 2045, 3, :o2, 59233573, 24 - tz.transition 2045, 10, :o1, 59238781, 24 - tz.transition 2046, 3, :o2, 59242309, 24 - tz.transition 2046, 10, :o1, 59247517, 24 - tz.transition 2047, 3, :o2, 59251213, 24 - tz.transition 2047, 10, :o1, 59256253, 24 - tz.transition 2048, 3, :o2, 59259949, 24 - tz.transition 2048, 10, :o1, 59264989, 24 - tz.transition 2049, 3, :o2, 59268685, 24 - tz.transition 2049, 10, :o1, 59273893, 24 - tz.transition 2050, 3, :o2, 59277421, 24 - tz.transition 2050, 10, :o1, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bratislava.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bratislava.rb deleted file mode 100644 index 7a731a0..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bratislava.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Bratislava - include TimezoneDefinition - - linked_timezone 'Europe/Bratislava', 'Europe/Prague' - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Brussels.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Brussels.rb deleted file mode 100644 index 6b0a242..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Brussels.rb +++ /dev/null @@ -1,232 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Brussels - include TimezoneDefinition - - timezone 'Europe/Brussels' do |tz| - tz.offset :o0, 1050, 0, :LMT - tz.offset :o1, 1050, 0, :BMT - tz.offset :o2, 0, 0, :WET - tz.offset :o3, 3600, 0, :CET - tz.offset :o4, 3600, 3600, :CEST - tz.offset :o5, 0, 3600, :WEST - - tz.transition 1879, 12, :o1, 1386844121, 576 - tz.transition 1892, 5, :o2, 1389438713, 576 - tz.transition 1914, 11, :o3, 4840889, 2 - tz.transition 1916, 4, :o4, 58103627, 24 - tz.transition 1916, 9, :o3, 58107299, 24 - tz.transition 1917, 4, :o4, 58112029, 24 - tz.transition 1917, 9, :o3, 58115725, 24 - tz.transition 1918, 4, :o4, 58120765, 24 - tz.transition 1918, 9, :o3, 58124461, 24 - tz.transition 1918, 11, :o2, 58125815, 24 - tz.transition 1919, 3, :o5, 58128467, 24 - tz.transition 1919, 10, :o2, 58133675, 24 - tz.transition 1920, 2, :o5, 58136867, 24 - tz.transition 1920, 10, :o2, 58142915, 24 - tz.transition 1921, 3, :o5, 58146323, 24 - tz.transition 1921, 10, :o2, 58151723, 24 - tz.transition 1922, 3, :o5, 58155347, 24 - tz.transition 1922, 10, :o2, 58160051, 24 - tz.transition 1923, 4, :o5, 58164755, 24 - tz.transition 1923, 10, :o2, 58168787, 24 - tz.transition 1924, 3, :o5, 58172987, 24 - tz.transition 1924, 10, :o2, 58177523, 24 - tz.transition 1925, 4, :o5, 58181891, 24 - tz.transition 1925, 10, :o2, 58186259, 24 - tz.transition 1926, 4, :o5, 58190963, 24 - tz.transition 1926, 10, :o2, 58194995, 24 - tz.transition 1927, 4, :o5, 58199531, 24 - tz.transition 1927, 10, :o2, 58203731, 24 - tz.transition 1928, 4, :o5, 58208435, 24 - tz.transition 1928, 10, :o2, 29106319, 12 - tz.transition 1929, 4, :o5, 29108671, 12 - tz.transition 1929, 10, :o2, 29110687, 12 - tz.transition 1930, 4, :o5, 29112955, 12 - tz.transition 1930, 10, :o2, 29115055, 12 - tz.transition 1931, 4, :o5, 29117407, 12 - tz.transition 1931, 10, :o2, 29119423, 12 - tz.transition 1932, 4, :o5, 29121607, 12 - tz.transition 1932, 10, :o2, 29123791, 12 - tz.transition 1933, 3, :o5, 29125891, 12 - tz.transition 1933, 10, :o2, 29128243, 12 - tz.transition 1934, 4, :o5, 29130427, 12 - tz.transition 1934, 10, :o2, 29132611, 12 - tz.transition 1935, 3, :o5, 29134711, 12 - tz.transition 1935, 10, :o2, 29136979, 12 - tz.transition 1936, 4, :o5, 29139331, 12 - tz.transition 1936, 10, :o2, 29141347, 12 - tz.transition 1937, 4, :o5, 29143531, 12 - tz.transition 1937, 10, :o2, 29145715, 12 - tz.transition 1938, 3, :o5, 29147815, 12 - tz.transition 1938, 10, :o2, 29150083, 12 - tz.transition 1939, 4, :o5, 29152435, 12 - tz.transition 1939, 11, :o2, 29155039, 12 - tz.transition 1940, 2, :o5, 29156215, 12 - tz.transition 1940, 5, :o4, 29157235, 12 - tz.transition 1942, 11, :o3, 58335973, 24 - tz.transition 1943, 3, :o4, 58339501, 24 - tz.transition 1943, 10, :o3, 58344037, 24 - tz.transition 1944, 4, :o4, 58348405, 24 - tz.transition 1944, 9, :o3, 58352413, 24 - tz.transition 1945, 4, :o4, 58357141, 24 - tz.transition 1945, 9, :o3, 58361149, 24 - tz.transition 1946, 5, :o4, 58367029, 24 - tz.transition 1946, 10, :o3, 58370413, 24 - tz.transition 1977, 4, :o4, 228877200 - tz.transition 1977, 9, :o3, 243997200 - tz.transition 1978, 4, :o4, 260326800 - tz.transition 1978, 10, :o3, 276051600 - tz.transition 1979, 4, :o4, 291776400 - tz.transition 1979, 9, :o3, 307501200 - tz.transition 1980, 4, :o4, 323830800 - tz.transition 1980, 9, :o3, 338950800 - tz.transition 1981, 3, :o4, 354675600 - tz.transition 1981, 9, :o3, 370400400 - tz.transition 1982, 3, :o4, 386125200 - tz.transition 1982, 9, :o3, 401850000 - tz.transition 1983, 3, :o4, 417574800 - tz.transition 1983, 9, :o3, 433299600 - tz.transition 1984, 3, :o4, 449024400 - tz.transition 1984, 9, :o3, 465354000 - tz.transition 1985, 3, :o4, 481078800 - tz.transition 1985, 9, :o3, 496803600 - tz.transition 1986, 3, :o4, 512528400 - tz.transition 1986, 9, :o3, 528253200 - tz.transition 1987, 3, :o4, 543978000 - tz.transition 1987, 9, :o3, 559702800 - tz.transition 1988, 3, :o4, 575427600 - tz.transition 1988, 9, :o3, 591152400 - tz.transition 1989, 3, :o4, 606877200 - tz.transition 1989, 9, :o3, 622602000 - tz.transition 1990, 3, :o4, 638326800 - tz.transition 1990, 9, :o3, 654656400 - tz.transition 1991, 3, :o4, 670381200 - tz.transition 1991, 9, :o3, 686106000 - tz.transition 1992, 3, :o4, 701830800 - tz.transition 1992, 9, :o3, 717555600 - tz.transition 1993, 3, :o4, 733280400 - tz.transition 1993, 9, :o3, 749005200 - tz.transition 1994, 3, :o4, 764730000 - tz.transition 1994, 9, :o3, 780454800 - tz.transition 1995, 3, :o4, 796179600 - tz.transition 1995, 9, :o3, 811904400 - tz.transition 1996, 3, :o4, 828234000 - tz.transition 1996, 10, :o3, 846378000 - tz.transition 1997, 3, :o4, 859683600 - tz.transition 1997, 10, :o3, 877827600 - tz.transition 1998, 3, :o4, 891133200 - tz.transition 1998, 10, :o3, 909277200 - tz.transition 1999, 3, :o4, 922582800 - tz.transition 1999, 10, :o3, 941331600 - tz.transition 2000, 3, :o4, 954032400 - tz.transition 2000, 10, :o3, 972781200 - tz.transition 2001, 3, :o4, 985482000 - tz.transition 2001, 10, :o3, 1004230800 - tz.transition 2002, 3, :o4, 1017536400 - tz.transition 2002, 10, :o3, 1035680400 - tz.transition 2003, 3, :o4, 1048986000 - tz.transition 2003, 10, :o3, 1067130000 - tz.transition 2004, 3, :o4, 1080435600 - tz.transition 2004, 10, :o3, 1099184400 - tz.transition 2005, 3, :o4, 1111885200 - tz.transition 2005, 10, :o3, 1130634000 - tz.transition 2006, 3, :o4, 1143334800 - tz.transition 2006, 10, :o3, 1162083600 - tz.transition 2007, 3, :o4, 1174784400 - tz.transition 2007, 10, :o3, 1193533200 - tz.transition 2008, 3, :o4, 1206838800 - tz.transition 2008, 10, :o3, 1224982800 - tz.transition 2009, 3, :o4, 1238288400 - tz.transition 2009, 10, :o3, 1256432400 - tz.transition 2010, 3, :o4, 1269738000 - tz.transition 2010, 10, :o3, 1288486800 - tz.transition 2011, 3, :o4, 1301187600 - tz.transition 2011, 10, :o3, 1319936400 - tz.transition 2012, 3, :o4, 1332637200 - tz.transition 2012, 10, :o3, 1351386000 - tz.transition 2013, 3, :o4, 1364691600 - tz.transition 2013, 10, :o3, 1382835600 - tz.transition 2014, 3, :o4, 1396141200 - tz.transition 2014, 10, :o3, 1414285200 - tz.transition 2015, 3, :o4, 1427590800 - tz.transition 2015, 10, :o3, 1445734800 - tz.transition 2016, 3, :o4, 1459040400 - tz.transition 2016, 10, :o3, 1477789200 - tz.transition 2017, 3, :o4, 1490490000 - tz.transition 2017, 10, :o3, 1509238800 - tz.transition 2018, 3, :o4, 1521939600 - tz.transition 2018, 10, :o3, 1540688400 - tz.transition 2019, 3, :o4, 1553994000 - tz.transition 2019, 10, :o3, 1572138000 - tz.transition 2020, 3, :o4, 1585443600 - tz.transition 2020, 10, :o3, 1603587600 - tz.transition 2021, 3, :o4, 1616893200 - tz.transition 2021, 10, :o3, 1635642000 - tz.transition 2022, 3, :o4, 1648342800 - tz.transition 2022, 10, :o3, 1667091600 - tz.transition 2023, 3, :o4, 1679792400 - tz.transition 2023, 10, :o3, 1698541200 - tz.transition 2024, 3, :o4, 1711846800 - tz.transition 2024, 10, :o3, 1729990800 - tz.transition 2025, 3, :o4, 1743296400 - tz.transition 2025, 10, :o3, 1761440400 - tz.transition 2026, 3, :o4, 1774746000 - tz.transition 2026, 10, :o3, 1792890000 - tz.transition 2027, 3, :o4, 1806195600 - tz.transition 2027, 10, :o3, 1824944400 - tz.transition 2028, 3, :o4, 1837645200 - tz.transition 2028, 10, :o3, 1856394000 - tz.transition 2029, 3, :o4, 1869094800 - tz.transition 2029, 10, :o3, 1887843600 - tz.transition 2030, 3, :o4, 1901149200 - tz.transition 2030, 10, :o3, 1919293200 - tz.transition 2031, 3, :o4, 1932598800 - tz.transition 2031, 10, :o3, 1950742800 - tz.transition 2032, 3, :o4, 1964048400 - tz.transition 2032, 10, :o3, 1982797200 - tz.transition 2033, 3, :o4, 1995498000 - tz.transition 2033, 10, :o3, 2014246800 - tz.transition 2034, 3, :o4, 2026947600 - tz.transition 2034, 10, :o3, 2045696400 - tz.transition 2035, 3, :o4, 2058397200 - tz.transition 2035, 10, :o3, 2077146000 - tz.transition 2036, 3, :o4, 2090451600 - tz.transition 2036, 10, :o3, 2108595600 - tz.transition 2037, 3, :o4, 2121901200 - tz.transition 2037, 10, :o3, 2140045200 - tz.transition 2038, 3, :o4, 59172253, 24 - tz.transition 2038, 10, :o3, 59177461, 24 - tz.transition 2039, 3, :o4, 59180989, 24 - tz.transition 2039, 10, :o3, 59186197, 24 - tz.transition 2040, 3, :o4, 59189725, 24 - tz.transition 2040, 10, :o3, 59194933, 24 - tz.transition 2041, 3, :o4, 59198629, 24 - tz.transition 2041, 10, :o3, 59203669, 24 - tz.transition 2042, 3, :o4, 59207365, 24 - tz.transition 2042, 10, :o3, 59212405, 24 - tz.transition 2043, 3, :o4, 59216101, 24 - tz.transition 2043, 10, :o3, 59221141, 24 - tz.transition 2044, 3, :o4, 59224837, 24 - tz.transition 2044, 10, :o3, 59230045, 24 - tz.transition 2045, 3, :o4, 59233573, 24 - tz.transition 2045, 10, :o3, 59238781, 24 - tz.transition 2046, 3, :o4, 59242309, 24 - tz.transition 2046, 10, :o3, 59247517, 24 - tz.transition 2047, 3, :o4, 59251213, 24 - tz.transition 2047, 10, :o3, 59256253, 24 - tz.transition 2048, 3, :o4, 59259949, 24 - tz.transition 2048, 10, :o3, 59264989, 24 - tz.transition 2049, 3, :o4, 59268685, 24 - tz.transition 2049, 10, :o3, 59273893, 24 - tz.transition 2050, 3, :o4, 59277421, 24 - tz.transition 2050, 10, :o3, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bucharest.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bucharest.rb deleted file mode 100644 index 521c3c9..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bucharest.rb +++ /dev/null @@ -1,181 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Bucharest - include TimezoneDefinition - - timezone 'Europe/Bucharest' do |tz| - tz.offset :o0, 6264, 0, :LMT - tz.offset :o1, 6264, 0, :BMT - tz.offset :o2, 7200, 0, :EET - tz.offset :o3, 7200, 3600, :EEST - - tz.transition 1891, 9, :o1, 964802571, 400 - tz.transition 1931, 7, :o2, 970618571, 400 - tz.transition 1932, 5, :o3, 29122181, 12 - tz.transition 1932, 10, :o2, 29123789, 12 - tz.transition 1933, 4, :o3, 29125973, 12 - tz.transition 1933, 9, :o2, 29128157, 12 - tz.transition 1934, 4, :o3, 29130425, 12 - tz.transition 1934, 10, :o2, 29132609, 12 - tz.transition 1935, 4, :o3, 29134793, 12 - tz.transition 1935, 10, :o2, 29136977, 12 - tz.transition 1936, 4, :o3, 29139161, 12 - tz.transition 1936, 10, :o2, 29141345, 12 - tz.transition 1937, 4, :o3, 29143529, 12 - tz.transition 1937, 10, :o2, 29145713, 12 - tz.transition 1938, 4, :o3, 29147897, 12 - tz.transition 1938, 10, :o2, 29150081, 12 - tz.transition 1939, 4, :o3, 29152265, 12 - tz.transition 1939, 9, :o2, 29154449, 12 - tz.transition 1979, 5, :o3, 296604000 - tz.transition 1979, 9, :o2, 307486800 - tz.transition 1980, 4, :o3, 323816400 - tz.transition 1980, 9, :o2, 338940000 - tz.transition 1981, 3, :o3, 354672000 - tz.transition 1981, 9, :o2, 370396800 - tz.transition 1982, 3, :o3, 386121600 - tz.transition 1982, 9, :o2, 401846400 - tz.transition 1983, 3, :o3, 417571200 - tz.transition 1983, 9, :o2, 433296000 - tz.transition 1984, 3, :o3, 449020800 - tz.transition 1984, 9, :o2, 465350400 - tz.transition 1985, 3, :o3, 481075200 - tz.transition 1985, 9, :o2, 496800000 - tz.transition 1986, 3, :o3, 512524800 - tz.transition 1986, 9, :o2, 528249600 - tz.transition 1987, 3, :o3, 543974400 - tz.transition 1987, 9, :o2, 559699200 - tz.transition 1988, 3, :o3, 575424000 - tz.transition 1988, 9, :o2, 591148800 - tz.transition 1989, 3, :o3, 606873600 - tz.transition 1989, 9, :o2, 622598400 - tz.transition 1990, 3, :o3, 638323200 - tz.transition 1990, 9, :o2, 654652800 - tz.transition 1991, 3, :o3, 670370400 - tz.transition 1991, 9, :o2, 686095200 - tz.transition 1992, 3, :o3, 701820000 - tz.transition 1992, 9, :o2, 717544800 - tz.transition 1993, 3, :o3, 733269600 - tz.transition 1993, 9, :o2, 748994400 - tz.transition 1994, 3, :o3, 764719200 - tz.transition 1994, 9, :o2, 780440400 - tz.transition 1995, 3, :o3, 796168800 - tz.transition 1995, 9, :o2, 811890000 - tz.transition 1996, 3, :o3, 828223200 - tz.transition 1996, 10, :o2, 846363600 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Budapest.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Budapest.rb deleted file mode 100644 index 1f3a973..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Budapest.rb +++ /dev/null @@ -1,197 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Budapest - include TimezoneDefinition - - timezone 'Europe/Budapest' do |tz| - tz.offset :o0, 4580, 0, :LMT - tz.offset :o1, 3600, 0, :CET - tz.offset :o2, 3600, 3600, :CEST - - tz.transition 1890, 9, :o1, 10418291051, 4320 - tz.transition 1916, 4, :o2, 29051813, 12 - tz.transition 1916, 9, :o1, 58107299, 24 - tz.transition 1917, 4, :o2, 58112029, 24 - tz.transition 1917, 9, :o1, 58115725, 24 - tz.transition 1918, 4, :o2, 29060215, 12 - tz.transition 1918, 9, :o1, 58124773, 24 - tz.transition 1919, 4, :o2, 29064763, 12 - tz.transition 1919, 9, :o1, 58133197, 24 - tz.transition 1920, 4, :o2, 29069035, 12 - tz.transition 1920, 9, :o1, 58142341, 24 - tz.transition 1941, 4, :o2, 58322173, 24 - tz.transition 1942, 11, :o1, 58335973, 24 - tz.transition 1943, 3, :o2, 58339501, 24 - tz.transition 1943, 10, :o1, 58344037, 24 - tz.transition 1944, 4, :o2, 58348405, 24 - tz.transition 1944, 10, :o1, 58352773, 24 - tz.transition 1945, 5, :o2, 29178929, 12 - tz.transition 1945, 11, :o1, 29181149, 12 - tz.transition 1946, 3, :o2, 58365853, 24 - tz.transition 1946, 10, :o1, 58370389, 24 - tz.transition 1947, 4, :o2, 58374757, 24 - tz.transition 1947, 10, :o1, 58379125, 24 - tz.transition 1948, 4, :o2, 58383493, 24 - tz.transition 1948, 10, :o1, 58387861, 24 - tz.transition 1949, 4, :o2, 58392397, 24 - tz.transition 1949, 10, :o1, 58396597, 24 - tz.transition 1950, 4, :o2, 58401325, 24 - tz.transition 1950, 10, :o1, 58405861, 24 - tz.transition 1954, 5, :o2, 58437251, 24 - tz.transition 1954, 10, :o1, 29220221, 12 - tz.transition 1955, 5, :o2, 58446011, 24 - tz.transition 1955, 10, :o1, 29224601, 12 - tz.transition 1956, 6, :o2, 58455059, 24 - tz.transition 1956, 9, :o1, 29228957, 12 - tz.transition 1957, 6, :o2, 4871983, 2 - tz.transition 1957, 9, :o1, 58466653, 24 - tz.transition 1980, 4, :o2, 323827200 - tz.transition 1980, 9, :o1, 338950800 - tz.transition 1981, 3, :o2, 354675600 - tz.transition 1981, 9, :o1, 370400400 - tz.transition 1982, 3, :o2, 386125200 - tz.transition 1982, 9, :o1, 401850000 - tz.transition 1983, 3, :o2, 417574800 - tz.transition 1983, 9, :o1, 433299600 - tz.transition 1984, 3, :o2, 449024400 - tz.transition 1984, 9, :o1, 465354000 - tz.transition 1985, 3, :o2, 481078800 - tz.transition 1985, 9, :o1, 496803600 - tz.transition 1986, 3, :o2, 512528400 - tz.transition 1986, 9, :o1, 528253200 - tz.transition 1987, 3, :o2, 543978000 - tz.transition 1987, 9, :o1, 559702800 - tz.transition 1988, 3, :o2, 575427600 - tz.transition 1988, 9, :o1, 591152400 - tz.transition 1989, 3, :o2, 606877200 - tz.transition 1989, 9, :o1, 622602000 - tz.transition 1990, 3, :o2, 638326800 - tz.transition 1990, 9, :o1, 654656400 - tz.transition 1991, 3, :o2, 670381200 - tz.transition 1991, 9, :o1, 686106000 - tz.transition 1992, 3, :o2, 701830800 - tz.transition 1992, 9, :o1, 717555600 - tz.transition 1993, 3, :o2, 733280400 - tz.transition 1993, 9, :o1, 749005200 - tz.transition 1994, 3, :o2, 764730000 - tz.transition 1994, 9, :o1, 780454800 - tz.transition 1995, 3, :o2, 796179600 - tz.transition 1995, 9, :o1, 811904400 - tz.transition 1996, 3, :o2, 828234000 - tz.transition 1996, 10, :o1, 846378000 - tz.transition 1997, 3, :o2, 859683600 - tz.transition 1997, 10, :o1, 877827600 - tz.transition 1998, 3, :o2, 891133200 - tz.transition 1998, 10, :o1, 909277200 - tz.transition 1999, 3, :o2, 922582800 - tz.transition 1999, 10, :o1, 941331600 - tz.transition 2000, 3, :o2, 954032400 - tz.transition 2000, 10, :o1, 972781200 - tz.transition 2001, 3, :o2, 985482000 - tz.transition 2001, 10, :o1, 1004230800 - tz.transition 2002, 3, :o2, 1017536400 - tz.transition 2002, 10, :o1, 1035680400 - tz.transition 2003, 3, :o2, 1048986000 - tz.transition 2003, 10, :o1, 1067130000 - tz.transition 2004, 3, :o2, 1080435600 - tz.transition 2004, 10, :o1, 1099184400 - tz.transition 2005, 3, :o2, 1111885200 - tz.transition 2005, 10, :o1, 1130634000 - tz.transition 2006, 3, :o2, 1143334800 - tz.transition 2006, 10, :o1, 1162083600 - tz.transition 2007, 3, :o2, 1174784400 - tz.transition 2007, 10, :o1, 1193533200 - tz.transition 2008, 3, :o2, 1206838800 - tz.transition 2008, 10, :o1, 1224982800 - tz.transition 2009, 3, :o2, 1238288400 - tz.transition 2009, 10, :o1, 1256432400 - tz.transition 2010, 3, :o2, 1269738000 - tz.transition 2010, 10, :o1, 1288486800 - tz.transition 2011, 3, :o2, 1301187600 - tz.transition 2011, 10, :o1, 1319936400 - tz.transition 2012, 3, :o2, 1332637200 - tz.transition 2012, 10, :o1, 1351386000 - tz.transition 2013, 3, :o2, 1364691600 - tz.transition 2013, 10, :o1, 1382835600 - tz.transition 2014, 3, :o2, 1396141200 - tz.transition 2014, 10, :o1, 1414285200 - tz.transition 2015, 3, :o2, 1427590800 - tz.transition 2015, 10, :o1, 1445734800 - tz.transition 2016, 3, :o2, 1459040400 - tz.transition 2016, 10, :o1, 1477789200 - tz.transition 2017, 3, :o2, 1490490000 - tz.transition 2017, 10, :o1, 1509238800 - tz.transition 2018, 3, :o2, 1521939600 - tz.transition 2018, 10, :o1, 1540688400 - tz.transition 2019, 3, :o2, 1553994000 - tz.transition 2019, 10, :o1, 1572138000 - tz.transition 2020, 3, :o2, 1585443600 - tz.transition 2020, 10, :o1, 1603587600 - tz.transition 2021, 3, :o2, 1616893200 - tz.transition 2021, 10, :o1, 1635642000 - tz.transition 2022, 3, :o2, 1648342800 - tz.transition 2022, 10, :o1, 1667091600 - tz.transition 2023, 3, :o2, 1679792400 - tz.transition 2023, 10, :o1, 1698541200 - tz.transition 2024, 3, :o2, 1711846800 - tz.transition 2024, 10, :o1, 1729990800 - tz.transition 2025, 3, :o2, 1743296400 - tz.transition 2025, 10, :o1, 1761440400 - tz.transition 2026, 3, :o2, 1774746000 - tz.transition 2026, 10, :o1, 1792890000 - tz.transition 2027, 3, :o2, 1806195600 - tz.transition 2027, 10, :o1, 1824944400 - tz.transition 2028, 3, :o2, 1837645200 - tz.transition 2028, 10, :o1, 1856394000 - tz.transition 2029, 3, :o2, 1869094800 - tz.transition 2029, 10, :o1, 1887843600 - tz.transition 2030, 3, :o2, 1901149200 - tz.transition 2030, 10, :o1, 1919293200 - tz.transition 2031, 3, :o2, 1932598800 - tz.transition 2031, 10, :o1, 1950742800 - tz.transition 2032, 3, :o2, 1964048400 - tz.transition 2032, 10, :o1, 1982797200 - tz.transition 2033, 3, :o2, 1995498000 - tz.transition 2033, 10, :o1, 2014246800 - tz.transition 2034, 3, :o2, 2026947600 - tz.transition 2034, 10, :o1, 2045696400 - tz.transition 2035, 3, :o2, 2058397200 - tz.transition 2035, 10, :o1, 2077146000 - tz.transition 2036, 3, :o2, 2090451600 - tz.transition 2036, 10, :o1, 2108595600 - tz.transition 2037, 3, :o2, 2121901200 - tz.transition 2037, 10, :o1, 2140045200 - tz.transition 2038, 3, :o2, 59172253, 24 - tz.transition 2038, 10, :o1, 59177461, 24 - tz.transition 2039, 3, :o2, 59180989, 24 - tz.transition 2039, 10, :o1, 59186197, 24 - tz.transition 2040, 3, :o2, 59189725, 24 - tz.transition 2040, 10, :o1, 59194933, 24 - tz.transition 2041, 3, :o2, 59198629, 24 - tz.transition 2041, 10, :o1, 59203669, 24 - tz.transition 2042, 3, :o2, 59207365, 24 - tz.transition 2042, 10, :o1, 59212405, 24 - tz.transition 2043, 3, :o2, 59216101, 24 - tz.transition 2043, 10, :o1, 59221141, 24 - tz.transition 2044, 3, :o2, 59224837, 24 - tz.transition 2044, 10, :o1, 59230045, 24 - tz.transition 2045, 3, :o2, 59233573, 24 - tz.transition 2045, 10, :o1, 59238781, 24 - tz.transition 2046, 3, :o2, 59242309, 24 - tz.transition 2046, 10, :o1, 59247517, 24 - tz.transition 2047, 3, :o2, 59251213, 24 - tz.transition 2047, 10, :o1, 59256253, 24 - tz.transition 2048, 3, :o2, 59259949, 24 - tz.transition 2048, 10, :o1, 59264989, 24 - tz.transition 2049, 3, :o2, 59268685, 24 - tz.transition 2049, 10, :o1, 59273893, 24 - tz.transition 2050, 3, :o2, 59277421, 24 - tz.transition 2050, 10, :o1, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Copenhagen.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Copenhagen.rb deleted file mode 100644 index 47cbaf1..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Copenhagen.rb +++ /dev/null @@ -1,179 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Copenhagen - include TimezoneDefinition - - timezone 'Europe/Copenhagen' do |tz| - tz.offset :o0, 3020, 0, :LMT - tz.offset :o1, 3020, 0, :CMT - tz.offset :o2, 3600, 0, :CET - tz.offset :o3, 3600, 3600, :CEST - - tz.transition 1889, 12, :o1, 10417111769, 4320 - tz.transition 1893, 12, :o2, 10423423289, 4320 - tz.transition 1916, 5, :o3, 29051981, 12 - tz.transition 1916, 9, :o2, 19369099, 8 - tz.transition 1940, 5, :o3, 58314347, 24 - tz.transition 1942, 11, :o2, 58335973, 24 - tz.transition 1943, 3, :o3, 58339501, 24 - tz.transition 1943, 10, :o2, 58344037, 24 - tz.transition 1944, 4, :o3, 58348405, 24 - tz.transition 1944, 10, :o2, 58352773, 24 - tz.transition 1945, 4, :o3, 58357141, 24 - tz.transition 1945, 8, :o2, 58360381, 24 - tz.transition 1946, 5, :o3, 58366597, 24 - tz.transition 1946, 9, :o2, 58369549, 24 - tz.transition 1947, 5, :o3, 58375429, 24 - tz.transition 1947, 8, :o2, 58377781, 24 - tz.transition 1948, 5, :o3, 58384333, 24 - tz.transition 1948, 8, :o2, 58386517, 24 - tz.transition 1980, 4, :o3, 323830800 - tz.transition 1980, 9, :o2, 338950800 - tz.transition 1981, 3, :o3, 354675600 - tz.transition 1981, 9, :o2, 370400400 - tz.transition 1982, 3, :o3, 386125200 - tz.transition 1982, 9, :o2, 401850000 - tz.transition 1983, 3, :o3, 417574800 - tz.transition 1983, 9, :o2, 433299600 - tz.transition 1984, 3, :o3, 449024400 - tz.transition 1984, 9, :o2, 465354000 - tz.transition 1985, 3, :o3, 481078800 - tz.transition 1985, 9, :o2, 496803600 - tz.transition 1986, 3, :o3, 512528400 - tz.transition 1986, 9, :o2, 528253200 - tz.transition 1987, 3, :o3, 543978000 - tz.transition 1987, 9, :o2, 559702800 - tz.transition 1988, 3, :o3, 575427600 - tz.transition 1988, 9, :o2, 591152400 - tz.transition 1989, 3, :o3, 606877200 - tz.transition 1989, 9, :o2, 622602000 - tz.transition 1990, 3, :o3, 638326800 - tz.transition 1990, 9, :o2, 654656400 - tz.transition 1991, 3, :o3, 670381200 - tz.transition 1991, 9, :o2, 686106000 - tz.transition 1992, 3, :o3, 701830800 - tz.transition 1992, 9, :o2, 717555600 - tz.transition 1993, 3, :o3, 733280400 - tz.transition 1993, 9, :o2, 749005200 - tz.transition 1994, 3, :o3, 764730000 - tz.transition 1994, 9, :o2, 780454800 - tz.transition 1995, 3, :o3, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o3, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Dublin.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Dublin.rb deleted file mode 100644 index 0560bb5..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Dublin.rb +++ /dev/null @@ -1,276 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Dublin - include TimezoneDefinition - - timezone 'Europe/Dublin' do |tz| - tz.offset :o0, -1500, 0, :LMT - tz.offset :o1, -1521, 0, :DMT - tz.offset :o2, -1521, 3600, :IST - tz.offset :o3, 0, 0, :GMT - tz.offset :o4, 0, 3600, :BST - tz.offset :o5, 0, 3600, :IST - tz.offset :o6, 3600, 0, :IST - - tz.transition 1880, 8, :o1, 693483701, 288 - tz.transition 1916, 5, :o2, 7747214723, 3200 - tz.transition 1916, 10, :o3, 7747640323, 3200 - tz.transition 1917, 4, :o4, 29055919, 12 - tz.transition 1917, 9, :o3, 29057863, 12 - tz.transition 1918, 3, :o4, 29060119, 12 - tz.transition 1918, 9, :o3, 29062399, 12 - tz.transition 1919, 3, :o4, 29064571, 12 - tz.transition 1919, 9, :o3, 29066767, 12 - tz.transition 1920, 3, :o4, 29068939, 12 - tz.transition 1920, 10, :o3, 29071471, 12 - tz.transition 1921, 4, :o4, 29073391, 12 - tz.transition 1921, 10, :o3, 29075587, 12 - tz.transition 1922, 3, :o5, 29077675, 12 - tz.transition 1922, 10, :o3, 29080027, 12 - tz.transition 1923, 4, :o5, 29082379, 12 - tz.transition 1923, 9, :o3, 29084143, 12 - tz.transition 1924, 4, :o5, 29086663, 12 - tz.transition 1924, 9, :o3, 29088595, 12 - tz.transition 1925, 4, :o5, 29091115, 12 - tz.transition 1925, 10, :o3, 29093131, 12 - tz.transition 1926, 4, :o5, 29095483, 12 - tz.transition 1926, 10, :o3, 29097499, 12 - tz.transition 1927, 4, :o5, 29099767, 12 - tz.transition 1927, 10, :o3, 29101867, 12 - tz.transition 1928, 4, :o5, 29104303, 12 - tz.transition 1928, 10, :o3, 29106319, 12 - tz.transition 1929, 4, :o5, 29108671, 12 - tz.transition 1929, 10, :o3, 29110687, 12 - tz.transition 1930, 4, :o5, 29112955, 12 - tz.transition 1930, 10, :o3, 29115055, 12 - tz.transition 1931, 4, :o5, 29117407, 12 - tz.transition 1931, 10, :o3, 29119423, 12 - tz.transition 1932, 4, :o5, 29121775, 12 - tz.transition 1932, 10, :o3, 29123791, 12 - tz.transition 1933, 4, :o5, 29126059, 12 - tz.transition 1933, 10, :o3, 29128243, 12 - tz.transition 1934, 4, :o5, 29130595, 12 - tz.transition 1934, 10, :o3, 29132611, 12 - tz.transition 1935, 4, :o5, 29134879, 12 - tz.transition 1935, 10, :o3, 29136979, 12 - tz.transition 1936, 4, :o5, 29139331, 12 - tz.transition 1936, 10, :o3, 29141347, 12 - tz.transition 1937, 4, :o5, 29143699, 12 - tz.transition 1937, 10, :o3, 29145715, 12 - tz.transition 1938, 4, :o5, 29147983, 12 - tz.transition 1938, 10, :o3, 29150083, 12 - tz.transition 1939, 4, :o5, 29152435, 12 - tz.transition 1939, 11, :o3, 29155039, 12 - tz.transition 1940, 2, :o5, 29156215, 12 - tz.transition 1946, 10, :o3, 58370389, 24 - tz.transition 1947, 3, :o5, 29187127, 12 - tz.transition 1947, 11, :o3, 58379797, 24 - tz.transition 1948, 4, :o5, 29191915, 12 - tz.transition 1948, 10, :o3, 29194267, 12 - tz.transition 1949, 4, :o5, 29196115, 12 - tz.transition 1949, 10, :o3, 29198635, 12 - tz.transition 1950, 4, :o5, 29200651, 12 - tz.transition 1950, 10, :o3, 29202919, 12 - tz.transition 1951, 4, :o5, 29205019, 12 - tz.transition 1951, 10, :o3, 29207287, 12 - tz.transition 1952, 4, :o5, 29209471, 12 - tz.transition 1952, 10, :o3, 29211739, 12 - tz.transition 1953, 4, :o5, 29213839, 12 - tz.transition 1953, 10, :o3, 29215855, 12 - tz.transition 1954, 4, :o5, 29218123, 12 - tz.transition 1954, 10, :o3, 29220223, 12 - tz.transition 1955, 4, :o5, 29222575, 12 - tz.transition 1955, 10, :o3, 29224591, 12 - tz.transition 1956, 4, :o5, 29227027, 12 - tz.transition 1956, 10, :o3, 29229043, 12 - tz.transition 1957, 4, :o5, 29231311, 12 - tz.transition 1957, 10, :o3, 29233411, 12 - tz.transition 1958, 4, :o5, 29235763, 12 - tz.transition 1958, 10, :o3, 29237779, 12 - tz.transition 1959, 4, :o5, 29240131, 12 - tz.transition 1959, 10, :o3, 29242147, 12 - tz.transition 1960, 4, :o5, 29244415, 12 - tz.transition 1960, 10, :o3, 29246515, 12 - tz.transition 1961, 3, :o5, 29248615, 12 - tz.transition 1961, 10, :o3, 29251219, 12 - tz.transition 1962, 3, :o5, 29252983, 12 - tz.transition 1962, 10, :o3, 29255587, 12 - tz.transition 1963, 3, :o5, 29257435, 12 - tz.transition 1963, 10, :o3, 29259955, 12 - tz.transition 1964, 3, :o5, 29261719, 12 - tz.transition 1964, 10, :o3, 29264323, 12 - tz.transition 1965, 3, :o5, 29266087, 12 - tz.transition 1965, 10, :o3, 29268691, 12 - tz.transition 1966, 3, :o5, 29270455, 12 - tz.transition 1966, 10, :o3, 29273059, 12 - tz.transition 1967, 3, :o5, 29274823, 12 - tz.transition 1967, 10, :o3, 29277511, 12 - tz.transition 1968, 2, :o5, 29278855, 12 - tz.transition 1968, 10, :o6, 58563755, 24 - tz.transition 1971, 10, :o3, 57722400 - tz.transition 1972, 3, :o5, 69818400 - tz.transition 1972, 10, :o3, 89172000 - tz.transition 1973, 3, :o5, 101268000 - tz.transition 1973, 10, :o3, 120621600 - tz.transition 1974, 3, :o5, 132717600 - tz.transition 1974, 10, :o3, 152071200 - tz.transition 1975, 3, :o5, 164167200 - tz.transition 1975, 10, :o3, 183520800 - tz.transition 1976, 3, :o5, 196221600 - tz.transition 1976, 10, :o3, 214970400 - tz.transition 1977, 3, :o5, 227671200 - tz.transition 1977, 10, :o3, 246420000 - tz.transition 1978, 3, :o5, 259120800 - tz.transition 1978, 10, :o3, 278474400 - tz.transition 1979, 3, :o5, 290570400 - tz.transition 1979, 10, :o3, 309924000 - tz.transition 1980, 3, :o5, 322020000 - tz.transition 1980, 10, :o3, 341373600 - tz.transition 1981, 3, :o5, 354675600 - tz.transition 1981, 10, :o3, 372819600 - tz.transition 1982, 3, :o5, 386125200 - tz.transition 1982, 10, :o3, 404269200 - tz.transition 1983, 3, :o5, 417574800 - tz.transition 1983, 10, :o3, 435718800 - tz.transition 1984, 3, :o5, 449024400 - tz.transition 1984, 10, :o3, 467773200 - tz.transition 1985, 3, :o5, 481078800 - tz.transition 1985, 10, :o3, 499222800 - tz.transition 1986, 3, :o5, 512528400 - tz.transition 1986, 10, :o3, 530672400 - tz.transition 1987, 3, :o5, 543978000 - tz.transition 1987, 10, :o3, 562122000 - tz.transition 1988, 3, :o5, 575427600 - tz.transition 1988, 10, :o3, 593571600 - tz.transition 1989, 3, :o5, 606877200 - tz.transition 1989, 10, :o3, 625626000 - tz.transition 1990, 3, :o5, 638326800 - tz.transition 1990, 10, :o3, 657075600 - tz.transition 1991, 3, :o5, 670381200 - tz.transition 1991, 10, :o3, 688525200 - tz.transition 1992, 3, :o5, 701830800 - tz.transition 1992, 10, :o3, 719974800 - tz.transition 1993, 3, :o5, 733280400 - tz.transition 1993, 10, :o3, 751424400 - tz.transition 1994, 3, :o5, 764730000 - tz.transition 1994, 10, :o3, 782874000 - tz.transition 1995, 3, :o5, 796179600 - tz.transition 1995, 10, :o3, 814323600 - tz.transition 1996, 3, :o5, 828234000 - tz.transition 1996, 10, :o3, 846378000 - tz.transition 1997, 3, :o5, 859683600 - tz.transition 1997, 10, :o3, 877827600 - tz.transition 1998, 3, :o5, 891133200 - tz.transition 1998, 10, :o3, 909277200 - tz.transition 1999, 3, :o5, 922582800 - tz.transition 1999, 10, :o3, 941331600 - tz.transition 2000, 3, :o5, 954032400 - tz.transition 2000, 10, :o3, 972781200 - tz.transition 2001, 3, :o5, 985482000 - tz.transition 2001, 10, :o3, 1004230800 - tz.transition 2002, 3, :o5, 1017536400 - tz.transition 2002, 10, :o3, 1035680400 - tz.transition 2003, 3, :o5, 1048986000 - tz.transition 2003, 10, :o3, 1067130000 - tz.transition 2004, 3, :o5, 1080435600 - tz.transition 2004, 10, :o3, 1099184400 - tz.transition 2005, 3, :o5, 1111885200 - tz.transition 2005, 10, :o3, 1130634000 - tz.transition 2006, 3, :o5, 1143334800 - tz.transition 2006, 10, :o3, 1162083600 - tz.transition 2007, 3, :o5, 1174784400 - tz.transition 2007, 10, :o3, 1193533200 - tz.transition 2008, 3, :o5, 1206838800 - tz.transition 2008, 10, :o3, 1224982800 - tz.transition 2009, 3, :o5, 1238288400 - tz.transition 2009, 10, :o3, 1256432400 - tz.transition 2010, 3, :o5, 1269738000 - tz.transition 2010, 10, :o3, 1288486800 - tz.transition 2011, 3, :o5, 1301187600 - tz.transition 2011, 10, :o3, 1319936400 - tz.transition 2012, 3, :o5, 1332637200 - tz.transition 2012, 10, :o3, 1351386000 - tz.transition 2013, 3, :o5, 1364691600 - tz.transition 2013, 10, :o3, 1382835600 - tz.transition 2014, 3, :o5, 1396141200 - tz.transition 2014, 10, :o3, 1414285200 - tz.transition 2015, 3, :o5, 1427590800 - tz.transition 2015, 10, :o3, 1445734800 - tz.transition 2016, 3, :o5, 1459040400 - tz.transition 2016, 10, :o3, 1477789200 - tz.transition 2017, 3, :o5, 1490490000 - tz.transition 2017, 10, :o3, 1509238800 - tz.transition 2018, 3, :o5, 1521939600 - tz.transition 2018, 10, :o3, 1540688400 - tz.transition 2019, 3, :o5, 1553994000 - tz.transition 2019, 10, :o3, 1572138000 - tz.transition 2020, 3, :o5, 1585443600 - tz.transition 2020, 10, :o3, 1603587600 - tz.transition 2021, 3, :o5, 1616893200 - tz.transition 2021, 10, :o3, 1635642000 - tz.transition 2022, 3, :o5, 1648342800 - tz.transition 2022, 10, :o3, 1667091600 - tz.transition 2023, 3, :o5, 1679792400 - tz.transition 2023, 10, :o3, 1698541200 - tz.transition 2024, 3, :o5, 1711846800 - tz.transition 2024, 10, :o3, 1729990800 - tz.transition 2025, 3, :o5, 1743296400 - tz.transition 2025, 10, :o3, 1761440400 - tz.transition 2026, 3, :o5, 1774746000 - tz.transition 2026, 10, :o3, 1792890000 - tz.transition 2027, 3, :o5, 1806195600 - tz.transition 2027, 10, :o3, 1824944400 - tz.transition 2028, 3, :o5, 1837645200 - tz.transition 2028, 10, :o3, 1856394000 - tz.transition 2029, 3, :o5, 1869094800 - tz.transition 2029, 10, :o3, 1887843600 - tz.transition 2030, 3, :o5, 1901149200 - tz.transition 2030, 10, :o3, 1919293200 - tz.transition 2031, 3, :o5, 1932598800 - tz.transition 2031, 10, :o3, 1950742800 - tz.transition 2032, 3, :o5, 1964048400 - tz.transition 2032, 10, :o3, 1982797200 - tz.transition 2033, 3, :o5, 1995498000 - tz.transition 2033, 10, :o3, 2014246800 - tz.transition 2034, 3, :o5, 2026947600 - tz.transition 2034, 10, :o3, 2045696400 - tz.transition 2035, 3, :o5, 2058397200 - tz.transition 2035, 10, :o3, 2077146000 - tz.transition 2036, 3, :o5, 2090451600 - tz.transition 2036, 10, :o3, 2108595600 - tz.transition 2037, 3, :o5, 2121901200 - tz.transition 2037, 10, :o3, 2140045200 - tz.transition 2038, 3, :o5, 59172253, 24 - tz.transition 2038, 10, :o3, 59177461, 24 - tz.transition 2039, 3, :o5, 59180989, 24 - tz.transition 2039, 10, :o3, 59186197, 24 - tz.transition 2040, 3, :o5, 59189725, 24 - tz.transition 2040, 10, :o3, 59194933, 24 - tz.transition 2041, 3, :o5, 59198629, 24 - tz.transition 2041, 10, :o3, 59203669, 24 - tz.transition 2042, 3, :o5, 59207365, 24 - tz.transition 2042, 10, :o3, 59212405, 24 - tz.transition 2043, 3, :o5, 59216101, 24 - tz.transition 2043, 10, :o3, 59221141, 24 - tz.transition 2044, 3, :o5, 59224837, 24 - tz.transition 2044, 10, :o3, 59230045, 24 - tz.transition 2045, 3, :o5, 59233573, 24 - tz.transition 2045, 10, :o3, 59238781, 24 - tz.transition 2046, 3, :o5, 59242309, 24 - tz.transition 2046, 10, :o3, 59247517, 24 - tz.transition 2047, 3, :o5, 59251213, 24 - tz.transition 2047, 10, :o3, 59256253, 24 - tz.transition 2048, 3, :o5, 59259949, 24 - tz.transition 2048, 10, :o3, 59264989, 24 - tz.transition 2049, 3, :o5, 59268685, 24 - tz.transition 2049, 10, :o3, 59273893, 24 - tz.transition 2050, 3, :o5, 59277421, 24 - tz.transition 2050, 10, :o3, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Helsinki.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Helsinki.rb deleted file mode 100644 index 13a806b..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Helsinki.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Helsinki - include TimezoneDefinition - - timezone 'Europe/Helsinki' do |tz| - tz.offset :o0, 5992, 0, :LMT - tz.offset :o1, 5992, 0, :HMT - tz.offset :o2, 7200, 0, :EET - tz.offset :o3, 7200, 3600, :EEST - - tz.transition 1878, 5, :o1, 25997062651, 10800 - tz.transition 1921, 4, :o2, 26166352651, 10800 - tz.transition 1942, 4, :o3, 29165429, 12 - tz.transition 1942, 10, :o2, 19445083, 8 - tz.transition 1981, 3, :o3, 354675600 - tz.transition 1981, 9, :o2, 370400400 - tz.transition 1982, 3, :o3, 386125200 - tz.transition 1982, 9, :o2, 401850000 - tz.transition 1983, 3, :o3, 417574800 - tz.transition 1983, 9, :o2, 433299600 - tz.transition 1984, 3, :o3, 449024400 - tz.transition 1984, 9, :o2, 465354000 - tz.transition 1985, 3, :o3, 481078800 - tz.transition 1985, 9, :o2, 496803600 - tz.transition 1986, 3, :o3, 512528400 - tz.transition 1986, 9, :o2, 528253200 - tz.transition 1987, 3, :o3, 543978000 - tz.transition 1987, 9, :o2, 559702800 - tz.transition 1988, 3, :o3, 575427600 - tz.transition 1988, 9, :o2, 591152400 - tz.transition 1989, 3, :o3, 606877200 - tz.transition 1989, 9, :o2, 622602000 - tz.transition 1990, 3, :o3, 638326800 - tz.transition 1990, 9, :o2, 654656400 - tz.transition 1991, 3, :o3, 670381200 - tz.transition 1991, 9, :o2, 686106000 - tz.transition 1992, 3, :o3, 701830800 - tz.transition 1992, 9, :o2, 717555600 - tz.transition 1993, 3, :o3, 733280400 - tz.transition 1993, 9, :o2, 749005200 - tz.transition 1994, 3, :o3, 764730000 - tz.transition 1994, 9, :o2, 780454800 - tz.transition 1995, 3, :o3, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o3, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Istanbul.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Istanbul.rb deleted file mode 100644 index 8306c47..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Istanbul.rb +++ /dev/null @@ -1,218 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Istanbul - include TimezoneDefinition - - timezone 'Europe/Istanbul' do |tz| - tz.offset :o0, 6952, 0, :LMT - tz.offset :o1, 7016, 0, :IMT - tz.offset :o2, 7200, 0, :EET - tz.offset :o3, 7200, 3600, :EEST - tz.offset :o4, 10800, 3600, :TRST - tz.offset :o5, 10800, 0, :TRT - - tz.transition 1879, 12, :o1, 26003326531, 10800 - tz.transition 1910, 9, :o2, 26124610523, 10800 - tz.transition 1916, 4, :o3, 29051813, 12 - tz.transition 1916, 9, :o2, 19369099, 8 - tz.transition 1920, 3, :o3, 29068937, 12 - tz.transition 1920, 10, :o2, 19380979, 8 - tz.transition 1921, 4, :o3, 29073389, 12 - tz.transition 1921, 10, :o2, 19383723, 8 - tz.transition 1922, 3, :o3, 29077673, 12 - tz.transition 1922, 10, :o2, 19386683, 8 - tz.transition 1924, 5, :o3, 29087021, 12 - tz.transition 1924, 9, :o2, 19392475, 8 - tz.transition 1925, 4, :o3, 29091257, 12 - tz.transition 1925, 9, :o2, 19395395, 8 - tz.transition 1940, 6, :o3, 29157725, 12 - tz.transition 1940, 10, :o2, 19439259, 8 - tz.transition 1940, 11, :o3, 29159573, 12 - tz.transition 1941, 9, :o2, 19442067, 8 - tz.transition 1942, 3, :o3, 29165405, 12 - tz.transition 1942, 10, :o2, 19445315, 8 - tz.transition 1945, 4, :o3, 29178569, 12 - tz.transition 1945, 10, :o2, 19453891, 8 - tz.transition 1946, 5, :o3, 29183669, 12 - tz.transition 1946, 9, :o2, 19456755, 8 - tz.transition 1947, 4, :o3, 29187545, 12 - tz.transition 1947, 10, :o2, 19459707, 8 - tz.transition 1948, 4, :o3, 29191913, 12 - tz.transition 1948, 10, :o2, 19462619, 8 - tz.transition 1949, 4, :o3, 29196197, 12 - tz.transition 1949, 10, :o2, 19465531, 8 - tz.transition 1950, 4, :o3, 29200685, 12 - tz.transition 1950, 10, :o2, 19468499, 8 - tz.transition 1951, 4, :o3, 29205101, 12 - tz.transition 1951, 10, :o2, 19471419, 8 - tz.transition 1962, 7, :o3, 29254325, 12 - tz.transition 1962, 10, :o2, 19503563, 8 - tz.transition 1964, 5, :o3, 29262365, 12 - tz.transition 1964, 9, :o2, 19509355, 8 - tz.transition 1970, 5, :o3, 10533600 - tz.transition 1970, 10, :o2, 23835600 - tz.transition 1971, 5, :o3, 41983200 - tz.transition 1971, 10, :o2, 55285200 - tz.transition 1972, 5, :o3, 74037600 - tz.transition 1972, 10, :o2, 87339600 - tz.transition 1973, 6, :o3, 107910000 - tz.transition 1973, 11, :o2, 121219200 - tz.transition 1974, 3, :o3, 133920000 - tz.transition 1974, 11, :o2, 152676000 - tz.transition 1975, 3, :o3, 165362400 - tz.transition 1975, 10, :o2, 183502800 - tz.transition 1976, 5, :o3, 202428000 - tz.transition 1976, 10, :o2, 215557200 - tz.transition 1977, 4, :o3, 228866400 - tz.transition 1977, 10, :o2, 245797200 - tz.transition 1978, 4, :o3, 260316000 - tz.transition 1978, 10, :o4, 277246800 - tz.transition 1979, 10, :o5, 308779200 - tz.transition 1980, 4, :o4, 323827200 - tz.transition 1980, 10, :o5, 340228800 - tz.transition 1981, 3, :o4, 354672000 - tz.transition 1981, 10, :o5, 371678400 - tz.transition 1982, 3, :o4, 386121600 - tz.transition 1982, 10, :o5, 403128000 - tz.transition 1983, 7, :o4, 428446800 - tz.transition 1983, 10, :o5, 433886400 - tz.transition 1985, 4, :o3, 482792400 - tz.transition 1985, 9, :o2, 496702800 - tz.transition 1986, 3, :o3, 512524800 - tz.transition 1986, 9, :o2, 528249600 - tz.transition 1987, 3, :o3, 543974400 - tz.transition 1987, 9, :o2, 559699200 - tz.transition 1988, 3, :o3, 575424000 - tz.transition 1988, 9, :o2, 591148800 - tz.transition 1989, 3, :o3, 606873600 - tz.transition 1989, 9, :o2, 622598400 - tz.transition 1990, 3, :o3, 638323200 - tz.transition 1990, 9, :o2, 654652800 - tz.transition 1991, 3, :o3, 670374000 - tz.transition 1991, 9, :o2, 686098800 - tz.transition 1992, 3, :o3, 701823600 - tz.transition 1992, 9, :o2, 717548400 - tz.transition 1993, 3, :o3, 733273200 - tz.transition 1993, 9, :o2, 748998000 - tz.transition 1994, 3, :o3, 764722800 - tz.transition 1994, 9, :o2, 780447600 - tz.transition 1995, 3, :o3, 796172400 - tz.transition 1995, 9, :o2, 811897200 - tz.transition 1996, 3, :o3, 828226800 - tz.transition 1996, 10, :o2, 846370800 - tz.transition 1997, 3, :o3, 859676400 - tz.transition 1997, 10, :o2, 877820400 - tz.transition 1998, 3, :o3, 891126000 - tz.transition 1998, 10, :o2, 909270000 - tz.transition 1999, 3, :o3, 922575600 - tz.transition 1999, 10, :o2, 941324400 - tz.transition 2000, 3, :o3, 954025200 - tz.transition 2000, 10, :o2, 972774000 - tz.transition 2001, 3, :o3, 985474800 - tz.transition 2001, 10, :o2, 1004223600 - tz.transition 2002, 3, :o3, 1017529200 - tz.transition 2002, 10, :o2, 1035673200 - tz.transition 2003, 3, :o3, 1048978800 - tz.transition 2003, 10, :o2, 1067122800 - tz.transition 2004, 3, :o3, 1080428400 - tz.transition 2004, 10, :o2, 1099177200 - tz.transition 2005, 3, :o3, 1111878000 - tz.transition 2005, 10, :o2, 1130626800 - tz.transition 2006, 3, :o3, 1143327600 - tz.transition 2006, 10, :o2, 1162076400 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Kiev.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Kiev.rb deleted file mode 100644 index 513d330..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Kiev.rb +++ /dev/null @@ -1,168 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Kiev - include TimezoneDefinition - - timezone 'Europe/Kiev' do |tz| - tz.offset :o0, 7324, 0, :LMT - tz.offset :o1, 7324, 0, :KMT - tz.offset :o2, 7200, 0, :EET - tz.offset :o3, 10800, 0, :MSK - tz.offset :o4, 3600, 3600, :CEST - tz.offset :o5, 3600, 0, :CET - tz.offset :o6, 10800, 3600, :MSD - tz.offset :o7, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 52006652969, 21600 - tz.transition 1924, 5, :o2, 52356400169, 21600 - tz.transition 1930, 6, :o3, 29113781, 12 - tz.transition 1941, 9, :o4, 19442059, 8 - tz.transition 1942, 11, :o5, 58335973, 24 - tz.transition 1943, 3, :o4, 58339501, 24 - tz.transition 1943, 10, :o5, 58344037, 24 - tz.transition 1943, 11, :o3, 58344827, 24 - tz.transition 1981, 3, :o6, 354920400 - tz.transition 1981, 9, :o3, 370728000 - tz.transition 1982, 3, :o6, 386456400 - tz.transition 1982, 9, :o3, 402264000 - tz.transition 1983, 3, :o6, 417992400 - tz.transition 1983, 9, :o3, 433800000 - tz.transition 1984, 3, :o6, 449614800 - tz.transition 1984, 9, :o3, 465346800 - tz.transition 1985, 3, :o6, 481071600 - tz.transition 1985, 9, :o3, 496796400 - tz.transition 1986, 3, :o6, 512521200 - tz.transition 1986, 9, :o3, 528246000 - tz.transition 1987, 3, :o6, 543970800 - tz.transition 1987, 9, :o3, 559695600 - tz.transition 1988, 3, :o6, 575420400 - tz.transition 1988, 9, :o3, 591145200 - tz.transition 1989, 3, :o6, 606870000 - tz.transition 1989, 9, :o3, 622594800 - tz.transition 1990, 6, :o2, 646786800 - tz.transition 1992, 3, :o7, 701820000 - tz.transition 1992, 9, :o2, 717541200 - tz.transition 1993, 3, :o7, 733269600 - tz.transition 1993, 9, :o2, 748990800 - tz.transition 1994, 3, :o7, 764719200 - tz.transition 1994, 9, :o2, 780440400 - tz.transition 1995, 3, :o7, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o7, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o7, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o7, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o7, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o7, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o7, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o7, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o7, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o7, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o7, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o7, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o7, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o7, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o7, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o7, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o7, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o7, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o7, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o7, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o7, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o7, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o7, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o7, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o7, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o7, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o7, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o7, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o7, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o7, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o7, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o7, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o7, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o7, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o7, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o7, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o7, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o7, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o7, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o7, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o7, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o7, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o7, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o7, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o7, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o7, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o7, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o7, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o7, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o7, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o7, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o7, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o7, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o7, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o7, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o7, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Lisbon.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Lisbon.rb deleted file mode 100644 index 1c6d2a3..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Lisbon.rb +++ /dev/null @@ -1,268 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Lisbon - include TimezoneDefinition - - timezone 'Europe/Lisbon' do |tz| - tz.offset :o0, -2192, 0, :LMT - tz.offset :o1, 0, 0, :WET - tz.offset :o2, 0, 3600, :WEST - tz.offset :o3, 0, 7200, :WEMT - tz.offset :o4, 3600, 0, :CET - tz.offset :o5, 3600, 3600, :CEST - - tz.transition 1912, 1, :o1, 13064773637, 5400 - tz.transition 1916, 6, :o2, 58104779, 24 - tz.transition 1916, 11, :o1, 4842337, 2 - tz.transition 1917, 2, :o2, 58110923, 24 - tz.transition 1917, 10, :o1, 58116395, 24 - tz.transition 1918, 3, :o2, 58119707, 24 - tz.transition 1918, 10, :o1, 58125155, 24 - tz.transition 1919, 2, :o2, 58128443, 24 - tz.transition 1919, 10, :o1, 58133915, 24 - tz.transition 1920, 2, :o2, 58137227, 24 - tz.transition 1920, 10, :o1, 58142699, 24 - tz.transition 1921, 2, :o2, 58145987, 24 - tz.transition 1921, 10, :o1, 58151459, 24 - tz.transition 1924, 4, :o2, 58173419, 24 - tz.transition 1924, 10, :o1, 58177763, 24 - tz.transition 1926, 4, :o2, 58190963, 24 - tz.transition 1926, 10, :o1, 58194995, 24 - tz.transition 1927, 4, :o2, 58199531, 24 - tz.transition 1927, 10, :o1, 58203731, 24 - tz.transition 1928, 4, :o2, 58208435, 24 - tz.transition 1928, 10, :o1, 58212635, 24 - tz.transition 1929, 4, :o2, 58217339, 24 - tz.transition 1929, 10, :o1, 58221371, 24 - tz.transition 1931, 4, :o2, 58234811, 24 - tz.transition 1931, 10, :o1, 58238843, 24 - tz.transition 1932, 4, :o2, 58243211, 24 - tz.transition 1932, 10, :o1, 58247579, 24 - tz.transition 1934, 4, :o2, 58260851, 24 - tz.transition 1934, 10, :o1, 58265219, 24 - tz.transition 1935, 3, :o2, 58269419, 24 - tz.transition 1935, 10, :o1, 58273955, 24 - tz.transition 1936, 4, :o2, 58278659, 24 - tz.transition 1936, 10, :o1, 58282691, 24 - tz.transition 1937, 4, :o2, 58287059, 24 - tz.transition 1937, 10, :o1, 58291427, 24 - tz.transition 1938, 3, :o2, 58295627, 24 - tz.transition 1938, 10, :o1, 58300163, 24 - tz.transition 1939, 4, :o2, 58304867, 24 - tz.transition 1939, 11, :o1, 58310075, 24 - tz.transition 1940, 2, :o2, 58312427, 24 - tz.transition 1940, 10, :o1, 58317803, 24 - tz.transition 1941, 4, :o2, 58322171, 24 - tz.transition 1941, 10, :o1, 58326563, 24 - tz.transition 1942, 3, :o2, 58330403, 24 - tz.transition 1942, 4, :o3, 29165705, 12 - tz.transition 1942, 8, :o2, 29167049, 12 - tz.transition 1942, 10, :o1, 58335779, 24 - tz.transition 1943, 3, :o2, 58339139, 24 - tz.transition 1943, 4, :o3, 29169989, 12 - tz.transition 1943, 8, :o2, 29171585, 12 - tz.transition 1943, 10, :o1, 58344683, 24 - tz.transition 1944, 3, :o2, 58347875, 24 - tz.transition 1944, 4, :o3, 29174441, 12 - tz.transition 1944, 8, :o2, 29175953, 12 - tz.transition 1944, 10, :o1, 58353419, 24 - tz.transition 1945, 3, :o2, 58356611, 24 - tz.transition 1945, 4, :o3, 29178809, 12 - tz.transition 1945, 8, :o2, 29180321, 12 - tz.transition 1945, 10, :o1, 58362155, 24 - tz.transition 1946, 4, :o2, 58366019, 24 - tz.transition 1946, 10, :o1, 58370387, 24 - tz.transition 1947, 4, :o2, 29187379, 12 - tz.transition 1947, 10, :o1, 29189563, 12 - tz.transition 1948, 4, :o2, 29191747, 12 - tz.transition 1948, 10, :o1, 29193931, 12 - tz.transition 1949, 4, :o2, 29196115, 12 - tz.transition 1949, 10, :o1, 29198299, 12 - tz.transition 1951, 4, :o2, 29204851, 12 - tz.transition 1951, 10, :o1, 29207119, 12 - tz.transition 1952, 4, :o2, 29209303, 12 - tz.transition 1952, 10, :o1, 29211487, 12 - tz.transition 1953, 4, :o2, 29213671, 12 - tz.transition 1953, 10, :o1, 29215855, 12 - tz.transition 1954, 4, :o2, 29218039, 12 - tz.transition 1954, 10, :o1, 29220223, 12 - tz.transition 1955, 4, :o2, 29222407, 12 - tz.transition 1955, 10, :o1, 29224591, 12 - tz.transition 1956, 4, :o2, 29226775, 12 - tz.transition 1956, 10, :o1, 29229043, 12 - tz.transition 1957, 4, :o2, 29231227, 12 - tz.transition 1957, 10, :o1, 29233411, 12 - tz.transition 1958, 4, :o2, 29235595, 12 - tz.transition 1958, 10, :o1, 29237779, 12 - tz.transition 1959, 4, :o2, 29239963, 12 - tz.transition 1959, 10, :o1, 29242147, 12 - tz.transition 1960, 4, :o2, 29244331, 12 - tz.transition 1960, 10, :o1, 29246515, 12 - tz.transition 1961, 4, :o2, 29248699, 12 - tz.transition 1961, 10, :o1, 29250883, 12 - tz.transition 1962, 4, :o2, 29253067, 12 - tz.transition 1962, 10, :o1, 29255335, 12 - tz.transition 1963, 4, :o2, 29257519, 12 - tz.transition 1963, 10, :o1, 29259703, 12 - tz.transition 1964, 4, :o2, 29261887, 12 - tz.transition 1964, 10, :o1, 29264071, 12 - tz.transition 1965, 4, :o2, 29266255, 12 - tz.transition 1965, 10, :o1, 29268439, 12 - tz.transition 1966, 4, :o4, 29270623, 12 - tz.transition 1976, 9, :o1, 212544000 - tz.transition 1977, 3, :o2, 228268800 - tz.transition 1977, 9, :o1, 243993600 - tz.transition 1978, 4, :o2, 260323200 - tz.transition 1978, 10, :o1, 276048000 - tz.transition 1979, 4, :o2, 291772800 - tz.transition 1979, 9, :o1, 307501200 - tz.transition 1980, 3, :o2, 323222400 - tz.transition 1980, 9, :o1, 338950800 - tz.transition 1981, 3, :o2, 354675600 - tz.transition 1981, 9, :o1, 370400400 - tz.transition 1982, 3, :o2, 386125200 - tz.transition 1982, 9, :o1, 401850000 - tz.transition 1983, 3, :o2, 417578400 - tz.transition 1983, 9, :o1, 433299600 - tz.transition 1984, 3, :o2, 449024400 - tz.transition 1984, 9, :o1, 465354000 - tz.transition 1985, 3, :o2, 481078800 - tz.transition 1985, 9, :o1, 496803600 - tz.transition 1986, 3, :o2, 512528400 - tz.transition 1986, 9, :o1, 528253200 - tz.transition 1987, 3, :o2, 543978000 - tz.transition 1987, 9, :o1, 559702800 - tz.transition 1988, 3, :o2, 575427600 - tz.transition 1988, 9, :o1, 591152400 - tz.transition 1989, 3, :o2, 606877200 - tz.transition 1989, 9, :o1, 622602000 - tz.transition 1990, 3, :o2, 638326800 - tz.transition 1990, 9, :o1, 654656400 - tz.transition 1991, 3, :o2, 670381200 - tz.transition 1991, 9, :o1, 686106000 - tz.transition 1992, 3, :o2, 701830800 - tz.transition 1992, 9, :o4, 717555600 - tz.transition 1993, 3, :o5, 733280400 - tz.transition 1993, 9, :o4, 749005200 - tz.transition 1994, 3, :o5, 764730000 - tz.transition 1994, 9, :o4, 780454800 - tz.transition 1995, 3, :o5, 796179600 - tz.transition 1995, 9, :o4, 811904400 - tz.transition 1996, 3, :o2, 828234000 - tz.transition 1996, 10, :o1, 846378000 - tz.transition 1997, 3, :o2, 859683600 - tz.transition 1997, 10, :o1, 877827600 - tz.transition 1998, 3, :o2, 891133200 - tz.transition 1998, 10, :o1, 909277200 - tz.transition 1999, 3, :o2, 922582800 - tz.transition 1999, 10, :o1, 941331600 - tz.transition 2000, 3, :o2, 954032400 - tz.transition 2000, 10, :o1, 972781200 - tz.transition 2001, 3, :o2, 985482000 - tz.transition 2001, 10, :o1, 1004230800 - tz.transition 2002, 3, :o2, 1017536400 - tz.transition 2002, 10, :o1, 1035680400 - tz.transition 2003, 3, :o2, 1048986000 - tz.transition 2003, 10, :o1, 1067130000 - tz.transition 2004, 3, :o2, 1080435600 - tz.transition 2004, 10, :o1, 1099184400 - tz.transition 2005, 3, :o2, 1111885200 - tz.transition 2005, 10, :o1, 1130634000 - tz.transition 2006, 3, :o2, 1143334800 - tz.transition 2006, 10, :o1, 1162083600 - tz.transition 2007, 3, :o2, 1174784400 - tz.transition 2007, 10, :o1, 1193533200 - tz.transition 2008, 3, :o2, 1206838800 - tz.transition 2008, 10, :o1, 1224982800 - tz.transition 2009, 3, :o2, 1238288400 - tz.transition 2009, 10, :o1, 1256432400 - tz.transition 2010, 3, :o2, 1269738000 - tz.transition 2010, 10, :o1, 1288486800 - tz.transition 2011, 3, :o2, 1301187600 - tz.transition 2011, 10, :o1, 1319936400 - tz.transition 2012, 3, :o2, 1332637200 - tz.transition 2012, 10, :o1, 1351386000 - tz.transition 2013, 3, :o2, 1364691600 - tz.transition 2013, 10, :o1, 1382835600 - tz.transition 2014, 3, :o2, 1396141200 - tz.transition 2014, 10, :o1, 1414285200 - tz.transition 2015, 3, :o2, 1427590800 - tz.transition 2015, 10, :o1, 1445734800 - tz.transition 2016, 3, :o2, 1459040400 - tz.transition 2016, 10, :o1, 1477789200 - tz.transition 2017, 3, :o2, 1490490000 - tz.transition 2017, 10, :o1, 1509238800 - tz.transition 2018, 3, :o2, 1521939600 - tz.transition 2018, 10, :o1, 1540688400 - tz.transition 2019, 3, :o2, 1553994000 - tz.transition 2019, 10, :o1, 1572138000 - tz.transition 2020, 3, :o2, 1585443600 - tz.transition 2020, 10, :o1, 1603587600 - tz.transition 2021, 3, :o2, 1616893200 - tz.transition 2021, 10, :o1, 1635642000 - tz.transition 2022, 3, :o2, 1648342800 - tz.transition 2022, 10, :o1, 1667091600 - tz.transition 2023, 3, :o2, 1679792400 - tz.transition 2023, 10, :o1, 1698541200 - tz.transition 2024, 3, :o2, 1711846800 - tz.transition 2024, 10, :o1, 1729990800 - tz.transition 2025, 3, :o2, 1743296400 - tz.transition 2025, 10, :o1, 1761440400 - tz.transition 2026, 3, :o2, 1774746000 - tz.transition 2026, 10, :o1, 1792890000 - tz.transition 2027, 3, :o2, 1806195600 - tz.transition 2027, 10, :o1, 1824944400 - tz.transition 2028, 3, :o2, 1837645200 - tz.transition 2028, 10, :o1, 1856394000 - tz.transition 2029, 3, :o2, 1869094800 - tz.transition 2029, 10, :o1, 1887843600 - tz.transition 2030, 3, :o2, 1901149200 - tz.transition 2030, 10, :o1, 1919293200 - tz.transition 2031, 3, :o2, 1932598800 - tz.transition 2031, 10, :o1, 1950742800 - tz.transition 2032, 3, :o2, 1964048400 - tz.transition 2032, 10, :o1, 1982797200 - tz.transition 2033, 3, :o2, 1995498000 - tz.transition 2033, 10, :o1, 2014246800 - tz.transition 2034, 3, :o2, 2026947600 - tz.transition 2034, 10, :o1, 2045696400 - tz.transition 2035, 3, :o2, 2058397200 - tz.transition 2035, 10, :o1, 2077146000 - tz.transition 2036, 3, :o2, 2090451600 - tz.transition 2036, 10, :o1, 2108595600 - tz.transition 2037, 3, :o2, 2121901200 - tz.transition 2037, 10, :o1, 2140045200 - tz.transition 2038, 3, :o2, 59172253, 24 - tz.transition 2038, 10, :o1, 59177461, 24 - tz.transition 2039, 3, :o2, 59180989, 24 - tz.transition 2039, 10, :o1, 59186197, 24 - tz.transition 2040, 3, :o2, 59189725, 24 - tz.transition 2040, 10, :o1, 59194933, 24 - tz.transition 2041, 3, :o2, 59198629, 24 - tz.transition 2041, 10, :o1, 59203669, 24 - tz.transition 2042, 3, :o2, 59207365, 24 - tz.transition 2042, 10, :o1, 59212405, 24 - tz.transition 2043, 3, :o2, 59216101, 24 - tz.transition 2043, 10, :o1, 59221141, 24 - tz.transition 2044, 3, :o2, 59224837, 24 - tz.transition 2044, 10, :o1, 59230045, 24 - tz.transition 2045, 3, :o2, 59233573, 24 - tz.transition 2045, 10, :o1, 59238781, 24 - tz.transition 2046, 3, :o2, 59242309, 24 - tz.transition 2046, 10, :o1, 59247517, 24 - tz.transition 2047, 3, :o2, 59251213, 24 - tz.transition 2047, 10, :o1, 59256253, 24 - tz.transition 2048, 3, :o2, 59259949, 24 - tz.transition 2048, 10, :o1, 59264989, 24 - tz.transition 2049, 3, :o2, 59268685, 24 - tz.transition 2049, 10, :o1, 59273893, 24 - tz.transition 2050, 3, :o2, 59277421, 24 - tz.transition 2050, 10, :o1, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Ljubljana.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Ljubljana.rb deleted file mode 100644 index a9828e6..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Ljubljana.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Ljubljana - include TimezoneDefinition - - linked_timezone 'Europe/Ljubljana', 'Europe/Belgrade' - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/London.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/London.rb deleted file mode 100644 index 64ce41e..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/London.rb +++ /dev/null @@ -1,288 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module London - include TimezoneDefinition - - timezone 'Europe/London' do |tz| - tz.offset :o0, -75, 0, :LMT - tz.offset :o1, 0, 0, :GMT - tz.offset :o2, 0, 3600, :BST - tz.offset :o3, 0, 7200, :BDST - tz.offset :o4, 3600, 0, :BST - - tz.transition 1847, 12, :o1, 2760187969, 1152 - tz.transition 1916, 5, :o2, 29052055, 12 - tz.transition 1916, 10, :o1, 29053651, 12 - tz.transition 1917, 4, :o2, 29055919, 12 - tz.transition 1917, 9, :o1, 29057863, 12 - tz.transition 1918, 3, :o2, 29060119, 12 - tz.transition 1918, 9, :o1, 29062399, 12 - tz.transition 1919, 3, :o2, 29064571, 12 - tz.transition 1919, 9, :o1, 29066767, 12 - tz.transition 1920, 3, :o2, 29068939, 12 - tz.transition 1920, 10, :o1, 29071471, 12 - tz.transition 1921, 4, :o2, 29073391, 12 - tz.transition 1921, 10, :o1, 29075587, 12 - tz.transition 1922, 3, :o2, 29077675, 12 - tz.transition 1922, 10, :o1, 29080027, 12 - tz.transition 1923, 4, :o2, 29082379, 12 - tz.transition 1923, 9, :o1, 29084143, 12 - tz.transition 1924, 4, :o2, 29086663, 12 - tz.transition 1924, 9, :o1, 29088595, 12 - tz.transition 1925, 4, :o2, 29091115, 12 - tz.transition 1925, 10, :o1, 29093131, 12 - tz.transition 1926, 4, :o2, 29095483, 12 - tz.transition 1926, 10, :o1, 29097499, 12 - tz.transition 1927, 4, :o2, 29099767, 12 - tz.transition 1927, 10, :o1, 29101867, 12 - tz.transition 1928, 4, :o2, 29104303, 12 - tz.transition 1928, 10, :o1, 29106319, 12 - tz.transition 1929, 4, :o2, 29108671, 12 - tz.transition 1929, 10, :o1, 29110687, 12 - tz.transition 1930, 4, :o2, 29112955, 12 - tz.transition 1930, 10, :o1, 29115055, 12 - tz.transition 1931, 4, :o2, 29117407, 12 - tz.transition 1931, 10, :o1, 29119423, 12 - tz.transition 1932, 4, :o2, 29121775, 12 - tz.transition 1932, 10, :o1, 29123791, 12 - tz.transition 1933, 4, :o2, 29126059, 12 - tz.transition 1933, 10, :o1, 29128243, 12 - tz.transition 1934, 4, :o2, 29130595, 12 - tz.transition 1934, 10, :o1, 29132611, 12 - tz.transition 1935, 4, :o2, 29134879, 12 - tz.transition 1935, 10, :o1, 29136979, 12 - tz.transition 1936, 4, :o2, 29139331, 12 - tz.transition 1936, 10, :o1, 29141347, 12 - tz.transition 1937, 4, :o2, 29143699, 12 - tz.transition 1937, 10, :o1, 29145715, 12 - tz.transition 1938, 4, :o2, 29147983, 12 - tz.transition 1938, 10, :o1, 29150083, 12 - tz.transition 1939, 4, :o2, 29152435, 12 - tz.transition 1939, 11, :o1, 29155039, 12 - tz.transition 1940, 2, :o2, 29156215, 12 - tz.transition 1941, 5, :o3, 58322845, 24 - tz.transition 1941, 8, :o2, 58325197, 24 - tz.transition 1942, 4, :o3, 58330909, 24 - tz.transition 1942, 8, :o2, 58333933, 24 - tz.transition 1943, 4, :o3, 58339645, 24 - tz.transition 1943, 8, :o2, 58342837, 24 - tz.transition 1944, 4, :o3, 58348381, 24 - tz.transition 1944, 9, :o2, 58352413, 24 - tz.transition 1945, 4, :o3, 58357141, 24 - tz.transition 1945, 7, :o2, 58359637, 24 - tz.transition 1945, 10, :o1, 29180827, 12 - tz.transition 1946, 4, :o2, 29183095, 12 - tz.transition 1946, 10, :o1, 29185195, 12 - tz.transition 1947, 3, :o2, 29187127, 12 - tz.transition 1947, 4, :o3, 58374925, 24 - tz.transition 1947, 8, :o2, 58377781, 24 - tz.transition 1947, 11, :o1, 29189899, 12 - tz.transition 1948, 3, :o2, 29191495, 12 - tz.transition 1948, 10, :o1, 29194267, 12 - tz.transition 1949, 4, :o2, 29196115, 12 - tz.transition 1949, 10, :o1, 29198635, 12 - tz.transition 1950, 4, :o2, 29200651, 12 - tz.transition 1950, 10, :o1, 29202919, 12 - tz.transition 1951, 4, :o2, 29205019, 12 - tz.transition 1951, 10, :o1, 29207287, 12 - tz.transition 1952, 4, :o2, 29209471, 12 - tz.transition 1952, 10, :o1, 29211739, 12 - tz.transition 1953, 4, :o2, 29213839, 12 - tz.transition 1953, 10, :o1, 29215855, 12 - tz.transition 1954, 4, :o2, 29218123, 12 - tz.transition 1954, 10, :o1, 29220223, 12 - tz.transition 1955, 4, :o2, 29222575, 12 - tz.transition 1955, 10, :o1, 29224591, 12 - tz.transition 1956, 4, :o2, 29227027, 12 - tz.transition 1956, 10, :o1, 29229043, 12 - tz.transition 1957, 4, :o2, 29231311, 12 - tz.transition 1957, 10, :o1, 29233411, 12 - tz.transition 1958, 4, :o2, 29235763, 12 - tz.transition 1958, 10, :o1, 29237779, 12 - tz.transition 1959, 4, :o2, 29240131, 12 - tz.transition 1959, 10, :o1, 29242147, 12 - tz.transition 1960, 4, :o2, 29244415, 12 - tz.transition 1960, 10, :o1, 29246515, 12 - tz.transition 1961, 3, :o2, 29248615, 12 - tz.transition 1961, 10, :o1, 29251219, 12 - tz.transition 1962, 3, :o2, 29252983, 12 - tz.transition 1962, 10, :o1, 29255587, 12 - tz.transition 1963, 3, :o2, 29257435, 12 - tz.transition 1963, 10, :o1, 29259955, 12 - tz.transition 1964, 3, :o2, 29261719, 12 - tz.transition 1964, 10, :o1, 29264323, 12 - tz.transition 1965, 3, :o2, 29266087, 12 - tz.transition 1965, 10, :o1, 29268691, 12 - tz.transition 1966, 3, :o2, 29270455, 12 - tz.transition 1966, 10, :o1, 29273059, 12 - tz.transition 1967, 3, :o2, 29274823, 12 - tz.transition 1967, 10, :o1, 29277511, 12 - tz.transition 1968, 2, :o2, 29278855, 12 - tz.transition 1968, 10, :o4, 58563755, 24 - tz.transition 1971, 10, :o1, 57722400 - tz.transition 1972, 3, :o2, 69818400 - tz.transition 1972, 10, :o1, 89172000 - tz.transition 1973, 3, :o2, 101268000 - tz.transition 1973, 10, :o1, 120621600 - tz.transition 1974, 3, :o2, 132717600 - tz.transition 1974, 10, :o1, 152071200 - tz.transition 1975, 3, :o2, 164167200 - tz.transition 1975, 10, :o1, 183520800 - tz.transition 1976, 3, :o2, 196221600 - tz.transition 1976, 10, :o1, 214970400 - tz.transition 1977, 3, :o2, 227671200 - tz.transition 1977, 10, :o1, 246420000 - tz.transition 1978, 3, :o2, 259120800 - tz.transition 1978, 10, :o1, 278474400 - tz.transition 1979, 3, :o2, 290570400 - tz.transition 1979, 10, :o1, 309924000 - tz.transition 1980, 3, :o2, 322020000 - tz.transition 1980, 10, :o1, 341373600 - tz.transition 1981, 3, :o2, 354675600 - tz.transition 1981, 10, :o1, 372819600 - tz.transition 1982, 3, :o2, 386125200 - tz.transition 1982, 10, :o1, 404269200 - tz.transition 1983, 3, :o2, 417574800 - tz.transition 1983, 10, :o1, 435718800 - tz.transition 1984, 3, :o2, 449024400 - tz.transition 1984, 10, :o1, 467773200 - tz.transition 1985, 3, :o2, 481078800 - tz.transition 1985, 10, :o1, 499222800 - tz.transition 1986, 3, :o2, 512528400 - tz.transition 1986, 10, :o1, 530672400 - tz.transition 1987, 3, :o2, 543978000 - tz.transition 1987, 10, :o1, 562122000 - tz.transition 1988, 3, :o2, 575427600 - tz.transition 1988, 10, :o1, 593571600 - tz.transition 1989, 3, :o2, 606877200 - tz.transition 1989, 10, :o1, 625626000 - tz.transition 1990, 3, :o2, 638326800 - tz.transition 1990, 10, :o1, 657075600 - tz.transition 1991, 3, :o2, 670381200 - tz.transition 1991, 10, :o1, 688525200 - tz.transition 1992, 3, :o2, 701830800 - tz.transition 1992, 10, :o1, 719974800 - tz.transition 1993, 3, :o2, 733280400 - tz.transition 1993, 10, :o1, 751424400 - tz.transition 1994, 3, :o2, 764730000 - tz.transition 1994, 10, :o1, 782874000 - tz.transition 1995, 3, :o2, 796179600 - tz.transition 1995, 10, :o1, 814323600 - tz.transition 1996, 3, :o2, 828234000 - tz.transition 1996, 10, :o1, 846378000 - tz.transition 1997, 3, :o2, 859683600 - tz.transition 1997, 10, :o1, 877827600 - tz.transition 1998, 3, :o2, 891133200 - tz.transition 1998, 10, :o1, 909277200 - tz.transition 1999, 3, :o2, 922582800 - tz.transition 1999, 10, :o1, 941331600 - tz.transition 2000, 3, :o2, 954032400 - tz.transition 2000, 10, :o1, 972781200 - tz.transition 2001, 3, :o2, 985482000 - tz.transition 2001, 10, :o1, 1004230800 - tz.transition 2002, 3, :o2, 1017536400 - tz.transition 2002, 10, :o1, 1035680400 - tz.transition 2003, 3, :o2, 1048986000 - tz.transition 2003, 10, :o1, 1067130000 - tz.transition 2004, 3, :o2, 1080435600 - tz.transition 2004, 10, :o1, 1099184400 - tz.transition 2005, 3, :o2, 1111885200 - tz.transition 2005, 10, :o1, 1130634000 - tz.transition 2006, 3, :o2, 1143334800 - tz.transition 2006, 10, :o1, 1162083600 - tz.transition 2007, 3, :o2, 1174784400 - tz.transition 2007, 10, :o1, 1193533200 - tz.transition 2008, 3, :o2, 1206838800 - tz.transition 2008, 10, :o1, 1224982800 - tz.transition 2009, 3, :o2, 1238288400 - tz.transition 2009, 10, :o1, 1256432400 - tz.transition 2010, 3, :o2, 1269738000 - tz.transition 2010, 10, :o1, 1288486800 - tz.transition 2011, 3, :o2, 1301187600 - tz.transition 2011, 10, :o1, 1319936400 - tz.transition 2012, 3, :o2, 1332637200 - tz.transition 2012, 10, :o1, 1351386000 - tz.transition 2013, 3, :o2, 1364691600 - tz.transition 2013, 10, :o1, 1382835600 - tz.transition 2014, 3, :o2, 1396141200 - tz.transition 2014, 10, :o1, 1414285200 - tz.transition 2015, 3, :o2, 1427590800 - tz.transition 2015, 10, :o1, 1445734800 - tz.transition 2016, 3, :o2, 1459040400 - tz.transition 2016, 10, :o1, 1477789200 - tz.transition 2017, 3, :o2, 1490490000 - tz.transition 2017, 10, :o1, 1509238800 - tz.transition 2018, 3, :o2, 1521939600 - tz.transition 2018, 10, :o1, 1540688400 - tz.transition 2019, 3, :o2, 1553994000 - tz.transition 2019, 10, :o1, 1572138000 - tz.transition 2020, 3, :o2, 1585443600 - tz.transition 2020, 10, :o1, 1603587600 - tz.transition 2021, 3, :o2, 1616893200 - tz.transition 2021, 10, :o1, 1635642000 - tz.transition 2022, 3, :o2, 1648342800 - tz.transition 2022, 10, :o1, 1667091600 - tz.transition 2023, 3, :o2, 1679792400 - tz.transition 2023, 10, :o1, 1698541200 - tz.transition 2024, 3, :o2, 1711846800 - tz.transition 2024, 10, :o1, 1729990800 - tz.transition 2025, 3, :o2, 1743296400 - tz.transition 2025, 10, :o1, 1761440400 - tz.transition 2026, 3, :o2, 1774746000 - tz.transition 2026, 10, :o1, 1792890000 - tz.transition 2027, 3, :o2, 1806195600 - tz.transition 2027, 10, :o1, 1824944400 - tz.transition 2028, 3, :o2, 1837645200 - tz.transition 2028, 10, :o1, 1856394000 - tz.transition 2029, 3, :o2, 1869094800 - tz.transition 2029, 10, :o1, 1887843600 - tz.transition 2030, 3, :o2, 1901149200 - tz.transition 2030, 10, :o1, 1919293200 - tz.transition 2031, 3, :o2, 1932598800 - tz.transition 2031, 10, :o1, 1950742800 - tz.transition 2032, 3, :o2, 1964048400 - tz.transition 2032, 10, :o1, 1982797200 - tz.transition 2033, 3, :o2, 1995498000 - tz.transition 2033, 10, :o1, 2014246800 - tz.transition 2034, 3, :o2, 2026947600 - tz.transition 2034, 10, :o1, 2045696400 - tz.transition 2035, 3, :o2, 2058397200 - tz.transition 2035, 10, :o1, 2077146000 - tz.transition 2036, 3, :o2, 2090451600 - tz.transition 2036, 10, :o1, 2108595600 - tz.transition 2037, 3, :o2, 2121901200 - tz.transition 2037, 10, :o1, 2140045200 - tz.transition 2038, 3, :o2, 59172253, 24 - tz.transition 2038, 10, :o1, 59177461, 24 - tz.transition 2039, 3, :o2, 59180989, 24 - tz.transition 2039, 10, :o1, 59186197, 24 - tz.transition 2040, 3, :o2, 59189725, 24 - tz.transition 2040, 10, :o1, 59194933, 24 - tz.transition 2041, 3, :o2, 59198629, 24 - tz.transition 2041, 10, :o1, 59203669, 24 - tz.transition 2042, 3, :o2, 59207365, 24 - tz.transition 2042, 10, :o1, 59212405, 24 - tz.transition 2043, 3, :o2, 59216101, 24 - tz.transition 2043, 10, :o1, 59221141, 24 - tz.transition 2044, 3, :o2, 59224837, 24 - tz.transition 2044, 10, :o1, 59230045, 24 - tz.transition 2045, 3, :o2, 59233573, 24 - tz.transition 2045, 10, :o1, 59238781, 24 - tz.transition 2046, 3, :o2, 59242309, 24 - tz.transition 2046, 10, :o1, 59247517, 24 - tz.transition 2047, 3, :o2, 59251213, 24 - tz.transition 2047, 10, :o1, 59256253, 24 - tz.transition 2048, 3, :o2, 59259949, 24 - tz.transition 2048, 10, :o1, 59264989, 24 - tz.transition 2049, 3, :o2, 59268685, 24 - tz.transition 2049, 10, :o1, 59273893, 24 - tz.transition 2050, 3, :o2, 59277421, 24 - tz.transition 2050, 10, :o1, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Madrid.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Madrid.rb deleted file mode 100644 index 1fb5682..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Madrid.rb +++ /dev/null @@ -1,211 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Madrid - include TimezoneDefinition - - timezone 'Europe/Madrid' do |tz| - tz.offset :o0, -884, 0, :LMT - tz.offset :o1, 0, 0, :WET - tz.offset :o2, 0, 3600, :WEST - tz.offset :o3, 0, 7200, :WEMT - tz.offset :o4, 3600, 0, :CET - tz.offset :o5, 3600, 3600, :CEST - - tz.transition 1901, 1, :o1, 52172327021, 21600 - tz.transition 1917, 5, :o2, 58112507, 24 - tz.transition 1917, 10, :o1, 58116203, 24 - tz.transition 1918, 4, :o2, 58120787, 24 - tz.transition 1918, 10, :o1, 58124963, 24 - tz.transition 1919, 4, :o2, 58129307, 24 - tz.transition 1919, 10, :o1, 58133723, 24 - tz.transition 1924, 4, :o2, 58173419, 24 - tz.transition 1924, 10, :o1, 58177523, 24 - tz.transition 1926, 4, :o2, 58190963, 24 - tz.transition 1926, 10, :o1, 58194995, 24 - tz.transition 1927, 4, :o2, 58199531, 24 - tz.transition 1927, 10, :o1, 58203731, 24 - tz.transition 1928, 4, :o2, 58208435, 24 - tz.transition 1928, 10, :o1, 58212635, 24 - tz.transition 1929, 4, :o2, 58217339, 24 - tz.transition 1929, 10, :o1, 58221371, 24 - tz.transition 1937, 5, :o2, 58288235, 24 - tz.transition 1937, 10, :o1, 58291427, 24 - tz.transition 1938, 3, :o2, 58295531, 24 - tz.transition 1938, 10, :o1, 58300163, 24 - tz.transition 1939, 4, :o2, 58304867, 24 - tz.transition 1939, 10, :o1, 58309067, 24 - tz.transition 1940, 3, :o2, 58312931, 24 - tz.transition 1942, 5, :o3, 29165789, 12 - tz.transition 1942, 9, :o2, 29167253, 12 - tz.transition 1943, 4, :o3, 29169989, 12 - tz.transition 1943, 10, :o2, 29172017, 12 - tz.transition 1944, 4, :o3, 29174357, 12 - tz.transition 1944, 10, :o2, 29176493, 12 - tz.transition 1945, 4, :o3, 29178725, 12 - tz.transition 1945, 9, :o2, 58361483, 24 - tz.transition 1946, 4, :o3, 29183093, 12 - tz.transition 1946, 9, :o4, 29185121, 12 - tz.transition 1949, 4, :o5, 29196449, 12 - tz.transition 1949, 9, :o4, 58396547, 24 - tz.transition 1974, 4, :o5, 135122400 - tz.transition 1974, 10, :o4, 150246000 - tz.transition 1975, 4, :o5, 167176800 - tz.transition 1975, 10, :o4, 181695600 - tz.transition 1976, 3, :o5, 196812000 - tz.transition 1976, 9, :o4, 212540400 - tz.transition 1977, 4, :o5, 228866400 - tz.transition 1977, 9, :o4, 243990000 - tz.transition 1978, 4, :o5, 260402400 - tz.transition 1978, 9, :o4, 276044400 - tz.transition 1979, 4, :o5, 291776400 - tz.transition 1979, 9, :o4, 307501200 - tz.transition 1980, 4, :o5, 323830800 - tz.transition 1980, 9, :o4, 338950800 - tz.transition 1981, 3, :o5, 354675600 - tz.transition 1981, 9, :o4, 370400400 - tz.transition 1982, 3, :o5, 386125200 - tz.transition 1982, 9, :o4, 401850000 - tz.transition 1983, 3, :o5, 417574800 - tz.transition 1983, 9, :o4, 433299600 - tz.transition 1984, 3, :o5, 449024400 - tz.transition 1984, 9, :o4, 465354000 - tz.transition 1985, 3, :o5, 481078800 - tz.transition 1985, 9, :o4, 496803600 - tz.transition 1986, 3, :o5, 512528400 - tz.transition 1986, 9, :o4, 528253200 - tz.transition 1987, 3, :o5, 543978000 - tz.transition 1987, 9, :o4, 559702800 - tz.transition 1988, 3, :o5, 575427600 - tz.transition 1988, 9, :o4, 591152400 - tz.transition 1989, 3, :o5, 606877200 - tz.transition 1989, 9, :o4, 622602000 - tz.transition 1990, 3, :o5, 638326800 - tz.transition 1990, 9, :o4, 654656400 - tz.transition 1991, 3, :o5, 670381200 - tz.transition 1991, 9, :o4, 686106000 - tz.transition 1992, 3, :o5, 701830800 - tz.transition 1992, 9, :o4, 717555600 - tz.transition 1993, 3, :o5, 733280400 - tz.transition 1993, 9, :o4, 749005200 - tz.transition 1994, 3, :o5, 764730000 - tz.transition 1994, 9, :o4, 780454800 - tz.transition 1995, 3, :o5, 796179600 - tz.transition 1995, 9, :o4, 811904400 - tz.transition 1996, 3, :o5, 828234000 - tz.transition 1996, 10, :o4, 846378000 - tz.transition 1997, 3, :o5, 859683600 - tz.transition 1997, 10, :o4, 877827600 - tz.transition 1998, 3, :o5, 891133200 - tz.transition 1998, 10, :o4, 909277200 - tz.transition 1999, 3, :o5, 922582800 - tz.transition 1999, 10, :o4, 941331600 - tz.transition 2000, 3, :o5, 954032400 - tz.transition 2000, 10, :o4, 972781200 - tz.transition 2001, 3, :o5, 985482000 - tz.transition 2001, 10, :o4, 1004230800 - tz.transition 2002, 3, :o5, 1017536400 - tz.transition 2002, 10, :o4, 1035680400 - tz.transition 2003, 3, :o5, 1048986000 - tz.transition 2003, 10, :o4, 1067130000 - tz.transition 2004, 3, :o5, 1080435600 - tz.transition 2004, 10, :o4, 1099184400 - tz.transition 2005, 3, :o5, 1111885200 - tz.transition 2005, 10, :o4, 1130634000 - tz.transition 2006, 3, :o5, 1143334800 - tz.transition 2006, 10, :o4, 1162083600 - tz.transition 2007, 3, :o5, 1174784400 - tz.transition 2007, 10, :o4, 1193533200 - tz.transition 2008, 3, :o5, 1206838800 - tz.transition 2008, 10, :o4, 1224982800 - tz.transition 2009, 3, :o5, 1238288400 - tz.transition 2009, 10, :o4, 1256432400 - tz.transition 2010, 3, :o5, 1269738000 - tz.transition 2010, 10, :o4, 1288486800 - tz.transition 2011, 3, :o5, 1301187600 - tz.transition 2011, 10, :o4, 1319936400 - tz.transition 2012, 3, :o5, 1332637200 - tz.transition 2012, 10, :o4, 1351386000 - tz.transition 2013, 3, :o5, 1364691600 - tz.transition 2013, 10, :o4, 1382835600 - tz.transition 2014, 3, :o5, 1396141200 - tz.transition 2014, 10, :o4, 1414285200 - tz.transition 2015, 3, :o5, 1427590800 - tz.transition 2015, 10, :o4, 1445734800 - tz.transition 2016, 3, :o5, 1459040400 - tz.transition 2016, 10, :o4, 1477789200 - tz.transition 2017, 3, :o5, 1490490000 - tz.transition 2017, 10, :o4, 1509238800 - tz.transition 2018, 3, :o5, 1521939600 - tz.transition 2018, 10, :o4, 1540688400 - tz.transition 2019, 3, :o5, 1553994000 - tz.transition 2019, 10, :o4, 1572138000 - tz.transition 2020, 3, :o5, 1585443600 - tz.transition 2020, 10, :o4, 1603587600 - tz.transition 2021, 3, :o5, 1616893200 - tz.transition 2021, 10, :o4, 1635642000 - tz.transition 2022, 3, :o5, 1648342800 - tz.transition 2022, 10, :o4, 1667091600 - tz.transition 2023, 3, :o5, 1679792400 - tz.transition 2023, 10, :o4, 1698541200 - tz.transition 2024, 3, :o5, 1711846800 - tz.transition 2024, 10, :o4, 1729990800 - tz.transition 2025, 3, :o5, 1743296400 - tz.transition 2025, 10, :o4, 1761440400 - tz.transition 2026, 3, :o5, 1774746000 - tz.transition 2026, 10, :o4, 1792890000 - tz.transition 2027, 3, :o5, 1806195600 - tz.transition 2027, 10, :o4, 1824944400 - tz.transition 2028, 3, :o5, 1837645200 - tz.transition 2028, 10, :o4, 1856394000 - tz.transition 2029, 3, :o5, 1869094800 - tz.transition 2029, 10, :o4, 1887843600 - tz.transition 2030, 3, :o5, 1901149200 - tz.transition 2030, 10, :o4, 1919293200 - tz.transition 2031, 3, :o5, 1932598800 - tz.transition 2031, 10, :o4, 1950742800 - tz.transition 2032, 3, :o5, 1964048400 - tz.transition 2032, 10, :o4, 1982797200 - tz.transition 2033, 3, :o5, 1995498000 - tz.transition 2033, 10, :o4, 2014246800 - tz.transition 2034, 3, :o5, 2026947600 - tz.transition 2034, 10, :o4, 2045696400 - tz.transition 2035, 3, :o5, 2058397200 - tz.transition 2035, 10, :o4, 2077146000 - tz.transition 2036, 3, :o5, 2090451600 - tz.transition 2036, 10, :o4, 2108595600 - tz.transition 2037, 3, :o5, 2121901200 - tz.transition 2037, 10, :o4, 2140045200 - tz.transition 2038, 3, :o5, 59172253, 24 - tz.transition 2038, 10, :o4, 59177461, 24 - tz.transition 2039, 3, :o5, 59180989, 24 - tz.transition 2039, 10, :o4, 59186197, 24 - tz.transition 2040, 3, :o5, 59189725, 24 - tz.transition 2040, 10, :o4, 59194933, 24 - tz.transition 2041, 3, :o5, 59198629, 24 - tz.transition 2041, 10, :o4, 59203669, 24 - tz.transition 2042, 3, :o5, 59207365, 24 - tz.transition 2042, 10, :o4, 59212405, 24 - tz.transition 2043, 3, :o5, 59216101, 24 - tz.transition 2043, 10, :o4, 59221141, 24 - tz.transition 2044, 3, :o5, 59224837, 24 - tz.transition 2044, 10, :o4, 59230045, 24 - tz.transition 2045, 3, :o5, 59233573, 24 - tz.transition 2045, 10, :o4, 59238781, 24 - tz.transition 2046, 3, :o5, 59242309, 24 - tz.transition 2046, 10, :o4, 59247517, 24 - tz.transition 2047, 3, :o5, 59251213, 24 - tz.transition 2047, 10, :o4, 59256253, 24 - tz.transition 2048, 3, :o5, 59259949, 24 - tz.transition 2048, 10, :o4, 59264989, 24 - tz.transition 2049, 3, :o5, 59268685, 24 - tz.transition 2049, 10, :o4, 59273893, 24 - tz.transition 2050, 3, :o5, 59277421, 24 - tz.transition 2050, 10, :o4, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Minsk.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Minsk.rb deleted file mode 100644 index fa15816..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Minsk.rb +++ /dev/null @@ -1,170 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Minsk - include TimezoneDefinition - - timezone 'Europe/Minsk' do |tz| - tz.offset :o0, 6616, 0, :LMT - tz.offset :o1, 6600, 0, :MMT - tz.offset :o2, 7200, 0, :EET - tz.offset :o3, 10800, 0, :MSK - tz.offset :o4, 3600, 3600, :CEST - tz.offset :o5, 3600, 0, :CET - tz.offset :o6, 10800, 3600, :MSD - tz.offset :o7, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 26003326573, 10800 - tz.transition 1924, 5, :o2, 349042669, 144 - tz.transition 1930, 6, :o3, 29113781, 12 - tz.transition 1941, 6, :o4, 19441387, 8 - tz.transition 1942, 11, :o5, 58335973, 24 - tz.transition 1943, 3, :o4, 58339501, 24 - tz.transition 1943, 10, :o5, 58344037, 24 - tz.transition 1944, 4, :o4, 58348405, 24 - tz.transition 1944, 7, :o3, 29175293, 12 - tz.transition 1981, 3, :o6, 354920400 - tz.transition 1981, 9, :o3, 370728000 - tz.transition 1982, 3, :o6, 386456400 - tz.transition 1982, 9, :o3, 402264000 - tz.transition 1983, 3, :o6, 417992400 - tz.transition 1983, 9, :o3, 433800000 - tz.transition 1984, 3, :o6, 449614800 - tz.transition 1984, 9, :o3, 465346800 - tz.transition 1985, 3, :o6, 481071600 - tz.transition 1985, 9, :o3, 496796400 - tz.transition 1986, 3, :o6, 512521200 - tz.transition 1986, 9, :o3, 528246000 - tz.transition 1987, 3, :o6, 543970800 - tz.transition 1987, 9, :o3, 559695600 - tz.transition 1988, 3, :o6, 575420400 - tz.transition 1988, 9, :o3, 591145200 - tz.transition 1989, 3, :o6, 606870000 - tz.transition 1989, 9, :o3, 622594800 - tz.transition 1991, 3, :o7, 670374000 - tz.transition 1991, 9, :o2, 686102400 - tz.transition 1992, 3, :o7, 701820000 - tz.transition 1992, 9, :o2, 717544800 - tz.transition 1993, 3, :o7, 733276800 - tz.transition 1993, 9, :o2, 749001600 - tz.transition 1994, 3, :o7, 764726400 - tz.transition 1994, 9, :o2, 780451200 - tz.transition 1995, 3, :o7, 796176000 - tz.transition 1995, 9, :o2, 811900800 - tz.transition 1996, 3, :o7, 828230400 - tz.transition 1996, 10, :o2, 846374400 - tz.transition 1997, 3, :o7, 859680000 - tz.transition 1997, 10, :o2, 877824000 - tz.transition 1998, 3, :o7, 891129600 - tz.transition 1998, 10, :o2, 909273600 - tz.transition 1999, 3, :o7, 922579200 - tz.transition 1999, 10, :o2, 941328000 - tz.transition 2000, 3, :o7, 954028800 - tz.transition 2000, 10, :o2, 972777600 - tz.transition 2001, 3, :o7, 985478400 - tz.transition 2001, 10, :o2, 1004227200 - tz.transition 2002, 3, :o7, 1017532800 - tz.transition 2002, 10, :o2, 1035676800 - tz.transition 2003, 3, :o7, 1048982400 - tz.transition 2003, 10, :o2, 1067126400 - tz.transition 2004, 3, :o7, 1080432000 - tz.transition 2004, 10, :o2, 1099180800 - tz.transition 2005, 3, :o7, 1111881600 - tz.transition 2005, 10, :o2, 1130630400 - tz.transition 2006, 3, :o7, 1143331200 - tz.transition 2006, 10, :o2, 1162080000 - tz.transition 2007, 3, :o7, 1174780800 - tz.transition 2007, 10, :o2, 1193529600 - tz.transition 2008, 3, :o7, 1206835200 - tz.transition 2008, 10, :o2, 1224979200 - tz.transition 2009, 3, :o7, 1238284800 - tz.transition 2009, 10, :o2, 1256428800 - tz.transition 2010, 3, :o7, 1269734400 - tz.transition 2010, 10, :o2, 1288483200 - tz.transition 2011, 3, :o7, 1301184000 - tz.transition 2011, 10, :o2, 1319932800 - tz.transition 2012, 3, :o7, 1332633600 - tz.transition 2012, 10, :o2, 1351382400 - tz.transition 2013, 3, :o7, 1364688000 - tz.transition 2013, 10, :o2, 1382832000 - tz.transition 2014, 3, :o7, 1396137600 - tz.transition 2014, 10, :o2, 1414281600 - tz.transition 2015, 3, :o7, 1427587200 - tz.transition 2015, 10, :o2, 1445731200 - tz.transition 2016, 3, :o7, 1459036800 - tz.transition 2016, 10, :o2, 1477785600 - tz.transition 2017, 3, :o7, 1490486400 - tz.transition 2017, 10, :o2, 1509235200 - tz.transition 2018, 3, :o7, 1521936000 - tz.transition 2018, 10, :o2, 1540684800 - tz.transition 2019, 3, :o7, 1553990400 - tz.transition 2019, 10, :o2, 1572134400 - tz.transition 2020, 3, :o7, 1585440000 - tz.transition 2020, 10, :o2, 1603584000 - tz.transition 2021, 3, :o7, 1616889600 - tz.transition 2021, 10, :o2, 1635638400 - tz.transition 2022, 3, :o7, 1648339200 - tz.transition 2022, 10, :o2, 1667088000 - tz.transition 2023, 3, :o7, 1679788800 - tz.transition 2023, 10, :o2, 1698537600 - tz.transition 2024, 3, :o7, 1711843200 - tz.transition 2024, 10, :o2, 1729987200 - tz.transition 2025, 3, :o7, 1743292800 - tz.transition 2025, 10, :o2, 1761436800 - tz.transition 2026, 3, :o7, 1774742400 - tz.transition 2026, 10, :o2, 1792886400 - tz.transition 2027, 3, :o7, 1806192000 - tz.transition 2027, 10, :o2, 1824940800 - tz.transition 2028, 3, :o7, 1837641600 - tz.transition 2028, 10, :o2, 1856390400 - tz.transition 2029, 3, :o7, 1869091200 - tz.transition 2029, 10, :o2, 1887840000 - tz.transition 2030, 3, :o7, 1901145600 - tz.transition 2030, 10, :o2, 1919289600 - tz.transition 2031, 3, :o7, 1932595200 - tz.transition 2031, 10, :o2, 1950739200 - tz.transition 2032, 3, :o7, 1964044800 - tz.transition 2032, 10, :o2, 1982793600 - tz.transition 2033, 3, :o7, 1995494400 - tz.transition 2033, 10, :o2, 2014243200 - tz.transition 2034, 3, :o7, 2026944000 - tz.transition 2034, 10, :o2, 2045692800 - tz.transition 2035, 3, :o7, 2058393600 - tz.transition 2035, 10, :o2, 2077142400 - tz.transition 2036, 3, :o7, 2090448000 - tz.transition 2036, 10, :o2, 2108592000 - tz.transition 2037, 3, :o7, 2121897600 - tz.transition 2037, 10, :o2, 2140041600 - tz.transition 2038, 3, :o7, 4931021, 2 - tz.transition 2038, 10, :o2, 4931455, 2 - tz.transition 2039, 3, :o7, 4931749, 2 - tz.transition 2039, 10, :o2, 4932183, 2 - tz.transition 2040, 3, :o7, 4932477, 2 - tz.transition 2040, 10, :o2, 4932911, 2 - tz.transition 2041, 3, :o7, 4933219, 2 - tz.transition 2041, 10, :o2, 4933639, 2 - tz.transition 2042, 3, :o7, 4933947, 2 - tz.transition 2042, 10, :o2, 4934367, 2 - tz.transition 2043, 3, :o7, 4934675, 2 - tz.transition 2043, 10, :o2, 4935095, 2 - tz.transition 2044, 3, :o7, 4935403, 2 - tz.transition 2044, 10, :o2, 4935837, 2 - tz.transition 2045, 3, :o7, 4936131, 2 - tz.transition 2045, 10, :o2, 4936565, 2 - tz.transition 2046, 3, :o7, 4936859, 2 - tz.transition 2046, 10, :o2, 4937293, 2 - tz.transition 2047, 3, :o7, 4937601, 2 - tz.transition 2047, 10, :o2, 4938021, 2 - tz.transition 2048, 3, :o7, 4938329, 2 - tz.transition 2048, 10, :o2, 4938749, 2 - tz.transition 2049, 3, :o7, 4939057, 2 - tz.transition 2049, 10, :o2, 4939491, 2 - tz.transition 2050, 3, :o7, 4939785, 2 - tz.transition 2050, 10, :o2, 4940219, 2 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Moscow.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Moscow.rb deleted file mode 100644 index ef269b6..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Moscow.rb +++ /dev/null @@ -1,181 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Moscow - include TimezoneDefinition - - timezone 'Europe/Moscow' do |tz| - tz.offset :o0, 9020, 0, :LMT - tz.offset :o1, 9000, 0, :MMT - tz.offset :o2, 9048, 0, :MMT - tz.offset :o3, 9048, 3600, :MST - tz.offset :o4, 9048, 7200, :MDST - tz.offset :o5, 10800, 3600, :MSD - tz.offset :o6, 10800, 0, :MSK - tz.offset :o7, 10800, 7200, :MSD - tz.offset :o8, 7200, 0, :EET - tz.offset :o9, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 10401330509, 4320 - tz.transition 1916, 7, :o2, 116210275, 48 - tz.transition 1917, 7, :o3, 8717080873, 3600 - tz.transition 1917, 12, :o2, 8717725273, 3600 - tz.transition 1918, 5, :o4, 8718283123, 3600 - tz.transition 1918, 9, :o3, 8718668473, 3600 - tz.transition 1919, 5, :o4, 8719597123, 3600 - tz.transition 1919, 6, :o5, 8719705423, 3600 - tz.transition 1919, 8, :o6, 7266559, 3 - tz.transition 1921, 2, :o5, 7268206, 3 - tz.transition 1921, 3, :o7, 58146463, 24 - tz.transition 1921, 8, :o5, 58150399, 24 - tz.transition 1921, 9, :o6, 7268890, 3 - tz.transition 1922, 9, :o8, 19386627, 8 - tz.transition 1930, 6, :o6, 29113781, 12 - tz.transition 1981, 3, :o5, 354920400 - tz.transition 1981, 9, :o6, 370728000 - tz.transition 1982, 3, :o5, 386456400 - tz.transition 1982, 9, :o6, 402264000 - tz.transition 1983, 3, :o5, 417992400 - tz.transition 1983, 9, :o6, 433800000 - tz.transition 1984, 3, :o5, 449614800 - tz.transition 1984, 9, :o6, 465346800 - tz.transition 1985, 3, :o5, 481071600 - tz.transition 1985, 9, :o6, 496796400 - tz.transition 1986, 3, :o5, 512521200 - tz.transition 1986, 9, :o6, 528246000 - tz.transition 1987, 3, :o5, 543970800 - tz.transition 1987, 9, :o6, 559695600 - tz.transition 1988, 3, :o5, 575420400 - tz.transition 1988, 9, :o6, 591145200 - tz.transition 1989, 3, :o5, 606870000 - tz.transition 1989, 9, :o6, 622594800 - tz.transition 1990, 3, :o5, 638319600 - tz.transition 1990, 9, :o6, 654649200 - tz.transition 1991, 3, :o9, 670374000 - tz.transition 1991, 9, :o8, 686102400 - tz.transition 1992, 1, :o6, 695779200 - tz.transition 1992, 3, :o5, 701812800 - tz.transition 1992, 9, :o6, 717534000 - tz.transition 1993, 3, :o5, 733273200 - tz.transition 1993, 9, :o6, 748998000 - tz.transition 1994, 3, :o5, 764722800 - tz.transition 1994, 9, :o6, 780447600 - tz.transition 1995, 3, :o5, 796172400 - tz.transition 1995, 9, :o6, 811897200 - tz.transition 1996, 3, :o5, 828226800 - tz.transition 1996, 10, :o6, 846370800 - tz.transition 1997, 3, :o5, 859676400 - tz.transition 1997, 10, :o6, 877820400 - tz.transition 1998, 3, :o5, 891126000 - tz.transition 1998, 10, :o6, 909270000 - tz.transition 1999, 3, :o5, 922575600 - tz.transition 1999, 10, :o6, 941324400 - tz.transition 2000, 3, :o5, 954025200 - tz.transition 2000, 10, :o6, 972774000 - tz.transition 2001, 3, :o5, 985474800 - tz.transition 2001, 10, :o6, 1004223600 - tz.transition 2002, 3, :o5, 1017529200 - tz.transition 2002, 10, :o6, 1035673200 - tz.transition 2003, 3, :o5, 1048978800 - tz.transition 2003, 10, :o6, 1067122800 - tz.transition 2004, 3, :o5, 1080428400 - tz.transition 2004, 10, :o6, 1099177200 - tz.transition 2005, 3, :o5, 1111878000 - tz.transition 2005, 10, :o6, 1130626800 - tz.transition 2006, 3, :o5, 1143327600 - tz.transition 2006, 10, :o6, 1162076400 - tz.transition 2007, 3, :o5, 1174777200 - tz.transition 2007, 10, :o6, 1193526000 - tz.transition 2008, 3, :o5, 1206831600 - tz.transition 2008, 10, :o6, 1224975600 - tz.transition 2009, 3, :o5, 1238281200 - tz.transition 2009, 10, :o6, 1256425200 - tz.transition 2010, 3, :o5, 1269730800 - tz.transition 2010, 10, :o6, 1288479600 - tz.transition 2011, 3, :o5, 1301180400 - tz.transition 2011, 10, :o6, 1319929200 - tz.transition 2012, 3, :o5, 1332630000 - tz.transition 2012, 10, :o6, 1351378800 - tz.transition 2013, 3, :o5, 1364684400 - tz.transition 2013, 10, :o6, 1382828400 - tz.transition 2014, 3, :o5, 1396134000 - tz.transition 2014, 10, :o6, 1414278000 - tz.transition 2015, 3, :o5, 1427583600 - tz.transition 2015, 10, :o6, 1445727600 - tz.transition 2016, 3, :o5, 1459033200 - tz.transition 2016, 10, :o6, 1477782000 - tz.transition 2017, 3, :o5, 1490482800 - tz.transition 2017, 10, :o6, 1509231600 - tz.transition 2018, 3, :o5, 1521932400 - tz.transition 2018, 10, :o6, 1540681200 - tz.transition 2019, 3, :o5, 1553986800 - tz.transition 2019, 10, :o6, 1572130800 - tz.transition 2020, 3, :o5, 1585436400 - tz.transition 2020, 10, :o6, 1603580400 - tz.transition 2021, 3, :o5, 1616886000 - tz.transition 2021, 10, :o6, 1635634800 - tz.transition 2022, 3, :o5, 1648335600 - tz.transition 2022, 10, :o6, 1667084400 - tz.transition 2023, 3, :o5, 1679785200 - tz.transition 2023, 10, :o6, 1698534000 - tz.transition 2024, 3, :o5, 1711839600 - tz.transition 2024, 10, :o6, 1729983600 - tz.transition 2025, 3, :o5, 1743289200 - tz.transition 2025, 10, :o6, 1761433200 - tz.transition 2026, 3, :o5, 1774738800 - tz.transition 2026, 10, :o6, 1792882800 - tz.transition 2027, 3, :o5, 1806188400 - tz.transition 2027, 10, :o6, 1824937200 - tz.transition 2028, 3, :o5, 1837638000 - tz.transition 2028, 10, :o6, 1856386800 - tz.transition 2029, 3, :o5, 1869087600 - tz.transition 2029, 10, :o6, 1887836400 - tz.transition 2030, 3, :o5, 1901142000 - tz.transition 2030, 10, :o6, 1919286000 - tz.transition 2031, 3, :o5, 1932591600 - tz.transition 2031, 10, :o6, 1950735600 - tz.transition 2032, 3, :o5, 1964041200 - tz.transition 2032, 10, :o6, 1982790000 - tz.transition 2033, 3, :o5, 1995490800 - tz.transition 2033, 10, :o6, 2014239600 - tz.transition 2034, 3, :o5, 2026940400 - tz.transition 2034, 10, :o6, 2045689200 - tz.transition 2035, 3, :o5, 2058390000 - tz.transition 2035, 10, :o6, 2077138800 - tz.transition 2036, 3, :o5, 2090444400 - tz.transition 2036, 10, :o6, 2108588400 - tz.transition 2037, 3, :o5, 2121894000 - tz.transition 2037, 10, :o6, 2140038000 - tz.transition 2038, 3, :o5, 59172251, 24 - tz.transition 2038, 10, :o6, 59177459, 24 - tz.transition 2039, 3, :o5, 59180987, 24 - tz.transition 2039, 10, :o6, 59186195, 24 - tz.transition 2040, 3, :o5, 59189723, 24 - tz.transition 2040, 10, :o6, 59194931, 24 - tz.transition 2041, 3, :o5, 59198627, 24 - tz.transition 2041, 10, :o6, 59203667, 24 - tz.transition 2042, 3, :o5, 59207363, 24 - tz.transition 2042, 10, :o6, 59212403, 24 - tz.transition 2043, 3, :o5, 59216099, 24 - tz.transition 2043, 10, :o6, 59221139, 24 - tz.transition 2044, 3, :o5, 59224835, 24 - tz.transition 2044, 10, :o6, 59230043, 24 - tz.transition 2045, 3, :o5, 59233571, 24 - tz.transition 2045, 10, :o6, 59238779, 24 - tz.transition 2046, 3, :o5, 59242307, 24 - tz.transition 2046, 10, :o6, 59247515, 24 - tz.transition 2047, 3, :o5, 59251211, 24 - tz.transition 2047, 10, :o6, 59256251, 24 - tz.transition 2048, 3, :o5, 59259947, 24 - tz.transition 2048, 10, :o6, 59264987, 24 - tz.transition 2049, 3, :o5, 59268683, 24 - tz.transition 2049, 10, :o6, 59273891, 24 - tz.transition 2050, 3, :o5, 59277419, 24 - tz.transition 2050, 10, :o6, 59282627, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Paris.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Paris.rb deleted file mode 100644 index e3236c0..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Paris.rb +++ /dev/null @@ -1,232 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Paris - include TimezoneDefinition - - timezone 'Europe/Paris' do |tz| - tz.offset :o0, 561, 0, :LMT - tz.offset :o1, 561, 0, :PMT - tz.offset :o2, 0, 0, :WET - tz.offset :o3, 0, 3600, :WEST - tz.offset :o4, 3600, 3600, :CEST - tz.offset :o5, 3600, 0, :CET - tz.offset :o6, 0, 7200, :WEMT - - tz.transition 1891, 3, :o1, 69460027033, 28800 - tz.transition 1911, 3, :o2, 69670267033, 28800 - tz.transition 1916, 6, :o3, 58104707, 24 - tz.transition 1916, 10, :o2, 58107323, 24 - tz.transition 1917, 3, :o3, 58111499, 24 - tz.transition 1917, 10, :o2, 58116227, 24 - tz.transition 1918, 3, :o3, 58119899, 24 - tz.transition 1918, 10, :o2, 58124963, 24 - tz.transition 1919, 3, :o3, 58128467, 24 - tz.transition 1919, 10, :o2, 58133699, 24 - tz.transition 1920, 2, :o3, 58136867, 24 - tz.transition 1920, 10, :o2, 58142915, 24 - tz.transition 1921, 3, :o3, 58146323, 24 - tz.transition 1921, 10, :o2, 58151723, 24 - tz.transition 1922, 3, :o3, 58155347, 24 - tz.transition 1922, 10, :o2, 58160051, 24 - tz.transition 1923, 5, :o3, 58165595, 24 - tz.transition 1923, 10, :o2, 58168787, 24 - tz.transition 1924, 3, :o3, 58172987, 24 - tz.transition 1924, 10, :o2, 58177523, 24 - tz.transition 1925, 4, :o3, 58181891, 24 - tz.transition 1925, 10, :o2, 58186259, 24 - tz.transition 1926, 4, :o3, 58190963, 24 - tz.transition 1926, 10, :o2, 58194995, 24 - tz.transition 1927, 4, :o3, 58199531, 24 - tz.transition 1927, 10, :o2, 58203731, 24 - tz.transition 1928, 4, :o3, 58208435, 24 - tz.transition 1928, 10, :o2, 58212635, 24 - tz.transition 1929, 4, :o3, 58217339, 24 - tz.transition 1929, 10, :o2, 58221371, 24 - tz.transition 1930, 4, :o3, 58225907, 24 - tz.transition 1930, 10, :o2, 58230107, 24 - tz.transition 1931, 4, :o3, 58234811, 24 - tz.transition 1931, 10, :o2, 58238843, 24 - tz.transition 1932, 4, :o3, 58243211, 24 - tz.transition 1932, 10, :o2, 58247579, 24 - tz.transition 1933, 3, :o3, 58251779, 24 - tz.transition 1933, 10, :o2, 58256483, 24 - tz.transition 1934, 4, :o3, 58260851, 24 - tz.transition 1934, 10, :o2, 58265219, 24 - tz.transition 1935, 3, :o3, 58269419, 24 - tz.transition 1935, 10, :o2, 58273955, 24 - tz.transition 1936, 4, :o3, 58278659, 24 - tz.transition 1936, 10, :o2, 58282691, 24 - tz.transition 1937, 4, :o3, 58287059, 24 - tz.transition 1937, 10, :o2, 58291427, 24 - tz.transition 1938, 3, :o3, 58295627, 24 - tz.transition 1938, 10, :o2, 58300163, 24 - tz.transition 1939, 4, :o3, 58304867, 24 - tz.transition 1939, 11, :o2, 58310075, 24 - tz.transition 1940, 2, :o3, 29156215, 12 - tz.transition 1940, 6, :o4, 29157545, 12 - tz.transition 1942, 11, :o5, 58335973, 24 - tz.transition 1943, 3, :o4, 58339501, 24 - tz.transition 1943, 10, :o5, 58344037, 24 - tz.transition 1944, 4, :o4, 58348405, 24 - tz.transition 1944, 8, :o6, 29175929, 12 - tz.transition 1944, 10, :o3, 58352915, 24 - tz.transition 1945, 4, :o6, 58357141, 24 - tz.transition 1945, 9, :o5, 58361149, 24 - tz.transition 1976, 3, :o4, 196819200 - tz.transition 1976, 9, :o5, 212540400 - tz.transition 1977, 4, :o4, 228877200 - tz.transition 1977, 9, :o5, 243997200 - tz.transition 1978, 4, :o4, 260326800 - tz.transition 1978, 10, :o5, 276051600 - tz.transition 1979, 4, :o4, 291776400 - tz.transition 1979, 9, :o5, 307501200 - tz.transition 1980, 4, :o4, 323830800 - tz.transition 1980, 9, :o5, 338950800 - tz.transition 1981, 3, :o4, 354675600 - tz.transition 1981, 9, :o5, 370400400 - tz.transition 1982, 3, :o4, 386125200 - tz.transition 1982, 9, :o5, 401850000 - tz.transition 1983, 3, :o4, 417574800 - tz.transition 1983, 9, :o5, 433299600 - tz.transition 1984, 3, :o4, 449024400 - tz.transition 1984, 9, :o5, 465354000 - tz.transition 1985, 3, :o4, 481078800 - tz.transition 1985, 9, :o5, 496803600 - tz.transition 1986, 3, :o4, 512528400 - tz.transition 1986, 9, :o5, 528253200 - tz.transition 1987, 3, :o4, 543978000 - tz.transition 1987, 9, :o5, 559702800 - tz.transition 1988, 3, :o4, 575427600 - tz.transition 1988, 9, :o5, 591152400 - tz.transition 1989, 3, :o4, 606877200 - tz.transition 1989, 9, :o5, 622602000 - tz.transition 1990, 3, :o4, 638326800 - tz.transition 1990, 9, :o5, 654656400 - tz.transition 1991, 3, :o4, 670381200 - tz.transition 1991, 9, :o5, 686106000 - tz.transition 1992, 3, :o4, 701830800 - tz.transition 1992, 9, :o5, 717555600 - tz.transition 1993, 3, :o4, 733280400 - tz.transition 1993, 9, :o5, 749005200 - tz.transition 1994, 3, :o4, 764730000 - tz.transition 1994, 9, :o5, 780454800 - tz.transition 1995, 3, :o4, 796179600 - tz.transition 1995, 9, :o5, 811904400 - tz.transition 1996, 3, :o4, 828234000 - tz.transition 1996, 10, :o5, 846378000 - tz.transition 1997, 3, :o4, 859683600 - tz.transition 1997, 10, :o5, 877827600 - tz.transition 1998, 3, :o4, 891133200 - tz.transition 1998, 10, :o5, 909277200 - tz.transition 1999, 3, :o4, 922582800 - tz.transition 1999, 10, :o5, 941331600 - tz.transition 2000, 3, :o4, 954032400 - tz.transition 2000, 10, :o5, 972781200 - tz.transition 2001, 3, :o4, 985482000 - tz.transition 2001, 10, :o5, 1004230800 - tz.transition 2002, 3, :o4, 1017536400 - tz.transition 2002, 10, :o5, 1035680400 - tz.transition 2003, 3, :o4, 1048986000 - tz.transition 2003, 10, :o5, 1067130000 - tz.transition 2004, 3, :o4, 1080435600 - tz.transition 2004, 10, :o5, 1099184400 - tz.transition 2005, 3, :o4, 1111885200 - tz.transition 2005, 10, :o5, 1130634000 - tz.transition 2006, 3, :o4, 1143334800 - tz.transition 2006, 10, :o5, 1162083600 - tz.transition 2007, 3, :o4, 1174784400 - tz.transition 2007, 10, :o5, 1193533200 - tz.transition 2008, 3, :o4, 1206838800 - tz.transition 2008, 10, :o5, 1224982800 - tz.transition 2009, 3, :o4, 1238288400 - tz.transition 2009, 10, :o5, 1256432400 - tz.transition 2010, 3, :o4, 1269738000 - tz.transition 2010, 10, :o5, 1288486800 - tz.transition 2011, 3, :o4, 1301187600 - tz.transition 2011, 10, :o5, 1319936400 - tz.transition 2012, 3, :o4, 1332637200 - tz.transition 2012, 10, :o5, 1351386000 - tz.transition 2013, 3, :o4, 1364691600 - tz.transition 2013, 10, :o5, 1382835600 - tz.transition 2014, 3, :o4, 1396141200 - tz.transition 2014, 10, :o5, 1414285200 - tz.transition 2015, 3, :o4, 1427590800 - tz.transition 2015, 10, :o5, 1445734800 - tz.transition 2016, 3, :o4, 1459040400 - tz.transition 2016, 10, :o5, 1477789200 - tz.transition 2017, 3, :o4, 1490490000 - tz.transition 2017, 10, :o5, 1509238800 - tz.transition 2018, 3, :o4, 1521939600 - tz.transition 2018, 10, :o5, 1540688400 - tz.transition 2019, 3, :o4, 1553994000 - tz.transition 2019, 10, :o5, 1572138000 - tz.transition 2020, 3, :o4, 1585443600 - tz.transition 2020, 10, :o5, 1603587600 - tz.transition 2021, 3, :o4, 1616893200 - tz.transition 2021, 10, :o5, 1635642000 - tz.transition 2022, 3, :o4, 1648342800 - tz.transition 2022, 10, :o5, 1667091600 - tz.transition 2023, 3, :o4, 1679792400 - tz.transition 2023, 10, :o5, 1698541200 - tz.transition 2024, 3, :o4, 1711846800 - tz.transition 2024, 10, :o5, 1729990800 - tz.transition 2025, 3, :o4, 1743296400 - tz.transition 2025, 10, :o5, 1761440400 - tz.transition 2026, 3, :o4, 1774746000 - tz.transition 2026, 10, :o5, 1792890000 - tz.transition 2027, 3, :o4, 1806195600 - tz.transition 2027, 10, :o5, 1824944400 - tz.transition 2028, 3, :o4, 1837645200 - tz.transition 2028, 10, :o5, 1856394000 - tz.transition 2029, 3, :o4, 1869094800 - tz.transition 2029, 10, :o5, 1887843600 - tz.transition 2030, 3, :o4, 1901149200 - tz.transition 2030, 10, :o5, 1919293200 - tz.transition 2031, 3, :o4, 1932598800 - tz.transition 2031, 10, :o5, 1950742800 - tz.transition 2032, 3, :o4, 1964048400 - tz.transition 2032, 10, :o5, 1982797200 - tz.transition 2033, 3, :o4, 1995498000 - tz.transition 2033, 10, :o5, 2014246800 - tz.transition 2034, 3, :o4, 2026947600 - tz.transition 2034, 10, :o5, 2045696400 - tz.transition 2035, 3, :o4, 2058397200 - tz.transition 2035, 10, :o5, 2077146000 - tz.transition 2036, 3, :o4, 2090451600 - tz.transition 2036, 10, :o5, 2108595600 - tz.transition 2037, 3, :o4, 2121901200 - tz.transition 2037, 10, :o5, 2140045200 - tz.transition 2038, 3, :o4, 59172253, 24 - tz.transition 2038, 10, :o5, 59177461, 24 - tz.transition 2039, 3, :o4, 59180989, 24 - tz.transition 2039, 10, :o5, 59186197, 24 - tz.transition 2040, 3, :o4, 59189725, 24 - tz.transition 2040, 10, :o5, 59194933, 24 - tz.transition 2041, 3, :o4, 59198629, 24 - tz.transition 2041, 10, :o5, 59203669, 24 - tz.transition 2042, 3, :o4, 59207365, 24 - tz.transition 2042, 10, :o5, 59212405, 24 - tz.transition 2043, 3, :o4, 59216101, 24 - tz.transition 2043, 10, :o5, 59221141, 24 - tz.transition 2044, 3, :o4, 59224837, 24 - tz.transition 2044, 10, :o5, 59230045, 24 - tz.transition 2045, 3, :o4, 59233573, 24 - tz.transition 2045, 10, :o5, 59238781, 24 - tz.transition 2046, 3, :o4, 59242309, 24 - tz.transition 2046, 10, :o5, 59247517, 24 - tz.transition 2047, 3, :o4, 59251213, 24 - tz.transition 2047, 10, :o5, 59256253, 24 - tz.transition 2048, 3, :o4, 59259949, 24 - tz.transition 2048, 10, :o5, 59264989, 24 - tz.transition 2049, 3, :o4, 59268685, 24 - tz.transition 2049, 10, :o5, 59273893, 24 - tz.transition 2050, 3, :o4, 59277421, 24 - tz.transition 2050, 10, :o5, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Prague.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Prague.rb deleted file mode 100644 index bcabee9..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Prague.rb +++ /dev/null @@ -1,187 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Prague - include TimezoneDefinition - - timezone 'Europe/Prague' do |tz| - tz.offset :o0, 3464, 0, :LMT - tz.offset :o1, 3464, 0, :PMT - tz.offset :o2, 3600, 0, :CET - tz.offset :o3, 3600, 3600, :CEST - - tz.transition 1849, 12, :o1, 25884991367, 10800 - tz.transition 1891, 9, :o2, 26049669767, 10800 - tz.transition 1916, 4, :o3, 29051813, 12 - tz.transition 1916, 9, :o2, 58107299, 24 - tz.transition 1917, 4, :o3, 58112029, 24 - tz.transition 1917, 9, :o2, 58115725, 24 - tz.transition 1918, 4, :o3, 58120765, 24 - tz.transition 1918, 9, :o2, 58124461, 24 - tz.transition 1940, 4, :o3, 58313293, 24 - tz.transition 1942, 11, :o2, 58335973, 24 - tz.transition 1943, 3, :o3, 58339501, 24 - tz.transition 1943, 10, :o2, 58344037, 24 - tz.transition 1944, 4, :o3, 58348405, 24 - tz.transition 1944, 9, :o2, 58352413, 24 - tz.transition 1945, 4, :o3, 58357285, 24 - tz.transition 1945, 11, :o2, 58362661, 24 - tz.transition 1946, 5, :o3, 58366717, 24 - tz.transition 1946, 10, :o2, 58370389, 24 - tz.transition 1947, 4, :o3, 58375093, 24 - tz.transition 1947, 10, :o2, 58379125, 24 - tz.transition 1948, 4, :o3, 58383829, 24 - tz.transition 1948, 10, :o2, 58387861, 24 - tz.transition 1949, 4, :o3, 58392373, 24 - tz.transition 1949, 10, :o2, 58396597, 24 - tz.transition 1979, 4, :o3, 291776400 - tz.transition 1979, 9, :o2, 307501200 - tz.transition 1980, 4, :o3, 323830800 - tz.transition 1980, 9, :o2, 338950800 - tz.transition 1981, 3, :o3, 354675600 - tz.transition 1981, 9, :o2, 370400400 - tz.transition 1982, 3, :o3, 386125200 - tz.transition 1982, 9, :o2, 401850000 - tz.transition 1983, 3, :o3, 417574800 - tz.transition 1983, 9, :o2, 433299600 - tz.transition 1984, 3, :o3, 449024400 - tz.transition 1984, 9, :o2, 465354000 - tz.transition 1985, 3, :o3, 481078800 - tz.transition 1985, 9, :o2, 496803600 - tz.transition 1986, 3, :o3, 512528400 - tz.transition 1986, 9, :o2, 528253200 - tz.transition 1987, 3, :o3, 543978000 - tz.transition 1987, 9, :o2, 559702800 - tz.transition 1988, 3, :o3, 575427600 - tz.transition 1988, 9, :o2, 591152400 - tz.transition 1989, 3, :o3, 606877200 - tz.transition 1989, 9, :o2, 622602000 - tz.transition 1990, 3, :o3, 638326800 - tz.transition 1990, 9, :o2, 654656400 - tz.transition 1991, 3, :o3, 670381200 - tz.transition 1991, 9, :o2, 686106000 - tz.transition 1992, 3, :o3, 701830800 - tz.transition 1992, 9, :o2, 717555600 - tz.transition 1993, 3, :o3, 733280400 - tz.transition 1993, 9, :o2, 749005200 - tz.transition 1994, 3, :o3, 764730000 - tz.transition 1994, 9, :o2, 780454800 - tz.transition 1995, 3, :o3, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o3, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Riga.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Riga.rb deleted file mode 100644 index 784837f..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Riga.rb +++ /dev/null @@ -1,176 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Riga - include TimezoneDefinition - - timezone 'Europe/Riga' do |tz| - tz.offset :o0, 5784, 0, :LMT - tz.offset :o1, 5784, 0, :RMT - tz.offset :o2, 5784, 3600, :LST - tz.offset :o3, 7200, 0, :EET - tz.offset :o4, 10800, 0, :MSK - tz.offset :o5, 3600, 3600, :CEST - tz.offset :o6, 3600, 0, :CET - tz.offset :o7, 10800, 3600, :MSD - tz.offset :o8, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 8667775559, 3600 - tz.transition 1918, 4, :o2, 8718114659, 3600 - tz.transition 1918, 9, :o1, 8718669059, 3600 - tz.transition 1919, 4, :o2, 8719378259, 3600 - tz.transition 1919, 5, :o1, 8719561859, 3600 - tz.transition 1926, 5, :o3, 8728727159, 3600 - tz.transition 1940, 8, :o4, 29158157, 12 - tz.transition 1941, 6, :o5, 19441411, 8 - tz.transition 1942, 11, :o6, 58335973, 24 - tz.transition 1943, 3, :o5, 58339501, 24 - tz.transition 1943, 10, :o6, 58344037, 24 - tz.transition 1944, 4, :o5, 58348405, 24 - tz.transition 1944, 10, :o6, 58352773, 24 - tz.transition 1944, 10, :o4, 58353035, 24 - tz.transition 1981, 3, :o7, 354920400 - tz.transition 1981, 9, :o4, 370728000 - tz.transition 1982, 3, :o7, 386456400 - tz.transition 1982, 9, :o4, 402264000 - tz.transition 1983, 3, :o7, 417992400 - tz.transition 1983, 9, :o4, 433800000 - tz.transition 1984, 3, :o7, 449614800 - tz.transition 1984, 9, :o4, 465346800 - tz.transition 1985, 3, :o7, 481071600 - tz.transition 1985, 9, :o4, 496796400 - tz.transition 1986, 3, :o7, 512521200 - tz.transition 1986, 9, :o4, 528246000 - tz.transition 1987, 3, :o7, 543970800 - tz.transition 1987, 9, :o4, 559695600 - tz.transition 1988, 3, :o7, 575420400 - tz.transition 1988, 9, :o4, 591145200 - tz.transition 1989, 3, :o8, 606870000 - tz.transition 1989, 9, :o3, 622598400 - tz.transition 1990, 3, :o8, 638323200 - tz.transition 1990, 9, :o3, 654652800 - tz.transition 1991, 3, :o8, 670377600 - tz.transition 1991, 9, :o3, 686102400 - tz.transition 1992, 3, :o8, 701827200 - tz.transition 1992, 9, :o3, 717552000 - tz.transition 1993, 3, :o8, 733276800 - tz.transition 1993, 9, :o3, 749001600 - tz.transition 1994, 3, :o8, 764726400 - tz.transition 1994, 9, :o3, 780451200 - tz.transition 1995, 3, :o8, 796176000 - tz.transition 1995, 9, :o3, 811900800 - tz.transition 1996, 3, :o8, 828230400 - tz.transition 1996, 9, :o3, 843955200 - tz.transition 1997, 3, :o8, 859683600 - tz.transition 1997, 10, :o3, 877827600 - tz.transition 1998, 3, :o8, 891133200 - tz.transition 1998, 10, :o3, 909277200 - tz.transition 1999, 3, :o8, 922582800 - tz.transition 1999, 10, :o3, 941331600 - tz.transition 2001, 3, :o8, 985482000 - tz.transition 2001, 10, :o3, 1004230800 - tz.transition 2002, 3, :o8, 1017536400 - tz.transition 2002, 10, :o3, 1035680400 - tz.transition 2003, 3, :o8, 1048986000 - tz.transition 2003, 10, :o3, 1067130000 - tz.transition 2004, 3, :o8, 1080435600 - tz.transition 2004, 10, :o3, 1099184400 - tz.transition 2005, 3, :o8, 1111885200 - tz.transition 2005, 10, :o3, 1130634000 - tz.transition 2006, 3, :o8, 1143334800 - tz.transition 2006, 10, :o3, 1162083600 - tz.transition 2007, 3, :o8, 1174784400 - tz.transition 2007, 10, :o3, 1193533200 - tz.transition 2008, 3, :o8, 1206838800 - tz.transition 2008, 10, :o3, 1224982800 - tz.transition 2009, 3, :o8, 1238288400 - tz.transition 2009, 10, :o3, 1256432400 - tz.transition 2010, 3, :o8, 1269738000 - tz.transition 2010, 10, :o3, 1288486800 - tz.transition 2011, 3, :o8, 1301187600 - tz.transition 2011, 10, :o3, 1319936400 - tz.transition 2012, 3, :o8, 1332637200 - tz.transition 2012, 10, :o3, 1351386000 - tz.transition 2013, 3, :o8, 1364691600 - tz.transition 2013, 10, :o3, 1382835600 - tz.transition 2014, 3, :o8, 1396141200 - tz.transition 2014, 10, :o3, 1414285200 - tz.transition 2015, 3, :o8, 1427590800 - tz.transition 2015, 10, :o3, 1445734800 - tz.transition 2016, 3, :o8, 1459040400 - tz.transition 2016, 10, :o3, 1477789200 - tz.transition 2017, 3, :o8, 1490490000 - tz.transition 2017, 10, :o3, 1509238800 - tz.transition 2018, 3, :o8, 1521939600 - tz.transition 2018, 10, :o3, 1540688400 - tz.transition 2019, 3, :o8, 1553994000 - tz.transition 2019, 10, :o3, 1572138000 - tz.transition 2020, 3, :o8, 1585443600 - tz.transition 2020, 10, :o3, 1603587600 - tz.transition 2021, 3, :o8, 1616893200 - tz.transition 2021, 10, :o3, 1635642000 - tz.transition 2022, 3, :o8, 1648342800 - tz.transition 2022, 10, :o3, 1667091600 - tz.transition 2023, 3, :o8, 1679792400 - tz.transition 2023, 10, :o3, 1698541200 - tz.transition 2024, 3, :o8, 1711846800 - tz.transition 2024, 10, :o3, 1729990800 - tz.transition 2025, 3, :o8, 1743296400 - tz.transition 2025, 10, :o3, 1761440400 - tz.transition 2026, 3, :o8, 1774746000 - tz.transition 2026, 10, :o3, 1792890000 - tz.transition 2027, 3, :o8, 1806195600 - tz.transition 2027, 10, :o3, 1824944400 - tz.transition 2028, 3, :o8, 1837645200 - tz.transition 2028, 10, :o3, 1856394000 - tz.transition 2029, 3, :o8, 1869094800 - tz.transition 2029, 10, :o3, 1887843600 - tz.transition 2030, 3, :o8, 1901149200 - tz.transition 2030, 10, :o3, 1919293200 - tz.transition 2031, 3, :o8, 1932598800 - tz.transition 2031, 10, :o3, 1950742800 - tz.transition 2032, 3, :o8, 1964048400 - tz.transition 2032, 10, :o3, 1982797200 - tz.transition 2033, 3, :o8, 1995498000 - tz.transition 2033, 10, :o3, 2014246800 - tz.transition 2034, 3, :o8, 2026947600 - tz.transition 2034, 10, :o3, 2045696400 - tz.transition 2035, 3, :o8, 2058397200 - tz.transition 2035, 10, :o3, 2077146000 - tz.transition 2036, 3, :o8, 2090451600 - tz.transition 2036, 10, :o3, 2108595600 - tz.transition 2037, 3, :o8, 2121901200 - tz.transition 2037, 10, :o3, 2140045200 - tz.transition 2038, 3, :o8, 59172253, 24 - tz.transition 2038, 10, :o3, 59177461, 24 - tz.transition 2039, 3, :o8, 59180989, 24 - tz.transition 2039, 10, :o3, 59186197, 24 - tz.transition 2040, 3, :o8, 59189725, 24 - tz.transition 2040, 10, :o3, 59194933, 24 - tz.transition 2041, 3, :o8, 59198629, 24 - tz.transition 2041, 10, :o3, 59203669, 24 - tz.transition 2042, 3, :o8, 59207365, 24 - tz.transition 2042, 10, :o3, 59212405, 24 - tz.transition 2043, 3, :o8, 59216101, 24 - tz.transition 2043, 10, :o3, 59221141, 24 - tz.transition 2044, 3, :o8, 59224837, 24 - tz.transition 2044, 10, :o3, 59230045, 24 - tz.transition 2045, 3, :o8, 59233573, 24 - tz.transition 2045, 10, :o3, 59238781, 24 - tz.transition 2046, 3, :o8, 59242309, 24 - tz.transition 2046, 10, :o3, 59247517, 24 - tz.transition 2047, 3, :o8, 59251213, 24 - tz.transition 2047, 10, :o3, 59256253, 24 - tz.transition 2048, 3, :o8, 59259949, 24 - tz.transition 2048, 10, :o3, 59264989, 24 - tz.transition 2049, 3, :o8, 59268685, 24 - tz.transition 2049, 10, :o3, 59273893, 24 - tz.transition 2050, 3, :o8, 59277421, 24 - tz.transition 2050, 10, :o3, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Rome.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Rome.rb deleted file mode 100644 index aa7b43d..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Rome.rb +++ /dev/null @@ -1,215 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Rome - include TimezoneDefinition - - timezone 'Europe/Rome' do |tz| - tz.offset :o0, 2996, 0, :LMT - tz.offset :o1, 2996, 0, :RMT - tz.offset :o2, 3600, 0, :CET - tz.offset :o3, 3600, 3600, :CEST - - tz.transition 1866, 9, :o1, 51901915651, 21600 - tz.transition 1893, 10, :o2, 52115798851, 21600 - tz.transition 1916, 6, :o3, 58104419, 24 - tz.transition 1916, 9, :o2, 58107299, 24 - tz.transition 1917, 3, :o3, 58111667, 24 - tz.transition 1917, 9, :o2, 58116035, 24 - tz.transition 1918, 3, :o3, 58119899, 24 - tz.transition 1918, 10, :o2, 58124939, 24 - tz.transition 1919, 3, :o3, 58128467, 24 - tz.transition 1919, 10, :o2, 58133675, 24 - tz.transition 1920, 3, :o3, 58137707, 24 - tz.transition 1920, 9, :o2, 58142075, 24 - tz.transition 1940, 6, :o3, 58315091, 24 - tz.transition 1942, 11, :o2, 58335973, 24 - tz.transition 1943, 3, :o3, 58339501, 24 - tz.transition 1943, 10, :o2, 58344037, 24 - tz.transition 1944, 4, :o3, 58348405, 24 - tz.transition 1944, 9, :o2, 58352411, 24 - tz.transition 1945, 4, :o3, 58357141, 24 - tz.transition 1945, 9, :o2, 58361123, 24 - tz.transition 1946, 3, :o3, 58365517, 24 - tz.transition 1946, 10, :o2, 58370389, 24 - tz.transition 1947, 3, :o3, 58374251, 24 - tz.transition 1947, 10, :o2, 58379123, 24 - tz.transition 1948, 2, :o3, 58382653, 24 - tz.transition 1948, 10, :o2, 58387861, 24 - tz.transition 1966, 5, :o3, 58542419, 24 - tz.transition 1966, 9, :o2, 29272721, 12 - tz.transition 1967, 5, :o3, 58551323, 24 - tz.transition 1967, 9, :o2, 29277089, 12 - tz.transition 1968, 5, :o3, 58560059, 24 - tz.transition 1968, 9, :o2, 29281457, 12 - tz.transition 1969, 5, :o3, 58568963, 24 - tz.transition 1969, 9, :o2, 29285909, 12 - tz.transition 1970, 5, :o3, 12956400 - tz.transition 1970, 9, :o2, 23234400 - tz.transition 1971, 5, :o3, 43801200 - tz.transition 1971, 9, :o2, 54687600 - tz.transition 1972, 5, :o3, 75855600 - tz.transition 1972, 9, :o2, 86738400 - tz.transition 1973, 6, :o3, 107910000 - tz.transition 1973, 9, :o2, 118188000 - tz.transition 1974, 5, :o3, 138754800 - tz.transition 1974, 9, :o2, 149637600 - tz.transition 1975, 5, :o3, 170809200 - tz.transition 1975, 9, :o2, 181090800 - tz.transition 1976, 5, :o3, 202258800 - tz.transition 1976, 9, :o2, 212540400 - tz.transition 1977, 5, :o3, 233103600 - tz.transition 1977, 9, :o2, 243990000 - tz.transition 1978, 5, :o3, 265158000 - tz.transition 1978, 9, :o2, 276044400 - tz.transition 1979, 5, :o3, 296607600 - tz.transition 1979, 9, :o2, 307494000 - tz.transition 1980, 4, :o3, 323830800 - tz.transition 1980, 9, :o2, 338950800 - tz.transition 1981, 3, :o3, 354675600 - tz.transition 1981, 9, :o2, 370400400 - tz.transition 1982, 3, :o3, 386125200 - tz.transition 1982, 9, :o2, 401850000 - tz.transition 1983, 3, :o3, 417574800 - tz.transition 1983, 9, :o2, 433299600 - tz.transition 1984, 3, :o3, 449024400 - tz.transition 1984, 9, :o2, 465354000 - tz.transition 1985, 3, :o3, 481078800 - tz.transition 1985, 9, :o2, 496803600 - tz.transition 1986, 3, :o3, 512528400 - tz.transition 1986, 9, :o2, 528253200 - tz.transition 1987, 3, :o3, 543978000 - tz.transition 1987, 9, :o2, 559702800 - tz.transition 1988, 3, :o3, 575427600 - tz.transition 1988, 9, :o2, 591152400 - tz.transition 1989, 3, :o3, 606877200 - tz.transition 1989, 9, :o2, 622602000 - tz.transition 1990, 3, :o3, 638326800 - tz.transition 1990, 9, :o2, 654656400 - tz.transition 1991, 3, :o3, 670381200 - tz.transition 1991, 9, :o2, 686106000 - tz.transition 1992, 3, :o3, 701830800 - tz.transition 1992, 9, :o2, 717555600 - tz.transition 1993, 3, :o3, 733280400 - tz.transition 1993, 9, :o2, 749005200 - tz.transition 1994, 3, :o3, 764730000 - tz.transition 1994, 9, :o2, 780454800 - tz.transition 1995, 3, :o3, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o3, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sarajevo.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sarajevo.rb deleted file mode 100644 index 068c5fe..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sarajevo.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Sarajevo - include TimezoneDefinition - - linked_timezone 'Europe/Sarajevo', 'Europe/Belgrade' - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Skopje.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Skopje.rb deleted file mode 100644 index 10b71f2..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Skopje.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Skopje - include TimezoneDefinition - - linked_timezone 'Europe/Skopje', 'Europe/Belgrade' - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sofia.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sofia.rb deleted file mode 100644 index 38a70ec..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sofia.rb +++ /dev/null @@ -1,173 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Sofia - include TimezoneDefinition - - timezone 'Europe/Sofia' do |tz| - tz.offset :o0, 5596, 0, :LMT - tz.offset :o1, 7016, 0, :IMT - tz.offset :o2, 7200, 0, :EET - tz.offset :o3, 3600, 0, :CET - tz.offset :o4, 3600, 3600, :CEST - tz.offset :o5, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 52006653401, 21600 - tz.transition 1894, 11, :o2, 26062154123, 10800 - tz.transition 1942, 11, :o3, 58335973, 24 - tz.transition 1943, 3, :o4, 58339501, 24 - tz.transition 1943, 10, :o3, 58344037, 24 - tz.transition 1944, 4, :o4, 58348405, 24 - tz.transition 1944, 10, :o3, 58352773, 24 - tz.transition 1945, 4, :o2, 29178571, 12 - tz.transition 1979, 3, :o5, 291762000 - tz.transition 1979, 9, :o2, 307576800 - tz.transition 1980, 4, :o5, 323816400 - tz.transition 1980, 9, :o2, 339026400 - tz.transition 1981, 4, :o5, 355266000 - tz.transition 1981, 9, :o2, 370393200 - tz.transition 1982, 4, :o5, 386715600 - tz.transition 1982, 9, :o2, 401846400 - tz.transition 1983, 3, :o5, 417571200 - tz.transition 1983, 9, :o2, 433296000 - tz.transition 1984, 3, :o5, 449020800 - tz.transition 1984, 9, :o2, 465350400 - tz.transition 1985, 3, :o5, 481075200 - tz.transition 1985, 9, :o2, 496800000 - tz.transition 1986, 3, :o5, 512524800 - tz.transition 1986, 9, :o2, 528249600 - tz.transition 1987, 3, :o5, 543974400 - tz.transition 1987, 9, :o2, 559699200 - tz.transition 1988, 3, :o5, 575424000 - tz.transition 1988, 9, :o2, 591148800 - tz.transition 1989, 3, :o5, 606873600 - tz.transition 1989, 9, :o2, 622598400 - tz.transition 1990, 3, :o5, 638323200 - tz.transition 1990, 9, :o2, 654652800 - tz.transition 1991, 3, :o5, 670370400 - tz.transition 1991, 9, :o2, 686091600 - tz.transition 1992, 3, :o5, 701820000 - tz.transition 1992, 9, :o2, 717541200 - tz.transition 1993, 3, :o5, 733269600 - tz.transition 1993, 9, :o2, 748990800 - tz.transition 1994, 3, :o5, 764719200 - tz.transition 1994, 9, :o2, 780440400 - tz.transition 1995, 3, :o5, 796168800 - tz.transition 1995, 9, :o2, 811890000 - tz.transition 1996, 3, :o5, 828223200 - tz.transition 1996, 10, :o2, 846363600 - tz.transition 1997, 3, :o5, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o5, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o5, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o5, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o5, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o5, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o5, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o5, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o5, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o5, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o5, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o5, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o5, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o5, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o5, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o5, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o5, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o5, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o5, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o5, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o5, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o5, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o5, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o5, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o5, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o5, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o5, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o5, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o5, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o5, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o5, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o5, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o5, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o5, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o5, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o5, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o5, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o5, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o5, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o5, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o5, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o5, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o5, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o5, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o5, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o5, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o5, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o5, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o5, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o5, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o5, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o5, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o5, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o5, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Stockholm.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Stockholm.rb deleted file mode 100644 index 43db70f..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Stockholm.rb +++ /dev/null @@ -1,165 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Stockholm - include TimezoneDefinition - - timezone 'Europe/Stockholm' do |tz| - tz.offset :o0, 4332, 0, :LMT - tz.offset :o1, 3614, 0, :SET - tz.offset :o2, 3600, 0, :CET - tz.offset :o3, 3600, 3600, :CEST - - tz.transition 1878, 12, :o1, 17332923239, 7200 - tz.transition 1899, 12, :o2, 104328883793, 43200 - tz.transition 1916, 5, :o3, 29051981, 12 - tz.transition 1916, 9, :o2, 58107299, 24 - tz.transition 1980, 4, :o3, 323830800 - tz.transition 1980, 9, :o2, 338950800 - tz.transition 1981, 3, :o3, 354675600 - tz.transition 1981, 9, :o2, 370400400 - tz.transition 1982, 3, :o3, 386125200 - tz.transition 1982, 9, :o2, 401850000 - tz.transition 1983, 3, :o3, 417574800 - tz.transition 1983, 9, :o2, 433299600 - tz.transition 1984, 3, :o3, 449024400 - tz.transition 1984, 9, :o2, 465354000 - tz.transition 1985, 3, :o3, 481078800 - tz.transition 1985, 9, :o2, 496803600 - tz.transition 1986, 3, :o3, 512528400 - tz.transition 1986, 9, :o2, 528253200 - tz.transition 1987, 3, :o3, 543978000 - tz.transition 1987, 9, :o2, 559702800 - tz.transition 1988, 3, :o3, 575427600 - tz.transition 1988, 9, :o2, 591152400 - tz.transition 1989, 3, :o3, 606877200 - tz.transition 1989, 9, :o2, 622602000 - tz.transition 1990, 3, :o3, 638326800 - tz.transition 1990, 9, :o2, 654656400 - tz.transition 1991, 3, :o3, 670381200 - tz.transition 1991, 9, :o2, 686106000 - tz.transition 1992, 3, :o3, 701830800 - tz.transition 1992, 9, :o2, 717555600 - tz.transition 1993, 3, :o3, 733280400 - tz.transition 1993, 9, :o2, 749005200 - tz.transition 1994, 3, :o3, 764730000 - tz.transition 1994, 9, :o2, 780454800 - tz.transition 1995, 3, :o3, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o3, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Tallinn.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Tallinn.rb deleted file mode 100644 index de5a856..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Tallinn.rb +++ /dev/null @@ -1,172 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Tallinn - include TimezoneDefinition - - timezone 'Europe/Tallinn' do |tz| - tz.offset :o0, 5940, 0, :LMT - tz.offset :o1, 5940, 0, :TMT - tz.offset :o2, 3600, 0, :CET - tz.offset :o3, 3600, 3600, :CEST - tz.offset :o4, 7200, 0, :EET - tz.offset :o5, 10800, 0, :MSK - tz.offset :o6, 10800, 3600, :MSD - tz.offset :o7, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 385234469, 160 - tz.transition 1918, 1, :o2, 387460069, 160 - tz.transition 1918, 4, :o3, 58120765, 24 - tz.transition 1918, 9, :o2, 58124461, 24 - tz.transition 1919, 6, :o1, 58131371, 24 - tz.transition 1921, 4, :o4, 387649669, 160 - tz.transition 1940, 8, :o5, 29158169, 12 - tz.transition 1941, 9, :o3, 19442019, 8 - tz.transition 1942, 11, :o2, 58335973, 24 - tz.transition 1943, 3, :o3, 58339501, 24 - tz.transition 1943, 10, :o2, 58344037, 24 - tz.transition 1944, 4, :o3, 58348405, 24 - tz.transition 1944, 9, :o5, 29176265, 12 - tz.transition 1981, 3, :o6, 354920400 - tz.transition 1981, 9, :o5, 370728000 - tz.transition 1982, 3, :o6, 386456400 - tz.transition 1982, 9, :o5, 402264000 - tz.transition 1983, 3, :o6, 417992400 - tz.transition 1983, 9, :o5, 433800000 - tz.transition 1984, 3, :o6, 449614800 - tz.transition 1984, 9, :o5, 465346800 - tz.transition 1985, 3, :o6, 481071600 - tz.transition 1985, 9, :o5, 496796400 - tz.transition 1986, 3, :o6, 512521200 - tz.transition 1986, 9, :o5, 528246000 - tz.transition 1987, 3, :o6, 543970800 - tz.transition 1987, 9, :o5, 559695600 - tz.transition 1988, 3, :o6, 575420400 - tz.transition 1988, 9, :o5, 591145200 - tz.transition 1989, 3, :o7, 606870000 - tz.transition 1989, 9, :o4, 622598400 - tz.transition 1990, 3, :o7, 638323200 - tz.transition 1990, 9, :o4, 654652800 - tz.transition 1991, 3, :o7, 670377600 - tz.transition 1991, 9, :o4, 686102400 - tz.transition 1992, 3, :o7, 701827200 - tz.transition 1992, 9, :o4, 717552000 - tz.transition 1993, 3, :o7, 733276800 - tz.transition 1993, 9, :o4, 749001600 - tz.transition 1994, 3, :o7, 764726400 - tz.transition 1994, 9, :o4, 780451200 - tz.transition 1995, 3, :o7, 796176000 - tz.transition 1995, 9, :o4, 811900800 - tz.transition 1996, 3, :o7, 828230400 - tz.transition 1996, 10, :o4, 846374400 - tz.transition 1997, 3, :o7, 859680000 - tz.transition 1997, 10, :o4, 877824000 - tz.transition 1998, 3, :o7, 891129600 - tz.transition 1998, 10, :o4, 909277200 - tz.transition 1999, 3, :o7, 922582800 - tz.transition 1999, 10, :o4, 941331600 - tz.transition 2002, 3, :o7, 1017536400 - tz.transition 2002, 10, :o4, 1035680400 - tz.transition 2003, 3, :o7, 1048986000 - tz.transition 2003, 10, :o4, 1067130000 - tz.transition 2004, 3, :o7, 1080435600 - tz.transition 2004, 10, :o4, 1099184400 - tz.transition 2005, 3, :o7, 1111885200 - tz.transition 2005, 10, :o4, 1130634000 - tz.transition 2006, 3, :o7, 1143334800 - tz.transition 2006, 10, :o4, 1162083600 - tz.transition 2007, 3, :o7, 1174784400 - tz.transition 2007, 10, :o4, 1193533200 - tz.transition 2008, 3, :o7, 1206838800 - tz.transition 2008, 10, :o4, 1224982800 - tz.transition 2009, 3, :o7, 1238288400 - tz.transition 2009, 10, :o4, 1256432400 - tz.transition 2010, 3, :o7, 1269738000 - tz.transition 2010, 10, :o4, 1288486800 - tz.transition 2011, 3, :o7, 1301187600 - tz.transition 2011, 10, :o4, 1319936400 - tz.transition 2012, 3, :o7, 1332637200 - tz.transition 2012, 10, :o4, 1351386000 - tz.transition 2013, 3, :o7, 1364691600 - tz.transition 2013, 10, :o4, 1382835600 - tz.transition 2014, 3, :o7, 1396141200 - tz.transition 2014, 10, :o4, 1414285200 - tz.transition 2015, 3, :o7, 1427590800 - tz.transition 2015, 10, :o4, 1445734800 - tz.transition 2016, 3, :o7, 1459040400 - tz.transition 2016, 10, :o4, 1477789200 - tz.transition 2017, 3, :o7, 1490490000 - tz.transition 2017, 10, :o4, 1509238800 - tz.transition 2018, 3, :o7, 1521939600 - tz.transition 2018, 10, :o4, 1540688400 - tz.transition 2019, 3, :o7, 1553994000 - tz.transition 2019, 10, :o4, 1572138000 - tz.transition 2020, 3, :o7, 1585443600 - tz.transition 2020, 10, :o4, 1603587600 - tz.transition 2021, 3, :o7, 1616893200 - tz.transition 2021, 10, :o4, 1635642000 - tz.transition 2022, 3, :o7, 1648342800 - tz.transition 2022, 10, :o4, 1667091600 - tz.transition 2023, 3, :o7, 1679792400 - tz.transition 2023, 10, :o4, 1698541200 - tz.transition 2024, 3, :o7, 1711846800 - tz.transition 2024, 10, :o4, 1729990800 - tz.transition 2025, 3, :o7, 1743296400 - tz.transition 2025, 10, :o4, 1761440400 - tz.transition 2026, 3, :o7, 1774746000 - tz.transition 2026, 10, :o4, 1792890000 - tz.transition 2027, 3, :o7, 1806195600 - tz.transition 2027, 10, :o4, 1824944400 - tz.transition 2028, 3, :o7, 1837645200 - tz.transition 2028, 10, :o4, 1856394000 - tz.transition 2029, 3, :o7, 1869094800 - tz.transition 2029, 10, :o4, 1887843600 - tz.transition 2030, 3, :o7, 1901149200 - tz.transition 2030, 10, :o4, 1919293200 - tz.transition 2031, 3, :o7, 1932598800 - tz.transition 2031, 10, :o4, 1950742800 - tz.transition 2032, 3, :o7, 1964048400 - tz.transition 2032, 10, :o4, 1982797200 - tz.transition 2033, 3, :o7, 1995498000 - tz.transition 2033, 10, :o4, 2014246800 - tz.transition 2034, 3, :o7, 2026947600 - tz.transition 2034, 10, :o4, 2045696400 - tz.transition 2035, 3, :o7, 2058397200 - tz.transition 2035, 10, :o4, 2077146000 - tz.transition 2036, 3, :o7, 2090451600 - tz.transition 2036, 10, :o4, 2108595600 - tz.transition 2037, 3, :o7, 2121901200 - tz.transition 2037, 10, :o4, 2140045200 - tz.transition 2038, 3, :o7, 59172253, 24 - tz.transition 2038, 10, :o4, 59177461, 24 - tz.transition 2039, 3, :o7, 59180989, 24 - tz.transition 2039, 10, :o4, 59186197, 24 - tz.transition 2040, 3, :o7, 59189725, 24 - tz.transition 2040, 10, :o4, 59194933, 24 - tz.transition 2041, 3, :o7, 59198629, 24 - tz.transition 2041, 10, :o4, 59203669, 24 - tz.transition 2042, 3, :o7, 59207365, 24 - tz.transition 2042, 10, :o4, 59212405, 24 - tz.transition 2043, 3, :o7, 59216101, 24 - tz.transition 2043, 10, :o4, 59221141, 24 - tz.transition 2044, 3, :o7, 59224837, 24 - tz.transition 2044, 10, :o4, 59230045, 24 - tz.transition 2045, 3, :o7, 59233573, 24 - tz.transition 2045, 10, :o4, 59238781, 24 - tz.transition 2046, 3, :o7, 59242309, 24 - tz.transition 2046, 10, :o4, 59247517, 24 - tz.transition 2047, 3, :o7, 59251213, 24 - tz.transition 2047, 10, :o4, 59256253, 24 - tz.transition 2048, 3, :o7, 59259949, 24 - tz.transition 2048, 10, :o4, 59264989, 24 - tz.transition 2049, 3, :o7, 59268685, 24 - tz.transition 2049, 10, :o4, 59273893, 24 - tz.transition 2050, 3, :o7, 59277421, 24 - tz.transition 2050, 10, :o4, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vienna.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vienna.rb deleted file mode 100644 index 990aaba..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vienna.rb +++ /dev/null @@ -1,183 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Vienna - include TimezoneDefinition - - timezone 'Europe/Vienna' do |tz| - tz.offset :o0, 3920, 0, :LMT - tz.offset :o1, 3600, 0, :CET - tz.offset :o2, 3600, 3600, :CEST - - tz.transition 1893, 3, :o1, 2605558811, 1080 - tz.transition 1916, 4, :o2, 29051813, 12 - tz.transition 1916, 9, :o1, 58107299, 24 - tz.transition 1917, 4, :o2, 58112029, 24 - tz.transition 1917, 9, :o1, 58115725, 24 - tz.transition 1918, 4, :o2, 58120765, 24 - tz.transition 1918, 9, :o1, 58124461, 24 - tz.transition 1920, 4, :o2, 58138069, 24 - tz.transition 1920, 9, :o1, 58141933, 24 - tz.transition 1940, 4, :o2, 58313293, 24 - tz.transition 1942, 11, :o1, 58335973, 24 - tz.transition 1943, 3, :o2, 58339501, 24 - tz.transition 1943, 10, :o1, 58344037, 24 - tz.transition 1944, 4, :o2, 58348405, 24 - tz.transition 1944, 10, :o1, 58352773, 24 - tz.transition 1945, 4, :o2, 58357141, 24 - tz.transition 1945, 4, :o1, 58357381, 24 - tz.transition 1946, 4, :o2, 58366189, 24 - tz.transition 1946, 10, :o1, 58370389, 24 - tz.transition 1947, 4, :o2, 58374757, 24 - tz.transition 1947, 10, :o1, 58379125, 24 - tz.transition 1948, 4, :o2, 58383829, 24 - tz.transition 1948, 10, :o1, 58387861, 24 - tz.transition 1980, 4, :o2, 323823600 - tz.transition 1980, 9, :o1, 338940000 - tz.transition 1981, 3, :o2, 354675600 - tz.transition 1981, 9, :o1, 370400400 - tz.transition 1982, 3, :o2, 386125200 - tz.transition 1982, 9, :o1, 401850000 - tz.transition 1983, 3, :o2, 417574800 - tz.transition 1983, 9, :o1, 433299600 - tz.transition 1984, 3, :o2, 449024400 - tz.transition 1984, 9, :o1, 465354000 - tz.transition 1985, 3, :o2, 481078800 - tz.transition 1985, 9, :o1, 496803600 - tz.transition 1986, 3, :o2, 512528400 - tz.transition 1986, 9, :o1, 528253200 - tz.transition 1987, 3, :o2, 543978000 - tz.transition 1987, 9, :o1, 559702800 - tz.transition 1988, 3, :o2, 575427600 - tz.transition 1988, 9, :o1, 591152400 - tz.transition 1989, 3, :o2, 606877200 - tz.transition 1989, 9, :o1, 622602000 - tz.transition 1990, 3, :o2, 638326800 - tz.transition 1990, 9, :o1, 654656400 - tz.transition 1991, 3, :o2, 670381200 - tz.transition 1991, 9, :o1, 686106000 - tz.transition 1992, 3, :o2, 701830800 - tz.transition 1992, 9, :o1, 717555600 - tz.transition 1993, 3, :o2, 733280400 - tz.transition 1993, 9, :o1, 749005200 - tz.transition 1994, 3, :o2, 764730000 - tz.transition 1994, 9, :o1, 780454800 - tz.transition 1995, 3, :o2, 796179600 - tz.transition 1995, 9, :o1, 811904400 - tz.transition 1996, 3, :o2, 828234000 - tz.transition 1996, 10, :o1, 846378000 - tz.transition 1997, 3, :o2, 859683600 - tz.transition 1997, 10, :o1, 877827600 - tz.transition 1998, 3, :o2, 891133200 - tz.transition 1998, 10, :o1, 909277200 - tz.transition 1999, 3, :o2, 922582800 - tz.transition 1999, 10, :o1, 941331600 - tz.transition 2000, 3, :o2, 954032400 - tz.transition 2000, 10, :o1, 972781200 - tz.transition 2001, 3, :o2, 985482000 - tz.transition 2001, 10, :o1, 1004230800 - tz.transition 2002, 3, :o2, 1017536400 - tz.transition 2002, 10, :o1, 1035680400 - tz.transition 2003, 3, :o2, 1048986000 - tz.transition 2003, 10, :o1, 1067130000 - tz.transition 2004, 3, :o2, 1080435600 - tz.transition 2004, 10, :o1, 1099184400 - tz.transition 2005, 3, :o2, 1111885200 - tz.transition 2005, 10, :o1, 1130634000 - tz.transition 2006, 3, :o2, 1143334800 - tz.transition 2006, 10, :o1, 1162083600 - tz.transition 2007, 3, :o2, 1174784400 - tz.transition 2007, 10, :o1, 1193533200 - tz.transition 2008, 3, :o2, 1206838800 - tz.transition 2008, 10, :o1, 1224982800 - tz.transition 2009, 3, :o2, 1238288400 - tz.transition 2009, 10, :o1, 1256432400 - tz.transition 2010, 3, :o2, 1269738000 - tz.transition 2010, 10, :o1, 1288486800 - tz.transition 2011, 3, :o2, 1301187600 - tz.transition 2011, 10, :o1, 1319936400 - tz.transition 2012, 3, :o2, 1332637200 - tz.transition 2012, 10, :o1, 1351386000 - tz.transition 2013, 3, :o2, 1364691600 - tz.transition 2013, 10, :o1, 1382835600 - tz.transition 2014, 3, :o2, 1396141200 - tz.transition 2014, 10, :o1, 1414285200 - tz.transition 2015, 3, :o2, 1427590800 - tz.transition 2015, 10, :o1, 1445734800 - tz.transition 2016, 3, :o2, 1459040400 - tz.transition 2016, 10, :o1, 1477789200 - tz.transition 2017, 3, :o2, 1490490000 - tz.transition 2017, 10, :o1, 1509238800 - tz.transition 2018, 3, :o2, 1521939600 - tz.transition 2018, 10, :o1, 1540688400 - tz.transition 2019, 3, :o2, 1553994000 - tz.transition 2019, 10, :o1, 1572138000 - tz.transition 2020, 3, :o2, 1585443600 - tz.transition 2020, 10, :o1, 1603587600 - tz.transition 2021, 3, :o2, 1616893200 - tz.transition 2021, 10, :o1, 1635642000 - tz.transition 2022, 3, :o2, 1648342800 - tz.transition 2022, 10, :o1, 1667091600 - tz.transition 2023, 3, :o2, 1679792400 - tz.transition 2023, 10, :o1, 1698541200 - tz.transition 2024, 3, :o2, 1711846800 - tz.transition 2024, 10, :o1, 1729990800 - tz.transition 2025, 3, :o2, 1743296400 - tz.transition 2025, 10, :o1, 1761440400 - tz.transition 2026, 3, :o2, 1774746000 - tz.transition 2026, 10, :o1, 1792890000 - tz.transition 2027, 3, :o2, 1806195600 - tz.transition 2027, 10, :o1, 1824944400 - tz.transition 2028, 3, :o2, 1837645200 - tz.transition 2028, 10, :o1, 1856394000 - tz.transition 2029, 3, :o2, 1869094800 - tz.transition 2029, 10, :o1, 1887843600 - tz.transition 2030, 3, :o2, 1901149200 - tz.transition 2030, 10, :o1, 1919293200 - tz.transition 2031, 3, :o2, 1932598800 - tz.transition 2031, 10, :o1, 1950742800 - tz.transition 2032, 3, :o2, 1964048400 - tz.transition 2032, 10, :o1, 1982797200 - tz.transition 2033, 3, :o2, 1995498000 - tz.transition 2033, 10, :o1, 2014246800 - tz.transition 2034, 3, :o2, 2026947600 - tz.transition 2034, 10, :o1, 2045696400 - tz.transition 2035, 3, :o2, 2058397200 - tz.transition 2035, 10, :o1, 2077146000 - tz.transition 2036, 3, :o2, 2090451600 - tz.transition 2036, 10, :o1, 2108595600 - tz.transition 2037, 3, :o2, 2121901200 - tz.transition 2037, 10, :o1, 2140045200 - tz.transition 2038, 3, :o2, 59172253, 24 - tz.transition 2038, 10, :o1, 59177461, 24 - tz.transition 2039, 3, :o2, 59180989, 24 - tz.transition 2039, 10, :o1, 59186197, 24 - tz.transition 2040, 3, :o2, 59189725, 24 - tz.transition 2040, 10, :o1, 59194933, 24 - tz.transition 2041, 3, :o2, 59198629, 24 - tz.transition 2041, 10, :o1, 59203669, 24 - tz.transition 2042, 3, :o2, 59207365, 24 - tz.transition 2042, 10, :o1, 59212405, 24 - tz.transition 2043, 3, :o2, 59216101, 24 - tz.transition 2043, 10, :o1, 59221141, 24 - tz.transition 2044, 3, :o2, 59224837, 24 - tz.transition 2044, 10, :o1, 59230045, 24 - tz.transition 2045, 3, :o2, 59233573, 24 - tz.transition 2045, 10, :o1, 59238781, 24 - tz.transition 2046, 3, :o2, 59242309, 24 - tz.transition 2046, 10, :o1, 59247517, 24 - tz.transition 2047, 3, :o2, 59251213, 24 - tz.transition 2047, 10, :o1, 59256253, 24 - tz.transition 2048, 3, :o2, 59259949, 24 - tz.transition 2048, 10, :o1, 59264989, 24 - tz.transition 2049, 3, :o2, 59268685, 24 - tz.transition 2049, 10, :o1, 59273893, 24 - tz.transition 2050, 3, :o2, 59277421, 24 - tz.transition 2050, 10, :o1, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vilnius.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vilnius.rb deleted file mode 100644 index d89d095..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vilnius.rb +++ /dev/null @@ -1,170 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Vilnius - include TimezoneDefinition - - timezone 'Europe/Vilnius' do |tz| - tz.offset :o0, 6076, 0, :LMT - tz.offset :o1, 5040, 0, :WMT - tz.offset :o2, 5736, 0, :KMT - tz.offset :o3, 3600, 0, :CET - tz.offset :o4, 7200, 0, :EET - tz.offset :o5, 10800, 0, :MSK - tz.offset :o6, 3600, 3600, :CEST - tz.offset :o7, 10800, 3600, :MSD - tz.offset :o8, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 52006653281, 21600 - tz.transition 1916, 12, :o2, 290547533, 120 - tz.transition 1919, 10, :o3, 8720069161, 3600 - tz.transition 1920, 7, :o4, 58140419, 24 - tz.transition 1920, 10, :o3, 29071277, 12 - tz.transition 1940, 8, :o5, 58316267, 24 - tz.transition 1941, 6, :o6, 19441355, 8 - tz.transition 1942, 11, :o3, 58335973, 24 - tz.transition 1943, 3, :o6, 58339501, 24 - tz.transition 1943, 10, :o3, 58344037, 24 - tz.transition 1944, 4, :o6, 58348405, 24 - tz.transition 1944, 7, :o5, 29175641, 12 - tz.transition 1981, 3, :o7, 354920400 - tz.transition 1981, 9, :o5, 370728000 - tz.transition 1982, 3, :o7, 386456400 - tz.transition 1982, 9, :o5, 402264000 - tz.transition 1983, 3, :o7, 417992400 - tz.transition 1983, 9, :o5, 433800000 - tz.transition 1984, 3, :o7, 449614800 - tz.transition 1984, 9, :o5, 465346800 - tz.transition 1985, 3, :o7, 481071600 - tz.transition 1985, 9, :o5, 496796400 - tz.transition 1986, 3, :o7, 512521200 - tz.transition 1986, 9, :o5, 528246000 - tz.transition 1987, 3, :o7, 543970800 - tz.transition 1987, 9, :o5, 559695600 - tz.transition 1988, 3, :o7, 575420400 - tz.transition 1988, 9, :o5, 591145200 - tz.transition 1989, 3, :o7, 606870000 - tz.transition 1989, 9, :o5, 622594800 - tz.transition 1990, 3, :o7, 638319600 - tz.transition 1990, 9, :o5, 654649200 - tz.transition 1991, 3, :o8, 670374000 - tz.transition 1991, 9, :o4, 686102400 - tz.transition 1992, 3, :o8, 701827200 - tz.transition 1992, 9, :o4, 717552000 - tz.transition 1993, 3, :o8, 733276800 - tz.transition 1993, 9, :o4, 749001600 - tz.transition 1994, 3, :o8, 764726400 - tz.transition 1994, 9, :o4, 780451200 - tz.transition 1995, 3, :o8, 796176000 - tz.transition 1995, 9, :o4, 811900800 - tz.transition 1996, 3, :o8, 828230400 - tz.transition 1996, 10, :o4, 846374400 - tz.transition 1997, 3, :o8, 859680000 - tz.transition 1997, 10, :o4, 877824000 - tz.transition 1998, 3, :o6, 891133200 - tz.transition 1998, 10, :o3, 909277200 - tz.transition 1999, 3, :o6, 922582800 - tz.transition 1999, 10, :o4, 941331600 - tz.transition 2003, 3, :o8, 1048986000 - tz.transition 2003, 10, :o4, 1067130000 - tz.transition 2004, 3, :o8, 1080435600 - tz.transition 2004, 10, :o4, 1099184400 - tz.transition 2005, 3, :o8, 1111885200 - tz.transition 2005, 10, :o4, 1130634000 - tz.transition 2006, 3, :o8, 1143334800 - tz.transition 2006, 10, :o4, 1162083600 - tz.transition 2007, 3, :o8, 1174784400 - tz.transition 2007, 10, :o4, 1193533200 - tz.transition 2008, 3, :o8, 1206838800 - tz.transition 2008, 10, :o4, 1224982800 - tz.transition 2009, 3, :o8, 1238288400 - tz.transition 2009, 10, :o4, 1256432400 - tz.transition 2010, 3, :o8, 1269738000 - tz.transition 2010, 10, :o4, 1288486800 - tz.transition 2011, 3, :o8, 1301187600 - tz.transition 2011, 10, :o4, 1319936400 - tz.transition 2012, 3, :o8, 1332637200 - tz.transition 2012, 10, :o4, 1351386000 - tz.transition 2013, 3, :o8, 1364691600 - tz.transition 2013, 10, :o4, 1382835600 - tz.transition 2014, 3, :o8, 1396141200 - tz.transition 2014, 10, :o4, 1414285200 - tz.transition 2015, 3, :o8, 1427590800 - tz.transition 2015, 10, :o4, 1445734800 - tz.transition 2016, 3, :o8, 1459040400 - tz.transition 2016, 10, :o4, 1477789200 - tz.transition 2017, 3, :o8, 1490490000 - tz.transition 2017, 10, :o4, 1509238800 - tz.transition 2018, 3, :o8, 1521939600 - tz.transition 2018, 10, :o4, 1540688400 - tz.transition 2019, 3, :o8, 1553994000 - tz.transition 2019, 10, :o4, 1572138000 - tz.transition 2020, 3, :o8, 1585443600 - tz.transition 2020, 10, :o4, 1603587600 - tz.transition 2021, 3, :o8, 1616893200 - tz.transition 2021, 10, :o4, 1635642000 - tz.transition 2022, 3, :o8, 1648342800 - tz.transition 2022, 10, :o4, 1667091600 - tz.transition 2023, 3, :o8, 1679792400 - tz.transition 2023, 10, :o4, 1698541200 - tz.transition 2024, 3, :o8, 1711846800 - tz.transition 2024, 10, :o4, 1729990800 - tz.transition 2025, 3, :o8, 1743296400 - tz.transition 2025, 10, :o4, 1761440400 - tz.transition 2026, 3, :o8, 1774746000 - tz.transition 2026, 10, :o4, 1792890000 - tz.transition 2027, 3, :o8, 1806195600 - tz.transition 2027, 10, :o4, 1824944400 - tz.transition 2028, 3, :o8, 1837645200 - tz.transition 2028, 10, :o4, 1856394000 - tz.transition 2029, 3, :o8, 1869094800 - tz.transition 2029, 10, :o4, 1887843600 - tz.transition 2030, 3, :o8, 1901149200 - tz.transition 2030, 10, :o4, 1919293200 - tz.transition 2031, 3, :o8, 1932598800 - tz.transition 2031, 10, :o4, 1950742800 - tz.transition 2032, 3, :o8, 1964048400 - tz.transition 2032, 10, :o4, 1982797200 - tz.transition 2033, 3, :o8, 1995498000 - tz.transition 2033, 10, :o4, 2014246800 - tz.transition 2034, 3, :o8, 2026947600 - tz.transition 2034, 10, :o4, 2045696400 - tz.transition 2035, 3, :o8, 2058397200 - tz.transition 2035, 10, :o4, 2077146000 - tz.transition 2036, 3, :o8, 2090451600 - tz.transition 2036, 10, :o4, 2108595600 - tz.transition 2037, 3, :o8, 2121901200 - tz.transition 2037, 10, :o4, 2140045200 - tz.transition 2038, 3, :o8, 59172253, 24 - tz.transition 2038, 10, :o4, 59177461, 24 - tz.transition 2039, 3, :o8, 59180989, 24 - tz.transition 2039, 10, :o4, 59186197, 24 - tz.transition 2040, 3, :o8, 59189725, 24 - tz.transition 2040, 10, :o4, 59194933, 24 - tz.transition 2041, 3, :o8, 59198629, 24 - tz.transition 2041, 10, :o4, 59203669, 24 - tz.transition 2042, 3, :o8, 59207365, 24 - tz.transition 2042, 10, :o4, 59212405, 24 - tz.transition 2043, 3, :o8, 59216101, 24 - tz.transition 2043, 10, :o4, 59221141, 24 - tz.transition 2044, 3, :o8, 59224837, 24 - tz.transition 2044, 10, :o4, 59230045, 24 - tz.transition 2045, 3, :o8, 59233573, 24 - tz.transition 2045, 10, :o4, 59238781, 24 - tz.transition 2046, 3, :o8, 59242309, 24 - tz.transition 2046, 10, :o4, 59247517, 24 - tz.transition 2047, 3, :o8, 59251213, 24 - tz.transition 2047, 10, :o4, 59256253, 24 - tz.transition 2048, 3, :o8, 59259949, 24 - tz.transition 2048, 10, :o4, 59264989, 24 - tz.transition 2049, 3, :o8, 59268685, 24 - tz.transition 2049, 10, :o4, 59273893, 24 - tz.transition 2050, 3, :o8, 59277421, 24 - tz.transition 2050, 10, :o4, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Warsaw.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Warsaw.rb deleted file mode 100644 index 7fa51c2..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Warsaw.rb +++ /dev/null @@ -1,212 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Warsaw - include TimezoneDefinition - - timezone 'Europe/Warsaw' do |tz| - tz.offset :o0, 5040, 0, :LMT - tz.offset :o1, 5040, 0, :WMT - tz.offset :o2, 3600, 0, :CET - tz.offset :o3, 3600, 3600, :CEST - tz.offset :o4, 7200, 0, :EET - tz.offset :o5, 7200, 3600, :EEST - - tz.transition 1879, 12, :o1, 288925853, 120 - tz.transition 1915, 8, :o2, 290485733, 120 - tz.transition 1916, 4, :o3, 29051813, 12 - tz.transition 1916, 9, :o2, 58107299, 24 - tz.transition 1917, 4, :o3, 58112029, 24 - tz.transition 1917, 9, :o2, 58115725, 24 - tz.transition 1918, 4, :o3, 58120765, 24 - tz.transition 1918, 9, :o4, 58124461, 24 - tz.transition 1919, 4, :o5, 4844127, 2 - tz.transition 1919, 9, :o4, 4844435, 2 - tz.transition 1922, 5, :o2, 29078477, 12 - tz.transition 1940, 6, :o3, 58315285, 24 - tz.transition 1942, 11, :o2, 58335973, 24 - tz.transition 1943, 3, :o3, 58339501, 24 - tz.transition 1943, 10, :o2, 58344037, 24 - tz.transition 1944, 4, :o3, 58348405, 24 - tz.transition 1944, 10, :o2, 4862735, 2 - tz.transition 1945, 4, :o3, 58357787, 24 - tz.transition 1945, 10, :o2, 29181125, 12 - tz.transition 1946, 4, :o3, 58366187, 24 - tz.transition 1946, 10, :o2, 58370413, 24 - tz.transition 1947, 5, :o3, 58375429, 24 - tz.transition 1947, 10, :o2, 58379125, 24 - tz.transition 1948, 4, :o3, 58383829, 24 - tz.transition 1948, 10, :o2, 58387861, 24 - tz.transition 1949, 4, :o3, 58392397, 24 - tz.transition 1949, 10, :o2, 58396597, 24 - tz.transition 1957, 6, :o3, 4871983, 2 - tz.transition 1957, 9, :o2, 4872221, 2 - tz.transition 1958, 3, :o3, 4872585, 2 - tz.transition 1958, 9, :o2, 4872949, 2 - tz.transition 1959, 5, :o3, 4873439, 2 - tz.transition 1959, 10, :o2, 4873691, 2 - tz.transition 1960, 4, :o3, 4874055, 2 - tz.transition 1960, 10, :o2, 4874419, 2 - tz.transition 1961, 5, :o3, 4874895, 2 - tz.transition 1961, 10, :o2, 4875147, 2 - tz.transition 1962, 5, :o3, 4875623, 2 - tz.transition 1962, 9, :o2, 4875875, 2 - tz.transition 1963, 5, :o3, 4876351, 2 - tz.transition 1963, 9, :o2, 4876603, 2 - tz.transition 1964, 5, :o3, 4877093, 2 - tz.transition 1964, 9, :o2, 4877331, 2 - tz.transition 1977, 4, :o3, 228873600 - tz.transition 1977, 9, :o2, 243993600 - tz.transition 1978, 4, :o3, 260323200 - tz.transition 1978, 10, :o2, 276048000 - tz.transition 1979, 4, :o3, 291772800 - tz.transition 1979, 9, :o2, 307497600 - tz.transition 1980, 4, :o3, 323827200 - tz.transition 1980, 9, :o2, 338947200 - tz.transition 1981, 3, :o3, 354672000 - tz.transition 1981, 9, :o2, 370396800 - tz.transition 1982, 3, :o3, 386121600 - tz.transition 1982, 9, :o2, 401846400 - tz.transition 1983, 3, :o3, 417571200 - tz.transition 1983, 9, :o2, 433296000 - tz.transition 1984, 3, :o3, 449020800 - tz.transition 1984, 9, :o2, 465350400 - tz.transition 1985, 3, :o3, 481075200 - tz.transition 1985, 9, :o2, 496800000 - tz.transition 1986, 3, :o3, 512524800 - tz.transition 1986, 9, :o2, 528249600 - tz.transition 1987, 3, :o3, 543974400 - tz.transition 1987, 9, :o2, 559699200 - tz.transition 1988, 3, :o3, 575427600 - tz.transition 1988, 9, :o2, 591152400 - tz.transition 1989, 3, :o3, 606877200 - tz.transition 1989, 9, :o2, 622602000 - tz.transition 1990, 3, :o3, 638326800 - tz.transition 1990, 9, :o2, 654656400 - tz.transition 1991, 3, :o3, 670381200 - tz.transition 1991, 9, :o2, 686106000 - tz.transition 1992, 3, :o3, 701830800 - tz.transition 1992, 9, :o2, 717555600 - tz.transition 1993, 3, :o3, 733280400 - tz.transition 1993, 9, :o2, 749005200 - tz.transition 1994, 3, :o3, 764730000 - tz.transition 1994, 9, :o2, 780454800 - tz.transition 1995, 3, :o3, 796179600 - tz.transition 1995, 9, :o2, 811904400 - tz.transition 1996, 3, :o3, 828234000 - tz.transition 1996, 10, :o2, 846378000 - tz.transition 1997, 3, :o3, 859683600 - tz.transition 1997, 10, :o2, 877827600 - tz.transition 1998, 3, :o3, 891133200 - tz.transition 1998, 10, :o2, 909277200 - tz.transition 1999, 3, :o3, 922582800 - tz.transition 1999, 10, :o2, 941331600 - tz.transition 2000, 3, :o3, 954032400 - tz.transition 2000, 10, :o2, 972781200 - tz.transition 2001, 3, :o3, 985482000 - tz.transition 2001, 10, :o2, 1004230800 - tz.transition 2002, 3, :o3, 1017536400 - tz.transition 2002, 10, :o2, 1035680400 - tz.transition 2003, 3, :o3, 1048986000 - tz.transition 2003, 10, :o2, 1067130000 - tz.transition 2004, 3, :o3, 1080435600 - tz.transition 2004, 10, :o2, 1099184400 - tz.transition 2005, 3, :o3, 1111885200 - tz.transition 2005, 10, :o2, 1130634000 - tz.transition 2006, 3, :o3, 1143334800 - tz.transition 2006, 10, :o2, 1162083600 - tz.transition 2007, 3, :o3, 1174784400 - tz.transition 2007, 10, :o2, 1193533200 - tz.transition 2008, 3, :o3, 1206838800 - tz.transition 2008, 10, :o2, 1224982800 - tz.transition 2009, 3, :o3, 1238288400 - tz.transition 2009, 10, :o2, 1256432400 - tz.transition 2010, 3, :o3, 1269738000 - tz.transition 2010, 10, :o2, 1288486800 - tz.transition 2011, 3, :o3, 1301187600 - tz.transition 2011, 10, :o2, 1319936400 - tz.transition 2012, 3, :o3, 1332637200 - tz.transition 2012, 10, :o2, 1351386000 - tz.transition 2013, 3, :o3, 1364691600 - tz.transition 2013, 10, :o2, 1382835600 - tz.transition 2014, 3, :o3, 1396141200 - tz.transition 2014, 10, :o2, 1414285200 - tz.transition 2015, 3, :o3, 1427590800 - tz.transition 2015, 10, :o2, 1445734800 - tz.transition 2016, 3, :o3, 1459040400 - tz.transition 2016, 10, :o2, 1477789200 - tz.transition 2017, 3, :o3, 1490490000 - tz.transition 2017, 10, :o2, 1509238800 - tz.transition 2018, 3, :o3, 1521939600 - tz.transition 2018, 10, :o2, 1540688400 - tz.transition 2019, 3, :o3, 1553994000 - tz.transition 2019, 10, :o2, 1572138000 - tz.transition 2020, 3, :o3, 1585443600 - tz.transition 2020, 10, :o2, 1603587600 - tz.transition 2021, 3, :o3, 1616893200 - tz.transition 2021, 10, :o2, 1635642000 - tz.transition 2022, 3, :o3, 1648342800 - tz.transition 2022, 10, :o2, 1667091600 - tz.transition 2023, 3, :o3, 1679792400 - tz.transition 2023, 10, :o2, 1698541200 - tz.transition 2024, 3, :o3, 1711846800 - tz.transition 2024, 10, :o2, 1729990800 - tz.transition 2025, 3, :o3, 1743296400 - tz.transition 2025, 10, :o2, 1761440400 - tz.transition 2026, 3, :o3, 1774746000 - tz.transition 2026, 10, :o2, 1792890000 - tz.transition 2027, 3, :o3, 1806195600 - tz.transition 2027, 10, :o2, 1824944400 - tz.transition 2028, 3, :o3, 1837645200 - tz.transition 2028, 10, :o2, 1856394000 - tz.transition 2029, 3, :o3, 1869094800 - tz.transition 2029, 10, :o2, 1887843600 - tz.transition 2030, 3, :o3, 1901149200 - tz.transition 2030, 10, :o2, 1919293200 - tz.transition 2031, 3, :o3, 1932598800 - tz.transition 2031, 10, :o2, 1950742800 - tz.transition 2032, 3, :o3, 1964048400 - tz.transition 2032, 10, :o2, 1982797200 - tz.transition 2033, 3, :o3, 1995498000 - tz.transition 2033, 10, :o2, 2014246800 - tz.transition 2034, 3, :o3, 2026947600 - tz.transition 2034, 10, :o2, 2045696400 - tz.transition 2035, 3, :o3, 2058397200 - tz.transition 2035, 10, :o2, 2077146000 - tz.transition 2036, 3, :o3, 2090451600 - tz.transition 2036, 10, :o2, 2108595600 - tz.transition 2037, 3, :o3, 2121901200 - tz.transition 2037, 10, :o2, 2140045200 - tz.transition 2038, 3, :o3, 59172253, 24 - tz.transition 2038, 10, :o2, 59177461, 24 - tz.transition 2039, 3, :o3, 59180989, 24 - tz.transition 2039, 10, :o2, 59186197, 24 - tz.transition 2040, 3, :o3, 59189725, 24 - tz.transition 2040, 10, :o2, 59194933, 24 - tz.transition 2041, 3, :o3, 59198629, 24 - tz.transition 2041, 10, :o2, 59203669, 24 - tz.transition 2042, 3, :o3, 59207365, 24 - tz.transition 2042, 10, :o2, 59212405, 24 - tz.transition 2043, 3, :o3, 59216101, 24 - tz.transition 2043, 10, :o2, 59221141, 24 - tz.transition 2044, 3, :o3, 59224837, 24 - tz.transition 2044, 10, :o2, 59230045, 24 - tz.transition 2045, 3, :o3, 59233573, 24 - tz.transition 2045, 10, :o2, 59238781, 24 - tz.transition 2046, 3, :o3, 59242309, 24 - tz.transition 2046, 10, :o2, 59247517, 24 - tz.transition 2047, 3, :o3, 59251213, 24 - tz.transition 2047, 10, :o2, 59256253, 24 - tz.transition 2048, 3, :o3, 59259949, 24 - tz.transition 2048, 10, :o2, 59264989, 24 - tz.transition 2049, 3, :o3, 59268685, 24 - tz.transition 2049, 10, :o2, 59273893, 24 - tz.transition 2050, 3, :o3, 59277421, 24 - tz.transition 2050, 10, :o2, 59282629, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Zagreb.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Zagreb.rb deleted file mode 100644 index ecdd903..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Zagreb.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Europe - module Zagreb - include TimezoneDefinition - - linked_timezone 'Europe/Zagreb', 'Europe/Belgrade' - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Auckland.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Auckland.rb deleted file mode 100644 index a524fd6..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Auckland.rb +++ /dev/null @@ -1,202 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Auckland - include TimezoneDefinition - - timezone 'Pacific/Auckland' do |tz| - tz.offset :o0, 41944, 0, :LMT - tz.offset :o1, 41400, 0, :NZMT - tz.offset :o2, 41400, 3600, :NZST - tz.offset :o3, 41400, 1800, :NZST - tz.offset :o4, 43200, 0, :NZST - tz.offset :o5, 43200, 3600, :NZDT - - tz.transition 1868, 11, :o1, 25959290557, 10800 - tz.transition 1927, 11, :o2, 116409125, 48 - tz.transition 1928, 3, :o1, 38804945, 16 - tz.transition 1928, 10, :o3, 116425589, 48 - tz.transition 1929, 3, :o1, 29108245, 12 - tz.transition 1929, 10, :o3, 116443061, 48 - tz.transition 1930, 3, :o1, 29112613, 12 - tz.transition 1930, 10, :o3, 116460533, 48 - tz.transition 1931, 3, :o1, 29116981, 12 - tz.transition 1931, 10, :o3, 116478005, 48 - tz.transition 1932, 3, :o1, 29121433, 12 - tz.transition 1932, 10, :o3, 116495477, 48 - tz.transition 1933, 3, :o1, 29125801, 12 - tz.transition 1933, 10, :o3, 116512949, 48 - tz.transition 1934, 4, :o1, 29130673, 12 - tz.transition 1934, 9, :o3, 116530085, 48 - tz.transition 1935, 4, :o1, 29135041, 12 - tz.transition 1935, 9, :o3, 116547557, 48 - tz.transition 1936, 4, :o1, 29139409, 12 - tz.transition 1936, 9, :o3, 116565029, 48 - tz.transition 1937, 4, :o1, 29143777, 12 - tz.transition 1937, 9, :o3, 116582501, 48 - tz.transition 1938, 4, :o1, 29148145, 12 - tz.transition 1938, 9, :o3, 116599973, 48 - tz.transition 1939, 4, :o1, 29152597, 12 - tz.transition 1939, 9, :o3, 116617445, 48 - tz.transition 1940, 4, :o1, 29156965, 12 - tz.transition 1940, 9, :o3, 116635253, 48 - tz.transition 1945, 12, :o4, 2431821, 1 - tz.transition 1974, 11, :o5, 152632800 - tz.transition 1975, 2, :o4, 162309600 - tz.transition 1975, 10, :o5, 183477600 - tz.transition 1976, 3, :o4, 194968800 - tz.transition 1976, 10, :o5, 215532000 - tz.transition 1977, 3, :o4, 226418400 - tz.transition 1977, 10, :o5, 246981600 - tz.transition 1978, 3, :o4, 257868000 - tz.transition 1978, 10, :o5, 278431200 - tz.transition 1979, 3, :o4, 289317600 - tz.transition 1979, 10, :o5, 309880800 - tz.transition 1980, 3, :o4, 320767200 - tz.transition 1980, 10, :o5, 341330400 - tz.transition 1981, 2, :o4, 352216800 - tz.transition 1981, 10, :o5, 372780000 - tz.transition 1982, 3, :o4, 384271200 - tz.transition 1982, 10, :o5, 404834400 - tz.transition 1983, 3, :o4, 415720800 - tz.transition 1983, 10, :o5, 436284000 - tz.transition 1984, 3, :o4, 447170400 - tz.transition 1984, 10, :o5, 467733600 - tz.transition 1985, 3, :o4, 478620000 - tz.transition 1985, 10, :o5, 499183200 - tz.transition 1986, 3, :o4, 510069600 - tz.transition 1986, 10, :o5, 530632800 - tz.transition 1987, 2, :o4, 541519200 - tz.transition 1987, 10, :o5, 562082400 - tz.transition 1988, 3, :o4, 573573600 - tz.transition 1988, 10, :o5, 594136800 - tz.transition 1989, 3, :o4, 605023200 - tz.transition 1989, 10, :o5, 623772000 - tz.transition 1990, 3, :o4, 637682400 - tz.transition 1990, 10, :o5, 655221600 - tz.transition 1991, 3, :o4, 669132000 - tz.transition 1991, 10, :o5, 686671200 - tz.transition 1992, 3, :o4, 700581600 - tz.transition 1992, 10, :o5, 718120800 - tz.transition 1993, 3, :o4, 732636000 - tz.transition 1993, 10, :o5, 749570400 - tz.transition 1994, 3, :o4, 764085600 - tz.transition 1994, 10, :o5, 781020000 - tz.transition 1995, 3, :o4, 795535200 - tz.transition 1995, 9, :o5, 812469600 - tz.transition 1996, 3, :o4, 826984800 - tz.transition 1996, 10, :o5, 844524000 - tz.transition 1997, 3, :o4, 858434400 - tz.transition 1997, 10, :o5, 875973600 - tz.transition 1998, 3, :o4, 889884000 - tz.transition 1998, 10, :o5, 907423200 - tz.transition 1999, 3, :o4, 921938400 - tz.transition 1999, 10, :o5, 938872800 - tz.transition 2000, 3, :o4, 953388000 - tz.transition 2000, 9, :o5, 970322400 - tz.transition 2001, 3, :o4, 984837600 - tz.transition 2001, 10, :o5, 1002376800 - tz.transition 2002, 3, :o4, 1016287200 - tz.transition 2002, 10, :o5, 1033826400 - tz.transition 2003, 3, :o4, 1047736800 - tz.transition 2003, 10, :o5, 1065276000 - tz.transition 2004, 3, :o4, 1079791200 - tz.transition 2004, 10, :o5, 1096725600 - tz.transition 2005, 3, :o4, 1111240800 - tz.transition 2005, 10, :o5, 1128175200 - tz.transition 2006, 3, :o4, 1142690400 - tz.transition 2006, 9, :o5, 1159624800 - tz.transition 2007, 3, :o4, 1174140000 - tz.transition 2007, 9, :o5, 1191074400 - tz.transition 2008, 4, :o4, 1207404000 - tz.transition 2008, 9, :o5, 1222524000 - tz.transition 2009, 4, :o4, 1238853600 - tz.transition 2009, 9, :o5, 1253973600 - tz.transition 2010, 4, :o4, 1270303200 - tz.transition 2010, 9, :o5, 1285423200 - tz.transition 2011, 4, :o4, 1301752800 - tz.transition 2011, 9, :o5, 1316872800 - tz.transition 2012, 3, :o4, 1333202400 - tz.transition 2012, 9, :o5, 1348927200 - tz.transition 2013, 4, :o4, 1365256800 - tz.transition 2013, 9, :o5, 1380376800 - tz.transition 2014, 4, :o4, 1396706400 - tz.transition 2014, 9, :o5, 1411826400 - tz.transition 2015, 4, :o4, 1428156000 - tz.transition 2015, 9, :o5, 1443276000 - tz.transition 2016, 4, :o4, 1459605600 - tz.transition 2016, 9, :o5, 1474725600 - tz.transition 2017, 4, :o4, 1491055200 - tz.transition 2017, 9, :o5, 1506175200 - tz.transition 2018, 3, :o4, 1522504800 - tz.transition 2018, 9, :o5, 1538229600 - tz.transition 2019, 4, :o4, 1554559200 - tz.transition 2019, 9, :o5, 1569679200 - tz.transition 2020, 4, :o4, 1586008800 - tz.transition 2020, 9, :o5, 1601128800 - tz.transition 2021, 4, :o4, 1617458400 - tz.transition 2021, 9, :o5, 1632578400 - tz.transition 2022, 4, :o4, 1648908000 - tz.transition 2022, 9, :o5, 1664028000 - tz.transition 2023, 4, :o4, 1680357600 - tz.transition 2023, 9, :o5, 1695477600 - tz.transition 2024, 4, :o4, 1712412000 - tz.transition 2024, 9, :o5, 1727532000 - tz.transition 2025, 4, :o4, 1743861600 - tz.transition 2025, 9, :o5, 1758981600 - tz.transition 2026, 4, :o4, 1775311200 - tz.transition 2026, 9, :o5, 1790431200 - tz.transition 2027, 4, :o4, 1806760800 - tz.transition 2027, 9, :o5, 1821880800 - tz.transition 2028, 4, :o4, 1838210400 - tz.transition 2028, 9, :o5, 1853330400 - tz.transition 2029, 3, :o4, 1869660000 - tz.transition 2029, 9, :o5, 1885384800 - tz.transition 2030, 4, :o4, 1901714400 - tz.transition 2030, 9, :o5, 1916834400 - tz.transition 2031, 4, :o4, 1933164000 - tz.transition 2031, 9, :o5, 1948284000 - tz.transition 2032, 4, :o4, 1964613600 - tz.transition 2032, 9, :o5, 1979733600 - tz.transition 2033, 4, :o4, 1996063200 - tz.transition 2033, 9, :o5, 2011183200 - tz.transition 2034, 4, :o4, 2027512800 - tz.transition 2034, 9, :o5, 2042632800 - tz.transition 2035, 3, :o4, 2058962400 - tz.transition 2035, 9, :o5, 2074687200 - tz.transition 2036, 4, :o4, 2091016800 - tz.transition 2036, 9, :o5, 2106136800 - tz.transition 2037, 4, :o4, 2122466400 - tz.transition 2037, 9, :o5, 2137586400 - tz.transition 2038, 4, :o4, 29586205, 12 - tz.transition 2038, 9, :o5, 29588305, 12 - tz.transition 2039, 4, :o4, 29590573, 12 - tz.transition 2039, 9, :o5, 29592673, 12 - tz.transition 2040, 3, :o4, 29594941, 12 - tz.transition 2040, 9, :o5, 29597125, 12 - tz.transition 2041, 4, :o4, 29599393, 12 - tz.transition 2041, 9, :o5, 29601493, 12 - tz.transition 2042, 4, :o4, 29603761, 12 - tz.transition 2042, 9, :o5, 29605861, 12 - tz.transition 2043, 4, :o4, 29608129, 12 - tz.transition 2043, 9, :o5, 29610229, 12 - tz.transition 2044, 4, :o4, 29612497, 12 - tz.transition 2044, 9, :o5, 29614597, 12 - tz.transition 2045, 4, :o4, 29616865, 12 - tz.transition 2045, 9, :o5, 29618965, 12 - tz.transition 2046, 3, :o4, 29621233, 12 - tz.transition 2046, 9, :o5, 29623417, 12 - tz.transition 2047, 4, :o4, 29625685, 12 - tz.transition 2047, 9, :o5, 29627785, 12 - tz.transition 2048, 4, :o4, 29630053, 12 - tz.transition 2048, 9, :o5, 29632153, 12 - tz.transition 2049, 4, :o4, 29634421, 12 - tz.transition 2049, 9, :o5, 29636521, 12 - tz.transition 2050, 4, :o4, 29638789, 12 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Fiji.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Fiji.rb deleted file mode 100644 index 5fe9bbd..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Fiji.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Fiji - include TimezoneDefinition - - timezone 'Pacific/Fiji' do |tz| - tz.offset :o0, 42820, 0, :LMT - tz.offset :o1, 43200, 0, :FJT - tz.offset :o2, 43200, 3600, :FJST - - tz.transition 1915, 10, :o1, 10457838739, 4320 - tz.transition 1998, 10, :o2, 909842400 - tz.transition 1999, 2, :o1, 920124000 - tz.transition 1999, 11, :o2, 941896800 - tz.transition 2000, 2, :o1, 951573600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Guam.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Guam.rb deleted file mode 100644 index d4c1a0a..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Guam.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Guam - include TimezoneDefinition - - timezone 'Pacific/Guam' do |tz| - tz.offset :o0, -51660, 0, :LMT - tz.offset :o1, 34740, 0, :LMT - tz.offset :o2, 36000, 0, :GST - tz.offset :o3, 36000, 0, :ChST - - tz.transition 1844, 12, :o1, 1149567407, 480 - tz.transition 1900, 12, :o2, 1159384847, 480 - tz.transition 2000, 12, :o3, 977493600 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Honolulu.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Honolulu.rb deleted file mode 100644 index 204b226..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Honolulu.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Honolulu - include TimezoneDefinition - - timezone 'Pacific/Honolulu' do |tz| - tz.offset :o0, -37886, 0, :LMT - tz.offset :o1, -37800, 0, :HST - tz.offset :o2, -37800, 3600, :HDT - tz.offset :o3, -37800, 3600, :HWT - tz.offset :o4, -37800, 3600, :HPT - tz.offset :o5, -36000, 0, :HST - - tz.transition 1900, 1, :o1, 104328926143, 43200 - tz.transition 1933, 4, :o2, 116505265, 48 - tz.transition 1933, 5, :o1, 116506271, 48 - tz.transition 1942, 2, :o3, 116659201, 48 - tz.transition 1945, 8, :o4, 58360379, 24 - tz.transition 1945, 9, :o1, 116722991, 48 - tz.transition 1947, 6, :o5, 116752561, 48 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Majuro.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Majuro.rb deleted file mode 100644 index 32adad9..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Majuro.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Majuro - include TimezoneDefinition - - timezone 'Pacific/Majuro' do |tz| - tz.offset :o0, 41088, 0, :LMT - tz.offset :o1, 39600, 0, :MHT - tz.offset :o2, 43200, 0, :MHT - - tz.transition 1900, 12, :o1, 1086923261, 450 - tz.transition 1969, 9, :o2, 58571881, 24 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Midway.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Midway.rb deleted file mode 100644 index 97784fc..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Midway.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Midway - include TimezoneDefinition - - timezone 'Pacific/Midway' do |tz| - tz.offset :o0, -42568, 0, :LMT - tz.offset :o1, -39600, 0, :NST - tz.offset :o2, -39600, 3600, :NDT - tz.offset :o3, -39600, 0, :BST - tz.offset :o4, -39600, 0, :SST - - tz.transition 1901, 1, :o1, 26086168721, 10800 - tz.transition 1956, 6, :o2, 58455071, 24 - tz.transition 1956, 9, :o1, 29228627, 12 - tz.transition 1967, 4, :o3, 58549967, 24 - tz.transition 1983, 11, :o4, 439038000 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Noumea.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Noumea.rb deleted file mode 100644 index 70173db..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Noumea.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Noumea - include TimezoneDefinition - - timezone 'Pacific/Noumea' do |tz| - tz.offset :o0, 39948, 0, :LMT - tz.offset :o1, 39600, 0, :NCT - tz.offset :o2, 39600, 3600, :NCST - - tz.transition 1912, 1, :o1, 17419781071, 7200 - tz.transition 1977, 12, :o2, 250002000 - tz.transition 1978, 2, :o1, 257342400 - tz.transition 1978, 12, :o2, 281451600 - tz.transition 1979, 2, :o1, 288878400 - tz.transition 1996, 11, :o2, 849366000 - tz.transition 1997, 3, :o1, 857228400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Pago_Pago.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Pago_Pago.rb deleted file mode 100644 index c8fcd7d..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Pago_Pago.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Pago_Pago - include TimezoneDefinition - - timezone 'Pacific/Pago_Pago' do |tz| - tz.offset :o0, 45432, 0, :LMT - tz.offset :o1, -40968, 0, :LMT - tz.offset :o2, -41400, 0, :SAMT - tz.offset :o3, -39600, 0, :NST - tz.offset :o4, -39600, 0, :BST - tz.offset :o5, -39600, 0, :SST - - tz.transition 1879, 7, :o1, 2889041969, 1200 - tz.transition 1911, 1, :o2, 2902845569, 1200 - tz.transition 1950, 1, :o3, 116797583, 48 - tz.transition 1967, 4, :o4, 58549967, 24 - tz.transition 1983, 11, :o5, 439038000 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Port_Moresby.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Port_Moresby.rb deleted file mode 100644 index f06cf6d..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Port_Moresby.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Port_Moresby - include TimezoneDefinition - - timezone 'Pacific/Port_Moresby' do |tz| - tz.offset :o0, 35320, 0, :LMT - tz.offset :o1, 35312, 0, :PMMT - tz.offset :o2, 36000, 0, :PGT - - tz.transition 1879, 12, :o1, 5200664597, 2160 - tz.transition 1894, 12, :o2, 13031248093, 5400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Tongatapu.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Tongatapu.rb deleted file mode 100644 index 7578d92..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Tongatapu.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'tzinfo/timezone_definition' - -module TZInfo - module Definitions - module Pacific - module Tongatapu - include TimezoneDefinition - - timezone 'Pacific/Tongatapu' do |tz| - tz.offset :o0, 44360, 0, :LMT - tz.offset :o1, 44400, 0, :TOT - tz.offset :o2, 46800, 0, :TOT - tz.offset :o3, 46800, 3600, :TOST - - tz.transition 1900, 12, :o1, 5217231571, 2160 - tz.transition 1940, 12, :o2, 174959639, 72 - tz.transition 1999, 10, :o3, 939214800 - tz.transition 2000, 3, :o2, 953384400 - tz.transition 2000, 11, :o3, 973342800 - tz.transition 2001, 1, :o2, 980596800 - tz.transition 2001, 11, :o3, 1004792400 - tz.transition 2002, 1, :o2, 1012046400 - end - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/info_timezone.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/info_timezone.rb deleted file mode 100644 index 001303c..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/info_timezone.rb +++ /dev/null @@ -1,52 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'tzinfo/timezone' - -module TZInfo - - # A Timezone based on a TimezoneInfo. - class InfoTimezone < Timezone #:nodoc: - - # Constructs a new InfoTimezone with a TimezoneInfo instance. - def self.new(info) - tz = super() - tz.send(:setup, info) - tz - end - - # The identifier of the timezone, e.g. "Europe/Paris". - def identifier - @info.identifier - end - - protected - # The TimezoneInfo for this Timezone. - def info - @info - end - - def setup(info) - @info = info - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone.rb deleted file mode 100644 index f8ec4fc..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone.rb +++ /dev/null @@ -1,51 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'tzinfo/info_timezone' - -module TZInfo - - class LinkedTimezone < InfoTimezone #:nodoc: - # Returns the TimezonePeriod for the given UTC time. utc can either be - # a DateTime, Time or integer timestamp (Time.to_i). Any timezone - # information in utc is ignored (it is treated as a UTC time). - # - # If no TimezonePeriod could be found, PeriodNotFound is raised. - def period_for_utc(utc) - @linked_timezone.period_for_utc(utc) - end - - # Returns the set of TimezonePeriod instances that are valid for the given - # local time as an array. If you just want a single period, use - # period_for_local instead and specify how abiguities should be resolved. - # Raises PeriodNotFound if no periods are found for the given time. - def periods_for_local(local) - @linked_timezone.periods_for_local(local) - end - - protected - def setup(info) - super(info) - @linked_timezone = Timezone.get(info.link_to_identifier) - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone_info.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone_info.rb deleted file mode 100644 index 8197ff3..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone_info.rb +++ /dev/null @@ -1,44 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'tzinfo/timezone_info' - -module TZInfo - # Represents a linked timezone defined in a data module. - class LinkedTimezoneInfo < TimezoneInfo #:nodoc: - - # The zone that provides the data (that this zone is an alias for). - attr_reader :link_to_identifier - - # Constructs a new TimezoneInfo with an identifier and the identifier - # of the zone linked to. - def initialize(identifier, link_to_identifier) - super(identifier) - @link_to_identifier = link_to_identifier - end - - # Returns internal object state as a programmer-readable string. - def inspect - "#<#{self.class}: #@identifier,#@link_to_identifier>" - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/offset_rationals.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/offset_rationals.rb deleted file mode 100644 index b1f10b2..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/offset_rationals.rb +++ /dev/null @@ -1,98 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'rational' -require 'tzinfo/ruby_core_support' - -module TZInfo - - # Provides a method for getting Rationals for a timezone offset in seconds. - # Pre-reduced rationals are returned for all the half-hour intervals between - # -14 and +14 hours to avoid having to call gcd at runtime. - module OffsetRationals #:nodoc: - @@rational_cache = { - -50400 => RubyCoreSupport.rational_new!(-7,12), - -48600 => RubyCoreSupport.rational_new!(-9,16), - -46800 => RubyCoreSupport.rational_new!(-13,24), - -45000 => RubyCoreSupport.rational_new!(-25,48), - -43200 => RubyCoreSupport.rational_new!(-1,2), - -41400 => RubyCoreSupport.rational_new!(-23,48), - -39600 => RubyCoreSupport.rational_new!(-11,24), - -37800 => RubyCoreSupport.rational_new!(-7,16), - -36000 => RubyCoreSupport.rational_new!(-5,12), - -34200 => RubyCoreSupport.rational_new!(-19,48), - -32400 => RubyCoreSupport.rational_new!(-3,8), - -30600 => RubyCoreSupport.rational_new!(-17,48), - -28800 => RubyCoreSupport.rational_new!(-1,3), - -27000 => RubyCoreSupport.rational_new!(-5,16), - -25200 => RubyCoreSupport.rational_new!(-7,24), - -23400 => RubyCoreSupport.rational_new!(-13,48), - -21600 => RubyCoreSupport.rational_new!(-1,4), - -19800 => RubyCoreSupport.rational_new!(-11,48), - -18000 => RubyCoreSupport.rational_new!(-5,24), - -16200 => RubyCoreSupport.rational_new!(-3,16), - -14400 => RubyCoreSupport.rational_new!(-1,6), - -12600 => RubyCoreSupport.rational_new!(-7,48), - -10800 => RubyCoreSupport.rational_new!(-1,8), - -9000 => RubyCoreSupport.rational_new!(-5,48), - -7200 => RubyCoreSupport.rational_new!(-1,12), - -5400 => RubyCoreSupport.rational_new!(-1,16), - -3600 => RubyCoreSupport.rational_new!(-1,24), - -1800 => RubyCoreSupport.rational_new!(-1,48), - 0 => RubyCoreSupport.rational_new!(0,1), - 1800 => RubyCoreSupport.rational_new!(1,48), - 3600 => RubyCoreSupport.rational_new!(1,24), - 5400 => RubyCoreSupport.rational_new!(1,16), - 7200 => RubyCoreSupport.rational_new!(1,12), - 9000 => RubyCoreSupport.rational_new!(5,48), - 10800 => RubyCoreSupport.rational_new!(1,8), - 12600 => RubyCoreSupport.rational_new!(7,48), - 14400 => RubyCoreSupport.rational_new!(1,6), - 16200 => RubyCoreSupport.rational_new!(3,16), - 18000 => RubyCoreSupport.rational_new!(5,24), - 19800 => RubyCoreSupport.rational_new!(11,48), - 21600 => RubyCoreSupport.rational_new!(1,4), - 23400 => RubyCoreSupport.rational_new!(13,48), - 25200 => RubyCoreSupport.rational_new!(7,24), - 27000 => RubyCoreSupport.rational_new!(5,16), - 28800 => RubyCoreSupport.rational_new!(1,3), - 30600 => RubyCoreSupport.rational_new!(17,48), - 32400 => RubyCoreSupport.rational_new!(3,8), - 34200 => RubyCoreSupport.rational_new!(19,48), - 36000 => RubyCoreSupport.rational_new!(5,12), - 37800 => RubyCoreSupport.rational_new!(7,16), - 39600 => RubyCoreSupport.rational_new!(11,24), - 41400 => RubyCoreSupport.rational_new!(23,48), - 43200 => RubyCoreSupport.rational_new!(1,2), - 45000 => RubyCoreSupport.rational_new!(25,48), - 46800 => RubyCoreSupport.rational_new!(13,24), - 48600 => RubyCoreSupport.rational_new!(9,16), - 50400 => RubyCoreSupport.rational_new!(7,12)} - - # Returns a Rational expressing the fraction of a day that offset in - # seconds represents (i.e. equivalent to Rational(offset, 86400)). - def rational_for_offset(offset) - @@rational_cache[offset] || Rational(offset, 86400) - end - module_function :rational_for_offset - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/ruby_core_support.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/ruby_core_support.rb deleted file mode 100644 index 9a04412..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/ruby_core_support.rb +++ /dev/null @@ -1,56 +0,0 @@ -#-- -# Copyright (c) 2008 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'date' -require 'rational' - -module TZInfo - - # Methods to support different versions of Ruby. - module RubyCoreSupport #:nodoc: - - # Use Rational.new! for performance reasons in Ruby 1.8. - # This has been removed from 1.9, but Rational performs better. - if Rational.respond_to? :new! - def self.rational_new!(numerator, denominator = 1) - Rational.new!(numerator, denominator) - end - else - def self.rational_new!(numerator, denominator = 1) - Rational(numerator, denominator) - end - end - - # Ruby 1.8.6 introduced new! and deprecated new0. - # Ruby 1.9.0 removed new0. - # We still need to support new0 for older versions of Ruby. - if DateTime.respond_to? :new! - def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY) - DateTime.new!(ajd, of, sg) - end - else - def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY) - DateTime.new0(ajd, of, sg) - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb deleted file mode 100644 index 264517f..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb +++ /dev/null @@ -1,292 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'date' -require 'time' -require 'tzinfo/offset_rationals' - -module TZInfo - # Used by TZInfo internally to represent either a Time, DateTime or integer - # timestamp (seconds since 1970-01-01 00:00:00). - class TimeOrDateTime #:nodoc: - include Comparable - - # Constructs a new TimeOrDateTime. timeOrDateTime can be a Time, DateTime - # or an integer. If using a Time or DateTime, any time zone information is - # ignored. - def initialize(timeOrDateTime) - @time = nil - @datetime = nil - @timestamp = nil - - if timeOrDateTime.is_a?(Time) - @time = timeOrDateTime - @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec) unless @time.zone == 'UTC' - @orig = @time - elsif timeOrDateTime.is_a?(DateTime) - @datetime = timeOrDateTime - @datetime = @datetime.new_offset(0) unless @datetime.offset == 0 - @orig = @datetime - else - @timestamp = timeOrDateTime.to_i - @orig = @timestamp - end - end - - # Returns the time as a Time. - def to_time - unless @time - if @timestamp - @time = Time.at(@timestamp).utc - else - @time = Time.utc(year, mon, mday, hour, min, sec) - end - end - - @time - end - - # Returns the time as a DateTime. - def to_datetime - unless @datetime - @datetime = DateTime.new(year, mon, mday, hour, min, sec) - end - - @datetime - end - - # Returns the time as an integer timestamp. - def to_i - unless @timestamp - @timestamp = to_time.to_i - end - - @timestamp - end - - # Returns the time as the original time passed to new. - def to_orig - @orig - end - - # Returns a string representation of the TimeOrDateTime. - def to_s - if @orig.is_a?(Time) - "Time: #{@orig.to_s}" - elsif @orig.is_a?(DateTime) - "DateTime: #{@orig.to_s}" - else - "Timestamp: #{@orig.to_s}" - end - end - - # Returns internal object state as a programmer-readable string. - def inspect - "#<#{self.class}: #{@orig.inspect}>" - end - - # Returns the year. - def year - if @time - @time.year - elsif @datetime - @datetime.year - else - to_time.year - end - end - - # Returns the month of the year (1..12). - def mon - if @time - @time.mon - elsif @datetime - @datetime.mon - else - to_time.mon - end - end - alias :month :mon - - # Returns the day of the month (1..n). - def mday - if @time - @time.mday - elsif @datetime - @datetime.mday - else - to_time.mday - end - end - alias :day :mday - - # Returns the hour of the day (0..23). - def hour - if @time - @time.hour - elsif @datetime - @datetime.hour - else - to_time.hour - end - end - - # Returns the minute of the hour (0..59). - def min - if @time - @time.min - elsif @datetime - @datetime.min - else - to_time.min - end - end - - # Returns the second of the minute (0..60). (60 for a leap second). - def sec - if @time - @time.sec - elsif @datetime - @datetime.sec - else - to_time.sec - end - end - - # Compares this TimeOrDateTime with another Time, DateTime, integer - # timestamp or TimeOrDateTime. Returns -1, 0 or +1 depending whether the - # receiver is less than, equal to, or greater than timeOrDateTime. - # - # Milliseconds and smaller units are ignored in the comparison. - def <=>(timeOrDateTime) - if timeOrDateTime.is_a?(TimeOrDateTime) - orig = timeOrDateTime.to_orig - - if @orig.is_a?(DateTime) || orig.is_a?(DateTime) - # If either is a DateTime, assume it is there for a reason - # (i.e. for range). - to_datetime <=> timeOrDateTime.to_datetime - elsif orig.is_a?(Time) - to_time <=> timeOrDateTime.to_time - else - to_i <=> timeOrDateTime.to_i - end - elsif @orig.is_a?(DateTime) || timeOrDateTime.is_a?(DateTime) - # If either is a DateTime, assume it is there for a reason - # (i.e. for range). - to_datetime <=> TimeOrDateTime.wrap(timeOrDateTime).to_datetime - elsif timeOrDateTime.is_a?(Time) - to_time <=> timeOrDateTime - else - to_i <=> timeOrDateTime.to_i - end - end - - # Adds a number of seconds to the TimeOrDateTime. Returns a new - # TimeOrDateTime, preserving what the original constructed type was. - # If the original type is a Time and the resulting calculation goes out of - # range for Times, then an exception will be raised by the Time class. - def +(seconds) - if seconds == 0 - self - else - if @orig.is_a?(DateTime) - TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds)) - else - # + defined for Time and integer timestamps - TimeOrDateTime.new(@orig + seconds) - end - end - end - - # Subtracts a number of seconds from the TimeOrDateTime. Returns a new - # TimeOrDateTime, preserving what the original constructed type was. - # If the original type is a Time and the resulting calculation goes out of - # range for Times, then an exception will be raised by the Time class. - def -(seconds) - self + (-seconds) - end - - # Similar to the + operator, but for cases where adding would cause a - # timestamp or time to go out of the allowed range, converts to a DateTime - # based TimeOrDateTime. - def add_with_convert(seconds) - if seconds == 0 - self - else - if @orig.is_a?(DateTime) - TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds)) - else - # A Time or timestamp. - result = to_i + seconds - - if result < 0 || result > 2147483647 - result = TimeOrDateTime.new(to_datetime + OffsetRationals.rational_for_offset(seconds)) - else - result = TimeOrDateTime.new(@orig + seconds) - end - end - end - end - - # Returns true if todt represents the same time and was originally - # constructed with the same type (DateTime, Time or timestamp) as this - # TimeOrDateTime. - def eql?(todt) - todt.respond_to?(:to_orig) && to_orig.eql?(todt.to_orig) - end - - # Returns a hash of this TimeOrDateTime. - def hash - @orig.hash - end - - # If no block is given, returns a TimeOrDateTime wrapping the given - # timeOrDateTime. If a block is specified, a TimeOrDateTime is constructed - # and passed to the block. The result of the block must be a TimeOrDateTime. - # to_orig will be called on the result and the result of to_orig will be - # returned. - # - # timeOrDateTime can be a Time, DateTime, integer timestamp or TimeOrDateTime. - # If a TimeOrDateTime is passed in, no new TimeOrDateTime will be constructed, - # the passed in value will be used. - def self.wrap(timeOrDateTime) - t = timeOrDateTime.is_a?(TimeOrDateTime) ? timeOrDateTime : TimeOrDateTime.new(timeOrDateTime) - - if block_given? - t = yield t - - if timeOrDateTime.is_a?(TimeOrDateTime) - t - elsif timeOrDateTime.is_a?(Time) - t.to_time - elsif timeOrDateTime.is_a?(DateTime) - t.to_datetime - else - t.to_i - end - else - t - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone.rb deleted file mode 100644 index f87fb6f..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone.rb +++ /dev/null @@ -1,508 +0,0 @@ -#-- -# Copyright (c) 2005-2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'date' -# require 'tzinfo/country' -require 'tzinfo/time_or_datetime' -require 'tzinfo/timezone_period' - -module TZInfo - # Indicate a specified time in a local timezone has more than one - # possible time in UTC. This happens when switching from daylight savings time - # to normal time where the clocks are rolled back. Thrown by period_for_local - # and local_to_utc when using an ambiguous time and not specifying any - # means to resolve the ambiguity. - class AmbiguousTime < StandardError - end - - # Thrown to indicate that no TimezonePeriod matching a given time could be found. - class PeriodNotFound < StandardError - end - - # Thrown by Timezone#get if the identifier given is not valid. - class InvalidTimezoneIdentifier < StandardError - end - - # Thrown if an attempt is made to use a timezone created with Timezone.new(nil). - class UnknownTimezone < StandardError - end - - # Timezone is the base class of all timezones. It provides a factory method - # get to access timezones by identifier. Once a specific Timezone has been - # retrieved, DateTimes, Times and timestamps can be converted between the UTC - # and the local time for the zone. For example: - # - # tz = TZInfo::Timezone.get('America/New_York') - # puts tz.utc_to_local(DateTime.new(2005,8,29,15,35,0)).to_s - # puts tz.local_to_utc(Time.utc(2005,8,29,11,35,0)).to_s - # puts tz.utc_to_local(1125315300).to_s - # - # Each time conversion method returns an object of the same type it was - # passed. - # - # The timezone information all comes from the tz database - # (see http://www.twinsun.com/tz/tz-link.htm) - class Timezone - include Comparable - - # Cache of loaded zones by identifier to avoid using require if a zone - # has already been loaded. - @@loaded_zones = {} - - # Whether the timezones index has been loaded yet. - @@index_loaded = false - - # Returns a timezone by its identifier (e.g. "Europe/London", - # "America/Chicago" or "UTC"). - # - # Raises InvalidTimezoneIdentifier if the timezone couldn't be found. - def self.get(identifier) - instance = @@loaded_zones[identifier] - unless instance - raise InvalidTimezoneIdentifier, 'Invalid identifier' if identifier !~ /^[A-z0-9\+\-_]+(\/[A-z0-9\+\-_]+)*$/ - identifier = identifier.gsub(/-/, '__m__').gsub(/\+/, '__p__') - begin - # Use a temporary variable to avoid an rdoc warning - file = "tzinfo/definitions/#{identifier}" - require file - - m = Definitions - identifier.split(/\//).each {|part| - m = m.const_get(part) - } - - info = m.get - - # Could make Timezone subclasses register an interest in an info - # type. Since there are currently only two however, there isn't - # much point. - if info.kind_of?(DataTimezoneInfo) - instance = DataTimezone.new(info) - elsif info.kind_of?(LinkedTimezoneInfo) - instance = LinkedTimezone.new(info) - else - raise InvalidTimezoneIdentifier, "No handler for info type #{info.class}" - end - - @@loaded_zones[instance.identifier] = instance - rescue LoadError, NameError => e - raise InvalidTimezoneIdentifier, e.message - end - end - - instance - end - - # Returns a proxy for the Timezone with the given identifier. The proxy - # will cause the real timezone to be loaded when an attempt is made to - # find a period or convert a time. get_proxy will not validate the - # identifier. If an invalid identifier is specified, no exception will be - # raised until the proxy is used. - def self.get_proxy(identifier) - TimezoneProxy.new(identifier) - end - - # If identifier is nil calls super(), otherwise calls get. An identfier - # should always be passed in when called externally. - def self.new(identifier = nil) - if identifier - get(identifier) - else - super() - end - end - - # Returns an array containing all the available Timezones. - # - # Returns TimezoneProxy objects to avoid the overhead of loading Timezone - # definitions until a conversion is actually required. - def self.all - get_proxies(all_identifiers) - end - - # Returns an array containing the identifiers of all the available - # Timezones. - def self.all_identifiers - load_index - Indexes::Timezones.timezones - end - - # Returns an array containing all the available Timezones that are based - # on data (are not links to other Timezones). - # - # Returns TimezoneProxy objects to avoid the overhead of loading Timezone - # definitions until a conversion is actually required. - def self.all_data_zones - get_proxies(all_data_zone_identifiers) - end - - # Returns an array containing the identifiers of all the available - # Timezones that are based on data (are not links to other Timezones).. - def self.all_data_zone_identifiers - load_index - Indexes::Timezones.data_timezones - end - - # Returns an array containing all the available Timezones that are links - # to other Timezones. - # - # Returns TimezoneProxy objects to avoid the overhead of loading Timezone - # definitions until a conversion is actually required. - def self.all_linked_zones - get_proxies(all_linked_zone_identifiers) - end - - # Returns an array containing the identifiers of all the available - # Timezones that are links to other Timezones. - def self.all_linked_zone_identifiers - load_index - Indexes::Timezones.linked_timezones - end - - # Returns all the Timezones defined for all Countries. This is not the - # complete set of Timezones as some are not country specific (e.g. - # 'Etc/GMT'). - # - # Returns TimezoneProxy objects to avoid the overhead of loading Timezone - # definitions until a conversion is actually required. - def self.all_country_zones - Country.all_codes.inject([]) {|zones,country| - zones += Country.get(country).zones - } - end - - # Returns all the zone identifiers defined for all Countries. This is not the - # complete set of zone identifiers as some are not country specific (e.g. - # 'Etc/GMT'). You can obtain a Timezone instance for a given identifier - # with the get method. - def self.all_country_zone_identifiers - Country.all_codes.inject([]) {|zones,country| - zones += Country.get(country).zone_identifiers - } - end - - # Returns all US Timezone instances. A shortcut for - # TZInfo::Country.get('US').zones. - # - # Returns TimezoneProxy objects to avoid the overhead of loading Timezone - # definitions until a conversion is actually required. - def self.us_zones - Country.get('US').zones - end - - # Returns all US zone identifiers. A shortcut for - # TZInfo::Country.get('US').zone_identifiers. - def self.us_zone_identifiers - Country.get('US').zone_identifiers - end - - # The identifier of the timezone, e.g. "Europe/Paris". - def identifier - raise UnknownTimezone, 'TZInfo::Timezone constructed directly' - end - - # An alias for identifier. - def name - # Don't use alias, as identifier gets overridden. - identifier - end - - # Returns a friendlier version of the identifier. - def to_s - friendly_identifier - end - - # Returns internal object state as a programmer-readable string. - def inspect - "#<#{self.class}: #{identifier}>" - end - - # Returns a friendlier version of the identifier. Set skip_first_part to - # omit the first part of the identifier (typically a region name) where - # there is more than one part. - # - # For example: - # - # Timezone.get('Europe/Paris').friendly_identifier(false) #=> "Europe - Paris" - # Timezone.get('Europe/Paris').friendly_identifier(true) #=> "Paris" - # Timezone.get('America/Indiana/Knox').friendly_identifier(false) #=> "America - Knox, Indiana" - # Timezone.get('America/Indiana/Knox').friendly_identifier(true) #=> "Knox, Indiana" - def friendly_identifier(skip_first_part = false) - parts = identifier.split('/') - if parts.empty? - # shouldn't happen - identifier - elsif parts.length == 1 - parts[0] - else - if skip_first_part - result = '' - else - result = parts[0] + ' - ' - end - - parts[1, parts.length - 1].reverse_each {|part| - part.gsub!(/_/, ' ') - - if part.index(/[a-z]/) - # Missing a space if a lower case followed by an upper case and the - # name isn't McXxxx. - part.gsub!(/([^M][a-z])([A-Z])/, '\1 \2') - part.gsub!(/([M][a-bd-z])([A-Z])/, '\1 \2') - - # Missing an apostrophe if two consecutive upper case characters. - part.gsub!(/([A-Z])([A-Z])/, '\1\'\2') - end - - result << part - result << ', ' - } - - result.slice!(result.length - 2, 2) - result - end - end - - # Returns the TimezonePeriod for the given UTC time. utc can either be - # a DateTime, Time or integer timestamp (Time.to_i). Any timezone - # information in utc is ignored (it is treated as a UTC time). - def period_for_utc(utc) - raise UnknownTimezone, 'TZInfo::Timezone constructed directly' - end - - # Returns the set of TimezonePeriod instances that are valid for the given - # local time as an array. If you just want a single period, use - # period_for_local instead and specify how ambiguities should be resolved. - # Returns an empty array if no periods are found for the given time. - def periods_for_local(local) - raise UnknownTimezone, 'TZInfo::Timezone constructed directly' - end - - # Returns the TimezonePeriod for the given local time. local can either be - # a DateTime, Time or integer timestamp (Time.to_i). Any timezone - # information in local is ignored (it is treated as a time in the current - # timezone). - # - # Warning: There are local times that have no equivalent UTC times (e.g. - # in the transition from standard time to daylight savings time). There are - # also local times that have more than one UTC equivalent (e.g. in the - # transition from daylight savings time to standard time). - # - # In the first case (no equivalent UTC time), a PeriodNotFound exception - # will be raised. - # - # In the second case (more than one equivalent UTC time), an AmbiguousTime - # exception will be raised unless the optional dst parameter or block - # handles the ambiguity. - # - # If the ambiguity is due to a transition from daylight savings time to - # standard time, the dst parameter can be used to select whether the - # daylight savings time or local time is used. For example, - # - # Timezone.get('America/New_York').period_for_local(DateTime.new(2004,10,31,1,30,0)) - # - # would raise an AmbiguousTime exception. - # - # Specifying dst=true would the daylight savings period from April to - # October 2004. Specifying dst=false would return the standard period - # from October 2004 to April 2005. - # - # If the dst parameter does not resolve the ambiguity, and a block is - # specified, it is called. The block must take a single parameter - an - # array of the periods that need to be resolved. The block can select and - # return a single period or return nil or an empty array - # to cause an AmbiguousTime exception to be raised. - def period_for_local(local, dst = nil) - results = periods_for_local(local) - - if results.empty? - raise PeriodNotFound - elsif results.size < 2 - results.first - else - # ambiguous result try to resolve - - if !dst.nil? - matches = results.find_all {|period| period.dst? == dst} - results = matches if !matches.empty? - end - - if results.size < 2 - results.first - else - # still ambiguous, try the block - - if block_given? - results = yield results - end - - if results.is_a?(TimezonePeriod) - results - elsif results && results.size == 1 - results.first - else - raise AmbiguousTime, "#{local} is an ambiguous local time." - end - end - end - end - - # Converts a time in UTC to the local timezone. utc can either be - # a DateTime, Time or timestamp (Time.to_i). The returned time has the same - # type as utc. Any timezone information in utc is ignored (it is treated as - # a UTC time). - def utc_to_local(utc) - TimeOrDateTime.wrap(utc) {|wrapped| - period_for_utc(wrapped).to_local(wrapped) - } - end - - # Converts a time in the local timezone to UTC. local can either be - # a DateTime, Time or timestamp (Time.to_i). The returned time has the same - # type as local. Any timezone information in local is ignored (it is treated - # as a local time). - # - # Warning: There are local times that have no equivalent UTC times (e.g. - # in the transition from standard time to daylight savings time). There are - # also local times that have more than one UTC equivalent (e.g. in the - # transition from daylight savings time to standard time). - # - # In the first case (no equivalent UTC time), a PeriodNotFound exception - # will be raised. - # - # In the second case (more than one equivalent UTC time), an AmbiguousTime - # exception will be raised unless the optional dst parameter or block - # handles the ambiguity. - # - # If the ambiguity is due to a transition from daylight savings time to - # standard time, the dst parameter can be used to select whether the - # daylight savings time or local time is used. For example, - # - # Timezone.get('America/New_York').local_to_utc(DateTime.new(2004,10,31,1,30,0)) - # - # would raise an AmbiguousTime exception. - # - # Specifying dst=true would return 2004-10-31 5:30:00. Specifying dst=false - # would return 2004-10-31 6:30:00. - # - # If the dst parameter does not resolve the ambiguity, and a block is - # specified, it is called. The block must take a single parameter - an - # array of the periods that need to be resolved. The block can return a - # single period to use to convert the time or return nil or an empty array - # to cause an AmbiguousTime exception to be raised. - def local_to_utc(local, dst = nil) - TimeOrDateTime.wrap(local) {|wrapped| - if block_given? - period = period_for_local(wrapped, dst) {|periods| yield periods } - else - period = period_for_local(wrapped, dst) - end - - period.to_utc(wrapped) - } - end - - # Returns the current time in the timezone as a Time. - def now - utc_to_local(Time.now.utc) - end - - # Returns the TimezonePeriod for the current time. - def current_period - period_for_utc(Time.now.utc) - end - - # Returns the current Time and TimezonePeriod as an array. The first element - # is the time, the second element is the period. - def current_period_and_time - utc = Time.now.utc - period = period_for_utc(utc) - [period.to_local(utc), period] - end - - alias :current_time_and_period :current_period_and_time - - # Converts a time in UTC to local time and returns it as a string - # according to the given format. The formatting is identical to - # Time.strftime and DateTime.strftime, except %Z is replaced with the - # timezone abbreviation for the specified time (for example, EST or EDT). - def strftime(format, utc = Time.now.utc) - period = period_for_utc(utc) - local = period.to_local(utc) - local = Time.at(local).utc unless local.kind_of?(Time) || local.kind_of?(DateTime) - abbreviation = period.abbreviation.to_s.gsub(/%/, '%%') - - format = format.gsub(/(.?)%Z/) do - if $1 == '%' - # return %%Z so the real strftime treats it as a literal %Z too - '%%Z' - else - "#$1#{abbreviation}" - end - end - - local.strftime(format) - end - - # Compares two Timezones based on their identifier. Returns -1 if tz is less - # than self, 0 if tz is equal to self and +1 if tz is greater than self. - def <=>(tz) - identifier <=> tz.identifier - end - - # Returns true if and only if the identifier of tz is equal to the - # identifier of this Timezone. - def eql?(tz) - self == tz - end - - # Returns a hash of this Timezone. - def hash - identifier.hash - end - - # Dumps this Timezone for marshalling. - def _dump(limit) - identifier - end - - # Loads a marshalled Timezone. - def self._load(data) - Timezone.get(data) - end - - private - # Loads in the index of timezones if it hasn't already been loaded. - def self.load_index - unless @@index_loaded - require 'tzinfo/indexes/timezones' - @@index_loaded = true - end - end - - # Returns an array of proxies corresponding to the given array of - # identifiers. - def self.get_proxies(identifiers) - identifiers.collect {|identifier| get_proxy(identifier)} - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_definition.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_definition.rb deleted file mode 100644 index 39ca8bf..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_definition.rb +++ /dev/null @@ -1,56 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'tzinfo/data_timezone_info' -require 'tzinfo/linked_timezone_info' - -module TZInfo - - # TimezoneDefinition is included into Timezone definition modules. - # TimezoneDefinition provides the methods for defining timezones. - module TimezoneDefinition #:nodoc: - # Add class methods to the includee. - def self.append_features(base) - super - base.extend(ClassMethods) - end - - # Class methods for inclusion. - module ClassMethods #:nodoc: - # Returns and yields a DataTimezoneInfo object to define a timezone. - def timezone(identifier) - yield @timezone = DataTimezoneInfo.new(identifier) - end - - # Defines a linked timezone. - def linked_timezone(identifier, link_to_identifier) - @timezone = LinkedTimezoneInfo.new(identifier, link_to_identifier) - end - - # Returns the last TimezoneInfo to be defined with timezone or - # linked_timezone. - def get - @timezone - end - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_info.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_info.rb deleted file mode 100644 index 68e38c3..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_info.rb +++ /dev/null @@ -1,40 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -module TZInfo - # Represents a timezone defined in a data module. - class TimezoneInfo #:nodoc: - - # The timezone identifier. - attr_reader :identifier - - # Constructs a new TimezoneInfo with an identifier. - def initialize(identifier) - @identifier = identifier - end - - # Returns internal object state as a programmer-readable string. - def inspect - "#<#{self.class}: #@identifier>" - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_offset_info.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_offset_info.rb deleted file mode 100644 index 6a0bbca..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_offset_info.rb +++ /dev/null @@ -1,94 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -module TZInfo - # Represents an offset defined in a Timezone data file. - class TimezoneOffsetInfo #:nodoc: - # The base offset of the timezone from UTC in seconds. - attr_reader :utc_offset - - # The offset from standard time for the zone in seconds (i.e. non-zero if - # daylight savings is being observed). - attr_reader :std_offset - - # The total offset of this observance from UTC in seconds - # (utc_offset + std_offset). - attr_reader :utc_total_offset - - # The abbreviation that identifies this observance, e.g. "GMT" - # (Greenwich Mean Time) or "BST" (British Summer Time) for "Europe/London". The returned identifier is a - # symbol. - attr_reader :abbreviation - - # Constructs a new TimezoneOffsetInfo. utc_offset and std_offset are - # specified in seconds. - def initialize(utc_offset, std_offset, abbreviation) - @utc_offset = utc_offset - @std_offset = std_offset - @abbreviation = abbreviation - - @utc_total_offset = @utc_offset + @std_offset - end - - # True if std_offset is non-zero. - def dst? - @std_offset != 0 - end - - # Converts a UTC DateTime to local time based on the offset of this period. - def to_local(utc) - TimeOrDateTime.wrap(utc) {|wrapped| - wrapped + @utc_total_offset - } - end - - # Converts a local DateTime to UTC based on the offset of this period. - def to_utc(local) - TimeOrDateTime.wrap(local) {|wrapped| - wrapped - @utc_total_offset - } - end - - # Returns true if and only if toi has the same utc_offset, std_offset - # and abbreviation as this TimezoneOffsetInfo. - def ==(toi) - toi.respond_to?(:utc_offset) && toi.respond_to?(:std_offset) && toi.respond_to?(:abbreviation) && - utc_offset == toi.utc_offset && std_offset == toi.std_offset && abbreviation == toi.abbreviation - end - - # Returns true if and only if toi has the same utc_offset, std_offset - # and abbreviation as this TimezoneOffsetInfo. - def eql?(toi) - self == toi - end - - # Returns a hash of this TimezoneOffsetInfo. - def hash - utc_offset.hash ^ std_offset.hash ^ abbreviation.hash - end - - # Returns internal object state as a programmer-readable string. - def inspect - "#<#{self.class}: #@utc_offset,#@std_offset,#@abbreviation>" - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb deleted file mode 100644 index 00888fc..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb +++ /dev/null @@ -1,198 +0,0 @@ -#-- -# Copyright (c) 2005-2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'tzinfo/offset_rationals' -require 'tzinfo/time_or_datetime' - -module TZInfo - # A period of time in a timezone where the same offset from UTC applies. - # - # All the methods that take times accept instances of Time, DateTime or - # integer timestamps. - class TimezonePeriod - # The TimezoneTransitionInfo that defines the start of this TimezonePeriod - # (may be nil if unbounded). - attr_reader :start_transition - - # The TimezoneTransitionInfo that defines the end of this TimezonePeriod - # (may be nil if unbounded). - attr_reader :end_transition - - # The TimezoneOffsetInfo for this period. - attr_reader :offset - - # Initializes a new TimezonePeriod. - def initialize(start_transition, end_transition, offset = nil) - @start_transition = start_transition - @end_transition = end_transition - - if offset - raise ArgumentError, 'Offset specified with transitions' if @start_transition || @end_transition - @offset = offset - else - if @start_transition - @offset = @start_transition.offset - elsif @end_transition - @offset = @end_transition.previous_offset - else - raise ArgumentError, 'No offset specified and no transitions to determine it from' - end - end - - @utc_total_offset_rational = nil - end - - # Base offset of the timezone from UTC (seconds). - def utc_offset - @offset.utc_offset - end - - # Offset from the local time where daylight savings is in effect (seconds). - # E.g.: utc_offset could be -5 hours. Normally, std_offset would be 0. - # During daylight savings, std_offset would typically become +1 hours. - def std_offset - @offset.std_offset - end - - # The identifier of this period, e.g. "GMT" (Greenwich Mean Time) or "BST" - # (British Summer Time) for "Europe/London". The returned identifier is a - # symbol. - def abbreviation - @offset.abbreviation - end - alias :zone_identifier :abbreviation - - # Total offset from UTC (seconds). Equal to utc_offset + std_offset. - def utc_total_offset - @offset.utc_total_offset - end - - # Total offset from UTC (days). Result is a Rational. - def utc_total_offset_rational - unless @utc_total_offset_rational - @utc_total_offset_rational = OffsetRationals.rational_for_offset(utc_total_offset) - end - @utc_total_offset_rational - end - - # The start time of the period in UTC as a DateTime. May be nil if unbounded. - def utc_start - @start_transition ? @start_transition.at.to_datetime : nil - end - - # The end time of the period in UTC as a DateTime. May be nil if unbounded. - def utc_end - @end_transition ? @end_transition.at.to_datetime : nil - end - - # The start time of the period in local time as a DateTime. May be nil if - # unbounded. - def local_start - @start_transition ? @start_transition.local_start.to_datetime : nil - end - - # The end time of the period in local time as a DateTime. May be nil if - # unbounded. - def local_end - @end_transition ? @end_transition.local_end.to_datetime : nil - end - - # true if daylight savings is in effect for this period; otherwise false. - def dst? - @offset.dst? - end - - # true if this period is valid for the given UTC DateTime; otherwise false. - def valid_for_utc?(utc) - utc_after_start?(utc) && utc_before_end?(utc) - end - - # true if the given UTC DateTime is after the start of the period - # (inclusive); otherwise false. - def utc_after_start?(utc) - !@start_transition || @start_transition.at <= utc - end - - # true if the given UTC DateTime is before the end of the period - # (exclusive); otherwise false. - def utc_before_end?(utc) - !@end_transition || @end_transition.at > utc - end - - # true if this period is valid for the given local DateTime; otherwise false. - def valid_for_local?(local) - local_after_start?(local) && local_before_end?(local) - end - - # true if the given local DateTime is after the start of the period - # (inclusive); otherwise false. - def local_after_start?(local) - !@start_transition || @start_transition.local_start <= local - end - - # true if the given local DateTime is before the end of the period - # (exclusive); otherwise false. - def local_before_end?(local) - !@end_transition || @end_transition.local_end > local - end - - # Converts a UTC DateTime to local time based on the offset of this period. - def to_local(utc) - @offset.to_local(utc) - end - - # Converts a local DateTime to UTC based on the offset of this period. - def to_utc(local) - @offset.to_utc(local) - end - - # Returns true if this TimezonePeriod is equal to p. This compares the - # start_transition, end_transition and offset using ==. - def ==(p) - p.respond_to?(:start_transition) && p.respond_to?(:end_transition) && - p.respond_to?(:offset) && start_transition == p.start_transition && - end_transition == p.end_transition && offset == p.offset - end - - # Returns true if this TimezonePeriods is equal to p. This compares the - # start_transition, end_transition and offset using eql? - def eql?(p) - p.respond_to?(:start_transition) && p.respond_to?(:end_transition) && - p.respond_to?(:offset) && start_transition.eql?(p.start_transition) && - end_transition.eql?(p.end_transition) && offset.eql?(p.offset) - end - - # Returns a hash of this TimezonePeriod. - def hash - result = @start_transition.hash ^ @end_transition.hash - result ^= @offset.hash unless @start_transition || @end_transition - result - end - - # Returns internal object state as a programmer-readable string. - def inspect - result = "#<#{self.class}: #{@start_transition.inspect},#{@end_transition.inspect}" - result << ",#{@offset.inspect}>" unless @start_transition || @end_transition - result + '>' - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_transition_info.rb b/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_transition_info.rb deleted file mode 100644 index 6b0669c..0000000 --- a/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_transition_info.rb +++ /dev/null @@ -1,129 +0,0 @@ -#-- -# Copyright (c) 2006 Philip Ross -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -#++ - -require 'date' -require 'tzinfo/time_or_datetime' - -module TZInfo - # Represents an offset defined in a Timezone data file. - class TimezoneTransitionInfo #:nodoc: - # The offset this transition changes to (a TimezoneOffsetInfo instance). - attr_reader :offset - - # The offset this transition changes from (a TimezoneOffsetInfo instance). - attr_reader :previous_offset - - # The numerator of the DateTime if the transition time is defined as a - # DateTime, otherwise the transition time as a timestamp. - attr_reader :numerator_or_time - protected :numerator_or_time - - # Either the denominotor of the DateTime if the transition time is defined - # as a DateTime, otherwise nil. - attr_reader :denominator - protected :denominator - - # Creates a new TimezoneTransitionInfo with the given offset, - # previous_offset (both TimezoneOffsetInfo instances) and UTC time. - # if denominator is nil, numerator_or_time is treated as a number of - # seconds since the epoch. If denominator is specified numerator_or_time - # and denominator are used to create a DateTime as follows: - # - # DateTime.new!(Rational.send(:new!, numerator_or_time, denominator), 0, Date::ITALY) - # - # For performance reasons, the numerator and denominator must be specified - # in their lowest form. - def initialize(offset, previous_offset, numerator_or_time, denominator = nil) - @offset = offset - @previous_offset = previous_offset - @numerator_or_time = numerator_or_time - @denominator = denominator - - @at = nil - @local_end = nil - @local_start = nil - end - - # A TimeOrDateTime instance representing the UTC time when this transition - # occurs. - def at - unless @at - unless @denominator - @at = TimeOrDateTime.new(@numerator_or_time) - else - r = RubyCoreSupport.rational_new!(@numerator_or_time, @denominator) - dt = RubyCoreSupport.datetime_new!(r, 0, Date::ITALY) - @at = TimeOrDateTime.new(dt) - end - end - - @at - end - - # A TimeOrDateTime instance representing the local time when this transition - # causes the previous observance to end (calculated from at using - # previous_offset). - def local_end - @local_end = at.add_with_convert(@previous_offset.utc_total_offset) unless @local_end - @local_end - end - - # A TimeOrDateTime instance representing the local time when this transition - # causes the next observance to start (calculated from at using offset). - def local_start - @local_start = at.add_with_convert(@offset.utc_total_offset) unless @local_start - @local_start - end - - # Returns true if this TimezoneTransitionInfo is equal to the given - # TimezoneTransitionInfo. Two TimezoneTransitionInfo instances are - # considered to be equal by == if offset, previous_offset and at are all - # equal. - def ==(tti) - tti.respond_to?(:offset) && tti.respond_to?(:previous_offset) && tti.respond_to?(:at) && - offset == tti.offset && previous_offset == tti.previous_offset && at == tti.at - end - - # Returns true if this TimezoneTransitionInfo is equal to the given - # TimezoneTransitionInfo. Two TimezoneTransitionInfo instances are - # considered to be equal by eql? if offset, previous_offset, - # numerator_or_time and denominator are all equal. This is stronger than ==, - # which just requires the at times to be equal regardless of how they were - # originally specified. - def eql?(tti) - tti.respond_to?(:offset) && tti.respond_to?(:previous_offset) && - tti.respond_to?(:numerator_or_time) && tti.respond_to?(:denominator) && - offset == tti.offset && previous_offset == tti.previous_offset && - numerator_or_time == tti.numerator_or_time && denominator == tti.denominator - end - - # Returns a hash of this TimezoneTransitionInfo instance. - def hash - @offset.hash ^ @previous_offset.hash ^ @numerator_or_time.hash ^ @denominator.hash - end - - # Returns internal object state as a programmer-readable string. - def inspect - "#<#{self.class}: #{at.inspect},#{@offset.inspect}>" - end - end -end diff --git a/vendor/rails/activesupport/lib/active_support/version.rb b/vendor/rails/activesupport/lib/active_support/version.rb deleted file mode 100644 index 30f598a..0000000 --- a/vendor/rails/activesupport/lib/active_support/version.rb +++ /dev/null @@ -1,9 +0,0 @@ -module ActiveSupport - module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 2 - - STRING = [MAJOR, MINOR, TINY].join('.') - end -end diff --git a/vendor/rails/activesupport/lib/active_support/whiny_nil.rb b/vendor/rails/activesupport/lib/active_support/whiny_nil.rb deleted file mode 100644 index 36fe951..0000000 --- a/vendor/rails/activesupport/lib/active_support/whiny_nil.rb +++ /dev/null @@ -1,58 +0,0 @@ -# Extensions to +nil+ which allow for more helpful error messages for people who -# are new to Rails. -# -# Ruby raises NoMethodError if you invoke a method on an object that does not -# respond to it: -# -# $ ruby -e nil.destroy -# -e:1: undefined method `destroy' for nil:NilClass (NoMethodError) -# -# With these extensions, if the method belongs to the public interface of the -# classes in NilClass::WHINERS the error message suggests which could be the -# actual intended class: -# -# $ script/runner nil.destroy -# ... -# You might have expected an instance of ActiveRecord::Base. -# ... -# -# NilClass#id exists in Ruby 1.8 (though it is deprecated). Since +id+ is a fundamental -# method of Active Record models NilClass#id is redefined as well to raise a RuntimeError -# and warn the user. She probably wanted a model database identifier and the 4 -# returned by the original method could result in obscure bugs. -# -# The flag <tt>config.whiny_nils</tt> determines whether this feature is enabled. -# By default it is on in development and test modes, and it is off in production -# mode. -class NilClass - WHINERS = [::Array] - WHINERS << ::ActiveRecord::Base if defined? ::ActiveRecord - - METHOD_CLASS_MAP = Hash.new - - WHINERS.each do |klass| - methods = klass.public_instance_methods - public_instance_methods - class_name = klass.name - methods.each { |method| METHOD_CLASS_MAP[method.to_sym] = class_name } - end - - # Raises a RuntimeError when you attempt to call +id+ on +nil+. - def id - raise RuntimeError, "Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id", caller - end - - private - def method_missing(method, *args, &block) - raise_nil_warning_for METHOD_CLASS_MAP[method], method, caller - end - - # Raises a NoMethodError when you attempt to call a method on +nil+. - def raise_nil_warning_for(class_name = nil, selector = nil, with_caller = nil) - message = "You have a nil object when you didn't expect it!" - message << "\nYou might have expected an instance of #{class_name}." if class_name - message << "\nThe error occurred while evaluating nil.#{selector}" if selector - - raise NoMethodError, message, with_caller || caller - end -end - diff --git a/vendor/rails/activesupport/lib/active_support/xml_mini.rb b/vendor/rails/activesupport/lib/active_support/xml_mini.rb deleted file mode 100644 index ccd1349..0000000 --- a/vendor/rails/activesupport/lib/active_support/xml_mini.rb +++ /dev/null @@ -1,31 +0,0 @@ -module ActiveSupport - # = XmlMini - # - # To use the much faster libxml parser: - # gem 'libxml-ruby', '=0.9.7' - # XmlMini.backend = 'LibXML' - module XmlMini - extend self - - attr_reader :backend - delegate :parse, :to => :backend - - def backend=(name) - if name.is_a?(Module) - @backend = name - else - require "active_support/xml_mini/#{name.to_s.downcase}.rb" - @backend = ActiveSupport.const_get("XmlMini_#{name}") - end - end - - def with_backend(name) - old_backend, self.backend = backend, name - yield - ensure - self.backend = old_backend - end - end - - XmlMini.backend = 'REXML' -end diff --git a/vendor/rails/activesupport/lib/active_support/xml_mini/libxml.rb b/vendor/rails/activesupport/lib/active_support/xml_mini/libxml.rb deleted file mode 100644 index 3586b24..0000000 --- a/vendor/rails/activesupport/lib/active_support/xml_mini/libxml.rb +++ /dev/null @@ -1,133 +0,0 @@ -require 'libxml' - -# = XmlMini LibXML implementation -module ActiveSupport - module XmlMini_LibXML #:nodoc: - extend self - - # Parse an XML Document string into a simple hash using libxml. - # string:: - # XML Document string to parse - def parse(string) - LibXML::XML.default_keep_blanks = false - - if string.blank? - {} - else - LibXML::XML::Parser.string(string.strip).parse.to_hash - end - end - - end -end - -module LibXML - module Conversions - module Document - def to_hash - root.to_hash - end - end - - module Node - CONTENT_ROOT = '__content__' - LIB_XML_LIMIT = 30000000 # Hardcoded LibXML limit - - # Convert XML document to hash - # - # hash:: - # Hash to merge the converted element into. - def to_hash(hash={}) - if text? - raise LibXML::XML::Error if content.length >= LIB_XML_LIMIT - hash[CONTENT_ROOT] = content - else - sub_hash = insert_name_into_hash(hash, name) - attributes_to_hash(sub_hash) - if array? - children_array_to_hash(sub_hash) - elsif yaml? - children_yaml_to_hash(sub_hash) - else - children_to_hash(sub_hash) - end - end - hash - end - - protected - - # Insert name into hash - # - # hash:: - # Hash to merge the converted element into. - # name:: - # name to to merge into hash - def insert_name_into_hash(hash, name) - sub_hash = {} - if hash[name] - if !hash[name].kind_of? Array - hash[name] = [hash[name]] - end - hash[name] << sub_hash - else - hash[name] = sub_hash - end - sub_hash - end - - # Insert children into hash - # - # hash:: - # Hash to merge the children into. - def children_to_hash(hash={}) - each { |child| child.to_hash(hash) } - attributes_to_hash(hash) - hash - end - - # Convert xml attributes to hash - # - # hash:: - # Hash to merge the attributes into - def attributes_to_hash(hash={}) - each_attr { |attr| hash[attr.name] = attr.value } - hash - end - - # Convert array into hash - # - # hash:: - # Hash to merge the array into - def children_array_to_hash(hash={}) - hash[child.name] = map do |child| - returning({}) { |sub_hash| child.children_to_hash(sub_hash) } - end - hash - end - - # Convert yaml into hash - # - # hash:: - # Hash to merge the yaml into - def children_yaml_to_hash(hash = {}) - hash[CONTENT_ROOT] = content unless content.blank? - hash - end - - # Check if child is of type array - def array? - child? && child.next? && child.name == child.next.name - end - - # Check if child is of type yaml - def yaml? - attributes.collect{|x| x.value}.include?('yaml') - end - - end - end -end - -LibXML::XML::Document.send(:include, LibXML::Conversions::Document) -LibXML::XML::Node.send(:include, LibXML::Conversions::Node) diff --git a/vendor/rails/activesupport/lib/active_support/xml_mini/nokogiri.rb b/vendor/rails/activesupport/lib/active_support/xml_mini/nokogiri.rb deleted file mode 100644 index 1028158..0000000 --- a/vendor/rails/activesupport/lib/active_support/xml_mini/nokogiri.rb +++ /dev/null @@ -1,77 +0,0 @@ -require 'nokogiri' - -# = XmlMini Nokogiri implementation -module ActiveSupport - module XmlMini_Nokogiri #:nodoc: - extend self - - # Parse an XML Document string into a simple hash using libxml / nokogiri. - # string:: - # XML Document string to parse - def parse(string) - if string.blank? - {} - else - doc = Nokogiri::XML(string) - raise doc.errors.first if doc.errors.length > 0 - doc.to_hash - end - end - - module Conversions - module Document - def to_hash - root.to_hash - end - end - - module Node - CONTENT_ROOT = '__content__' - - # Convert XML document to hash - # - # hash:: - # Hash to merge the converted element into. - def to_hash(hash = {}) - hash[name] ||= attributes_as_hash - - walker = lambda { |memo, parent, child, callback| - next if child.blank? && 'file' != parent['type'] - - if child.text? - (memo[CONTENT_ROOT] ||= '') << child.content - next - end - - name = child.name - - child_hash = child.attributes_as_hash - if memo[name] - memo[name] = [memo[name]].flatten - memo[name] << child_hash - else - memo[name] = child_hash - end - - # Recusively walk children - child.children.each { |c| - callback.call(child_hash, child, c, callback) - } - } - - children.each { |c| walker.call(hash[name], self, c, walker) } - hash - end - - def attributes_as_hash - Hash[*(attribute_nodes.map { |node| - [node.node_name, node.value] - }.flatten)] - end - end - end - - Nokogiri::XML::Document.send(:include, Conversions::Document) - Nokogiri::XML::Node.send(:include, Conversions::Node) - end -end diff --git a/vendor/rails/activesupport/lib/active_support/xml_mini/rexml.rb b/vendor/rails/activesupport/lib/active_support/xml_mini/rexml.rb deleted file mode 100644 index a8fdeca..0000000 --- a/vendor/rails/activesupport/lib/active_support/xml_mini/rexml.rb +++ /dev/null @@ -1,108 +0,0 @@ -# = XmlMini ReXML implementation -module ActiveSupport - module XmlMini_REXML #:nodoc: - extend self - - CONTENT_KEY = '__content__'.freeze - - # Parse an XML Document string into a simple hash - # - # Same as XmlSimple::xml_in but doesn't shoot itself in the foot, - # and uses the defaults from ActiveSupport - # - # string:: - # XML Document string to parse - def parse(string) - require 'rexml/document' unless defined?(REXML::Document) - doc = REXML::Document.new(string) - merge_element!({}, doc.root) - end - - private - # Convert an XML element and merge into the hash - # - # hash:: - # Hash to merge the converted element into. - # element:: - # XML element to merge into hash - def merge_element!(hash, element) - merge!(hash, element.name, collapse(element)) - end - - # Actually converts an XML document element into a data structure. - # - # element:: - # The document element to be collapsed. - def collapse(element) - hash = get_attributes(element) - - if element.has_elements? - element.each_element {|child| merge_element!(hash, child) } - merge_texts!(hash, element) unless empty_content?(element) - hash - else - merge_texts!(hash, element) - end - end - - # Merge all the texts of an element into the hash - # - # hash:: - # Hash to add the converted emement to. - # element:: - # XML element whose texts are to me merged into the hash - def merge_texts!(hash, element) - unless element.has_text? - hash - else - # must use value to prevent double-escaping - merge!(hash, CONTENT_KEY, element.texts.sum(&:value)) - end - end - - # Adds a new key/value pair to an existing Hash. If the key to be added - # already exists and the existing value associated with key is not - # an Array, it will be wrapped in an Array. Then the new value is - # appended to that Array. - # - # hash:: - # Hash to add key/value pair to. - # key:: - # Key to be added. - # value:: - # Value to be associated with key. - def merge!(hash, key, value) - if hash.has_key?(key) - if hash[key].instance_of?(Array) - hash[key] << value - else - hash[key] = [hash[key], value] - end - elsif value.instance_of?(Array) - hash[key] = [value] - else - hash[key] = value - end - hash - end - - # Converts the attributes array of an XML element into a hash. - # Returns an empty Hash if node has no attributes. - # - # element:: - # XML element to extract attributes from. - def get_attributes(element) - attributes = {} - element.attributes.each { |n,v| attributes[n] = v } - attributes - end - - # Determines if a document element has text content - # - # element:: - # XML element to be checked. - def empty_content?(element) - element.texts.join.blank? - end - end -end diff --git a/vendor/rails/activesupport/lib/activesupport.rb b/vendor/rails/activesupport/lib/activesupport.rb deleted file mode 100644 index 69f36f7..0000000 --- a/vendor/rails/activesupport/lib/activesupport.rb +++ /dev/null @@ -1 +0,0 @@ -require 'active_support' diff --git a/vendor/rails/railties/CHANGELOG b/vendor/rails/railties/CHANGELOG deleted file mode 100644 index e8e8434..0000000 --- a/vendor/rails/railties/CHANGELOG +++ /dev/null @@ -1,2156 +0,0 @@ -*2.3.2 [Final] (March 15, 2009)* - -* Allow metal to live in plugins #2045 [Matthew Rudy] - -* Added metal [Josh Peek] - -* Remove script/performance/request in favour of the performance integration tests. [Pratik Naik] - - To continue using script/performance/request, install the request_profiler plugin : - - script/plugin install git://github.com/rails/request_profiler.git - -* Add a rake task to apply a template to an existing application : rake rails:template LOCATION=~/template.rb [Pratik Naik] - -* Add "-m/--template" option to Rails generator to apply a template to the generated application. [Jeremy McAnally] - - This has been extracted from rg - http://github.com/jeremymcanally/rg - - Example: - - # template.rb - - # Install plugins from git or svn - plugin "will-paginate", :git => "git://github.com/mislav/will_paginate.git" - plugin "old-restful-auth", :svn => "http://svn.techno-weenie.net/projects/plugins/restful_authentication/" - - # Add gems to environment.rb - gem "jeremymcanally-context" - gem "bluecloth" - - # Vendor file. Data in a string or... - vendor("borrowed.rb", <<CODE - def helpful_method - do_something_helpful_here - end - CODE - - # ...file data from block return value. - # #initializer creates a new initializer file - initializer("crypto.rb") do - salt = "--#{Time.now}--#{rand}--#{srand(Time.now.to_i)}" - - "SPECIAL_SALT = '#{salt}'" - end - - Usage: - - To use a template, provide a file path or URL: - - 1. Using a local file : - - rails <application name> -m /path/to/my/template.rb - - 2. Or directly from a URL : - - rails <application name> --template=http://gist.github.com/31208.txt - -* Extracted the process scripts (inspector, reaper, spawner) into the plugin irs_process_scripts [David Heinemeier Hansson] - -* Changed Rails.root to return a Pathname object (allows for Rails.root.join('app', 'controllers') => "#{RAILS_ROOT}/app/controllers") #1482 [Damian Janowski/?] - -* Added view path support for engines [David Heinemeier Hansson] - -* Added that config/routes.rb files in engine plugins are automatically loaded (and reloaded when they change in dev mode) [David Heinemeier Hansson] - -* Added app/[models|controllers|helpers] to the load path for plugins that has an app directory (go engines ;)) [David Heinemeier Hansson] - -* Add config.preload_frameworks to load all frameworks at startup. Default to false so Rails autoloads itself as it's used. Turn this on for Passenger and JRuby. Also turned on by config.threadsafe! [Jeremy Kemper] - -* Add a rake task to generate dispatchers : rake rails:generate_dispatchers [Pratik Naik] - -* "rails <app>" will not generate public/dispatch.cgi/fcgi/rb files by default now. Please use "--with-dispatchers" option if you need them. [Yaroslav Markin, Pratik Naik] - -* Added rake rails:update:application_controller to renamed application.rb to application_controller.rb -- included in rake rails:update so upgrading to 2.3 will automatically trigger it #1439 [kastner] - -* Added Rails.backtrace_cleaner as an accessor for the Rails::BacktraceCleaner instance used by the framework to cut down on backtrace noise and config/initializers/backtrace_silencers.rb to add your own (or turn them all off) [David Heinemeier Hansson] - -* Switch from Test::Unit::TestCase to ActiveSupport::TestCase. [Jeremy Kemper] - -* Added config.i18n settings gatherer to config/environment, auto-loading of all locales in config/locales/*.rb,yml, and config/locales/en.yml as a sample locale [David Heinemeier Hansson] - -* BACKWARDS INCOMPATIBLE: Renamed application.rb to application_controller.rb and removed all the special casing that was in place to support the former. You must do this rename in your own application when you upgrade to this version [David Heinemeier Hansson] - - -*2.2.1 [RC2] (November 14th, 2008)* - -* Fixed plugin generator so that generated unit tests would subclass ActiveSupport::TestCase, also introduced a helper script to reduce the needed require statements #1137 [Mathias Meyer] - -* Update Prototype to 1.6.0.3 [sam] - - -*2.2.0 [RC1] (October 24th, 2008)* - -* Fixed that sqlite would report "db/development.sqlite3 already exists" whether true or not on db:create #614 [Antonio Cangiano] - -* Added config.threadsafe! to toggle allow concurrency settings and disable the dependency loader [Josh Peek] - -* Turn cache_classes on by default [Josh Peek] - -* Added configurable eager load paths. Defaults to app/models, app/controllers, and app/helpers [Josh Peek] - -* Introduce simple internationalization support. [Ruby i18n team] - -* Make script/plugin install <plugin> -r <revision> option work with git based plugins. #257. [Tim Pope Jakub Kuźma]. Example: - - script/plugin install git://github.com/mislav/will_paginate.git -r agnostic # Installs 'agnostic' branch - script/plugin install git://github.com/dchelimsky/rspec.git -r 'tag 1.1.4' - -* Added Rails.initialized? flag [Josh Peek] - -* Make rake test:uncommitted work with Git. [Tim Pope] - -* Added Thin support to script/server. #488 [Bob Klosinski] - -* Fix script/about in production mode. #370 [Cheah Chu Yeow, Xavier Noria, David Krmpotic] - -* Add the gem load paths before the framework is loaded, so certain gems like RedCloth and BlueCloth can be frozen. - -* Fix discrepancies with loading rails/init.rb from gems. - -* Plugins check for the gem init path (rails/init.rb) before the standard plugin init path (init.rb) [Jacek Becela] - -* Changed all generated tests to use the test/do declaration style [David Heinemeier Hansson] - -* Wrapped Rails.env in StringInquirer so you can do Rails.env.development? [David Heinemeier Hansson] - -* Fixed that RailsInfoController wasn't considering all requests local in development mode (Edgard Castro) [#310 state:resolved] - - -*2.1.0 (May 31st, 2008)* - -* script/dbconsole fires up the command-line database client. #102 [Steve Purcell] - -* Fix bug where plugin init.rb files from frozen gem specs weren't being run. (pjb3) [#122 state:resolved] - -* Made the location of the routes file configurable with config.routes_configuration_file (Scott Fleckenstein) [#88] - -* Rails Edge info returns the latest git commit hash [Francesc Esplugas] - -* Added Rails.public_path to control where HTML and assets are expected to be loaded from (defaults to Rails.root + "/public") #11581 [Nick Sieger] - -* rake time:zones:local finds correct base utc offset for zones in the Southern Hemisphere [Geoff Buesing] - -* Don't require rails/gem_builder during rails initialization, it's only needed for the gems:build task. [Rick Olson] - -* script/performance/profiler compatibility with the ruby-prof >= 0.5.0. Closes #9176. [Jonathan del Strother] - -* Flesh out rake gems:unpack to unpack all gems, and add rake gems:build for native extensions. #11513 [ddollar] - - rake gems:unpack # unpacks all gems - rake gems:unpack GEM=mygem # unpacks only the gem 'mygem' - - rake gems:build # builds all unpacked gems - rake gems:build GEM=mygem # builds only the gem 'mygem' - -* Add config.active_support for future configuration options. Also, add more new Rails 3 config settings to new_rails_defaults.rb [Rick Olson] - -* Add Rails.logger, Rails.root, Rails.env and Rails.cache shortcuts for RAILS_* constants [Pratik Naik] - -* Allow files in plugins to be reloaded like the rest of the application. [Rick Olson] - - Enables or disables plugin reloading. - - config.reload_plugins = true - - You can get around this setting per plugin. - If #reload_plugins? == false (DEFAULT), add this to your plugin's init.rb to make it reloadable: - - Dependencies.load_once_paths.delete lib_path - - If #reload_plugins? == true, add this to your plugin's init.rb to only load it once: - - Dependencies.load_once_paths << lib_path - -* Small tweak to allow plugins to specify gem dependencies. [Rick Olson] - - # OLD open_id_authentication plugin init.rb - require 'yadis' - require 'openid' - ActionController::Base.send :include, OpenIdAuthentication - - # NEW - config.gem "ruby-openid", :lib => "openid", :version => "1.1.4" - config.gem "ruby-yadis", :lib => "yadis", :version => "0.3.4" - - config.after_initialize do - ActionController::Base.send :include, OpenIdAuthentication - end - -* Added config.gem for specifying which gems are required by the application, as well as rake tasks for installing and freezing gems. [Rick Olson] - - Rails::Initializer.run do |config| - config.gem "bj" - config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net" - config.gem "aws-s3", :lib => "aws/s3" - end - - # List required gems. - rake gems - - # Install all required gems: - rake gems:install - - # Unpack specified gem to vendor/gems/gem_name-x.x.x - rake gems:unpack GEM=bj - -* Removed the default .htaccess configuration as there are so many good deployment options now (kept it as an example in README) [David Heinemeier Hansson] - -* config.time_zone accepts TZInfo::Timezone identifiers as well as Rails TimeZone identifiers [Geoff Buesing] - -* Rails::Initializer#initialize_time_zone raises an error if value assigned to config.time_zone is not recognized. Rake time zone tasks only require ActiveSupport instead of entire environment [Geoff Buesing] - -* Stop adding the antiquated test/mocks/* directories and only add them to the path if they're still there for legacy reasons [David Heinemeier Hansson] - -* Added that gems can now be plugins if they include rails/init.rb #11444 [John Barnette] - -* Added Plugin#about method to programmatically access the about.yml in a plugin #10979 [James Adam] - - plugin = Rails::Plugin.new(path_to_my_plugin) - plugin.about["author"] # => "James Adam" - plugin.about["url"] # => "http://interblah.net" - -* Improve documentation. [Ryan Bigg, Jan De Poorter, Cheah Chu Yeow, Xavier Shay, Jack Danger Canty, Emilio Tagua, Xavier Noria, Sunny Ripert] - -* Added config.time_zone = 'UTC' in the default environment.rb [Geoff Buesing] - -* Added rake tasks time:zones:all, time:zones:us and time:zones:local for finding time zone names for config.time_zone option [Geoff Buesing] - -* Add config.time_zone for configuring the default Time.zone value. #10982 [Geoff Buesing] - -* Added support for installing plugins hosted at git repositories #11294 [Jack Danger Canty] - -* Fixed that script/generate would not look for plugin generators in plugin_paths #11000 [glv] - -* Fixed database rake tasks to work with charset/collation and show proper error messages on failure. Closes #11301 [matt] - -* Added a -e/--export to script/plugin install, uses svn export. #10847 [jon@blankpad.net)] - -* Reshuffle load order so that routes and observers are initialized after plugins and app initializers. Closes #10980 [Rick Olson] - -* Git support for script/generate. #10690 [ssoroka] - -* Update scaffold to use labels instead of bold tags. Closes #10757 [zach-inglis-lt3] - -* Resurrect WordNet synonym lookups. #10710 [tom./, matt] - -* Added config.cache_store to environment options to control the default cache store (default is FileStore if tmp/cache is present, otherwise MemoryStore is used) [David Heinemeier Hansson] - -* Added that rails:update is run when you do rails:freeze:edge to ensure you also get the latest JS and config files #10565 [jeff] - -* SQLite: db:drop:all doesn't fail silently if the database is already open. #10577 [Cheah Chu Yeow, mrichman] - -* Introduce native mongrel handler and push mutex into dispatcher. [Jeremy Kemper] - -* Ruby 1.9 compatibility. #1689, #10546 [Cheah Chu Yeow, frederico] - - -*2.0.2* (December 16th, 2007) - -* Changed the default database from mysql to sqlite3, so now running "rails myapp" will have a config/database.yml that's setup for SQLite3 (which in OS X Leopard is installed by default, so is the gem, so everything Just Works with no database configuration at all). To get a Rails application preconfigured for MySQL, just run "rails -d mysql myapp" [David Heinemeier Hansson] - -* Turned on ActionView::Base.cache_template_loading by default in config/environments/production.rb to prevent file system stat calls for every template loading to see if it changed (this means that you have to restart the application to see template changes in production mode) [David Heinemeier Hansson] - -* Introduce `rake secret` to output a crytographically secure secret key for use with cookie sessions #10363 [revans] - -* Fixed that local database creation should consider 127.0.0.1 local #9026 [parcelbrat] - -* Fixed that functional tests generated for scaffolds should use fixture calls instead of hard-coded IDs #10435 [boone] - -* Added db:migrate:redo and db:migrate:reset for rerunning existing migrations #10431, #10432 [matt] - -* RAILS_GEM_VERSION may be double-quoted also. #10443 [James Cox] - -* Update rails:freeze:gems to work with RubyGems 0.9.5. [Jeremy Kemper] - - -*2.0.1* (December 7th, 2007) - -* Fixed Active Record bug - - -*2.0.0* (December 6th, 2007) - -* The test task stops with a warning if you have pending migrations. #10377 [Josh Knowles] - -* Add warning to documentation about using transactional fixtures when the code under test uses transactions itself. Closes #7548 [Thijs van der Vossen] - -* Update Prototype to 1.6.0.1. [sam] - -* Update script.aculo.us to 1.8.0.1. [madrobby] - -* Added db:fixtures:identity as a way of locating what ID a foxy fixture was assigned #10332 [John Barnette] - -* Generated fixtures should not specify ids since theyre expected to be foxy fixtures #10330 [John Barnette] - -* Update to Prototype -r8232. [sam] - -* Introduce SecretKeyGenerator for more secure session secrets than CGI::Session's pseudo-random id generator. Consider extracting to Active Support later. #10286 [Hongli Lai (Phusion)] - -* RAILS_GEM_VERSION may be set to any valid gem version specifier. #10057 [Chad Woolley, Cheah Chu Yeow] - -* Load config/preinitializer.rb, if present, before loading the environment. #9943 [Chad Woolley] - -* FastCGI handler ignores unsupported signals like USR2 on Windows. [Grzegorz Derebecki] - -* Only load ActionMailer::TestCase if ActionMailer is loaded. Closes #10137 [defunkt] - -* Fixed that db:reset would use migrations instead of loading db/schema.rb [David Heinemeier Hansson] - -* Ensure the plugin loader only loads plugins once. Closes #10102 [haruki_zaemon] - -* Refactor Plugin Loader. Add plugin lib paths early, and add lots of tests. Closes #9795 [James Adam] - -* Added --skip-timestamps to generators that produce models #10036 [Tim Pope] - -* Update Prototype to 1.6.0 and script.aculo.us to 1.8.0. [sam, madrobby] - -* Added db:rollback to rollback the schema one version (or multiple as specified by STEP) [Jeffrey Allan Hardy] - -* Fix typo in test_helper. Closes #9925 [viktor tron] - -* Request profiler. [Jeremy Kemper] - -* config/boot.rb correctly detects RAILS_GEM_VERSION. #9834 [alexch, thewoolleyman] - -* Fixed incorrect migration number if script/generate executed outside of Rails root #7080 [Jeremy McAnally] - -* Update Prototype to 1.6.0_rc1 and script.aculo.us to 1.8.0 preview 0. [sam, madrobby] - -* Generated fixtures use the actual primary key instead of id. #4343 [Frederick Ros, Tarmo Tänav] - -* Extend the console +helper+ method to allow you to include custom helpers. e.g: - >> helper :posts - >> helper.some_method_from_posts_helper(Post.find(1)) - -* db:create works with remote databases whereas db:create:all only creates -databases on localhost. #9753 [Trevor Wennblom] - -* Removed calls to fixtures in generated tests as fixtures :all is now present by default in test_helper.rb [David Heinemeier Hansson] - -* Add --prefix option to script/server when using mongrel. [dacat] - - -*2.0.0 [Preview Release]* (September 29th, 2007) [Includes duplicates of changes from 1.1.4 - 1.2.3] - -* Fixed that installing plugins from SVN repositories that use trunk/ will work #8188 [evan] - -* Moved the SourceAnnotationExtractor to a separate file in case libraries try to load the rails rake tasks twice. [Rick Olson] - -* Moved Dispatcher to ActionController::Dispatcher. [Jeremy Kemper] - -* Changed the default logger from Ruby's own Logger with the clean_logger extensions to ActiveSupport::BufferedLogger for performance reasons [David Heinemeier Hansson]. (You can change it back with config.logger = Logger.new("/path/to/log", level).) - -* Added a default 422.html page to be rendered when ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved, or ActionController::InvalidAuthenticityToken is raised [David Heinemeier Hansson] - -* Added --skip-fixture option to script/generate model #6862 [sandofsky] - -* Print Rails version when starting console #7440 [eyematz] - -* Fixed the placement of fixture files for nested models when generating through script/generate model #7547 [jkit] - -* Added TEMPLATE option to rake doc:app to set a custom output template #7737 [Jakob Skjerning] - -* Added VERBOSE option to rake db:migrate to turn off output #8204 [John Barnette] - -* Fixed that rake doc:app should use UTF-8 #8906 [farzy] - -* Fixes rake annotations to search erb and builder files as well #9150 [m.langenberg] - -* Removed web_service generator [Michael Koziarski] - -* Added the :all option to config.plugins that'll include the rest of the plugins not already explicitly named #9613 [Frederick Cheung]. Example: - - # Loads :classic_pagination before all the other plugins - config.plugins = [ :classic_pagination, :all ] - -* Added symbols as a legal way of specifying plugins in config.plugins #9629 [tom] - -* Removed deprecated task names, like clear_logs, in favor of the new namespaced style [David Heinemeier Hansson] - -* Support multiple config.after_initialize blocks so plugins and apps can more easily cooperate. #9582 [Zach Dennis] - -* Added db:drop:all to drop all databases declared in config/database.yml [David Heinemeier Hansson] - -* Use attribute pairs instead of the migration name to create add and remove column migrations. Closes #9166 [Pratik Naik] - - For example: - - ruby script/generation migration AddSomeStuffToCustomers first_name:string last_name:string - - or - - ruby script/generation migration RemoveSomeStuffFromCustomers first_name:string last_name:string - -* Add ActiveResource to Rails::Info. Closes #8741 [Chris Kampmeier] - -* use Gem.find_name instead of search when freezing gems. Prevent false positives for other gems with rails in the name. Closes #8729 [wselman] - -* Automatically generate add/remove column commands in specially named migrations like AddLocationToEvent. Closes #9006 [Ryan Davis] - -* Default to plural table name in Rails Generator if ActiveRecord is not present. Closes #8963 [evan] - -* Added rake routes for listing all the defined routes in the system. #8795 [Josh Peek] - -* db:create creates the database for the current environment if it's on localhost. db:create:all creates local databases for all environments. #8783 [matt] - -* Generators: look for generators in all gems, not just those suffixed with _generator, in the gem's generators or rails_generators directory. Allow use of the rails_generators directory instead of the standard generators directory in plugins also. #8730 [Dr Nic, topfunky] - -* MySQL, PostgreSQL: database.yml defaults to utf-8. #8701 [matt] - -* Added db:version to get the current schema number [via Err The Blog] - -* Added --skip-migration option to scaffold and resource generators #8656 [Michael Glaesemann] - -* Fix that FCGIs would leave log files open when asked to shut down by USR2. #3028 [Sebastian Kanthak, Josh Peek] - -* Fixed that dispatcher preparation callbacks only run once in production mode. Mock Routes.reload so that dispatcher preparation callback tests run. [Rick Olson] - -* Fix syntax error in dispatcher than wrecked failsafe responses. #8625 [mtitorenko] - -* Scaffolded validation errors set the appropriate HTTP status for XML responses. #6946, #8622 [Manfred Stienstra, mmmultiworks] - -* Sexy migrations for the session_migration generator. #8561 [Vladislav] - -* Console reload! runs to_prepare callbacks also. #8393 [f.svehla] - -* Generated migrations include timestamps by default. #8501 [Shane Vitarana] - -* Drop Action Web Service from rails:freeze:edge. [Jeremy Kemper] - -* Add db:create, drop, reset, charset, and collation tasks. #8448 [matt] - -* Scaffold generator depends on model generator instead of duplicating it. #7222 [bscofield] - -* Scaffold generator tests. #8443 [pelle] - -* Generated scaffold functional tests use assert_difference. #8421 [Norbert Crombach] - -* Update to Prototype 1.5.1. [Sam Stephenson] - -* Update to script.aculo.us 1.7.1_beta3. [Thomas Fuchs] - -* Generators use *.html.erb view template naming. #8278 [Tim Pope] - -* Updated resource_scaffold and model generators to use short-hand style migrations [David Heinemeier Hansson] - -* Updated initializer to only load #{RAILS_ENV}.rb once. Added deprecation warning for config.breakpoint_server. [Nicholas Seckar] - -* Removed breakpointer and Binding.of_caller in favor of relying on ruby-debug by Kent Sibilev since the breakpointer has been broken since Ruby 1.8.4 and will not be coming back [David Heinemeier Hansson] - - To use the new debugger, start your server with script/server --debugger and insert a call to 'debugger' - (instead of 'breakpoint') where you want to jump into the debugger. - - BACKWARDS INCOMPATIBILITY NOTE: You must remove the default line 12 from config/environments/development.rb: - - config.breakpoint_server = true - - This configuration option is no longer available. Rails will fail to start in development mode as long as - that's still present. - -* Resource scaffolding returns the created entity.to_xml. [Jeremy Kemper] - -* Resource scaffolding responds to new.xml. #8185 [Eric Mill] - -* Include Active Resource in rails:freeze:edge rake task. [Thomas Fuchs] - -* Include Active Resource instead of Action Web Service [David Heinemeier Hansson] You can add AWS back with this in config/environment.rb: - - config.load_paths += %W( #{RAILS_ROOT}/vendor/rails/actionwebservice/lib ) - - ...or just gem 'actionwebservice' - -* Give generate scaffold a more descriptive database message. Closes #7316 [Jeremy McAnally] - -* Canonicalize RAILS_ROOT by using File.expand_path on Windows, which doesn't have to worry about symlinks, and Pathname#realpath elsewhere, which respects symlinks in relative paths but is incompatible with Windows. #6755 [Jeremy Kemper, trevor] - -* Deprecation: remove components from controller paths. [Jeremy Kemper] - -* Add environment variable RAILS_DEFAULT_DATABASE, which allows the builtin default of 'mysql' to be overridden. [Nicholas Seckar] - -* Windows: include MinGW in RUBY_PLATFORM check. #2982 [okkez000@gmail.com, Kaspar Schiess] - -* Split out the basic plugin locator functionality into an abstract super class. Add a FileSystemLocator to do the job of checking the plugin_paths for plugins. Add plugin_locators configuration option which will iterate over the set of plugin locators and load each of the plugin loaders they return. Rename locater everywhere to locator. [Marcel Molina Jr.] - -* Split plugin location and loading out of the initializer and into a new Plugin namespace, which includes Plugin::Locater and Plugin::Loader. The loader class that is used can be customized using the config.plugin_loader option. Those monkey patching the plugin loading subsystem take note, the internals changing here will likely break your modifications. The good news is that it should be substantially easier to hook into the plugin locating and loading process now. [Marcel Molina Jr.] - -* Added assumption that all plugin creators desire to be sharing individuals and release their work under the MIT license [David Heinemeier Hansson] - -* Added source-annotations extractor tasks to rake [Jamis Buck]. This allows you to add FIXME, OPTIMIZE, and TODO comments to your source code that can then be extracted in concert with rake notes (shows all), rake notes:fixme, rake notes:optimize and rake notes:todo. - -* Added fixtures :all to test_helper.rb to assume that most people just want all their fixtures loaded all the time [David Heinemeier Hansson] - -* Added config/initializers where all ruby files within it are automatically loaded after the Rails configuration is done, so you don't have to litter the environment.rb file with a ton of mixed stuff [David Heinemeier Hansson] - -* For new apps, generate a random secret for the cookie-based session store. [Jeremy Kemper] - -* Stop swallowing errors during rake test [Michael Koziarski] - -* Update Rails Initializer to use ActionController::Base#view_paths [Rick Olson] - -* Fix gem deprecation warnings, which also means depending on RubyGems 0.9.0+ [Chad Fowler] - -* Plugins may be symlinked in vendor/plugins. #4245 [brandon, progrium@gmail.com] - -* Resource generator depends on the model generator rather than duplicating it. #7269 [bscofield] - -* Add/Update usage documentation for script/destroy, resource generator and scaffold_resource generator. Closes #7092, #7271, #7267. [bscofield] - -* Update to script.aculo.us 1.7.0. [Thomas Fuchs] - -* Update to Prototype 1.5.0. [Sam Stephenson] - -* Generator: use destination path for diff tempfiles. #7015 [alfeld] - -* Fixed that webrick would strip leading newlines and hang connection #4156 [psross] - -* Ensure plugins are in the Dependencies.load_once_paths collection by default. [Rick Olson] - If you really want your plugins to reload, add this to the very top of init.rb: - - Dependencies.load_once_paths.delete(lib_path) - -* Allow config.to_prepare to work, make the dispatcher safe to 're require'. [Michael Koziarski, Nicholas Seckar] - -* Fix scaffold_resource generator so it respects the --pretend argument when creating the routes file. Closes #6852 [fearoffish] - -* Fix Webrick Daemon dispatching bug regarding a bad current working directory. Closes #4899 [Rick Olson] - -* Make config.plugins affect the load path and the dependencies system. Allows you to control plugin loading order, and keep disabled plugins off the load path. [James Adam] - -* Don't generate a components directory in new Rails apps. [Jeremy Kemper] - -* Fixed script/process/spawner to work properly with Mongrel including in -r (daemonize mode) [David Heinemeier Hansson] - -* Added one-letter aliases for the three default environments to script/console, so script/console p will load the production environment (t for test, d for development) [David Heinemeier Hansson] - -* Fixed that script/server running against Mongrel should tail the proper log regardless of the environment [David Heinemeier Hansson] - -* Update initializer to load Rails::VERSION as soon as possible. Closes #6698. [Nicholas Seckar] - -* Added ActiveRecord::Base.clear_active_connections! in development mode so the database connection is not carried over from request to request. Some databases won't reread the schema if that doesn't happen (I'm looking at you SQLite), so you have to restart the server after each migration (= no fun) [David Heinemeier Hansson] - -* Made RAILS_GEM_VERSION work for beta gems too, so specifying 1.1.6 will give you 1.1.6.4520 if available [David Heinemeier Hansson] - -* Update to Prototype and script.aculo.us [5579]. [Thomas Fuchs] - -* Made script/server work with -e and -d when using Mongrel [David Heinemeier Hansson] - -* Update to Prototype 1.5.0_rc2 [5550] which makes it work in Opera again [Thomas Fuchs] - -* Make sure that exceptions which are thrown outside of the user code try their best to be handeled in ApplicationController#rescue_action [Tobias Lütke] - -* Rails::VERSION::STRING should always be available without having to require 'rails/version'. #6244 [fearoffish] - -* Update to Prototype 1.5.0_rc2. [Sam Stephenson] - -* Add grep-based fallback to reaper, to work in pidless setups [Jamis Buck] - -* Only wrap request processing with our USR1 signal handler so FastCGI can trap it and raise an exception while waiting for connections. Idle processes exit immediately rather than waiting for another request; active processes gracefully exit when the request is finished. [Jeremy Kemper] - -* Alter prior change to use require_dependency instead of require_or_load. Causes ApplicationController to be reloaded again. Closes #6587. [Nicholas Seckar] - -* Rake: use absolute paths to load lib and vendor tasks so they may be run outside of RAILS_ROOT. #6584 [jchris] - -* Remove temporary crutch to help ApplicationController be unloaded. Closes #6496. [Nicholas Seckar] - -* scaffold_resource generator uses _path named routes and head instead of render :nothing => true. #6545 [Josh Susser] - -* Generator can show diff on file collision to help you decide whether to skip or overwrite. #6364 [jeffw, Jeremy Kemper] - -* Generated directories are recursively svn added, like mkdir -p. #6416 [NeilW] - -* resource and scaffold_resource generators add a restful route to config/routes.rb [Jeremy Kemper] - -* Revert environment changes for autoload_paths. [Michael Koziarski] - -* Update to latest Prototype, which doesn't serialize disabled form elements, adds clone() to arrays, empty/non-string Element.update() and adds a fixes excessive error reporting in WebKit beta versions [Thomas Fuchs] - -* Clean up the output of rake stats, de-emphasise components and apis, and remove the indents for tests [Michael Koziarski] - -* Added option to script/process/spawner of specifying the binding address #5133 [Dee Zsombor] - -* Update environment.rb comments to include config.autoload_paths. Closes #6478 [caio] - -* Update scaffold to use new form_tag block functionality. Closes #6480. [Bob Silva] - -* Plugin generator: check for class collisions. #4833 [vinbarnes@gmail.com] - -* Mailer generator: handle mailers in modules, set mime_version in unit test. [Jeremy Kemper] - -* Set $KCODE to 'u' by default to enable the multibyte safe String#chars proxy. [Michael Koziarski] - -* Added config.plugins to control which plugins are loaded #6269 [Stefan Kaes]. By default, everything in vendor/plugins will be loaded, but if you specify config.plugins, only those will be loaded. Example: - - config.plugins = %w[ routing_navigator simply_helpful ] - -* Clean up html on included error pages. [Tim Lucas] - -* Fixed default 404.html and 500.htmls to remove extreme ugliness and include human language [David Heinemeier Hansson] - -* Update to latest Prototype and script.aculo.us trunk versions [Thomas Fuchs] - -* PostgreSQL: db:test:purge closes open database connections first. #6236 [alex] - -* Fixed test:uncommitted on Windows (backslash issue) #4999 [paul@paulbutcher.com] - -* Fixed migration creation to work with namespaced models, so script/generate model Gallery::Image will use create_table :gallery_images #6327 [Bob Silva] - -* Fixed rename_table on SQLite tables with indexes defined #5942 [brandon@opensoul.org] - -* Added default timeout setting of 5 seconds to SQLite3 database.yml configurations [David Heinemeier Hansson] - -* Added generated attribute options to script/generate model, like the one found in scaffold_resource and resource [David Heinemeier Hansson]. Examples: - - ./script/generate model post title:string created_on:date body:text published:boolean - -* Added script/generate resource which works just like scaffold_resource, but creates empty placeholders instead of predefined [David Heinemeier Hansson] - -* script/runner can run files, pass on arguments, and be used as a shebang. #6286 [Tuxie, dlpond] - #!/usr/bin/env /path/to/my/app/script/runner - # Example: just start using your models as if you are in script/console - Product.find(:all).each { |product| product.check_inventory } - -* Look for rake tasks in plugin subdirs. #6259 [obrie] - -* Added map.connect ':controller/:action/:id.:format' as a default route to config/routes.rb [David Heinemeier Hansson] - -* Updated prototype.js to 1.5.0_rc1 with latest fixes. [Rick Olson] - - - XPATH support - - Make Form.getElements() return elements in the correct order - - fix broken Form.serialize return - -* session_migration generator adds an index on updated_at. #6207 [grg] - -* script/server creates the tmp/pids directory. #6204 [jonathan] - -* Fix script/console --sandbox for internal transactions changes. #5738 [Chris McGrath, charles.gerungan@gmail.com] - -* Remove the uncanny default of adding all app/models/*/ directories to the load path. This change will break application which expect the current behavior. As -documented in initializer.rb, the workaround is: - - config.autoload_paths += Dir[RAILS_ROOT + '/app/models/*/'] - -References #6031. [Nicholas Seckar] - -* Update to script.aculo.us 1.6.3 [Thomas Fuchs] - -* Update to Prototype 1.5.0_rc1 [sam] - -* Formally Deprecate the old rake tasks. [Michael Koziarski] - -* Thoroughly test the FCGI dispatcher. #5970 [Kevin Clark] - -* Remove Dir.chdir in the Webrick DispatchServlet#initialize method. Fix bad path errors when trying to load config/routes.rb. [Rick Olson] - -* Tighten rescue clauses. #5985 [james@grayproductions.net] - -* Cleaning up tests. [Kevin Clark, Jeremy Kemper] - -* Add Dependencies.load_once_paths. [Nicholas Seckar] - -* Updated to script.aculo.us 1.6.2 [Thomas Fuchs] - -* Assign Routing.controller_paths; fix script/about and rails info controller. [Nicholas Seckar] - -* Don't warn dispatcher of Reloadable deprecations. [Nicholas Seckar] - -* Rearrange application resetting and preparation, fix bug with leaking subclasses hash in ActiveRecord::Base [Rick Olson] - - ActiveRecord::Base.reset_subclasses is called before Dependencies are cleared and classes removed. - ActiveRecord::Base.instantiate_observers is called during a Dispatcher preparation callback. - -* Add missing mock directories from the autoload_paths configuration. [Rick Olson] - -* Nested controller scaffolding also nests the generated layout. [iain d broadfoot] - -* Add "require 'dispatcher'" to webrick server in the continuing quest to squash webrick weirdness. [Nicholas Seckar] - -* Add autoload_paths support to Initializer. [Nicholas Seckar] - -* Fix Dispatcher.reset_application! so that AR subclasses are removed and Observers re-initialized *after* Reloadable classes are removed. Closes #5743. [Rick Olson] - -* Clarify usage of script/plugin source. Closes #5344. [James Adam] - -* Add Dispatcher.to_prepare and config.to_prepare to provide a pre-request hook. [Nicholas Seckar] - -* Tweak the Rails load order so observers are loaded after plugins, and reloaded in development mode. Closed #5279. [Rick Olson] - -* Added that you can change the web server port in config/lighttpd.conf from script/server --port/-p #5465 [mats@imediatec.co.uk] - -* script/performance/profiler compatibility with the new ruby-prof, including an option to choose the results printer. #5679 [Shugo Maeda] - -* Fixed the failsafe response so it uses either the current recognized controller or ApplicationController. [Rick Olson] - -* Make sure script/reaper only reaps dispatcher pids by default, and not the spawner's pid. [Jamis Buck] - -* Fix script/plugin about so it uses about.yml and not meta.yml. [James Adam] - -* Dispatcher processes rescued actions with the same controller that processed the request. #4625 [sd@notso.net] - -* rails -d frontbase to create a new project with a frontbase database.yml. #4945 [mlaster@metavillage.com] - -* Ensure the logger is initialized. #5629 [mike@clarkware.com] - -* Added Mongrel-spawning capabilities to script/process/spawner. Mongrel will be the default choice if installed, otherwise FCGI is tried [David Heinemeier Hansson]. Examples: - - spawner # starts instances on 8000, 8001, and 8002 using Mongrel if available - spawner fcgi # starts instances on 8000, 8001, and 8002 using FCGI - spawner mongrel -i 5 # starts instances on 8000, 8001, 8002, 8003, and 8004 using Mongrel - spawner -p 9100 -i 10 # starts 10 instances counting from 9100 to 9109 using Mongrel if available - spawner -p 9100 -r 5 # starts 3 instances counting from 9100 to 9102 and attempts start them every 5 seconds - - Also note that script/process/reaper is Mongrel capable. So the combination of spawner and reaper is a built-in alternative to something like mongrel_cluster. - -* Update scaffolding functional tests to use :id => people(:first) instead of :id => 1. #5612 [evan@protest.net] - -* db:test:clone should remove existing tables before reloading the schema. #5607 [sveit@tradeharbor.com] - -* Fixed migration generation for class names like ACLController #5197 [brad@madriska.com] - -* Added show_source_list and show_call_stack to breakpoints to make it easier to get context #5476 [takiuchi@drecom.co.jp]. Examples: - - irb(#<TopController:0x40822a68>):002:0> show_source_list - 0001 class TopController < ApplicationController - 0002 def show - 0003-> breakpoint - 0004 end - 0005 - 0006 def index - 0007 end - 0008 - => "/path/to/rails/root/app/controllers/top_controller.rb" - - irb(#<TopController:0x40822a68>):004:0> show_call_stack 3 - vendor/rails/railties/lib/breakpoint.rb:536:in `breakpoint' - vendor/rails/railties/lib/breakpoint.rb:536:in `breakpoint' - app/controllers/top_controller.rb:3:in `show' - => "/path/to/rails/root/app/controllers/top_controller.rb:3" - -* Generate scaffold layout in subdirectory appropriate to its module nesting. #5511 [nils@alumni.rice.edu] - -* Mongrel: script/server tails the rails log like it does with lighttpd. Prefer mongrel over lighttpd. #5541 [mike@clarkware.com] - -* Don't assume Active Record is available. #5497 [bob@sporkmonger.com] - -* Mongrel: script/server works on Win32. #5499 [jeremydurham@gmail.com] - -* Remove opts.on { |options[:option_name] } style hash assignment. Closes #4440. [Nick Sieger] - -* Mongrel support for script/server. #5475 [jeremydurham@gmail.com] - -* Fix script/plugin so it doesn't barf on invalid URLs [Rick Olson] - -* Fix plugin install bug at dir with space. (closes #5359) [Yoshimasa NIWA] - -* Fix bug with 'script/plugin install' so it reports unknown plugin names correctly. [Rick Olson] - -* Added uninstall.rb hook to plugin handling, such that plugins have a way of removing assets and other artifacts on removal #5003 [takiuchi@drecom.co.jp] - -* Create temporary dirs relative to RAILS_ROOT when running script/server #5014 [elliot@townx.org] - -* Minor tweak to dispatcher to use recognize instead of recognize!, as per the new routes. [Jamis Buck] - -* Make "script/plugin install" work with svn+ssh URLs. [Sam Stephenson] - -* Added lib/ to the directories that will get application docs generated [David Heinemeier Hansson] - -* Add observer generator. Closes #5167. [François Beausoleil] - -* Session migration generator obeys pluralize_table_names. #5145 [James Adam] - -* rake test:recent understands subdirectories. #2925 [jerrett@bravenet.com] - -* The app generator detects the XAMPP package's MySQL socket location. #3832 [elliot@townx.org] - -* The app generator sets a session key in application.rb so apps running on the same host may distinguish their cookies. #2967 [rcoder, rails-bug@owl.me.uk] - -* Distinguish the spawners for different processes [David Heinemeier Hansson] - -* Added -n/--process to script/process/spawner name the process pid (default is dispatch) [David Heinemeier Hansson] - -* Namespaced OrderedHash so the Rails implementation does not clash with any others. (fixes #4911) [Julian Tarkhanov] - -* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.] - -* Added script/process/inspector to do simple process status information on Rails dispatchers keeping pid files in tmp/pids [David Heinemeier Hansson] - -* Added pid file usage to script/process/spawner and script/process/reaper along with a directive in default config/lighttpd.conf file to record the pid. They will all save their pid file in tmp/pids [David Heinemeier Hansson] - - -*1.2.3* (March 12th, 2007) - -* Ruby 1.8.6 compatibility - -* Windows: include MinGW in RUBY_PLATFORM check. #2982 [okkez000@gmail.com, Kaspar Schiess] - -* Stop swallowing errors during rake test [Michael Koziarski] - - -*1.2.2* (February 5th, 2007) - -* Fix gem deprecation warnings, which also means depending on RubyGems 0.9.0+ [Chad Fowler] - -* Require the dispatcher for Rails::Configuration#to_prepare. [Rick Olson] - - -*1.2.1* (January 16th, 2007) - -* Updated to Active Record 1.15.1, Action Pack 1.13.1, Action Mailer 1.3.1, Action Web Service 1.2.1 - - -*1.2.0* (January 16th, 2007) - -* Update to Prototype 1.5.0. [Sam Stephenson] - -* Generator: use destination path for diff tempfiles. #7015 [alfeld] - -* Fixed that webrick would strip leading newlines and hang connection #4156 [psross] - -* Ensure plugins are in the Dependencies.load_once_paths collection by default. [Rick Olson] - If you really want your plugins to reload, add this to the very top of init.rb: - - Dependencies.load_once_paths.delete(lib_path) - -* Fix scaffold_resource generator so it respects the --pretend argument when creating the routes file. Closes #6852 [fearoffish] - -* Fix Webrick Daemon dispatching bug regarding a bad current working directory. Closes #4899 [Rick Olson] - -* Make config.plugins affect the load path and the dependencies system. Allows you to control plugin loading order, and keep disabled plugins off the load path. [James Adam] - -* Don't generate a components directory in new Rails apps. [Jeremy Kemper] - -* Fixed script/process/spawner to work properly with Mongrel including in -r (daemonize mode) [David Heinemeier Hansson] - -* Deprecated the name route "root" as it'll be used as a shortcut for map.connect '' in Rails 2.0 [David Heinemeier Hansson] - -* Fixed that script/server running against Mongrel should tail the proper log regardless of the environment [David Heinemeier Hansson] - -* Update initializer to load Rails::VERSION as soon as possible. Closes #6698. [Nicholas Seckar] - -* Added ActiveRecord::Base.clear_active_connections! in development mode so the database connection is not carried over from request to request. Some databases won't reread the schema if that doesn't happen (I'm looking at you SQLite), so you have to restart the server after each migration (= no fun) [David Heinemeier Hansson] - -* Made RAILS_GEM_VERSION work for beta gems too, so specifying 1.1.6 will give you 1.1.6.4520 if available [David Heinemeier Hansson] - -* Update to Prototype and script.aculo.us [5579]. [Sam Stephenson, Thomas Fuchs] - -* Made script/server work with -e and -d when using Mongrel [David Heinemeier Hansson] - -* Make sure that exceptions which are thrown outside of the user code try their best to be handeled in ApplicationController#rescue_action [Tobias Lütke] - -* Rails::VERSION::STRING should always be available without having to require 'rails/version'. #6244 [fearoffish] - -* Add grep-based fallback to reaper, to work in pidless setups [Jamis Buck] - -* Only wrap request processing with our USR1 signal handler so FastCGI can trap it and raise an exception while waiting for connections. Idle processes exit immediately rather than waiting for another request; active processes gracefully exit when the request is finished. [Jeremy Kemper] - -* Alter prior change to use require_dependency instead of require_or_load. Causes ApplicationController to be reloaded again. Closes #6587. [Nicholas Seckar] - -* Rake: use absolute paths to load lib and vendor tasks so they may be run outside of RAILS_ROOT. #6584 [jchris] - -* scaffold_resource generator uses _path named routes and head instead of render :nothing => true. #6545 [Josh Susser] - -* Generator can show diff on file collision to help you decide whether to skip or overwrite. #6364 [jeffw, Jeremy Kemper] - -* Generated directories are recursively svn added, like mkdir -p. #6416 [NeilW] - -* resource and scaffold_resource generators add a restful route to config/routes.rb [Jeremy Kemper] - -* Revert environment changes for autoload_paths. [Michael Koziarski] - -* Clean up the output of rake stats, de-emphasise components and apis, and remove the indents for tests [Michael Koziarski] - -* Added option to script/process/spawner of specifying the binding address #5133 [Dee Zsombor] - -* Update environment.rb comments to include config.autoload_paths. Closes #6478 [caio] - -* Update scaffold to use new form_tag block functionality. Closes #6480. [Bob Silva] - -* Plugin generator: check for class collisions. #4833 [vinbarnes@gmail.com] - -* Mailer generator: handle mailers in modules, set mime_version in unit test. [Jeremy Kemper] - -* Set $KCODE to 'u' by default to enable the multibyte safe String#chars proxy. [Michael Koziarski] - -* Added config.plugins to control which plugins are loaded #6269 [Stefan Kaes]. By default, everything in vendor/plugins will be loaded, but if you specify config.plugins, only those will be loaded. Example: - - config.plugins = %w[ routing_navigator simply_helpful ] - -* Clean up html on included error pages. [Tim Lucas] - -* Fixed default 404.html and 500.htmls to remove extreme ugliness and include human language [David Heinemeier Hansson] - -* Update to latest Prototype and script.aculo.us trunk versions [Thomas Fuchs] - -* PostgreSQL: db:test:purge closes open database connections first. #6236 [alex] - -* Fixed test:uncommitted on Windows (backslash issue) #4999 [paul@paulbutcher.com] - -* Fixed migration creation to work with namespaced models, so script/generate model Gallery::Image will use create_table :gallery_images #6327 [Bob Silva] - -* Fixed rename_table on SQLite tables with indexes defined #5942 [brandon@opensoul.org] - -* Added default timeout setting of 5 seconds to SQLite3 database.yml configurations [David Heinemeier Hansson] - -* Added generated attribute options to script/generate model, like the one found in scaffold_resource and resource [David Heinemeier Hansson]. Examples: - - ./script/generate model post title:string created_on:date body:text published:boolean - -* Added script/generate resource which works just like scaffold_resource, but creates empty placeholders instead of predefined [David Heinemeier Hansson] - -* script/runner can run files, pass on arguments, and be used as a shebang. #6286 [Tuxie, dlpond] - #!/usr/bin/env /path/to/my/app/script/runner - # Example: just start using your models as if you are in script/console - Product.find(:all).each { |product| product.check_inventory } - -* Look for rake tasks in plugin subdirs. #6259 [obrie] - -* Added map.connect ':controller/:action/:id.:format' as a default route to config/routes.rb [David Heinemeier Hansson] - -* session_migration generator adds an index on updated_at. #6207 [grg] - -* script/server creates the tmp/pids directory. #6204 [jonathan] - -* Fix script/console --sandbox for internal transactions changes. #5738 [Chris McGrath, charles.gerungan@gmail.com] - -* Remove the uncanny default of adding all app/models/*/ directories to the load path. This change will break application which expect the current behavior. As -documented in initializer.rb, the workaround is: - - config.autoload_paths += Dir[RAILS_ROOT + '/app/models/*/'] - -References #6031. [Nicholas Seckar] - -* Update to script.aculo.us 1.6.3 [Thomas Fuchs] - -* Formally Deprecate the old rake tasks. [Michael Koziarski] - -* Thoroughly test the FCGI dispatcher. #5970 [Kevin Clark] - -* Remove Dir.chdir in the Webrick DispatchServlet#initialize method. Fix bad path errors when trying to load config/routes.rb. [Rick Olson] - -* Tighten rescue clauses. #5985 [james@grayproductions.net] - -* Cleaning up tests. [Kevin Clark, Jeremy Kemper] - -* Add Dependencies.load_once_paths. [Nicholas Seckar] - -* Assign Routing.controller_paths; fix script/about and rails info controller. [Nicholas Seckar] - -* Don't warn dispatcher of Reloadable deprecations. [Nicholas Seckar] - -* Rearrange application resetting and preparation, fix bug with leaking subclasses hash in ActiveRecord::Base [Rick Olson] - - ActiveRecord::Base.reset_subclasses is called before Dependencies are cleared and classes removed. - ActiveRecord::Base.instantiate_observers is called during a Dispatcher preparation callback. - -* Add missing mock directories from the autoload_paths configuration. [Rick Olson] - -* Nested controller scaffolding also nests the generated layout. [iain d broadfoot] - -* Add "require 'dispatcher'" to webrick server in the continuing quest to squash webrick weirdness. [Nicholas Seckar] - -* Add autoload_paths support to Initializer. [Nicholas Seckar] - -* Fix Dispatcher.reset_application! so that AR subclasses are removed and Observers re-initialized *after* Reloadable classes are removed. Closes #5743. [Rick Olson] - -* Clarify usage of script/plugin source. Closes #5344. [James Adam] - -* Add Dispatcher.to_prepare and config.to_prepare to provide a pre-request hook. [Nicholas Seckar] - -* Tweak the Rails load order so observers are loaded after plugins, and reloaded in development mode. Closed #5279. [Rick Olson] - -* Added that you can change the web server port in config/lighttpd.conf from script/server --port/-p #5465 [mats@imediatec.co.uk] - -* script/performance/profiler compatibility with the new ruby-prof, including an option to choose the results printer. #5679 [Shugo Maeda] - -* Fixed the failsafe response so it uses either the current recognized controller or ApplicationController. [Rick Olson] - -* Make sure script/reaper only reaps dispatcher pids by default, and not the spawner's pid. [Jamis Buck] - -* Fix script/plugin about so it uses about.yml and not meta.yml. [James Adam] - -* Dispatcher processes rescued actions with the same controller that processed the request. #4625 [sd@notso.net] - -* rails -d frontbase to create a new project with a frontbase database.yml. #4945 [mlaster@metavillage.com] - -* Ensure the logger is initialized. #5629 [mike@clarkware.com] - -* Added Mongrel-spawning capabilities to script/process/spawner. Mongrel will be the default choice if installed, otherwise FCGI is tried [David Heinemeier Hansson]. Examples: - - spawner # starts instances on 8000, 8001, and 8002 using Mongrel if available - spawner fcgi # starts instances on 8000, 8001, and 8002 using FCGI - spawner mongrel -i 5 # starts instances on 8000, 8001, 8002, 8003, and 8004 using Mongrel - spawner -p 9100 -i 10 # starts 10 instances counting from 9100 to 9109 using Mongrel if available - spawner -p 9100 -r 5 # starts 3 instances counting from 9100 to 9102 and attempts start them every 5 seconds - - Also note that script/process/reaper is Mongrel capable. So the combination of spawner and reaper is a built-in alternative to something like mongrel_cluster. - -* Update scaffolding functional tests to use :id => people(:first) instead of :id => 1. #5612 [evan@protest.net] - -* db:test:clone should remove existing tables before reloading the schema. #5607 [sveit@tradeharbor.com] - -* Fixed migration generation for class names like ACLController #5197 [brad@madriska.com] - -* Added show_source_list and show_call_stack to breakpoints to make it easier to get context #5476 [takiuchi@drecom.co.jp]. Examples: - - irb(#<TopController:0x40822a68>):002:0> show_source_list - 0001 class TopController < ApplicationController - 0002 def show - 0003-> breakpoint - 0004 end - 0005 - 0006 def index - 0007 end - 0008 - => "/path/to/rails/root/app/controllers/top_controller.rb" - - irb(#<TopController:0x40822a68>):004:0> show_call_stack 3 - vendor/rails/railties/lib/breakpoint.rb:536:in `breakpoint' - vendor/rails/railties/lib/breakpoint.rb:536:in `breakpoint' - app/controllers/top_controller.rb:3:in `show' - => "/path/to/rails/root/app/controllers/top_controller.rb:3" - -* Generate scaffold layout in subdirectory appropriate to its module nesting. #5511 [nils@alumni.rice.edu] - -* Mongrel: script/server tails the rails log like it does with lighttpd. Prefer mongrel over lighttpd. #5541 [mike@clarkware.com] - -* Don't assume Active Record is available. #5497 [bob@sporkmonger.com] - -* Mongrel: script/server works on Win32. #5499 [jeremydurham@gmail.com] - -* Remove opts.on { |options[:option_name] } style hash assignment. Closes #4440. [Nick Sieger] - -* Mongrel support for script/server. #5475 [jeremydurham@gmail.com] - -* Fix script/plugin so it doesn't barf on invalid URLs [Rick Olson] - -* Fix plugin install bug at dir with space. (closes #5359) [Yoshimasa NIWA] - -* Fix bug with 'script/plugin install' so it reports unknown plugin names correctly. [Rick Olson] - -* Added uninstall.rb hook to plugin handling, such that plugins have a way of removing assets and other artifacts on removal #5003 [takiuchi@drecom.co.jp] - -* Create temporary dirs relative to RAILS_ROOT when running script/server #5014 [elliot@townx.org] - -* Minor tweak to dispatcher to use recognize instead of recognize!, as per the new routes. [Jamis Buck] - -* Make "script/plugin install" work with svn+ssh URLs. [Sam Stephenson] - -* Added lib/ to the directories that will get application docs generated [David Heinemeier Hansson] - -* Add observer generator. Closes #5167. [François Beausoleil] - -* Session migration generator obeys pluralize_table_names. #5145 [James Adam] - -* rake test:recent understands subdirectories. #2925 [jerrett@bravenet.com] - -* The app generator detects the XAMPP package's MySQL socket location. #3832 [elliot@townx.org] - -* The app generator sets a session key in application.rb so apps running on the same host may distinguish their cookies. #2967 [rcoder, rails-bug@owl.me.uk] - -* Distinguish the spawners for different processes [David Heinemeier Hansson] - -* Added -n/--process to script/process/spawner name the process pid (default is dispatch) [David Heinemeier Hansson] - -* Namespaced OrderedHash so the Rails implementation does not clash with any others. (fixes #4911) [Julian Tarkhanov] - -* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.] - -* Added script/process/inspector to do simple process status information on Rails dispatchers keeping pid files in tmp/pids [David Heinemeier Hansson] - -* Added pid file usage to script/process/spawner and script/process/reaper along with a directive in default config/lighttpd.conf file to record the pid. They will all save their pid file in tmp/pids [David Heinemeier Hansson] - - -*1.1.6* (August 10th, 2006) - -* Additional security patch - - -*1.1.5* (August 8th, 2006) - -* Mention in docs that config.frameworks doesn't work when getting Rails via Gems. #4857 [Alisdair McDiarmid] - -* Change the scaffolding layout to use yield rather than @content_for_layout. [Marcel Molina Jr.] - -* Includes critical security patch - - -*1.1.4* (June 29th, 2006) - -* Remove use of opts.on { |options[:name] } style hash assignment. References #4440. [headius@headius.com] - -* Updated to Action Pack 1.12.3, ActionWebService 1.1.4, ActionMailer 1.2.3 - - -*1.1.3* (June 27th, 2006) - -* Updated to Active Record 1.14.3, Action Pack 1.12.2, ActionWebService 1.1.3, ActionMailer 1.2.2 - - -*1.1.2* (April 9th, 2006) - -* Mention in docs that config.frameworks doesn't work when getting Rails via Gems. Closes #4857. [Alisdair McDiarmid] - -* Change the scaffolding layout to use yield rather than @content_for_layout. [Marcel Molina Jr.] - -* Added rake rails:update:configs to update config/boot.rb from the latest (also included in rake rails:update) [David Heinemeier Hansson] - -* Fixed that boot.rb would set RAILS_GEM_VERSION twice, not respect an uncommented RAILS_GEM_VERSION line, and not use require_gem [David Heinemeier Hansson] - - -*1.1.1* (April 6th, 2006) - -* Enhances plugin#discover allowing it to discover svn:// like URIs (closes #4565) [ruben.nine@gmail.com] - -* Update to Prototype 1.5.0_rc0 [Sam Stephenson] - -* Fixed that the -r/--ruby path option of the rails command was not being respected #4549 [ryan.raaum@gmail.com] - -* Added that Dispatcher exceptions should not be shown to the user unless a default log has not been configured. Instead show public/500.html [David Heinemeier Hansson] - -* Fixed that rake clone_structure_to_test should quit on pgsql if the dump is unsuccesful #4585 [augustz@augustz.com] - -* Fixed that rails --version should have the return code of 0 (success) #4560 [blair@orcaware.com] - -* Install alias so Rails::InfoController is accessible at /rails_info. Closes #4546. [Nicholas Seckar] - -* Fixed that spawner should daemonize if running in repeat mode [David Heinemeier Hansson] - -* Added TAG option for rake rails:freeze:edge, so you can say rake rails:freeze:edge TAG=rel_1-1-0 to lock to the 1.1.0 release [David Heinemeier Hansson] - -* Applied Prototype $() performance patches (#4465, #4477) and updated script.aculo.us [Sam Stephenson, Thomas Fuchs] - -* Use --simple-prompt instead of --prompt-mode simple for console compatibility with Windows/Ruby 1.8.2 #4532 [starr@starrnhorne.com] - -* Make Rails::VERSION implicitly loadable #4491. [Nicholas Seckar] - -* Fixed rake rails:freeze:gems #4518 [benji@silverinsanity.com] - -* Added -f/--freeze option to rails command for freezing the application to the Rails version it was generated with [David Heinemeier Hansson] - -* Added gem binding of apps generated through the rails command to the gems of they were generated with [Nicholas Seckar] - -* Added expiration settings for JavaScript, CSS, HTML, and images to default lighttpd.conf [David Heinemeier Hansson] - -* Added gzip compression for JavaScript, CSS, and HTML to default lighttpd.conf [David Heinemeier Hansson] - -* Avoid passing escapeHTML non-string in Rails' info controller [Nicholas Seckar] - - -*1.1.0* (March 27th, 2006) - -* Allow db:fixtures:load to load a subset of the applications fixtures. [Chad Fowler] - - ex. - - rake db:fixtures:load FIXTURES=customers,plans - -* Update to Prototype 1.5.0_pre1 [Sam Stephenson] - -* Update to script.aculo.us 1.6 [Thomas Fuchs] - -* Add an integration_test generator [Jamis Buck] - -* Make all ActionView helpers available in the console from the helper method for debugging purposes. n.b.: Only an 80% solution. Some stuff won't work, most will. [Marcel Molina Jr.] - - ex. - - >> puts helper.options_for_select([%w(a 1), %w(b 2), %w(c 3)]) - <option value="1">a</option> - <option value="2">b</option> - <option value="3">c</option> - => nil - -* Replaced old session rake tasks with db:sessions:create to generate a migration, and db:sessions:clear to remove sessions. [Rick Olson] - -* Reject Ruby 1.8.3 when loading Rails; extract version checking code. [Chad Fowler] - -* Remove explicit loading of RailsInfo and RailsInfoController. [Nicholas Seckar] - -* Move RailsInfo and RailsInfoController to Rails::Info and Rails::InfoController. [Nicholas Seckar] - -* Extend load path with Railties' builtin directory to make adding support code easy. [Nicholas Seckar] - -* Fix the rails_info controller by explicitly loading it, and marking it as not reloadable. [Nicholas Seckar] - -* Fixed rails:freeze:gems for Windows #3274 [paul@paulbutcher.com] - -* Added 'port open?' check to the spawner when running in repeat mode so we don't needlessly boot the dispatcher if the port is already in use anyway #4089 [guy.naor@famundo.com] - -* Add verification to generated scaffolds, don't allow get for unsafe actions [Michael Koziarski] - -* Don't replace application.js in public/javascripts if it already exists [Cody Fauser] - -* Change test:uncommitted to delay execution of `svn status` by using internal Rake API's. [Nicholas Seckar] - -* Use require_library_or_gem to load rake in commands/server.rb. Closes #4205. [rob.rasmussen@gmail.com] - -* Use the Rake API instead of shelling out to create the tmp directory in commands/server.rb. [Chad Fowler] - -* Added a backtrace to the evil WSOD (White Screen of Death). Closes #4073. TODO: Clearer exceptions [Rick Olson] - -* Added tracking of database and framework versions in script/about #4088 [charles.gerungan@gmail.com/Rick Olson] - -* Added public/javascripts/application.js as a sample since it'll automatically be included in javascript_include_tag :defaults [David Heinemeier Hansson] - -* Added socket cleanup for lighttpd, both before and after [David Heinemeier Hansson] - -* Added automatic creation of tmp/ when running script/server [David Heinemeier Hansson] - -* Added silence_stream that'll work on both STDERR or STDOUT or any other stream and deprecated silence_stderr in the process [David Heinemeier Hansson] - -* Added reload! method to script/console to reload all models and others that include Reloadable without quitting the console #4056 [esad@esse.at] - -* Added that rake rails:freeze:edge will now just export all the contents of the frameworks instead of just lib, so stuff like rails:update:scripts, rails:update:javascripts, and script/server on lighttpd still just works #4047 [David Heinemeier Hansson] - -* Added fix for upload problems with lighttpd from Safari/IE to config/lighttpd.conf #3999 [Thijs van der Vossen] - -* Added test:uncommitted to test changes since last checkin to Subversion #4035 [technomancy@gmail.com] - -* Help script/about print the correct svn revision when in a non-English locale. #4026 [babie7a0@ybb.ne.jp] - -* Add 'app' accessor to script/console as an instance of Integration::Session [Jamis Buck] - -* Generator::Base#usage takes an optional message argument which defaults to Generator::Base#usage_message. [Jeremy Kemper] - -* Remove the extraneous AR::Base.threaded_connections setting from the webrick server. [Jeremy Kemper] - -* Add integration test support to app generation and testing [Jamis Buck] - -* Added namespaces to all tasks, so for example load_fixtures is now db:fixtures:load. All the old task names are still valid, they just point to the new namespaced names. "rake -T" will only show the namespaced ones, though [David Heinemeier Hansson] - -* CHANGED DEFAULT: ActiveRecord::Base.schema_format is now :ruby by default instead of :sql. This means that we'll assume you want to live in the world of db/schema.rb where the grass is green and the girls are pretty. If your schema contains un-dumpable elements, such as constraints or database-specific column types, you just got an invitation to either 1) patch the dumper to include foreign key support, 2) stop being db specific, or 3) just change the default in config/environment.rb to config.active_record.schema_format = :sql -- we even include an example for that on new Rails skeletons now. Brought to you by the federation of opinionated framework builders! [David Heinemeier Hansson] - -* Added -r/--repeat option to script/process/spawner that offers the same loop protection as the spinner did. This deprecates the script/process/spinner, so it's no longer included in the default Rails skeleton, but still available for backwards compatibility #3461 [ror@andreas-s.net] - -* Added collision option to template generation in generators #3329 [anna@wota.jp]. Examples: - - m.template "stuff.config" , "config/stuff.config" , :collision => :skip - m.template "auto-stamping", "config/generator.log", :collision => :force - -* Added more information to script/plugin's doings to ease debugging #3755 [Rick Olson] - -* Changed the default configuration for lighttpd to use tmp/sockets instead of log/ for the FastCGI sockets [David Heinemeier Hansson] - -* Added a default configuration of the FileStore for fragment caching if tmp/cache is available, which makes action/fragment caching ready to use out of the box with no additional configuration [David Heinemeier Hansson] - -* Changed the default session configuration to place sessions in tmp/sessions, if that directory is available, instead of /tmp (this essentially means a goodbye to 9/10 White Screen of Death errors and should have web hosting firms around the world cheering) [David Heinemeier Hansson] - -* Added tmp/sessions, tmp/cache, and tmp/sockets as default directories in the Rails skeleton [David Heinemeier Hansson] - -* Added that script/generate model will now automatically create a migration file for the model created. This can be turned off by calling the generator with --skip-migration [David Heinemeier Hansson] - -* Added -d/--database option to the rails command, so you can do "rails --database=sqlite2 myapp" to start a new application preconfigured to use SQLite2 as the database. Removed the configuration examples from SQLite and PostgreSQL from the default MySQL configuration [David Heinemeier Hansson] - -* Allow script/server -c /path/to/lighttpd.conf [Jeremy Kemper] - -* Remove hardcoded path to reaper script in script/server [Jeremy Kemper] - -* Update script.aculo.us to V1.5.3 [Thomas Fuchs] - -* Added SIGTRAP signal handler to RailsFCGIHandler that'll force the process into a breakpoint after the next request. This breakpoint can then be caught with script/breakpointer and give you access to the Ruby image inside that process. Useful for debugging memory leaks among other things [David Heinemeier Hansson] - -* Changed default lighttpd.conf to use CWD from lighttpd 1.4.10 that allows the same configuration to be used for both detach and not. Also ensured that auto-repeaping of FCGIs only happens when lighttpd is not detached. [David Heinemeier Hansson] - -* Added Configuration#after_initialize for registering a block which gets called after the framework is fully initialized. Useful for things like per-environment configuration of plugins. [Michael Koziarski] - -* Added check for RAILS_FRAMEWORK_ROOT constant that allows the Rails framework to be found in a different place than vendor/rails. Should be set in boot.rb. [David Heinemeier Hansson] - -* Fixed that static requests could unlock the mutex guarding dynamic requests in the WEBrick servlet #3433 [tom@craz8.com] - -* Fixed documentation tasks to work with Rake 0.7.0 #3563 [kazuhiko@fdiary.net] - -* Update to Prototype 1.5.0_pre0 [Sam Stephenson] - -* Sort the list of plugins so we load in a consistent order [Rick Olson] - -* Show usage when script/plugin is called without arguments [tom@craz8.com] - -* Corrected problems with plugin loader where plugins set 'name' incorrectly #3297 [anna@wota.jp] - -* Make migration generator only report on exact duplicate names, not partial dupliate names. #3442 [jeremy@planetargon.com Marcel Molina Jr.] - -* Fix typo in mailer generator USAGE. #3458 [chriztian.steinmeier@gmail.com] - -* Ignore version mismatch between pg_dump and the database server. #3457 [Simon Stapleton] - -* Reap FCGI processes after lighttpd exits. [Sam Stephenson] - -* Honor ActiveRecord::Base.pluralize_table_names when creating and destroying session store table. #3204. [rails@bencurtis.com, Marcel Molina Jr.] - -*1.0.0* (December 13th, 2005) - -* Update instructions on how to find and install generators. #3172. [Chad Fowler] - -* Generator looks in vendor/generators also. [Chad Fowler] - -* Generator copies files in binary mode. #3156 [minimudboy@gmail.com] - -* Add builtin/ to the gemspec. Closes #3047. [Nicholas Seckar, Sam Stephenson] - -* Add install.rb file to plugin generation which is loaded, if it exists, when you install a plugin. [Marcel Molina Jr.] - -* Run initialize_logger in script/lighttpd to ensure the log file exists before tailing it. [Sam Stephenson] - -* Make load_fixtures include csv fixtures. #3053. [me@mdaines.com] - -* Fix freeze_gems so that the latest rails version is dumped by default. [Nicholas Seckar] - -* script/plugin: handle root paths and plugin names which contain spaces. #2995 [justin@aspect.net] - -* Model generator: correct relative path to test_helper in unit test. [Jeremy Kemper] - -* Make the db_schema_dump task honor the SCHEMA environment variable if present the way db_schema_import does. #2931. [Blair Zajac] - -* Have the lighttpd server script report the actual ip to which the server is bound. #2903. [Adam] - -* Add plugin library directories to the load path after the lib directory so that libraries in the lib directory get precedence. #2910. [James Adam] - -* Make help for the console command more explicit about how to specify the desired environment in which to run the console. #2911. [anonymous] - -* PostgreSQL: the purge_test_database Rake task shouldn't explicitly specify the template0 template when creating a fresh test database. #2964 [Dreamer3] - -* Introducing the session_migration generator. Creates an add_session_table migration. Allows generator to specify migrations directory. #2958, #2960 [Rick Olson] - -* script/console uses RAILS_ENV environment variable if present. #2932 [Blair Zajac <blair@orcaware.com> - -* Windows: eliminate the socket option in database.yml. #2924 [Wayne Vucenic <waynev@gmail.com>] - -* Eliminate nil from newly generated logfiles. #2927 [Blair Zajac <blair@orcaware.com>] - -* Rename Version constant to VERSION. #2802 [Marcel Molina Jr.] - -* Eliminate Subversion dependencies in scripts/plugin. Correct install options. Introduce --force option to reinstall a plugin. Remove useless --long option for list. Use --quiet to quiet the download output and --revision to update to a specific svn revision. #2842 [Chad Fowler, Rick Olson] - -* SQLite: the clone_structure_to_test and purge_test_database Rake tasks should always use the test environment. #2846 [Rick Olson] - -* Make sure that legacy db tasks also reference :database for SQLite #2830 [kazuhiko@fdiary.net] - -* Pass __FILE__ when evaluating plugins' init.rb. #2817 [James Adam] - -* Better svn status matching for generators. #2814 [François Beausoleil <francois.beausoleil@gmail.com>, Blair Zajac <blair@orcaware.com>] - -* Don't reload routes until plugins have been loaded so they have a chance to extend the routing capabilities [David Heinemeier Hansson] - -* Don't detach or fork for script/server tailing [Nicholas Seckar] - -* Changed all script/* to use #!/usr/bin/env ruby instead of hard-coded Ruby path. public/dispatcher.* still uses the hard-coded path for compatibility with web servers that don't have Ruby in path [David Heinemeier Hansson] - -* Force RAILS_ENV to be "test" when running tests, so that ENV["RAILS_ENV"] = "production" in config/environment.rb doesn't wreck havok [David Heinemeier Hansson] #2660 - -* Correct versioning in :freeze_gems Rake task. #2778 [Jakob Skjerning, Jeremy Kemper] - -* Added an omnipresent RailsInfoController with a properties action that delivers an HTML rendering of Rails::Info (but only when local_request? is true). Added a new default index.html which fetches this with Ajax. [Sam Stephenson] - - -*0.14.3 (RC4)* (November 7th, 2005) - -* Add 'add_new_scripts' rake task for adding new rails scripts to script/* [Jamis Buck] - -* Remove bogus hyphen from script/process/reaper calls to 'ps'. #2767 [anonymous] - -* Copy lighttpd.conf when it is first needed, instead of on app creation [Jamis Buck] - -* Use require_library_or_gem 'fcgi' in script/server [Sam Stephenson] - -* Added default lighttpd config in config/lighttpd.conf and added a default runner for lighttpd in script/server (works like script/server, but using lighttpd and FastCGI). It will use lighttpd if available, otherwise WEBrick. You can force either or using 'script/server lighttpd' or 'script/server webrick' [David Heinemeier Hansson] - -* New configuration option config.plugin_paths which may be a single path like the default 'vendor/plugins' or an array of paths: ['vendor/plugins', 'lib/plugins']. [Jeremy Kemper] - -* Plugins are discovered in nested paths, so you can organize your plugins directory as you like. [Jeremy Kemper] - -* Refactor load_plugin from load_plugins. #2757 [alex.r.moon@gmail.com] - -* Make use of silence_stderr in script/lighttpd, script/plugin, and Rails::Info [Sam Stephenson] - -* Enable HTTP installation of plugins when svn isn't avaialable. Closes #2661. [Chad Fowler] - -* Added script/about to display formatted Rails::Info output [Sam Stephenson] - -* Added Rails::Info to catalog assorted information about a Rails application's environment [Sam Stephenson] - -* Tail the logfile when running script/server lighttpd in the foreground [Sam Stephenson] - -* Try to guess the port number from config/lighttpd.conf in script/server lighttpd [Sam Stephenson] - -* Don't reap spawn-fcgi. #2727 [matthew@walker.wattle.id.au] - -* Reaper knows how to find processes even if the dispatch path is very long. #2711 [matthew@walker.wattle.id.au] - -* Make fcgi handler respond to TERM signals with an explicit exit [Jamis Buck] - -* Added demonstration of fixture use to the test case generated by the model generator [David Heinemeier Hansson] - -* If specified, pass PostgreSQL client character encoding to createdb. #2703 [Kazuhiko <kazuhiko@fdiary.net>] - -* Catch CGI multipart parse errors. Wrap dispatcher internals in a failsafe response handler. [Jeremy Kemper] - -* The freeze_gems Rake task accepts the VERSION environment variable to decide which version of Rails to pull into vendor/rails. [Chad Fowler, Jeremy Kemper] - -* Removed script.aculo.us.js, builder.js and slider.js (preperation for move of scriptaculous extensions to plugins, core scriptaculous will remain in Railties) [Thomas Fuchs] - -* The freeze_edge Rake task does smarter svn detection and can export a specific revision by passing the REVISION environment variable. For example: rake freeze_edge REVISION=1234. #2663 [Rick Olson] - -* Comment database.yml and include PostgreSQL and SQLite examples. [Jeremy Kemper] - -* Improve script/plugin on Windows. #2646 [Chad Fowler] - -* The *_plugindoc Rake tasks look deeper into the plugins' lib directories. #2652 [bellis@deepthought.org] - -* The PostgreSQL :db_structure_dump Rake task limits its dump to the schema search path in database.yml. [Anatol Pomozov <anatol.pomozov@gmail.com>] - -* Add task to generate rdoc for all installed plugins. [Marcel Molina Jr.] - -* Update script.aculo.us to V1.5_rc4 [Thomas Fuchs] - -* Add default Mac + DarwinPorts MySQL socket locations to the app generator. [Jeremy Kemper] - -* Migrations may be destroyed: script/destroy migration foo. #2635 [Charles M. Gerungan <charles.gerungan@gmail.com>, Jamis Buck, Jeremy Kemper] - -* Added that plugins can carry generators and that generator stub files can be created along with new plugins using script/generate plugin <name> --with-generator [David Heinemeier Hansson] - -* Removed app/apis as a default empty dir since its automatically created when using script/generate web_service [David Heinemeier Hansson] - -* Added script/plugin to manage plugins (install, remove, list, etc) [Ryan Tomayko] - -* Added test_plugins task: Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name) [David Heinemeier Hansson] - -* Added plugin generator to create a stub structure for a new plugin in vendor/plugins (see "script/generate plugin" for help) [David Heinemeier Hansson] - -* Fixed scaffold generator when started with only 1 parameter #2609 [self@mattmower.com] - -* rake should run functional tests even if the unit tests have failures [Jim Weirich] - -* Back off cleanpath to be symlink friendly. Closes #2533 [Nicholas Seckar] - -* Load rake task files in alphabetical order so you can build dependencies and count on them #2554 [Blair Zajac] - - -*0.14.2 (RC3)* (October 26th, 2005) - -* Constants set in the development/test/production environment file are set in Object - -* Scaffold generator pays attention to the controller name. #2562 [self@mattmower.com] - -* Include tasks from vendor/plugins/*/tasks in the Rakefile #2545 [Rick Olson] - - -*0.14.1 (RC2)* (October 19th, 2005) - -* Don't clean RAILS_ROOT on windows - -* Remove trailing '/' from RAILS_ROOT [Nicholas Seckar] - -* Upgraded to Active Record 1.12.1 and Action Pack 1.10.1 - - -*0.14.0 (RC1)* (October 16th, 2005) - -* Moved generator folder from RAILS_ROOT/generators to RAILS_ROOT/lib/generators [Tobias Lütke] - -* Fix rake dev and related commands [Nicholas Seckar] - -* The rails command tries to deduce your MySQL socket by running `mysql_config ---socket`. If it fails, default to /path/to/your/mysql.sock - -* Made the rails command use the application name for database names in the tailored database.yml file. Example: "rails ~/projects/blog" will use "blog_development" instead of "rails_development". [Florian Weber] - -* Added Rails framework freezing tasks: freeze_gems (freeze to current gems), freeze_edge (freeze to Rails SVN trunk), unfreeze_rails (float with newest gems on system) - -* Added update_javascripts task which will fetch all the latest js files from your current rails install. Use after updating rails. [Tobias Lütke] - -* Added cleaning of RAILS_ROOT to useless elements such as '../non-dot-dot/'. Provides cleaner backtraces and error messages. [Nicholas Seckar] - -* Made the instantiated/transactional fixtures settings be controlled through Rails::Initializer. Transactional and non-instantiated fixtures are default from now on. [Florian Weber] - -* Support using different database adapters for development and test with ActiveRecord::Base.schema_format = :ruby [Sam Stephenson] - -* Make webrick work with session(:off) - -* Add --version, -v option to the Rails command. Closes #1840. [stancell] - -* Update Prototype to V1.4.0_pre11, script.aculo.us to V1.5_rc3 [2504] and fix the rails generator to include the new .js files [Thomas Fuchs] - -* Make the generator skip a file if it already exists and is identical to the new file. - -* Add experimental plugin support #2335 - -* Made Rakefile aware of new .js files in script.aculo.us [Thomas Fuchs] - -* Make table_name and controller_name in generators honor AR::Base.pluralize_table_names. #1216 #2213 [kazuhiko@fdiary.net] - -* Clearly label functional and unit tests in rake stats output. #2297 [lasse.koskela@gmail.com] - -* Make the migration generator only check files ending in *.rb when calculating the next file name #2317 [Chad Fowler] - -* Added prevention of duplicate migrations from the generator #2240 [François Beausoleil] - -* Add db_schema_dump and db_schema_import rake tasks to work with the new ActiveRecord::SchemaDumper (for dumping a schema to and reading a schema from a ruby file). - -* Reformed all the config/environments/* files to conform to the new Rails::Configuration approach. Fully backwards compatible. - -* Added create_sessions_table, drop_sessions_table, and purge_sessions_table as rake tasks for databases that supports migrations (MySQL, PostgreSQL, SQLite) to get a table for use with CGI::Session::ActiveRecordStore - -* Added dump of schema version to the db_structure_dump task for databases that support migrations #1835 [Rick Olson] - -* Fixed script/profiler for Ruby 1.8.2 #1863 [Rick Olson] - -* Fixed clone_structure_to_test task for SQLite #1864 [jon@burningbush.us] - -* Added -m/--mime-types option to the WEBrick server, so you can specify a Apache-style mime.types file to load #2059 [ask@develooper.com] - -* Added -c/--svn option to the generator that'll add new files and remove destroyed files using svn add/revert/remove as appropriate #2064 [Kevin Clark] - -* Added -c/--charset option to WEBrick server, so you can specify a default charset (which without changes is UTF-8) #2084 [wejn@box.cz] - -* Make the default stats task extendable by modifying the STATS_DIRECTORIES constant - -* Allow the selected environment to define RAILS_DEFAULT_LOGGER, and have Rails::Initializer use it if it exists. - -* Moved all the shared tasks from Rakefile into Rails, so that the Rakefile is empty and doesn't require updating. - -* Added Rails::Initializer and Rails::Configuration to abstract all of the common setup out of config/environment.rb (uses config/boot.rb to bootstrap the initializer and paths) - -* Fixed the scaffold generator to fail right away if the database isn't accessible instead of in mid-air #1169 [Chad Fowler] - -* Corrected project-local generator location in scripts.rb #2010 [Michael Schuerig] - -* Don't require the environment just to clear the logs #2093 [Scott Barron] - -* Make the default rakefile read *.rake files from config/tasks (for easy extension of the rakefile by e.g. generators) - -* Only load breakpoint in development mode and when BREAKPOINT_SERVER_PORT is defined. - -* Allow the --toggle-spin switch on process/reaper to be negated - -* Replace render_partial with render :partial in scaffold generator [Nicholas Seckar] - -* Added -w flag to ps in process/reaper #1934 [Scott Barron] - -* Allow ERb in the database.yml file (just like with fixtures), so you can pull out the database configuration in environment variables #1822 [Duane Johnson] - -* Added convenience controls for FCGI processes (especially when managed remotely): spinner, spawner, and reaper. They reside in script/process. More details can be had by calling them with -h/--help. - -* Added load_fixtures task to the Rakefile, which will load all the fixtures into the database for the current environment #1791 [Marcel Molina Jr.] - -* Added an empty robots.txt to public/, so that web servers asking for it won't trigger a dynamic call, like favicon.ico #1738 [Michael Schubert] - -* Dropped the 'immediate close-down' of FCGI processes since it didn't work consistently and produced bad responses when it didn't. So now a TERM ensures exit after the next request (just as if the process is handling a request when it receives the signal). This means that you'll have to 'nudge' all FCGI processes with a request in order to ensure that they have all reloaded. This can be done by something like ./script/process/repear --nudge 'http://www.myapp.com' --instances 10, which will load the myapp site 10 times (and thus hit all of the 10 FCGI processes once, enough to shut down). - - -*0.13.1* (11 July, 2005) - -* Look for app-specific generators in RAILS_ROOT/generators rather than the clunky old RAILS_ROOT/script/generators. Nobody really uses this feature except for the unit tests, so it's a negligible-impact change. If you want to work with third-party generators, drop them in ~/.rails/generators or simply install gems. - -* Fixed that each request with the WEBrick adapter would open a new database connection #1685 [Sam Stephenson] - -* Added support for SQL Server in the database rake tasks #1652 [Ken Barker] Note: osql and scptxfr may need to be installed on your development environment. This involves getting the .exes and a .rll (scptxfr) from a production SQL Server (not developer level SQL Server). Add their location to your Environment PATH and you are all set. - -* Added a VERSION parameter to the migrate task that allows you to do "rake migrate VERSION=34" to migrate to the 34th version traveling up or down depending on the current version - -* Extend Ruby version check to include RUBY_RELEASE_DATE >= '2005-12-25', the final Ruby 1.8.2 release #1674 [court3nay] - -* Improved documentation for environment config files #1625 [court3nay] - - -*0.13.0* (6 July, 2005) - -* Changed the default logging level in config/environment.rb to INFO for production (so SQL statements won't be logged) - -* Added migration generator: ./script/generate migration add_system_settings - -* Added "migrate" as rake task to execute all the pending migrations from db/migrate - -* Fixed that model generator would make fixtures plural, even if ActiveRecord::Base.pluralize_table_names was false #1185 [Marcel Molina Jr.] - -* Added a DOCTYPE of HTML transitional to the HTML files generated by Rails #1124 [Michael Koziarski] - -* SIGTERM also gracefully exits dispatch.fcgi. Ignore SIGUSR1 on Windows. - -* Add the option to manually manage garbage collection in the FastCGI dispatcher. Set the number of requests between GC runs in your public/dispatch.fcgi [Stefan Kaes] - -* Allow dynamic application reloading for dispatch.fcgi processes by sending a SIGHUP. If the process is currently handling a request, the request will be allowed to complete first. This allows production fcgi's to be reloaded without having to restart them. - -* RailsFCGIHandler (dispatch.fcgi) no longer tries to explicitly flush $stdout (CgiProcess#out always calls flush) - -* Fixed rakefile actions against PostgreSQL when the password is all numeric #1462 [Michael Schubert] - -* ActionMailer::Base subclasses are reloaded with the other rails components #1262 - -* Made the WEBrick adapter not use a mutex around action performance if ActionController::Base.allow_concurrency is true (default is false) - -* Fixed that mailer generator generated fixtures/plural while units expected fixtures/singular #1457 [Scott Barron] - -* Added a 'whiny nil' that's aim to ensure that when users pass nil to methods where that isn't appropriate, instead of NoMethodError? and the name of some method used by the framework users will see a message explaining what type of object was expected. Only active in test and development environments by default #1209 [Michael Koziarski] - -* Fixed the test_helper.rb to be safe for requiring controllers from multiple spots, like app/controllers/article_controller.rb and app/controllers/admin/article_controller.rb, without reloading the environment twice #1390 [Nicholas Seckar] - -* Fixed Webrick to escape + characters in URL's the same way that lighttpd and apache do #1397 [Nicholas Seckar] - -* Added -e/--environment option to script/runner #1408 [François Beausoleil] - -* Modernize the scaffold generator to use the simplified render and test methods and to change style from @params["id"] to params[:id]. #1367 - -* Added graceful exit from pressing CTRL-C during the run of the rails command #1150 [Caleb Tennis] - -* Allow graceful exits for dispatch.fcgi processes by sending a SIGUSR1. If the process is currently handling a request, the request will be allowed to complete and then will terminate itself. If a request is not being handled, the process is terminated immediately (via #exit). This basically works like restart graceful on Apache. [Jamis Buck] - -* Made dispatch.fcgi more robust by catching fluke errors and retrying unless its a permanent condition. [Jamis Buck] - -* Added console --profile for profiling an IRB session #1154 [Jeremy Kemper] - -* Changed console_sandbox into console --sandbox #1154 [Jeremy Kemper] - - -*0.12.1* (20th April, 2005) - -* Upgraded to Active Record 1.10.1, Action Pack 1.8.1, Action Mailer 0.9.1, Action Web Service 0.7.1 - - -*0.12.0* (19th April, 2005) - -* Fixed that purge_test_database would use database settings from the development environment when recreating the test database #1122 [rails@cogentdude.com] - -* Added script/benchmarker to easily benchmark one or more statement a number of times from within the environment. Examples: - - # runs the one statement 10 times - script/benchmarker 10 'Person.expensive_method(10)' - - # pits the two statements against each other with 50 runs each - script/benchmarker 50 'Person.expensive_method(10)' 'Person.cheap_method(10)' - -* Added script/profiler to easily profile a single statement from within the environment. Examples: - - script/profiler 'Person.expensive_method(10)' - script/profiler 'Person.expensive_method(10)' 10 # runs the statement 10 times - -* Added Rake target clear_logs that'll truncate all the *.log files in log/ to zero #1079 [Lucas Carlson] - -* Added lazy typing for generate, such that ./script/generate cn == ./script/generate controller and the likes #1051 [k@v2studio.com] - -* Fixed that ownership is brought over in pg_dump during tests for PostgreSQL #1060 [pburleson] - -* Upgraded to Active Record 1.10.0, Action Pack 1.8.0, Action Mailer 0.9.0, Action Web Service 0.7.0, Active Support 1.0.4 - - -*0.11.1* (27th March, 2005) - -* Fixed the dispatch.fcgi use of a logger - -* Upgraded to Active Record 1.9.1, Action Pack 1.7.0, Action Mailer 0.8.1, Action Web Service 0.6.2, Active Support 1.0.3 - - -*0.11.0* (22th March, 2005) - -* Removed SCRIPT_NAME from the WEBrick environment to prevent conflicts with PATH_INFO #896 [Nicholas Seckar] - -* Removed ?$1 from the dispatch.f/cgi redirect line to get rid of 'complete/path/from/request.html' => nil being in the @params now that the ENV["REQUEST_URI"] is used to determine the path #895 [dblack/Nicholas Seckar] - -* Added additional error handling to the FastCGI dispatcher to catch even errors taking down the entire process - -* Improved the generated scaffold code a lot to take advantage of recent Rails developments #882 [Tobias Lütke] - -* Combined the script/environment.rb used for gems and regular files version. If vendor/rails/* has all the frameworks, then files version is used, otherwise gems #878 [Nicholas Seckar] - -* Changed .htaccess to allow dispatch.* to be called from a sub-directory as part of the push with Action Pack to make Rails work on non-vhost setups #826 [Nicholas Seckar/Tobias Lütke] - -* Added script/runner which can be used to run code inside the environment by eval'ing the first parameter. Examples: - - ./script/runner 'ReminderService.deliver' - ./script/runner 'Mailer.receive(STDIN.read)' - - This makes it easier to do CRON and postfix scripts without actually making a script just to trigger 1 line of code. - -* Fixed webrick_server cookie handling to allow multiple cookes to be set at once #800, #813 [dave@cherryville.org] - -* Fixed the Rakefile's interaction with postgresql to: - - 1. Use PGPASSWORD and PGHOST in the environment to fix prompting for - passwords when connecting to a remote db and local socket connections. - 2. Add a '-x' flag to pg_dump which stops it dumping privileges #807 [rasputnik] - 3. Quote the user name and use template0 when dumping so the functions doesn't get dumped too #855 [pburleson] - 4. Use the port if available #875 [madrobby] - -* Upgraded to Active Record 1.9.0, Action Pack 1.6.0, Action Mailer 0.8.0, Action Web Service 0.6.1, Active Support 1.0.2 - - -*0.10.1* (7th March, 2005) - -* Fixed rake stats to ignore editor backup files like model.rb~ #791 [Sebastian Kanthak] - -* Added exception shallowing if the DRb server can't be started (not worth making a fuss about to distract new users) #779 [Tobias Lütke] - -* Added an empty favicon.ico file to the public directory of new applications (so the logs are not spammed by its absence) - -* Fixed that scaffold generator new template should use local variable instead of instance variable #778 [Dan Peterson] - -* Allow unit tests to run on a remote server for PostgreSQL #781 [adamm@galacticasoftware.com] - -* Added web_service generator (run ./script/generate web_service for help) #776 [Leon Bredt] - -* Added app/apis and components to code statistics report #729 [Scott Barron] - -* Fixed WEBrick server to use ABSOLUTE_RAILS_ROOT instead of working_directory #687 [Nicholas Seckar] - -* Fixed rails_generator to be usable without RubyGems #686 [Cristi BALAN] - -* Fixed -h/--help for generate and destroy generators #331 - -* Added begin/rescue around the FCGI dispatcher so no uncaught exceptions can bubble up to kill the process (logs to log/fastcgi.crash.log) - -* Fixed that association#count would produce invalid sql when called sequentialy #659 [kanis@comcard.de] - -* Fixed test/mocks/testing to the correct test/mocks/test #740 - -* Added early failure if the Ruby version isn't 1.8.2 or above #735 - -* Removed the obsolete -i/--index option from the WEBrick servlet #743 - -* Upgraded to Active Record 1.8.0, Action Pack 1.5.1, Action Mailer 0.7.1, Action Web Service 0.6.0, Active Support 1.0.1 - - -*0.10.0* (24th February, 2005) - -* Changed default IP binding for WEBrick from 127.0.0.1 to 0.0.0.0 so that the server is accessible both locally and remotely #696 [Marcel Molina Jr.] - -* Fixed that script/server -d was broken so daemon mode couldn't be used #687 [Nicholas Seckar] - -* Upgraded to breakpoint 92 which fixes: - - * overload IRB.parse_opts(), fixes #443 - => breakpoints in tests work even when running them via rake - * untaint handlers, might fix an issue discussed on the Rails ML - * added verbose mode to breakpoint_client - * less noise caused by breakpoint_client by default - * ignored TerminateLineInput exception in signal handler - => quiet exit on Ctrl-C - -* Added support for independent components residing in /components. Example: - - Controller: components/list/items_controller.rb - (holds a List::ItemsController class with uses_component_template_root called) - - Model : components/list/item.rb - (namespace is still shared, so an Item model in app/models will take precedence) - - Views : components/list/items/show.rhtml - - -* Added --sandbox option to script/console that'll roll back all changes made to the database when you quit #672 [Jeremy Kemper] - -* Added 'recent' as a rake target that'll run tests for files that changed in the last 10 minutes #612 [Jeremy Kemper] - -* Changed script/console to default to development environment and drop --no-inspect #650 [Jeremy Kemper] - -* Added that the 'fixture :posts' syntax can be used for has_and_belongs_to_many fixtures where a model doesn't exist #572 [Jeremy Kemper] - -* Added that running test_units and test_functional now performs the clone_structure_to_test as well #566 [rasputnik] - -* Added new generator framework that informs about its doings on generation and enables updating and destruction of generated artifacts. See the new script/destroy and script/update for more details #487 [Jeremy Kemper] - -* Added Action Web Service as a new add-on framework for Action Pack [Leon Bredt] - -* Added Active Support as an independent utility and standard library extension bundle - -* Upgraded to Active Record 1.7.0, Action Pack 1.5.0, Action Mailer 0.7.0 - - -*0.9.5* (January 25th, 2005) - -* Fixed dependency reloading by switching to a remove_const approach where all Active Records, Active Record Observers, and Action Controllers are reloading by undefining their classes. This enables you to remove methods in all three types and see the change reflected immediately and it fixes #539. This also means that only those three types of classes will benefit from the const_missing and reloading approach. If you want other classes (like some in lib/) to reload, you must use require_dependency to do it. - -* Added Florian Gross' latest version of Breakpointer and friends that fixes a variaty of bugs #441 [Florian Gross] - -* Fixed skeleton Rakefile to work with sqlite3 out of the box #521 [rasputnik] - -* Fixed that script/breakpointer didn't get the Ruby path rewritten as the other scripts #523 [brandt@kurowski.net] - -* Fixed handling of syntax errors in models that had already been succesfully required once in the current interpreter - -* Fixed that models that weren't referenced in associations weren't being reloaded in the development mode by reinstating the reload - -* Fixed that generate scaffold would produce bad functional tests - -* Fixed that FCGI can also display SyntaxErrors - -* Upgraded to Active Record 1.6.0, Action Pack 1.4.0 - - -*0.9.4.1* (January 18th, 2005) - -* Added 5-second timeout to WordNet alternatives on creating reserved-word models #501 [Marcel Molina Jr.] - -* Fixed binding of caller #496 [Alexey] - -* Upgraded to Active Record 1.5.1, Action Pack 1.3.1, Action Mailer 0.6.1 - - -*0.9.4* (January 17th, 2005) - -* Added that ApplicationController will catch a ControllerNotFound exception if someone attempts to access a url pointing to an unexisting controller [Tobias Lütke] - -* Flipped code-to-test ratio around to be more readable #468 [Scott Baron] - -* Fixed log file permissions to be 666 instead of 777 (so they're not executable) #471 [Lucas Carlson] - -* Fixed that auto reloading would some times not work or would reload the models twice #475 [Tobias Lütke] - -* Added rewrite rules to deal with caching to public/.htaccess - -* Added the option to specify a controller name to "generate scaffold" and made the default controller name the plural form of the model. - -* Added that rake clone_structure_to_test, db_structure_dump, and purge_test_database tasks now pick up the source database to use from - RAILS_ENV instead of just forcing development #424 [Tobias Lütke] - -* Fixed script/console to work with Windows (that requires the use of irb.bat) #418 [Chris McGrath] - -* Fixed WEBrick servlet slowdown over time by restricting the load path reloading to mod_ruby - -* Removed Fancy Indexing as a default option on the WEBrick servlet as it made it harder to use various caching schemes - -* Upgraded to Active Record 1.5, Action Pack 1.3, Action Mailer 0.6 - - -*0.9.3* (January 4th, 2005) - -* Added support for SQLite in the auto-dumping/importing of schemas for development -> test #416 - -* Added automated rewriting of the shebang lines on installs through the gem rails command #379 [Manfred Stienstra] - -* Added ActionMailer::Base.deliver_method = :test to the test environment so that mail objects are available in ActionMailer::Base.deliveries - for functional testing. - -* Added protection for creating a model through the generators with a name of an existing class, like Thread or Date. - It'll even offer you a synonym using wordnet.princeton.edu as a look-up. No, I'm not kidding :) [Florian Gross] - -* Fixed dependency management to happen in a unified fashion for Active Record and Action Pack using the new Dependencies module. This means that - the environment options needs to change from: - - Before in development.rb: - ActionController::Base.reload_dependencies = true   - ActiveRecord::Base.reload_associations     = true - - Now in development.rb: - Dependencies.mechanism = :load - - Before in production.rb and test.rb: - ActionController::Base.reload_dependencies = false - ActiveRecord::Base.reload_associations     = false - - Now in production.rb and test.rb: - Dependencies.mechanism = :require - -* Fixed problems with dependency caching and controller hierarchies on Ruby 1.8.2 in development mode #351 - -* Fixed that generated action_mailers doesnt need to require the action_mailer since thats already done in the environment #382 [Lucas Carlson] - -* Upgraded to Action Pack 1.2.0 and Active Record 1.4.0 - - -*0.9.2* - -* Fixed CTRL-C exists from the Breakpointer to be a clean affair without error dumping [Kent Sibilev] - -* Fixed "rake stats" to work with sub-directories in models and controllers and to report the code to test ration [Scott Baron] - -* Added that Active Record associations are now reloaded instead of cleared to work with the new const_missing hook in Active Record. - -* Added graceful handling of an inaccessible log file by redirecting output to STDERR with a warning #330 [rainmkr] - -* Added support for a -h/--help parameter in the generator #331 [Ulysses] - -* Fixed that File.expand_path in config/environment.rb would fail when dealing with symlinked public directories [mjobin] - -* Upgraded to Action Pack 1.1.0 and Active Record 1.3.0 - - -*0.9.1* - -* Upgraded to Action Pack 1.0.1 for important bug fix - -* Updated gem dependencies - - -*0.9.0* - -* Renamed public/dispatch.servlet to script/server -- it wasn't really dispatching anyway as its delegating calls to public/dispatch.rb - -* Renamed AbstractApplicationController and abstract_application.rb to ApplicationController and application.rb, so that it will be possible - for the framework to automatically pick up on app/views/layouts/application.rhtml and app/helpers/application.rb - -* Added script/console that makes it even easier to start an IRB session for interacting with the domain model. Run with no-args to - see help. - -* Added breakpoint support through the script/breakpointer client. This means that you can break out of execution at any point in - the code, investigate and change the model, AND then resume execution! Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find_all - breakpoint "Breaking out from the list" - end - end - - So the controller will accept the action, run the first line, then present you with a IRB prompt in the breakpointer window. - Here you can do things like: - - Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint' - - >> @posts.inspect - => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>, - #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]" - >> @posts.first.title = "hello from a breakpoint" - => "hello from a breakpoint" - - ...and even better is that you can examine how your runtime objects actually work: - - >> f = @posts.first - => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}> - >> f. - Display all 152 possibilities? (y or n) - - Finally, when you're ready to resume execution, you press CTRL-D - -* Changed environments to be configurable through an environment variable. By default, the environment is "development", but you - can change that and set your own by configuring the Apache vhost with a string like (mod_env must be available on the server): - - SetEnv RAILS_ENV production - - ...if you're using WEBrick, you can pick the environment to use with the command-line parameters -e/--environment, like this: - - ruby public/dispatcher.servlet -e production - -* Added a new default environment called "development", which leaves the production environment to be tuned exclusively for that. - -* Added a start_server in the root of the Rails application to make it even easier to get started - -* Fixed public/.htaccess to use RewriteBase and share the same rewrite rules for all the dispatch methods - -* Fixed webrick_server to handle requests in a serialized manner (the Rails reloading infrastructure is not thread-safe) - -* Added support for controllers in directories. So you can have: - - app/controllers/account_controller.rb # URL: /account/ - app/controllers/admin/account_controller.rb # URL: /admin/account/ - - NOTE: You need to update your public/.htaccess with the new rules to pick it up - -* Added reloading for associations and dependencies under cached environments like FastCGI and mod_ruby. This makes it possible to use - those environments for development. This is turned on by default, but can be turned off with - ActiveRecord::Base.reload_associations = false and ActionController::Base.reload_dependencies = false in production environments. - -* Added support for sub-directories in app/models. So now you can have something like Basecamp with: - - app/models/accounting - app/models/project - app/models/participants - app/models/settings - - It's poor man's namespacing, but only for file-system organization. You still require files just like before. - Nothing changes inside the files themselves. - - -* Fixed a few references in the tests generated by new_mailer [Jeremy Kemper] - -* Added support for mocks in testing with test/mocks - -* Cleaned up the environments a bit and added global constant RAILS_ROOT - - -*0.8.5* (9) - -* Made dev-util available to all tests, so you can insert breakpoints in any test case to get an IRB prompt at that point [Jeremy Kemper]: - - def test_complex_stuff - @david.projects << @new_project - breakpoint "Let's have a closer look at @david" - end - - You need to install dev-utils yourself for this to work ("gem install dev-util"). - -* Added shared generator behavior so future upgrades should be possible without manually copying over files [Jeremy Kemper] - -* Added the new helper style to both controller and helper templates [Jeremy Kemper] - -* Added new_crud generator for creating a model and controller at the same time with explicit scaffolding [Jeremy Kemper] - -* Added configuration of Test::Unit::TestCase.fixture_path to test_helper to concide with the new AR fixtures style - -* Fixed that new_model was generating singular table/fixture names - -* Upgraded to Action Mailer 0.4.0 - -* Upgraded to Action Pack 0.9.5 - -* Upgraded to Active Record 1.1.0 - - -*0.8.0 (15)* - -* Removed custom_table_name option for new_model now that the Inflector is as powerful as it is - -* Changed the default rake action to just do testing and separate API generation and coding statistics into a "doc" task. - -* Fixed WEBrick dispatcher to handle missing slashes in the URLs gracefully [alexey] - -* Added user option for all postgresql tool calls in the rakefile [elvstone] - -* Fixed problem with running "ruby public/dispatch.servlet" instead of "cd public; ruby dispatch.servlet" [alexey] - -* Fixed WEBrick server so that it no longer hardcodes the ruby interpreter used to "ruby" but will get the one used based - on the Ruby runtime configuration. [Marcel Molina Jr.] - -* Fixed Dispatcher so it'll route requests to magic_beans to MagicBeansController/magic_beans_controller.rb [Caio Chassot] - -* "new_controller MagicBeans" and "new_model SubscriptionPayments" will now both behave properly as they use the new Inflector. - -* Fixed problem with MySQL foreign key constraint checks in Rake :clone_production_structure_to_test target [Andreas Schwarz] - -* Changed WEBrick server to by default be auto-reloading, which is slower but makes source changes instant. - Class compilation cache can be turned on with "-c" or "--cache-classes". - -* Added "-b/--binding" option to WEBrick dispatcher to bind the server to a specific IP address (default: 127.0.0.1) [Kevin Temp] - -* dispatch.fcgi now DOESN'T set FCGI_PURE_RUBY as it was slowing things down for now reason [Andreas Schwarz] - -* Added new_mailer generator to work with Action Mailer - -* Included new framework: Action Mailer 0.3 - -* Upgraded to Action Pack 0.9.0 - -* Upgraded to Active Record 1.0.0 - - -*0.7.0* - -* Added an optional second argument to the new_model script that allows the programmer to specify the table name, - which will used to generate a custom table_name method in the model and will also be used in the creation of fixtures. - [Kevin Radloff] - -* script/new_model now turns AccountHolder into account_holder instead of accountholder [Kevin Radloff] - -* Fixed the faulty handleing of static files with WEBrick [Andreas Schwarz] - -* Unified function_test_helper and unit_test_helper into test_helper - -* Fixed bug with the automated production => test database dropping on PostgreSQL [dhawkins] - -* create_fixtures in both the functional and unit test helper now turns off the log during fixture generation - and can generate more than one fixture at a time. Which makes it possible for assignments like: - - @people, @projects, @project_access, @companies, @accounts = - create_fixtures "people", "projects", "project_access", "companies", "accounts" - -* Upgraded to Action Pack 0.8.5 (locally-scoped variables, partials, advanced send_file) - -* Upgraded to Active Record 0.9.5 (better table_name guessing, cloning, find_all_in_collection) - - -*0.6.5* - -* No longer specifies a template for rdoc, so it'll use whatever is default (you can change it in the rakefile) - -* The new_model generator will now use the same rules for plural wordings as Active Record - (so Category will give categories, not categorys) [Kevin Radloff] - -* dispatch.fcgi now sets FCGI_PURE_RUBY to true to ensure that it's the Ruby version that's loaded [danp] - -* Made the GEM work with Windows - -* Fixed bug where mod_ruby would "forget" the load paths added when switching between controllers - -* PostgreSQL are now supported for the automated production => test database dropping [Kevin Radloff] - -* Errors thrown by the dispatcher are now properly handled in FCGI. - -* Upgraded to Action Pack 0.8.0 (lots and lots and lots of fixes) - -* Upgraded to Active Record 0.9.4 (a bunch of fixes) - - -*0.6.0* - -* Added AbstractionApplicationController as a superclass for all controllers generated. This class can be used - to carry filters and methods that are to be shared by all. It has an accompanying ApplicationHelper that all - controllers will also automatically have available. - -* Added environments that can be included from any script to get the full Active Record and Action Controller - context running. This can be used by maintenance scripts or to interact with the model through IRB. Example: - - require 'config/environments/production' - - for account in Account.find_all - account.recalculate_interests - end - - A short migration script for an account model that had it's interest calculation strategy changed. - -* Accessing the index of a controller with "/weblog" will now redirect to "/weblog/" (only on Apache, not WEBrick) - -* Simplified the default Apache config so even remote requests are served off CGI as a default. - You'll now have to do something specific to activate mod_ruby and FCGI (like using the force urls). - This should make it easier for new comers that start on an external server. - -* Added more of the necessary Apache options to .htaccess to make it easier to setup - -* Upgraded to Action Pack 0.7.9 (lots of fixes) - -* Upgraded to Active Record 0.9.3 (lots of fixes) - - -*0.5.7* - -* Fixed bug in the WEBrick dispatcher that prevented it from getting parameters from the URL - (through GET requests or otherwise) - -* Added lib in root as a place to store app specific libraries - -* Added lib and vendor to load_path, so anything store within can be loaded directly. - Hence lib/redcloth.rb can be loaded with require "redcloth" - -* Upgraded to Action Pack 0.7.8 (lots of fixes) - -* Upgraded to Active Record 0.9.2 (minor upgrade) - - -*0.5.6* - -* Upgraded to Action Pack 0.7.7 (multipart form fix) - -* Updated the generated template stubs to valid XHTML files - -* Ensure that controllers generated are capitalized, so "new_controller TodoLists" - gives the same as "new_controller Todolists" and "new_controller todolists". - - -*0.5.5* - -* Works on Windows out of the box! (Dropped symlinks) - -* Added webrick dispatcher: Try "ruby public/dispatch.servlet --help" [Florian Gross] - -* Report errors about initialization to browser (instead of attempting to use uninitialized logger) - -* Upgraded to Action Pack 0.7.6 - -* Upgraded to Active Record 0.9.1 - -* Added distinct 500.html instead of reusing 404.html - -* Added MIT license - - -*0.5.0* - -* First public release diff --git a/vendor/rails/railties/MIT-LICENSE b/vendor/rails/railties/MIT-LICENSE deleted file mode 100644 index e6df487..0000000 --- a/vendor/rails/railties/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2004-2009 David Heinemeier Hansson - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/vendor/rails/railties/README b/vendor/rails/railties/README deleted file mode 100644 index 37ec8ea..0000000 --- a/vendor/rails/railties/README +++ /dev/null @@ -1,243 +0,0 @@ -== Welcome to Rails - -Rails is a web-application framework that includes everything needed to create -database-backed web applications according to the Model-View-Control pattern. - -This pattern splits the view (also called the presentation) into "dumb" templates -that are primarily responsible for inserting pre-built data in between HTML tags. -The model contains the "smart" domain objects (such as Account, Product, Person, -Post) that holds all the business logic and knows how to persist themselves to -a database. The controller handles the incoming requests (such as Save New Account, -Update Product, Show Post) by manipulating the model and directing data to the view. - -In Rails, the model is handled by what's called an object-relational mapping -layer entitled Active Record. This layer allows you to present the data from -database rows as objects and embellish these data objects with business logic -methods. You can read more about Active Record in -link:files/vendor/rails/activerecord/README.html. - -The controller and view are handled by the Action Pack, which handles both -layers by its two parts: Action View and Action Controller. These two layers -are bundled in a single package due to their heavy interdependence. This is -unlike the relationship between the Active Record and Action Pack that is much -more separate. Each of these packages can be used independently outside of -Rails. You can read more about Action Pack in -link:files/vendor/rails/actionpack/README.html. - - -== Getting Started - -1. At the command prompt, start a new Rails application using the <tt>rails</tt> command - and your application name. Ex: rails myapp -2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options) -3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!" -4. Follow the guidelines to start developing your application - - -== Web Servers - -By default, Rails will try to use Mongrel if it's are installed when started with script/server, otherwise Rails will use WEBrick, the webserver that ships with Ruby. But you can also use Rails -with a variety of other web servers. - -Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is -suitable for development and deployment of Rails applications. If you have Ruby Gems installed, -getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>. -More info at: http://mongrel.rubyforge.org - -Say other Ruby web servers like Thin and Ebb or regular web servers like Apache or LiteSpeed or -Lighttpd or IIS. The Ruby web servers are run through Rack and the latter can either be setup to use -FCGI or proxy to a pack of Mongrels/Thin/Ebb servers. - -== Apache .htaccess example for FCGI/CGI - -# General Apache options -AddHandler fastcgi-script .fcgi -AddHandler cgi-script .cgi -Options +FollowSymLinks +ExecCGI - -# If you don't want Rails to look in certain directories, -# use the following rewrite rules so that Apache won't rewrite certain requests -# -# Example: -# RewriteCond %{REQUEST_URI} ^/notrails.* -# RewriteRule .* - [L] - -# Redirect all requests not available on the filesystem to Rails -# By default the cgi dispatcher is used which is very slow -# -# For better performance replace the dispatcher with the fastcgi one -# -# Example: -# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] -RewriteEngine On - -# If your Rails application is accessed via an Alias directive, -# then you MUST also set the RewriteBase in this htaccess file. -# -# Example: -# Alias /myrailsapp /path/to/myrailsapp/public -# RewriteBase /myrailsapp - -RewriteRule ^$ index.html [QSA] -RewriteRule ^([^.]+)$ $1.html [QSA] -RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^(.*)$ dispatch.cgi [QSA,L] - -# In case Rails experiences terminal errors -# Instead of displaying this message you can supply a file here which will be rendered instead -# -# Example: -# ErrorDocument 500 /500.html - -ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly" - - -== Debugging Rails - -Sometimes your application goes wrong. Fortunately there are a lot of tools that -will help you debug it and get it back on the rails. - -First area to check is the application log files. Have "tail -f" commands running -on the server.log and development.log. Rails will automatically display debugging -and runtime information to these files. Debugging info will also be shown in the -browser on requests from 127.0.0.1. - -You can also log your own messages directly into the log file from your code using -the Ruby logger class from inside your controllers. Example: - - class WeblogController < ActionController::Base - def destroy - @weblog = Weblog.find(params[:id]) - @weblog.destroy - logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!") - end - end - -The result will be a message in your log file along the lines of: - - Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1 - -More information on how to use the logger is at http://www.ruby-doc.org/core/ - -Also, Ruby documentation can be found at http://www.ruby-lang.org/ including: - -* The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/ -* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide) - -These two online (and free) books will bring you up to speed on the Ruby language -and also on programming in general. - - -== Debugger - -Debugger support is available through the debugger command when you start your Mongrel or -Webrick server with --debugger. This means that you can break out of execution at any point -in the code, investigate and change the model, AND then resume execution! -You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug' -Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find(:all) - debugger - end - end - -So the controller will accept the action, run the first line, then present you -with a IRB prompt in the server window. Here you can do things like: - - >> @posts.inspect - => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>, - #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]" - >> @posts.first.title = "hello from a debugger" - => "hello from a debugger" - -...and even better is that you can examine how your runtime objects actually work: - - >> f = @posts.first - => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}> - >> f. - Display all 152 possibilities? (y or n) - -Finally, when you're ready to resume execution, you enter "cont" - - -== Console - -You can interact with the domain model by starting the console through <tt>script/console</tt>. -Here you'll have all parts of the application configured, just like it is when the -application is running. You can inspect domain models, change values, and save to the -database. Starting the script without arguments will launch it in the development environment. -Passing an argument will specify a different environment, like <tt>script/console production</tt>. - -To reload your controllers and models after launching the console run <tt>reload!</tt> - -== dbconsole - -You can go to the command line of your database directly through <tt>script/dbconsole</tt>. -You would be connected to the database with the credentials defined in database.yml. -Starting the script without arguments will connect you to the development database. Passing an -argument will connect you to a different database, like <tt>script/dbconsole production</tt>. -Currently works for mysql, postgresql and sqlite. - -== Description of Contents - -app - Holds all the code that's specific to this particular application. - -app/controllers - Holds controllers that should be named like weblogs_controller.rb for - automated URL mapping. All controllers should descend from ApplicationController - which itself descends from ActionController::Base. - -app/models - Holds models that should be named like post.rb. - Most models will descend from ActiveRecord::Base. - -app/views - Holds the template files for the view that should be named like - weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby - syntax. - -app/views/layouts - Holds the template files for layouts to be used with views. This models the common - header/footer method of wrapping views. In your views, define a layout using the - <tt>layout :default</tt> and create a file named default.html.erb. Inside default.html.erb, - call <% yield %> to render the view using this layout. - -app/helpers - Holds view helpers that should be named like weblogs_helper.rb. These are generated - for you automatically when using script/generate for controllers. Helpers can be used to - wrap functionality for your views into methods. - -config - Configuration files for the Rails environment, the routing map, the database, and other dependencies. - -db - Contains the database schema in schema.rb. db/migrate contains all - the sequence of Migrations for your schema. - -doc - This directory is where your application documentation will be stored when generated - using <tt>rake doc:app</tt> - -lib - Application specific libraries. Basically, any kind of custom code that doesn't - belong under controllers, models, or helpers. This directory is in the load path. - -public - The directory available for the web server. Contains subdirectories for images, stylesheets, - and javascripts. Also contains the dispatchers and the default HTML files. This should be - set as the DOCUMENT_ROOT of your web server. - -script - Helper scripts for automation and generation. - -test - Unit and functional tests along with fixtures. When using the script/generate scripts, template - test files will be generated for you and placed in this directory. - -vendor - External libraries that the application depends on. Also includes the plugins subdirectory. - If the app has frozen rails, those gems also go here, under vendor/rails/. - This directory is in the load path. diff --git a/vendor/rails/railties/Rakefile b/vendor/rails/railties/Rakefile deleted file mode 100644 index 6c0fc22..0000000 --- a/vendor/rails/railties/Rakefile +++ /dev/null @@ -1,364 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' -require 'rake/gempackagetask' -require 'rake/contrib/rubyforgepublisher' - -require 'date' -require 'rbconfig' - -require File.join(File.dirname(__FILE__), 'lib/rails', 'version') - -PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' -PKG_NAME = 'rails' -PKG_VERSION = Rails::VERSION::STRING + PKG_BUILD -PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" -PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}" - -RELEASE_NAME = "REL #{PKG_VERSION}" - -RUBY_FORGE_PROJECT = "rails" -RUBY_FORGE_USER = "webster132" - - -task :default => :test - -## This is required until the regular test task -## below passes. It's not ideal, but at least -## we can see the failures -task :test do - Dir['test/**/*_test.rb'].all? do |file| - ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')) - system(ruby, '-Itest', file) - end or raise "Failures" -end - -Rake::TestTask.new("regular_test") do |t| - t.libs << 'test' - t.pattern = 'test/**/*_test.rb' - t.warning = true - t.verbose = true -end - - -BASE_DIRS = %w( - app - config/environments - config/initializers - config/locales - db - doc - log - lib - lib/tasks - public - script - script/performance - test - vendor - vendor/plugins - tmp/sessions - tmp/cache - tmp/sockets - tmp/pids -) - -APP_DIRS = %w( models controllers helpers views views/layouts ) -PUBLIC_DIRS = %w( images javascripts stylesheets ) -TEST_DIRS = %w( fixtures unit functional mocks mocks/development mocks/test ) - -LOG_FILES = %w( server.log development.log test.log production.log ) -HTML_FILES = %w( 422.html 404.html 500.html index.html robots.txt favicon.ico images/rails.png - javascripts/prototype.js javascripts/application.js - javascripts/effects.js javascripts/dragdrop.js javascripts/controls.js ) -BIN_FILES = %w( about console destroy generate performance/benchmarker performance/profiler runner server plugin ) - -VENDOR_LIBS = %w( actionpack activerecord actionmailer activesupport activeresource railties ) - - -desc "Generates a fresh Rails package with documentation" -task :fresh_rails => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_vendor_libraries, :copy_ties_content, :generate_documentation ] - -desc "Generates a fresh Rails package using GEMs with documentation" -task :fresh_gem_rails => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_ties_content, :copy_gem_environment ] - -desc "Generates a fresh Rails package without documentation (faster)" -task :fresh_rails_without_docs => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_vendor_libraries, :copy_ties_content ] - -desc "Generates a fresh Rails package without documentation (faster)" -task :fresh_rails_without_docs_using_links => [ :clean, :make_dir_structure, :initialize_file_stubs, :link_vendor_libraries, :copy_ties_content ] - -desc "Generates minimal Rails package using symlinks" -task :dev => [ :clean, :make_dir_structure, :initialize_file_stubs, :link_vendor_libraries, :copy_ties_content ] - -desc "Packages the fresh Rails package with documentation" -task :package => [ :clean, :fresh_rails ] do - system %{cd ..; tar -czvf #{PKG_NAME}-#{PKG_VERSION}.tgz #{PKG_NAME}} - system %{cd ..; zip -r #{PKG_NAME}-#{PKG_VERSION}.zip #{PKG_NAME}} -end - -task :clean do - rm_rf PKG_DESTINATION -end - -# Get external spinoffs ------------------------------------------------------------------- - -desc "Updates railties to the latest version of the javascript spinoffs" -task :update_js do - for js in %w( prototype controls dragdrop effects ) - rm "html/javascripts/#{js}.js" - cp "./../actionpack/lib/action_view/helpers/javascripts/#{js}.js", "html/javascripts" - end -end - -# Make directory structure ---------------------------------------------------------------- - -def make_dest_dirs(dirs, path = '.') - mkdir_p dirs.map { |dir| File.join(PKG_DESTINATION, path.to_s, dir) } -end - -desc "Make the directory structure for the new Rails application" -task :make_dir_structure => [ :make_base_dirs, :make_app_dirs, :make_public_dirs, :make_test_dirs ] - -task(:make_base_dirs) { make_dest_dirs BASE_DIRS } -task(:make_app_dirs) { make_dest_dirs APP_DIRS, 'app' } -task(:make_public_dirs) { make_dest_dirs PUBLIC_DIRS, 'public' } -task(:make_test_dirs) { make_dest_dirs TEST_DIRS, 'test' } - - -# Initialize file stubs ------------------------------------------------------------------- - -desc "Initialize empty file stubs (such as for logging)" -task :initialize_file_stubs => [ :initialize_log_files ] - -task :initialize_log_files do - log_dir = File.join(PKG_DESTINATION, 'log') - chmod 0777, log_dir - LOG_FILES.each do |log_file| - log_path = File.join(log_dir, log_file) - touch log_path - chmod 0666, log_path - end -end - - -# Copy Vendors ---------------------------------------------------------------------------- - -desc "Copy in all the Rails packages to vendor" -task :copy_vendor_libraries do - mkdir File.join(PKG_DESTINATION, 'vendor', 'rails') - VENDOR_LIBS.each { |dir| cp_r File.join('..', dir), File.join(PKG_DESTINATION, 'vendor', 'rails', dir) } - FileUtils.rm_r(Dir.glob(File.join(PKG_DESTINATION, 'vendor', 'rails', "**", ".svn"))) -end - -desc "Link in all the Rails packages to vendor" -task :link_vendor_libraries do - mkdir File.join(PKG_DESTINATION, 'vendor', 'rails') - VENDOR_LIBS.each { |dir| ln_s File.join('..', '..', '..', dir), File.join(PKG_DESTINATION, 'vendor', 'rails', dir) } -end - - -# Copy Ties Content ----------------------------------------------------------------------- - -desc "Make copies of all the default content of ties" -task :copy_ties_content => [ - :copy_rootfiles, :copy_dispatches, :copy_html_files, :copy_application, - :copy_configs, :copy_binfiles, :copy_test_helpers, :copy_app_doc_readme ] - -task :copy_dispatches do - copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.rb") - chmod 0755, "#{PKG_DESTINATION}/public/dispatch.rb" - - copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.cgi") - chmod 0755, "#{PKG_DESTINATION}/public/dispatch.cgi" - - copy_with_rewritten_ruby_path("dispatches/dispatch.fcgi", "#{PKG_DESTINATION}/public/dispatch.fcgi") - chmod 0755, "#{PKG_DESTINATION}/public/dispatch.fcgi" -end - -task :copy_html_files do - HTML_FILES.each { |file| cp File.join('html', file), File.join(PKG_DESTINATION, 'public', file) } -end - -task :copy_application do - cp "helpers/application_controller.rb", "#{PKG_DESTINATION}/app/controllers/application_controller.rb" - cp "helpers/application_helper.rb", "#{PKG_DESTINATION}/app/helpers/application_helper.rb" -end - -task :copy_configs do - app_name = "rails" - socket = nil - require 'erb' - File.open("#{PKG_DESTINATION}/config/database.yml", 'w') {|f| f.write ERB.new(IO.read("configs/databases/sqlite3.yml"), nil, '-').result(binding)} - - cp "configs/routes.rb", "#{PKG_DESTINATION}/config/routes.rb" - - cp "configs/initializers/backtrace_silencers.rb", "#{PKG_DESTINATION}/config/initializers/backtrace_silencers.rb" - cp "configs/initializers/inflections.rb", "#{PKG_DESTINATION}/config/initializers/inflections.rb" - cp "configs/initializers/mime_types.rb", "#{PKG_DESTINATION}/config/initializers/mime_types.rb" - cp "configs/initializers/new_rails_defaults.rb", "#{PKG_DESTINATION}/config/initializers/new_rails_defaults.rb" - - cp "configs/locales/en.yml", "#{PKG_DESTINATION}/config/locales/en.yml" - - cp "environments/boot.rb", "#{PKG_DESTINATION}/config/boot.rb" - cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb" - cp "environments/production.rb", "#{PKG_DESTINATION}/config/environments/production.rb" - cp "environments/development.rb", "#{PKG_DESTINATION}/config/environments/development.rb" - cp "environments/test.rb", "#{PKG_DESTINATION}/config/environments/test.rb" -end - -task :copy_binfiles do - BIN_FILES.each do |file| - dest_file = File.join(PKG_DESTINATION, 'script', file) - copy_with_rewritten_ruby_path(File.join('bin', file), dest_file) - chmod 0755, dest_file - end -end - -task :copy_rootfiles do - cp "fresh_rakefile", "#{PKG_DESTINATION}/Rakefile" - cp "README", "#{PKG_DESTINATION}/README" - cp "CHANGELOG", "#{PKG_DESTINATION}/CHANGELOG" -end - -task :copy_test_helpers do - cp "helpers/test_helper.rb", "#{PKG_DESTINATION}/test/test_helper.rb" -end - -task :copy_app_doc_readme do - cp "doc/README_FOR_APP", "#{PKG_DESTINATION}/doc/README_FOR_APP" -end - -def copy_with_rewritten_ruby_path(src_file, dest_file) - ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) - - File.open(dest_file, 'w') do |df| - File.open(src_file) do |sf| - line = sf.gets - if (line =~ /#!.+ruby\s*/) != nil - df.puts("#!#{ruby}") - else - df.puts(line) - end - df.write(sf.read) - end - end -end - -desc 'Generate guides (for authors), use ONLY=foo to process just "foo.textile"' -task :guides do - ruby "guides/rails_guides.rb" -end - - -# Generate documentation ------------------------------------------------------------------ - -desc "Generate documentation for the framework and for the empty application" -task :generate_documentation => [ :generate_app_doc, :generate_rails_framework_doc ] - -task :generate_rails_framework_doc do - system %{cd #{PKG_DESTINATION}; rake doc:rails} -end - -task :generate_app_doc do - cp "doc/README_FOR_APP", "#{PKG_DESTINATION}/doc/README_FOR_APP" - system %{cd #{PKG_DESTINATION}; rake doc:app} -end - -Rake::RDocTask.new { |rdoc| - rdoc.rdoc_dir = 'doc' - rdoc.title = "Railties -- Gluing the Engine to the Rails" - rdoc.options << '--line-numbers' << '--inline-source' << '--accessor' << 'cattr_accessor=object' - rdoc.options << '--charset' << 'utf-8' - rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo' - rdoc.rdoc_files.include('README', 'CHANGELOG') - rdoc.rdoc_files.include('lib/*.rb') - rdoc.rdoc_files.include('lib/rails/*.rb') - rdoc.rdoc_files.include('lib/rails_generator/*.rb') - rdoc.rdoc_files.include('lib/commands/**/*.rb') -} - -# Generate GEM ---------------------------------------------------------------------------- - -task :copy_gem_environment do - cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb" - chmod 0755, dest_file -end - - -PKG_FILES = FileList[ - '[a-zA-Z]*', - 'bin/**/*', - 'builtin/**/*', - 'configs/**/*', - 'doc/**/*', - 'dispatches/**/*', - 'environments/**/*', - 'helpers/**/*', - 'generators/**/*', - 'html/**/*', - 'lib/**/*' -] - [ 'test' ] - -spec = Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = 'rails' - s.version = PKG_VERSION - s.summary = "Web-application framework with template engine, control-flow layer, and ORM." - s.description = <<-EOF - Rails is a framework for building web-application using CGI, FCGI, mod_ruby, or WEBrick - on top of either MySQL, PostgreSQL, SQLite, DB2, SQL Server, or Oracle with eRuby- or Builder-based templates. - EOF - - s.add_dependency('rake', '>= 0.8.3') - s.add_dependency('activesupport', '= 2.3.2' + PKG_BUILD) - s.add_dependency('activerecord', '= 2.3.2' + PKG_BUILD) - s.add_dependency('actionpack', '= 2.3.2' + PKG_BUILD) - s.add_dependency('actionmailer', '= 2.3.2' + PKG_BUILD) - s.add_dependency('activeresource', '= 2.3.2' + PKG_BUILD) - - s.rdoc_options << '--exclude' << '.' - s.has_rdoc = false - - s.files = PKG_FILES.to_a.delete_if {|f| f.include?('.svn')} - s.require_path = 'lib' - s.bindir = "bin" # Use these for applications. - s.executables = ["rails"] - s.default_executable = "rails" - - s.author = "David Heinemeier Hansson" - s.email = "david@loudthinking.com" - s.homepage = "http://www.rubyonrails.org" - s.rubyforge_project = "rails" -end - -Rake::GemPackageTask.new(spec) do |pkg| - pkg.gem_spec = spec -end - - -# Publishing ------------------------------------------------------- -desc "Publish the rails gem" -task :pgem => [:gem] do - Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload - `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'` -end - -desc "Publish the guides" -task :pguides => :guides do - mkdir_p 'pkg' - `tar -czf pkg/guides.gz guides/output` - Rake::SshFilePublisher.new("web.rubyonrails.org", "/u/sites/guides.rubyonrails.org/public", "pkg", "guides.gz").upload - `ssh web.rubyonrails.org 'cd /u/sites/guides.rubyonrails.org/public/ && tar -xvzf guides.gz && mv guides/output/* . && rm -rf guides*'` -end - -desc "Publish the release files to RubyForge." -task :release => [ :package ] do - require 'rubyforge' - - packages = %w( gem ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" } - - rubyforge = RubyForge.new - rubyforge.login - rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages) -end diff --git a/vendor/rails/railties/bin/about b/vendor/rails/railties/bin/about deleted file mode 100755 index ed8deb0..0000000 --- a/vendor/rails/railties/bin/about +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" -require 'commands/about' \ No newline at end of file diff --git a/vendor/rails/railties/bin/console b/vendor/rails/railties/bin/console deleted file mode 100755 index 498077a..0000000 --- a/vendor/rails/railties/bin/console +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/console' diff --git a/vendor/rails/railties/bin/dbconsole b/vendor/rails/railties/bin/dbconsole deleted file mode 100755 index caa60ce..0000000 --- a/vendor/rails/railties/bin/dbconsole +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/dbconsole' diff --git a/vendor/rails/railties/bin/destroy b/vendor/rails/railties/bin/destroy deleted file mode 100755 index a4df765..0000000 --- a/vendor/rails/railties/bin/destroy +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/destroy' diff --git a/vendor/rails/railties/bin/generate b/vendor/rails/railties/bin/generate deleted file mode 100755 index 173a9f1..0000000 --- a/vendor/rails/railties/bin/generate +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/generate' diff --git a/vendor/rails/railties/bin/performance/benchmarker b/vendor/rails/railties/bin/performance/benchmarker deleted file mode 100755 index c842d35..0000000 --- a/vendor/rails/railties/bin/performance/benchmarker +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/performance/benchmarker' diff --git a/vendor/rails/railties/bin/performance/profiler b/vendor/rails/railties/bin/performance/profiler deleted file mode 100755 index d855ac8..0000000 --- a/vendor/rails/railties/bin/performance/profiler +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/performance/profiler' diff --git a/vendor/rails/railties/bin/plugin b/vendor/rails/railties/bin/plugin deleted file mode 100755 index 87cd207..0000000 --- a/vendor/rails/railties/bin/plugin +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/plugin' diff --git a/vendor/rails/railties/bin/rails b/vendor/rails/railties/bin/rails deleted file mode 100755 index 6a0c675..0000000 --- a/vendor/rails/railties/bin/rails +++ /dev/null @@ -1,20 +0,0 @@ -require File.dirname(__FILE__) + '/../lib/ruby_version_check' -Signal.trap("INT") { puts; exit } - -require File.dirname(__FILE__) + '/../lib/rails/version' -if %w(--version -v).include? ARGV.first - puts "Rails #{Rails::VERSION::STRING}" - exit(0) -end - -freeze = ARGV.any? { |option| %w(--freeze -f).include?(option) } - -app_path = ARGV.first - -require File.dirname(__FILE__) + '/../lib/rails_generator' - -require 'rails_generator/scripts/generate' -Rails::Generator::Base.use_application_sources! -Rails::Generator::Scripts::Generate.new.run(ARGV, :generator => 'app') - -Dir.chdir(app_path) { `rake rails:freeze:gems`; puts "froze" } if freeze \ No newline at end of file diff --git a/vendor/rails/railties/bin/runner b/vendor/rails/railties/bin/runner deleted file mode 100755 index a4a7cb2..0000000 --- a/vendor/rails/railties/bin/runner +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/runner' diff --git a/vendor/rails/railties/bin/server b/vendor/rails/railties/bin/server deleted file mode 100755 index 3c67f39..0000000 --- a/vendor/rails/railties/bin/server +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/server' diff --git a/vendor/rails/railties/builtin/rails_info/rails/info.rb b/vendor/rails/railties/builtin/rails_info/rails/info.rb deleted file mode 100644 index a20d9bf..0000000 --- a/vendor/rails/railties/builtin/rails_info/rails/info.rb +++ /dev/null @@ -1,129 +0,0 @@ -module Rails - module Info - mattr_accessor :properties - class << (@@properties = []) - def names - map &:first - end - - def value_for(property_name) - if property = assoc(property_name) - property.last - end - end - end - - class << self #:nodoc: - def property(name, value = nil) - value ||= yield - properties << [name, value] if value - rescue Exception - end - - def frameworks - %w( active_record action_pack active_resource action_mailer active_support ) - end - - def framework_version(framework) - require "#{framework}/version" - "#{framework.classify}::VERSION::STRING".constantize - end - - def edge_rails_revision(info = git_info) - info[/commit ([a-z0-9-]+)/, 1] || freeze_edge_version - end - - def freeze_edge_version - if File.exist?(rails_vendor_root) - begin - Dir[File.join(rails_vendor_root, 'REVISION_*')].first.scan(/_(\d+)$/).first.first - rescue - Dir[File.join(rails_vendor_root, 'TAG_*')].first.scan(/_(.+)$/).first.first rescue 'unknown' - end - end - end - - def to_s - column_width = properties.names.map {|name| name.length}.max - ["About your application's environment", *properties.map do |property| - "%-#{column_width}s %s" % property - end] * "\n" - end - - alias inspect to_s - - def to_html - returning table = '<table>' do - properties.each do |(name, value)| - table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>) - table << %(<td class="value">#{CGI.escapeHTML(value.to_s)}</td></tr>) - end - table << '</table>' - end - end - - protected - def rails_vendor_root - @rails_vendor_root ||= "#{RAILS_ROOT}/vendor/rails" - end - - def git_info - env_lang, ENV['LC_ALL'] = ENV['LC_ALL'], 'C' - Dir.chdir(rails_vendor_root) do - silence_stderr { `git log -n 1` } - end - ensure - ENV['LC_ALL'] = env_lang - end - end - - # The Ruby version and platform, e.g. "1.8.2 (powerpc-darwin8.2.0)". - property 'Ruby version', "#{RUBY_VERSION} (#{RUBY_PLATFORM})" - - # The RubyGems version, if it's installed. - property 'RubyGems version' do - Gem::RubyGemsVersion - end - - property 'Rack version' do - ::Rack.release - end - - # The Rails version. - property 'Rails version' do - Rails::VERSION::STRING - end - - # Versions of each Rails framework (Active Record, Action Pack, - # Active Resource, Action Mailer, and Active Support). - frameworks.each do |framework| - property "#{framework.titlecase} version" do - framework_version(framework) - end - end - - # The Rails Git revision, if it's checked out into vendor/rails. - property 'Edge Rails revision' do - edge_rails_revision - end - - # The application's location on the filesystem. - property 'Application root' do - File.expand_path(RAILS_ROOT) - end - - # The current Rails environment (development, test, or production). - property 'Environment' do - RAILS_ENV - end - - # The name of the database adapter for the current environment. - property 'Database adapter' do - ActiveRecord::Base.configurations[RAILS_ENV]['adapter'] - end - - property 'Database schema version' do - ActiveRecord::Migrator.current_version rescue nil - end - end -end diff --git a/vendor/rails/railties/builtin/rails_info/rails/info_controller.rb b/vendor/rails/railties/builtin/rails_info/rails/info_controller.rb deleted file mode 100644 index 05745d6..0000000 --- a/vendor/rails/railties/builtin/rails_info/rails/info_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Rails::InfoController < ActionController::Base - def properties - if consider_all_requests_local || local_request? - render :inline => Rails::Info.to_html - else - render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => 500 - end - end -end diff --git a/vendor/rails/railties/builtin/rails_info/rails/info_helper.rb b/vendor/rails/railties/builtin/rails_info/rails/info_helper.rb deleted file mode 100644 index e5605a8..0000000 --- a/vendor/rails/railties/builtin/rails_info/rails/info_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Rails::InfoHelper -end diff --git a/vendor/rails/railties/builtin/rails_info/rails_info_controller.rb b/vendor/rails/railties/builtin/rails_info/rails_info_controller.rb deleted file mode 100644 index 2009eb3..0000000 --- a/vendor/rails/railties/builtin/rails_info/rails_info_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -# Alias to ensure old public.html still works. -RailsInfoController = Rails::InfoController diff --git a/vendor/rails/railties/configs/databases/frontbase.yml b/vendor/rails/railties/configs/databases/frontbase.yml deleted file mode 100644 index c0c3588..0000000 --- a/vendor/rails/railties/configs/databases/frontbase.yml +++ /dev/null @@ -1,28 +0,0 @@ -# FrontBase versions 4.x -# -# Get the bindings: -# gem install ruby-frontbase - -development: - adapter: frontbase - host: localhost - database: <%= app_name %>_development - username: <%= app_name %> - password: '' - -# 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: frontbase - host: localhost - database: <%= app_name %>_test - username: <%= app_name %> - password: '' - -production: - adapter: frontbase - host: localhost - database: <%= app_name %>_production - username: <%= app_name %> - password: '' diff --git a/vendor/rails/railties/configs/databases/ibm_db.yml b/vendor/rails/railties/configs/databases/ibm_db.yml deleted file mode 100644 index a9716dd..0000000 --- a/vendor/rails/railties/configs/databases/ibm_db.yml +++ /dev/null @@ -1,62 +0,0 @@ -# IBM Dataservers -# -# Home Page -# http://rubyforge.org/projects/rubyibm/ -# -# To install the ibm_db gem: -# On Linux: -# Source the db2profile file and set the necessary environment variables: -# -# . /home/db2inst1/sqllib/db2profile -# export IBM_DB_DIR=/opt/ibm/db2/V9.1 -# export IBM_DB_LIB=/opt/ibm/db2/V9.1/lib32 -# -# Then issue the command: gem install ibm_db -# -# On Windows: -# Issue the command: gem install ibm_db -# If prompted, select the mswin32 option -# -# For more details on the installation refer to http://rubyforge.org/docman/view.php/2361/7682/IBM_DB_GEM.pdf -# -# For more details on the connection parameters below refer to: -# http://rubyibm.rubyforge.org/docs/adapter/0.9.0/rdoc/classes/ActiveRecord/ConnectionAdapters/IBM_DBAdapter.html - -development: - adapter: ibm_db - username: db2inst1 - password: - database: <%= app_name[0,4] %>_dev - #schema: db2inst1 - #host: localhost - #port: 50000 - #account: my_account - #app_user: my_app_user - #application: my_application - #workstation: my_workstation - -test: - adapter: ibm_db - username: db2inst1 - password: - database: <%= app_name[0,4] %>_tst - #schema: db2inst1 - #host: localhost - #port: 50000 - #account: my_account - #app_user: my_app_user - #application: my_application - #workstation: my_workstation - -production: - adapter: ibm_db - username: db2inst1 - password: - database: <%= app_name[0,4] %>_prd - #schema: db2inst1 - #host: localhost - #port: 50000 - #account: my_account - #app_user: my_app_user - #application: my_application - #workstation: my_workstation \ No newline at end of file diff --git a/vendor/rails/railties/configs/databases/mysql.yml b/vendor/rails/railties/configs/databases/mysql.yml deleted file mode 100644 index 1a14bfb..0000000 --- a/vendor/rails/railties/configs/databases/mysql.yml +++ /dev/null @@ -1,60 +0,0 @@ -# MySQL. Versions 4.1 and 5.0 are recommended. -# -# Install the MySQL driver: -# gem install mysql -# On Mac OS X: -# sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql -# On Mac OS X Leopard: -# sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config -# This sets the ARCHFLAGS environment variable to your native architecture -# On Windows: -# gem install mysql -# Choose the win32 build. -# Install MySQL and put its /bin directory on your path. -# -# And be sure to use new-style password hashing: -# http://dev.mysql.com/doc/refman/5.0/en/old-client.html -development: - adapter: mysql - encoding: utf8 - reconnect: false - database: <%= app_name %>_development - pool: 5 - username: root - password: -<% if socket -%> - socket: <%= socket %> -<% else -%> - host: localhost -<% end -%> - -# 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: mysql - encoding: utf8 - reconnect: false - database: <%= app_name %>_test - pool: 5 - username: root - password: -<% if socket -%> - socket: <%= socket %> -<% else -%> - host: localhost -<% end -%> - -production: - adapter: mysql - encoding: utf8 - reconnect: false - database: <%= app_name %>_production - pool: 5 - username: root - password: -<% if socket -%> - socket: <%= socket %> -<% else -%> - host: localhost -<% end -%> diff --git a/vendor/rails/railties/configs/databases/oracle.yml b/vendor/rails/railties/configs/databases/oracle.yml deleted file mode 100644 index a1883f6..0000000 --- a/vendor/rails/railties/configs/databases/oracle.yml +++ /dev/null @@ -1,39 +0,0 @@ -# Oracle/OCI 8i, 9, 10g -# -# Requires Ruby/OCI8: -# http://rubyforge.org/projects/ruby-oci8/ -# -# Specify your database using any valid connection syntax, such as a -# tnsnames.ora service name, or a SQL connect url string of the form: -# -# //host:[port][/service name] -# -# By default prefetch_rows (OCI_ATTR_PREFETCH_ROWS) is set to 100. And -# until true bind variables are supported, cursor_sharing is set by default -# to 'similar'. Both can be changed in the configation below; the defaults -# are equivalent to specifying: -# -# prefetch_rows: 100 -# cursor_sharing: similar -# - -development: - adapter: oracle - database: <%= app_name %>_development - username: <%= app_name %> - password: - -# 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: oracle - database: <%= app_name %>_test - username: <%= app_name %> - password: - -production: - adapter: oracle - database: <%= app_name %>_production - username: <%= app_name %> - password: diff --git a/vendor/rails/railties/configs/databases/postgresql.yml b/vendor/rails/railties/configs/databases/postgresql.yml deleted file mode 100644 index f600e05..0000000 --- a/vendor/rails/railties/configs/databases/postgresql.yml +++ /dev/null @@ -1,51 +0,0 @@ -# PostgreSQL. Versions 7.4 and 8.x are supported. -# -# Install the ruby-postgres driver: -# gem install ruby-postgres -# On Mac OS X: -# gem install ruby-postgres -- --include=/usr/local/pgsql -# On Windows: -# gem install ruby-postgres -# Choose the win32 build. -# Install PostgreSQL and put its /bin directory on your path. -development: - adapter: postgresql - encoding: unicode - database: <%= app_name %>_development - pool: 5 - username: <%= app_name %> - password: - - # Connect on a TCP socket. Omitted by default since the client uses a - # domain socket that doesn't need configuration. Windows does not have - # domain sockets, so uncomment these lines. - #host: localhost - #port: 5432 - - # Schema search path. The server defaults to $user,public - #schema_search_path: myapp,sharedapp,public - - # Minimum log levels, in increasing order: - # debug5, debug4, debug3, debug2, debug1, - # log, notice, warning, error, fatal, and panic - # The server defaults to notice. - #min_messages: warning - -# 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: postgresql - encoding: unicode - database: <%= app_name %>_test - pool: 5 - username: <%= app_name %> - password: - -production: - adapter: postgresql - encoding: unicode - database: <%= app_name %>_production - pool: 5 - username: <%= app_name %> - password: diff --git a/vendor/rails/railties/configs/databases/sqlite2.yml b/vendor/rails/railties/configs/databases/sqlite2.yml deleted file mode 100644 index 46f01cb..0000000 --- a/vendor/rails/railties/configs/databases/sqlite2.yml +++ /dev/null @@ -1,19 +0,0 @@ -# SQLite version 2.x -# gem install sqlite-ruby -development: - adapter: sqlite - database: db/development.sqlite2 - pool: 5 - -# 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: sqlite - database: db/test.sqlite2 - pool: 5 - -production: - adapter: sqlite - database: db/production.sqlite2 - pool: 5 diff --git a/vendor/rails/railties/configs/databases/sqlite3.yml b/vendor/rails/railties/configs/databases/sqlite3.yml deleted file mode 100644 index 025d62a..0000000 --- a/vendor/rails/railties/configs/databases/sqlite3.yml +++ /dev/null @@ -1,22 +0,0 @@ -# SQLite version 3.x -# gem install sqlite3-ruby (not necessary on OS X Leopard) -development: - adapter: sqlite3 - database: db/development.sqlite3 - 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: db/test.sqlite3 - pool: 5 - timeout: 5000 - -production: - adapter: sqlite3 - database: db/production.sqlite3 - pool: 5 - timeout: 5000 diff --git a/vendor/rails/railties/configs/empty.log b/vendor/rails/railties/configs/empty.log deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/rails/railties/configs/initializers/backtrace_silencers.rb b/vendor/rails/railties/configs/initializers/backtrace_silencers.rb deleted file mode 100644 index c2169ed..0000000 --- a/vendor/rails/railties/configs/initializers/backtrace_silencers.rb +++ /dev/null @@ -1,7 +0,0 @@ -# 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! \ No newline at end of file diff --git a/vendor/rails/railties/configs/initializers/inflections.rb b/vendor/rails/railties/configs/initializers/inflections.rb deleted file mode 100644 index d531b8b..0000000 --- a/vendor/rails/railties/configs/initializers/inflections.rb +++ /dev/null @@ -1,10 +0,0 @@ -# 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 diff --git a/vendor/rails/railties/configs/initializers/mime_types.rb b/vendor/rails/railties/configs/initializers/mime_types.rb deleted file mode 100644 index 72aca7e..0000000 --- a/vendor/rails/railties/configs/initializers/mime_types.rb +++ /dev/null @@ -1,5 +0,0 @@ -# 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 diff --git a/vendor/rails/railties/configs/initializers/new_rails_defaults.rb b/vendor/rails/railties/configs/initializers/new_rails_defaults.rb deleted file mode 100644 index 8ec3186..0000000 --- a/vendor/rails/railties/configs/initializers/new_rails_defaults.rb +++ /dev/null @@ -1,19 +0,0 @@ -# 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 - -# 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 \ No newline at end of file diff --git a/vendor/rails/railties/configs/initializers/session_store.rb b/vendor/rails/railties/configs/initializers/session_store.rb deleted file mode 100644 index 4499ab8..0000000 --- a/vendor/rails/railties/configs/initializers/session_store.rb +++ /dev/null @@ -1,15 +0,0 @@ -# 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 => '_<%= app_name %>_session', - :secret => '<%= app_secret %>' -} - -# 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 diff --git a/vendor/rails/railties/configs/locales/en.yml b/vendor/rails/railties/configs/locales/en.yml deleted file mode 100644 index f265c06..0000000 --- a/vendor/rails/railties/configs/locales/en.yml +++ /dev/null @@ -1,5 +0,0 @@ -# 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" \ No newline at end of file diff --git a/vendor/rails/railties/configs/routes.rb b/vendor/rails/railties/configs/routes.rb deleted file mode 100644 index 4f3d9d2..0000000 --- a/vendor/rails/railties/configs/routes.rb +++ /dev/null @@ -1,43 +0,0 @@ -ActionController::Routing::Routes.draw do |map| - # 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 the them or commenting them out if you're using named routes and resources. - map.connect ':controller/:action/:id' - map.connect ':controller/:action/:id.:format' -end diff --git a/vendor/rails/railties/dispatches/config.ru b/vendor/rails/railties/dispatches/config.ru deleted file mode 100644 index acbfe4e..0000000 --- a/vendor/rails/railties/dispatches/config.ru +++ /dev/null @@ -1,7 +0,0 @@ -# Rack Dispatcher - -# Require your environment file to bootstrap Rails -require File.dirname(__FILE__) + '/config/environment' - -# Dispatch the request -run ActionController::Dispatcher.new diff --git a/vendor/rails/railties/dispatches/dispatch.fcgi b/vendor/rails/railties/dispatches/dispatch.fcgi deleted file mode 100755 index 664dbbb..0000000 --- a/vendor/rails/railties/dispatches/dispatch.fcgi +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env ruby -# -# You may specify the path to the FastCGI crash log (a log of unhandled -# exceptions which forced the FastCGI instance to exit, great for debugging) -# and the number of requests to process before running garbage collection. -# -# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log -# and the GC period is nil (turned off). A reasonable number of requests -# could range from 10-100 depending on the memory footprint of your app. -# -# Example: -# # Default log path, normal GC behavior. -# RailsFCGIHandler.process! -# -# # Default log path, 50 requests between GC. -# RailsFCGIHandler.process! nil, 50 -# -# # Custom log path, normal GC behavior. -# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log' -# -require File.dirname(__FILE__) + "/../config/environment" -require 'fcgi_handler' - -RailsFCGIHandler.process! diff --git a/vendor/rails/railties/dispatches/dispatch.rb b/vendor/rails/railties/dispatches/dispatch.rb deleted file mode 100755 index 32fa3b2..0000000 --- a/vendor/rails/railties/dispatches/dispatch.rb +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) - -# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: -# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired -require "dispatcher" - -ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) -Dispatcher.dispatch diff --git a/vendor/rails/railties/dispatches/gateway.cgi b/vendor/rails/railties/dispatches/gateway.cgi deleted file mode 100755 index 0305b7f..0000000 --- a/vendor/rails/railties/dispatches/gateway.cgi +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env ruby - -require 'drb' - -# This file includes an experimental gateway CGI implementation. It will work -# only on platforms which support both fork and sockets. -# -# To enable it edit public/.htaccess and replace dispatch.cgi with gateway.cgi. -# -# Next, create the directory log/drb_gateway and grant the apache user rw access -# to said directory. -# -# On the next request to your server, the gateway tracker should start up, along -# with a few listener processes. This setup should provide you with much better -# speeds than dispatch.cgi. -# -# Keep in mind that the first request made to the server will be slow, as the -# tracker and listeners will have to load. Also, the tracker and listeners will -# shutdown after a period if inactivity. You can set this value below -- the -# default is 90 seconds. - -TrackerSocket = File.expand_path(File.join(File.dirname(__FILE__), '../log/drb_gateway/tracker.sock')) -DieAfter = 90 # Seconds -Listeners = 3 - -def message(s) - $stderr.puts "gateway.cgi: #{s}" if ENV && ENV["DEBUG_GATEWAY"] -end - -def listener_socket(number) - File.expand_path(File.join(File.dirname(__FILE__), "../log/drb_gateway/listener_#{number}.sock")) -end - -unless File.exist? TrackerSocket - message "Starting tracker and #{Listeners} listeners" - fork do - Process.setsid - STDIN.reopen "/dev/null" - STDOUT.reopen "/dev/null", "a" - - root = File.expand_path(File.dirname(__FILE__) + '/..') - - message "starting tracker" - fork do - ARGV.clear - ARGV << TrackerSocket << Listeners.to_s << DieAfter.to_s - load File.join(root, 'script', 'tracker') - end - - message "starting listeners" - require File.join(root, 'config/environment.rb') - Listeners.times do |number| - fork do - ARGV.clear - ARGV << listener_socket(number) << DieAfter.to_s - load File.join(root, 'script', 'listener') - end - end - end - - message "waiting for tracker and listener to arise..." - ready = false - 10.times do - sleep 0.5 - break if (ready = File.exist?(TrackerSocket) && File.exist?(listener_socket(0))) - end - - if ready - message "tracker and listener are ready" - else - message "Waited 5 seconds, listener and tracker not ready... dropping request" - Kernel.exit 1 - end -end - -DRb.start_service - -message "connecting to tracker" -tracker = DRbObject.new_with_uri("drbunix:#{TrackerSocket}") - -input = $stdin.read -$stdin.close - -env = ENV.inspect - -output = nil -tracker.with_listener do |number| - message "connecting to listener #{number}" - socket = listener_socket(number) - listener = DRbObject.new_with_uri("drbunix:#{socket}") - output = listener.process(env, input) - message "listener #{number} has finished, writing output" -end - -$stdout.write output -$stdout.flush -$stdout.close diff --git a/vendor/rails/railties/doc/README_FOR_APP b/vendor/rails/railties/doc/README_FOR_APP deleted file mode 100644 index fe41f5c..0000000 --- a/vendor/rails/railties/doc/README_FOR_APP +++ /dev/null @@ -1,2 +0,0 @@ -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. diff --git a/vendor/rails/railties/environments/boot.rb b/vendor/rails/railties/environments/boot.rb deleted file mode 100644 index 0ad0f78..0000000 --- a/vendor/rails/railties/environments/boot.rb +++ /dev/null @@ -1,110 +0,0 @@ -# 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 - $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 - 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 - require 'rubygems' - min_version = '1.3.1' - 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 - -# All that for this: -Rails.boot! diff --git a/vendor/rails/railties/environments/development.rb b/vendor/rails/railties/environments/development.rb deleted file mode 100644 index 85c9a60..0000000 --- a/vendor/rails/railties/environments/development.rb +++ /dev/null @@ -1,17 +0,0 @@ -# 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 \ No newline at end of file diff --git a/vendor/rails/railties/environments/environment.rb b/vendor/rails/railties/environments/environment.rb deleted file mode 100644 index 4a2df36..0000000 --- a/vendor/rails/railties/environments/environment.rb +++ /dev/null @@ -1,41 +0,0 @@ -# Be sure to restart your server when you modify this file - -# Specifies gem version of Rails to use when vendor/rails is not present -<%= '# ' if freeze %>RAILS_GEM_VERSION = '<%= Rails::VERSION::STRING %>' 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.load_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" - - # 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 \ No newline at end of file diff --git a/vendor/rails/railties/environments/production.rb b/vendor/rails/railties/environments/production.rb deleted file mode 100644 index 27119d2..0000000 --- a/vendor/rails/railties/environments/production.rb +++ /dev/null @@ -1,28 +0,0 @@ -# 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! \ No newline at end of file diff --git a/vendor/rails/railties/environments/test.rb b/vendor/rails/railties/environments/test.rb deleted file mode 100644 index d6f80a4..0000000 --- a/vendor/rails/railties/environments/test.rb +++ /dev/null @@ -1,28 +0,0 @@ -# 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 \ No newline at end of file diff --git a/vendor/rails/railties/fresh_rakefile b/vendor/rails/railties/fresh_rakefile deleted file mode 100755 index 3bb0e85..0000000 --- a/vendor/rails/railties/fresh_rakefile +++ /dev/null @@ -1,10 +0,0 @@ -# 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' diff --git a/vendor/rails/railties/helpers/application_controller.rb b/vendor/rails/railties/helpers/application_controller.rb deleted file mode 100644 index 6635a3f..0000000 --- a/vendor/rails/railties/helpers/application_controller.rb +++ /dev/null @@ -1,10 +0,0 @@ -# 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 diff --git a/vendor/rails/railties/helpers/application_helper.rb b/vendor/rails/railties/helpers/application_helper.rb deleted file mode 100644 index 22a7940..0000000 --- a/vendor/rails/railties/helpers/application_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -# Methods added to this helper will be available to all templates in the application. -module ApplicationHelper -end diff --git a/vendor/rails/railties/helpers/performance_test.rb b/vendor/rails/railties/helpers/performance_test.rb deleted file mode 100644 index 4b60558..0000000 --- a/vendor/rails/railties/helpers/performance_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'test_helper' -require 'performance_test_help' - -# Profiling results for each test method are written to tmp/performance. -class BrowsingTest < ActionController::PerformanceTest - def test_homepage - get '/' - end -end diff --git a/vendor/rails/railties/helpers/test_helper.rb b/vendor/rails/railties/helpers/test_helper.rb deleted file mode 100644 index b9fe251..0000000 --- a/vendor/rails/railties/helpers/test_helper.rb +++ /dev/null @@ -1,38 +0,0 @@ -ENV["RAILS_ENV"] = "test" -require File.expand_path(File.dirname(__FILE__) + "/../config/environment") -require 'test_help' - -class ActiveSupport::TestCase - # Transactional fixtures accelerate your tests by wrapping each test method - # in a transaction that's rolled back on completion. This ensures that the - # test database remains unchanged so your fixtures don't have to be reloaded - # between every test method. Fewer database queries means faster tests. - # - # Read Mike Clark's excellent walkthrough at - # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting - # - # Every Active Record database supports transactions except MyISAM tables - # in MySQL. Turn off transactional fixtures in this case; however, if you - # don't care one way or the other, switching from MyISAM to InnoDB tables - # is recommended. - # - # The only drawback to using transactional fixtures is when you actually - # need to test transactions. Since your test is bracketed by a transaction, - # any transactions started in your code will be automatically rolled back. - self.use_transactional_fixtures = true - - # Instantiated fixtures are slow, but give you @david where otherwise you - # would need people(:david). If you don't want to migrate your existing - # test cases which use the @david style and don't mind the speed hit (each - # instantiated fixtures translates to a database query per test method), - # then set this back to true. - self.use_instantiated_fixtures = false - - # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. - # - # Note: You'll currently still have to declare fixtures explicitly in integration tests - # -- they do not yet inherit this setting - fixtures :all - - # Add more helper methods to be used by all tests here... -end diff --git a/vendor/rails/railties/html/404.html b/vendor/rails/railties/html/404.html deleted file mode 100644 index eff660b..0000000 --- a/vendor/rails/railties/html/404.html +++ /dev/null @@ -1,30 +0,0 @@ -<!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> \ No newline at end of file diff --git a/vendor/rails/railties/html/422.html b/vendor/rails/railties/html/422.html deleted file mode 100644 index b54e4a3..0000000 --- a/vendor/rails/railties/html/422.html +++ /dev/null @@ -1,30 +0,0 @@ -<!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> \ No newline at end of file diff --git a/vendor/rails/railties/html/500.html b/vendor/rails/railties/html/500.html deleted file mode 100644 index ec3bbf0..0000000 --- a/vendor/rails/railties/html/500.html +++ /dev/null @@ -1,30 +0,0 @@ -<!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> diff --git a/vendor/rails/railties/html/favicon.ico b/vendor/rails/railties/html/favicon.ico deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/rails/railties/html/images/rails.png b/vendor/rails/railties/html/images/rails.png deleted file mode 100644 index d5edc04..0000000 Binary files a/vendor/rails/railties/html/images/rails.png and /dev/null differ diff --git a/vendor/rails/railties/html/index.html b/vendor/rails/railties/html/index.html deleted file mode 100644 index 0dd5189..0000000 --- a/vendor/rails/railties/html/index.html +++ /dev/null @@ -1,275 +0,0 @@ -<!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> \ No newline at end of file diff --git a/vendor/rails/railties/html/javascripts/application.js b/vendor/rails/railties/html/javascripts/application.js deleted file mode 100644 index fe45776..0000000 --- a/vendor/rails/railties/html/javascripts/application.js +++ /dev/null @@ -1,2 +0,0 @@ -// Place your application-specific JavaScript functions and classes here -// This file is automatically included by javascript_include_tag :defaults diff --git a/vendor/rails/railties/html/javascripts/controls.js b/vendor/rails/railties/html/javascripts/controls.js deleted file mode 100644 index ca29aef..0000000 --- a/vendor/rails/railties/html/javascripts/controls.js +++ /dev/null @@ -1,963 +0,0 @@ -// 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(); - else - this.buildOptionList(); - }, - - loadExternalText: function() { - this.showLoadingText(this.options.loadingText); - 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._text = transport.responseText.strip(); - this.buildOptionList(); - }.bind(this), - onFailure: this.onFailure - }); - new Ajax.Request(this.options.loadTextURL, options); - }, - - buildOptionList: function() { - this._form.removeClassName(this.options.loadingClassName); - this._collection = this._collection.map(function(entry) { - return 2 === entry.length ? entry : [entry, entry].flatten(); - }); - var marker = ('value' in this.options) ? this.options.value : this._text; - var textFound = this._collection.any(function(entry) { - return entry[0] == marker; - }.bind(this)); - this._controls.editor.update(''); - var option; - this._collection.each(function(entry, index) { - option = document.createElement('option'); - option.value = entry[0]; - option.selected = textFound ? entry[0] == marker : 0 == index; - option.appendChild(document.createTextNode(entry[1])); - this._controls.editor.appendChild(option); - }.bind(this)); - this._controls.editor.disabled = false; - Field.scrollFreeActivate(this._controls.editor); - } -}); - -//**** DEPRECATION LAYER FOR InPlace[Collection]Editor! **** -//**** This only exists for a while, in order to let **** -//**** users adapt to the new API. Read up on the new **** -//**** API and convert your code to it ASAP! **** - -Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) { - if (!options) return; - function fallback(name, expr) { - if (name in options || expr === undefined) return; - options[name] = expr; - }; - fallback('cancelControl', (options.cancelLink ? 'link' : (options.cancelButton ? 'button' : - options.cancelLink == options.cancelButton == false ? false : undefined))); - fallback('okControl', (options.okLink ? 'link' : (options.okButton ? 'button' : - options.okLink == options.okButton == false ? false : undefined))); - fallback('highlightColor', options.highlightcolor); - fallback('highlightEndColor', options.highlightendcolor); -}; - -Object.extend(Ajax.InPlaceEditor, { - DefaultOptions: { - ajaxOptions: { }, - autoRows: 3, // Use when multi-line w/ rows == 1 - cancelControl: 'link', // 'link'|'button'|false - cancelText: 'cancel', - clickToEditText: 'Click to edit', - externalControl: null, // id|elt - externalControlOnly: false, - fieldPostCreation: 'activate', // 'activate'|'focus'|false - formClassName: 'inplaceeditor-form', - formId: null, // id|elt - highlightColor: '#ffff99', - highlightEndColor: '#ffffff', - hoverClassName: '', - htmlResponse: true, - loadingClassName: 'inplaceeditor-loading', - loadingText: 'Loading...', - okControl: 'button', // 'link'|'button'|false - okText: 'ok', - paramName: 'value', - rows: 1, // If 1 and multi-line, uses autoRows - savingClassName: 'inplaceeditor-saving', - savingText: 'Saving...', - size: 0, - stripLoadedTextTags: false, - submitOnBlur: false, - textAfterControls: '', - textBeforeControls: '', - textBetweenControls: '' - }, - DefaultCallbacks: { - callback: function(form) { - return Form.serialize(form); - }, - onComplete: function(transport, element) { - // For backward compatibility, this one is bound to the IPE, and passes - // the element directly. It was too often customized, so we don't break it. - new Effect.Highlight(element, { - startcolor: this.options.highlightColor, keepBackgroundImage: true }); - }, - onEnterEditMode: null, - onEnterHover: function(ipe) { - ipe.element.style.backgroundColor = ipe.options.highlightColor; - if (ipe._effect) - ipe._effect.cancel(); - }, - onFailure: function(transport, ipe) { - alert('Error communication with the server: ' + transport.responseText.stripTags()); - }, - onFormCustomization: null, // Takes the IPE and its generated form, after editor, before controls. - onLeaveEditMode: null, - onLeaveHover: function(ipe) { - ipe._effect = new Effect.Highlight(ipe.element, { - startcolor: ipe.options.highlightColor, endcolor: ipe.options.highlightEndColor, - restorecolor: ipe._originalBackground, keepBackgroundImage: true - }); - } - }, - Listeners: { - click: 'enterEditMode', - keydown: 'checkForEscapeOrReturn', - mouseover: 'enterHover', - mouseout: 'leaveHover' - } -}); - -Ajax.InPlaceCollectionEditor.DefaultOptions = { - loadingCollectionText: 'Loading options...' -}; - -// Delayed observer, like Form.Element.Observer, -// but waits for delay after last key input -// Ideal for live-search fields - -Form.Element.DelayedObserver = Class.create({ - initialize: function(element, delay, callback) { - this.delay = delay || 0.5; - this.element = $(element); - this.callback = callback; - this.timer = null; - this.lastValue = $F(this.element); - Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this)); - }, - delayedListener: function(event) { - if(this.lastValue == $F(this.element)) return; - if(this.timer) clearTimeout(this.timer); - this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000); - this.lastValue = $F(this.element); - }, - onTimerEvent: function() { - this.timer = null; - this.callback(this.element, $F(this.element)); - } -}); \ No newline at end of file diff --git a/vendor/rails/railties/html/javascripts/dragdrop.js b/vendor/rails/railties/html/javascripts/dragdrop.js deleted file mode 100644 index 07229f9..0000000 --- a/vendor/rails/railties/html/javascripts/dragdrop.js +++ /dev/null @@ -1,973 +0,0 @@ -// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// (c) 2005-2008 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) -// -// 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/ - -if(Object.isUndefined(Effect)) - throw("dragdrop.js requires including script.aculo.us' effects.js library"); - -var Droppables = { - drops: [], - - remove: function(element) { - this.drops = this.drops.reject(function(d) { return d.element==$(element) }); - }, - - add: function(element) { - element = $(element); - var options = Object.extend({ - greedy: true, - hoverclass: null, - tree: false - }, arguments[1] || { }); - - // cache containers - if(options.containment) { - options._containers = []; - var containment = options.containment; - if(Object.isArray(containment)) { - containment.each( function(c) { options._containers.push($(c)) }); - } else { - options._containers.push($(containment)); - } - } - - if(options.accept) options.accept = [options.accept].flatten(); - - Element.makePositioned(element); // fix IE - options.element = element; - - this.drops.push(options); - }, - - findDeepestChild: function(drops) { - deepest = drops[0]; - - for (i = 1; i < drops.length; ++i) - if (Element.isParent(drops[i].element, deepest.element)) - deepest = drops[i]; - - return deepest; - }, - - isContained: function(element, drop) { - var containmentNode; - if(drop.tree) { - containmentNode = element.treeNode; - } else { - containmentNode = element.parentNode; - } - return drop._containers.detect(function(c) { return containmentNode == c }); - }, - - isAffected: function(point, element, drop) { - return ( - (drop.element!=element) && - ((!drop._containers) || - this.isContained(element, drop)) && - ((!drop.accept) || - (Element.classNames(element).detect( - function(v) { return drop.accept.include(v) } ) )) && - Position.within(drop.element, point[0], point[1]) ); - }, - - deactivate: function(drop) { - if(drop.hoverclass) - Element.removeClassName(drop.element, drop.hoverclass); - this.last_active = null; - }, - - activate: function(drop) { - if(drop.hoverclass) - Element.addClassName(drop.element, drop.hoverclass); - this.last_active = drop; - }, - - show: function(point, element) { - if(!this.drops.length) return; - var drop, affected = []; - - this.drops.each( function(drop) { - if(Droppables.isAffected(point, element, drop)) - affected.push(drop); - }); - - if(affected.length>0) - drop = Droppables.findDeepestChild(affected); - - if(this.last_active && this.last_active != drop) this.deactivate(this.last_active); - if (drop) { - Position.within(drop.element, point[0], point[1]); - if(drop.onHover) - drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element)); - - if (drop != this.last_active) Droppables.activate(drop); - } - }, - - fire: function(event, element) { - if(!this.last_active) return; - Position.prepare(); - - if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active)) - if (this.last_active.onDrop) { - this.last_active.onDrop(element, this.last_active.element, event); - return true; - } - }, - - reset: function() { - if(this.last_active) - this.deactivate(this.last_active); - } -}; - -var Draggables = { - drags: [], - observers: [], - - register: function(draggable) { - if(this.drags.length == 0) { - this.eventMouseUp = this.endDrag.bindAsEventListener(this); - this.eventMouseMove = this.updateDrag.bindAsEventListener(this); - this.eventKeypress = this.keyPress.bindAsEventListener(this); - - Event.observe(document, "mouseup", this.eventMouseUp); - Event.observe(document, "mousemove", this.eventMouseMove); - Event.observe(document, "keypress", this.eventKeypress); - } - this.drags.push(draggable); - }, - - unregister: function(draggable) { - this.drags = this.drags.reject(function(d) { return d==draggable }); - if(this.drags.length == 0) { - Event.stopObserving(document, "mouseup", this.eventMouseUp); - Event.stopObserving(document, "mousemove", this.eventMouseMove); - Event.stopObserving(document, "keypress", this.eventKeypress); - } - }, - - activate: function(draggable) { - if(draggable.options.delay) { - this._timeout = setTimeout(function() { - Draggables._timeout = null; - window.focus(); - Draggables.activeDraggable = draggable; - }.bind(this), draggable.options.delay); - } else { - window.focus(); // allows keypress events if window isn't currently focused, fails for Safari - this.activeDraggable = draggable; - } - }, - - deactivate: function() { - this.activeDraggable = null; - }, - - updateDrag: function(event) { - if(!this.activeDraggable) return; - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - // Mozilla-based browsers fire successive mousemove events with - // the same coordinates, prevent needless redrawing (moz bug?) - if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return; - this._lastPointer = pointer; - - this.activeDraggable.updateDrag(event, pointer); - }, - - endDrag: function(event) { - if(this._timeout) { - clearTimeout(this._timeout); - this._timeout = null; - } - if(!this.activeDraggable) return; - this._lastPointer = null; - this.activeDraggable.endDrag(event); - this.activeDraggable = null; - }, - - keyPress: function(event) { - if(this.activeDraggable) - this.activeDraggable.keyPress(event); - }, - - addObserver: function(observer) { - this.observers.push(observer); - this._cacheObserverCallbacks(); - }, - - removeObserver: function(element) { // element instead of observer fixes mem leaks - this.observers = this.observers.reject( function(o) { return o.element==element }); - this._cacheObserverCallbacks(); - }, - - notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag' - if(this[eventName+'Count'] > 0) - this.observers.each( function(o) { - if(o[eventName]) o[eventName](eventName, draggable, event); - }); - if(draggable.options[eventName]) draggable.options[eventName](draggable, event); - }, - - _cacheObserverCallbacks: function() { - ['onStart','onEnd','onDrag'].each( function(eventName) { - Draggables[eventName+'Count'] = Draggables.observers.select( - function(o) { return o[eventName]; } - ).length; - }); - } -}; - -/*--------------------------------------------------------------------------*/ - -var Draggable = Class.create({ - initialize: function(element) { - var defaults = { - handle: false, - reverteffect: function(element, top_offset, left_offset) { - var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; - new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur, - queue: {scope:'_draggable', position:'end'} - }); - }, - endeffect: function(element) { - var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0; - new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity, - queue: {scope:'_draggable', position:'end'}, - afterFinish: function(){ - Draggable._dragging[element] = false - } - }); - }, - zindex: 1000, - revert: false, - quiet: false, - scroll: false, - scrollSensitivity: 20, - scrollSpeed: 15, - snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] } - delay: 0 - }; - - if(!arguments[1] || Object.isUndefined(arguments[1].endeffect)) - Object.extend(defaults, { - starteffect: function(element) { - element._opacity = Element.getOpacity(element); - Draggable._dragging[element] = true; - new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7}); - } - }); - - var options = Object.extend(defaults, arguments[1] || { }); - - this.element = $(element); - - if(options.handle && Object.isString(options.handle)) - this.handle = this.element.down('.'+options.handle, 0); - - if(!this.handle) this.handle = $(options.handle); - if(!this.handle) this.handle = this.element; - - if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) { - options.scroll = $(options.scroll); - this._isScrollChild = Element.childOf(this.element, options.scroll); - } - - Element.makePositioned(this.element); // fix IE - - this.options = options; - this.dragging = false; - - this.eventMouseDown = this.initDrag.bindAsEventListener(this); - Event.observe(this.handle, "mousedown", this.eventMouseDown); - - Draggables.register(this); - }, - - destroy: function() { - Event.stopObserving(this.handle, "mousedown", this.eventMouseDown); - Draggables.unregister(this); - }, - - currentDelta: function() { - return([ - parseInt(Element.getStyle(this.element,'left') || '0'), - parseInt(Element.getStyle(this.element,'top') || '0')]); - }, - - initDrag: function(event) { - if(!Object.isUndefined(Draggable._dragging[this.element]) && - Draggable._dragging[this.element]) return; - if(Event.isLeftClick(event)) { - // abort on form elements, fixes a Firefox issue - var src = Event.element(event); - if((tag_name = src.tagName.toUpperCase()) && ( - tag_name=='INPUT' || - tag_name=='SELECT' || - tag_name=='OPTION' || - tag_name=='BUTTON' || - tag_name=='TEXTAREA')) return; - - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - var pos = Position.cumulativeOffset(this.element); - this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) }); - - Draggables.activate(this); - Event.stop(event); - } - }, - - startDrag: function(event) { - this.dragging = true; - if(!this.delta) - this.delta = this.currentDelta(); - - if(this.options.zindex) { - this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0); - this.element.style.zIndex = this.options.zindex; - } - - if(this.options.ghosting) { - this._clone = this.element.cloneNode(true); - this._originallyAbsolute = (this.element.getStyle('position') == 'absolute'); - if (!this._originallyAbsolute) - Position.absolutize(this.element); - this.element.parentNode.insertBefore(this._clone, this.element); - } - - if(this.options.scroll) { - if (this.options.scroll == window) { - var where = this._getWindowScroll(this.options.scroll); - this.originalScrollLeft = where.left; - this.originalScrollTop = where.top; - } else { - this.originalScrollLeft = this.options.scroll.scrollLeft; - this.originalScrollTop = this.options.scroll.scrollTop; - } - } - - Draggables.notify('onStart', this, event); - - if(this.options.starteffect) this.options.starteffect(this.element); - }, - - updateDrag: function(event, pointer) { - if(!this.dragging) this.startDrag(event); - - if(!this.options.quiet){ - Position.prepare(); - Droppables.show(pointer, this.element); - } - - Draggables.notify('onDrag', this, event); - - this.draw(pointer); - if(this.options.change) this.options.change(this); - - if(this.options.scroll) { - this.stopScrolling(); - - var p; - if (this.options.scroll == window) { - with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; } - } else { - p = Position.page(this.options.scroll); - p[0] += this.options.scroll.scrollLeft + Position.deltaX; - p[1] += this.options.scroll.scrollTop + Position.deltaY; - p.push(p[0]+this.options.scroll.offsetWidth); - p.push(p[1]+this.options.scroll.offsetHeight); - } - var speed = [0,0]; - if(pointer[0] < (p[0]+this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[0]+this.options.scrollSensitivity); - if(pointer[1] < (p[1]+this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[1]+this.options.scrollSensitivity); - if(pointer[0] > (p[2]-this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[2]-this.options.scrollSensitivity); - if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity); - this.startScrolling(speed); - } - - // fix AppleWebKit rendering - if(Prototype.Browser.WebKit) window.scrollBy(0,0); - - Event.stop(event); - }, - - finishDrag: function(event, success) { - this.dragging = false; - - if(this.options.quiet){ - Position.prepare(); - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - Droppables.show(pointer, this.element); - } - - if(this.options.ghosting) { - if (!this._originallyAbsolute) - Position.relativize(this.element); - delete this._originallyAbsolute; - Element.remove(this._clone); - this._clone = null; - } - - var dropped = false; - if(success) { - dropped = Droppables.fire(event, this.element); - if (!dropped) dropped = false; - } - if(dropped && this.options.onDropped) this.options.onDropped(this.element); - Draggables.notify('onEnd', this, event); - - var revert = this.options.revert; - if(revert && Object.isFunction(revert)) revert = revert(this.element); - - var d = this.currentDelta(); - if(revert && this.options.reverteffect) { - if (dropped == 0 || revert != 'failure') - this.options.reverteffect(this.element, - d[1]-this.delta[1], d[0]-this.delta[0]); - } else { - this.delta = d; - } - - if(this.options.zindex) - this.element.style.zIndex = this.originalZ; - - if(this.options.endeffect) - this.options.endeffect(this.element); - - Draggables.deactivate(this); - Droppables.reset(); - }, - - keyPress: function(event) { - if(event.keyCode!=Event.KEY_ESC) return; - this.finishDrag(event, false); - Event.stop(event); - }, - - endDrag: function(event) { - if(!this.dragging) return; - this.stopScrolling(); - this.finishDrag(event, true); - Event.stop(event); - }, - - draw: function(point) { - var pos = Position.cumulativeOffset(this.element); - if(this.options.ghosting) { - var r = Position.realOffset(this.element); - pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY; - } - - var d = this.currentDelta(); - pos[0] -= d[0]; pos[1] -= d[1]; - - if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) { - pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft; - pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop; - } - - var p = [0,1].map(function(i){ - return (point[i]-pos[i]-this.offset[i]) - }.bind(this)); - - if(this.options.snap) { - if(Object.isFunction(this.options.snap)) { - p = this.options.snap(p[0],p[1],this); - } else { - if(Object.isArray(this.options.snap)) { - p = p.map( function(v, i) { - return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this)); - } else { - p = p.map( function(v) { - return (v/this.options.snap).round()*this.options.snap }.bind(this)); - } - }} - - var style = this.element.style; - if((!this.options.constraint) || (this.options.constraint=='horizontal')) - style.left = p[0] + "px"; - if((!this.options.constraint) || (this.options.constraint=='vertical')) - style.top = p[1] + "px"; - - if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering - }, - - stopScrolling: function() { - if(this.scrollInterval) { - clearInterval(this.scrollInterval); - this.scrollInterval = null; - Draggables._lastScrollPointer = null; - } - }, - - startScrolling: function(speed) { - if(!(speed[0] || speed[1])) return; - this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed]; - this.lastScrolled = new Date(); - this.scrollInterval = setInterval(this.scroll.bind(this), 10); - }, - - scroll: function() { - var current = new Date(); - var delta = current - this.lastScrolled; - this.lastScrolled = current; - if(this.options.scroll == window) { - with (this._getWindowScroll(this.options.scroll)) { - if (this.scrollSpeed[0] || this.scrollSpeed[1]) { - var d = delta / 1000; - this.options.scroll.scrollTo( left + d*this.scrollSpeed[0], top + d*this.scrollSpeed[1] ); - } - } - } else { - this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000; - this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000; - } - - Position.prepare(); - Droppables.show(Draggables._lastPointer, this.element); - Draggables.notify('onDrag', this); - if (this._isScrollChild) { - Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer); - Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000; - Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000; - if (Draggables._lastScrollPointer[0] < 0) - Draggables._lastScrollPointer[0] = 0; - if (Draggables._lastScrollPointer[1] < 0) - Draggables._lastScrollPointer[1] = 0; - this.draw(Draggables._lastScrollPointer); - } - - if(this.options.change) this.options.change(this); - }, - - _getWindowScroll: function(w) { - var T, L, W, H; - with (w.document) { - if (w.document.documentElement && documentElement.scrollTop) { - T = documentElement.scrollTop; - L = documentElement.scrollLeft; - } else if (w.document.body) { - T = body.scrollTop; - L = body.scrollLeft; - } - if (w.innerWidth) { - W = w.innerWidth; - H = w.innerHeight; - } else if (w.document.documentElement && documentElement.clientWidth) { - W = documentElement.clientWidth; - H = documentElement.clientHeight; - } else { - W = body.offsetWidth; - H = body.offsetHeight; - } - } - return { top: T, left: L, width: W, height: H }; - } -}); - -Draggable._dragging = { }; - -/*--------------------------------------------------------------------------*/ - -var SortableObserver = Class.create({ - initialize: function(element, observer) { - this.element = $(element); - this.observer = observer; - this.lastValue = Sortable.serialize(this.element); - }, - - onStart: function() { - this.lastValue = Sortable.serialize(this.element); - }, - - onEnd: function() { - Sortable.unmark(); - if(this.lastValue != Sortable.serialize(this.element)) - this.observer(this.element) - } -}); - -var Sortable = { - SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/, - - sortables: { }, - - _findRootElement: function(element) { - while (element.tagName.toUpperCase() != "BODY") { - if(element.id && Sortable.sortables[element.id]) return element; - element = element.parentNode; - } - }, - - options: function(element) { - element = Sortable._findRootElement($(element)); - if(!element) return; - return Sortable.sortables[element.id]; - }, - - destroy: function(element){ - element = $(element); - var s = Sortable.sortables[element.id]; - - if(s) { - Draggables.removeObserver(s.element); - s.droppables.each(function(d){ Droppables.remove(d) }); - s.draggables.invoke('destroy'); - - delete Sortable.sortables[s.element.id]; - } - }, - - create: function(element) { - element = $(element); - var options = Object.extend({ - element: element, - tag: 'li', // assumes li children, override with tag: 'tagname' - dropOnEmpty: false, - tree: false, - treeTag: 'ul', - overlap: 'vertical', // one of 'vertical', 'horizontal' - constraint: 'vertical', // one of 'vertical', 'horizontal', false - containment: element, // also takes array of elements (or id's); or false - handle: false, // or a CSS class - only: false, - delay: 0, - hoverclass: null, - ghosting: false, - quiet: false, - scroll: false, - scrollSensitivity: 20, - scrollSpeed: 15, - format: this.SERIALIZE_RULE, - - // these take arrays of elements or ids and can be - // used for better initialization performance - elements: false, - handles: false, - - onChange: Prototype.emptyFunction, - onUpdate: Prototype.emptyFunction - }, arguments[1] || { }); - - // clear any old sortable with same element - this.destroy(element); - - // build options for the draggables - var options_for_draggable = { - revert: true, - quiet: options.quiet, - scroll: options.scroll, - scrollSpeed: options.scrollSpeed, - scrollSensitivity: options.scrollSensitivity, - delay: options.delay, - ghosting: options.ghosting, - constraint: options.constraint, - handle: options.handle }; - - if(options.starteffect) - options_for_draggable.starteffect = options.starteffect; - - if(options.reverteffect) - options_for_draggable.reverteffect = options.reverteffect; - else - if(options.ghosting) options_for_draggable.reverteffect = function(element) { - element.style.top = 0; - element.style.left = 0; - }; - - if(options.endeffect) - options_for_draggable.endeffect = options.endeffect; - - if(options.zindex) - options_for_draggable.zindex = options.zindex; - - // build options for the droppables - var options_for_droppable = { - overlap: options.overlap, - containment: options.containment, - tree: options.tree, - hoverclass: options.hoverclass, - onHover: Sortable.onHover - }; - - var options_for_tree = { - onHover: Sortable.onEmptyHover, - overlap: options.overlap, - containment: options.containment, - hoverclass: options.hoverclass - }; - - // fix for gecko engine - Element.cleanWhitespace(element); - - options.draggables = []; - options.droppables = []; - - // drop on empty handling - if(options.dropOnEmpty || options.tree) { - Droppables.add(element, options_for_tree); - options.droppables.push(element); - } - - (options.elements || this.findElements(element, options) || []).each( function(e,i) { - var handle = options.handles ? $(options.handles[i]) : - (options.handle ? $(e).select('.' + options.handle)[0] : e); - options.draggables.push( - new Draggable(e, Object.extend(options_for_draggable, { handle: handle }))); - Droppables.add(e, options_for_droppable); - if(options.tree) e.treeNode = element; - options.droppables.push(e); - }); - - if(options.tree) { - (Sortable.findTreeElements(element, options) || []).each( function(e) { - Droppables.add(e, options_for_tree); - e.treeNode = element; - options.droppables.push(e); - }); - } - - // keep reference - this.sortables[element.id] = options; - - // for onupdate - Draggables.addObserver(new SortableObserver(element, options.onUpdate)); - - }, - - // return all suitable-for-sortable elements in a guaranteed order - findElements: function(element, options) { - return Element.findChildren( - element, options.only, options.tree ? true : false, options.tag); - }, - - findTreeElements: function(element, options) { - return Element.findChildren( - element, options.only, options.tree ? true : false, options.treeTag); - }, - - onHover: function(element, dropon, overlap) { - if(Element.isParent(dropon, element)) return; - - if(overlap > .33 && overlap < .66 && Sortable.options(dropon).tree) { - return; - } else if(overlap>0.5) { - Sortable.mark(dropon, 'before'); - if(dropon.previousSibling != element) { - var oldParentNode = element.parentNode; - element.style.visibility = "hidden"; // fix gecko rendering - dropon.parentNode.insertBefore(element, dropon); - if(dropon.parentNode!=oldParentNode) - Sortable.options(oldParentNode).onChange(element); - Sortable.options(dropon.parentNode).onChange(element); - } - } else { - Sortable.mark(dropon, 'after'); - var nextElement = dropon.nextSibling || null; - if(nextElement != element) { - var oldParentNode = element.parentNode; - element.style.visibility = "hidden"; // fix gecko rendering - dropon.parentNode.insertBefore(element, nextElement); - if(dropon.parentNode!=oldParentNode) - Sortable.options(oldParentNode).onChange(element); - Sortable.options(dropon.parentNode).onChange(element); - } - } - }, - - onEmptyHover: function(element, dropon, overlap) { - var oldParentNode = element.parentNode; - var droponOptions = Sortable.options(dropon); - - if(!Element.isParent(dropon, element)) { - var index; - - var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only}); - var child = null; - - if(children) { - var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap); - - for (index = 0; index < children.length; index += 1) { - if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) { - offset -= Element.offsetSize (children[index], droponOptions.overlap); - } else if (offset - (Element.offsetSize (children[index], droponOptions.overlap) / 2) >= 0) { - child = index + 1 < children.length ? children[index + 1] : null; - break; - } else { - child = children[index]; - break; - } - } - } - - dropon.insertBefore(element, child); - - Sortable.options(oldParentNode).onChange(element); - droponOptions.onChange(element); - } - }, - - unmark: function() { - if(Sortable._marker) Sortable._marker.hide(); - }, - - mark: function(dropon, position) { - // mark on ghosting only - var sortable = Sortable.options(dropon.parentNode); - if(sortable && !sortable.ghosting) return; - - if(!Sortable._marker) { - Sortable._marker = - ($('dropmarker') || Element.extend(document.createElement('DIV'))). - hide().addClassName('dropmarker').setStyle({position:'absolute'}); - document.getElementsByTagName("body").item(0).appendChild(Sortable._marker); - } - var offsets = Position.cumulativeOffset(dropon); - Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'}); - - if(position=='after') - if(sortable.overlap == 'horizontal') - Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'}); - else - Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'}); - - Sortable._marker.show(); - }, - - _tree: function(element, options, parent) { - var children = Sortable.findElements(element, options) || []; - - for (var i = 0; i < children.length; ++i) { - var match = children[i].id.match(options.format); - - if (!match) continue; - - var child = { - id: encodeURIComponent(match ? match[1] : null), - element: element, - parent: parent, - children: [], - position: parent.children.length, - container: $(children[i]).down(options.treeTag) - }; - - /* Get the element containing the children and recurse over it */ - if (child.container) - this._tree(child.container, options, child); - - parent.children.push (child); - } - - return parent; - }, - - tree: function(element) { - element = $(element); - var sortableOptions = this.options(element); - var options = Object.extend({ - tag: sortableOptions.tag, - treeTag: sortableOptions.treeTag, - only: sortableOptions.only, - name: element.id, - format: sortableOptions.format - }, arguments[1] || { }); - - var root = { - id: null, - parent: null, - children: [], - container: element, - position: 0 - }; - - return Sortable._tree(element, options, root); - }, - - /* Construct a [i] index for a particular node */ - _constructIndex: function(node) { - var index = ''; - do { - if (node.id) index = '[' + node.position + ']' + index; - } while ((node = node.parent) != null); - return index; - }, - - sequence: function(element) { - element = $(element); - var options = Object.extend(this.options(element), arguments[1] || { }); - - return $(this.findElements(element, options) || []).map( function(item) { - return item.id.match(options.format) ? item.id.match(options.format)[1] : ''; - }); - }, - - setSequence: function(element, new_sequence) { - element = $(element); - var options = Object.extend(this.options(element), arguments[2] || { }); - - var nodeMap = { }; - this.findElements(element, options).each( function(n) { - if (n.id.match(options.format)) - nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode]; - n.parentNode.removeChild(n); - }); - - new_sequence.each(function(ident) { - var n = nodeMap[ident]; - if (n) { - n[1].appendChild(n[0]); - delete nodeMap[ident]; - } - }); - }, - - serialize: function(element) { - element = $(element); - var options = Object.extend(Sortable.options(element), arguments[1] || { }); - var name = encodeURIComponent( - (arguments[1] && arguments[1].name) ? arguments[1].name : element.id); - - if (options.tree) { - return Sortable.tree(element, arguments[1]).children.map( function (item) { - return [name + Sortable._constructIndex(item) + "[id]=" + - encodeURIComponent(item.id)].concat(item.children.map(arguments.callee)); - }).flatten().join('&'); - } else { - return Sortable.sequence(element, arguments[1]).map( function(item) { - return name + "[]=" + encodeURIComponent(item); - }).join('&'); - } - } -}; - -// Returns true if child is contained within element -Element.isParent = function(child, element) { - if (!child.parentNode || child == element) return false; - if (child.parentNode == element) return true; - return Element.isParent(child.parentNode, element); -}; - -Element.findChildren = function(element, only, recursive, tagName) { - if(!element.hasChildNodes()) return null; - tagName = tagName.toUpperCase(); - if(only) only = [only].flatten(); - var elements = []; - $A(element.childNodes).each( function(e) { - if(e.tagName && e.tagName.toUpperCase()==tagName && - (!only || (Element.classNames(e).detect(function(v) { return only.include(v) })))) - elements.push(e); - if(recursive) { - var grandchildren = Element.findChildren(e, only, recursive, tagName); - if(grandchildren) elements.push(grandchildren); - } - }); - - return (elements.length>0 ? elements.flatten() : []); -}; - -Element.offsetSize = function (element, type) { - return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')]; -}; \ No newline at end of file diff --git a/vendor/rails/railties/html/javascripts/effects.js b/vendor/rails/railties/html/javascripts/effects.js deleted file mode 100644 index 5a639d2..0000000 --- a/vendor/rails/railties/html/javascripts/effects.js +++ /dev/null @@ -1,1128 +0,0 @@ -// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// Contributors: -// Justin Palmer (http://encytemedia.com/) -// Mark Pilgrim (http://diveintomark.org/) -// Martin Bialasinki -// -// 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/ - -// converts rgb() and #xxx to #xxxxxx format, -// returns self (or first argument) if not convertable -String.prototype.parseColor = function() { - var color = '#'; - if (this.slice(0,4) == 'rgb(') { - var cols = this.slice(4,this.length-1).split(','); - var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3); - } else { - if (this.slice(0,1) == '#') { - if (this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase(); - if (this.length==7) color = this.toLowerCase(); - } - } - return (color.length==7 ? color : (arguments[0] || this)); -}; - -/*--------------------------------------------------------------------------*/ - -Element.collectTextNodes = function(element) { - return $A($(element).childNodes).collect( function(node) { - return (node.nodeType==3 ? node.nodeValue : - (node.hasChildNodes() ? Element.collectTextNodes(node) : '')); - }).flatten().join(''); -}; - -Element.collectTextNodesIgnoreClass = function(element, className) { - return $A($(element).childNodes).collect( function(node) { - return (node.nodeType==3 ? node.nodeValue : - ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? - Element.collectTextNodesIgnoreClass(node, className) : '')); - }).flatten().join(''); -}; - -Element.setContentZoom = function(element, percent) { - element = $(element); - element.setStyle({fontSize: (percent/100) + 'em'}); - if (Prototype.Browser.WebKit) window.scrollBy(0,0); - return element; -}; - -Element.getInlineOpacity = function(element){ - return $(element).style.opacity || ''; -}; - -Element.forceRerendering = function(element) { - try { - element = $(element); - var n = document.createTextNode(' '); - element.appendChild(n); - element.removeChild(n); - } catch(e) { } -}; - -/*--------------------------------------------------------------------------*/ - -var Effect = { - _elementDoesNotExistError: { - name: 'ElementDoesNotExistError', - message: 'The specified DOM element does not exist, but is required for this effect to operate' - }, - Transitions: { - linear: Prototype.K, - sinoidal: function(pos) { - return (-Math.cos(pos*Math.PI)/2) + .5; - }, - reverse: function(pos) { - return 1-pos; - }, - flicker: function(pos) { - var pos = ((-Math.cos(pos*Math.PI)/4) + .75) + Math.random()/4; - return pos > 1 ? 1 : pos; - }, - wobble: function(pos) { - return (-Math.cos(pos*Math.PI*(9*pos))/2) + .5; - }, - pulse: function(pos, pulses) { - return (-Math.cos((pos*((pulses||5)-.5)*2)*Math.PI)/2) + .5; - }, - spring: function(pos) { - return 1 - (Math.cos(pos * 4.5 * Math.PI) * Math.exp(-pos * 6)); - }, - none: function(pos) { - return 0; - }, - full: function(pos) { - return 1; - } - }, - DefaultOptions: { - duration: 1.0, // seconds - fps: 100, // 100= assume 66fps max. - sync: false, // true for combining - from: 0.0, - to: 1.0, - delay: 0.0, - queue: 'parallel' - }, - tagifyText: function(element) { - var tagifyStyle = 'position:relative'; - if (Prototype.Browser.IE) tagifyStyle += ';zoom:1'; - - element = $(element); - $A(element.childNodes).each( function(child) { - if (child.nodeType==3) { - child.nodeValue.toArray().each( function(character) { - element.insertBefore( - new Element('span', {style: tagifyStyle}).update( - character == ' ' ? String.fromCharCode(160) : character), - child); - }); - Element.remove(child); - } - }); - }, - multiple: function(element, effect) { - var elements; - if (((typeof element == 'object') || - Object.isFunction(element)) && - (element.length)) - elements = element; - else - elements = $(element).childNodes; - - var options = Object.extend({ - speed: 0.1, - delay: 0.0 - }, arguments[2] || { }); - var masterDelay = options.delay; - - $A(elements).each( function(element, index) { - new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay })); - }); - }, - PAIRS: { - 'slide': ['SlideDown','SlideUp'], - 'blind': ['BlindDown','BlindUp'], - 'appear': ['Appear','Fade'] - }, - toggle: function(element, effect) { - element = $(element); - effect = (effect || 'appear').toLowerCase(); - var options = Object.extend({ - queue: { position:'end', scope:(element.id || 'global'), limit: 1 } - }, arguments[2] || { }); - Effect[element.visible() ? - Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options); - } -}; - -Effect.DefaultOptions.transition = Effect.Transitions.sinoidal; - -/* ------------- core effects ------------- */ - -Effect.ScopedQueue = Class.create(Enumerable, { - initialize: function() { - this.effects = []; - this.interval = null; - }, - _each: function(iterator) { - this.effects._each(iterator); - }, - add: function(effect) { - var timestamp = new Date().getTime(); - - var position = Object.isString(effect.options.queue) ? - effect.options.queue : effect.options.queue.position; - - switch(position) { - case 'front': - // move unstarted effects after this effect - this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) { - e.startOn += effect.finishOn; - e.finishOn += effect.finishOn; - }); - break; - case 'with-last': - timestamp = this.effects.pluck('startOn').max() || timestamp; - break; - case 'end': - // start effect after last queued effect has finished - timestamp = this.effects.pluck('finishOn').max() || timestamp; - break; - } - - effect.startOn += timestamp; - effect.finishOn += timestamp; - - if (!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit)) - this.effects.push(effect); - - if (!this.interval) - this.interval = setInterval(this.loop.bind(this), 15); - }, - remove: function(effect) { - this.effects = this.effects.reject(function(e) { return e==effect }); - if (this.effects.length == 0) { - clearInterval(this.interval); - this.interval = null; - } - }, - loop: function() { - var timePos = new Date().getTime(); - for(var i=0, len=this.effects.length;i<len;i++) - this.effects[i] && this.effects[i].loop(timePos); - } -}); - -Effect.Queues = { - instances: $H(), - get: function(queueName) { - if (!Object.isString(queueName)) return queueName; - - return this.instances.get(queueName) || - this.instances.set(queueName, new Effect.ScopedQueue()); - } -}; -Effect.Queue = Effect.Queues.get('global'); - -Effect.Base = Class.create({ - position: null, - start: function(options) { - function codeForEvent(options,eventName){ - return ( - (options[eventName+'Internal'] ? 'this.options.'+eventName+'Internal(this);' : '') + - (options[eventName] ? 'this.options.'+eventName+'(this);' : '') - ); - } - if (options && options.transition === false) options.transition = Effect.Transitions.linear; - this.options = Object.extend(Object.extend({ },Effect.DefaultOptions), options || { }); - this.currentFrame = 0; - this.state = 'idle'; - this.startOn = this.options.delay*1000; - this.finishOn = this.startOn+(this.options.duration*1000); - this.fromToDelta = this.options.to-this.options.from; - this.totalTime = this.finishOn-this.startOn; - this.totalFrames = this.options.fps*this.options.duration; - - this.render = (function() { - function dispatch(effect, eventName) { - if (effect.options[eventName + 'Internal']) - effect.options[eventName + 'Internal'](effect); - if (effect.options[eventName]) - effect.options[eventName](effect); - } - - return function(pos) { - if (this.state === "idle") { - this.state = "running"; - dispatch(this, 'beforeSetup'); - if (this.setup) this.setup(); - dispatch(this, 'afterSetup'); - } - if (this.state === "running") { - pos = (this.options.transition(pos) * this.fromToDelta) + this.options.from; - this.position = pos; - dispatch(this, 'beforeUpdate'); - if (this.update) this.update(pos); - dispatch(this, 'afterUpdate'); - } - }; - })(); - - this.event('beforeStart'); - if (!this.options.sync) - Effect.Queues.get(Object.isString(this.options.queue) ? - 'global' : this.options.queue.scope).add(this); - }, - loop: function(timePos) { - if (timePos >= this.startOn) { - if (timePos >= this.finishOn) { - this.render(1.0); - this.cancel(); - this.event('beforeFinish'); - if (this.finish) this.finish(); - this.event('afterFinish'); - return; - } - var pos = (timePos - this.startOn) / this.totalTime, - frame = (pos * this.totalFrames).round(); - if (frame > this.currentFrame) { - this.render(pos); - this.currentFrame = frame; - } - } - }, - cancel: function() { - if (!this.options.sync) - Effect.Queues.get(Object.isString(this.options.queue) ? - 'global' : this.options.queue.scope).remove(this); - this.state = 'finished'; - }, - event: function(eventName) { - if (this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this); - if (this.options[eventName]) this.options[eventName](this); - }, - inspect: function() { - var data = $H(); - for(property in this) - if (!Object.isFunction(this[property])) data.set(property, this[property]); - return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>'; - } -}); - -Effect.Parallel = Class.create(Effect.Base, { - initialize: function(effects) { - this.effects = effects || []; - this.start(arguments[1]); - }, - update: function(position) { - this.effects.invoke('render', position); - }, - finish: function(position) { - this.effects.each( function(effect) { - effect.render(1.0); - effect.cancel(); - effect.event('beforeFinish'); - if (effect.finish) effect.finish(position); - effect.event('afterFinish'); - }); - } -}); - -Effect.Tween = Class.create(Effect.Base, { - initialize: function(object, from, to) { - object = Object.isString(object) ? $(object) : object; - var args = $A(arguments), method = args.last(), - options = args.length == 5 ? args[3] : null; - this.method = Object.isFunction(method) ? method.bind(object) : - Object.isFunction(object[method]) ? object[method].bind(object) : - function(value) { object[method] = value }; - this.start(Object.extend({ from: from, to: to }, options || { })); - }, - update: function(position) { - this.method(position); - } -}); - -Effect.Event = Class.create(Effect.Base, { - initialize: function() { - this.start(Object.extend({ duration: 0 }, arguments[0] || { })); - }, - update: Prototype.emptyFunction -}); - -Effect.Opacity = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - // make this work on IE on elements without 'layout' - if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout)) - this.element.setStyle({zoom: 1}); - var options = Object.extend({ - from: this.element.getOpacity() || 0.0, - to: 1.0 - }, arguments[1] || { }); - this.start(options); - }, - update: function(position) { - this.element.setOpacity(position); - } -}); - -Effect.Move = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - x: 0, - y: 0, - mode: 'relative' - }, arguments[1] || { }); - this.start(options); - }, - setup: function() { - this.element.makePositioned(); - this.originalLeft = parseFloat(this.element.getStyle('left') || '0'); - this.originalTop = parseFloat(this.element.getStyle('top') || '0'); - if (this.options.mode == 'absolute') { - this.options.x = this.options.x - this.originalLeft; - this.options.y = this.options.y - this.originalTop; - } - }, - update: function(position) { - this.element.setStyle({ - left: (this.options.x * position + this.originalLeft).round() + 'px', - top: (this.options.y * position + this.originalTop).round() + 'px' - }); - } -}); - -// for backwards compatibility -Effect.MoveBy = function(element, toTop, toLeft) { - return new Effect.Move(element, - Object.extend({ x: toLeft, y: toTop }, arguments[3] || { })); -}; - -Effect.Scale = Class.create(Effect.Base, { - initialize: function(element, percent) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - scaleX: true, - scaleY: true, - scaleContent: true, - scaleFromCenter: false, - scaleMode: 'box', // 'box' or 'contents' or { } with provided values - scaleFrom: 100.0, - scaleTo: percent - }, arguments[2] || { }); - this.start(options); - }, - setup: function() { - this.restoreAfterFinish = this.options.restoreAfterFinish || false; - this.elementPositioning = this.element.getStyle('position'); - - this.originalStyle = { }; - ['top','left','width','height','fontSize'].each( function(k) { - this.originalStyle[k] = this.element.style[k]; - }.bind(this)); - - this.originalTop = this.element.offsetTop; - this.originalLeft = this.element.offsetLeft; - - var fontSize = this.element.getStyle('font-size') || '100%'; - ['em','px','%','pt'].each( function(fontSizeType) { - if (fontSize.indexOf(fontSizeType)>0) { - this.fontSize = parseFloat(fontSize); - this.fontSizeType = fontSizeType; - } - }.bind(this)); - - this.factor = (this.options.scaleTo - this.options.scaleFrom)/100; - - this.dims = null; - if (this.options.scaleMode=='box') - this.dims = [this.element.offsetHeight, this.element.offsetWidth]; - if (/^content/.test(this.options.scaleMode)) - this.dims = [this.element.scrollHeight, this.element.scrollWidth]; - if (!this.dims) - this.dims = [this.options.scaleMode.originalHeight, - this.options.scaleMode.originalWidth]; - }, - update: function(position) { - var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position); - if (this.options.scaleContent && this.fontSize) - this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType }); - this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale); - }, - finish: function(position) { - if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle); - }, - setDimensions: function(height, width) { - var d = { }; - if (this.options.scaleX) d.width = width.round() + 'px'; - if (this.options.scaleY) d.height = height.round() + 'px'; - if (this.options.scaleFromCenter) { - var topd = (height - this.dims[0])/2; - var leftd = (width - this.dims[1])/2; - if (this.elementPositioning == 'absolute') { - if (this.options.scaleY) d.top = this.originalTop-topd + 'px'; - if (this.options.scaleX) d.left = this.originalLeft-leftd + 'px'; - } else { - if (this.options.scaleY) d.top = -topd + 'px'; - if (this.options.scaleX) d.left = -leftd + 'px'; - } - } - this.element.setStyle(d); - } -}); - -Effect.Highlight = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || { }); - this.start(options); - }, - setup: function() { - // Prevent executing on elements not in the layout flow - if (this.element.getStyle('display')=='none') { this.cancel(); return; } - // Disable background image during the effect - this.oldStyle = { }; - if (!this.options.keepBackgroundImage) { - this.oldStyle.backgroundImage = this.element.getStyle('background-image'); - this.element.setStyle({backgroundImage: 'none'}); - } - if (!this.options.endcolor) - this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff'); - if (!this.options.restorecolor) - this.options.restorecolor = this.element.getStyle('background-color'); - // init color calculations - this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this)); - this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this)); - }, - update: function(position) { - this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){ - return m+((this._base[i]+(this._delta[i]*position)).round().toColorPart()); }.bind(this)) }); - }, - finish: function() { - this.element.setStyle(Object.extend(this.oldStyle, { - backgroundColor: this.options.restorecolor - })); - } -}); - -Effect.ScrollTo = function(element) { - var options = arguments[1] || { }, - scrollOffsets = document.viewport.getScrollOffsets(), - elementOffsets = $(element).cumulativeOffset(); - - if (options.offset) elementOffsets[1] += options.offset; - - return new Effect.Tween(null, - scrollOffsets.top, - elementOffsets[1], - options, - function(p){ scrollTo(scrollOffsets.left, p.round()); } - ); -}; - -/* ------------- combination effects ------------- */ - -Effect.Fade = function(element) { - element = $(element); - var oldOpacity = element.getInlineOpacity(); - var options = Object.extend({ - from: element.getOpacity() || 1.0, - to: 0.0, - afterFinishInternal: function(effect) { - if (effect.options.to!=0) return; - effect.element.hide().setStyle({opacity: oldOpacity}); - } - }, arguments[1] || { }); - return new Effect.Opacity(element,options); -}; - -Effect.Appear = function(element) { - element = $(element); - var options = Object.extend({ - from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0), - to: 1.0, - // force Safari to render floated elements properly - afterFinishInternal: function(effect) { - effect.element.forceRerendering(); - }, - beforeSetup: function(effect) { - effect.element.setOpacity(effect.options.from).show(); - }}, arguments[1] || { }); - return new Effect.Opacity(element,options); -}; - -Effect.Puff = function(element) { - element = $(element); - var oldStyle = { - opacity: element.getInlineOpacity(), - position: element.getStyle('position'), - top: element.style.top, - left: element.style.left, - width: element.style.width, - height: element.style.height - }; - return new Effect.Parallel( - [ new Effect.Scale(element, 200, - { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), - new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], - Object.extend({ duration: 1.0, - beforeSetupInternal: function(effect) { - Position.absolutize(effect.effects[0].element); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.hide().setStyle(oldStyle); } - }, arguments[1] || { }) - ); -}; - -Effect.BlindUp = function(element) { - element = $(element); - element.makeClipping(); - return new Effect.Scale(element, 0, - Object.extend({ scaleContent: false, - scaleX: false, - restoreAfterFinish: true, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping(); - } - }, arguments[1] || { }) - ); -}; - -Effect.BlindDown = function(element) { - element = $(element); - var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, 100, Object.extend({ - scaleContent: false, - scaleX: false, - scaleFrom: 0, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { - effect.element.makeClipping().setStyle({height: '0px'}).show(); - }, - afterFinishInternal: function(effect) { - effect.element.undoClipping(); - } - }, arguments[1] || { })); -}; - -Effect.SwitchOff = function(element) { - element = $(element); - var oldOpacity = element.getInlineOpacity(); - return new Effect.Appear(element, Object.extend({ - duration: 0.4, - from: 0, - transition: Effect.Transitions.flicker, - afterFinishInternal: function(effect) { - new Effect.Scale(effect.element, 1, { - duration: 0.3, scaleFromCenter: true, - scaleX: false, scaleContent: false, restoreAfterFinish: true, - beforeSetup: function(effect) { - effect.element.makePositioned().makeClipping(); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity}); - } - }); - } - }, arguments[1] || { })); -}; - -Effect.DropOut = function(element) { - element = $(element); - var oldStyle = { - top: element.getStyle('top'), - left: element.getStyle('left'), - opacity: element.getInlineOpacity() }; - return new Effect.Parallel( - [ new Effect.Move(element, {x: 0, y: 100, sync: true }), - new Effect.Opacity(element, { sync: true, to: 0.0 }) ], - Object.extend( - { duration: 0.5, - beforeSetup: function(effect) { - effect.effects[0].element.makePositioned(); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle); - } - }, arguments[1] || { })); -}; - -Effect.Shake = function(element) { - element = $(element); - var options = Object.extend({ - distance: 20, - duration: 0.5 - }, arguments[1] || {}); - var distance = parseFloat(options.distance); - var split = parseFloat(options.duration) / 10.0; - var oldStyle = { - top: element.getStyle('top'), - left: element.getStyle('left') }; - return new Effect.Move(element, - { x: distance, y: 0, duration: split, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -distance, y: 0, duration: split, afterFinishInternal: function(effect) { - effect.element.undoPositioned().setStyle(oldStyle); - }}); }}); }}); }}); }}); }}); -}; - -Effect.SlideDown = function(element) { - element = $(element).cleanWhitespace(); - // SlideDown need to have the content of the element wrapped in a container element with fixed height! - var oldInnerBottom = element.down().getStyle('bottom'); - var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, 100, Object.extend({ - scaleContent: false, - scaleX: false, - scaleFrom: window.opera ? 0 : 1, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { - effect.element.makePositioned(); - effect.element.down().makePositioned(); - if (window.opera) effect.element.setStyle({top: ''}); - effect.element.makeClipping().setStyle({height: '0px'}).show(); - }, - afterUpdateInternal: function(effect) { - effect.element.down().setStyle({bottom: - (effect.dims[0] - effect.element.clientHeight) + 'px' }); - }, - afterFinishInternal: function(effect) { - effect.element.undoClipping().undoPositioned(); - effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); } - }, arguments[1] || { }) - ); -}; - -Effect.SlideUp = function(element) { - element = $(element).cleanWhitespace(); - var oldInnerBottom = element.down().getStyle('bottom'); - var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, window.opera ? 0 : 1, - Object.extend({ scaleContent: false, - scaleX: false, - scaleMode: 'box', - scaleFrom: 100, - scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, - restoreAfterFinish: true, - afterSetup: function(effect) { - effect.element.makePositioned(); - effect.element.down().makePositioned(); - if (window.opera) effect.element.setStyle({top: ''}); - effect.element.makeClipping().show(); - }, - afterUpdateInternal: function(effect) { - effect.element.down().setStyle({bottom: - (effect.dims[0] - effect.element.clientHeight) + 'px' }); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().undoPositioned(); - effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); - } - }, arguments[1] || { }) - ); -}; - -// Bug in opera makes the TD containing this element expand for a instance after finish -Effect.Squish = function(element) { - return new Effect.Scale(element, window.opera ? 1 : 0, { - restoreAfterFinish: true, - beforeSetup: function(effect) { - effect.element.makeClipping(); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping(); - } - }); -}; - -Effect.Grow = function(element) { - element = $(element); - var options = Object.extend({ - direction: 'center', - moveTransition: Effect.Transitions.sinoidal, - scaleTransition: Effect.Transitions.sinoidal, - opacityTransition: Effect.Transitions.full - }, arguments[1] || { }); - var oldStyle = { - top: element.style.top, - left: element.style.left, - height: element.style.height, - width: element.style.width, - opacity: element.getInlineOpacity() }; - - var dims = element.getDimensions(); - var initialMoveX, initialMoveY; - var moveX, moveY; - - switch (options.direction) { - case 'top-left': - initialMoveX = initialMoveY = moveX = moveY = 0; - break; - case 'top-right': - initialMoveX = dims.width; - initialMoveY = moveY = 0; - moveX = -dims.width; - break; - case 'bottom-left': - initialMoveX = moveX = 0; - initialMoveY = dims.height; - moveY = -dims.height; - break; - case 'bottom-right': - initialMoveX = dims.width; - initialMoveY = dims.height; - moveX = -dims.width; - moveY = -dims.height; - break; - case 'center': - initialMoveX = dims.width / 2; - initialMoveY = dims.height / 2; - moveX = -dims.width / 2; - moveY = -dims.height / 2; - break; - } - - return new Effect.Move(element, { - x: initialMoveX, - y: initialMoveY, - duration: 0.01, - beforeSetup: function(effect) { - effect.element.hide().makeClipping().makePositioned(); - }, - afterFinishInternal: function(effect) { - new Effect.Parallel( - [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }), - new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }), - new Effect.Scale(effect.element, 100, { - scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, - sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true}) - ], Object.extend({ - beforeSetup: function(effect) { - effect.effects[0].element.setStyle({height: '0px'}).show(); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle); - } - }, options) - ); - } - }); -}; - -Effect.Shrink = function(element) { - element = $(element); - var options = Object.extend({ - direction: 'center', - moveTransition: Effect.Transitions.sinoidal, - scaleTransition: Effect.Transitions.sinoidal, - opacityTransition: Effect.Transitions.none - }, arguments[1] || { }); - var oldStyle = { - top: element.style.top, - left: element.style.left, - height: element.style.height, - width: element.style.width, - opacity: element.getInlineOpacity() }; - - var dims = element.getDimensions(); - var moveX, moveY; - - switch (options.direction) { - case 'top-left': - moveX = moveY = 0; - break; - case 'top-right': - moveX = dims.width; - moveY = 0; - break; - case 'bottom-left': - moveX = 0; - moveY = dims.height; - break; - case 'bottom-right': - moveX = dims.width; - moveY = dims.height; - break; - case 'center': - moveX = dims.width / 2; - moveY = dims.height / 2; - break; - } - - return new Effect.Parallel( - [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }), - new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}), - new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }) - ], Object.extend({ - beforeStartInternal: function(effect) { - effect.effects[0].element.makePositioned().makeClipping(); - }, - afterFinishInternal: function(effect) { - effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); } - }, options) - ); -}; - -Effect.Pulsate = function(element) { - element = $(element); - var options = arguments[1] || { }, - oldOpacity = element.getInlineOpacity(), - transition = options.transition || Effect.Transitions.linear, - reverser = function(pos){ - return 1 - transition((-Math.cos((pos*(options.pulses||5)*2)*Math.PI)/2) + .5); - }; - - return new Effect.Opacity(element, - Object.extend(Object.extend({ duration: 2.0, from: 0, - afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); } - }, options), {transition: reverser})); -}; - -Effect.Fold = function(element) { - element = $(element); - var oldStyle = { - top: element.style.top, - left: element.style.left, - width: element.style.width, - height: element.style.height }; - element.makeClipping(); - return new Effect.Scale(element, 5, Object.extend({ - scaleContent: false, - scaleX: false, - afterFinishInternal: function(effect) { - new Effect.Scale(element, 1, { - scaleContent: false, - scaleY: false, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().setStyle(oldStyle); - } }); - }}, arguments[1] || { })); -}; - -Effect.Morph = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - style: { } - }, arguments[1] || { }); - - if (!Object.isString(options.style)) this.style = $H(options.style); - else { - if (options.style.include(':')) - this.style = options.style.parseStyle(); - else { - this.element.addClassName(options.style); - this.style = $H(this.element.getStyles()); - this.element.removeClassName(options.style); - var css = this.element.getStyles(); - this.style = this.style.reject(function(style) { - return style.value == css[style.key]; - }); - options.afterFinishInternal = function(effect) { - effect.element.addClassName(effect.options.style); - effect.transforms.each(function(transform) { - effect.element.style[transform.style] = ''; - }); - }; - } - } - this.start(options); - }, - - setup: function(){ - function parseColor(color){ - if (!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff'; - color = color.parseColor(); - return $R(0,2).map(function(i){ - return parseInt( color.slice(i*2+1,i*2+3), 16 ); - }); - } - this.transforms = this.style.map(function(pair){ - var property = pair[0], value = pair[1], unit = null; - - if (value.parseColor('#zzzzzz') != '#zzzzzz') { - value = value.parseColor(); - unit = 'color'; - } else if (property == 'opacity') { - value = parseFloat(value); - if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout)) - this.element.setStyle({zoom: 1}); - } else if (Element.CSS_LENGTH.test(value)) { - var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/); - value = parseFloat(components[1]); - unit = (components.length == 3) ? components[2] : null; - } - - var originalValue = this.element.getStyle(property); - return { - style: property.camelize(), - originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0), - targetValue: unit=='color' ? parseColor(value) : value, - unit: unit - }; - }.bind(this)).reject(function(transform){ - return ( - (transform.originalValue == transform.targetValue) || - ( - transform.unit != 'color' && - (isNaN(transform.originalValue) || isNaN(transform.targetValue)) - ) - ); - }); - }, - update: function(position) { - var style = { }, transform, i = this.transforms.length; - while(i--) - style[(transform = this.transforms[i]).style] = - transform.unit=='color' ? '#'+ - (Math.round(transform.originalValue[0]+ - (transform.targetValue[0]-transform.originalValue[0])*position)).toColorPart() + - (Math.round(transform.originalValue[1]+ - (transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart() + - (Math.round(transform.originalValue[2]+ - (transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() : - (transform.originalValue + - (transform.targetValue - transform.originalValue) * position).toFixed(3) + - (transform.unit === null ? '' : transform.unit); - this.element.setStyle(style, true); - } -}); - -Effect.Transform = Class.create({ - initialize: function(tracks){ - this.tracks = []; - this.options = arguments[1] || { }; - this.addTracks(tracks); - }, - addTracks: function(tracks){ - tracks.each(function(track){ - track = $H(track); - var data = track.values().first(); - this.tracks.push($H({ - ids: track.keys().first(), - effect: Effect.Morph, - options: { style: data } - })); - }.bind(this)); - return this; - }, - play: function(){ - return new Effect.Parallel( - this.tracks.map(function(track){ - var ids = track.get('ids'), effect = track.get('effect'), options = track.get('options'); - var elements = [$(ids) || $$(ids)].flatten(); - return elements.map(function(e){ return new effect(e, Object.extend({ sync:true }, options)) }); - }).flatten(), - this.options - ); - } -}); - -Element.CSS_PROPERTIES = $w( - 'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' + - 'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' + - 'borderRightColor borderRightStyle borderRightWidth borderSpacing ' + - 'borderTopColor borderTopStyle borderTopWidth bottom clip color ' + - 'fontSize fontWeight height left letterSpacing lineHeight ' + - 'marginBottom marginLeft marginRight marginTop markerOffset maxHeight '+ - 'maxWidth minHeight minWidth opacity outlineColor outlineOffset ' + - 'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' + - 'right textIndent top width wordSpacing zIndex'); - -Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/; - -String.__parseStyleElement = document.createElement('div'); -String.prototype.parseStyle = function(){ - var style, styleRules = $H(); - if (Prototype.Browser.WebKit) - style = new Element('div',{style:this}).style; - else { - String.__parseStyleElement.innerHTML = '<div style="' + this + '"></div>'; - style = String.__parseStyleElement.childNodes[0].style; - } - - Element.CSS_PROPERTIES.each(function(property){ - if (style[property]) styleRules.set(property, style[property]); - }); - - if (Prototype.Browser.IE && this.include('opacity')) - styleRules.set('opacity', this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]); - - return styleRules; -}; - -if (document.defaultView && document.defaultView.getComputedStyle) { - Element.getStyles = function(element) { - var css = document.defaultView.getComputedStyle($(element), null); - return Element.CSS_PROPERTIES.inject({ }, function(styles, property) { - styles[property] = css[property]; - return styles; - }); - }; -} else { - Element.getStyles = function(element) { - element = $(element); - var css = element.currentStyle, styles; - styles = Element.CSS_PROPERTIES.inject({ }, function(results, property) { - results[property] = css[property]; - return results; - }); - if (!styles.opacity) styles.opacity = element.getOpacity(); - return styles; - }; -} - -Effect.Methods = { - morph: function(element, style) { - element = $(element); - new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || { })); - return element; - }, - visualEffect: function(element, effect, options) { - element = $(element); - var s = effect.dasherize().camelize(), klass = s.charAt(0).toUpperCase() + s.substring(1); - new Effect[klass](element, options); - return element; - }, - highlight: function(element, options) { - element = $(element); - new Effect.Highlight(element, options); - return element; - } -}; - -$w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+ - 'pulsate shake puff squish switchOff dropOut').each( - function(effect) { - Effect.Methods[effect] = function(element, options){ - element = $(element); - Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options); - return element; - }; - } -); - -$w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each( - function(f) { Effect.Methods[f] = Element[f]; } -); - -Element.addMethods(Effect.Methods); \ No newline at end of file diff --git a/vendor/rails/railties/html/javascripts/prototype.js b/vendor/rails/railties/html/javascripts/prototype.js deleted file mode 100644 index dfe8ab4..0000000 --- a/vendor/rails/railties/html/javascripts/prototype.js +++ /dev/null @@ -1,4320 +0,0 @@ -/* Prototype JavaScript framework, version 1.6.0.3 - * (c) 2005-2008 Sam Stephenson - * - * Prototype is freely distributable under the terms of an MIT-style license. - * For details, see the Prototype web site: http://www.prototypejs.org/ - * - *--------------------------------------------------------------------------*/ - -var Prototype = { - Version: '1.6.0.3', - - Browser: { - IE: !!(window.attachEvent && - navigator.userAgent.indexOf('Opera') === -1), - Opera: navigator.userAgent.indexOf('Opera') > -1, - WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, - Gecko: navigator.userAgent.indexOf('Gecko') > -1 && - navigator.userAgent.indexOf('KHTML') === -1, - MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/) - }, - - BrowserFeatures: { - XPath: !!document.evaluate, - SelectorsAPI: !!document.querySelector, - ElementExtensions: !!window.HTMLElement, - SpecificElementExtensions: - document.createElement('div')['__proto__'] && - document.createElement('div')['__proto__'] !== - document.createElement('form')['__proto__'] - }, - - ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>', - JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, - - emptyFunction: function() { }, - K: function(x) { return x } -}; - -if (Prototype.Browser.MobileSafari) - Prototype.BrowserFeatures.SpecificElementExtensions = false; - - -/* Based on Alex Arnell's inheritance implementation. */ -var Class = { - create: function() { - var parent = null, properties = $A(arguments); - if (Object.isFunction(properties[0])) - parent = properties.shift(); - - function klass() { - this.initialize.apply(this, arguments); - } - - Object.extend(klass, Class.Methods); - klass.superclass = parent; - klass.subclasses = []; - - if (parent) { - var subclass = function() { }; - subclass.prototype = parent.prototype; - klass.prototype = new subclass; - parent.subclasses.push(klass); - } - - for (var i = 0; i < properties.length; i++) - klass.addMethods(properties[i]); - - if (!klass.prototype.initialize) - klass.prototype.initialize = Prototype.emptyFunction; - - klass.prototype.constructor = klass; - - return klass; - } -}; - -Class.Methods = { - addMethods: function(source) { - var ancestor = this.superclass && this.superclass.prototype; - var properties = Object.keys(source); - - if (!Object.keys({ toString: true }).length) - properties.push("toString", "valueOf"); - - for (var i = 0, length = properties.length; i < length; i++) { - var property = properties[i], value = source[property]; - if (ancestor && Object.isFunction(value) && - value.argumentNames().first() == "$super") { - var method = value; - value = (function(m) { - return function() { return ancestor[m].apply(this, arguments) }; - })(property).wrap(method); - - value.valueOf = method.valueOf.bind(method); - value.toString = method.toString.bind(method); - } - this.prototype[property] = value; - } - - return this; - } -}; - -var Abstract = { }; - -Object.extend = function(destination, source) { - for (var property in source) - destination[property] = source[property]; - return destination; -}; - -Object.extend(Object, { - inspect: function(object) { - try { - if (Object.isUndefined(object)) return 'undefined'; - if (object === null) return 'null'; - return object.inspect ? object.inspect() : String(object); - } catch (e) { - if (e instanceof RangeError) return '...'; - throw e; - } - }, - - toJSON: function(object) { - var type = typeof object; - switch (type) { - case 'undefined': - case 'function': - case 'unknown': return; - case 'boolean': return object.toString(); - } - - if (object === null) return 'null'; - if (object.toJSON) return object.toJSON(); - if (Object.isElement(object)) return; - - var results = []; - for (var property in object) { - var value = Object.toJSON(object[property]); - if (!Object.isUndefined(value)) - results.push(property.toJSON() + ': ' + value); - } - - return '{' + results.join(', ') + '}'; - }, - - toQueryString: function(object) { - return $H(object).toQueryString(); - }, - - toHTML: function(object) { - return object && object.toHTML ? object.toHTML() : String.interpret(object); - }, - - keys: function(object) { - var keys = []; - for (var property in object) - keys.push(property); - return keys; - }, - - values: function(object) { - var values = []; - for (var property in object) - values.push(object[property]); - return values; - }, - - clone: function(object) { - return Object.extend({ }, object); - }, - - isElement: function(object) { - return !!(object && object.nodeType == 1); - }, - - isArray: function(object) { - return object != null && typeof object == "object" && - 'splice' in object && 'join' in object; - }, - - isHash: function(object) { - return object instanceof Hash; - }, - - isFunction: function(object) { - return typeof object == "function"; - }, - - isString: function(object) { - return typeof object == "string"; - }, - - isNumber: function(object) { - return typeof object == "number"; - }, - - isUndefined: function(object) { - return typeof object == "undefined"; - } -}); - -Object.extend(Function.prototype, { - argumentNames: function() { - var names = this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1] - .replace(/\s+/g, '').split(','); - return names.length == 1 && !names[0] ? [] : names; - }, - - bind: function() { - if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this; - var __method = this, args = $A(arguments), object = args.shift(); - return function() { - return __method.apply(object, args.concat($A(arguments))); - } - }, - - bindAsEventListener: function() { - var __method = this, args = $A(arguments), object = args.shift(); - return function(event) { - return __method.apply(object, [event || window.event].concat(args)); - } - }, - - curry: function() { - if (!arguments.length) return this; - var __method = this, args = $A(arguments); - return function() { - return __method.apply(this, args.concat($A(arguments))); - } - }, - - delay: function() { - var __method = this, args = $A(arguments), timeout = args.shift() * 1000; - return window.setTimeout(function() { - return __method.apply(__method, args); - }, timeout); - }, - - defer: function() { - var args = [0.01].concat($A(arguments)); - return this.delay.apply(this, args); - }, - - wrap: function(wrapper) { - var __method = this; - return function() { - return wrapper.apply(this, [__method.bind(this)].concat($A(arguments))); - } - }, - - methodize: function() { - if (this._methodized) return this._methodized; - var __method = this; - return this._methodized = function() { - return __method.apply(null, [this].concat($A(arguments))); - }; - } -}); - -Date.prototype.toJSON = function() { - return '"' + this.getUTCFullYear() + '-' + - (this.getUTCMonth() + 1).toPaddedString(2) + '-' + - this.getUTCDate().toPaddedString(2) + 'T' + - this.getUTCHours().toPaddedString(2) + ':' + - this.getUTCMinutes().toPaddedString(2) + ':' + - this.getUTCSeconds().toPaddedString(2) + 'Z"'; -}; - -var Try = { - these: function() { - var returnValue; - - for (var i = 0, length = arguments.length; i < length; i++) { - var lambda = arguments[i]; - try { - returnValue = lambda(); - break; - } catch (e) { } - } - - return returnValue; - } -}; - -RegExp.prototype.match = RegExp.prototype.test; - -RegExp.escape = function(str) { - return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); -}; - -/*--------------------------------------------------------------------------*/ - -var PeriodicalExecuter = Class.create({ - initialize: function(callback, frequency) { - this.callback = callback; - this.frequency = frequency; - this.currentlyExecuting = false; - - this.registerCallback(); - }, - - registerCallback: function() { - this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); - }, - - execute: function() { - this.callback(this); - }, - - stop: function() { - if (!this.timer) return; - clearInterval(this.timer); - this.timer = null; - }, - - onTimerEvent: function() { - if (!this.currentlyExecuting) { - try { - this.currentlyExecuting = true; - this.execute(); - } finally { - this.currentlyExecuting = false; - } - } - } -}); -Object.extend(String, { - interpret: function(value) { - return value == null ? '' : String(value); - }, - specialChar: { - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '\\': '\\\\' - } -}); - -Object.extend(String.prototype, { - gsub: function(pattern, replacement) { - var result = '', source = this, match; - replacement = arguments.callee.prepareReplacement(replacement); - - while (source.length > 0) { - if (match = source.match(pattern)) { - result += source.slice(0, match.index); - result += String.interpret(replacement(match)); - source = source.slice(match.index + match[0].length); - } else { - result += source, source = ''; - } - } - return result; - }, - - sub: function(pattern, replacement, count) { - replacement = this.gsub.prepareReplacement(replacement); - count = Object.isUndefined(count) ? 1 : count; - - return this.gsub(pattern, function(match) { - if (--count < 0) return match[0]; - return replacement(match); - }); - }, - - scan: function(pattern, iterator) { - this.gsub(pattern, iterator); - return String(this); - }, - - truncate: function(length, truncation) { - length = length || 30; - truncation = Object.isUndefined(truncation) ? '...' : truncation; - return this.length > length ? - this.slice(0, length - truncation.length) + truncation : String(this); - }, - - strip: function() { - return this.replace(/^\s+/, '').replace(/\s+$/, ''); - }, - - stripTags: function() { - return this.replace(/<\/?[^>]+>/gi, ''); - }, - - stripScripts: function() { - return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); - }, - - extractScripts: function() { - var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); - var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); - return (this.match(matchAll) || []).map(function(scriptTag) { - return (scriptTag.match(matchOne) || ['', ''])[1]; - }); - }, - - evalScripts: function() { - return this.extractScripts().map(function(script) { return eval(script) }); - }, - - escapeHTML: function() { - var self = arguments.callee; - self.text.data = this; - return self.div.innerHTML; - }, - - unescapeHTML: function() { - var div = new Element('div'); - div.innerHTML = this.stripTags(); - return div.childNodes[0] ? (div.childNodes.length > 1 ? - $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) : - div.childNodes[0].nodeValue) : ''; - }, - - toQueryParams: function(separator) { - var match = this.strip().match(/([^?#]*)(#.*)?$/); - if (!match) return { }; - - return match[1].split(separator || '&').inject({ }, function(hash, pair) { - if ((pair = pair.split('='))[0]) { - var key = decodeURIComponent(pair.shift()); - var value = pair.length > 1 ? pair.join('=') : pair[0]; - if (value != undefined) value = decodeURIComponent(value); - - if (key in hash) { - if (!Object.isArray(hash[key])) hash[key] = [hash[key]]; - hash[key].push(value); - } - else hash[key] = value; - } - return hash; - }); - }, - - toArray: function() { - return this.split(''); - }, - - succ: function() { - return this.slice(0, this.length - 1) + - String.fromCharCode(this.charCodeAt(this.length - 1) + 1); - }, - - times: function(count) { - return count < 1 ? '' : new Array(count + 1).join(this); - }, - - camelize: function() { - var parts = this.split('-'), len = parts.length; - if (len == 1) return parts[0]; - - var camelized = this.charAt(0) == '-' - ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) - : parts[0]; - - for (var i = 1; i < len; i++) - camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); - - return camelized; - }, - - capitalize: function() { - return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); - }, - - underscore: function() { - return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase(); - }, - - dasherize: function() { - return this.gsub(/_/,'-'); - }, - - inspect: function(useDoubleQuotes) { - var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) { - var character = String.specialChar[match[0]]; - return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16); - }); - if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"'; - return "'" + escapedString.replace(/'/g, '\\\'') + "'"; - }, - - toJSON: function() { - return this.inspect(true); - }, - - unfilterJSON: function(filter) { - return this.sub(filter || Prototype.JSONFilter, '#{1}'); - }, - - isJSON: function() { - var str = this; - if (str.blank()) return false; - str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); - return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str); - }, - - evalJSON: function(sanitize) { - var json = this.unfilterJSON(); - try { - if (!sanitize || json.isJSON()) return eval('(' + json + ')'); - } catch (e) { } - throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); - }, - - include: function(pattern) { - return this.indexOf(pattern) > -1; - }, - - startsWith: function(pattern) { - return this.indexOf(pattern) === 0; - }, - - endsWith: function(pattern) { - var d = this.length - pattern.length; - return d >= 0 && this.lastIndexOf(pattern) === d; - }, - - empty: function() { - return this == ''; - }, - - blank: function() { - return /^\s*$/.test(this); - }, - - interpolate: function(object, pattern) { - return new Template(this, pattern).evaluate(object); - } -}); - -if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, { - escapeHTML: function() { - return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); - }, - unescapeHTML: function() { - return this.stripTags().replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>'); - } -}); - -String.prototype.gsub.prepareReplacement = function(replacement) { - if (Object.isFunction(replacement)) return replacement; - var template = new Template(replacement); - return function(match) { return template.evaluate(match) }; -}; - -String.prototype.parseQuery = String.prototype.toQueryParams; - -Object.extend(String.prototype.escapeHTML, { - div: document.createElement('div'), - text: document.createTextNode('') -}); - -String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text); - -var Template = Class.create({ - initialize: function(template, pattern) { - this.template = template.toString(); - this.pattern = pattern || Template.Pattern; - }, - - evaluate: function(object) { - if (Object.isFunction(object.toTemplateReplacements)) - object = object.toTemplateReplacements(); - - return this.template.gsub(this.pattern, function(match) { - if (object == null) return ''; - - var before = match[1] || ''; - if (before == '\\') return match[2]; - - var ctx = object, expr = match[3]; - var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/; - match = pattern.exec(expr); - if (match == null) return before; - - while (match != null) { - var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1]; - ctx = ctx[comp]; - if (null == ctx || '' == match[3]) break; - expr = expr.substring('[' == match[3] ? match[1].length : match[0].length); - match = pattern.exec(expr); - } - - return before + String.interpret(ctx); - }); - } -}); -Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; - -var $break = { }; - -var Enumerable = { - each: function(iterator, context) { - var index = 0; - try { - this._each(function(value) { - iterator.call(context, value, index++); - }); - } catch (e) { - if (e != $break) throw e; - } - return this; - }, - - eachSlice: function(number, iterator, context) { - var index = -number, slices = [], array = this.toArray(); - if (number < 1) return array; - while ((index += number) < array.length) - slices.push(array.slice(index, index+number)); - return slices.collect(iterator, context); - }, - - all: function(iterator, context) { - iterator = iterator || Prototype.K; - var result = true; - this.each(function(value, index) { - result = result && !!iterator.call(context, value, index); - if (!result) throw $break; - }); - return result; - }, - - any: function(iterator, context) { - iterator = iterator || Prototype.K; - var result = false; - this.each(function(value, index) { - if (result = !!iterator.call(context, value, index)) - throw $break; - }); - return result; - }, - - collect: function(iterator, context) { - iterator = iterator || Prototype.K; - var results = []; - this.each(function(value, index) { - results.push(iterator.call(context, value, index)); - }); - return results; - }, - - detect: function(iterator, context) { - var result; - this.each(function(value, index) { - if (iterator.call(context, value, index)) { - result = value; - throw $break; - } - }); - return result; - }, - - findAll: function(iterator, context) { - var results = []; - this.each(function(value, index) { - if (iterator.call(context, value, index)) - results.push(value); - }); - return results; - }, - - grep: function(filter, iterator, context) { - iterator = iterator || Prototype.K; - var results = []; - - if (Object.isString(filter)) - filter = new RegExp(filter); - - this.each(function(value, index) { - if (filter.match(value)) - results.push(iterator.call(context, value, index)); - }); - return results; - }, - - include: function(object) { - if (Object.isFunction(this.indexOf)) - if (this.indexOf(object) != -1) return true; - - var found = false; - this.each(function(value) { - if (value == object) { - found = true; - throw $break; - } - }); - return found; - }, - - inGroupsOf: function(number, fillWith) { - fillWith = Object.isUndefined(fillWith) ? null : fillWith; - return this.eachSlice(number, function(slice) { - while(slice.length < number) slice.push(fillWith); - return slice; - }); - }, - - inject: function(memo, iterator, context) { - this.each(function(value, index) { - memo = iterator.call(context, memo, value, index); - }); - return memo; - }, - - invoke: function(method) { - var args = $A(arguments).slice(1); - return this.map(function(value) { - return value[method].apply(value, args); - }); - }, - - max: function(iterator, context) { - iterator = iterator || Prototype.K; - var result; - this.each(function(value, index) { - value = iterator.call(context, value, index); - if (result == null || value >= result) - result = value; - }); - return result; - }, - - min: function(iterator, context) { - iterator = iterator || Prototype.K; - var result; - this.each(function(value, index) { - value = iterator.call(context, value, index); - if (result == null || value < result) - result = value; - }); - return result; - }, - - partition: function(iterator, context) { - iterator = iterator || Prototype.K; - var trues = [], falses = []; - this.each(function(value, index) { - (iterator.call(context, value, index) ? - trues : falses).push(value); - }); - return [trues, falses]; - }, - - pluck: function(property) { - var results = []; - this.each(function(value) { - results.push(value[property]); - }); - return results; - }, - - reject: function(iterator, context) { - var results = []; - this.each(function(value, index) { - if (!iterator.call(context, value, index)) - results.push(value); - }); - return results; - }, - - sortBy: function(iterator, context) { - return this.map(function(value, index) { - return { - value: value, - criteria: iterator.call(context, value, index) - }; - }).sort(function(left, right) { - var a = left.criteria, b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - }).pluck('value'); - }, - - toArray: function() { - return this.map(); - }, - - zip: function() { - var iterator = Prototype.K, args = $A(arguments); - if (Object.isFunction(args.last())) - iterator = args.pop(); - - var collections = [this].concat(args).map($A); - return this.map(function(value, index) { - return iterator(collections.pluck(index)); - }); - }, - - size: function() { - return this.toArray().length; - }, - - inspect: function() { - return '#<Enumerable:' + this.toArray().inspect() + '>'; - } -}; - -Object.extend(Enumerable, { - map: Enumerable.collect, - find: Enumerable.detect, - select: Enumerable.findAll, - filter: Enumerable.findAll, - member: Enumerable.include, - entries: Enumerable.toArray, - every: Enumerable.all, - some: Enumerable.any -}); -function $A(iterable) { - if (!iterable) return []; - if (iterable.toArray) return iterable.toArray(); - var length = iterable.length || 0, results = new Array(length); - while (length--) results[length] = iterable[length]; - return results; -} - -if (Prototype.Browser.WebKit) { - $A = function(iterable) { - if (!iterable) return []; - // In Safari, only use the `toArray` method if it's not a NodeList. - // A NodeList is a function, has an function `item` property, and a numeric - // `length` property. Adapted from Google Doctype. - if (!(typeof iterable === 'function' && typeof iterable.length === - 'number' && typeof iterable.item === 'function') && iterable.toArray) - return iterable.toArray(); - var length = iterable.length || 0, results = new Array(length); - while (length--) results[length] = iterable[length]; - return results; - }; -} - -Array.from = $A; - -Object.extend(Array.prototype, Enumerable); - -if (!Array.prototype._reverse) Array.prototype._reverse = Array.prototype.reverse; - -Object.extend(Array.prototype, { - _each: function(iterator) { - for (var i = 0, length = this.length; i < length; i++) - iterator(this[i]); - }, - - clear: function() { - this.length = 0; - return this; - }, - - first: function() { - return this[0]; - }, - - last: function() { - return this[this.length - 1]; - }, - - compact: function() { - return this.select(function(value) { - return value != null; - }); - }, - - flatten: function() { - return this.inject([], function(array, value) { - return array.concat(Object.isArray(value) ? - value.flatten() : [value]); - }); - }, - - without: function() { - var values = $A(arguments); - return this.select(function(value) { - return !values.include(value); - }); - }, - - reverse: function(inline) { - return (inline !== false ? this : this.toArray())._reverse(); - }, - - reduce: function() { - return this.length > 1 ? this : this[0]; - }, - - uniq: function(sorted) { - return this.inject([], function(array, value, index) { - if (0 == index || (sorted ? array.last() != value : !array.include(value))) - array.push(value); - return array; - }); - }, - - intersect: function(array) { - return this.uniq().findAll(function(item) { - return array.detect(function(value) { return item === value }); - }); - }, - - clone: function() { - return [].concat(this); - }, - - size: function() { - return this.length; - }, - - inspect: function() { - return '[' + this.map(Object.inspect).join(', ') + ']'; - }, - - toJSON: function() { - var results = []; - this.each(function(object) { - var value = Object.toJSON(object); - if (!Object.isUndefined(value)) results.push(value); - }); - return '[' + results.join(', ') + ']'; - } -}); - -// use native browser JS 1.6 implementation if available -if (Object.isFunction(Array.prototype.forEach)) - Array.prototype._each = Array.prototype.forEach; - -if (!Array.prototype.indexOf) Array.prototype.indexOf = function(item, i) { - i || (i = 0); - var length = this.length; - if (i < 0) i = length + i; - for (; i < length; i++) - if (this[i] === item) return i; - return -1; -}; - -if (!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(item, i) { - i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1; - var n = this.slice(0, i).reverse().indexOf(item); - return (n < 0) ? n : i - n - 1; -}; - -Array.prototype.toArray = Array.prototype.clone; - -function $w(string) { - if (!Object.isString(string)) return []; - string = string.strip(); - return string ? string.split(/\s+/) : []; -} - -if (Prototype.Browser.Opera){ - Array.prototype.concat = function() { - var array = []; - for (var i = 0, length = this.length; i < length; i++) array.push(this[i]); - for (var i = 0, length = arguments.length; i < length; i++) { - if (Object.isArray(arguments[i])) { - for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) - array.push(arguments[i][j]); - } else { - array.push(arguments[i]); - } - } - return array; - }; -} -Object.extend(Number.prototype, { - toColorPart: function() { - return this.toPaddedString(2, 16); - }, - - succ: function() { - return this + 1; - }, - - times: function(iterator, context) { - $R(0, this, true).each(iterator, context); - return this; - }, - - toPaddedString: function(length, radix) { - var string = this.toString(radix || 10); - return '0'.times(length - string.length) + string; - }, - - toJSON: function() { - return isFinite(this) ? this.toString() : 'null'; - } -}); - -$w('abs round ceil floor').each(function(method){ - Number.prototype[method] = Math[method].methodize(); -}); -function $H(object) { - return new Hash(object); -}; - -var Hash = Class.create(Enumerable, (function() { - - function toQueryPair(key, value) { - if (Object.isUndefined(value)) return key; - return key + '=' + encodeURIComponent(String.interpret(value)); - } - - return { - initialize: function(object) { - this._object = Object.isHash(object) ? object.toObject() : Object.clone(object); - }, - - _each: function(iterator) { - for (var key in this._object) { - var value = this._object[key], pair = [key, value]; - pair.key = key; - pair.value = value; - iterator(pair); - } - }, - - set: function(key, value) { - return this._object[key] = value; - }, - - get: function(key) { - // simulating poorly supported hasOwnProperty - if (this._object[key] !== Object.prototype[key]) - return this._object[key]; - }, - - unset: function(key) { - var value = this._object[key]; - delete this._object[key]; - return value; - }, - - toObject: function() { - return Object.clone(this._object); - }, - - keys: function() { - return this.pluck('key'); - }, - - values: function() { - return this.pluck('value'); - }, - - index: function(value) { - var match = this.detect(function(pair) { - return pair.value === value; - }); - return match && match.key; - }, - - merge: function(object) { - return this.clone().update(object); - }, - - update: function(object) { - return new Hash(object).inject(this, function(result, pair) { - result.set(pair.key, pair.value); - return result; - }); - }, - - toQueryString: function() { - return this.inject([], function(results, pair) { - var key = encodeURIComponent(pair.key), values = pair.value; - - if (values && typeof values == 'object') { - if (Object.isArray(values)) - return results.concat(values.map(toQueryPair.curry(key))); - } else results.push(toQueryPair(key, values)); - return results; - }).join('&'); - }, - - inspect: function() { - return '#<Hash:{' + this.map(function(pair) { - return pair.map(Object.inspect).join(': '); - }).join(', ') + '}>'; - }, - - toJSON: function() { - return Object.toJSON(this.toObject()); - }, - - clone: function() { - return new Hash(this); - } - } -})()); - -Hash.prototype.toTemplateReplacements = Hash.prototype.toObject; -Hash.from = $H; -var ObjectRange = Class.create(Enumerable, { - initialize: function(start, end, exclusive) { - this.start = start; - this.end = end; - this.exclusive = exclusive; - }, - - _each: function(iterator) { - var value = this.start; - while (this.include(value)) { - iterator(value); - value = value.succ(); - } - }, - - include: function(value) { - if (value < this.start) - return false; - if (this.exclusive) - return value < this.end; - return value <= this.end; - } -}); - -var $R = function(start, end, exclusive) { - return new ObjectRange(start, end, exclusive); -}; - -var Ajax = { - getTransport: function() { - return Try.these( - function() {return new XMLHttpRequest()}, - function() {return new ActiveXObject('Msxml2.XMLHTTP')}, - function() {return new ActiveXObject('Microsoft.XMLHTTP')} - ) || false; - }, - - activeRequestCount: 0 -}; - -Ajax.Responders = { - responders: [], - - _each: function(iterator) { - this.responders._each(iterator); - }, - - register: function(responder) { - if (!this.include(responder)) - this.responders.push(responder); - }, - - unregister: function(responder) { - this.responders = this.responders.without(responder); - }, - - dispatch: function(callback, request, transport, json) { - this.each(function(responder) { - if (Object.isFunction(responder[callback])) { - try { - responder[callback].apply(responder, [request, transport, json]); - } catch (e) { } - } - }); - } -}; - -Object.extend(Ajax.Responders, Enumerable); - -Ajax.Responders.register({ - onCreate: function() { Ajax.activeRequestCount++ }, - onComplete: function() { Ajax.activeRequestCount-- } -}); - -Ajax.Base = Class.create({ - initialize: function(options) { - this.options = { - method: 'post', - asynchronous: true, - contentType: 'application/x-www-form-urlencoded', - encoding: 'UTF-8', - parameters: '', - evalJSON: true, - evalJS: true - }; - Object.extend(this.options, options || { }); - - this.options.method = this.options.method.toLowerCase(); - - if (Object.isString(this.options.parameters)) - this.options.parameters = this.options.parameters.toQueryParams(); - else if (Object.isHash(this.options.parameters)) - this.options.parameters = this.options.parameters.toObject(); - } -}); - -Ajax.Request = Class.create(Ajax.Base, { - _complete: false, - - initialize: function($super, url, options) { - $super(options); - this.transport = Ajax.getTransport(); - this.request(url); - }, - - request: function(url) { - this.url = url; - this.method = this.options.method; - var params = Object.clone(this.options.parameters); - - if (!['get', 'post'].include(this.method)) { - // simulate other verbs over post - params['_method'] = this.method; - this.method = 'post'; - } - - this.parameters = params; - - if (params = Object.toQueryString(params)) { - // when GET, append parameters to URL - if (this.method == 'get') - this.url += (this.url.include('?') ? '&' : '?') + params; - else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) - params += '&_='; - } - - try { - var response = new Ajax.Response(this); - if (this.options.onCreate) this.options.onCreate(response); - Ajax.Responders.dispatch('onCreate', this, response); - - this.transport.open(this.method.toUpperCase(), this.url, - this.options.asynchronous); - - if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1); - - this.transport.onreadystatechange = this.onStateChange.bind(this); - this.setRequestHeaders(); - - this.body = this.method == 'post' ? (this.options.postBody || params) : null; - this.transport.send(this.body); - - /* Force Firefox to handle ready state 4 for synchronous requests */ - if (!this.options.asynchronous && this.transport.overrideMimeType) - this.onStateChange(); - - } - catch (e) { - this.dispatchException(e); - } - }, - - onStateChange: function() { - var readyState = this.transport.readyState; - if (readyState > 1 && !((readyState == 4) && this._complete)) - this.respondToReadyState(this.transport.readyState); - }, - - setRequestHeaders: function() { - var headers = { - 'X-Requested-With': 'XMLHttpRequest', - 'X-Prototype-Version': Prototype.Version, - 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' - }; - - if (this.method == 'post') { - headers['Content-type'] = this.options.contentType + - (this.options.encoding ? '; charset=' + this.options.encoding : ''); - - /* Force "Connection: close" for older Mozilla browsers to work - * around a bug where XMLHttpRequest sends an incorrect - * Content-length header. See Mozilla Bugzilla #246651. - */ - if (this.transport.overrideMimeType && - (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) - headers['Connection'] = 'close'; - } - - // user-defined headers - if (typeof this.options.requestHeaders == 'object') { - var extras = this.options.requestHeaders; - - if (Object.isFunction(extras.push)) - for (var i = 0, length = extras.length; i < length; i += 2) - headers[extras[i]] = extras[i+1]; - else - $H(extras).each(function(pair) { headers[pair.key] = pair.value }); - } - - for (var name in headers) - this.transport.setRequestHeader(name, headers[name]); - }, - - success: function() { - var status = this.getStatus(); - return !status || (status >= 200 && status < 300); - }, - - getStatus: function() { - try { - return this.transport.status || 0; - } catch (e) { return 0 } - }, - - respondToReadyState: function(readyState) { - var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this); - - if (state == 'Complete') { - try { - this._complete = true; - (this.options['on' + response.status] - || this.options['on' + (this.success() ? 'Success' : 'Failure')] - || Prototype.emptyFunction)(response, response.headerJSON); - } catch (e) { - this.dispatchException(e); - } - - var contentType = response.getHeader('Content-type'); - if (this.options.evalJS == 'force' - || (this.options.evalJS && this.isSameOrigin() && contentType - && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))) - this.evalResponse(); - } - - try { - (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON); - Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON); - } catch (e) { - this.dispatchException(e); - } - - if (state == 'Complete') { - // avoid memory leak in MSIE: clean up - this.transport.onreadystatechange = Prototype.emptyFunction; - } - }, - - isSameOrigin: function() { - var m = this.url.match(/^\s*https?:\/\/[^\/]*/); - return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({ - protocol: location.protocol, - domain: document.domain, - port: location.port ? ':' + location.port : '' - })); - }, - - getHeader: function(name) { - try { - return this.transport.getResponseHeader(name) || null; - } catch (e) { return null } - }, - - evalResponse: function() { - try { - return eval((this.transport.responseText || '').unfilterJSON()); - } catch (e) { - this.dispatchException(e); - } - }, - - dispatchException: function(exception) { - (this.options.onException || Prototype.emptyFunction)(this, exception); - Ajax.Responders.dispatch('onException', this, exception); - } -}); - -Ajax.Request.Events = - ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; - -Ajax.Response = Class.create({ - initialize: function(request){ - this.request = request; - var transport = this.transport = request.transport, - readyState = this.readyState = transport.readyState; - - if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) { - this.status = this.getStatus(); - this.statusText = this.getStatusText(); - this.responseText = String.interpret(transport.responseText); - this.headerJSON = this._getHeaderJSON(); - } - - if(readyState == 4) { - var xml = transport.responseXML; - this.responseXML = Object.isUndefined(xml) ? null : xml; - this.responseJSON = this._getResponseJSON(); - } - }, - - status: 0, - statusText: '', - - getStatus: Ajax.Request.prototype.getStatus, - - getStatusText: function() { - try { - return this.transport.statusText || ''; - } catch (e) { return '' } - }, - - getHeader: Ajax.Request.prototype.getHeader, - - getAllHeaders: function() { - try { - return this.getAllResponseHeaders(); - } catch (e) { return null } - }, - - getResponseHeader: function(name) { - return this.transport.getResponseHeader(name); - }, - - getAllResponseHeaders: function() { - return this.transport.getAllResponseHeaders(); - }, - - _getHeaderJSON: function() { - var json = this.getHeader('X-JSON'); - if (!json) return null; - json = decodeURIComponent(escape(json)); - try { - return json.evalJSON(this.request.options.sanitizeJSON || - !this.request.isSameOrigin()); - } catch (e) { - this.request.dispatchException(e); - } - }, - - _getResponseJSON: function() { - var options = this.request.options; - if (!options.evalJSON || (options.evalJSON != 'force' && - !(this.getHeader('Content-type') || '').include('application/json')) || - this.responseText.blank()) - return null; - try { - return this.responseText.evalJSON(options.sanitizeJSON || - !this.request.isSameOrigin()); - } catch (e) { - this.request.dispatchException(e); - } - } -}); - -Ajax.Updater = Class.create(Ajax.Request, { - initialize: function($super, container, url, options) { - this.container = { - success: (container.success || container), - failure: (container.failure || (container.success ? null : container)) - }; - - options = Object.clone(options); - var onComplete = options.onComplete; - options.onComplete = (function(response, json) { - this.updateContent(response.responseText); - if (Object.isFunction(onComplete)) onComplete(response, json); - }).bind(this); - - $super(url, options); - }, - - updateContent: function(responseText) { - var receiver = this.container[this.success() ? 'success' : 'failure'], - options = this.options; - - if (!options.evalScripts) responseText = responseText.stripScripts(); - - if (receiver = $(receiver)) { - if (options.insertion) { - if (Object.isString(options.insertion)) { - var insertion = { }; insertion[options.insertion] = responseText; - receiver.insert(insertion); - } - else options.insertion(receiver, responseText); - } - else receiver.update(responseText); - } - } -}); - -Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { - initialize: function($super, container, url, options) { - $super(options); - this.onComplete = this.options.onComplete; - - this.frequency = (this.options.frequency || 2); - this.decay = (this.options.decay || 1); - - this.updater = { }; - this.container = container; - this.url = url; - - this.start(); - }, - - start: function() { - this.options.onComplete = this.updateComplete.bind(this); - this.onTimerEvent(); - }, - - stop: function() { - this.updater.options.onComplete = undefined; - clearTimeout(this.timer); - (this.onComplete || Prototype.emptyFunction).apply(this, arguments); - }, - - updateComplete: function(response) { - if (this.options.decay) { - this.decay = (response.responseText == this.lastText ? - this.decay * this.options.decay : 1); - - this.lastText = response.responseText; - } - this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency); - }, - - onTimerEvent: function() { - this.updater = new Ajax.Updater(this.container, this.url, this.options); - } -}); -function $(element) { - if (arguments.length > 1) { - for (var i = 0, elements = [], length = arguments.length; i < length; i++) - elements.push($(arguments[i])); - return elements; - } - if (Object.isString(element)) - element = document.getElementById(element); - return Element.extend(element); -} - -if (Prototype.BrowserFeatures.XPath) { - document._getElementsByXPath = function(expression, parentElement) { - var results = []; - var query = document.evaluate(expression, $(parentElement) || document, - null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - for (var i = 0, length = query.snapshotLength; i < length; i++) - results.push(Element.extend(query.snapshotItem(i))); - return results; - }; -} - -/*--------------------------------------------------------------------------*/ - -if (!window.Node) var Node = { }; - -if (!Node.ELEMENT_NODE) { - // DOM level 2 ECMAScript Language Binding - Object.extend(Node, { - ELEMENT_NODE: 1, - ATTRIBUTE_NODE: 2, - TEXT_NODE: 3, - CDATA_SECTION_NODE: 4, - ENTITY_REFERENCE_NODE: 5, - ENTITY_NODE: 6, - PROCESSING_INSTRUCTION_NODE: 7, - COMMENT_NODE: 8, - DOCUMENT_NODE: 9, - DOCUMENT_TYPE_NODE: 10, - DOCUMENT_FRAGMENT_NODE: 11, - NOTATION_NODE: 12 - }); -} - -(function() { - var element = this.Element; - this.Element = function(tagName, attributes) { - attributes = attributes || { }; - tagName = tagName.toLowerCase(); - var cache = Element.cache; - if (Prototype.Browser.IE && attributes.name) { - tagName = '<' + tagName + ' name="' + attributes.name + '">'; - delete attributes.name; - return Element.writeAttribute(document.createElement(tagName), attributes); - } - if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName)); - return Element.writeAttribute(cache[tagName].cloneNode(false), attributes); - }; - Object.extend(this.Element, element || { }); - if (element) this.Element.prototype = element.prototype; -}).call(window); - -Element.cache = { }; - -Element.Methods = { - visible: function(element) { - return $(element).style.display != 'none'; - }, - - toggle: function(element) { - element = $(element); - Element[Element.visible(element) ? 'hide' : 'show'](element); - return element; - }, - - hide: function(element) { - element = $(element); - element.style.display = 'none'; - return element; - }, - - show: function(element) { - element = $(element); - element.style.display = ''; - return element; - }, - - remove: function(element) { - element = $(element); - element.parentNode.removeChild(element); - return element; - }, - - update: function(element, content) { - element = $(element); - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) return element.update().insert(content); - content = Object.toHTML(content); - element.innerHTML = content.stripScripts(); - content.evalScripts.bind(content).defer(); - return element; - }, - - replace: function(element, content) { - element = $(element); - if (content && content.toElement) content = content.toElement(); - else if (!Object.isElement(content)) { - content = Object.toHTML(content); - var range = element.ownerDocument.createRange(); - range.selectNode(element); - content.evalScripts.bind(content).defer(); - content = range.createContextualFragment(content.stripScripts()); - } - element.parentNode.replaceChild(content, element); - return element; - }, - - insert: function(element, insertions) { - element = $(element); - - if (Object.isString(insertions) || Object.isNumber(insertions) || - Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML))) - insertions = {bottom:insertions}; - - var content, insert, tagName, childNodes; - - for (var position in insertions) { - content = insertions[position]; - position = position.toLowerCase(); - insert = Element._insertionTranslations[position]; - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) { - insert(element, content); - continue; - } - - content = Object.toHTML(content); - - tagName = ((position == 'before' || position == 'after') - ? element.parentNode : element).tagName.toUpperCase(); - - childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); - - if (position == 'top' || position == 'after') childNodes.reverse(); - childNodes.each(insert.curry(element)); - - content.evalScripts.bind(content).defer(); - } - - return element; - }, - - wrap: function(element, wrapper, attributes) { - element = $(element); - if (Object.isElement(wrapper)) - $(wrapper).writeAttribute(attributes || { }); - else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes); - else wrapper = new Element('div', wrapper); - if (element.parentNode) - element.parentNode.replaceChild(wrapper, element); - wrapper.appendChild(element); - return wrapper; - }, - - inspect: function(element) { - element = $(element); - var result = '<' + element.tagName.toLowerCase(); - $H({'id': 'id', 'className': 'class'}).each(function(pair) { - var property = pair.first(), attribute = pair.last(); - var value = (element[property] || '').toString(); - if (value) result += ' ' + attribute + '=' + value.inspect(true); - }); - return result + '>'; - }, - - recursivelyCollect: function(element, property) { - element = $(element); - var elements = []; - while (element = element[property]) - if (element.nodeType == 1) - elements.push(Element.extend(element)); - return elements; - }, - - ancestors: function(element) { - return $(element).recursivelyCollect('parentNode'); - }, - - descendants: function(element) { - return $(element).select("*"); - }, - - firstDescendant: function(element) { - element = $(element).firstChild; - while (element && element.nodeType != 1) element = element.nextSibling; - return $(element); - }, - - immediateDescendants: function(element) { - if (!(element = $(element).firstChild)) return []; - while (element && element.nodeType != 1) element = element.nextSibling; - if (element) return [element].concat($(element).nextSiblings()); - return []; - }, - - previousSiblings: function(element) { - return $(element).recursivelyCollect('previousSibling'); - }, - - nextSiblings: function(element) { - return $(element).recursivelyCollect('nextSibling'); - }, - - siblings: function(element) { - element = $(element); - return element.previousSiblings().reverse().concat(element.nextSiblings()); - }, - - match: function(element, selector) { - if (Object.isString(selector)) - selector = new Selector(selector); - return selector.match($(element)); - }, - - up: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(element.parentNode); - var ancestors = element.ancestors(); - return Object.isNumber(expression) ? ancestors[expression] : - Selector.findElement(ancestors, expression, index); - }, - - down: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return element.firstDescendant(); - return Object.isNumber(expression) ? element.descendants()[expression] : - Element.select(element, expression)[index || 0]; - }, - - previous: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element)); - var previousSiblings = element.previousSiblings(); - return Object.isNumber(expression) ? previousSiblings[expression] : - Selector.findElement(previousSiblings, expression, index); - }, - - next: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element)); - var nextSiblings = element.nextSiblings(); - return Object.isNumber(expression) ? nextSiblings[expression] : - Selector.findElement(nextSiblings, expression, index); - }, - - select: function() { - var args = $A(arguments), element = $(args.shift()); - return Selector.findChildElements(element, args); - }, - - adjacent: function() { - var args = $A(arguments), element = $(args.shift()); - return Selector.findChildElements(element.parentNode, args).without(element); - }, - - identify: function(element) { - element = $(element); - var id = element.readAttribute('id'), self = arguments.callee; - if (id) return id; - do { id = 'anonymous_element_' + self.counter++ } while ($(id)); - element.writeAttribute('id', id); - return id; - }, - - readAttribute: function(element, name) { - element = $(element); - if (Prototype.Browser.IE) { - var t = Element._attributeTranslations.read; - if (t.values[name]) return t.values[name](element, name); - if (t.names[name]) name = t.names[name]; - if (name.include(':')) { - return (!element.attributes || !element.attributes[name]) ? null : - element.attributes[name].value; - } - } - return element.getAttribute(name); - }, - - writeAttribute: function(element, name, value) { - element = $(element); - var attributes = { }, t = Element._attributeTranslations.write; - - if (typeof name == 'object') attributes = name; - else attributes[name] = Object.isUndefined(value) ? true : value; - - for (var attr in attributes) { - name = t.names[attr] || attr; - value = attributes[attr]; - if (t.values[attr]) name = t.values[attr](element, value); - if (value === false || value === null) - element.removeAttribute(name); - else if (value === true) - element.setAttribute(name, name); - else element.setAttribute(name, value); - } - return element; - }, - - getHeight: function(element) { - return $(element).getDimensions().height; - }, - - getWidth: function(element) { - return $(element).getDimensions().width; - }, - - classNames: function(element) { - return new Element.ClassNames(element); - }, - - hasClassName: function(element, className) { - if (!(element = $(element))) return; - var elementClassName = element.className; - return (elementClassName.length > 0 && (elementClassName == className || - new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName))); - }, - - addClassName: function(element, className) { - if (!(element = $(element))) return; - if (!element.hasClassName(className)) - element.className += (element.className ? ' ' : '') + className; - return element; - }, - - removeClassName: function(element, className) { - if (!(element = $(element))) return; - element.className = element.className.replace( - new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip(); - return element; - }, - - toggleClassName: function(element, className) { - if (!(element = $(element))) return; - return element[element.hasClassName(className) ? - 'removeClassName' : 'addClassName'](className); - }, - - // removes whitespace-only text node children - cleanWhitespace: function(element) { - element = $(element); - var node = element.firstChild; - while (node) { - var nextNode = node.nextSibling; - if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) - element.removeChild(node); - node = nextNode; - } - return element; - }, - - empty: function(element) { - return $(element).innerHTML.blank(); - }, - - descendantOf: function(element, ancestor) { - element = $(element), ancestor = $(ancestor); - - if (element.compareDocumentPosition) - return (element.compareDocumentPosition(ancestor) & 8) === 8; - - if (ancestor.contains) - return ancestor.contains(element) && ancestor !== element; - - while (element = element.parentNode) - if (element == ancestor) return true; - - return false; - }, - - scrollTo: function(element) { - element = $(element); - var pos = element.cumulativeOffset(); - window.scrollTo(pos[0], pos[1]); - return element; - }, - - getStyle: function(element, style) { - element = $(element); - style = style == 'float' ? 'cssFloat' : style.camelize(); - var value = element.style[style]; - if (!value || value == 'auto') { - var css = document.defaultView.getComputedStyle(element, null); - value = css ? css[style] : null; - } - if (style == 'opacity') return value ? parseFloat(value) : 1.0; - return value == 'auto' ? null : value; - }, - - getOpacity: function(element) { - return $(element).getStyle('opacity'); - }, - - setStyle: function(element, styles) { - element = $(element); - var elementStyle = element.style, match; - if (Object.isString(styles)) { - element.style.cssText += ';' + styles; - return styles.include('opacity') ? - element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element; - } - for (var property in styles) - if (property == 'opacity') element.setOpacity(styles[property]); - else - elementStyle[(property == 'float' || property == 'cssFloat') ? - (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') : - property] = styles[property]; - - return element; - }, - - setOpacity: function(element, value) { - element = $(element); - element.style.opacity = (value == 1 || value === '') ? '' : - (value < 0.00001) ? 0 : value; - return element; - }, - - getDimensions: function(element) { - element = $(element); - var display = element.getStyle('display'); - if (display != 'none' && display != null) // Safari bug - return {width: element.offsetWidth, height: element.offsetHeight}; - - // All *Width and *Height properties give 0 on elements with display none, - // so enable the element temporarily - var els = element.style; - var originalVisibility = els.visibility; - var originalPosition = els.position; - var originalDisplay = els.display; - els.visibility = 'hidden'; - els.position = 'absolute'; - els.display = 'block'; - var originalWidth = element.clientWidth; - var originalHeight = element.clientHeight; - els.display = originalDisplay; - els.position = originalPosition; - els.visibility = originalVisibility; - return {width: originalWidth, height: originalHeight}; - }, - - makePositioned: function(element) { - element = $(element); - var pos = Element.getStyle(element, 'position'); - if (pos == 'static' || !pos) { - element._madePositioned = true; - element.style.position = 'relative'; - // Opera returns the offset relative to the positioning context, when an - // element is position relative but top and left have not been defined - if (Prototype.Browser.Opera) { - element.style.top = 0; - element.style.left = 0; - } - } - return element; - }, - - undoPositioned: function(element) { - element = $(element); - if (element._madePositioned) { - element._madePositioned = undefined; - element.style.position = - element.style.top = - element.style.left = - element.style.bottom = - element.style.right = ''; - } - return element; - }, - - makeClipping: function(element) { - element = $(element); - if (element._overflow) return element; - element._overflow = Element.getStyle(element, 'overflow') || 'auto'; - if (element._overflow !== 'hidden') - element.style.overflow = 'hidden'; - return element; - }, - - undoClipping: function(element) { - element = $(element); - if (!element._overflow) return element; - element.style.overflow = element._overflow == 'auto' ? '' : element._overflow; - element._overflow = null; - return element; - }, - - cumulativeOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - positionedOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - if (element) { - if (element.tagName.toUpperCase() == 'BODY') break; - var p = Element.getStyle(element, 'position'); - if (p !== 'static') break; - } - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - absolutize: function(element) { - element = $(element); - if (element.getStyle('position') == 'absolute') return element; - // Position.prepare(); // To be done manually by Scripty when it needs it. - - var offsets = element.positionedOffset(); - var top = offsets[1]; - var left = offsets[0]; - var width = element.clientWidth; - var height = element.clientHeight; - - element._originalLeft = left - parseFloat(element.style.left || 0); - element._originalTop = top - parseFloat(element.style.top || 0); - element._originalWidth = element.style.width; - element._originalHeight = element.style.height; - - element.style.position = 'absolute'; - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.width = width + 'px'; - element.style.height = height + 'px'; - return element; - }, - - relativize: function(element) { - element = $(element); - if (element.getStyle('position') == 'relative') return element; - // Position.prepare(); // To be done manually by Scripty when it needs it. - - element.style.position = 'relative'; - var top = parseFloat(element.style.top || 0) - (element._originalTop || 0); - var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0); - - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.height = element._originalHeight; - element.style.width = element._originalWidth; - return element; - }, - - cumulativeScrollOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.scrollTop || 0; - valueL += element.scrollLeft || 0; - element = element.parentNode; - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - getOffsetParent: function(element) { - if (element.offsetParent) return $(element.offsetParent); - if (element == document.body) return $(element); - - while ((element = element.parentNode) && element != document.body) - if (Element.getStyle(element, 'position') != 'static') - return $(element); - - return $(document.body); - }, - - viewportOffset: function(forElement) { - var valueT = 0, valueL = 0; - - var element = forElement; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - - // Safari fix - if (element.offsetParent == document.body && - Element.getStyle(element, 'position') == 'absolute') break; - - } while (element = element.offsetParent); - - element = forElement; - do { - if (!Prototype.Browser.Opera || (element.tagName && (element.tagName.toUpperCase() == 'BODY'))) { - valueT -= element.scrollTop || 0; - valueL -= element.scrollLeft || 0; - } - } while (element = element.parentNode); - - return Element._returnOffset(valueL, valueT); - }, - - clonePosition: function(element, source) { - var options = Object.extend({ - setLeft: true, - setTop: true, - setWidth: true, - setHeight: true, - offsetTop: 0, - offsetLeft: 0 - }, arguments[2] || { }); - - // find page position of source - source = $(source); - var p = source.viewportOffset(); - - // find coordinate system to use - element = $(element); - var delta = [0, 0]; - var parent = null; - // delta [0,0] will do fine with position: fixed elements, - // position:absolute needs offsetParent deltas - if (Element.getStyle(element, 'position') == 'absolute') { - parent = element.getOffsetParent(); - delta = parent.viewportOffset(); - } - - // correct by body offsets (fixes Safari) - if (parent == document.body) { - delta[0] -= document.body.offsetLeft; - delta[1] -= document.body.offsetTop; - } - - // set position - if (options.setLeft) element.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px'; - if (options.setTop) element.style.top = (p[1] - delta[1] + options.offsetTop) + 'px'; - if (options.setWidth) element.style.width = source.offsetWidth + 'px'; - if (options.setHeight) element.style.height = source.offsetHeight + 'px'; - return element; - } -}; - -Element.Methods.identify.counter = 1; - -Object.extend(Element.Methods, { - getElementsBySelector: Element.Methods.select, - childElements: Element.Methods.immediateDescendants -}); - -Element._attributeTranslations = { - write: { - names: { - className: 'class', - htmlFor: 'for' - }, - values: { } - } -}; - -if (Prototype.Browser.Opera) { - Element.Methods.getStyle = Element.Methods.getStyle.wrap( - function(proceed, element, style) { - switch (style) { - case 'left': case 'top': case 'right': case 'bottom': - if (proceed(element, 'position') === 'static') return null; - case 'height': case 'width': - // returns '0px' for hidden elements; we want it to return null - if (!Element.visible(element)) return null; - - // returns the border-box dimensions rather than the content-box - // dimensions, so we subtract padding and borders from the value - var dim = parseInt(proceed(element, style), 10); - - if (dim !== element['offset' + style.capitalize()]) - return dim + 'px'; - - var properties; - if (style === 'height') { - properties = ['border-top-width', 'padding-top', - 'padding-bottom', 'border-bottom-width']; - } - else { - properties = ['border-left-width', 'padding-left', - 'padding-right', 'border-right-width']; - } - return properties.inject(dim, function(memo, property) { - var val = proceed(element, property); - return val === null ? memo : memo - parseInt(val, 10); - }) + 'px'; - default: return proceed(element, style); - } - } - ); - - Element.Methods.readAttribute = Element.Methods.readAttribute.wrap( - function(proceed, element, attribute) { - if (attribute === 'title') return element.title; - return proceed(element, attribute); - } - ); -} - -else if (Prototype.Browser.IE) { - // IE doesn't report offsets correctly for static elements, so we change them - // to "relative" to get the values, then change them back. - Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap( - function(proceed, element) { - element = $(element); - // IE throws an error if element is not in document - try { element.offsetParent } - catch(e) { return $(document.body) } - var position = element.getStyle('position'); - if (position !== 'static') return proceed(element); - element.setStyle({ position: 'relative' }); - var value = proceed(element); - element.setStyle({ position: position }); - return value; - } - ); - - $w('positionedOffset viewportOffset').each(function(method) { - Element.Methods[method] = Element.Methods[method].wrap( - function(proceed, element) { - element = $(element); - try { element.offsetParent } - catch(e) { return Element._returnOffset(0,0) } - var position = element.getStyle('position'); - if (position !== 'static') return proceed(element); - // Trigger hasLayout on the offset parent so that IE6 reports - // accurate offsetTop and offsetLeft values for position: fixed. - var offsetParent = element.getOffsetParent(); - if (offsetParent && offsetParent.getStyle('position') === 'fixed') - offsetParent.setStyle({ zoom: 1 }); - element.setStyle({ position: 'relative' }); - var value = proceed(element); - element.setStyle({ position: position }); - return value; - } - ); - }); - - Element.Methods.cumulativeOffset = Element.Methods.cumulativeOffset.wrap( - function(proceed, element) { - try { element.offsetParent } - catch(e) { return Element._returnOffset(0,0) } - return proceed(element); - } - ); - - Element.Methods.getStyle = function(element, style) { - element = $(element); - style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize(); - var value = element.style[style]; - if (!value && element.currentStyle) value = element.currentStyle[style]; - - if (style == 'opacity') { - if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) - if (value[1]) return parseFloat(value[1]) / 100; - return 1.0; - } - - if (value == 'auto') { - if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none')) - return element['offset' + style.capitalize()] + 'px'; - return null; - } - return value; - }; - - Element.Methods.setOpacity = function(element, value) { - function stripAlpha(filter){ - return filter.replace(/alpha\([^\)]*\)/gi,''); - } - element = $(element); - var currentStyle = element.currentStyle; - if ((currentStyle && !currentStyle.hasLayout) || - (!currentStyle && element.style.zoom == 'normal')) - element.style.zoom = 1; - - var filter = element.getStyle('filter'), style = element.style; - if (value == 1 || value === '') { - (filter = stripAlpha(filter)) ? - style.filter = filter : style.removeAttribute('filter'); - return element; - } else if (value < 0.00001) value = 0; - style.filter = stripAlpha(filter) + - 'alpha(opacity=' + (value * 100) + ')'; - return element; - }; - - Element._attributeTranslations = { - read: { - names: { - 'class': 'className', - 'for': 'htmlFor' - }, - values: { - _getAttr: function(element, attribute) { - return element.getAttribute(attribute, 2); - }, - _getAttrNode: function(element, attribute) { - var node = element.getAttributeNode(attribute); - return node ? node.value : ""; - }, - _getEv: function(element, attribute) { - attribute = element.getAttribute(attribute); - return attribute ? attribute.toString().slice(23, -2) : null; - }, - _flag: function(element, attribute) { - return $(element).hasAttribute(attribute) ? attribute : null; - }, - style: function(element) { - return element.style.cssText.toLowerCase(); - }, - title: function(element) { - return element.title; - } - } - } - }; - - Element._attributeTranslations.write = { - names: Object.extend({ - cellpadding: 'cellPadding', - cellspacing: 'cellSpacing' - }, Element._attributeTranslations.read.names), - values: { - checked: function(element, value) { - element.checked = !!value; - }, - - style: function(element, value) { - element.style.cssText = value ? value : ''; - } - } - }; - - Element._attributeTranslations.has = {}; - - $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' + - 'encType maxLength readOnly longDesc frameBorder').each(function(attr) { - Element._attributeTranslations.write.names[attr.toLowerCase()] = attr; - Element._attributeTranslations.has[attr.toLowerCase()] = attr; - }); - - (function(v) { - Object.extend(v, { - href: v._getAttr, - src: v._getAttr, - type: v._getAttr, - action: v._getAttrNode, - disabled: v._flag, - checked: v._flag, - readonly: v._flag, - multiple: v._flag, - onload: v._getEv, - onunload: v._getEv, - onclick: v._getEv, - ondblclick: v._getEv, - onmousedown: v._getEv, - onmouseup: v._getEv, - onmouseover: v._getEv, - onmousemove: v._getEv, - onmouseout: v._getEv, - onfocus: v._getEv, - onblur: v._getEv, - onkeypress: v._getEv, - onkeydown: v._getEv, - onkeyup: v._getEv, - onsubmit: v._getEv, - onreset: v._getEv, - onselect: v._getEv, - onchange: v._getEv - }); - })(Element._attributeTranslations.read.values); -} - -else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) { - Element.Methods.setOpacity = function(element, value) { - element = $(element); - element.style.opacity = (value == 1) ? 0.999999 : - (value === '') ? '' : (value < 0.00001) ? 0 : value; - return element; - }; -} - -else if (Prototype.Browser.WebKit) { - Element.Methods.setOpacity = function(element, value) { - element = $(element); - element.style.opacity = (value == 1 || value === '') ? '' : - (value < 0.00001) ? 0 : value; - - if (value == 1) - if(element.tagName.toUpperCase() == 'IMG' && element.width) { - element.width++; element.width--; - } else try { - var n = document.createTextNode(' '); - element.appendChild(n); - element.removeChild(n); - } catch (e) { } - - return element; - }; - - // Safari returns margins on body which is incorrect if the child is absolutely - // positioned. For performance reasons, redefine Element#cumulativeOffset for - // KHTML/WebKit only. - Element.Methods.cumulativeOffset = function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - if (element.offsetParent == document.body) - if (Element.getStyle(element, 'position') == 'absolute') break; - - element = element.offsetParent; - } while (element); - - return Element._returnOffset(valueL, valueT); - }; -} - -if (Prototype.Browser.IE || Prototype.Browser.Opera) { - // IE and Opera are missing .innerHTML support for TABLE-related and SELECT elements - Element.Methods.update = function(element, content) { - element = $(element); - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) return element.update().insert(content); - - content = Object.toHTML(content); - var tagName = element.tagName.toUpperCase(); - - if (tagName in Element._insertionTranslations.tags) { - $A(element.childNodes).each(function(node) { element.removeChild(node) }); - Element._getContentFromAnonymousElement(tagName, content.stripScripts()) - .each(function(node) { element.appendChild(node) }); - } - else element.innerHTML = content.stripScripts(); - - content.evalScripts.bind(content).defer(); - return element; - }; -} - -if ('outerHTML' in document.createElement('div')) { - Element.Methods.replace = function(element, content) { - element = $(element); - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) { - element.parentNode.replaceChild(content, element); - return element; - } - - content = Object.toHTML(content); - var parent = element.parentNode, tagName = parent.tagName.toUpperCase(); - - if (Element._insertionTranslations.tags[tagName]) { - var nextSibling = element.next(); - var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); - parent.removeChild(element); - if (nextSibling) - fragments.each(function(node) { parent.insertBefore(node, nextSibling) }); - else - fragments.each(function(node) { parent.appendChild(node) }); - } - else element.outerHTML = content.stripScripts(); - - content.evalScripts.bind(content).defer(); - return element; - }; -} - -Element._returnOffset = function(l, t) { - var result = [l, t]; - result.left = l; - result.top = t; - return result; -}; - -Element._getContentFromAnonymousElement = function(tagName, html) { - var div = new Element('div'), t = Element._insertionTranslations.tags[tagName]; - if (t) { - div.innerHTML = t[0] + html + t[1]; - t[2].times(function() { div = div.firstChild }); - } else div.innerHTML = html; - return $A(div.childNodes); -}; - -Element._insertionTranslations = { - before: function(element, node) { - element.parentNode.insertBefore(node, element); - }, - top: function(element, node) { - element.insertBefore(node, element.firstChild); - }, - bottom: function(element, node) { - element.appendChild(node); - }, - after: function(element, node) { - element.parentNode.insertBefore(node, element.nextSibling); - }, - tags: { - TABLE: ['<table>', '</table>', 1], - TBODY: ['<table><tbody>', '</tbody></table>', 2], - TR: ['<table><tbody><tr>', '</tr></tbody></table>', 3], - TD: ['<table><tbody><tr><td>', '</td></tr></tbody></table>', 4], - SELECT: ['<select>', '</select>', 1] - } -}; - -(function() { - Object.extend(this.tags, { - THEAD: this.tags.TBODY, - TFOOT: this.tags.TBODY, - TH: this.tags.TD - }); -}).call(Element._insertionTranslations); - -Element.Methods.Simulated = { - hasAttribute: function(element, attribute) { - attribute = Element._attributeTranslations.has[attribute] || attribute; - var node = $(element).getAttributeNode(attribute); - return !!(node && node.specified); - } -}; - -Element.Methods.ByTag = { }; - -Object.extend(Element, Element.Methods); - -if (!Prototype.BrowserFeatures.ElementExtensions && - document.createElement('div')['__proto__']) { - window.HTMLElement = { }; - window.HTMLElement.prototype = document.createElement('div')['__proto__']; - Prototype.BrowserFeatures.ElementExtensions = true; -} - -Element.extend = (function() { - if (Prototype.BrowserFeatures.SpecificElementExtensions) - return Prototype.K; - - var Methods = { }, ByTag = Element.Methods.ByTag; - - var extend = Object.extend(function(element) { - if (!element || element._extendedByPrototype || - element.nodeType != 1 || element == window) return element; - - var methods = Object.clone(Methods), - tagName = element.tagName.toUpperCase(), property, value; - - // extend methods for specific tags - if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]); - - for (property in methods) { - value = methods[property]; - if (Object.isFunction(value) && !(property in element)) - element[property] = value.methodize(); - } - - element._extendedByPrototype = Prototype.emptyFunction; - return element; - - }, { - refresh: function() { - // extend methods for all tags (Safari doesn't need this) - if (!Prototype.BrowserFeatures.ElementExtensions) { - Object.extend(Methods, Element.Methods); - Object.extend(Methods, Element.Methods.Simulated); - } - } - }); - - extend.refresh(); - return extend; -})(); - -Element.hasAttribute = function(element, attribute) { - if (element.hasAttribute) return element.hasAttribute(attribute); - return Element.Methods.Simulated.hasAttribute(element, attribute); -}; - -Element.addMethods = function(methods) { - var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag; - - if (!methods) { - Object.extend(Form, Form.Methods); - Object.extend(Form.Element, Form.Element.Methods); - Object.extend(Element.Methods.ByTag, { - "FORM": Object.clone(Form.Methods), - "INPUT": Object.clone(Form.Element.Methods), - "SELECT": Object.clone(Form.Element.Methods), - "TEXTAREA": Object.clone(Form.Element.Methods) - }); - } - - if (arguments.length == 2) { - var tagName = methods; - methods = arguments[1]; - } - - if (!tagName) Object.extend(Element.Methods, methods || { }); - else { - if (Object.isArray(tagName)) tagName.each(extend); - else extend(tagName); - } - - function extend(tagName) { - tagName = tagName.toUpperCase(); - if (!Element.Methods.ByTag[tagName]) - Element.Methods.ByTag[tagName] = { }; - Object.extend(Element.Methods.ByTag[tagName], methods); - } - - function copy(methods, destination, onlyIfAbsent) { - onlyIfAbsent = onlyIfAbsent || false; - for (var property in methods) { - var value = methods[property]; - if (!Object.isFunction(value)) continue; - if (!onlyIfAbsent || !(property in destination)) - destination[property] = value.methodize(); - } - } - - function findDOMClass(tagName) { - var klass; - var trans = { - "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph", - "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList", - "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading", - "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote", - "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION": - "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD": - "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR": - "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET": - "FrameSet", "IFRAME": "IFrame" - }; - if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element'; - if (window[klass]) return window[klass]; - klass = 'HTML' + tagName + 'Element'; - if (window[klass]) return window[klass]; - klass = 'HTML' + tagName.capitalize() + 'Element'; - if (window[klass]) return window[klass]; - - window[klass] = { }; - window[klass].prototype = document.createElement(tagName)['__proto__']; - return window[klass]; - } - - if (F.ElementExtensions) { - copy(Element.Methods, HTMLElement.prototype); - copy(Element.Methods.Simulated, HTMLElement.prototype, true); - } - - if (F.SpecificElementExtensions) { - for (var tag in Element.Methods.ByTag) { - var klass = findDOMClass(tag); - if (Object.isUndefined(klass)) continue; - copy(T[tag], klass.prototype); - } - } - - Object.extend(Element, Element.Methods); - delete Element.ByTag; - - if (Element.extend.refresh) Element.extend.refresh(); - Element.cache = { }; -}; - -document.viewport = { - getDimensions: function() { - var dimensions = { }, B = Prototype.Browser; - $w('width height').each(function(d) { - var D = d.capitalize(); - if (B.WebKit && !document.evaluate) { - // Safari <3.0 needs self.innerWidth/Height - dimensions[d] = self['inner' + D]; - } else if (B.Opera && parseFloat(window.opera.version()) < 9.5) { - // Opera <9.5 needs document.body.clientWidth/Height - dimensions[d] = document.body['client' + D] - } else { - dimensions[d] = document.documentElement['client' + D]; - } - }); - return dimensions; - }, - - getWidth: function() { - return this.getDimensions().width; - }, - - getHeight: function() { - return this.getDimensions().height; - }, - - getScrollOffsets: function() { - return Element._returnOffset( - window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft, - window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop); - } -}; -/* Portions of the Selector class are derived from Jack Slocum's DomQuery, - * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style - * license. Please see http://www.yui-ext.com/ for more information. */ - -var Selector = Class.create({ - initialize: function(expression) { - this.expression = expression.strip(); - - if (this.shouldUseSelectorsAPI()) { - this.mode = 'selectorsAPI'; - } else if (this.shouldUseXPath()) { - this.mode = 'xpath'; - this.compileXPathMatcher(); - } else { - this.mode = "normal"; - this.compileMatcher(); - } - - }, - - shouldUseXPath: function() { - if (!Prototype.BrowserFeatures.XPath) return false; - - var e = this.expression; - - // Safari 3 chokes on :*-of-type and :empty - if (Prototype.Browser.WebKit && - (e.include("-of-type") || e.include(":empty"))) - return false; - - // XPath can't do namespaced attributes, nor can it read - // the "checked" property from DOM nodes - if ((/(\[[\w-]*?:|:checked)/).test(e)) - return false; - - return true; - }, - - shouldUseSelectorsAPI: function() { - if (!Prototype.BrowserFeatures.SelectorsAPI) return false; - - if (!Selector._div) Selector._div = new Element('div'); - - // Make sure the browser treats the selector as valid. Test on an - // isolated element to minimize cost of this check. - try { - Selector._div.querySelector(this.expression); - } catch(e) { - return false; - } - - return true; - }, - - compileMatcher: function() { - var e = this.expression, ps = Selector.patterns, h = Selector.handlers, - c = Selector.criteria, le, p, m; - - if (Selector._cache[e]) { - this.matcher = Selector._cache[e]; - return; - } - - this.matcher = ["this.matcher = function(root) {", - "var r = root, h = Selector.handlers, c = false, n;"]; - - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - p = ps[i]; - if (m = e.match(p)) { - this.matcher.push(Object.isFunction(c[i]) ? c[i](m) : - new Template(c[i]).evaluate(m)); - e = e.replace(m[0], ''); - break; - } - } - } - - this.matcher.push("return h.unique(n);\n}"); - eval(this.matcher.join('\n')); - Selector._cache[this.expression] = this.matcher; - }, - - compileXPathMatcher: function() { - var e = this.expression, ps = Selector.patterns, - x = Selector.xpath, le, m; - - if (Selector._cache[e]) { - this.xpath = Selector._cache[e]; return; - } - - this.matcher = ['.//*']; - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - if (m = e.match(ps[i])) { - this.matcher.push(Object.isFunction(x[i]) ? x[i](m) : - new Template(x[i]).evaluate(m)); - e = e.replace(m[0], ''); - break; - } - } - } - - this.xpath = this.matcher.join(''); - Selector._cache[this.expression] = this.xpath; - }, - - findElements: function(root) { - root = root || document; - var e = this.expression, results; - - switch (this.mode) { - case 'selectorsAPI': - // querySelectorAll queries document-wide, then filters to descendants - // of the context element. That's not what we want. - // Add an explicit context to the selector if necessary. - if (root !== document) { - var oldId = root.id, id = $(root).identify(); - e = "#" + id + " " + e; - } - - results = $A(root.querySelectorAll(e)).map(Element.extend); - root.id = oldId; - - return results; - case 'xpath': - return document._getElementsByXPath(this.xpath, root); - default: - return this.matcher(root); - } - }, - - match: function(element) { - this.tokens = []; - - var e = this.expression, ps = Selector.patterns, as = Selector.assertions; - var le, p, m; - - while (e && le !== e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - p = ps[i]; - if (m = e.match(p)) { - // use the Selector.assertions methods unless the selector - // is too complex. - if (as[i]) { - this.tokens.push([i, Object.clone(m)]); - e = e.replace(m[0], ''); - } else { - // reluctantly do a document-wide search - // and look for a match in the array - return this.findElements(document).include(element); - } - } - } - } - - var match = true, name, matches; - for (var i = 0, token; token = this.tokens[i]; i++) { - name = token[0], matches = token[1]; - if (!Selector.assertions[name](element, matches)) { - match = false; break; - } - } - - return match; - }, - - toString: function() { - return this.expression; - }, - - inspect: function() { - return "#<Selector:" + this.expression.inspect() + ">"; - } -}); - -Object.extend(Selector, { - _cache: { }, - - xpath: { - descendant: "//*", - child: "/*", - adjacent: "/following-sibling::*[1]", - laterSibling: '/following-sibling::*', - tagName: function(m) { - if (m[1] == '*') return ''; - return "[local-name()='" + m[1].toLowerCase() + - "' or local-name()='" + m[1].toUpperCase() + "']"; - }, - className: "[contains(concat(' ', @class, ' '), ' #{1} ')]", - id: "[@id='#{1}']", - attrPresence: function(m) { - m[1] = m[1].toLowerCase(); - return new Template("[@#{1}]").evaluate(m); - }, - attr: function(m) { - m[1] = m[1].toLowerCase(); - m[3] = m[5] || m[6]; - return new Template(Selector.xpath.operators[m[2]]).evaluate(m); - }, - pseudo: function(m) { - var h = Selector.xpath.pseudos[m[1]]; - if (!h) return ''; - if (Object.isFunction(h)) return h(m); - return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m); - }, - operators: { - '=': "[@#{1}='#{3}']", - '!=': "[@#{1}!='#{3}']", - '^=': "[starts-with(@#{1}, '#{3}')]", - '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']", - '*=': "[contains(@#{1}, '#{3}')]", - '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]", - '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]" - }, - pseudos: { - 'first-child': '[not(preceding-sibling::*)]', - 'last-child': '[not(following-sibling::*)]', - 'only-child': '[not(preceding-sibling::* or following-sibling::*)]', - 'empty': "[count(*) = 0 and (count(text()) = 0)]", - 'checked': "[@checked]", - 'disabled': "[(@disabled) and (@type!='hidden')]", - 'enabled': "[not(@disabled) and (@type!='hidden')]", - 'not': function(m) { - var e = m[6], p = Selector.patterns, - x = Selector.xpath, le, v; - - var exclusion = []; - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in p) { - if (m = e.match(p[i])) { - v = Object.isFunction(x[i]) ? x[i](m) : new Template(x[i]).evaluate(m); - exclusion.push("(" + v.substring(1, v.length - 1) + ")"); - e = e.replace(m[0], ''); - break; - } - } - } - return "[not(" + exclusion.join(" and ") + ")]"; - }, - 'nth-child': function(m) { - return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m); - }, - 'nth-last-child': function(m) { - return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m); - }, - 'nth-of-type': function(m) { - return Selector.xpath.pseudos.nth("position() ", m); - }, - 'nth-last-of-type': function(m) { - return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m); - }, - 'first-of-type': function(m) { - m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m); - }, - 'last-of-type': function(m) { - m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m); - }, - 'only-of-type': function(m) { - var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m); - }, - nth: function(fragment, m) { - var mm, formula = m[6], predicate; - if (formula == 'even') formula = '2n+0'; - if (formula == 'odd') formula = '2n+1'; - if (mm = formula.match(/^(\d+)$/)) // digit only - return '[' + fragment + "= " + mm[1] + ']'; - if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b - if (mm[1] == "-") mm[1] = -1; - var a = mm[1] ? Number(mm[1]) : 1; - var b = mm[2] ? Number(mm[2]) : 0; - predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " + - "((#{fragment} - #{b}) div #{a} >= 0)]"; - return new Template(predicate).evaluate({ - fragment: fragment, a: a, b: b }); - } - } - } - }, - - criteria: { - tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;', - className: 'n = h.className(n, r, "#{1}", c); c = false;', - id: 'n = h.id(n, r, "#{1}", c); c = false;', - attrPresence: 'n = h.attrPresence(n, r, "#{1}", c); c = false;', - attr: function(m) { - m[3] = (m[5] || m[6]); - return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(m); - }, - pseudo: function(m) { - if (m[6]) m[6] = m[6].replace(/"/g, '\\"'); - return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m); - }, - descendant: 'c = "descendant";', - child: 'c = "child";', - adjacent: 'c = "adjacent";', - laterSibling: 'c = "laterSibling";' - }, - - patterns: { - // combinators must be listed first - // (and descendant needs to be last combinator) - laterSibling: /^\s*~\s*/, - child: /^\s*>\s*/, - adjacent: /^\s*\+\s*/, - descendant: /^\s/, - - // selectors follow - tagName: /^\s*(\*|[\w\-]+)(\b|$)?/, - id: /^#([\w\-\*]+)(\b|$)/, - className: /^\.([\w\-\*]+)(\b|$)/, - pseudo: -/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/, - attrPresence: /^\[((?:[\w]+:)?[\w]+)\]/, - attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/ - }, - - // for Selector.match and Element#match - assertions: { - tagName: function(element, matches) { - return matches[1].toUpperCase() == element.tagName.toUpperCase(); - }, - - className: function(element, matches) { - return Element.hasClassName(element, matches[1]); - }, - - id: function(element, matches) { - return element.id === matches[1]; - }, - - attrPresence: function(element, matches) { - return Element.hasAttribute(element, matches[1]); - }, - - attr: function(element, matches) { - var nodeValue = Element.readAttribute(element, matches[1]); - return nodeValue && Selector.operators[matches[2]](nodeValue, matches[5] || matches[6]); - } - }, - - handlers: { - // UTILITY FUNCTIONS - // joins two collections - concat: function(a, b) { - for (var i = 0, node; node = b[i]; i++) - a.push(node); - return a; - }, - - // marks an array of nodes for counting - mark: function(nodes) { - var _true = Prototype.emptyFunction; - for (var i = 0, node; node = nodes[i]; i++) - node._countedByPrototype = _true; - return nodes; - }, - - unmark: function(nodes) { - for (var i = 0, node; node = nodes[i]; i++) - node._countedByPrototype = undefined; - return nodes; - }, - - // mark each child node with its position (for nth calls) - // "ofType" flag indicates whether we're indexing for nth-of-type - // rather than nth-child - index: function(parentNode, reverse, ofType) { - parentNode._countedByPrototype = Prototype.emptyFunction; - if (reverse) { - for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) { - var node = nodes[i]; - if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++; - } - } else { - for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++) - if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++; - } - }, - - // filters out duplicates and extends all nodes - unique: function(nodes) { - if (nodes.length == 0) return nodes; - var results = [], n; - for (var i = 0, l = nodes.length; i < l; i++) - if (!(n = nodes[i])._countedByPrototype) { - n._countedByPrototype = Prototype.emptyFunction; - results.push(Element.extend(n)); - } - return Selector.handlers.unmark(results); - }, - - // COMBINATOR FUNCTIONS - descendant: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - h.concat(results, node.getElementsByTagName('*')); - return results; - }, - - child: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) { - for (var j = 0, child; child = node.childNodes[j]; j++) - if (child.nodeType == 1 && child.tagName != '!') results.push(child); - } - return results; - }, - - adjacent: function(nodes) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - var next = this.nextElementSibling(node); - if (next) results.push(next); - } - return results; - }, - - laterSibling: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - h.concat(results, Element.nextSiblings(node)); - return results; - }, - - nextElementSibling: function(node) { - while (node = node.nextSibling) - if (node.nodeType == 1) return node; - return null; - }, - - previousElementSibling: function(node) { - while (node = node.previousSibling) - if (node.nodeType == 1) return node; - return null; - }, - - // TOKEN FUNCTIONS - tagName: function(nodes, root, tagName, combinator) { - var uTagName = tagName.toUpperCase(); - var results = [], h = Selector.handlers; - if (nodes) { - if (combinator) { - // fastlane for ordinary descendant combinators - if (combinator == "descendant") { - for (var i = 0, node; node = nodes[i]; i++) - h.concat(results, node.getElementsByTagName(tagName)); - return results; - } else nodes = this[combinator](nodes); - if (tagName == "*") return nodes; - } - for (var i = 0, node; node = nodes[i]; i++) - if (node.tagName.toUpperCase() === uTagName) results.push(node); - return results; - } else return root.getElementsByTagName(tagName); - }, - - id: function(nodes, root, id, combinator) { - var targetNode = $(id), h = Selector.handlers; - if (!targetNode) return []; - if (!nodes && root == document) return [targetNode]; - if (nodes) { - if (combinator) { - if (combinator == 'child') { - for (var i = 0, node; node = nodes[i]; i++) - if (targetNode.parentNode == node) return [targetNode]; - } else if (combinator == 'descendant') { - for (var i = 0, node; node = nodes[i]; i++) - if (Element.descendantOf(targetNode, node)) return [targetNode]; - } else if (combinator == 'adjacent') { - for (var i = 0, node; node = nodes[i]; i++) - if (Selector.handlers.previousElementSibling(targetNode) == node) - return [targetNode]; - } else nodes = h[combinator](nodes); - } - for (var i = 0, node; node = nodes[i]; i++) - if (node == targetNode) return [targetNode]; - return []; - } - return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : []; - }, - - className: function(nodes, root, className, combinator) { - if (nodes && combinator) nodes = this[combinator](nodes); - return Selector.handlers.byClassName(nodes, root, className); - }, - - byClassName: function(nodes, root, className) { - if (!nodes) nodes = Selector.handlers.descendant([root]); - var needle = ' ' + className + ' '; - for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) { - nodeClassName = node.className; - if (nodeClassName.length == 0) continue; - if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle)) - results.push(node); - } - return results; - }, - - attrPresence: function(nodes, root, attr, combinator) { - if (!nodes) nodes = root.getElementsByTagName("*"); - if (nodes && combinator) nodes = this[combinator](nodes); - var results = []; - for (var i = 0, node; node = nodes[i]; i++) - if (Element.hasAttribute(node, attr)) results.push(node); - return results; - }, - - attr: function(nodes, root, attr, value, operator, combinator) { - if (!nodes) nodes = root.getElementsByTagName("*"); - if (nodes && combinator) nodes = this[combinator](nodes); - var handler = Selector.operators[operator], results = []; - for (var i = 0, node; node = nodes[i]; i++) { - var nodeValue = Element.readAttribute(node, attr); - if (nodeValue === null) continue; - if (handler(nodeValue, value)) results.push(node); - } - return results; - }, - - pseudo: function(nodes, name, value, root, combinator) { - if (nodes && combinator) nodes = this[combinator](nodes); - if (!nodes) nodes = root.getElementsByTagName("*"); - return Selector.pseudos[name](nodes, value, root); - } - }, - - pseudos: { - 'first-child': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - if (Selector.handlers.previousElementSibling(node)) continue; - results.push(node); - } - return results; - }, - 'last-child': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - if (Selector.handlers.nextElementSibling(node)) continue; - results.push(node); - } - return results; - }, - 'only-child': function(nodes, value, root) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!h.previousElementSibling(node) && !h.nextElementSibling(node)) - results.push(node); - return results; - }, - 'nth-child': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root); - }, - 'nth-last-child': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, true); - }, - 'nth-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, false, true); - }, - 'nth-last-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, true, true); - }, - 'first-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, "1", root, false, true); - }, - 'last-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, "1", root, true, true); - }, - 'only-of-type': function(nodes, formula, root) { - var p = Selector.pseudos; - return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root); - }, - - // handles the an+b logic - getIndices: function(a, b, total) { - if (a == 0) return b > 0 ? [b] : []; - return $R(1, total).inject([], function(memo, i) { - if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i); - return memo; - }); - }, - - // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type - nth: function(nodes, formula, root, reverse, ofType) { - if (nodes.length == 0) return []; - if (formula == 'even') formula = '2n+0'; - if (formula == 'odd') formula = '2n+1'; - var h = Selector.handlers, results = [], indexed = [], m; - h.mark(nodes); - for (var i = 0, node; node = nodes[i]; i++) { - if (!node.parentNode._countedByPrototype) { - h.index(node.parentNode, reverse, ofType); - indexed.push(node.parentNode); - } - } - if (formula.match(/^\d+$/)) { // just a number - formula = Number(formula); - for (var i = 0, node; node = nodes[i]; i++) - if (node.nodeIndex == formula) results.push(node); - } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b - if (m[1] == "-") m[1] = -1; - var a = m[1] ? Number(m[1]) : 1; - var b = m[2] ? Number(m[2]) : 0; - var indices = Selector.pseudos.getIndices(a, b, nodes.length); - for (var i = 0, node, l = indices.length; node = nodes[i]; i++) { - for (var j = 0; j < l; j++) - if (node.nodeIndex == indices[j]) results.push(node); - } - } - h.unmark(nodes); - h.unmark(indexed); - return results; - }, - - 'empty': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - // IE treats comments as element nodes - if (node.tagName == '!' || node.firstChild) continue; - results.push(node); - } - return results; - }, - - 'not': function(nodes, selector, root) { - var h = Selector.handlers, selectorType, m; - var exclusions = new Selector(selector).findElements(root); - h.mark(exclusions); - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!node._countedByPrototype) results.push(node); - h.unmark(exclusions); - return results; - }, - - 'enabled': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!node.disabled && (!node.type || node.type !== 'hidden')) - results.push(node); - return results; - }, - - 'disabled': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (node.disabled) results.push(node); - return results; - }, - - 'checked': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (node.checked) results.push(node); - return results; - } - }, - - operators: { - '=': function(nv, v) { return nv == v; }, - '!=': function(nv, v) { return nv != v; }, - '^=': function(nv, v) { return nv == v || nv && nv.startsWith(v); }, - '$=': function(nv, v) { return nv == v || nv && nv.endsWith(v); }, - '*=': function(nv, v) { return nv == v || nv && nv.include(v); }, - '$=': function(nv, v) { return nv.endsWith(v); }, - '*=': function(nv, v) { return nv.include(v); }, - '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); }, - '|=': function(nv, v) { return ('-' + (nv || "").toUpperCase() + - '-').include('-' + (v || "").toUpperCase() + '-'); } - }, - - split: function(expression) { - var expressions = []; - expression.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) { - expressions.push(m[1].strip()); - }); - return expressions; - }, - - matchElements: function(elements, expression) { - var matches = $$(expression), h = Selector.handlers; - h.mark(matches); - for (var i = 0, results = [], element; element = elements[i]; i++) - if (element._countedByPrototype) results.push(element); - h.unmark(matches); - return results; - }, - - findElement: function(elements, expression, index) { - if (Object.isNumber(expression)) { - index = expression; expression = false; - } - return Selector.matchElements(elements, expression || '*')[index || 0]; - }, - - findChildElements: function(element, expressions) { - expressions = Selector.split(expressions.join(',')); - var results = [], h = Selector.handlers; - for (var i = 0, l = expressions.length, selector; i < l; i++) { - selector = new Selector(expressions[i].strip()); - h.concat(results, selector.findElements(element)); - } - return (l > 1) ? h.unique(results) : results; - } -}); - -if (Prototype.Browser.IE) { - Object.extend(Selector.handlers, { - // IE returns comment nodes on getElementsByTagName("*"). - // Filter them out. - concat: function(a, b) { - for (var i = 0, node; node = b[i]; i++) - if (node.tagName !== "!") a.push(node); - return a; - }, - - // IE improperly serializes _countedByPrototype in (inner|outer)HTML. - unmark: function(nodes) { - for (var i = 0, node; node = nodes[i]; i++) - node.removeAttribute('_countedByPrototype'); - return nodes; - } - }); -} - -function $$() { - return Selector.findChildElements(document, $A(arguments)); -} -var Form = { - reset: function(form) { - $(form).reset(); - return form; - }, - - serializeElements: function(elements, options) { - if (typeof options != 'object') options = { hash: !!options }; - else if (Object.isUndefined(options.hash)) options.hash = true; - var key, value, submitted = false, submit = options.submit; - - var data = elements.inject({ }, function(result, element) { - if (!element.disabled && element.name) { - key = element.name; value = $(element).getValue(); - if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted && - submit !== false && (!submit || key == submit) && (submitted = true)))) { - if (key in result) { - // a key is already present; construct an array of values - if (!Object.isArray(result[key])) result[key] = [result[key]]; - result[key].push(value); - } - else result[key] = value; - } - } - return result; - }); - - return options.hash ? data : Object.toQueryString(data); - } -}; - -Form.Methods = { - serialize: function(form, options) { - return Form.serializeElements(Form.getElements(form), options); - }, - - getElements: function(form) { - return $A($(form).getElementsByTagName('*')).inject([], - function(elements, child) { - if (Form.Element.Serializers[child.tagName.toLowerCase()]) - elements.push(Element.extend(child)); - return elements; - } - ); - }, - - getInputs: function(form, typeName, name) { - form = $(form); - var inputs = form.getElementsByTagName('input'); - - if (!typeName && !name) return $A(inputs).map(Element.extend); - - for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) { - var input = inputs[i]; - if ((typeName && input.type != typeName) || (name && input.name != name)) - continue; - matchingInputs.push(Element.extend(input)); - } - - return matchingInputs; - }, - - disable: function(form) { - form = $(form); - Form.getElements(form).invoke('disable'); - return form; - }, - - enable: function(form) { - form = $(form); - Form.getElements(form).invoke('enable'); - return form; - }, - - findFirstElement: function(form) { - var elements = $(form).getElements().findAll(function(element) { - return 'hidden' != element.type && !element.disabled; - }); - var firstByIndex = elements.findAll(function(element) { - return element.hasAttribute('tabIndex') && element.tabIndex >= 0; - }).sortBy(function(element) { return element.tabIndex }).first(); - - return firstByIndex ? firstByIndex : elements.find(function(element) { - return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); - }); - }, - - focusFirstElement: function(form) { - form = $(form); - form.findFirstElement().activate(); - return form; - }, - - request: function(form, options) { - form = $(form), options = Object.clone(options || { }); - - var params = options.parameters, action = form.readAttribute('action') || ''; - if (action.blank()) action = window.location.href; - options.parameters = form.serialize(true); - - if (params) { - if (Object.isString(params)) params = params.toQueryParams(); - Object.extend(options.parameters, params); - } - - if (form.hasAttribute('method') && !options.method) - options.method = form.method; - - return new Ajax.Request(action, options); - } -}; - -/*--------------------------------------------------------------------------*/ - -Form.Element = { - focus: function(element) { - $(element).focus(); - return element; - }, - - select: function(element) { - $(element).select(); - return element; - } -}; - -Form.Element.Methods = { - serialize: function(element) { - element = $(element); - if (!element.disabled && element.name) { - var value = element.getValue(); - if (value != undefined) { - var pair = { }; - pair[element.name] = value; - return Object.toQueryString(pair); - } - } - return ''; - }, - - getValue: function(element) { - element = $(element); - var method = element.tagName.toLowerCase(); - return Form.Element.Serializers[method](element); - }, - - setValue: function(element, value) { - element = $(element); - var method = element.tagName.toLowerCase(); - Form.Element.Serializers[method](element, value); - return element; - }, - - clear: function(element) { - $(element).value = ''; - return element; - }, - - present: function(element) { - return $(element).value != ''; - }, - - activate: function(element) { - element = $(element); - try { - element.focus(); - if (element.select && (element.tagName.toLowerCase() != 'input' || - !['button', 'reset', 'submit'].include(element.type))) - element.select(); - } catch (e) { } - return element; - }, - - disable: function(element) { - element = $(element); - element.disabled = true; - return element; - }, - - enable: function(element) { - element = $(element); - element.disabled = false; - return element; - } -}; - -/*--------------------------------------------------------------------------*/ - -var Field = Form.Element; -var $F = Form.Element.Methods.getValue; - -/*--------------------------------------------------------------------------*/ - -Form.Element.Serializers = { - input: function(element, value) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - return Form.Element.Serializers.inputSelector(element, value); - default: - return Form.Element.Serializers.textarea(element, value); - } - }, - - inputSelector: function(element, value) { - if (Object.isUndefined(value)) return element.checked ? element.value : null; - else element.checked = !!value; - }, - - textarea: function(element, value) { - if (Object.isUndefined(value)) return element.value; - else element.value = value; - }, - - select: function(element, value) { - if (Object.isUndefined(value)) - return this[element.type == 'select-one' ? - 'selectOne' : 'selectMany'](element); - else { - var opt, currentValue, single = !Object.isArray(value); - for (var i = 0, length = element.length; i < length; i++) { - opt = element.options[i]; - currentValue = this.optionValue(opt); - if (single) { - if (currentValue == value) { - opt.selected = true; - return; - } - } - else opt.selected = value.include(currentValue); - } - } - }, - - selectOne: function(element) { - var index = element.selectedIndex; - return index >= 0 ? this.optionValue(element.options[index]) : null; - }, - - selectMany: function(element) { - var values, length = element.length; - if (!length) return null; - - for (var i = 0, values = []; i < length; i++) { - var opt = element.options[i]; - if (opt.selected) values.push(this.optionValue(opt)); - } - return values; - }, - - optionValue: function(opt) { - // extend element because hasAttribute may not be native - return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text; - } -}; - -/*--------------------------------------------------------------------------*/ - -Abstract.TimedObserver = Class.create(PeriodicalExecuter, { - initialize: function($super, element, frequency, callback) { - $super(callback, frequency); - this.element = $(element); - this.lastValue = this.getValue(); - }, - - execute: function() { - var value = this.getValue(); - if (Object.isString(this.lastValue) && Object.isString(value) ? - this.lastValue != value : String(this.lastValue) != String(value)) { - this.callback(this.element, value); - this.lastValue = value; - } - } -}); - -Form.Element.Observer = Class.create(Abstract.TimedObserver, { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.Observer = Class.create(Abstract.TimedObserver, { - getValue: function() { - return Form.serialize(this.element); - } -}); - -/*--------------------------------------------------------------------------*/ - -Abstract.EventObserver = Class.create({ - initialize: function(element, callback) { - this.element = $(element); - this.callback = callback; - - this.lastValue = this.getValue(); - if (this.element.tagName.toLowerCase() == 'form') - this.registerFormCallbacks(); - else - this.registerCallback(this.element); - }, - - onElementEvent: function() { - var value = this.getValue(); - if (this.lastValue != value) { - this.callback(this.element, value); - this.lastValue = value; - } - }, - - registerFormCallbacks: function() { - Form.getElements(this.element).each(this.registerCallback, this); - }, - - registerCallback: function(element) { - if (element.type) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - Event.observe(element, 'click', this.onElementEvent.bind(this)); - break; - default: - Event.observe(element, 'change', this.onElementEvent.bind(this)); - break; - } - } - } -}); - -Form.Element.EventObserver = Class.create(Abstract.EventObserver, { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.EventObserver = Class.create(Abstract.EventObserver, { - getValue: function() { - return Form.serialize(this.element); - } -}); -if (!window.Event) var Event = { }; - -Object.extend(Event, { - KEY_BACKSPACE: 8, - KEY_TAB: 9, - KEY_RETURN: 13, - KEY_ESC: 27, - KEY_LEFT: 37, - KEY_UP: 38, - KEY_RIGHT: 39, - KEY_DOWN: 40, - KEY_DELETE: 46, - KEY_HOME: 36, - KEY_END: 35, - KEY_PAGEUP: 33, - KEY_PAGEDOWN: 34, - KEY_INSERT: 45, - - cache: { }, - - relatedTarget: function(event) { - var element; - switch(event.type) { - case 'mouseover': element = event.fromElement; break; - case 'mouseout': element = event.toElement; break; - default: return null; - } - return Element.extend(element); - } -}); - -Event.Methods = (function() { - var isButton; - - if (Prototype.Browser.IE) { - var buttonMap = { 0: 1, 1: 4, 2: 2 }; - isButton = function(event, code) { - return event.button == buttonMap[code]; - }; - - } else if (Prototype.Browser.WebKit) { - isButton = function(event, code) { - switch (code) { - case 0: return event.which == 1 && !event.metaKey; - case 1: return event.which == 1 && event.metaKey; - default: return false; - } - }; - - } else { - isButton = function(event, code) { - return event.which ? (event.which === code + 1) : (event.button === code); - }; - } - - return { - isLeftClick: function(event) { return isButton(event, 0) }, - isMiddleClick: function(event) { return isButton(event, 1) }, - isRightClick: function(event) { return isButton(event, 2) }, - - element: function(event) { - event = Event.extend(event); - - var node = event.target, - type = event.type, - currentTarget = event.currentTarget; - - if (currentTarget && currentTarget.tagName) { - // Firefox screws up the "click" event when moving between radio buttons - // via arrow keys. It also screws up the "load" and "error" events on images, - // reporting the document as the target instead of the original image. - if (type === 'load' || type === 'error' || - (type === 'click' && currentTarget.tagName.toLowerCase() === 'input' - && currentTarget.type === 'radio')) - node = currentTarget; - } - if (node.nodeType == Node.TEXT_NODE) node = node.parentNode; - return Element.extend(node); - }, - - findElement: function(event, expression) { - var element = Event.element(event); - if (!expression) return element; - var elements = [element].concat(element.ancestors()); - return Selector.findElement(elements, expression, 0); - }, - - pointer: function(event) { - var docElement = document.documentElement, - body = document.body || { scrollLeft: 0, scrollTop: 0 }; - return { - x: event.pageX || (event.clientX + - (docElement.scrollLeft || body.scrollLeft) - - (docElement.clientLeft || 0)), - y: event.pageY || (event.clientY + - (docElement.scrollTop || body.scrollTop) - - (docElement.clientTop || 0)) - }; - }, - - pointerX: function(event) { return Event.pointer(event).x }, - pointerY: function(event) { return Event.pointer(event).y }, - - stop: function(event) { - Event.extend(event); - event.preventDefault(); - event.stopPropagation(); - event.stopped = true; - } - }; -})(); - -Event.extend = (function() { - var methods = Object.keys(Event.Methods).inject({ }, function(m, name) { - m[name] = Event.Methods[name].methodize(); - return m; - }); - - if (Prototype.Browser.IE) { - Object.extend(methods, { - stopPropagation: function() { this.cancelBubble = true }, - preventDefault: function() { this.returnValue = false }, - inspect: function() { return "[object Event]" } - }); - - return function(event) { - if (!event) return false; - if (event._extendedByPrototype) return event; - - event._extendedByPrototype = Prototype.emptyFunction; - var pointer = Event.pointer(event); - Object.extend(event, { - target: event.srcElement, - relatedTarget: Event.relatedTarget(event), - pageX: pointer.x, - pageY: pointer.y - }); - return Object.extend(event, methods); - }; - - } else { - Event.prototype = Event.prototype || document.createEvent("HTMLEvents")['__proto__']; - Object.extend(Event.prototype, methods); - return Prototype.K; - } -})(); - -Object.extend(Event, (function() { - var cache = Event.cache; - - function getEventID(element) { - if (element._prototypeEventID) return element._prototypeEventID[0]; - arguments.callee.id = arguments.callee.id || 1; - return element._prototypeEventID = [++arguments.callee.id]; - } - - function getDOMEventName(eventName) { - if (eventName && eventName.include(':')) return "dataavailable"; - return eventName; - } - - function getCacheForID(id) { - return cache[id] = cache[id] || { }; - } - - function getWrappersForEventName(id, eventName) { - var c = getCacheForID(id); - return c[eventName] = c[eventName] || []; - } - - function createWrapper(element, eventName, handler) { - var id = getEventID(element); - var c = getWrappersForEventName(id, eventName); - if (c.pluck("handler").include(handler)) return false; - - var wrapper = function(event) { - if (!Event || !Event.extend || - (event.eventName && event.eventName != eventName)) - return false; - - Event.extend(event); - handler.call(element, event); - }; - - wrapper.handler = handler; - c.push(wrapper); - return wrapper; - } - - function findWrapper(id, eventName, handler) { - var c = getWrappersForEventName(id, eventName); - return c.find(function(wrapper) { return wrapper.handler == handler }); - } - - function destroyWrapper(id, eventName, handler) { - var c = getCacheForID(id); - if (!c[eventName]) return false; - c[eventName] = c[eventName].without(findWrapper(id, eventName, handler)); - } - - function destroyCache() { - for (var id in cache) - for (var eventName in cache[id]) - cache[id][eventName] = null; - } - - - // Internet Explorer needs to remove event handlers on page unload - // in order to avoid memory leaks. - if (window.attachEvent) { - window.attachEvent("onunload", destroyCache); - } - - // Safari has a dummy event handler on page unload so that it won't - // use its bfcache. Safari <= 3.1 has an issue with restoring the "document" - // object when page is returned to via the back button using its bfcache. - if (Prototype.Browser.WebKit) { - window.addEventListener('unload', Prototype.emptyFunction, false); - } - - return { - observe: function(element, eventName, handler) { - element = $(element); - var name = getDOMEventName(eventName); - - var wrapper = createWrapper(element, eventName, handler); - if (!wrapper) return element; - - if (element.addEventListener) { - element.addEventListener(name, wrapper, false); - } else { - element.attachEvent("on" + name, wrapper); - } - - return element; - }, - - stopObserving: function(element, eventName, handler) { - element = $(element); - var id = getEventID(element), name = getDOMEventName(eventName); - - if (!handler && eventName) { - getWrappersForEventName(id, eventName).each(function(wrapper) { - element.stopObserving(eventName, wrapper.handler); - }); - return element; - - } else if (!eventName) { - Object.keys(getCacheForID(id)).each(function(eventName) { - element.stopObserving(eventName); - }); - return element; - } - - var wrapper = findWrapper(id, eventName, handler); - if (!wrapper) return element; - - if (element.removeEventListener) { - element.removeEventListener(name, wrapper, false); - } else { - element.detachEvent("on" + name, wrapper); - } - - destroyWrapper(id, eventName, handler); - - return element; - }, - - fire: function(element, eventName, memo) { - element = $(element); - if (element == document && document.createEvent && !element.dispatchEvent) - element = document.documentElement; - - var event; - if (document.createEvent) { - event = document.createEvent("HTMLEvents"); - event.initEvent("dataavailable", true, true); - } else { - event = document.createEventObject(); - event.eventType = "ondataavailable"; - } - - event.eventName = eventName; - event.memo = memo || { }; - - if (document.createEvent) { - element.dispatchEvent(event); - } else { - element.fireEvent(event.eventType, event); - } - - return Event.extend(event); - } - }; -})()); - -Object.extend(Event, Event.Methods); - -Element.addMethods({ - fire: Event.fire, - observe: Event.observe, - stopObserving: Event.stopObserving -}); - -Object.extend(document, { - fire: Element.Methods.fire.methodize(), - observe: Element.Methods.observe.methodize(), - stopObserving: Element.Methods.stopObserving.methodize(), - loaded: false -}); - -(function() { - /* Support for the DOMContentLoaded event is based on work by Dan Webb, - Matthias Miller, Dean Edwards and John Resig. */ - - var timer; - - function fireContentLoadedEvent() { - if (document.loaded) return; - if (timer) window.clearInterval(timer); - document.fire("dom:loaded"); - document.loaded = true; - } - - if (document.addEventListener) { - if (Prototype.Browser.WebKit) { - timer = window.setInterval(function() { - if (/loaded|complete/.test(document.readyState)) - fireContentLoadedEvent(); - }, 0); - - Event.observe(window, "load", fireContentLoadedEvent); - - } else { - document.addEventListener("DOMContentLoaded", - fireContentLoadedEvent, false); - } - - } else { - document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>"); - $("__onDOMContentLoaded").onreadystatechange = function() { - if (this.readyState == "complete") { - this.onreadystatechange = null; - fireContentLoadedEvent(); - } - }; - } -})(); -/*------------------------------- DEPRECATED -------------------------------*/ - -Hash.toQueryString = Object.toQueryString; - -var Toggle = { display: Element.toggle }; - -Element.Methods.childOf = Element.Methods.descendantOf; - -var Insertion = { - Before: function(element, content) { - return Element.insert(element, {before:content}); - }, - - Top: function(element, content) { - return Element.insert(element, {top:content}); - }, - - Bottom: function(element, content) { - return Element.insert(element, {bottom:content}); - }, - - After: function(element, content) { - return Element.insert(element, {after:content}); - } -}; - -var $continue = new Error('"throw $continue" is deprecated, use "return" instead'); - -// This should be moved to script.aculo.us; notice the deprecated methods -// further below, that map to the newer Element methods. -var Position = { - // set to true if needed, warning: firefox performance problems - // NOT neeeded for page scrolling, only if draggable contained in - // scrollable elements - includeScrollOffsets: false, - - // must be called before calling withinIncludingScrolloffset, every time the - // page is scrolled - prepare: function() { - this.deltaX = window.pageXOffset - || document.documentElement.scrollLeft - || document.body.scrollLeft - || 0; - this.deltaY = window.pageYOffset - || document.documentElement.scrollTop - || document.body.scrollTop - || 0; - }, - - // caches x/y coordinate pair to use with overlap - within: function(element, x, y) { - if (this.includeScrollOffsets) - return this.withinIncludingScrolloffsets(element, x, y); - this.xcomp = x; - this.ycomp = y; - this.offset = Element.cumulativeOffset(element); - - return (y >= this.offset[1] && - y < this.offset[1] + element.offsetHeight && - x >= this.offset[0] && - x < this.offset[0] + element.offsetWidth); - }, - - withinIncludingScrolloffsets: function(element, x, y) { - var offsetcache = Element.cumulativeScrollOffset(element); - - this.xcomp = x + offsetcache[0] - this.deltaX; - this.ycomp = y + offsetcache[1] - this.deltaY; - this.offset = Element.cumulativeOffset(element); - - return (this.ycomp >= this.offset[1] && - this.ycomp < this.offset[1] + element.offsetHeight && - this.xcomp >= this.offset[0] && - this.xcomp < this.offset[0] + element.offsetWidth); - }, - - // within must be called directly before - overlap: function(mode, element) { - if (!mode) return 0; - if (mode == 'vertical') - return ((this.offset[1] + element.offsetHeight) - this.ycomp) / - element.offsetHeight; - if (mode == 'horizontal') - return ((this.offset[0] + element.offsetWidth) - this.xcomp) / - element.offsetWidth; - }, - - // Deprecation layer -- use newer Element methods now (1.5.2). - - cumulativeOffset: Element.Methods.cumulativeOffset, - - positionedOffset: Element.Methods.positionedOffset, - - absolutize: function(element) { - Position.prepare(); - return Element.absolutize(element); - }, - - relativize: function(element) { - Position.prepare(); - return Element.relativize(element); - }, - - realOffset: Element.Methods.cumulativeScrollOffset, - - offsetParent: Element.Methods.getOffsetParent, - - page: Element.Methods.viewportOffset, - - clone: function(source, target, options) { - options = options || { }; - return Element.clonePosition(target, source, options); - } -}; - -/*--------------------------------------------------------------------------*/ - -if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){ - function iter(name) { - return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]"; - } - - instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ? - function(element, className) { - className = className.toString().strip(); - var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className); - return cond ? document._getElementsByXPath('.//*' + cond, element) : []; - } : function(element, className) { - className = className.toString().strip(); - var elements = [], classNames = (/\s/.test(className) ? $w(className) : null); - if (!classNames && !className) return elements; - - var nodes = $(element).getElementsByTagName('*'); - className = ' ' + className + ' '; - - for (var i = 0, child, cn; child = nodes[i]; i++) { - if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) || - (classNames && classNames.all(function(name) { - return !name.toString().blank() && cn.include(' ' + name + ' '); - })))) - elements.push(Element.extend(child)); - } - return elements; - }; - - return function(className, parentElement) { - return $(parentElement || document.body).getElementsByClassName(className); - }; -}(Element.Methods); - -/*--------------------------------------------------------------------------*/ - -Element.ClassNames = Class.create(); -Element.ClassNames.prototype = { - initialize: function(element) { - this.element = $(element); - }, - - _each: function(iterator) { - this.element.className.split(/\s+/).select(function(name) { - return name.length > 0; - })._each(iterator); - }, - - set: function(className) { - this.element.className = className; - }, - - add: function(classNameToAdd) { - if (this.include(classNameToAdd)) return; - this.set($A(this).concat(classNameToAdd).join(' ')); - }, - - remove: function(classNameToRemove) { - if (!this.include(classNameToRemove)) return; - this.set($A(this).without(classNameToRemove).join(' ')); - }, - - toString: function() { - return $A(this).join(' '); - } -}; - -Object.extend(Element.ClassNames.prototype, Enumerable); - -/*--------------------------------------------------------------------------*/ - -Element.addMethods(); \ No newline at end of file diff --git a/vendor/rails/railties/html/robots.txt b/vendor/rails/railties/html/robots.txt deleted file mode 100644 index 085187f..0000000 --- a/vendor/rails/railties/html/robots.txt +++ /dev/null @@ -1,5 +0,0 @@ -# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file -# -# To ban all spiders from the entire site uncomment the next two lines: -# User-Agent: * -# Disallow: / diff --git a/vendor/rails/railties/lib/code_statistics.rb b/vendor/rails/railties/lib/code_statistics.rb deleted file mode 100644 index 740d8a1..0000000 --- a/vendor/rails/railties/lib/code_statistics.rb +++ /dev/null @@ -1,107 +0,0 @@ -class CodeStatistics #:nodoc: - - TEST_TYPES = %w(Units Functionals Unit\ tests Functional\ tests Integration\ tests) - - def initialize(*pairs) - @pairs = pairs - @statistics = calculate_statistics - @total = calculate_total if pairs.length > 1 - end - - def to_s - print_header - @pairs.each { |pair| print_line(pair.first, @statistics[pair.first]) } - print_splitter - - if @total - print_line("Total", @total) - print_splitter - end - - print_code_test_stats - end - - private - def calculate_statistics - @pairs.inject({}) { |stats, pair| stats[pair.first] = calculate_directory_statistics(pair.last); stats } - end - - def calculate_directory_statistics(directory, pattern = /.*\.rb$/) - stats = { "lines" => 0, "codelines" => 0, "classes" => 0, "methods" => 0 } - - Dir.foreach(directory) do |file_name| - if File.stat(directory + "/" + file_name).directory? and (/^\./ !~ file_name) - newstats = calculate_directory_statistics(directory + "/" + file_name, pattern) - stats.each { |k, v| stats[k] += newstats[k] } - end - - next unless file_name =~ pattern - - f = File.open(directory + "/" + file_name) - - while line = f.gets - stats["lines"] += 1 - stats["classes"] += 1 if line =~ /class [A-Z]/ - stats["methods"] += 1 if line =~ /def [a-z]/ - stats["codelines"] += 1 unless line =~ /^\s*$/ || line =~ /^\s*#/ - end - end - - stats - end - - def calculate_total - total = { "lines" => 0, "codelines" => 0, "classes" => 0, "methods" => 0 } - @statistics.each_value { |pair| pair.each { |k, v| total[k] += v } } - total - end - - def calculate_code - code_loc = 0 - @statistics.each { |k, v| code_loc += v['codelines'] unless TEST_TYPES.include? k } - code_loc - end - - def calculate_tests - test_loc = 0 - @statistics.each { |k, v| test_loc += v['codelines'] if TEST_TYPES.include? k } - test_loc - end - - def print_header - print_splitter - puts "| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |" - print_splitter - end - - def print_splitter - puts "+----------------------+-------+-------+---------+---------+-----+-------+" - end - - def print_line(name, statistics) - m_over_c = (statistics["methods"] / statistics["classes"]) rescue m_over_c = 0 - loc_over_m = (statistics["codelines"] / statistics["methods"]) - 2 rescue loc_over_m = 0 - - start = if TEST_TYPES.include? name - "| #{name.ljust(20)} " - else - "| #{name.ljust(20)} " - end - - puts start + - "| #{statistics["lines"].to_s.rjust(5)} " + - "| #{statistics["codelines"].to_s.rjust(5)} " + - "| #{statistics["classes"].to_s.rjust(7)} " + - "| #{statistics["methods"].to_s.rjust(7)} " + - "| #{m_over_c.to_s.rjust(3)} " + - "| #{loc_over_m.to_s.rjust(5)} |" - end - - def print_code_test_stats - code = calculate_code - tests = calculate_tests - - puts " Code LOC: #{code} Test LOC: #{tests} Code to Test Ratio: 1:#{sprintf("%.1f", tests.to_f/code)}" - puts "" - end - end diff --git a/vendor/rails/railties/lib/commands.rb b/vendor/rails/railties/lib/commands.rb deleted file mode 100644 index 841e98a..0000000 --- a/vendor/rails/railties/lib/commands.rb +++ /dev/null @@ -1,17 +0,0 @@ -commands = Dir["#{File.dirname(__FILE__)}/commands/*.rb"].collect { |file_path| File.basename(file_path).split(".").first } - -if commands.include?(ARGV.first) - require "#{File.dirname(__FILE__)}/commands/#{ARGV.shift}" -else - puts <<-USAGE -The 'run' provides a unified access point for all the default Rails' commands. - -Usage: ./script/run <command> [OPTIONS] - -Examples: - ./script/run generate controller Admin - ./script/run process reaper - -USAGE - puts "Choose: #{commands.join(", ")}" -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/commands/about.rb b/vendor/rails/railties/lib/commands/about.rb deleted file mode 100644 index bc2cfcb..0000000 --- a/vendor/rails/railties/lib/commands/about.rb +++ /dev/null @@ -1,3 +0,0 @@ -require "#{RAILS_ROOT}/config/environment" -require 'rails/info' -puts Rails::Info diff --git a/vendor/rails/railties/lib/commands/console.rb b/vendor/rails/railties/lib/commands/console.rb deleted file mode 100644 index 63df834..0000000 --- a/vendor/rails/railties/lib/commands/console.rb +++ /dev/null @@ -1,45 +0,0 @@ -irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb' - -require 'optparse' - -options = { :sandbox => false, :irb => irb } -OptionParser.new do |opt| - opt.banner = "Usage: console [environment] [options]" - opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v } - opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |v| options[:irb] = v } - opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v } - opt.parse!(ARGV) -end - -libs = " -r irb/completion" -libs << %( -r "#{RAILS_ROOT}/config/environment") -libs << " -r console_app" -libs << " -r console_sandbox" if options[:sandbox] -libs << " -r console_with_helpers" - -if options[:debugger] - begin - require 'ruby-debug' - libs << " -r ruby-debug" - puts "=> Debugger enabled" - rescue Exception - puts "You need to install ruby-debug to run the console in debugging mode. With gems, use 'gem install ruby-debug'" - exit - end -end - -ENV['RAILS_ENV'] = case ARGV.first - when "p"; "production" - when "d"; "development" - when "t"; "test" - else - ARGV.first || ENV['RAILS_ENV'] || 'development' -end - -if options[:sandbox] - puts "Loading #{ENV['RAILS_ENV']} environment in sandbox (Rails #{Rails.version})" - puts "Any modifications you make will be rolled back on exit" -else - puts "Loading #{ENV['RAILS_ENV']} environment (Rails #{Rails.version})" -end -exec "#{options[:irb]} #{libs} --simple-prompt" diff --git a/vendor/rails/railties/lib/commands/dbconsole.rb b/vendor/rails/railties/lib/commands/dbconsole.rb deleted file mode 100644 index 8002264..0000000 --- a/vendor/rails/railties/lib/commands/dbconsole.rb +++ /dev/null @@ -1,83 +0,0 @@ -require 'erb' -require 'yaml' -require 'optparse' - -include_password = false -options = {} - -OptionParser.new do |opt| - opt.banner = "Usage: dbconsole [options] [environment]" - opt.on("-p", "--include-password", "Automatically provide the password from database.yml") do |v| - include_password = true - end - - opt.on("--mode [MODE]", ['html', 'list', 'line', 'column'], - "Automatically put the sqlite3 database in the specified mode (html, list, line, column).") do |mode| - options['mode'] = mode - end - - opt.on("-h", "--header") do |h| - options['header'] = h - end - - opt.parse!(ARGV) - abort opt.to_s unless (0..1).include?(ARGV.size) -end - -env = ARGV.first || ENV['RAILS_ENV'] || 'development' -unless config = YAML::load(ERB.new(IO.read(RAILS_ROOT + "/config/database.yml")).result)[env] - abort "No database is configured for the environment '#{env}'" -end - - -def find_cmd(*commands) - dirs_on_path = ENV['PATH'].to_s.split(File::PATH_SEPARATOR) - commands += commands.map{|cmd| "#{cmd}.exe"} if RUBY_PLATFORM =~ /win32/ - commands.detect do |cmd| - dirs_on_path.detect do |path| - File.executable? File.join(path, cmd) - end - end || abort("Couldn't find database client: #{commands.join(', ')}. Check your $PATH and try again.") -end - -case config["adapter"] -when "mysql" - args = { - 'host' => '--host', - 'port' => '--port', - 'socket' => '--socket', - 'username' => '--user', - 'encoding' => '--default-character-set' - }.map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }.compact - - if config['password'] && include_password - args << "--password=#{config['password']}" - elsif config['password'] && !config['password'].to_s.empty? - args << "-p" - end - - args << config['database'] - - exec(find_cmd('mysql', 'mysql5'), *args) - -when "postgresql" - ENV['PGUSER'] = config["username"] if config["username"] - ENV['PGHOST'] = config["host"] if config["host"] - ENV['PGPORT'] = config["port"].to_s if config["port"] - ENV['PGPASSWORD'] = config["password"].to_s if config["password"] && include_password - exec(find_cmd('psql'), config["database"]) - -when "sqlite" - exec(find_cmd('sqlite'), config["database"]) - -when "sqlite3" - args = [] - - args << "-#{options['mode']}" if options['mode'] - args << "-header" if options['header'] - args << config['database'] - - exec(find_cmd('sqlite3'), *args) -else - abort "Unknown command-line client for #{config['database']}. Submit a Rails patch to add support!" -end diff --git a/vendor/rails/railties/lib/commands/destroy.rb b/vendor/rails/railties/lib/commands/destroy.rb deleted file mode 100644 index f4b81d6..0000000 --- a/vendor/rails/railties/lib/commands/destroy.rb +++ /dev/null @@ -1,6 +0,0 @@ -require "#{RAILS_ROOT}/config/environment" -require 'rails_generator' -require 'rails_generator/scripts/destroy' - -ARGV.shift if ['--help', '-h'].include?(ARGV[0]) -Rails::Generator::Scripts::Destroy.new.run(ARGV) diff --git a/vendor/rails/railties/lib/commands/generate.rb b/vendor/rails/railties/lib/commands/generate.rb deleted file mode 100755 index 3d3db3d..0000000 --- a/vendor/rails/railties/lib/commands/generate.rb +++ /dev/null @@ -1,6 +0,0 @@ -require "#{RAILS_ROOT}/config/environment" -require 'rails_generator' -require 'rails_generator/scripts/generate' - -ARGV.shift if ['--help', '-h'].include?(ARGV[0]) -Rails::Generator::Scripts::Generate.new.run(ARGV) diff --git a/vendor/rails/railties/lib/commands/ncgi/listener b/vendor/rails/railties/lib/commands/ncgi/listener deleted file mode 100755 index 7079ef7..0000000 --- a/vendor/rails/railties/lib/commands/ncgi/listener +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env ruby - -require 'stringio' -require 'fileutils' -require 'fcgi_handler' - -def message(s) - $stderr.puts "listener: #{s}" if ENV && ENV["DEBUG_GATEWAY"] -end - -class RemoteCGI < CGI - attr_accessor :stdinput, :stdoutput, :env_table - def initialize(env_table, input = nil, output = nil) - self.env_table = env_table - self.stdinput = input || StringIO.new - self.stdoutput = output || StringIO.new - super() - end - - def out(stream) # Ignore the requested output stream - super(stdoutput) - end -end - -class Listener - include DRbUndumped - - def initialize(timeout, socket_path) - @socket = File.expand_path(socket_path) - @mutex = Mutex.new - @active = false - @timeout = timeout - - @handler = RailsFCGIHandler.new - @handler.extend DRbUndumped - - message 'opening socket' - DRb.start_service("drbunix:#{@socket}", self) - - message 'entering process loop' - @handler.process! self - end - - def each_cgi(&cgi_block) - @cgi_block = cgi_block - message 'entering idle loop' - loop do - sleep @timeout rescue nil - die! unless @active - @active = false - end - end - - def process(env, input) - message 'received request' - @mutex.synchronize do - @active = true - - message 'creating input stream' - input_stream = StringIO.new(input) - message 'building CGI instance' - cgi = RemoteCGI.new(eval(env), input_stream) - - message 'yielding to fcgi handler' - @cgi_block.call cgi - message 'yield finished -- sending output' - - cgi.stdoutput.seek(0) - output = cgi.stdoutput.read - - return output - end - end - - def die! - message 'shutting down' - DRb.stop_service - FileUtils.rm_f @socket - Kernel.exit 0 - end -end - -socket_path = ARGV.shift -timeout = (ARGV.shift || 90).to_i - -Listener.new(timeout, socket_path) diff --git a/vendor/rails/railties/lib/commands/ncgi/tracker b/vendor/rails/railties/lib/commands/ncgi/tracker deleted file mode 100755 index 4ca12d7..0000000 --- a/vendor/rails/railties/lib/commands/ncgi/tracker +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env ruby - -require 'drb' -require 'thread' - -def message(s) - $stderr.puts "tracker: #{s}" if ENV && ENV["DEBUG_GATEWAY"] -end - -class Tracker - include DRbUndumped - - def initialize(instances, socket_path) - @instances = instances - @socket = File.expand_path(socket_path) - @active = false - - @listeners = [] - @instances.times { @listeners << Mutex.new } - - message "using #{@listeners.length} listeners" - message "opening socket at #{@socket}" - - @service = DRb.start_service("drbunix://#{@socket}", self) - end - - def with_listener - message "listener requested" - - mutex = has_lock = index = nil - 3.times do - @listeners.each_with_index do |mutex, index| - has_lock = mutex.try_lock - break if has_lock - end - break if has_lock - sleep 0.05 - end - - if has_lock - message "obtained listener #{index}" - @active = true - begin yield index - ensure - mutex.unlock - message "released listener #{index}" - end - else - message "dropping request because no listeners are available!" - end - end - - def background(check_interval = nil) - if check_interval - loop do - sleep check_interval - message "Idle for #{check_interval}, shutting down" unless @active - @active = false - Kernel.exit 0 - end - else DRb.thread.join - end - end -end - -socket_path = ARGV.shift -instances = ARGV.shift.to_i -t = Tracker.new(instances, socket_path) -t.background(ARGV.first ? ARGV.shift.to_i : 90) diff --git a/vendor/rails/railties/lib/commands/performance/benchmarker.rb b/vendor/rails/railties/lib/commands/performance/benchmarker.rb deleted file mode 100644 index e8804fe..0000000 --- a/vendor/rails/railties/lib/commands/performance/benchmarker.rb +++ /dev/null @@ -1,24 +0,0 @@ -if ARGV.empty? - puts "Usage: ./script/performance/benchmarker [times] 'Person.expensive_way' 'Person.another_expensive_way' ..." - exit 1 -end - -begin - N = Integer(ARGV.first) - ARGV.shift -rescue ArgumentError - N = 1 -end - -require RAILS_ROOT + '/config/environment' -require 'benchmark' -include Benchmark - -# Don't include compilation in the benchmark -ARGV.each { |expression| eval(expression) } - -bm(6) do |x| - ARGV.each_with_index do |expression, idx| - x.report("##{idx + 1}") { N.times { eval(expression) } } - end -end diff --git a/vendor/rails/railties/lib/commands/performance/profiler.rb b/vendor/rails/railties/lib/commands/performance/profiler.rb deleted file mode 100644 index fd111ba..0000000 --- a/vendor/rails/railties/lib/commands/performance/profiler.rb +++ /dev/null @@ -1,50 +0,0 @@ -if ARGV.empty? - $stderr.puts "Usage: ./script/performance/profiler 'Person.expensive_method(10)' [times] [flat|graph|graph_html]" - exit(1) -end - -# Keep the expensive require out of the profile. -$stderr.puts 'Loading Rails...' -require RAILS_ROOT + '/config/environment' - -# Define a method to profile. -if ARGV[1] and ARGV[1].to_i > 1 - eval "def profile_me() #{ARGV[1]}.times { #{ARGV[0]} } end" -else - eval "def profile_me() #{ARGV[0]} end" -end - -# Use the ruby-prof extension if available. Fall back to stdlib profiler. -begin - begin - require "ruby-prof" - $stderr.puts 'Using the ruby-prof extension.' - RubyProf.measure_mode = RubyProf::WALL_TIME - RubyProf.start - profile_me - results = RubyProf.stop - if ARGV[2] - printer_class = RubyProf.const_get((ARGV[2] + "_printer").classify) - else - printer_class = RubyProf::FlatPrinter - end - printer = printer_class.new(results) - printer.print($stderr, 0) - rescue LoadError - require "prof" - $stderr.puts 'Using the old ruby-prof extension.' - Prof.clock_mode = Prof::GETTIMEOFDAY - Prof.start - profile_me - results = Prof.stop - require 'rubyprof_ext' - Prof.print_profile(results, $stderr) - end -rescue LoadError - require 'profiler' - $stderr.puts 'Using the standard Ruby profiler.' - Profiler__.start_profile - profile_me - Profiler__.stop_profile - Profiler__.print_profile($stderr) -end diff --git a/vendor/rails/railties/lib/commands/plugin.rb b/vendor/rails/railties/lib/commands/plugin.rb deleted file mode 100644 index 8589b16..0000000 --- a/vendor/rails/railties/lib/commands/plugin.rb +++ /dev/null @@ -1,968 +0,0 @@ -# Rails Plugin Manager. -# -# Listing available plugins: -# -# $ ./script/plugin list -# continuous_builder http://dev.rubyonrails.com/svn/rails/plugins/continuous_builder -# asset_timestamping http://svn.aviditybytes.com/rails/plugins/asset_timestamping -# enumerations_mixin http://svn.protocool.com/rails/plugins/enumerations_mixin/trunk -# calculations http://techno-weenie.net/svn/projects/calculations/ -# ... -# -# Installing plugins: -# -# $ ./script/plugin install continuous_builder asset_timestamping -# -# Finding Repositories: -# -# $ ./script/plugin discover -# -# Adding Repositories: -# -# $ ./script/plugin source http://svn.protocool.com/rails/plugins/ -# -# How it works: -# -# * Maintains a list of subversion repositories that are assumed to have -# a plugin directory structure. Manage them with the (source, unsource, -# and sources commands) -# -# * The discover command scrapes the following page for things that -# look like subversion repositories with plugins: -# http://wiki.rubyonrails.org/rails/pages/Plugins -# -# * Unless you specify that you want to use svn, script/plugin uses plain old -# HTTP for downloads. The following bullets are true if you specify -# that you want to use svn. -# -# * If `vendor/plugins` is under subversion control, the script will -# modify the svn:externals property and perform an update. You can -# use normal subversion commands to keep the plugins up to date. -# -# * Or, if `vendor/plugins` is not under subversion control, the -# plugin is pulled via `svn checkout` or `svn export` but looks -# exactly the same. -# -# Specifying revisions: -# -# * Subversion revision is a single integer. -# -# * Git revision format: -# - full - 'refs/tags/1.8.0' or 'refs/heads/experimental' -# - short: 'experimental' (equivalent to 'refs/heads/experimental') -# 'tag 1.8.0' (equivalent to 'refs/tags/1.8.0') -# -# -# This is Free Software, copyright 2005 by Ryan Tomayko (rtomayko@gmail.com) -# and is licensed MIT: (http://www.opensource.org/licenses/mit-license.php) - -$verbose = false - - -require 'open-uri' -require 'fileutils' -require 'tempfile' - -include FileUtils - -class RailsEnvironment - attr_reader :root - - def initialize(dir) - @root = dir - end - - def self.find(dir=nil) - dir ||= pwd - while dir.length > 1 - return new(dir) if File.exist?(File.join(dir, 'config', 'environment.rb')) - dir = File.dirname(dir) - end - end - - def self.default - @default ||= find - end - - def self.default=(rails_env) - @default = rails_env - end - - def install(name_uri_or_plugin) - if name_uri_or_plugin.is_a? String - if name_uri_or_plugin =~ /:\/\// - plugin = Plugin.new(name_uri_or_plugin) - else - plugin = Plugins[name_uri_or_plugin] - end - else - plugin = name_uri_or_plugin - end - unless plugin.nil? - plugin.install - else - puts "Plugin not found: #{name_uri_or_plugin}" - end - end - - def use_svn? - require 'active_support/core_ext/kernel' - silence_stderr {`svn --version` rescue nil} - !$?.nil? && $?.success? - end - - def use_externals? - use_svn? && File.directory?("#{root}/vendor/plugins/.svn") - end - - def use_checkout? - # this is a bit of a guess. we assume that if the rails environment - # is under subversion then they probably want the plugin checked out - # instead of exported. This can be overridden on the command line - File.directory?("#{root}/.svn") - end - - def best_install_method - return :http unless use_svn? - case - when use_externals? then :externals - when use_checkout? then :checkout - else :export - end - end - - def externals - return [] unless use_externals? - ext = `svn propget svn:externals "#{root}/vendor/plugins"` - lines = ext.respond_to?(:lines) ? ext.lines : ext - lines.reject{ |line| line.strip == '' }.map do |line| - line.strip.split(/\s+/, 2) - end - end - - def externals=(items) - unless items.is_a? String - items = items.map{|name,uri| "#{name.ljust(29)} #{uri.chomp('/')}"}.join("\n") - end - Tempfile.open("svn-set-prop") do |file| - file.write(items) - file.flush - system("svn propset -q svn:externals -F \"#{file.path}\" \"#{root}/vendor/plugins\"") - end - end - -end - -class Plugin - attr_reader :name, :uri - - def initialize(uri, name=nil) - @uri = uri - guess_name(uri) - end - - def self.find(name) - name =~ /\// ? new(name) : Repositories.instance.find_plugin(name) - end - - def to_s - "#{@name.ljust(30)}#{@uri}" - end - - def svn_url? - @uri =~ /svn(?:\+ssh)?:\/\/*/ - end - - def git_url? - @uri =~ /^git:\/\// || @uri =~ /\.git$/ - end - - def installed? - File.directory?("#{rails_env.root}/vendor/plugins/#{name}") \ - or rails_env.externals.detect{ |name, repo| self.uri == repo } - end - - def install(method=nil, options = {}) - method ||= rails_env.best_install_method? - if :http == method - method = :export if svn_url? - method = :git if git_url? - end - - uninstall if installed? and options[:force] - - unless installed? - send("install_using_#{method}", options) - run_install_hook - else - puts "already installed: #{name} (#{uri}). pass --force to reinstall" - end - end - - def uninstall - path = "#{rails_env.root}/vendor/plugins/#{name}" - if File.directory?(path) - puts "Removing 'vendor/plugins/#{name}'" if $verbose - run_uninstall_hook - rm_r path - else - puts "Plugin doesn't exist: #{path}" - end - # clean up svn:externals - externals = rails_env.externals - externals.reject!{|n,u| name == n or name == u} - rails_env.externals = externals - end - - def info - tmp = "#{rails_env.root}/_tmp_about.yml" - if svn_url? - cmd = "svn export #{@uri} \"#{rails_env.root}/#{tmp}\"" - puts cmd if $verbose - system(cmd) - end - open(svn_url? ? tmp : File.join(@uri, 'about.yml')) do |stream| - stream.read - end rescue "No about.yml found in #{uri}" - ensure - FileUtils.rm_rf tmp if svn_url? - end - - private - - def run_install_hook - install_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/install.rb" - load install_hook_file if File.exist? install_hook_file - end - - def run_uninstall_hook - uninstall_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/uninstall.rb" - load uninstall_hook_file if File.exist? uninstall_hook_file - end - - def install_using_export(options = {}) - svn_command :export, options - end - - def install_using_checkout(options = {}) - svn_command :checkout, options - end - - def install_using_externals(options = {}) - externals = rails_env.externals - externals.push([@name, uri]) - rails_env.externals = externals - install_using_checkout(options) - end - - def install_using_http(options = {}) - root = rails_env.root - mkdir_p "#{root}/vendor/plugins/#{@name}" - Dir.chdir "#{root}/vendor/plugins/#{@name}" do - puts "fetching from '#{uri}'" if $verbose - fetcher = RecursiveHTTPFetcher.new(uri, -1) - fetcher.quiet = true if options[:quiet] - fetcher.fetch - end - end - - def install_using_git(options = {}) - root = rails_env.root - install_path = mkdir_p "#{root}/vendor/plugins/#{name}" - Dir.chdir install_path do - init_cmd = "git init" - init_cmd += " -q" if options[:quiet] and not $verbose - puts init_cmd if $verbose - system(init_cmd) - base_cmd = "git pull --depth 1 #{uri}" - base_cmd += " -q" if options[:quiet] and not $verbose - base_cmd += " #{options[:revision]}" if options[:revision] - puts base_cmd if $verbose - if system(base_cmd) - puts "removing: .git .gitignore" if $verbose - rm_rf %w(.git .gitignore) - else - rm_rf install_path - end - end - end - - def svn_command(cmd, options = {}) - root = rails_env.root - mkdir_p "#{root}/vendor/plugins" - base_cmd = "svn #{cmd} #{uri} \"#{root}/vendor/plugins/#{name}\"" - base_cmd += ' -q' if options[:quiet] and not $verbose - base_cmd += " -r #{options[:revision]}" if options[:revision] - puts base_cmd if $verbose - system(base_cmd) - end - - def guess_name(url) - @name = File.basename(url) - if @name == 'trunk' || @name.empty? - @name = File.basename(File.dirname(url)) - end - @name.gsub!(/\.git$/, '') if @name =~ /\.git$/ - end - - def rails_env - @rails_env || RailsEnvironment.default - end -end - -class Repositories - include Enumerable - - def initialize(cache_file = File.join(find_home, ".rails-plugin-sources")) - @cache_file = File.expand_path(cache_file) - load! - end - - def each(&block) - @repositories.each(&block) - end - - def add(uri) - unless find{|repo| repo.uri == uri } - @repositories.push(Repository.new(uri)).last - end - end - - def remove(uri) - @repositories.reject!{|repo| repo.uri == uri} - end - - def exist?(uri) - @repositories.detect{|repo| repo.uri == uri } - end - - def all - @repositories - end - - def find_plugin(name) - @repositories.each do |repo| - repo.each do |plugin| - return plugin if plugin.name == name - end - end - return nil - end - - def load! - contents = File.exist?(@cache_file) ? File.read(@cache_file) : defaults - contents = defaults if contents.empty? - @repositories = contents.split(/\n/).reject do |line| - line =~ /^\s*#/ or line =~ /^\s*$/ - end.map { |source| Repository.new(source.strip) } - end - - def save - File.open(@cache_file, 'w') do |f| - each do |repo| - f.write(repo.uri) - f.write("\n") - end - end - end - - def defaults - <<-DEFAULTS - http://dev.rubyonrails.com/svn/rails/plugins/ - DEFAULTS - end - - def find_home - ['HOME', 'USERPROFILE'].each do |homekey| - return ENV[homekey] if ENV[homekey] - end - if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] - return "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}" - end - begin - File.expand_path("~") - rescue StandardError => ex - if File::ALT_SEPARATOR - "C:/" - else - "/" - end - end - end - - def self.instance - @instance ||= Repositories.new - end - - def self.each(&block) - self.instance.each(&block) - end -end - -class Repository - include Enumerable - attr_reader :uri, :plugins - - def initialize(uri) - @uri = uri.chomp('/') << "/" - @plugins = nil - end - - def plugins - unless @plugins - if $verbose - puts "Discovering plugins in #{@uri}" - puts index - end - - @plugins = index.reject{ |line| line !~ /\/$/ } - @plugins.map! { |name| Plugin.new(File.join(@uri, name), name) } - end - - @plugins - end - - def each(&block) - plugins.each(&block) - end - - private - def index - @index ||= RecursiveHTTPFetcher.new(@uri).ls - end -end - - -# load default environment and parse arguments -require 'optparse' -module Commands - - class Plugin - attr_reader :environment, :script_name, :sources - def initialize - @environment = RailsEnvironment.default - @rails_root = RailsEnvironment.default.root - @script_name = File.basename($0) - @sources = [] - end - - def environment=(value) - @environment = value - RailsEnvironment.default = value - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@script_name} [OPTIONS] command" - o.define_head "Rails plugin manager." - - o.separator "" - o.separator "GENERAL OPTIONS" - - o.on("-r", "--root=DIR", String, - "Set an explicit rails app directory.", - "Default: #{@rails_root}") { |rails_root| @rails_root = rails_root; self.environment = RailsEnvironment.new(@rails_root) } - o.on("-s", "--source=URL1,URL2", Array, - "Use the specified plugin repositories instead of the defaults.") { |sources| @sources = sources} - - o.on("-v", "--verbose", "Turn on verbose output.") { |verbose| $verbose = verbose } - o.on("-h", "--help", "Show this help message.") { puts o; exit } - - o.separator "" - o.separator "COMMANDS" - - o.separator " discover Discover plugin repositories." - o.separator " list List available plugins." - o.separator " install Install plugin(s) from known repositories or URLs." - o.separator " update Update installed plugins." - o.separator " remove Uninstall plugins." - o.separator " source Add a plugin source repository." - o.separator " unsource Remove a plugin repository." - o.separator " sources List currently configured plugin repositories." - - o.separator "" - o.separator "EXAMPLES" - o.separator " Install a plugin:" - o.separator " #{@script_name} install continuous_builder\n" - o.separator " Install a plugin from a subversion URL:" - o.separator " #{@script_name} install http://dev.rubyonrails.com/svn/rails/plugins/continuous_builder\n" - o.separator " Install a plugin from a git URL:" - o.separator " #{@script_name} install git://github.com/SomeGuy/my_awesome_plugin.git\n" - o.separator " Install a plugin and add a svn:externals entry to vendor/plugins" - o.separator " #{@script_name} install -x continuous_builder\n" - o.separator " List all available plugins:" - o.separator " #{@script_name} list\n" - o.separator " List plugins in the specified repository:" - o.separator " #{@script_name} list --source=http://dev.rubyonrails.com/svn/rails/plugins/\n" - o.separator " Discover and prompt to add new repositories:" - o.separator " #{@script_name} discover\n" - o.separator " Discover new repositories but just list them, don't add anything:" - o.separator " #{@script_name} discover -l\n" - o.separator " Add a new repository to the source list:" - o.separator " #{@script_name} source http://dev.rubyonrails.com/svn/rails/plugins/\n" - o.separator " Remove a repository from the source list:" - o.separator " #{@script_name} unsource http://dev.rubyonrails.com/svn/rails/plugins/\n" - o.separator " Show currently configured repositories:" - o.separator " #{@script_name} sources\n" - end - end - - def parse!(args=ARGV) - general, sub = split_args(args) - options.parse!(general) - - command = general.shift - if command =~ /^(list|discover|install|source|unsource|sources|remove|update|info)$/ - command = Commands.const_get(command.capitalize).new(self) - command.parse!(sub) - else - puts "Unknown command: #{command}" - puts options - exit 1 - end - end - - def split_args(args) - left = [] - left << args.shift while args[0] and args[0] =~ /^-/ - left << args.shift if args[0] - return [left, args] - end - - def self.parse!(args=ARGV) - Plugin.new.parse!(args) - end - end - - - class List - def initialize(base_command) - @base_command = base_command - @sources = [] - @local = false - @remote = true - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} list [OPTIONS] [PATTERN]" - o.define_head "List available plugins." - o.separator "" - o.separator "Options:" - o.separator "" - o.on( "-s", "--source=URL1,URL2", Array, - "Use the specified plugin repositories.") {|sources| @sources = sources} - o.on( "--local", - "List locally installed plugins.") {|local| @local, @remote = local, false} - o.on( "--remote", - "List remotely available plugins. This is the default behavior", - "unless --local is provided.") {|remote| @remote = remote} - end - end - - def parse!(args) - options.order!(args) - unless @sources.empty? - @sources.map!{ |uri| Repository.new(uri) } - else - @sources = Repositories.instance.all - end - if @remote - @sources.map{|r| r.plugins}.flatten.each do |plugin| - if @local or !plugin.installed? - puts plugin.to_s - end - end - else - cd "#{@base_command.environment.root}/vendor/plugins" - Dir["*"].select{|p| File.directory?(p)}.each do |name| - puts name - end - end - end - end - - - class Sources - def initialize(base_command) - @base_command = base_command - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} sources [OPTIONS] [PATTERN]" - o.define_head "List configured plugin repositories." - o.separator "" - o.separator "Options:" - o.separator "" - o.on( "-c", "--check", - "Report status of repository.") { |sources| @sources = sources} - end - end - - def parse!(args) - options.parse!(args) - Repositories.each do |repo| - puts repo.uri - end - end - end - - - class Source - def initialize(base_command) - @base_command = base_command - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} source REPOSITORY [REPOSITORY [REPOSITORY]...]" - o.define_head "Add new repositories to the default search list." - end - end - - def parse!(args) - options.parse!(args) - count = 0 - args.each do |uri| - if Repositories.instance.add(uri) - puts "added: #{uri.ljust(50)}" if $verbose - count += 1 - else - puts "failed: #{uri.ljust(50)}" - end - end - Repositories.instance.save - puts "Added #{count} repositories." - end - end - - - class Unsource - def initialize(base_command) - @base_command = base_command - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} unsource URI [URI [URI]...]" - o.define_head "Remove repositories from the default search list." - o.separator "" - o.on_tail("-h", "--help", "Show this help message.") { puts o; exit } - end - end - - def parse!(args) - options.parse!(args) - count = 0 - args.each do |uri| - if Repositories.instance.remove(uri) - count += 1 - puts "removed: #{uri.ljust(50)}" - else - puts "failed: #{uri.ljust(50)}" - end - end - Repositories.instance.save - puts "Removed #{count} repositories." - end - end - - - class Discover - def initialize(base_command) - @base_command = base_command - @list = false - @prompt = true - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} discover URI [URI [URI]...]" - o.define_head "Discover repositories referenced on a page." - o.separator "" - o.separator "Options:" - o.separator "" - o.on( "-l", "--list", - "List but don't prompt or add discovered repositories.") { |list| @list, @prompt = list, !@list } - o.on( "-n", "--no-prompt", - "Add all new repositories without prompting.") { |v| @prompt = !v } - end - end - - def parse!(args) - options.parse!(args) - args = ['http://wiki.rubyonrails.org/rails/pages/Plugins'] if args.empty? - args.each do |uri| - scrape(uri) do |repo_uri| - catch(:next_uri) do - if @prompt - begin - $stdout.print "Add #{repo_uri}? [Y/n] " - throw :next_uri if $stdin.gets !~ /^y?$/i - rescue Interrupt - $stdout.puts - exit 1 - end - elsif @list - puts repo_uri - throw :next_uri - end - Repositories.instance.add(repo_uri) - puts "discovered: #{repo_uri}" if $verbose or !@prompt - end - end - end - Repositories.instance.save - end - - def scrape(uri) - require 'open-uri' - puts "Scraping #{uri}" if $verbose - dupes = [] - content = open(uri).each do |line| - begin - if line =~ /<a[^>]*href=['"]([^'"]*)['"]/ || line =~ /(svn:\/\/[^<|\n]*)/ - uri = $1 - if uri =~ /^\w+:\/\// && uri =~ /\/plugins\// && uri !~ /\/browser\// && uri !~ /^http:\/\/wiki\.rubyonrails/ && uri !~ /http:\/\/instiki/ - uri = extract_repository_uri(uri) - yield uri unless dupes.include?(uri) || Repositories.instance.exist?(uri) - dupes << uri - end - end - rescue - puts "Problems scraping '#{uri}': #{$!.to_s}" - end - end - end - - def extract_repository_uri(uri) - uri.match(/(svn|https?):.*\/plugins\//i)[0] - end - end - - class Install - def initialize(base_command) - @base_command = base_command - @method = :http - @options = { :quiet => false, :revision => nil, :force => false } - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} install PLUGIN [PLUGIN [PLUGIN] ...]" - o.define_head "Install one or more plugins." - o.separator "" - o.separator "Options:" - o.on( "-x", "--externals", - "Use svn:externals to grab the plugin.", - "Enables plugin updates and plugin versioning.") { |v| @method = :externals } - o.on( "-o", "--checkout", - "Use svn checkout to grab the plugin.", - "Enables updating but does not add a svn:externals entry.") { |v| @method = :checkout } - o.on( "-e", "--export", - "Use svn export to grab the plugin.", - "Exports the plugin, allowing you to check it into your local repository. Does not enable updates, or add an svn:externals entry.") { |v| @method = :export } - o.on( "-q", "--quiet", - "Suppresses the output from installation.", - "Ignored if -v is passed (./script/plugin -v install ...)") { |v| @options[:quiet] = true } - o.on( "-r REVISION", "--revision REVISION", - "Checks out the given revision from subversion or git.", - "Ignored if subversion/git is not used.") { |v| @options[:revision] = v } - o.on( "-f", "--force", - "Reinstalls a plugin if it's already installed.") { |v| @options[:force] = true } - o.separator "" - o.separator "You can specify plugin names as given in 'plugin list' output or absolute URLs to " - o.separator "a plugin repository." - end - end - - def determine_install_method - best = @base_command.environment.best_install_method - @method = :http if best == :http and @method == :export - case - when (best == :http and @method != :http) - msg = "Cannot install using subversion because `svn' cannot be found in your PATH" - when (best == :export and (@method != :export and @method != :http)) - msg = "Cannot install using #{@method} because this project is not under subversion." - when (best != :externals and @method == :externals) - msg = "Cannot install using externals because vendor/plugins is not under subversion." - end - if msg - puts msg - exit 1 - end - @method - end - - def parse!(args) - options.parse!(args) - environment = @base_command.environment - install_method = determine_install_method - puts "Plugins will be installed using #{install_method}" if $verbose - args.each do |name| - ::Plugin.find(name).install(install_method, @options) - end - rescue StandardError => e - puts "Plugin not found: #{args.inspect}" - puts e.inspect if $verbose - exit 1 - end - end - - class Update - def initialize(base_command) - @base_command = base_command - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} update [name [name]...]" - o.on( "-r REVISION", "--revision REVISION", - "Checks out the given revision from subversion.", - "Ignored if subversion is not used.") { |v| @revision = v } - o.define_head "Update plugins." - end - end - - def parse!(args) - options.parse!(args) - root = @base_command.environment.root - cd root - args = Dir["vendor/plugins/*"].map do |f| - File.directory?("#{f}/.svn") ? File.basename(f) : nil - end.compact if args.empty? - cd "vendor/plugins" - args.each do |name| - if File.directory?(name) - puts "Updating plugin: #{name}" - system("svn #{$verbose ? '' : '-q'} up \"#{name}\" #{@revision ? "-r #{@revision}" : ''}") - else - puts "Plugin doesn't exist: #{name}" - end - end - end - end - - class Remove - def initialize(base_command) - @base_command = base_command - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} remove name [name]..." - o.define_head "Remove plugins." - end - end - - def parse!(args) - options.parse!(args) - root = @base_command.environment.root - args.each do |name| - ::Plugin.new(name).uninstall - end - end - end - - class Info - def initialize(base_command) - @base_command = base_command - end - - def options - OptionParser.new do |o| - o.set_summary_indent(' ') - o.banner = "Usage: #{@base_command.script_name} info name [name]..." - o.define_head "Shows plugin info at {url}/about.yml." - end - end - - def parse!(args) - options.parse!(args) - args.each do |name| - puts ::Plugin.find(name).info - puts - end - end - end -end - -class RecursiveHTTPFetcher - attr_accessor :quiet - def initialize(urls_to_fetch, level = 1, cwd = ".") - @level = level - @cwd = cwd - @urls_to_fetch = RUBY_VERSION >= '1.9' ? urls_to_fetch.lines : urls_to_fetch.to_a - @quiet = false - end - - def ls - @urls_to_fetch.collect do |url| - if url =~ /^svn(\+ssh)?:\/\/.*/ - `svn ls #{url}`.split("\n").map {|entry| "/#{entry}"} rescue nil - else - open(url) do |stream| - links("", stream.read) - end rescue nil - end - end.flatten - end - - def push_d(dir) - @cwd = File.join(@cwd, dir) - FileUtils.mkdir_p(@cwd) - end - - def pop_d - @cwd = File.dirname(@cwd) - end - - def links(base_url, contents) - links = [] - contents.scan(/href\s*=\s*\"*[^\">]*/i) do |link| - link = link.sub(/href="/i, "") - next if link =~ /svnindex.xsl$/ - next if link =~ /^(\w*:|)\/\// || link =~ /^\./ - links << File.join(base_url, link) - end - links - end - - def download(link) - puts "+ #{File.join(@cwd, File.basename(link))}" unless @quiet - open(link) do |stream| - File.open(File.join(@cwd, File.basename(link)), "wb") do |file| - file.write(stream.read) - end - end - end - - def fetch(links = @urls_to_fetch) - links.each do |l| - (l =~ /\/$/ || links == @urls_to_fetch) ? fetch_dir(l) : download(l) - end - end - - def fetch_dir(url) - @level += 1 - push_d(File.basename(url)) if @level > 0 - open(url) do |stream| - contents = stream.read - fetch(links(url, contents)) - end - pop_d if @level > 0 - @level -= 1 - end -end - -Commands::Plugin.parse! diff --git a/vendor/rails/railties/lib/commands/runner.rb b/vendor/rails/railties/lib/commands/runner.rb deleted file mode 100644 index 5101283..0000000 --- a/vendor/rails/railties/lib/commands/runner.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'optparse' - -options = { :environment => (ENV['RAILS_ENV'] || "development").dup } -code_or_file = nil - -ARGV.clone.options do |opts| - script_name = File.basename($0) - opts.banner = "Usage: #{$0} [options] ('Some.ruby(code)' or a filename)" - - opts.separator "" - - opts.on("-e", "--environment=name", String, - "Specifies the environment for the runner to operate under (test/development/production).", - "Default: development") { |v| options[:environment] = v } - - opts.separator "" - - opts.on("-h", "--help", - "Show this help message.") { $stderr.puts opts; exit } - - if RUBY_PLATFORM !~ /mswin/ - opts.separator "" - opts.separator "You can also use runner as a shebang line for your scripts like this:" - opts.separator "-------------------------------------------------------------" - opts.separator "#!/usr/bin/env #{File.expand_path($0)}" - opts.separator "" - opts.separator "Product.find(:all).each { |p| p.price *= 2 ; p.save! }" - opts.separator "-------------------------------------------------------------" - end - - opts.order! { |o| code_or_file ||= o } rescue retry -end - -ARGV.delete(code_or_file) - -ENV["RAILS_ENV"] = options[:environment] -RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV) - -require RAILS_ROOT + '/config/environment' - -begin - if code_or_file.nil? - $stderr.puts "Run '#{$0} -h' for help." - exit 1 - elsif File.exist?(code_or_file) - eval(File.read(code_or_file), nil, code_or_file) - else - eval(code_or_file) - end -ensure - if defined? Rails - Rails.logger.flush if Rails.logger.respond_to?(:flush) - end -end diff --git a/vendor/rails/railties/lib/commands/server.rb b/vendor/rails/railties/lib/commands/server.rb deleted file mode 100644 index ebe34a4..0000000 --- a/vendor/rails/railties/lib/commands/server.rb +++ /dev/null @@ -1,114 +0,0 @@ -require 'active_support' -require 'action_controller' - -require 'fileutils' -require 'optparse' - -# TODO: Push Thin adapter upstream so we don't need worry about requiring it -begin - require_library_or_gem 'thin' -rescue Exception - # Thin not available -end - -options = { - :Port => 3000, - :Host => "0.0.0.0", - :environment => (ENV['RAILS_ENV'] || "development").dup, - :config => RAILS_ROOT + "/config.ru", - :detach => false, - :debugger => false, - :path => nil -} - -ARGV.clone.options do |opts| - opts.on("-p", "--port=port", Integer, - "Runs Rails on the specified port.", "Default: 3000") { |v| options[:Port] = v } - opts.on("-b", "--binding=ip", String, - "Binds Rails to the specified ip.", "Default: 0.0.0.0") { |v| options[:Host] = v } - opts.on("-c", "--config=file", String, - "Use custom rackup configuration file") { |v| options[:config] = v } - opts.on("-d", "--daemon", "Make server run as a Daemon.") { options[:detach] = true } - opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { options[:debugger] = true } - opts.on("-e", "--environment=name", String, - "Specifies the environment to run this server under (test/development/production).", - "Default: development") { |v| options[:environment] = v } - opts.on("-P", "--path=/path", String, "Runs Rails app mounted at a specific path.", "Default: /") { |v| options[:path] = v } - - opts.separator "" - - opts.on("-h", "--help", "Show this help message.") { puts opts; exit } - - opts.parse! -end - -server = Rack::Handler.get(ARGV.first) rescue nil -unless server - begin - server = Rack::Handler::Mongrel - rescue LoadError => e - server = Rack::Handler::WEBrick - end -end - -puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}" -puts "=> Rails #{Rails.version} application starting on http://#{options[:Host]}:#{options[:Port]}#{options[:path]}" - -%w(cache pids sessions sockets).each do |dir_to_make| - FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', dir_to_make)) -end - -if options[:detach] - Process.daemon - pid = "#{RAILS_ROOT}/tmp/pids/server.pid" - File.open(pid, 'w'){ |f| f.write(Process.pid) } - at_exit { File.delete(pid) if File.exist?(pid) } -end - -ENV["RAILS_ENV"] = options[:environment] -RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV) - -if File.exist?(options[:config]) - config = options[:config] - if config =~ /\.ru$/ - cfgfile = File.read(config) - if cfgfile[/^#\\(.*)/] - opts.parse!($1.split(/\s+/)) - end - inner_app = eval("Rack::Builder.new {( " + cfgfile + "\n )}.to_app", nil, config) - else - require config - inner_app = Object.const_get(File.basename(config, '.rb').capitalize) - end -else - require RAILS_ROOT + "/config/environment" - inner_app = ActionController::Dispatcher.new -end - -if options[:path].nil? - map_path = "/" -else - ActionController::Base.relative_url_root = options[:path] - map_path = options[:path] -end - -app = Rack::Builder.new { - use Rails::Rack::LogTailer unless options[:detach] - use Rails::Rack::Debugger if options[:debugger] - map map_path do - use Rails::Rack::Static - run inner_app - end -}.to_app - -puts "=> Call with -d to detach" - -trap(:INT) { exit } - -puts "=> Ctrl-C to shutdown server" - -begin - server.run(app, options.merge(:AccessLog => [])) -ensure - puts 'Exiting' -end diff --git a/vendor/rails/railties/lib/commands/update.rb b/vendor/rails/railties/lib/commands/update.rb deleted file mode 100644 index 83ef833..0000000 --- a/vendor/rails/railties/lib/commands/update.rb +++ /dev/null @@ -1,4 +0,0 @@ -require "#{RAILS_ROOT}/config/environment" -require 'rails_generator' -require 'rails_generator/scripts/update' -Rails::Generator::Scripts::Update.new.run(ARGV) diff --git a/vendor/rails/railties/lib/console_app.rb b/vendor/rails/railties/lib/console_app.rb deleted file mode 100644 index d7d01d7..0000000 --- a/vendor/rails/railties/lib/console_app.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'active_support/test_case' -require 'action_controller' - -# work around the at_exit hook in test/unit, which kills IRB -Test::Unit.run = true if Test::Unit.respond_to?(:run=) - -# reference the global "app" instance, created on demand. To recreate the -# instance, pass a non-false value as the parameter. -def app(create=false) - @app_integration_instance = nil if create - @app_integration_instance ||= new_session do |sess| - sess.host! "www.example.com" - end -end - -# create a new session. If a block is given, the new session will be yielded -# to the block before being returned. -def new_session - session = ActionController::Integration::Session.new - yield session if block_given? - session -end - -#reloads the environment -def reload! - puts "Reloading..." - Dispatcher.cleanup_application - Dispatcher.reload_application - true -end diff --git a/vendor/rails/railties/lib/console_sandbox.rb b/vendor/rails/railties/lib/console_sandbox.rb deleted file mode 100644 index 65a3d68..0000000 --- a/vendor/rails/railties/lib/console_sandbox.rb +++ /dev/null @@ -1,6 +0,0 @@ -ActiveRecord::Base.connection.increment_open_transactions -ActiveRecord::Base.connection.begin_db_transaction -at_exit do - ActiveRecord::Base.connection.rollback_db_transaction - ActiveRecord::Base.connection.decrement_open_transactions -end diff --git a/vendor/rails/railties/lib/console_with_helpers.rb b/vendor/rails/railties/lib/console_with_helpers.rb deleted file mode 100644 index 039db66..0000000 --- a/vendor/rails/railties/lib/console_with_helpers.rb +++ /dev/null @@ -1,5 +0,0 @@ -def helper - @helper ||= ApplicationController.helpers -end - -@controller = ApplicationController.new diff --git a/vendor/rails/railties/lib/dispatcher.rb b/vendor/rails/railties/lib/dispatcher.rb deleted file mode 100644 index 9f8b59a..0000000 --- a/vendor/rails/railties/lib/dispatcher.rb +++ /dev/null @@ -1,24 +0,0 @@ -#-- -# Copyright (c) 2004-2009 David Heinemeier Hansson -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ -require 'action_controller/dispatcher' -Dispatcher = ActionController::Dispatcher diff --git a/vendor/rails/railties/lib/fcgi_handler.rb b/vendor/rails/railties/lib/fcgi_handler.rb deleted file mode 100644 index 0cd2dc5..0000000 --- a/vendor/rails/railties/lib/fcgi_handler.rb +++ /dev/null @@ -1,239 +0,0 @@ -require 'fcgi' -require 'logger' -require 'dispatcher' -require 'rbconfig' - -class RailsFCGIHandler - SIGNALS = { - 'HUP' => :reload, - 'INT' => :exit_now, - 'TERM' => :exit_now, - 'USR1' => :exit, - 'USR2' => :restart - } - GLOBAL_SIGNALS = SIGNALS.keys - %w(USR1) - - attr_reader :when_ready - - attr_accessor :log_file_path - attr_accessor :gc_request_period - - # Initialize and run the FastCGI instance, passing arguments through to new. - def self.process!(*args, &block) - new(*args, &block).process! - end - - # Initialize the FastCGI instance with the path to a crash log - # detailing unhandled exceptions (default RAILS_ROOT/log/fastcgi.crash.log) - # and the number of requests to process between garbage collection runs - # (default nil for normal GC behavior.) Optionally, pass a block which - # takes this instance as an argument for further configuration. - def initialize(log_file_path = nil, gc_request_period = nil) - self.log_file_path = log_file_path || "#{RAILS_ROOT}/log/fastcgi.crash.log" - self.gc_request_period = gc_request_period - - # Yield for additional configuration. - yield self if block_given? - - # Safely install signal handlers. - install_signal_handlers - - @app = Dispatcher.new - - # Start error timestamp at 11 seconds ago. - @last_error_on = Time.now - 11 - end - - def process!(provider = FCGI) - mark_features! - - dispatcher_log :info, 'starting' - process_each_request provider - dispatcher_log :info, 'stopping gracefully' - - rescue Exception => error - case error - when SystemExit - dispatcher_log :info, 'stopping after explicit exit' - when SignalException - dispatcher_error error, 'stopping after unhandled signal' - else - # Retry if exceptions occur more than 10 seconds apart. - if Time.now - @last_error_on > 10 - @last_error_on = Time.now - dispatcher_error error, 'retrying after unhandled exception' - retry - else - dispatcher_error error, 'stopping after unhandled exception within 10 seconds of the last' - end - end - end - - protected - def process_each_request(provider) - request = nil - - catch :exit do - provider.each do |request| - process_request(request) - - case when_ready - when :reload - reload! - when :restart - close_connection(request) - restart! - when :exit - close_connection(request) - throw :exit - end - end - end - rescue SignalException => signal - raise unless signal.message == 'SIGUSR1' - close_connection(request) - end - - def process_request(request) - @processing, @when_ready = true, nil - gc_countdown - - with_signal_handler 'USR1' do - begin - ::Rack::Handler::FastCGI.serve(request, @app) - rescue SignalException, SystemExit - raise - rescue Exception => error - dispatcher_error error, 'unhandled dispatch error' - end - end - ensure - @processing = false - end - - def logger - @logger ||= Logger.new(@log_file_path) - end - - def dispatcher_log(level, msg) - time_str = Time.now.strftime("%d/%b/%Y:%H:%M:%S") - logger.send(level, "[#{time_str} :: #{$$}] #{msg}") - rescue Exception => log_error # Logger errors - STDERR << "Couldn't write to #{@log_file_path.inspect}: #{msg}\n" - STDERR << " #{log_error.class}: #{log_error.message}\n" - end - - def dispatcher_error(e, msg = "") - error_message = - "Dispatcher failed to catch: #{e} (#{e.class})\n" + - " #{e.backtrace.join("\n ")}\n#{msg}" - dispatcher_log(:error, error_message) - end - - def install_signal_handlers - GLOBAL_SIGNALS.each { |signal| install_signal_handler(signal) } - end - - def install_signal_handler(signal, handler = nil) - if SIGNALS.include?(signal) && self.class.method_defined?(name = "#{SIGNALS[signal]}_handler") - handler ||= method(name).to_proc - - begin - trap(signal, handler) - rescue ArgumentError - dispatcher_log :warn, "Ignoring unsupported signal #{signal}." - end - else - dispatcher_log :warn, "Ignoring unsupported signal #{signal}." - end - end - - def with_signal_handler(signal) - install_signal_handler(signal) - yield - ensure - install_signal_handler(signal, 'DEFAULT') - end - - def exit_now_handler(signal) - dispatcher_log :info, "asked to stop immediately" - exit - end - - def exit_handler(signal) - dispatcher_log :info, "asked to stop ASAP" - if @processing - @when_ready = :exit - else - throw :exit - end - end - - def reload_handler(signal) - dispatcher_log :info, "asked to reload ASAP" - if @processing - @when_ready = :reload - else - reload! - end - end - - def restart_handler(signal) - dispatcher_log :info, "asked to restart ASAP" - if @processing - @when_ready = :restart - else - restart! - end - end - - def restart! - config = ::Config::CONFIG - ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT'] - command_line = [ruby, $0, ARGV].flatten.join(' ') - - dispatcher_log :info, "restarted" - - # close resources as they won't be closed by - # the OS when using exec - logger.close rescue nil - Rails.logger.close rescue nil - - exec(command_line) - end - - def reload! - run_gc! if gc_request_period - restore! - @when_ready = nil - dispatcher_log :info, "reloaded" - end - - # Make a note of $" so we can safely reload this instance. - def mark_features! - @features = $".clone - end - - def restore! - $".replace @features - Dispatcher.reset_application! - ActionController::Routing::Routes.reload - end - - def run_gc! - @gc_request_countdown = gc_request_period - GC.enable; GC.start; GC.disable - end - - def gc_countdown - if gc_request_period - @gc_request_countdown ||= gc_request_period - @gc_request_countdown -= 1 - run_gc! if @gc_request_countdown <= 0 - end - end - - def close_connection(request) - request.finish if request - end -end diff --git a/vendor/rails/railties/lib/initializer.rb b/vendor/rails/railties/lib/initializer.rb deleted file mode 100644 index a04405a..0000000 --- a/vendor/rails/railties/lib/initializer.rb +++ /dev/null @@ -1,1105 +0,0 @@ -require 'logger' -require 'set' -require 'pathname' - -$LOAD_PATH.unshift File.dirname(__FILE__) -require 'railties_path' -require 'rails/version' -require 'rails/plugin/locator' -require 'rails/plugin/loader' -require 'rails/gem_dependency' -require 'rails/rack' - - -RAILS_ENV = (ENV['RAILS_ENV'] || 'development').dup unless defined?(RAILS_ENV) - -module Rails - class << self - # The Configuration instance used to configure the Rails environment - def configuration - @@configuration - end - - def configuration=(configuration) - @@configuration = configuration - end - - def initialized? - @initialized || false - end - - def initialized=(initialized) - @initialized ||= initialized - end - - def logger - if defined?(RAILS_DEFAULT_LOGGER) - RAILS_DEFAULT_LOGGER - else - nil - end - end - - def backtrace_cleaner - @@backtrace_cleaner ||= begin - # Relies on ActiveSupport, so we have to lazy load to postpone definition until AS has been loaded - require 'rails/backtrace_cleaner' - Rails::BacktraceCleaner.new - end - end - - def root - Pathname.new(RAILS_ROOT) if defined?(RAILS_ROOT) - end - - def env - @_env ||= ActiveSupport::StringInquirer.new(RAILS_ENV) - end - - def cache - RAILS_CACHE - end - - def version - VERSION::STRING - end - - def public_path - @@public_path ||= self.root ? File.join(self.root, "public") : "public" - end - - def public_path=(path) - @@public_path = path - end - end - - # The Initializer is responsible for processing the Rails configuration, such - # as setting the $LOAD_PATH, requiring the right frameworks, initializing - # logging, and more. It can be run either as a single command that'll just - # use the default configuration, like this: - # - # Rails::Initializer.run - # - # But normally it's more interesting to pass in a custom configuration - # through the block running: - # - # Rails::Initializer.run do |config| - # config.frameworks -= [ :action_mailer ] - # end - # - # This will use the default configuration options from Rails::Configuration, - # but allow for overwriting on select areas. - class Initializer - # The Configuration instance used by this Initializer instance. - attr_reader :configuration - - # The set of loaded plugins. - attr_reader :loaded_plugins - - # Whether or not all the gem dependencies have been met - attr_reader :gems_dependencies_loaded - - # Runs the initializer. By default, this will invoke the #process method, - # which simply executes all of the initialization routines. Alternately, - # you can specify explicitly which initialization routine you want: - # - # Rails::Initializer.run(:set_load_path) - # - # This is useful if you only want the load path initialized, without - # incurring the overhead of completely loading the entire environment. - def self.run(command = :process, configuration = Configuration.new) - yield configuration if block_given? - initializer = new configuration - initializer.send(command) - initializer - end - - # Create a new Initializer instance that references the given Configuration - # instance. - def initialize(configuration) - @configuration = configuration - @loaded_plugins = [] - end - - # Sequentially step through all of the available initialization routines, - # in order (view execution order in source). - def process - Rails.configuration = configuration - - check_ruby_version - install_gem_spec_stubs - set_load_path - add_gem_load_paths - - require_frameworks - set_autoload_paths - add_plugin_load_paths - load_environment - preload_frameworks - - initialize_encoding - initialize_database - - initialize_cache - initialize_framework_caches - - initialize_logger - initialize_framework_logging - - initialize_dependency_mechanism - initialize_whiny_nils - - initialize_time_zone - initialize_i18n - - initialize_framework_settings - initialize_framework_views - - initialize_metal - - add_support_load_paths - - load_gems - load_plugins - - # pick up any gems that plugins depend on - add_gem_load_paths - load_gems - check_gem_dependencies - - # bail out if gems are missing - note that check_gem_dependencies will have - # already called abort() unless $gems_rake_task is set - return unless gems_dependencies_loaded - - load_application_initializers - - # the framework is now fully initialized - after_initialize - - # Setup database middleware after initializers have run - initialize_database_middleware - - # Prepare dispatcher callbacks and run 'prepare' callbacks - prepare_dispatcher - - # Routing must be initialized after plugins to allow the former to extend the routes - initialize_routing - - # Observers are loaded after plugins in case Observers or observed models are modified by plugins. - load_observers - - # Load view path cache - load_view_paths - - # Load application classes - load_application_classes - - # Disable dependency loading during request cycle - disable_dependency_loading - - # Flag initialized - Rails.initialized = true - end - - # Check for valid Ruby version - # This is done in an external file, so we can use it - # from the `rails` program as well without duplication. - def check_ruby_version - require 'ruby_version_check' - end - - # If Rails is vendored and RubyGems is available, install stub GemSpecs - # for Rails, Active Support, Active Record, Action Pack, Action Mailer, and - # Active Resource. This allows Gem plugins to depend on Rails even when - # the Gem version of Rails shouldn't be loaded. - def install_gem_spec_stubs - unless Rails.respond_to?(:vendor_rails?) - abort %{Your config/boot.rb is outdated: Run "rake rails:update".} - end - - if Rails.vendor_rails? - begin; require "rubygems"; rescue LoadError; return; end - - stubs = %w(rails activesupport activerecord actionpack actionmailer activeresource) - stubs.reject! { |s| Gem.loaded_specs.key?(s) } - - stubs.each do |stub| - Gem.loaded_specs[stub] = Gem::Specification.new do |s| - s.name = stub - s.version = Rails::VERSION::STRING - s.loaded_from = "" - end - end - end - end - - # Set the <tt>$LOAD_PATH</tt> based on the value of - # Configuration#load_paths. Duplicates are removed. - def set_load_path - load_paths = configuration.load_paths + configuration.framework_paths - load_paths.reverse_each { |dir| $LOAD_PATH.unshift(dir) if File.directory?(dir) } - $LOAD_PATH.uniq! - end - - # Set the paths from which Rails will automatically load source files, and - # the load_once paths. - def set_autoload_paths - ActiveSupport::Dependencies.load_paths = configuration.load_paths.uniq - ActiveSupport::Dependencies.load_once_paths = configuration.load_once_paths.uniq - - extra = ActiveSupport::Dependencies.load_once_paths - ActiveSupport::Dependencies.load_paths - unless extra.empty? - abort <<-end_error - load_once_paths must be a subset of the load_paths. - Extra items in load_once_paths: #{extra * ','} - end_error - end - - # Freeze the arrays so future modifications will fail rather than do nothing mysteriously - configuration.load_once_paths.freeze - end - - # Requires all frameworks specified by the Configuration#frameworks - # list. By default, all frameworks (Active Record, Active Support, - # Action Pack, Action Mailer, and Active Resource) are loaded. - def require_frameworks - configuration.frameworks.each { |framework| require(framework.to_s) } - rescue LoadError => e - # Re-raise as RuntimeError because Mongrel would swallow LoadError. - raise e.to_s - end - - # Preload all frameworks specified by the Configuration#frameworks. - # Used by Passenger to ensure everything's loaded before forking and - # to avoid autoload race conditions in JRuby. - def preload_frameworks - if configuration.preload_frameworks - configuration.frameworks.each do |framework| - # String#classify and #constantize aren't available yet. - toplevel = Object.const_get(framework.to_s.gsub(/(?:^|_)(.)/) { $1.upcase }) - toplevel.load_all! if toplevel.respond_to?(:load_all!) - end - end - end - - # Add the load paths used by support functions such as the info controller - def add_support_load_paths - end - - # Adds all load paths from plugins to the global set of load paths, so that - # code from plugins can be required (explicitly or automatically via ActiveSupport::Dependencies). - def add_plugin_load_paths - plugin_loader.add_plugin_load_paths - end - - def add_gem_load_paths - Rails::GemDependency.add_frozen_gem_path - unless @configuration.gems.empty? - require "rubygems" - @configuration.gems.each { |gem| gem.add_load_paths } - end - end - - def load_gems - unless $gems_build_rake_task - @configuration.gems.each { |gem| gem.load } - end - end - - def check_gem_dependencies - unloaded_gems = @configuration.gems.reject { |g| g.loaded? } - if unloaded_gems.size > 0 - @gems_dependencies_loaded = false - # don't print if the gems rake tasks are being run - unless $gems_rake_task - abort <<-end_error -Missing these required gems: - #{unloaded_gems.map { |gem| "#{gem.name} #{gem.requirement}" } * "\n "} - -You're running: - ruby #{Gem.ruby_version} at #{Gem.ruby} - rubygems #{Gem::RubyGemsVersion} at #{Gem.path * ', '} - -Run `rake gems:install` to install the missing gems. - end_error - end - else - @gems_dependencies_loaded = true - end - end - - # Loads all plugins in <tt>config.plugin_paths</tt>. <tt>plugin_paths</tt> - # defaults to <tt>vendor/plugins</tt> but may also be set to a list of - # paths, such as - # config.plugin_paths = ["#{RAILS_ROOT}/lib/plugins", "#{RAILS_ROOT}/vendor/plugins"] - # - # In the default implementation, as each plugin discovered in <tt>plugin_paths</tt> is initialized: - # * its +lib+ directory, if present, is added to the load path (immediately after the applications lib directory) - # * <tt>init.rb</tt> is evaluated, if present - # - # After all plugins are loaded, duplicates are removed from the load path. - # If an array of plugin names is specified in config.plugins, only those plugins will be loaded - # and they plugins will be loaded in that order. Otherwise, plugins are loaded in alphabetical - # order. - # - # if config.plugins ends contains :all then the named plugins will be loaded in the given order and all other - # plugins will be loaded in alphabetical order - def load_plugins - plugin_loader.load_plugins - end - - def plugin_loader - @plugin_loader ||= configuration.plugin_loader.new(self) - end - - # Loads the environment specified by Configuration#environment_path, which - # is typically one of development, test, or production. - def load_environment - silence_warnings do - return if @environment_loaded - @environment_loaded = true - - config = configuration - constants = self.class.constants - - eval(IO.read(configuration.environment_path), binding, configuration.environment_path) - - (self.class.constants - constants).each do |const| - Object.const_set(const, self.class.const_get(const)) - end - end - end - - def load_observers - if gems_dependencies_loaded && configuration.frameworks.include?(:active_record) - ActiveRecord::Base.instantiate_observers - end - end - - def load_view_paths - if configuration.frameworks.include?(:action_view) - ActionController::Base.view_paths.load! if configuration.frameworks.include?(:action_controller) - ActionMailer::Base.view_paths.load! if configuration.frameworks.include?(:action_mailer) - end - end - - # Eager load application classes - def load_application_classes - return if $rails_rake_task - if configuration.cache_classes - configuration.eager_load_paths.each do |load_path| - matcher = /\A#{Regexp.escape(load_path)}(.*)\.rb\Z/ - Dir.glob("#{load_path}/**/*.rb").sort.each do |file| - require_dependency file.sub(matcher, '\1') - end - end - end - end - - # For Ruby 1.8, this initialization sets $KCODE to 'u' to enable the - # multibyte safe operations. Plugin authors supporting other encodings - # should override this behaviour and set the relevant +default_charset+ - # on ActionController::Base. - # - # For Ruby 1.9, this does nothing. Specify the default encoding in the Ruby - # shebang line if you don't want UTF-8. - def initialize_encoding - $KCODE='u' if RUBY_VERSION < '1.9' - end - - # This initialization routine does nothing unless <tt>:active_record</tt> - # is one of the frameworks to load (Configuration#frameworks). If it is, - # this sets the database configuration from Configuration#database_configuration - # and then establishes the connection. - def initialize_database - if configuration.frameworks.include?(:active_record) - ActiveRecord::Base.configurations = configuration.database_configuration - ActiveRecord::Base.establish_connection - end - end - - def initialize_database_middleware - if configuration.frameworks.include?(:active_record) - if ActionController::Base.session_store == ActiveRecord::SessionStore - configuration.middleware.insert_before :"ActiveRecord::SessionStore", ActiveRecord::ConnectionAdapters::ConnectionManagement - configuration.middleware.insert_before :"ActiveRecord::SessionStore", ActiveRecord::QueryCache - else - configuration.middleware.use ActiveRecord::ConnectionAdapters::ConnectionManagement - configuration.middleware.use ActiveRecord::QueryCache - end - end - end - - def initialize_cache - unless defined?(RAILS_CACHE) - silence_warnings { Object.const_set "RAILS_CACHE", ActiveSupport::Cache.lookup_store(configuration.cache_store) } - - if RAILS_CACHE.respond_to?(:middleware) - # Insert middleware to setup and teardown local cache for each request - configuration.middleware.insert_after(:"ActionController::Failsafe", RAILS_CACHE.middleware) - end - end - end - - def initialize_framework_caches - if configuration.frameworks.include?(:action_controller) - ActionController::Base.cache_store ||= RAILS_CACHE - end - end - - # If the RAILS_DEFAULT_LOGGER constant is already set, this initialization - # routine does nothing. If the constant is not set, and Configuration#logger - # is not +nil+, this also does nothing. Otherwise, a new logger instance - # is created at Configuration#log_path, with a default log level of - # Configuration#log_level. - # - # If the log could not be created, the log will be set to output to - # +STDERR+, with a log level of +WARN+. - def initialize_logger - # if the environment has explicitly defined a logger, use it - return if Rails.logger - - unless logger = configuration.logger - begin - logger = ActiveSupport::BufferedLogger.new(configuration.log_path) - logger.level = ActiveSupport::BufferedLogger.const_get(configuration.log_level.to_s.upcase) - if configuration.environment == "production" - logger.auto_flushing = false - end - rescue StandardError => e - logger = ActiveSupport::BufferedLogger.new(STDERR) - logger.level = ActiveSupport::BufferedLogger::WARN - logger.warn( - "Rails Error: Unable to access log file. Please ensure that #{configuration.log_path} exists and is chmod 0666. " + - "The log level has been raised to WARN and the output directed to STDERR until the problem is fixed." - ) - end - end - - silence_warnings { Object.const_set "RAILS_DEFAULT_LOGGER", logger } - end - - # Sets the logger for Active Record, Action Controller, and Action Mailer - # (but only for those frameworks that are to be loaded). If the framework's - # logger is already set, it is not changed, otherwise it is set to use - # RAILS_DEFAULT_LOGGER. - def initialize_framework_logging - for framework in ([ :active_record, :action_controller, :action_mailer ] & configuration.frameworks) - framework.to_s.camelize.constantize.const_get("Base").logger ||= Rails.logger - end - - ActiveSupport::Dependencies.logger ||= Rails.logger - Rails.cache.logger ||= Rails.logger - end - - # Sets +ActionController::Base#view_paths+ and +ActionMailer::Base#template_root+ - # (but only for those frameworks that are to be loaded). If the framework's - # paths have already been set, it is not changed, otherwise it is - # set to use Configuration#view_path. - def initialize_framework_views - if configuration.frameworks.include?(:action_view) - view_path = ActionView::PathSet.type_cast(configuration.view_path) - ActionMailer::Base.template_root = view_path if configuration.frameworks.include?(:action_mailer) && ActionMailer::Base.view_paths.blank? - ActionController::Base.view_paths = view_path if configuration.frameworks.include?(:action_controller) && ActionController::Base.view_paths.blank? - end - end - - # If Action Controller is not one of the loaded frameworks (Configuration#frameworks) - # this does nothing. Otherwise, it loads the routing definitions and sets up - # loading module used to lazily load controllers (Configuration#controller_paths). - def initialize_routing - return unless configuration.frameworks.include?(:action_controller) - - ActionController::Routing.controller_paths += configuration.controller_paths - ActionController::Routing::Routes.add_configuration_file(configuration.routes_configuration_file) - ActionController::Routing::Routes.reload! - end - - # Sets the dependency loading mechanism based on the value of - # Configuration#cache_classes. - def initialize_dependency_mechanism - ActiveSupport::Dependencies.mechanism = configuration.cache_classes ? :require : :load - end - - # Loads support for "whiny nil" (noisy warnings when methods are invoked - # on +nil+ values) if Configuration#whiny_nils is true. - def initialize_whiny_nils - require('active_support/whiny_nil') if configuration.whiny_nils - end - - # Sets the default value for Time.zone, and turns on ActiveRecord::Base#time_zone_aware_attributes. - # If assigned value cannot be matched to a TimeZone, an exception will be raised. - def initialize_time_zone - if configuration.time_zone - zone_default = Time.__send__(:get_zone, configuration.time_zone) - - unless zone_default - raise \ - 'Value assigned to config.time_zone not recognized.' + - 'Run "rake -D time" for a list of tasks for finding appropriate time zone names.' - end - - Time.zone_default = zone_default - - if configuration.frameworks.include?(:active_record) - ActiveRecord::Base.time_zone_aware_attributes = true - ActiveRecord::Base.default_timezone = :utc - end - end - end - - # Set the i18n configuration from config.i18n but special-case for the load_path which should be - # appended to what's already set instead of overwritten. - def initialize_i18n - configuration.i18n.each do |setting, value| - if setting == :load_path - I18n.load_path += value - else - I18n.send("#{setting}=", value) - end - end - end - - def initialize_metal - Rails::Rack::Metal.requested_metals = configuration.metals - Rails::Rack::Metal.metal_paths += plugin_loader.engine_metal_paths - - configuration.middleware.insert_before( - :"ActionController::RewindableInput", - Rails::Rack::Metal, :if => Rails::Rack::Metal.metals.any?) - end - - # Initializes framework-specific settings for each of the loaded frameworks - # (Configuration#frameworks). The available settings map to the accessors - # on each of the corresponding Base classes. - def initialize_framework_settings - configuration.frameworks.each do |framework| - base_class = framework.to_s.camelize.constantize.const_get("Base") - - configuration.send(framework).each do |setting, value| - base_class.send("#{setting}=", value) - end - end - configuration.active_support.each do |setting, value| - ActiveSupport.send("#{setting}=", value) - end - end - - # Fires the user-supplied after_initialize block (Configuration#after_initialize) - def after_initialize - if gems_dependencies_loaded - configuration.after_initialize_blocks.each do |block| - block.call - end - end - end - - def load_application_initializers - if gems_dependencies_loaded - Dir["#{configuration.root_path}/config/initializers/**/*.rb"].sort.each do |initializer| - load(initializer) - end - end - end - - def prepare_dispatcher - return unless configuration.frameworks.include?(:action_controller) - require 'dispatcher' unless defined?(::Dispatcher) - Dispatcher.define_dispatcher_callbacks(configuration.cache_classes) - Dispatcher.run_prepare_callbacks - end - - def disable_dependency_loading - if configuration.cache_classes && !configuration.dependency_loading - ActiveSupport::Dependencies.unhook! - end - end - end - - # The Configuration class holds all the parameters for the Initializer and - # ships with defaults that suites most Rails applications. But it's possible - # to overwrite everything. Usually, you'll create an Configuration file - # implicitly through the block running on the Initializer, but it's also - # possible to create the Configuration instance in advance and pass it in - # like this: - # - # config = Rails::Configuration.new - # Rails::Initializer.run(:process, config) - class Configuration - # The application's base directory. - attr_reader :root_path - - # A stub for setting options on ActionController::Base. - attr_accessor :action_controller - - # A stub for setting options on ActionMailer::Base. - attr_accessor :action_mailer - - # A stub for setting options on ActionView::Base. - attr_accessor :action_view - - # A stub for setting options on ActiveRecord::Base. - attr_accessor :active_record - - # A stub for setting options on ActiveResource::Base. - attr_accessor :active_resource - - # A stub for setting options on ActiveSupport. - attr_accessor :active_support - - # Whether to preload all frameworks at startup. - attr_accessor :preload_frameworks - - # Whether or not classes should be cached (set to false if you want - # application classes to be reloaded on each request) - attr_accessor :cache_classes - - # The list of paths that should be searched for controllers. (Defaults - # to <tt>app/controllers</tt>.) - attr_accessor :controller_paths - - # The path to the database configuration file to use. (Defaults to - # <tt>config/database.yml</tt>.) - attr_accessor :database_configuration_file - - # The path to the routes configuration file to use. (Defaults to - # <tt>config/routes.rb</tt>.) - attr_accessor :routes_configuration_file - - # The list of rails framework components that should be loaded. (Defaults - # to <tt>:active_record</tt>, <tt>:action_controller</tt>, - # <tt>:action_view</tt>, <tt>:action_mailer</tt>, and - # <tt>:active_resource</tt>). - attr_accessor :frameworks - - # An array of additional paths to prepend to the load path. By default, - # all +app+, +lib+, +vendor+ and mock paths are included in this list. - attr_accessor :load_paths - - # An array of paths from which Rails will automatically load from only once. - # All elements of this array must also be in +load_paths+. - attr_accessor :load_once_paths - - # An array of paths from which Rails will eager load on boot if cache - # classes is enabled. All elements of this array must also be in - # +load_paths+. - attr_accessor :eager_load_paths - - # The log level to use for the default Rails logger. In production mode, - # this defaults to <tt>:info</tt>. In development mode, it defaults to - # <tt>:debug</tt>. - attr_accessor :log_level - - # The path to the log file to use. Defaults to log/#{environment}.log - # (e.g. log/development.log or log/production.log). - attr_accessor :log_path - - # The specific logger to use. By default, a logger will be created and - # initialized using #log_path and #log_level, but a programmer may - # specifically set the logger to use via this accessor and it will be - # used directly. - attr_accessor :logger - - # The specific cache store to use. By default, the ActiveSupport::Cache::Store will be used. - attr_accessor :cache_store - - # The root of the application's views. (Defaults to <tt>app/views</tt>.) - attr_accessor :view_path - - # Set to +true+ if you want to be warned (noisily) when you try to invoke - # any method of +nil+. Set to +false+ for the standard Ruby behavior. - attr_accessor :whiny_nils - - # The list of plugins to load. If this is set to <tt>nil</tt>, all plugins will - # be loaded. If this is set to <tt>[]</tt>, no plugins will be loaded. Otherwise, - # plugins will be loaded in the order specified. - attr_reader :plugins - def plugins=(plugins) - @plugins = plugins.nil? ? nil : plugins.map { |p| p.to_sym } - end - - # The list of metals to load. If this is set to <tt>nil</tt>, all metals will - # be loaded in alphabetical order. If this is set to <tt>[]</tt>, no metals will - # be loaded. Otherwise metals will be loaded in the order specified - attr_accessor :metals - - # The path to the root of the plugins directory. By default, it is in - # <tt>vendor/plugins</tt>. - attr_accessor :plugin_paths - - # The classes that handle finding the desired plugins that you'd like to load for - # your application. By default it is the Rails::Plugin::FileSystemLocator which finds - # plugins to load in <tt>vendor/plugins</tt>. You can hook into gem location by subclassing - # Rails::Plugin::Locator and adding it onto the list of <tt>plugin_locators</tt>. - attr_accessor :plugin_locators - - # The class that handles loading each plugin. Defaults to Rails::Plugin::Loader, but - # a sub class would have access to fine grained modification of the loading behavior. See - # the implementation of Rails::Plugin::Loader for more details. - attr_accessor :plugin_loader - - # Enables or disables plugin reloading. You can get around this setting per plugin. - # If <tt>reload_plugins?</tt> is false, add this to your plugin's <tt>init.rb</tt> - # to make it reloadable: - # - # ActiveSupport::Dependencies.load_once_paths.delete lib_path - # - # If <tt>reload_plugins?</tt> is true, add this to your plugin's <tt>init.rb</tt> - # to only load it once: - # - # ActiveSupport::Dependencies.load_once_paths << lib_path - # - attr_accessor :reload_plugins - - # Returns true if plugin reloading is enabled. - def reload_plugins? - !!@reload_plugins - end - - # Enables or disables dependency loading during the request cycle. Setting - # <tt>dependency_loading</tt> to true will allow new classes to be loaded - # during a request. Setting it to false will disable this behavior. - # - # Those who want to run in a threaded environment should disable this - # option and eager load or require all there classes on initialization. - # - # If <tt>cache_classes</tt> is disabled, dependency loaded will always be - # on. - attr_accessor :dependency_loading - - # An array of gems that this rails application depends on. Rails will automatically load - # these gems during installation, and allow you to install any missing gems with: - # - # rake gems:install - # - # You can add gems with the #gem method. - attr_accessor :gems - - # Adds a single Gem dependency to the rails application. By default, it will require - # the library with the same name as the gem. Use :lib to specify a different name. - # - # # gem 'aws-s3', '>= 0.4.0' - # # require 'aws/s3' - # config.gem 'aws-s3', :lib => 'aws/s3', :version => '>= 0.4.0', \ - # :source => "http://code.whytheluckystiff.net" - # - # To require a library be installed, but not attempt to load it, pass :lib => false - # - # config.gem 'qrp', :version => '0.4.1', :lib => false - def gem(name, options = {}) - @gems << Rails::GemDependency.new(name, options) - end - - # Deprecated options: - def breakpoint_server(_ = nil) - $stderr.puts %( - ******************************************************************* - * config.breakpoint_server has been deprecated and has no effect. * - ******************************************************************* - ) - end - alias_method :breakpoint_server=, :breakpoint_server - - # Sets the default +time_zone+. Setting this will enable +time_zone+ - # awareness for Active Record models and set the Active Record default - # timezone to <tt>:utc</tt>. - attr_accessor :time_zone - - # Accessor for i18n settings. - attr_accessor :i18n - - # Create a new Configuration instance, initialized with the default - # values. - def initialize - set_root_path! - - self.frameworks = default_frameworks - self.load_paths = default_load_paths - self.load_once_paths = default_load_once_paths - self.eager_load_paths = default_eager_load_paths - self.log_path = default_log_path - self.log_level = default_log_level - self.view_path = default_view_path - self.controller_paths = default_controller_paths - self.preload_frameworks = default_preload_frameworks - self.cache_classes = default_cache_classes - self.dependency_loading = default_dependency_loading - self.whiny_nils = default_whiny_nils - self.plugins = default_plugins - self.plugin_paths = default_plugin_paths - self.plugin_locators = default_plugin_locators - self.plugin_loader = default_plugin_loader - self.database_configuration_file = default_database_configuration_file - self.routes_configuration_file = default_routes_configuration_file - self.gems = default_gems - self.i18n = default_i18n - - for framework in default_frameworks - self.send("#{framework}=", Rails::OrderedOptions.new) - end - self.active_support = Rails::OrderedOptions.new - end - - # Set the root_path to RAILS_ROOT and canonicalize it. - def set_root_path! - raise 'RAILS_ROOT is not set' unless defined?(::RAILS_ROOT) - raise 'RAILS_ROOT is not a directory' unless File.directory?(::RAILS_ROOT) - - @root_path = - # Pathname is incompatible with Windows, but Windows doesn't have - # real symlinks so File.expand_path is safe. - if RUBY_PLATFORM =~ /(:?mswin|mingw)/ - File.expand_path(::RAILS_ROOT) - - # Otherwise use Pathname#realpath which respects symlinks. - else - Pathname.new(::RAILS_ROOT).realpath.to_s - end - - Object.const_set(:RELATIVE_RAILS_ROOT, ::RAILS_ROOT.dup) unless defined?(::RELATIVE_RAILS_ROOT) - ::RAILS_ROOT.replace @root_path - end - - # Enable threaded mode. Allows concurrent requests to controller actions and - # multiple database connections. Also disables automatic dependency loading - # after boot, and disables reloading code on every request, as these are - # fundamentally incompatible with thread safety. - def threadsafe! - self.preload_frameworks = true - self.cache_classes = true - self.dependency_loading = false - self.action_controller.allow_concurrency = true - self - end - - # Loads and returns the contents of the #database_configuration_file. The - # contents of the file are processed via ERB before being sent through - # YAML::load. - def database_configuration - require 'erb' - YAML::load(ERB.new(IO.read(database_configuration_file)).result) - end - - # The path to the current environment's file (<tt>development.rb</tt>, etc.). By - # default the file is at <tt>config/environments/#{environment}.rb</tt>. - def environment_path - "#{root_path}/config/environments/#{environment}.rb" - end - - # Return the currently selected environment. By default, it returns the - # value of the RAILS_ENV constant. - def environment - ::RAILS_ENV - end - - # Adds a block which will be executed after rails has been fully initialized. - # Useful for per-environment configuration which depends on the framework being - # fully initialized. - def after_initialize(&after_initialize_block) - after_initialize_blocks << after_initialize_block if after_initialize_block - end - - # Returns the blocks added with Configuration#after_initialize - def after_initialize_blocks - @after_initialize_blocks ||= [] - end - - # Add a preparation callback that will run before every request in development - # mode, or before the first request in production. - # - # See Dispatcher#to_prepare. - def to_prepare(&callback) - after_initialize do - require 'dispatcher' unless defined?(::Dispatcher) - Dispatcher.to_prepare(&callback) - end - end - - def middleware - require 'action_controller' - ActionController::Dispatcher.middleware - end - - def builtin_directories - # Include builtins only in the development environment. - (environment == 'development') ? Dir["#{RAILTIES_PATH}/builtin/*/"] : [] - end - - def framework_paths - paths = %w(railties railties/lib activesupport/lib) - paths << 'actionpack/lib' if frameworks.include?(:action_controller) || frameworks.include?(:action_view) - - [:active_record, :action_mailer, :active_resource, :action_web_service].each do |framework| - paths << "#{framework.to_s.gsub('_', '')}/lib" if frameworks.include?(framework) - end - - paths.map { |dir| "#{framework_root_path}/#{dir}" }.select { |dir| File.directory?(dir) } - end - - private - def framework_root_path - defined?(::RAILS_FRAMEWORK_ROOT) ? ::RAILS_FRAMEWORK_ROOT : "#{root_path}/vendor/rails" - end - - def default_frameworks - [ :active_record, :action_controller, :action_view, :action_mailer, :active_resource ] - end - - def default_load_paths - paths = [] - - # Add the old mock paths only if the directories exists - paths.concat(Dir["#{root_path}/test/mocks/#{environment}"]) if File.exists?("#{root_path}/test/mocks/#{environment}") - - # Add the app's controller directory - paths.concat(Dir["#{root_path}/app/controllers/"]) - - # Followed by the standard includes. - paths.concat %w( - app - app/metal - app/models - app/controllers - app/helpers - app/services - lib - vendor - ).map { |dir| "#{root_path}/#{dir}" }.select { |dir| File.directory?(dir) } - - paths.concat builtin_directories - end - - # Doesn't matter since plugins aren't in load_paths yet. - def default_load_once_paths - [] - end - - def default_eager_load_paths - %w( - app/metal - app/models - app/controllers - app/helpers - ).map { |dir| "#{root_path}/#{dir}" }.select { |dir| File.directory?(dir) } - end - - def default_log_path - File.join(root_path, 'log', "#{environment}.log") - end - - def default_log_level - environment == 'production' ? :info : :debug - end - - def default_database_configuration_file - File.join(root_path, 'config', 'database.yml') - end - - def default_routes_configuration_file - File.join(root_path, 'config', 'routes.rb') - end - - def default_view_path - File.join(root_path, 'app', 'views') - end - - def default_controller_paths - paths = [File.join(root_path, 'app', 'controllers')] - paths.concat builtin_directories - paths - end - - def default_dependency_loading - true - end - - def default_preload_frameworks - false - end - - def default_cache_classes - true - end - - def default_whiny_nils - false - end - - def default_plugins - nil - end - - def default_plugin_paths - ["#{root_path}/vendor/plugins"] - end - - def default_plugin_locators - locators = [] - locators << Plugin::GemLocator if defined? Gem - locators << Plugin::FileSystemLocator - end - - def default_plugin_loader - Plugin::Loader - end - - def default_cache_store - if File.exist?("#{root_path}/tmp/cache/") - [ :file_store, "#{root_path}/tmp/cache/" ] - else - :memory_store - end - end - - def default_gems - [] - end - - def default_i18n - i18n = Rails::OrderedOptions.new - i18n.load_path = [] - - if File.exist?(File.join(RAILS_ROOT, 'config', 'locales')) - i18n.load_path << Dir[File.join(RAILS_ROOT, 'config', 'locales', '*.{rb,yml}')] - i18n.load_path.flatten! - end - - i18n - end - end -end - -# Needs to be duplicated from Active Support since its needed before Active -# Support is available. Here both Options and Hash are namespaced to prevent -# conflicts with other implementations AND with the classes residing in Active Support. -class Rails::OrderedOptions < Array #:nodoc: - def []=(key, value) - key = key.to_sym - - if pair = find_pair(key) - pair.pop - pair << value - else - self << [key, value] - end - end - - def [](key) - pair = find_pair(key.to_sym) - pair ? pair.last : nil - end - - def method_missing(name, *args) - if name.to_s =~ /(.*)=$/ - self[$1.to_sym] = args.first - else - self[name] - end - end - - private - def find_pair(key) - self.each { |i| return i if i.first == key } - return false - end -end diff --git a/vendor/rails/railties/lib/performance_test_help.rb b/vendor/rails/railties/lib/performance_test_help.rb deleted file mode 100644 index 5148b4a..0000000 --- a/vendor/rails/railties/lib/performance_test_help.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'action_controller/performance_test' - -ActionController::Base.perform_caching = true -ActiveSupport::Dependencies.mechanism = :require -Rails.logger.level = ActiveSupport::BufferedLogger::INFO diff --git a/vendor/rails/railties/lib/rails/backtrace_cleaner.rb b/vendor/rails/railties/lib/rails/backtrace_cleaner.rb deleted file mode 100644 index 923ed8b..0000000 --- a/vendor/rails/railties/lib/rails/backtrace_cleaner.rb +++ /dev/null @@ -1,54 +0,0 @@ -module Rails - class BacktraceCleaner < ActiveSupport::BacktraceCleaner - ERB_METHOD_SIG = /:in `_run_erb_.*/ - - RAILS_GEMS = %w( actionpack activerecord actionmailer activesupport activeresource rails ) - - VENDOR_DIRS = %w( vendor/rails ) - SERVER_DIRS = %w( lib/mongrel bin/mongrel - lib/passenger bin/passenger-spawn-server - lib/rack ) - RAILS_NOISE = %w( script/server ) - RUBY_NOISE = %w( rubygems/custom_require benchmark.rb ) - - ALL_NOISE = VENDOR_DIRS + SERVER_DIRS + RAILS_NOISE + RUBY_NOISE - - def initialize - super - add_filter { |line| line.sub("#{RAILS_ROOT}/", '') } - add_filter { |line| line.sub(ERB_METHOD_SIG, '') } - add_filter { |line| line.sub('./', '/') } # for tests - - add_gem_filters - - add_silencer { |line| ALL_NOISE.any? { |dir| line.include?(dir) } } - add_silencer { |line| RAILS_GEMS.any? { |gem| line =~ /^#{gem} / } } - add_silencer { |line| line =~ %r(vendor/plugins/[^\/]+/lib) } - end - - - private - def add_gem_filters - Gem.path.each do |path| - # http://gist.github.com/30430 - add_filter { |line| line.sub(/(#{path})\/gems\/([a-z]+)-([0-9.]+)\/(.*)/, '\2 (\3) \4')} - end - - vendor_gems_path = Rails::GemDependency.unpacked_path.sub("#{RAILS_ROOT}/",'') - add_filter { |line| line.sub(/(#{vendor_gems_path})\/([a-z]+)-([0-9.]+)\/(.*)/, '\2 (\3) [v] \4')} - end - end - - # For installing the BacktraceCleaner in the test/unit - module BacktraceFilterForTestUnit #:nodoc: - def self.included(klass) - klass.send :alias_method_chain, :filter_backtrace, :cleaning - end - - def filter_backtrace_with_cleaning(backtrace, prefix=nil) - backtrace = filter_backtrace_without_cleaning(backtrace, prefix) - backtrace = backtrace.first.split("\n") if backtrace.size == 1 - Rails.backtrace_cleaner.clean(backtrace) - end - end -end diff --git a/vendor/rails/railties/lib/rails/gem_builder.rb b/vendor/rails/railties/lib/rails/gem_builder.rb deleted file mode 100644 index 79c61cc..0000000 --- a/vendor/rails/railties/lib/rails/gem_builder.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rubygems' -require 'rubygems/installer' - -module Rails - - # this class hijacks the functionality of Gem::Installer by overloading its - # initializer to only provide the information needed by - # Gem::Installer#build_extensions (which happens to be what we have) - class GemBuilder < Gem::Installer - - def initialize(spec, gem_dir) - @spec = spec - @gem_dir = gem_dir - end - - # silence the underlying builder - def say(message) - end - - end -end diff --git a/vendor/rails/railties/lib/rails/gem_dependency.rb b/vendor/rails/railties/lib/rails/gem_dependency.rb deleted file mode 100644 index 3062a77..0000000 --- a/vendor/rails/railties/lib/rails/gem_dependency.rb +++ /dev/null @@ -1,282 +0,0 @@ -require 'rails/vendor_gem_source_index' - -module Gem - def self.source_index=(index) - @@source_index = index - end -end - -module Rails - class GemDependency < Gem::Dependency - attr_accessor :lib, :source, :dep - - def self.unpacked_path - @unpacked_path ||= File.join(RAILS_ROOT, 'vendor', 'gems') - end - - @@framework_gems = {} - - def self.add_frozen_gem_path - @@paths_loaded ||= begin - source_index = Rails::VendorGemSourceIndex.new(Gem.source_index) - Gem.clear_paths - Gem.source_index = source_index - # loaded before us - we can't change them, so mark them - Gem.loaded_specs.each do |name, spec| - @@framework_gems[name] = spec - end - true - end - end - - def initialize(name, options = {}) - require 'rubygems' unless Object.const_defined?(:Gem) - - if options[:requirement] - req = options[:requirement] - elsif options[:version] - req = Gem::Requirement.create(options[:version]) - else - req = Gem::Requirement.default - end - - @lib = options[:lib] - @source = options[:source] - @loaded = @frozen = @load_paths_added = false - - super(name, req) - end - - def add_load_paths - self.class.add_frozen_gem_path - return if @loaded || @load_paths_added - if framework_gem? - @load_paths_added = @loaded = @frozen = true - return - end - gem self - @spec = Gem.loaded_specs[name] - @frozen = @spec.loaded_from.include?(self.class.unpacked_path) if @spec - @load_paths_added = true - rescue Gem::LoadError - end - - def dependencies - return [] if framework_gem? - return [] unless installed? - specification.dependencies.reject do |dependency| - dependency.type == :development - end.map do |dependency| - GemDependency.new(dependency.name, :requirement => dependency.version_requirements) - end - end - - def specification - # code repeated from Gem.activate. Find a matching spec, or the currently loaded version. - # error out if loaded version and requested version are incompatible. - @spec ||= begin - matches = Gem.source_index.search(self) - matches << @@framework_gems[name] if framework_gem? - if Gem.loaded_specs[name] then - # This gem is already loaded. If the currently loaded gem is not in the - # list of candidate gems, then we have a version conflict. - existing_spec = Gem.loaded_specs[name] - unless matches.any? { |spec| spec.version == existing_spec.version } then - raise Gem::Exception, - "can't activate #{@dep}, already activated #{existing_spec.full_name}" - end - # we're stuck with it, so change to match - version_requirements = Gem::Requirement.create("=#{existing_spec.version}") - existing_spec - else - # new load - matches.last - end - end - end - - def requirement - r = version_requirements - (r == Gem::Requirement.default) ? nil : r - end - - def built? - # TODO: If Rubygems ever gives us a way to detect this, we should use it - false - end - - def framework_gem? - @@framework_gems.has_key?(name) - end - - def frozen? - @frozen ||= vendor_rails? || vendor_gem? - end - - def installed? - Gem.loaded_specs.keys.include?(name) - end - - def load_paths_added? - # always try to add load paths - even if a gem is loaded, it may not - # be a compatible version (ie random_gem 0.4 is loaded and a later spec - # needs >= 0.5 - gem 'random_gem' will catch this and error out) - @load_paths_added - end - - def loaded? - @loaded ||= begin - if vendor_rails? - true - elsif specification.nil? - false - else - # check if the gem is loaded by inspecting $" - # specification.files lists all the files contained in the gem - gem_files = specification.files - # select only the files contained in require_paths - typically in bin and lib - require_paths_regexp = Regexp.new("^(#{specification.require_paths*'|'})/") - gem_lib_files = gem_files.select { |f| require_paths_regexp.match(f) } - # chop the leading directory off - a typical file might be in - # lib/gem_name/file_name.rb, but it will be 'require'd as gem_name/file_name.rb - gem_lib_files.map! { |f| f.split('/', 2)[1] } - # if any of the files from the above list appear in $", the gem is assumed to - # have been loaded - !(gem_lib_files & $").empty? - end - end - end - - def vendor_rails? - Gem.loaded_specs.has_key?(name) && Gem.loaded_specs[name].loaded_from.empty? - end - - def vendor_gem? - specification && File.exists?(unpacked_gem_directory) - end - - def build - require 'rails/gem_builder' - unless built? - return unless File.exists?(unpacked_specification_filename) - spec = YAML::load_file(unpacked_specification_filename) - Rails::GemBuilder.new(spec, unpacked_gem_directory).build_extensions - puts "Built gem: '#{unpacked_gem_directory}'" - end - dependencies.each { |dep| dep.build } - end - - def install - unless installed? - cmd = "#{gem_command} #{install_command.join(' ')}" - puts cmd - puts %x(#{cmd}) - end - end - - def load - return if @loaded || @load_paths_added == false - require(@lib || name) unless @lib == false - @loaded = true - rescue LoadError - puts $!.to_s - $!.backtrace.each { |b| puts b } - end - - def refresh - Rails::VendorGemSourceIndex.silence_spec_warnings = true - real_gems = Gem.source_index.installed_source_index - exact_dep = Gem::Dependency.new(name, "= #{specification.version}") - matches = real_gems.search(exact_dep) - installed_spec = matches.first - if frozen? - if installed_spec - # we have a real copy - # get a fresh spec - matches should only have one element - # note that there is no reliable method to check that the loaded - # spec is the same as the copy from real_gems - Gem.activate changes - # some of the fields - real_spec = Gem::Specification.load(matches.first.loaded_from) - write_specification(real_spec) - puts "Reloaded specification for #{name} from installed gems." - else - # the gem isn't installed locally - write out our current specs - write_specification(specification) - puts "Gem #{name} not loaded locally - writing out current spec." - end - else - if framework_gem? - puts "Gem directory for #{name} not found - check if it's loading before rails." - else - puts "Something bad is going on - gem directory not found for #{name}." - end - end - end - - def unpack(options={}) - unless frozen? || framework_gem? - FileUtils.mkdir_p unpack_base - Dir.chdir unpack_base do - Gem::GemRunner.new.run(unpack_command) - end - # Gem.activate changes the spec - get the original - real_spec = Gem::Specification.load(specification.loaded_from) - write_specification(real_spec) - end - dependencies.each { |dep| dep.unpack } if options[:recursive] - end - - def write_specification(spec) - # copy the gem's specification into GEMDIR/.specification so that - # we can access information about the gem on deployment systems - # without having the gem installed - File.open(unpacked_specification_filename, 'w') do |file| - file.puts spec.to_yaml - end - end - - def ==(other) - self.name == other.name && self.requirement == other.requirement - end - alias_method :"eql?", :"==" - - private - - def gem_command - case RUBY_PLATFORM - when /win32/ - 'gem.bat' - when /java/ - 'jruby -S gem' - else - 'gem' - end - end - - def install_command - cmd = %w(install) << name - cmd << "--version" << %("#{requirement.to_s}") if requirement - cmd << "--source" << @source if @source - cmd - end - - def unpack_command - cmd = %w(unpack) << name - cmd << "--version" << "= "+specification.version.to_s if requirement - cmd - end - - def unpack_base - Rails::GemDependency.unpacked_path - end - - def unpacked_gem_directory - File.join(unpack_base, specification.full_name) - end - - def unpacked_specification_filename - File.join(unpacked_gem_directory, '.specification') - end - - end -end diff --git a/vendor/rails/railties/lib/rails/plugin.rb b/vendor/rails/railties/lib/rails/plugin.rb deleted file mode 100644 index 80deb73..0000000 --- a/vendor/rails/railties/lib/rails/plugin.rb +++ /dev/null @@ -1,167 +0,0 @@ -module Rails - # The Plugin class should be an object which provides the following methods: - # - # * +name+ - Used during initialisation to order the plugin (based on name and - # the contents of <tt>config.plugins</tt>). - # * +valid?+ - Returns true if this plugin can be loaded. - # * +load_paths+ - Each path within the returned array will be added to the <tt>$LOAD_PATH</tt>. - # * +load+ - Finally 'load' the plugin. - # - # These methods are expected by the Rails::Plugin::Locator and Rails::Plugin::Loader classes. - # The default implementation returns the <tt>lib</tt> directory as its <tt>load_paths</tt>, - # and evaluates <tt>init.rb</tt> when <tt>load</tt> is called. - # - # You can also inspect the about.yml data programmatically: - # - # plugin = Rails::Plugin.new(path_to_my_plugin) - # plugin.about["author"] # => "James Adam" - # plugin.about["url"] # => "http://interblah.net" - class Plugin - include Comparable - - attr_reader :directory, :name - - def initialize(directory) - @directory = directory - @name = File.basename(@directory) rescue nil - @loaded = false - end - - def valid? - File.directory?(directory) && (has_app_directory? || has_lib_directory? || has_init_file?) - end - - # Returns a list of paths this plugin wishes to make available in <tt>$LOAD_PATH</tt>. - def load_paths - report_nonexistant_or_empty_plugin! unless valid? - - returning [] do |load_paths| - load_paths << lib_path if has_lib_directory? - load_paths << app_paths if has_app_directory? - end.flatten - end - - # Evaluates a plugin's init.rb file. - def load(initializer) - return if loaded? - report_nonexistant_or_empty_plugin! unless valid? - evaluate_init_rb(initializer) - @loaded = true - end - - def loaded? - @loaded - end - - def <=>(other_plugin) - name <=> other_plugin.name - end - - def about - @about ||= load_about_information - end - - # Engines are plugins with an app/ directory. - def engine? - has_app_directory? - end - - # Returns true if the engine ships with a routing file - def routed? - File.exist?(routing_file) - end - - - def view_path - File.join(directory, 'app', 'views') - end - - def controller_path - File.join(directory, 'app', 'controllers') - end - - def metal_path - File.join(directory, 'app', 'metal') - end - - def routing_file - File.join(directory, 'config', 'routes.rb') - end - - - private - def load_about_information - about_yml_path = File.join(@directory, "about.yml") - parsed_yml = File.exist?(about_yml_path) ? YAML.load(File.read(about_yml_path)) : {} - parsed_yml || {} - rescue Exception - {} - end - - def report_nonexistant_or_empty_plugin! - raise LoadError, "Can not find the plugin named: #{name}" - end - - - def app_paths - [ File.join(directory, 'app', 'models'), File.join(directory, 'app', 'helpers'), controller_path, metal_path ] - end - - def lib_path - File.join(directory, 'lib') - end - - def classic_init_path - File.join(directory, 'init.rb') - end - - def gem_init_path - File.join(directory, 'rails', 'init.rb') - end - - def init_path - File.file?(gem_init_path) ? gem_init_path : classic_init_path - end - - - def has_app_directory? - File.directory?(File.join(directory, 'app')) - end - - def has_lib_directory? - File.directory?(lib_path) - end - - def has_init_file? - File.file?(init_path) - end - - - def evaluate_init_rb(initializer) - if has_init_file? - silence_warnings do - # Allow plugins to reference the current configuration object - config = initializer.configuration - - eval(IO.read(init_path), binding, init_path) - end - end - end - end - - # This Plugin subclass represents a Gem plugin. Although RubyGems has already - # taken care of $LOAD_PATHs, it exposes its load_paths to add them - # to Dependencies.load_paths. - class GemPlugin < Plugin - # Initialize this plugin from a Gem::Specification. - def initialize(spec, gem) - directory = spec.full_gem_path - super(directory) - @name = spec.name - end - - def init_path - File.join(directory, 'rails', 'init.rb') - end - end -end diff --git a/vendor/rails/railties/lib/rails/plugin/loader.rb b/vendor/rails/railties/lib/rails/plugin/loader.rb deleted file mode 100644 index 66e01d7..0000000 --- a/vendor/rails/railties/lib/rails/plugin/loader.rb +++ /dev/null @@ -1,191 +0,0 @@ -require "rails/plugin" - -module Rails - class Plugin - class Loader - attr_reader :initializer - - # Creates a new Plugin::Loader instance, associated with the given - # Rails::Initializer. This default implementation automatically locates - # all plugins, and adds all plugin load paths, when it is created. The plugins - # are then fully loaded (init.rb is evaluated) when load_plugins is called. - # - # It is the loader's responsibility to ensure that only the plugins specified - # in the configuration are actually loaded, and that the order defined - # is respected. - def initialize(initializer) - @initializer = initializer - end - - # Returns the plugins to be loaded, in the order they should be loaded. - def plugins - @plugins ||= all_plugins.select { |plugin| should_load?(plugin) }.sort { |p1, p2| order_plugins(p1, p2) } - end - - # Returns the plugins that are in engine-form (have an app/ directory) - def engines - @engines ||= plugins.select(&:engine?) - end - - # Returns all the plugins that could be found by the current locators. - def all_plugins - @all_plugins ||= locate_plugins - @all_plugins - end - - def load_plugins - plugins.each do |plugin| - plugin.load(initializer) - register_plugin_as_loaded(plugin) - end - - configure_engines - - ensure_all_registered_plugins_are_loaded! - end - - # Adds the load paths for every plugin into the $LOAD_PATH. Plugin load paths are - # added *after* the application's <tt>lib</tt> directory, to ensure that an application - # can always override code within a plugin. - # - # Plugin load paths are also added to Dependencies.load_paths, and Dependencies.load_once_paths. - def add_plugin_load_paths - plugins.each do |plugin| - plugin.load_paths.each do |path| - $LOAD_PATH.insert(application_lib_index + 1, path) - - ActiveSupport::Dependencies.load_paths << path - - unless configuration.reload_plugins? - ActiveSupport::Dependencies.load_once_paths << path - end - end - end - - $LOAD_PATH.uniq! - end - - def engine_metal_paths - engines.collect(&:metal_path) - end - - protected - def configure_engines - if engines.any? - add_engine_routing_configurations - add_engine_controller_paths - add_engine_view_paths - end - end - - def add_engine_routing_configurations - engines.select(&:routed?).collect(&:routing_file).each do |routing_file| - ActionController::Routing::Routes.add_configuration_file(routing_file) - end - end - - def add_engine_controller_paths - ActionController::Routing.controller_paths += engines.collect(&:controller_path) - end - - def add_engine_view_paths - # reverse it such that the last engine can overwrite view paths from the first, like with routes - paths = ActionView::PathSet.new(engines.collect(&:view_path).reverse) - ActionController::Base.view_paths.concat(paths) - ActionMailer::Base.view_paths.concat(paths) if configuration.frameworks.include?(:action_mailer) - end - - # The locate_plugins method uses each class in config.plugin_locators to - # find the set of all plugins available to this Rails application. - def locate_plugins - configuration.plugin_locators.map do |locator| - locator.new(initializer).plugins - end.flatten - # TODO: sorting based on config.plugins - end - - def register_plugin_as_loaded(plugin) - initializer.loaded_plugins << plugin - end - - def configuration - initializer.configuration - end - - def should_load?(plugin) - # uses Plugin#name and Plugin#valid? - enabled?(plugin) && plugin.valid? - end - - def order_plugins(plugin_a, plugin_b) - if !explicit_plugin_loading_order? - plugin_a <=> plugin_b - else - if !explicitly_enabled?(plugin_a) && !explicitly_enabled?(plugin_b) - plugin_a <=> plugin_b - else - effective_order_of(plugin_a) <=> effective_order_of(plugin_b) - end - end - end - - def effective_order_of(plugin) - if explicitly_enabled?(plugin) - registered_plugin_names.index(plugin.name) - else - registered_plugin_names.index('all') - end - end - - def application_lib_index - $LOAD_PATH.index(File.join(RAILS_ROOT, 'lib')) || 0 - end - - def enabled?(plugin) - !explicit_plugin_loading_order? || registered?(plugin) - end - - def explicit_plugin_loading_order? - !registered_plugin_names.nil? - end - - def registered?(plugin) - explicit_plugin_loading_order? && registered_plugins_names_plugin?(plugin) - end - - def explicitly_enabled?(plugin) - !explicit_plugin_loading_order? || explicitly_registered?(plugin) - end - - def explicitly_registered?(plugin) - explicit_plugin_loading_order? && registered_plugin_names.include?(plugin.name) - end - - def registered_plugins_names_plugin?(plugin) - registered_plugin_names.include?(plugin.name) || registered_plugin_names.include?('all') - end - - # The plugins that have been explicitly listed with config.plugins. If this list is nil - # then it means the client does not care which plugins or in what order they are loaded, - # so we load all in alphabetical order. If it is an empty array, we load no plugins, if it is - # non empty, we load the named plugins in the order specified. - def registered_plugin_names - configuration.plugins ? configuration.plugins.map(&:to_s) : nil - end - - def loaded?(plugin_name) - initializer.loaded_plugins.detect { |plugin| plugin.name == plugin_name.to_s } - end - - def ensure_all_registered_plugins_are_loaded! - if explicit_plugin_loading_order? - if configuration.plugins.detect {|plugin| plugin != :all && !loaded?(plugin) } - missing_plugins = configuration.plugins - (plugins.map{|p| p.name.to_sym} + [:all]) - raise LoadError, "Could not locate the following plugins: #{missing_plugins.to_sentence(:locale => :en)}" - end - end - end - - end - end -end diff --git a/vendor/rails/railties/lib/rails/plugin/locator.rb b/vendor/rails/railties/lib/rails/plugin/locator.rb deleted file mode 100644 index a6fc388..0000000 --- a/vendor/rails/railties/lib/rails/plugin/locator.rb +++ /dev/null @@ -1,100 +0,0 @@ -module Rails - class Plugin - - # The Plugin::Locator class should be subclasses to provide custom plugin-finding - # abilities to Rails (i.e. loading plugins from Gems, etc). Each subclass should implement - # the <tt>located_plugins</tt> method, which return an array of Plugin objects that have been found. - class Locator - include Enumerable - - attr_reader :initializer - - def initialize(initializer) - @initializer = initializer - end - - # This method should return all the plugins which this Plugin::Locator can find - # These will then be used by the current Plugin::Loader, which is responsible for actually - # loading the plugins themselves - def plugins - raise "The `plugins' method must be defined by concrete subclasses of #{self.class}" - end - - def each(&block) - plugins.each(&block) - end - - def plugin_names - plugins.map(&:name) - end - end - - # The Rails::Plugin::FileSystemLocator will try to locate plugins by examining the directories - # in the paths given in configuration.plugin_paths. Any plugins that can be found are returned - # in a list. - # - # The criteria for a valid plugin in this case is found in Rails::Plugin#valid?, although - # other subclasses of Rails::Plugin::Locator can of course use different conditions. - class FileSystemLocator < Locator - - # Returns all the plugins which can be loaded in the filesystem, under the paths given - # by configuration.plugin_paths. - def plugins - initializer.configuration.plugin_paths.flatten.inject([]) do |plugins, path| - plugins.concat locate_plugins_under(path) - plugins - end.flatten - end - - private - - # Attempts to create a plugin from the given path. If the created plugin is valid? - # (see Rails::Plugin#valid?) then the plugin instance is returned; otherwise nil. - def create_plugin(path) - plugin = Rails::Plugin.new(path) - plugin.valid? ? plugin : nil - end - - # This starts at the base path looking for valid plugins (see Rails::Plugin#valid?). - # Since plugins can be nested arbitrarily deep within an unspecified number of intermediary - # directories, this method runs recursively until it finds a plugin directory, e.g. - # - # locate_plugins_under('vendor/plugins/acts/acts_as_chunky_bacon') - # => <Rails::Plugin name: 'acts_as_chunky_bacon' ... > - # - def locate_plugins_under(base_path) - Dir.glob(File.join(base_path, '*')).sort.inject([]) do |plugins, path| - if plugin = create_plugin(path) - plugins << plugin - elsif File.directory?(path) - plugins.concat locate_plugins_under(path) - end - plugins - end - end - end - - # The GemLocator scans all the loaded RubyGems, looking for gems with - # a <tt>rails/init.rb</tt> file. - class GemLocator < Locator - def plugins - gem_index = initializer.configuration.gems.inject({}) { |memo, gem| memo.update gem.specification => gem } - specs = gem_index.keys - specs += Gem.loaded_specs.values.select do |spec| - spec.loaded_from && # prune stubs - File.exist?(File.join(spec.full_gem_path, "rails", "init.rb")) - end - specs.compact! - - require "rubygems/dependency_list" - - deps = Gem::DependencyList.new - deps.add(*specs) unless specs.empty? - - deps.dependency_order.collect do |spec| - Rails::GemPlugin.new(spec, gem_index[spec]) - end - end - end - end -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails/rack.rb b/vendor/rails/railties/lib/rails/rack.rb deleted file mode 100644 index 9705f65..0000000 --- a/vendor/rails/railties/lib/rails/rack.rb +++ /dev/null @@ -1,8 +0,0 @@ -module Rails - module Rack - autoload :Debugger, "rails/rack/debugger" - autoload :LogTailer, "rails/rack/log_tailer" - autoload :Metal, "rails/rack/metal" - autoload :Static, "rails/rack/static" - end -end diff --git a/vendor/rails/railties/lib/rails/rack/debugger.rb b/vendor/rails/railties/lib/rails/rack/debugger.rb deleted file mode 100644 index aa2711c..0000000 --- a/vendor/rails/railties/lib/rails/rack/debugger.rb +++ /dev/null @@ -1,21 +0,0 @@ -module Rails - module Rack - class Debugger - def initialize(app) - @app = app - - require_library_or_gem 'ruby-debug' - ::Debugger.start - ::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings) - puts "=> Debugger enabled" - rescue Exception - puts "You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'" - exit - end - - def call(env) - @app.call(env) - end - end - end -end diff --git a/vendor/rails/railties/lib/rails/rack/log_tailer.rb b/vendor/rails/railties/lib/rails/rack/log_tailer.rb deleted file mode 100644 index a237cee..0000000 --- a/vendor/rails/railties/lib/rails/rack/log_tailer.rb +++ /dev/null @@ -1,35 +0,0 @@ -module Rails - module Rack - class LogTailer - EnvironmentLog = "#{File.expand_path(Rails.root)}/log/#{Rails.env}.log" - - def initialize(app, log = nil) - @app = app - - path = Pathname.new(log || EnvironmentLog).cleanpath - @cursor = ::File.size(path) - @last_checked = Time.now.to_f - - @file = ::File.open(path, 'r') - end - - def call(env) - response = @app.call(env) - tail_log - response - end - - def tail_log - @file.seek @cursor - - mod = @file.mtime.to_f - if mod > @last_checked - contents = @file.read - @last_checked = mod - @cursor += contents.size - $stdout.print contents - end - end - end - end -end diff --git a/vendor/rails/railties/lib/rails/rack/metal.rb b/vendor/rails/railties/lib/rails/rack/metal.rb deleted file mode 100644 index adc43da..0000000 --- a/vendor/rails/railties/lib/rails/rack/metal.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'active_support/ordered_hash' - -module Rails - module Rack - class Metal - NotFoundResponse = [404, {}, []].freeze - NotFound = lambda { NotFoundResponse } - - cattr_accessor :metal_paths - self.metal_paths = ["#{Rails.root}/app/metal"] - cattr_accessor :requested_metals - - def self.metals - matcher = /#{Regexp.escape('/app/metal/')}(.*)\.rb\Z/ - metal_glob = metal_paths.map{ |base| "#{base}/**/*.rb" } - all_metals = {} - - metal_glob.each do |glob| - Dir[glob].sort.map do |file| - file = file.match(matcher)[1] - all_metals[file.camelize] = file - end - end - - load_list = requested_metals || all_metals.keys - - load_list.map do |requested_metal| - if metal = all_metals[requested_metal] - require metal - requested_metal.constantize - end - end.compact - end - - def initialize(app) - @app = app - @metals = ActiveSupport::OrderedHash.new - self.class.metals.each { |app| @metals[app] = true } - freeze - end - - def call(env) - @metals.keys.each do |app| - result = app.call(env) - return result unless result[0].to_i == 404 - end - @app.call(env) - end - end - end -end diff --git a/vendor/rails/railties/lib/rails/rack/static.rb b/vendor/rails/railties/lib/rails/rack/static.rb deleted file mode 100644 index f07c6be..0000000 --- a/vendor/rails/railties/lib/rails/rack/static.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'rack/utils' - -module Rails - module Rack - class Static - FILE_METHODS = %w(GET HEAD).freeze - - def initialize(app) - @app = app - @file_server = ::Rack::File.new(File.join(RAILS_ROOT, "public")) - end - - def call(env) - path = env['PATH_INFO'].chomp('/') - method = env['REQUEST_METHOD'] - - if FILE_METHODS.include?(method) - if file_exist?(path) - return @file_server.call(env) - else - cached_path = directory_exist?(path) ? "#{path}/index" : path - cached_path += ::ActionController::Base.page_cache_extension - - if file_exist?(cached_path) - env['PATH_INFO'] = cached_path - return @file_server.call(env) - end - end - end - - @app.call(env) - end - - private - def file_exist?(path) - full_path = File.join(@file_server.root, ::Rack::Utils.unescape(path)) - File.file?(full_path) && File.readable?(full_path) - end - - def directory_exist?(path) - full_path = File.join(@file_server.root, ::Rack::Utils.unescape(path)) - File.directory?(full_path) && File.readable?(full_path) - end - end - end -end diff --git a/vendor/rails/railties/lib/rails/vendor_gem_source_index.rb b/vendor/rails/railties/lib/rails/vendor_gem_source_index.rb deleted file mode 100644 index 5b7721f..0000000 --- a/vendor/rails/railties/lib/rails/vendor_gem_source_index.rb +++ /dev/null @@ -1,140 +0,0 @@ -require 'rubygems' -require 'yaml' - -module Rails - - class VendorGemSourceIndex - # VendorGemSourceIndex acts as a proxy for the Gem source index, allowing - # gems to be loaded from vendor/gems. Rather than the standard gem repository format, - # vendor/gems contains unpacked gems, with YAML specifications in .specification in - # each gem directory. - include Enumerable - - attr_reader :installed_source_index - attr_reader :vendor_source_index - - @@silence_spec_warnings = false - - def self.silence_spec_warnings - @@silence_spec_warnings - end - - def self.silence_spec_warnings=(v) - @@silence_spec_warnings = v - end - - def initialize(installed_index, vendor_dir=Rails::GemDependency.unpacked_path) - @installed_source_index = installed_index - @vendor_dir = vendor_dir - refresh! - end - - def refresh! - # reload the installed gems - @installed_source_index.refresh! - vendor_gems = {} - - # handle vendor Rails gems - they are identified by having loaded_from set to "" - # we add them manually to the list, so that other gems can find them via dependencies - Gem.loaded_specs.each do |n, s| - next unless s.loaded_from.empty? - vendor_gems[s.full_name] = s - end - - # load specifications from vendor/gems - Dir[File.join(Rails::GemDependency.unpacked_path, '*')].each do |d| - dir_name = File.basename(d) - dir_version = version_for_dir(dir_name) - spec = load_specification(d) - if spec - if spec.full_name != dir_name - # mismatched directory name and gem spec - produced by 2.1.0-era unpack code - if dir_version - # fix the spec version - this is not optimal (spec.files may be wrong) - # but it's better than breaking apps. Complain to remind users to get correct specs. - # use ActiveSupport::Deprecation.warn, as the logger is not set yet - $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems has a mismatched specification file."+ - " Run 'rake gems:refresh_specs' to fix this.") unless @@silence_spec_warnings - spec.version = dir_version - else - $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems is not in a versioned directory"+ - "(should be #{spec.full_name}).") unless @@silence_spec_warnings - # continue, assume everything is OK - end - end - else - # no spec - produced by early-2008 unpack code - # emulate old behavior, and complain. - $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems has no specification file."+ - " Run 'rake gems:refresh_specs' to fix this.") unless @@silence_spec_warnings - if dir_version - spec = Gem::Specification.new - spec.version = dir_version - spec.require_paths = ['lib'] - ext_path = File.join(d, 'ext') - spec.require_paths << 'ext' if File.exist?(ext_path) - spec.name = /^(.*)-[^-]+$/.match(dir_name)[1] - files = ['lib'] - # set files to everything in lib/ - files += Dir[File.join(d, 'lib', '*')].map { |v| v.gsub(/^#{d}\//, '') } - files += Dir[File.join(d, 'ext', '*')].map { |v| v.gsub(/^#{d}\//, '') } if ext_path - spec.files = files - else - $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems not in a versioned directory."+ - " Giving up.") unless @@silence_spec_warnings - next - end - end - spec.loaded_from = File.join(d, '.specification') - # finally, swap out full_gem_path - # it would be better to use a Gem::Specification subclass, but the YAML loads an explicit class - class << spec - def full_gem_path - path = File.join installation_path, full_name - return path if File.directory? path - File.join installation_path, original_name - end - end - vendor_gems[File.basename(d)] = spec - end - @vendor_source_index = Gem::SourceIndex.new(vendor_gems) - end - - def version_for_dir(d) - matches = /-([^-]+)$/.match(d) - Gem::Version.new(matches[1]) if matches - end - - def load_specification(gem_dir) - spec_file = File.join(gem_dir, '.specification') - YAML.load_file(spec_file) if File.exist?(spec_file) - end - - def find_name(*args) - @installed_source_index.find_name(*args) + @vendor_source_index.find_name(*args) - end - - def search(*args) - # look for vendor gems, and then installed gems - later elements take priority - @installed_source_index.search(*args) + @vendor_source_index.search(*args) - end - - def each(&block) - @vendor_source_index.each(&block) - @installed_source_index.each(&block) - end - - def add_spec(spec) - @vendor_source_index.add_spec spec - end - - def remove_spec(spec) - @vendor_source_index.remove_spec spec - end - - def size - @vendor_source_index.size + @installed_source_index.size - end - - end -end diff --git a/vendor/rails/railties/lib/rails/version.rb b/vendor/rails/railties/lib/rails/version.rb deleted file mode 100644 index 99c7516..0000000 --- a/vendor/rails/railties/lib/rails/version.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Rails - module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 2 - - STRING = [MAJOR, MINOR, TINY].join('.') - end -end diff --git a/vendor/rails/railties/lib/rails_generator.rb b/vendor/rails/railties/lib/rails_generator.rb deleted file mode 100644 index 9f0ffc1..0000000 --- a/vendor/rails/railties/lib/rails_generator.rb +++ /dev/null @@ -1,43 +0,0 @@ -#-- -# Copyright (c) 2004 Jeremy Kemper -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ - -$:.unshift(File.dirname(__FILE__)) -$:.unshift(File.dirname(__FILE__) + "/../../activesupport/lib") - -begin - require 'active_support' -rescue LoadError - require 'rubygems' - gem 'activesupport' -end - -require 'rails_generator/base' -require 'rails_generator/lookup' -require 'rails_generator/commands' - -Rails::Generator::Base.send(:include, Rails::Generator::Lookup) -Rails::Generator::Base.send(:include, Rails::Generator::Commands) - -# Set up a default logger for convenience. -require 'rails_generator/simple_logger' -Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new(STDOUT) diff --git a/vendor/rails/railties/lib/rails_generator/base.rb b/vendor/rails/railties/lib/rails_generator/base.rb deleted file mode 100644 index aa7081f..0000000 --- a/vendor/rails/railties/lib/rails_generator/base.rb +++ /dev/null @@ -1,266 +0,0 @@ -require File.dirname(__FILE__) + '/options' -require File.dirname(__FILE__) + '/manifest' -require File.dirname(__FILE__) + '/spec' -require File.dirname(__FILE__) + '/generated_attribute' - -module Rails - # Rails::Generator is a code generation platform tailored for the Rails - # web application framework. Generators are easily invoked within Rails - # applications to add and remove components such as models and controllers. - # New generators are easy to create and may be distributed as RubyGems, - # tarballs, or Rails plugins for inclusion system-wide, per-user, - # or per-application. - # - # For actual examples see the rails_generator/generators directory in the - # Rails source (or the +railties+ directory if you have frozen the Rails - # source in your application). - # - # Generators may subclass other generators to provide variations that - # require little or no new logic but replace the template files. - # - # For a RubyGem, put your generator class and templates in the +lib+ - # directory. For a Rails plugin, make a +generators+ directory at the - # root of your plugin. - # - # The layout of generator files can be seen in the built-in - # +controller+ generator: - # - # generators/ - # components/ - # controller/ - # controller_generator.rb - # templates/ - # controller.rb - # functional_test.rb - # helper.rb - # view.html.erb - # - # The directory name (+controller+) matches the name of the generator file - # (controller_generator.rb) and class (ControllerGenerator). The files - # that will be copied or used as templates are stored in the +templates+ - # directory. - # - # The filenames of the templates don't matter, but choose something that - # will be self-explanatory since you will be referencing these in the - # +manifest+ method inside your generator subclass. - # - # - module Generator - class GeneratorError < StandardError; end - class UsageError < GeneratorError; end - - - # The base code generator is bare-bones. It sets up the source and - # destination paths and tells the logger whether to keep its trap shut. - # - # It's useful for copying files such as stylesheets, images, or - # javascripts. - # - # For more comprehensive template-based passive code generation with - # arguments, you'll want Rails::Generator::NamedBase. - # - # Generators create a manifest of the actions they perform then hand - # the manifest to a command which replays the actions to do the heavy - # lifting (such as checking for existing files or creating directories - # if needed). Create, destroy, and list commands are included. Since a - # single manifest may be used by any command, creating new generators is - # as simple as writing some code templates and declaring what you'd like - # to do with them. - # - # The manifest method must be implemented by subclasses, returning a - # Rails::Generator::Manifest. The +record+ method is provided as a - # convenience for manifest creation. Example: - # - # class StylesheetGenerator < Rails::Generator::Base - # def manifest - # record do |m| - # m.directory('public/stylesheets') - # m.file('application.css', 'public/stylesheets/application.css') - # end - # end - # end - # - # See Rails::Generator::Commands::Create for a list of methods available - # to the manifest. - class Base - include Options - - # Declare default options for the generator. These options - # are inherited to subclasses. - default_options :collision => :ask, :quiet => false - - # A logger instance available everywhere in the generator. - cattr_accessor :logger - - # Every generator that is dynamically looked up is tagged with a - # Spec describing where it was found. - class_inheritable_accessor :spec - - attr_reader :source_root, :destination_root, :args - - def initialize(runtime_args, runtime_options = {}) - @args = runtime_args - parse!(@args, runtime_options) - - # Derive source and destination paths. - @source_root = options[:source] || File.join(spec.path, 'templates') - if options[:destination] - @destination_root = options[:destination] - elsif defined? ::RAILS_ROOT - @destination_root = ::RAILS_ROOT - end - - # Silence the logger if requested. - logger.quiet = options[:quiet] - - # Raise usage error if help is requested. - usage if options[:help] - end - - # Generators must provide a manifest. Use the +record+ method to create - # a new manifest and record your generator's actions. - def manifest - raise NotImplementedError, "No manifest for '#{spec.name}' generator." - end - - # Return the full path from the source root for the given path. - # Example for source_root = '/source': - # source_path('some/path.rb') == '/source/some/path.rb' - # - # The given path may include a colon ':' character to indicate that - # the file belongs to another generator. This notation allows any - # generator to borrow files from another. Example: - # source_path('model:fixture.yml') = '/model/source/path/fixture.yml' - def source_path(relative_source) - # Check whether we're referring to another generator's file. - name, path = relative_source.split(':', 2) - - # If not, return the full path to our source file. - if path.nil? - File.join(source_root, name) - - # Otherwise, ask our referral for the file. - else - # FIXME: this is broken, though almost always true. Others' - # source_root are not necessarily the templates dir. - File.join(self.class.lookup(name).path, 'templates', path) - end - end - - # Return the full path from the destination root for the given path. - # Example for destination_root = '/dest': - # destination_path('some/path.rb') == '/dest/some/path.rb' - def destination_path(relative_destination) - File.join(destination_root, relative_destination) - end - - def after_generate - end - - protected - # Convenience method for generator subclasses to record a manifest. - def record - Rails::Generator::Manifest.new(self) { |m| yield m } - end - - # Override with your own usage banner. - def banner - "Usage: #{$0} #{spec.name} [options]" - end - - # Read USAGE from file in generator base path. - def usage_message - File.read(File.join(spec.path, 'USAGE')) rescue '' - end - end - - - # The base generator for named components: models, controllers, mailers, - # etc. The target name is taken as the first argument and inflected to - # singular, plural, class, file, and table forms for your convenience. - # The remaining arguments are aliased to +actions+ as an array for - # controller and mailer convenience. - # - # Several useful local variables and methods are populated in the - # +initialize+ method. See below for a list of Attributes and - # External Aliases available to both the manifest and to all templates. - # - # If no name is provided, the generator raises a usage error with content - # optionally read from the USAGE file in the generator's base path. - # - # For example, the +controller+ generator takes the first argument as - # the name of the class and subsequent arguments as the names of - # actions to be generated: - # - # ./script/generate controller Article index new create - # - # See Rails::Generator::Base for a discussion of manifests, - # Rails::Generator::Commands::Create for methods available to the manifest, - # and Rails::Generator for a general discussion of generators. - class NamedBase < Base - attr_reader :name, :class_name, :singular_name, :plural_name, :table_name - attr_reader :class_path, :file_path, :class_nesting, :class_nesting_depth - alias_method :file_name, :singular_name - alias_method :actions, :args - - def initialize(runtime_args, runtime_options = {}) - super - - # Name argument is required. - usage if runtime_args.empty? - - @args = runtime_args.dup - base_name = @args.shift - assign_names!(base_name) - end - - protected - # Override with your own usage banner. - def banner - "Usage: #{$0} #{spec.name} #{spec.name.camelize}Name [options]" - end - - def attributes - @attributes ||= @args.collect do |attribute| - Rails::Generator::GeneratedAttribute.new(*attribute.split(":")) - end - end - - - private - def assign_names!(name) - @name = name - base_name, @class_path, @file_path, @class_nesting, @class_nesting_depth = extract_modules(@name) - @class_name_without_nesting, @singular_name, @plural_name = inflect_names(base_name) - @table_name = (!defined?(ActiveRecord::Base) || ActiveRecord::Base.pluralize_table_names) ? plural_name : singular_name - @table_name.gsub! '/', '_' - if @class_nesting.empty? - @class_name = @class_name_without_nesting - else - @table_name = @class_nesting.underscore << "_" << @table_name - @class_name = "#{@class_nesting}::#{@class_name_without_nesting}" - end - end - - # Extract modules from filesystem-style or ruby-style path: - # good/fun/stuff - # Good::Fun::Stuff - # produce the same results. - def extract_modules(name) - modules = name.include?('/') ? name.split('/') : name.split('::') - name = modules.pop - path = modules.map { |m| m.underscore } - file_path = (path + [name.underscore]).join('/') - nesting = modules.map { |m| m.camelize }.join('::') - [name, path, file_path, nesting, modules.size] - end - - def inflect_names(name) - camel = name.camelize - under = camel.underscore - plural = under.pluralize - [camel, under, plural] - end - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/commands.rb b/vendor/rails/railties/lib/rails_generator/commands.rb deleted file mode 100644 index b684dc9..0000000 --- a/vendor/rails/railties/lib/rails_generator/commands.rb +++ /dev/null @@ -1,621 +0,0 @@ -require 'delegate' -require 'optparse' -require 'fileutils' -require 'tempfile' -require 'erb' - -module Rails - module Generator - module Commands - # Here's a convenient way to get a handle on generator commands. - # Command.instance('destroy', my_generator) instantiates a Destroy - # delegate of my_generator ready to do your dirty work. - def self.instance(command, generator) - const_get(command.to_s.camelize).new(generator) - end - - # Even more convenient access to commands. Include Commands in - # the generator Base class to get a nice #command instance method - # which returns a delegate for the requested command. - def self.included(base) - base.send(:define_method, :command) do |command| - Commands.instance(command, self) - end - end - - - # Generator commands delegate Rails::Generator::Base and implement - # a standard set of actions. Their behavior is defined by the way - # they respond to these actions: Create brings life; Destroy brings - # death; List passively observes. - # - # Commands are invoked by replaying (or rewinding) the generator's - # manifest of actions. See Rails::Generator::Manifest and - # Rails::Generator::Base#manifest method that generator subclasses - # are required to override. - # - # Commands allows generators to "plug in" invocation behavior, which - # corresponds to the GoF Strategy pattern. - class Base < DelegateClass(Rails::Generator::Base) - # Replay action manifest. RewindBase subclass rewinds manifest. - def invoke! - manifest.replay(self) - after_generate - end - - def dependency(generator_name, args, runtime_options = {}) - logger.dependency(generator_name) do - self.class.new(instance(generator_name, args, full_options(runtime_options))).invoke! - end - end - - # Does nothing for all commands except Create. - def class_collisions(*class_names) - end - - # Does nothing for all commands except Create. - def readme(*args) - end - - protected - def current_migration_number - Dir.glob("#{RAILS_ROOT}/#{@migration_directory}/[0-9]*_*.rb").inject(0) do |max, file_path| - n = File.basename(file_path).split('_', 2).first.to_i - if n > max then n else max end - end - end - - def next_migration_number - current_migration_number + 1 - end - - def migration_directory(relative_path) - directory(@migration_directory = relative_path) - end - - def existing_migrations(file_name) - Dir.glob("#{@migration_directory}/[0-9]*_*.rb").grep(/[0-9]+_#{file_name}.rb$/) - end - - def migration_exists?(file_name) - not existing_migrations(file_name).empty? - end - - def next_migration_string(padding = 3) - if ActiveRecord::Base.timestamped_migrations - Time.now.utc.strftime("%Y%m%d%H%M%S") - else - "%.#{padding}d" % next_migration_number - end - end - - def gsub_file(relative_destination, regexp, *args, &block) - path = destination_path(relative_destination) - content = File.read(path).gsub(regexp, *args, &block) - File.open(path, 'wb') { |file| file.write(content) } - end - - private - # Ask the user interactively whether to force collision. - def force_file_collision?(destination, src, dst, file_options = {}, &block) - $stdout.print "overwrite #{destination}? (enter \"h\" for help) [Ynaqdh] " - case $stdin.gets.chomp - when /\Ad\z/i - Tempfile.open(File.basename(destination), File.dirname(dst)) do |temp| - temp.write render_file(src, file_options, &block) - temp.rewind - $stdout.puts `#{diff_cmd} "#{dst}" "#{temp.path}"` - end - puts "retrying" - raise 'retry diff' - when /\Aa\z/i - $stdout.puts "forcing #{spec.name}" - options[:collision] = :force - when /\Aq\z/i - $stdout.puts "aborting #{spec.name}" - raise SystemExit - when /\An\z/i then :skip - when /\Ay\z/i then :force - else - $stdout.puts <<-HELP -Y - yes, overwrite -n - no, do not overwrite -a - all, overwrite this and all others -q - quit, abort -d - diff, show the differences between the old and the new -h - help, show this help -HELP - raise 'retry' - end - rescue - retry - end - - def diff_cmd - ENV['RAILS_DIFF'] || 'diff -u' - end - - def render_template_part(template_options) - # Getting Sandbox to evaluate part template in it - part_binding = template_options[:sandbox].call.sandbox_binding - part_rel_path = template_options[:insert] - part_path = source_path(part_rel_path) - - # Render inner template within Sandbox binding - rendered_part = ERB.new(File.readlines(part_path).join, nil, '-').result(part_binding) - begin_mark = template_part_mark(template_options[:begin_mark], template_options[:mark_id]) - end_mark = template_part_mark(template_options[:end_mark], template_options[:mark_id]) - begin_mark + rendered_part + end_mark - end - - def template_part_mark(name, id) - "<!--[#{name}:#{id}]-->\n" - end - end - - # Base class for commands which handle generator actions in reverse, such as Destroy. - class RewindBase < Base - # Rewind action manifest. - def invoke! - manifest.rewind(self) - end - end - - - # Create is the premier generator command. It copies files, creates - # directories, renders templates, and more. - class Create < Base - - # Check whether the given class names are already taken by - # Ruby or Rails. In the future, expand to check other namespaces - # such as the rest of the user's app. - def class_collisions(*class_names) - path = class_names.shift - class_names.flatten.each do |class_name| - # Convert to string to allow symbol arguments. - class_name = class_name.to_s - - # Skip empty strings. - next if class_name.strip.empty? - - # Split the class from its module nesting. - nesting = class_name.split('::') - name = nesting.pop - - # Hack to limit const_defined? to non-inherited on 1.9. - extra = [] - extra << false unless Object.method(:const_defined?).arity == 1 - - # Extract the last Module in the nesting. - last = nesting.inject(Object) { |last, nest| - break unless last.const_defined?(nest, *extra) - last.const_get(nest) - } - - # If the last Module exists, check whether the given - # class exists and raise a collision if so. - if last and last.const_defined?(name.camelize, *extra) - raise_class_collision(class_name) - end - end - end - - # Copy a file from source to destination with collision checking. - # - # The file_options hash accepts :chmod and :shebang and :collision options. - # :chmod sets the permissions of the destination file: - # file 'config/empty.log', 'log/test.log', :chmod => 0664 - # :shebang sets the #!/usr/bin/ruby line for scripts - # file 'bin/generate.rb', 'script/generate', :chmod => 0755, :shebang => '/usr/bin/env ruby' - # :collision sets the collision option only for the destination file: - # file 'settings/server.yml', 'config/server.yml', :collision => :skip - # - # Collisions are handled by checking whether the destination file - # exists and either skipping the file, forcing overwrite, or asking - # the user what to do. - def file(relative_source, relative_destination, file_options = {}, &block) - # Determine full paths for source and destination files. - source = source_path(relative_source) - destination = destination_path(relative_destination) - destination_exists = File.exist?(destination) - - # If source and destination are identical then we're done. - if destination_exists and identical?(source, destination, &block) - return logger.identical(relative_destination) - end - - # Check for and resolve file collisions. - if destination_exists - - # Make a choice whether to overwrite the file. :force and - # :skip already have their mind made up, but give :ask a shot. - choice = case (file_options[:collision] || options[:collision]).to_sym #|| :ask - when :ask then force_file_collision?(relative_destination, source, destination, file_options, &block) - when :force then :force - when :skip then :skip - else raise "Invalid collision option: #{options[:collision].inspect}" - end - - # Take action based on our choice. Bail out if we chose to - # skip the file; otherwise, log our transgression and continue. - case choice - when :force then logger.force(relative_destination) - when :skip then return(logger.skip(relative_destination)) - else raise "Invalid collision choice: #{choice}.inspect" - end - - # File doesn't exist so log its unbesmirched creation. - else - logger.create relative_destination - end - - # If we're pretending, back off now. - return if options[:pretend] - - # Write destination file with optional shebang. Yield for content - # if block given so templaters may render the source file. If a - # shebang is requested, replace the existing shebang or insert a - # new one. - File.open(destination, 'wb') do |dest| - dest.write render_file(source, file_options, &block) - end - - # Optionally change permissions. - if file_options[:chmod] - FileUtils.chmod(file_options[:chmod], destination) - end - - # Optionally add file to subversion or git - system("svn add #{destination}") if options[:svn] - system("git add -v #{relative_destination}") if options[:git] - end - - # Checks if the source and the destination file are identical. If - # passed a block then the source file is a template that needs to first - # be evaluated before being compared to the destination. - def identical?(source, destination, &block) - return false if File.directory? destination - source = block_given? ? File.open(source) {|sf| yield(sf)} : IO.read(source) - destination = IO.read(destination) - source == destination - end - - # Generate a file for a Rails application using an ERuby template. - # Looks up and evaluates a template by name and writes the result. - # - # The ERB template uses explicit trim mode to best control the - # proliferation of whitespace in generated code. <%- trims leading - # whitespace; -%> trims trailing whitespace including one newline. - # - # A hash of template options may be passed as the last argument. - # The options accepted by the file are accepted as well as :assigns, - # a hash of variable bindings. Example: - # template 'foo', 'bar', :assigns => { :action => 'view' } - # - # Template is implemented in terms of file. It calls file with a - # block which takes a file handle and returns its rendered contents. - def template(relative_source, relative_destination, template_options = {}) - file(relative_source, relative_destination, template_options) do |file| - # Evaluate any assignments in a temporary, throwaway binding. - vars = template_options[:assigns] || {} - b = template_options[:binding] || binding - vars.each { |k,v| eval "#{k} = vars[:#{k}] || vars['#{k}']", b } - - # Render the source file with the temporary binding. - ERB.new(file.read, nil, '-').result(b) - end - end - - def complex_template(relative_source, relative_destination, template_options = {}) - options = template_options.dup - options[:assigns] ||= {} - options[:assigns]['template_for_inclusion'] = render_template_part(template_options) - template(relative_source, relative_destination, options) - end - - # Create a directory including any missing parent directories. - # Always skips directories which exist. - def directory(relative_path) - path = destination_path(relative_path) - if File.exist?(path) - logger.exists relative_path - else - logger.create relative_path - unless options[:pretend] - FileUtils.mkdir_p(path) - # git doesn't require adding the paths, adding the files later will - # automatically do a path add. - - # Subversion doesn't do path adds, so we need to add - # each directory individually. - # So stack up the directory tree and add the paths to - # subversion in order without recursion. - if options[:svn] - stack = [relative_path] - until File.dirname(stack.last) == stack.last # dirname('.') == '.' - stack.push File.dirname(stack.last) - end - stack.reverse_each do |rel_path| - svn_path = destination_path(rel_path) - system("svn add -N #{svn_path}") unless File.directory?(File.join(svn_path, '.svn')) - end - end - end - end - end - - # Display a README. - def readme(*relative_sources) - relative_sources.flatten.each do |relative_source| - logger.readme relative_source - puts File.read(source_path(relative_source)) unless options[:pretend] - end - end - - # When creating a migration, it knows to find the first available file in db/migrate and use the migration.rb template. - def migration_template(relative_source, relative_destination, template_options = {}) - migration_directory relative_destination - migration_file_name = template_options[:migration_file_name] || file_name - raise "Another migration is already named #{migration_file_name}: #{existing_migrations(migration_file_name).first}" if migration_exists?(migration_file_name) - template(relative_source, "#{relative_destination}/#{next_migration_string}_#{migration_file_name}.rb", template_options) - end - - def route_resources(*resources) - resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') - sentinel = 'ActionController::Routing::Routes.draw do |map|' - - logger.route "map.resources #{resource_list}" - unless options[:pretend] - gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match| - "#{match}\n map.resources #{resource_list}\n" - end - end - end - - private - def render_file(path, options = {}) - File.open(path, 'rb') do |file| - if block_given? - yield file - else - content = '' - if shebang = options[:shebang] - content << "#!#{shebang}\n" - if line = file.gets - content << "line\n" if line !~ /^#!/ - end - end - content << file.read - end - end - end - - # Raise a usage error with an informative WordNet suggestion. - # Thanks to Florian Gross (flgr). - def raise_class_collision(class_name) - message = <<end_message - The name '#{class_name}' is either already used in your application or reserved by Ruby on Rails. - Please choose an alternative and run this generator again. -end_message - if suggest = find_synonyms(class_name) - if suggest.any? - message << "\n Suggestions: \n\n" - message << suggest.join("\n") - end - end - raise UsageError, message - end - - SYNONYM_LOOKUP_URI = "http://wordnet.princeton.edu/perl/webwn?s=%s" - - # Look up synonyms on WordNet. Thanks to Florian Gross (flgr). - def find_synonyms(word) - require 'open-uri' - require 'timeout' - timeout(5) do - open(SYNONYM_LOOKUP_URI % word) do |stream| - # Grab words linked to dictionary entries as possible synonyms - data = stream.read.gsub("&nbsp;", " ").scan(/<a href="webwn.*?">([\w ]*?)<\/a>/s).uniq - end - end - rescue Exception - return nil - end - end - - - # Undo the actions performed by a generator. Rewind the action - # manifest and attempt to completely erase the results of each action. - class Destroy < RewindBase - # Remove a file if it exists and is a file. - def file(relative_source, relative_destination, file_options = {}) - destination = destination_path(relative_destination) - if File.exist?(destination) - logger.rm relative_destination - unless options[:pretend] - if options[:svn] - # If the file has been marked to be added - # but has not yet been checked in, revert and delete - if options[:svn][relative_destination] - system("svn revert #{destination}") - FileUtils.rm(destination) - else - # If the directory is not in the status list, it - # has no modifications so we can simply remove it - system("svn rm #{destination}") - end - elsif options[:git] - if options[:git][:new][relative_destination] - # file has been added, but not committed - system("git reset HEAD #{relative_destination}") - FileUtils.rm(destination) - elsif options[:git][:modified][relative_destination] - # file is committed and modified - system("git rm -f #{relative_destination}") - else - # If the directory is not in the status list, it - # has no modifications so we can simply remove it - system("git rm #{relative_destination}") - end - else - FileUtils.rm(destination) - end - end - else - logger.missing relative_destination - return - end - end - - # Templates are deleted just like files and the actions take the - # same parameters, so simply alias the file method. - alias_method :template, :file - - # Remove each directory in the given path from right to left. - # Remove each subdirectory if it exists and is a directory. - def directory(relative_path) - parts = relative_path.split('/') - until parts.empty? - partial = File.join(parts) - path = destination_path(partial) - if File.exist?(path) - if Dir[File.join(path, '*')].empty? - logger.rmdir partial - unless options[:pretend] - if options[:svn] - # If the directory has been marked to be added - # but has not yet been checked in, revert and delete - if options[:svn][relative_path] - system("svn revert #{path}") - FileUtils.rmdir(path) - else - # If the directory is not in the status list, it - # has no modifications so we can simply remove it - system("svn rm #{path}") - end - # I don't think git needs to remove directories?.. - # or maybe they have special consideration... - else - FileUtils.rmdir(path) - end - end - else - logger.notempty partial - end - else - logger.missing partial - end - parts.pop - end - end - - def complex_template(*args) - # nothing should be done here - end - - # When deleting a migration, it knows to delete every file named "[0-9]*_#{file_name}". - def migration_template(relative_source, relative_destination, template_options = {}) - migration_directory relative_destination - - migration_file_name = template_options[:migration_file_name] || file_name - unless migration_exists?(migration_file_name) - puts "There is no migration named #{migration_file_name}" - return - end - - - existing_migrations(migration_file_name).each do |file_path| - file(relative_source, file_path, template_options) - end - end - - def route_resources(*resources) - resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') - look_for = "\n map.resources #{resource_list}\n" - logger.route "map.resources #{resource_list}" - gsub_file 'config/routes.rb', /(#{look_for})/mi, '' - end - end - - - # List a generator's action manifest. - class List < Base - def dependency(generator_name, args, options = {}) - logger.dependency "#{generator_name}(#{args.join(', ')}, #{options.inspect})" - end - - def class_collisions(*class_names) - logger.class_collisions class_names.join(', ') - end - - def file(relative_source, relative_destination, options = {}) - logger.file relative_destination - end - - def template(relative_source, relative_destination, options = {}) - logger.template relative_destination - end - - def complex_template(relative_source, relative_destination, options = {}) - logger.template "#{options[:insert]} inside #{relative_destination}" - end - - def directory(relative_path) - logger.directory "#{destination_path(relative_path)}/" - end - - def readme(*args) - logger.readme args.join(', ') - end - - def migration_template(relative_source, relative_destination, options = {}) - migration_directory relative_destination - logger.migration_template file_name - end - - def route_resources(*resources) - resource_list = resources.map { |r| r.to_sym.inspect }.join(', ') - logger.route "map.resources #{resource_list}" - end - end - - # Update generator's action manifest. - class Update < Create - def file(relative_source, relative_destination, options = {}) - # logger.file relative_destination - end - - def template(relative_source, relative_destination, options = {}) - # logger.template relative_destination - end - - def complex_template(relative_source, relative_destination, template_options = {}) - - begin - dest_file = destination_path(relative_destination) - source_to_update = File.readlines(dest_file).join - rescue Errno::ENOENT - logger.missing relative_destination - return - end - - logger.refreshing "#{template_options[:insert].gsub(/\.erb/,'')} inside #{relative_destination}" - - begin_mark = Regexp.quote(template_part_mark(template_options[:begin_mark], template_options[:mark_id])) - end_mark = Regexp.quote(template_part_mark(template_options[:end_mark], template_options[:mark_id])) - - # Refreshing inner part of the template with freshly rendered part. - rendered_part = render_template_part(template_options) - source_to_update.gsub!(/#{begin_mark}.*?#{end_mark}/m, rendered_part) - - File.open(dest_file, 'w') { |file| file.write(source_to_update) } - end - - def directory(relative_path) - # logger.directory "#{destination_path(relative_path)}/" - end - end - - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generated_attribute.rb b/vendor/rails/railties/lib/rails_generator/generated_attribute.rb deleted file mode 100644 index a3d4a01..0000000 --- a/vendor/rails/railties/lib/rails_generator/generated_attribute.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'optparse' - -module Rails - module Generator - class GeneratedAttribute - attr_accessor :name, :type, :column - - def initialize(name, type) - @name, @type = name, type.to_sym - @column = ActiveRecord::ConnectionAdapters::Column.new(name, nil, @type) - end - - def field_type - @field_type ||= case type - when :integer, :float, :decimal then :text_field - when :datetime, :timestamp, :time then :datetime_select - when :date then :date_select - when :string then :text_field - when :text then :text_area - when :boolean then :check_box - else - :text_field - end - end - - def default - @default ||= case type - when :integer then 1 - when :float then 1.5 - when :decimal then "9.99" - when :datetime, :timestamp, :time then Time.now.to_s(:db) - when :date then Date.today.to_s(:db) - when :string then "MyString" - when :text then "MyText" - when :boolean then false - else - "" - end - end - - def reference? - [ :references, :belongs_to ].include?(self.type) - end - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/applications/app/USAGE b/vendor/rails/railties/lib/rails_generator/generators/applications/app/USAGE deleted file mode 100644 index 36d6061..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/applications/app/USAGE +++ /dev/null @@ -1,9 +0,0 @@ -Description: - The 'rails' command creates a new Rails application with a default - directory structure and configuration at the path you specify. - -Example: - rails ~/Code/Ruby/weblog - - This generates a skeletal Rails installation in ~/Code/Ruby/weblog. - See the README in the newly created application to get going. diff --git a/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb deleted file mode 100644 index 2c31d89..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ /dev/null @@ -1,258 +0,0 @@ -require 'rbconfig' -require File.dirname(__FILE__) + '/template_runner' -require 'digest/md5' -require 'active_support/secure_random' - -class AppGenerator < Rails::Generator::Base - DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) - - DATABASES = %w( mysql oracle postgresql sqlite2 sqlite3 frontbase ibm_db ) - DEFAULT_DATABASE = 'sqlite3' - - mandatory_options :source => "#{File.dirname(__FILE__)}/../../../../.." - default_options :db => (ENV["RAILS_DEFAULT_DATABASE"] || DEFAULT_DATABASE), - :shebang => DEFAULT_SHEBANG, :with_dispatchers => false, :freeze => false - - - def initialize(runtime_args, runtime_options = {}) - super - - usage if args.empty? - usage("Databases supported for preconfiguration are: #{DATABASES.join(", ")}") if (options[:db] && !DATABASES.include?(options[:db])) - - @destination_root = args.shift - @app_name = File.basename(File.expand_path(@destination_root)) - end - - def manifest - record do |m| - create_directories(m) - create_root_files(m) - create_app_files(m) - create_config_files(m) - create_script_files(m) - create_test_files(m) - create_public_files(m) - create_documentation_file(m) - create_log_files(m) - end - end - - def after_generate - if options[:template] - Rails::TemplateRunner.new(options[:template], @destination_root) - end - end - - protected - def banner - "Usage: #{$0} /path/to/your/app [options]" - end - - def add_options!(opt) - opt.separator '' - opt.separator 'Options:' - opt.on("-r", "--ruby=path", String, - "Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).", - "Default: #{DEFAULT_SHEBANG}") { |v| options[:shebang] = v } - - opt.on("-d", "--database=name", String, - "Preconfigure for selected database (options: #{DATABASES.join('/')}).", - "Default: #{DEFAULT_DATABASE}") { |v| options[:db] = v } - - opt.on("-D", "--with-dispatchers", - "Add CGI/FastCGI/mod_ruby dispatches code to generated application skeleton", - "Default: false") { |v| options[:with_dispatchers] = v } - - opt.on("-f", "--freeze", - "Freeze Rails in vendor/rails from the gems generating the skeleton", - "Default: false") { |v| options[:freeze] = v } - - opt.on("-m", "--template=path", String, - "Use an application template that lives at path (can be a filesystem path or URL).", - "Default: (none)") { |v| options[:template] = v } - - end - - - private - def create_directories(m) - m.directory '' - - # Intermediate directories are automatically created so don't sweat their absence here. - %w( - app/controllers - app/helpers - app/models - app/views/layouts - config/environments - config/initializers - config/locales - db - doc - lib - lib/tasks - log - public/images - public/javascripts - public/stylesheets - script/performance - test/fixtures - test/functional - test/integration - test/performance - test/unit - vendor - vendor/plugins - tmp/sessions - tmp/sockets - tmp/cache - tmp/pids - ).each { |path| m.directory(path) } - end - - def create_root_files(m) - m.file "fresh_rakefile", "Rakefile" - m.file "README", "README" - end - - def create_app_files(m) - m.file "helpers/application_controller.rb", "app/controllers/application_controller.rb" - m.file "helpers/application_helper.rb", "app/helpers/application_helper.rb" - end - - def create_config_files(m) - create_database_configuration_file(m) - create_routes_file(m) - create_locale_file(m) - create_initializer_files(m) - create_environment_files(m) - end - - def create_documentation_file(m) - m.file "doc/README_FOR_APP", "doc/README_FOR_APP" - end - - def create_log_files(m) - %w( server production development test ).each do |file| - m.file "configs/empty.log", "log/#{file}.log", :chmod => 0666 - end - end - - def create_public_files(m) - create_dispatch_files(m) - create_error_files(m) - create_welcome_file(m) - create_browser_convention_files(m) - create_rails_image(m) - create_javascript_files(m) - end - - def create_script_files(m) - %w( - about console dbconsole destroy generate runner server plugin - performance/benchmarker performance/profiler - ).each do |file| - m.file "bin/#{file}", "script/#{file}", { - :chmod => 0755, - :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] - } - end - end - - def create_test_files(m) - m.file "helpers/test_helper.rb", "test/test_helper.rb" - m.file "helpers/performance_test.rb", "test/performance/browsing_test.rb" - end - - - def create_database_configuration_file(m) - m.template "configs/databases/#{options[:db]}.yml", "config/database.yml", :assigns => { - :app_name => @app_name, - :socket => options[:db] == "mysql" ? mysql_socket_location : nil } - end - - def create_routes_file(m) - m.file "configs/routes.rb", "config/routes.rb" - end - - def create_initializer_files(m) - %w( - backtrace_silencers - inflections - mime_types - new_rails_defaults - ).each do |initializer| - m.file "configs/initializers/#{initializer}.rb", "config/initializers/#{initializer}.rb" - end - - m.template "configs/initializers/session_store.rb", "config/initializers/session_store.rb", - :assigns => { :app_name => @app_name, :app_secret => ActiveSupport::SecureRandom.hex(64) } - end - - def create_locale_file(m) - m.file "configs/locales/en.yml", "config/locales/en.yml" - end - - def create_environment_files(m) - m.template "environments/environment.rb", "config/environment.rb", - :assigns => { :freeze => options[:freeze] } - - m.file "environments/boot.rb", "config/boot.rb" - m.file "environments/production.rb", "config/environments/production.rb" - m.file "environments/development.rb", "config/environments/development.rb" - m.file "environments/test.rb", "config/environments/test.rb" - end - - - def create_dispatch_files(m) - if options[:with_dispatchers] - dispatcher_options = { :chmod => 0755, :shebang => options[:shebang] } - - m.file "dispatches/config.ru", "config.ru" - m.file "dispatches/dispatch.rb", "public/dispatch.rb", dispatcher_options - m.file "dispatches/dispatch.rb", "public/dispatch.cgi", dispatcher_options - m.file "dispatches/dispatch.fcgi", "public/dispatch.fcgi", dispatcher_options - end - end - - def create_error_files(m) - %w( 404 422 500 ).each do |file| - m.file "html/#{file}.html", "public/#{file}.html" - end - end - - def create_welcome_file(m) - m.file 'html/index.html', 'public/index.html' - end - - def create_browser_convention_files(m) - m.file "html/favicon.ico", "public/favicon.ico" - m.file "html/robots.txt", "public/robots.txt" - end - - def create_rails_image(m) - m.file "html/images/rails.png", "public/images/rails.png" - end - - def create_javascript_files(m) - %w( prototype effects dragdrop controls application ).each do |javascript| - m.file "html/javascripts/#{javascript}.js", "public/javascripts/#{javascript}.js" - end - end - - - def mysql_socket_location - [ - "/tmp/mysql.sock", # default - "/var/run/mysqld/mysqld.sock", # debian/gentoo - "/var/tmp/mysql.sock", # freebsd - "/var/lib/mysql/mysql.sock", # fedora - "/opt/local/lib/mysql/mysql.sock", # fedora - "/opt/local/var/run/mysqld/mysqld.sock", # mac + darwinports + mysql - "/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4 - "/opt/local/var/run/mysql5/mysqld.sock", # mac + darwinports + mysql5 - "/opt/lampp/var/mysql/mysql.sock" # xampp for linux - ].find { |f| File.exist?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/ - end -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/git.rb b/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/git.rb deleted file mode 100644 index 445de6a..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/git.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Rails - class Git < Scm - def self.clone(repos, branch=nil) - `git clone #{repos}` - - if branch - `cd #{repos.split('/').last}/` - `git checkout #{branch}` - end - end - - def self.run(command) - `git #{command}` - end - end -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/scm.rb b/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/scm.rb deleted file mode 100644 index f6c08ca..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/scm.rb +++ /dev/null @@ -1,8 +0,0 @@ -module Rails - class Scm - private - def self.hash_to_parameters(hash) - hash.collect { |key, value| "--#{key} #{(value.kind_of?(String) ? value : "")}"}.join(" ") - end - end -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/svn.rb b/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/svn.rb deleted file mode 100644 index 22b5966..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/applications/app/scm/svn.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Rails - class Svn < Scm - def self.checkout(repos, branch = nil) - `svn checkout #{repos}/#{branch || "trunk"}` - end - end -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/applications/app/template_runner.rb b/vendor/rails/railties/lib/rails_generator/generators/applications/app/template_runner.rb deleted file mode 100644 index 3b49b1f..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/applications/app/template_runner.rb +++ /dev/null @@ -1,401 +0,0 @@ -require File.dirname(__FILE__) + '/scm/scm' -require File.dirname(__FILE__) + '/scm/git' -require File.dirname(__FILE__) + '/scm/svn' - -require 'open-uri' -require 'fileutils' - -module Rails - class TemplateRunner - attr_reader :root - attr_writer :logger - - def initialize(template, root = '') # :nodoc: - @root = File.expand_path(File.directory?(root) ? root : File.join(Dir.pwd, root)) - - log 'applying', "template: #{template}" - - load_template(template) - - log 'applied', "#{template}" - end - - def load_template(template) - begin - code = open(template).read - in_root { self.instance_eval(code) } - rescue LoadError, Errno::ENOENT => e - raise "The template [#{template}] could not be loaded. Error: #{e}" - end - end - - # Create a new file in the Rails project folder. Specify the - # relative path from RAILS_ROOT. Data is the return value of a block - # or a data string. - # - # ==== Examples - # - # file("lib/fun_party.rb") do - # hostname = ask("What is the virtual hostname I should use?") - # "vhost.name = #{hostname}" - # end - # - # file("config/apach.conf", "your apache config") - # - def file(filename, data = nil, log_action = true, &block) - log 'file', filename if log_action - dir, file = [File.dirname(filename), File.basename(filename)] - - inside(dir) do - File.open(file, "w") do |f| - if block_given? - f.write(block.call) - else - f.write(data) - end - end - end - end - - # Install a plugin. You must provide either a Subversion url or Git url. - # For a Git-hosted plugin, you can specify if it should be added as a submodule instead of cloned. - # - # ==== Examples - # - # plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git' - # plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :submodule => true - # plugin 'restful-authentication', :svn => 'svn://svnhub.com/technoweenie/restful-authentication/trunk' - # - def plugin(name, options) - log 'plugin', name - - if options[:git] && options[:submodule] - in_root do - Git.run("submodule add #{options[:git]} vendor/plugins/#{name}") - end - elsif options[:git] || options[:svn] - in_root do - run_ruby_script("script/plugin install #{options[:svn] || options[:git]}", false) - end - else - log "! no git or svn provided for #{name}. skipping..." - end - end - - # Adds an entry into config/environment.rb for the supplied gem : - def gem(name, options = {}) - log 'gem', name - env = options.delete(:env) - - gems_code = "config.gem '#{name}'" - - if options.any? - opts = options.inject([]) {|result, h| result << [":#{h[0]} => #{h[1].inspect.gsub('"',"'")}"] }.sort.join(", ") - gems_code << ", #{opts}" - end - - environment gems_code, :env => env - end - - # Adds a line inside the Initializer block for config/environment.rb. Used by #gem - # If options :env is specified, the line is appended to the corresponding - # file in config/environments/#{env}.rb - def environment(data = nil, options = {}, &block) - sentinel = 'Rails::Initializer.run do |config|' - - data = block.call if !data && block_given? - - in_root do - if options[:env].nil? - gsub_file 'config/environment.rb', /(#{Regexp.escape(sentinel)})/mi do |match| - "#{match}\n " << data - end - else - Array.wrap(options[:env]).each do|env| - append_file "config/environments/#{env}.rb", "\n#{data}" - end - end - end - end - - # Run a command in git. - # - # ==== Examples - # - # git :init - # git :add => "this.file that.rb" - # git :add => "onefile.rb", :rm => "badfile.cxx" - # - def git(command = {}) - in_root do - if command.is_a?(Symbol) - log 'running', "git #{command}" - Git.run(command.to_s) - else - command.each do |command, options| - log 'running', "git #{command} #{options}" - Git.run("#{command} #{options}") - end - end - end - end - - # Create a new file in the vendor/ directory. Code can be specified - # in a block or a data string can be given. - # - # ==== Examples - # - # vendor("sekrit.rb") do - # sekrit_salt = "#{Time.now}--#{3.years.ago}--#{rand}--" - # "salt = '#{sekrit_salt}'" - # end - # - # vendor("foreign.rb", "# Foreign code is fun") - # - def vendor(filename, data = nil, &block) - log 'vendoring', filename - file("vendor/#{filename}", data, false, &block) - end - - # Create a new file in the lib/ directory. Code can be specified - # in a block or a data string can be given. - # - # ==== Examples - # - # lib("crypto.rb") do - # "crypted_special_value = '#{rand}--#{Time.now}--#{rand(1337)}--'" - # end - # - # lib("foreign.rb", "# Foreign code is fun") - # - def lib(filename, data = nil, &block) - log 'lib', filename - file("lib/#{filename}", data, false, &block) - end - - # Create a new Rakefile with the provided code (either in a block or a string). - # - # ==== Examples - # - # rakefile("bootstrap.rake") do - # project = ask("What is the UNIX name of your project?") - # - # <<-TASK - # namespace :#{project} do - # task :bootstrap do - # puts "i like boots!" - # end - # end - # TASK - # end - # - # rakefile("seed.rake", "puts 'im plantin ur seedz'") - # - def rakefile(filename, data = nil, &block) - log 'rakefile', filename - file("lib/tasks/#{filename}", data, false, &block) - end - - # Create a new initializer with the provided code (either in a block or a string). - # - # ==== Examples - # - # initializer("globals.rb") do - # data = "" - # - # ['MY_WORK', 'ADMINS', 'BEST_COMPANY_EVAR'].each do - # data << "#{const} = :entp" - # end - # - # data - # end - # - # initializer("api.rb", "API_KEY = '123456'") - # - def initializer(filename, data = nil, &block) - log 'initializer', filename - file("config/initializers/#{filename}", data, false, &block) - end - - # Generate something using a generator from Rails or a plugin. - # The second parameter is the argument string that is passed to - # the generator or an Array that is joined. - # - # ==== Example - # - # generate(:authenticated, "user session") - # - def generate(what, *args) - log 'generating', what - argument = args.map(&:to_s).flatten.join(" ") - - in_root { run_ruby_script("script/generate #{what} #{argument}", false) } - end - - # Executes a command - # - # ==== Example - # - # inside('vendor') do - # run('ln -s ~/edge rails) - # end - # - def run(command, log_action = true) - log 'executing', "#{command} from #{Dir.pwd}" if log_action - `#{command}` - end - - # Executes a ruby script (taking into account WIN32 platform quirks) - def run_ruby_script(command, log_action = true) - ruby_command = RUBY_PLATFORM=~ /win32/ ? 'ruby ' : '' - run("#{ruby_command}#{command}", log_action) - end - - # Runs the supplied rake task - # - # ==== Example - # - # rake("db:migrate") - # rake("db:migrate", :env => "production") - # rake("gems:install", :sudo => true) - # - def rake(command, options = {}) - log 'rake', command - env = options[:env] || 'development' - sudo = options[:sudo] ? 'sudo ' : '' - in_root { run("#{sudo}rake #{command} RAILS_ENV=#{env}", false) } - end - - # Just run the capify command in root - # - # ==== Example - # - # capify! - # - def capify! - log 'capifying' - in_root { run('capify .', false) } - end - - # Add Rails to /vendor/rails - # - # ==== Example - # - # freeze! - # - def freeze!(args = {}) - log 'vendor', 'rails edge' - in_root { run('rake rails:freeze:edge', false) } - end - - # Make an entry in Rails routing file conifg/routes.rb - # - # === Example - # - # route "map.root :controller => :welcome" - # - def route(routing_code) - log 'route', routing_code - sentinel = 'ActionController::Routing::Routes.draw do |map|' - - in_root do - gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match| - "#{match}\n #{routing_code}\n" - end - end - end - - protected - - # Get a user's input - # - # ==== Example - # - # answer = ask("Should I freeze the latest Rails?") - # freeze! if ask("Should I freeze the latest Rails?") == "yes" - # - def ask(string) - log '', string - STDIN.gets.strip - end - - # Do something in the root of the Rails application or - # a provided subfolder; the full path is yielded to the block you provide. - # The path is set back to the previous path when the method exits. - def inside(dir = '', &block) - folder = File.join(root, dir) - FileUtils.mkdir_p(folder) unless File.exist?(folder) - FileUtils.cd(folder) { block.arity == 1 ? yield(folder) : yield } - end - - def in_root - FileUtils.cd(root) { yield } - end - - # Helper to test if the user says yes(y)? - # - # ==== Example - # - # freeze! if yes?("Should I freeze the latest Rails?") - # - def yes?(question) - answer = ask(question).downcase - answer == "y" || answer == "yes" - end - - # Helper to test if the user does NOT say yes(y)? - # - # ==== Example - # - # capify! if no?("Will you be using vlad to deploy your application?") - # - def no?(question) - !yes?(question) - end - - # Run a regular expression replacement on a file - # - # ==== Example - # - # gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1' - # - def gsub_file(relative_destination, regexp, *args, &block) - path = destination_path(relative_destination) - content = File.read(path).gsub(regexp, *args, &block) - File.open(path, 'wb') { |file| file.write(content) } - end - - # Append text to a file - # - # ==== Example - # - # append_file 'config/environments/test.rb', 'config.gem "rspec"' - # - def append_file(relative_destination, data) - path = destination_path(relative_destination) - File.open(path, 'ab') { |file| file.write(data) } - end - - def destination_path(relative_destination) - File.join(root, relative_destination) - end - - def log(action, message = '') - logger.log(action, message) - end - - def logger - @logger ||= Rails::Generator::Base.logger - end - - def logger - @logger ||= if defined?(Rails::Generator::Base) - Rails::Generator::Base.logger - else - require 'rails_generator/simple_logger' - Rails::Generator::SimpleLogger.new(STDOUT) - end - end - - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/controller/USAGE deleted file mode 100644 index 362872e..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/USAGE +++ /dev/null @@ -1,30 +0,0 @@ -Description: - Stubs out a new controller and its views. Pass the controller name, either - CamelCased or under_scored, and a list of views as arguments. - - To create a controller within a module, specify the controller name as a - path like 'parent_module/controller_name'. - - This generates a controller class in app/controllers, view templates in - app/views/controller_name, a helper class in app/helpers, a functional - test suite in test/functional and a helper test suite in test/unit/helpers. - -Example: - `./script/generate controller CreditCard open debit credit close` - - Credit card controller with URLs like /credit_card/debit. - Controller: app/controllers/credit_card_controller.rb - Functional Test: test/functional/credit_card_controller_test.rb - Views: app/views/credit_card/debit.html.erb [...] - Helper: app/helpers/credit_card_helper.rb - Helper Test: test/unit/helpers/credit_card_helper_test.rb - -Modules Example: - `./script/generate controller 'admin/credit_card' suspend late_fee` - - Credit card admin controller with URLs /admin/credit_card/suspend. - Controller: app/controllers/admin/credit_card_controller.rb - Functional Test: test/functional/admin/credit_card_controller_test.rb - Views: app/views/admin/credit_card/debit.html.erb [...] - Helper: app/helpers/admin/credit_card_helper.rb - Helper Test: test/unit/helpers/admin/credit_card_helper_test.rb diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/controller_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/controller/controller_generator.rb deleted file mode 100644 index dc126e8..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/controller_generator.rb +++ /dev/null @@ -1,43 +0,0 @@ -class ControllerGenerator < Rails::Generator::NamedBase - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper", "#{class_name}HelperTest" - - # Controller, helper, views, and test directories. - m.directory File.join('app/controllers', class_path) - m.directory File.join('app/helpers', class_path) - m.directory File.join('app/views', class_path, file_name) - m.directory File.join('test/functional', class_path) - m.directory File.join('test/unit/helpers', class_path) - - # Controller class, functional test, and helper class. - m.template 'controller.rb', - File.join('app/controllers', - class_path, - "#{file_name}_controller.rb") - - m.template 'functional_test.rb', - File.join('test/functional', - class_path, - "#{file_name}_controller_test.rb") - - m.template 'helper.rb', - File.join('app/helpers', - class_path, - "#{file_name}_helper.rb") - - m.template 'helper_test.rb', - File.join('test/unit/helpers', - class_path, - "#{file_name}_helper_test.rb") - - # View template for each action. - actions.each do |action| - path = File.join('app/views', class_path, file_name, "#{action}.html.erb") - m.template 'view.html.erb', path, - :assigns => { :action => action, :path => path } - end - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/controller.rb b/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/controller.rb deleted file mode 100644 index cda2659..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class <%= class_name %>Controller < ApplicationController -<% for action in actions -%> - def <%= action %> - end - -<% end -%> -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb deleted file mode 100644 index 62fa5d8..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test_helper' - -class <%= class_name %>ControllerTest < ActionController::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/helper.rb b/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/helper.rb deleted file mode 100644 index 3fe2ecd..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module <%= class_name %>Helper -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/helper_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/helper_test.rb deleted file mode 100644 index 591e409..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class <%= class_name %>HelperTest < ActionView::TestCase -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/view.html.erb b/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/view.html.erb deleted file mode 100644 index ad85431..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/view.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -<h1><%= class_name %>#<%= action %></h1> -<p>Find me in <%= path %></p> diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/helper/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/helper/USAGE deleted file mode 100644 index ef27ca6..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/helper/USAGE +++ /dev/null @@ -1,24 +0,0 @@ -Description: - Stubs out a new helper. Pass the helper name, either - CamelCased or under_scored. - - To create a helper within a module, specify the helper name as a - path like 'parent_module/helper_name'. - - This generates a helper class in app/helpers and a helper test - suite in test/unit/helpers. - -Example: - `./script/generate helper CreditCard` - - Credit card helper. - Helper: app/helpers/credit_card_helper.rb - Test: test/unit/helpers/credit_card_helper_test.rb - -Modules Example: - `./script/generate helper 'admin/credit_card'` - - Credit card admin helper. - Helper: app/helpers/admin/credit_card_helper.rb - Test: test/unit/helpers/admin/credit_card_helper_test.rb - diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/helper/helper_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/helper/helper_generator.rb deleted file mode 100644 index f7831f7..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/helper/helper_generator.rb +++ /dev/null @@ -1,25 +0,0 @@ -class HelperGenerator < Rails::Generator::NamedBase - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions class_path, "#{class_name}Helper", "#{class_name}HelperTest" - - # Helper and helper test directories. - m.directory File.join('app/helpers', class_path) - m.directory File.join('test/unit/helpers', class_path) - - # Helper and helper test class. - - m.template 'helper.rb', - File.join('app/helpers', - class_path, - "#{file_name}_helper.rb") - - m.template 'helper_test.rb', - File.join('test/unit/helpers', - class_path, - "#{file_name}_helper_test.rb") - - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/helper/templates/helper.rb b/vendor/rails/railties/lib/rails_generator/generators/components/helper/templates/helper.rb deleted file mode 100644 index 3fe2ecd..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/helper/templates/helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module <%= class_name %>Helper -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/helper/templates/helper_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/helper/templates/helper_test.rb deleted file mode 100644 index 591e409..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/helper/templates/helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class <%= class_name %>HelperTest < ActionView::TestCase -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/USAGE deleted file mode 100644 index 09e2691..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/USAGE +++ /dev/null @@ -1,8 +0,0 @@ -Description: - Stubs out a new integration test. Pass the name of the test, either - CamelCased or under_scored, as an argument. The new test class is - generated in test/integration/testname_test.rb - -Example: - `./script/generate integration_test GeneralStories` creates a GeneralStories - integration test in test/integration/general_stories_test.rb diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb deleted file mode 100644 index 44323f2..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +++ /dev/null @@ -1,16 +0,0 @@ -class IntegrationTestGenerator < Rails::Generator::NamedBase - default_options :skip_migration => false - - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions class_name, "#{class_name}Test" - - # integration test directory - m.directory File.join('test/integration', class_path) - - # integration test stub - m.template 'integration_test.rb', File.join('test/integration', class_path, "#{file_name}_test.rb") - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb deleted file mode 100644 index 2c57158..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'test_helper' - -class <%= class_name %>Test < ActionController::IntegrationTest - fixtures :all - - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/USAGE deleted file mode 100644 index 61a649e..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/USAGE +++ /dev/null @@ -1,16 +0,0 @@ -Description: - Stubs out a new mailer and its views. Pass the mailer name, either - CamelCased or under_scored, and an optional list of emails as arguments. - - This generates a mailer class in app/models, view templates in - app/views/mailer_name, a unit test in test/unit, and fixtures in - test/fixtures. - -Example: - `./script/generate mailer Notifications signup forgot_password invoice` - - creates a Notifications mailer class, views, test, and fixtures: - Mailer: app/models/notifications.rb - Views: app/views/notifications/signup.erb [...] - Test: test/unit/test/unit/notifications_test.rb - Fixtures: test/fixtures/notifications/signup [...] diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/mailer_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/mailer_generator.rb deleted file mode 100644 index ba6d60c..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/mailer_generator.rb +++ /dev/null @@ -1,30 +0,0 @@ -class MailerGenerator < Rails::Generator::NamedBase - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions class_name, "#{class_name}Test" - - # Mailer, view, test, and fixture directories. - m.directory File.join('app/models', class_path) - m.directory File.join('app/views', file_path) - m.directory File.join('test/unit', class_path) - m.directory File.join('test/fixtures', file_path) - - # Mailer class and unit test. - m.template "mailer.rb", File.join('app/models', class_path, "#{file_name}.rb") - m.template "unit_test.rb", File.join('test/unit', class_path, "#{file_name}_test.rb") - - # View template and fixture for each action. - actions.each do |action| - relative_path = File.join(file_path, action) - view_path = File.join('app/views', "#{relative_path}.erb") - fixture_path = File.join('test/fixtures', relative_path) - - m.template "view.erb", view_path, - :assigns => { :action => action, :path => view_path } - m.template "fixture.erb", fixture_path, - :assigns => { :action => action, :path => view_path } - end - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/fixture.erb b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/fixture.erb deleted file mode 100644 index 6899257..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/fixture.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= class_name %>#<%= action %> - -Find me in <%= path %> diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb deleted file mode 100644 index ce15ae9..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb +++ /dev/null @@ -1,15 +0,0 @@ -class <%= class_name %> < ActionMailer::Base - -<% for action in actions -%> - - def <%= action %>(sent_at = Time.now) - subject '<%= class_name %>#<%= action %>' - recipients '' - from '' - sent_on sent_at - - body :greeting => 'Hi,' - end -<% end -%> - -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb deleted file mode 100644 index 4de9407..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'test_helper' - -class <%= class_name %>Test < ActionMailer::TestCase -<% for action in actions -%> - test "<%= action %>" do - @expected.subject = '<%= class_name %>#<%= action %>' - @expected.body = read_fixture('<%= action %>') - @expected.date = Time.now - - assert_equal @expected.encoded, <%= class_name %>.create_<%= action %>(@expected.date).encoded - end - -<% end -%> -<% if actions.blank? -%> - # replace this with your real tests - test "the truth" do - assert true - end -<% end -%> -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/view.erb b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/view.erb deleted file mode 100644 index 6899257..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/view.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= class_name %>#<%= action %> - -Find me in <%= path %> diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/view.rhtml b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/view.rhtml deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/metal/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/metal/USAGE deleted file mode 100644 index 123ec6c..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/metal/USAGE +++ /dev/null @@ -1,8 +0,0 @@ -Description: - Cast some metal! - -Examples: - `./script/generate metal poller` - - This will create: - Metal: app/metal/poller.rb diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/metal/metal_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/metal/metal_generator.rb deleted file mode 100644 index 64f49d9..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/metal/metal_generator.rb +++ /dev/null @@ -1,8 +0,0 @@ -class MetalGenerator < Rails::Generator::NamedBase - def manifest - record do |m| - m.directory 'app/metal' - m.template 'metal.rb', File.join('app/metal', "#{file_name}.rb") - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/metal/templates/metal.rb b/vendor/rails/railties/lib/rails_generator/generators/components/metal/templates/metal.rb deleted file mode 100644 index e94982b..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/metal/templates/metal.rb +++ /dev/null @@ -1,12 +0,0 @@ -# Allow the metal piece to run in isolation -require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails) - -class <%= class_name %> - def self.call(env) - if env["PATH_INFO"] =~ /^\/<%= file_name %>/ - [200, {"Content-Type" => "text/html"}, ["Hello, World!"]] - else - [404, {"Content-Type" => "text/html"}, ["Not Found"]] - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/migration/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/migration/USAGE deleted file mode 100644 index b83c657..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/migration/USAGE +++ /dev/null @@ -1,29 +0,0 @@ -Description: - Stubs out a new database migration. Pass the migration name, either - CamelCased or under_scored, and an optional list of attribute pairs as arguments. - - A migration class is generated in db/migrate prefixed by a timestamp of the current date and time. - - You can name your migration in either of these formats to generate add/remove - column lines from supplied attributes: AddColumnsToTable or RemoveColumnsFromTable - -Example: - `./script/generate migration AddSslFlag` - - If the current date is May 14, 2008 and the current time 09:09:12, this creates the AddSslFlag migration - db/migrate/20080514090912_add_ssl_flag.rb - - `./script/generate migration AddTitleBodyToPost title:string body:text published:boolean` - - This will create the AddTitleBodyToPost in db/migrate/20080514090912_add_title_body_to_post.rb with - this in the Up migration: - - add_column :posts, :title, :string - add_column :posts, :body, :text - add_column :posts, :published, :boolean - - And this in the Down migration: - - remove_column :posts, :published - remove_column :posts, :body - remove_column :posts, :title diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/migration/migration_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/migration/migration_generator.rb deleted file mode 100644 index acf41e0..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/migration/migration_generator.rb +++ /dev/null @@ -1,20 +0,0 @@ -class MigrationGenerator < Rails::Generator::NamedBase - def manifest - record do |m| - m.migration_template 'migration.rb', 'db/migrate', :assigns => get_local_assigns - end - end - - - private - def get_local_assigns - returning(assigns = {}) do - if class_name.underscore =~ /^(add|remove)_.*_(?:to|from)_(.*)/ - assigns[:migration_action] = $1 - assigns[:table_name] = $2.pluralize - else - assigns[:attributes] = [] - end - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/migration/templates/migration.rb b/vendor/rails/railties/lib/rails_generator/generators/components/migration/templates/migration.rb deleted file mode 100644 index ca35a43..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/migration/templates/migration.rb +++ /dev/null @@ -1,11 +0,0 @@ -class <%= class_name.underscore.camelize %> < ActiveRecord::Migration - def self.up<% attributes.each do |attribute| %> - <%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end -%> - <%- end %> - end - - def self.down<% attributes.reverse.each do |attribute| %> - <%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><% end -%> - <%- end %> - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/model/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/model/USAGE deleted file mode 100644 index 24b03b4..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/model/USAGE +++ /dev/null @@ -1,27 +0,0 @@ -Description: - Stubs out a new model. Pass the model name, either CamelCased or - under_scored, and an optional list of attribute pairs as arguments. - - Attribute pairs are column_name:sql_type arguments specifying the - model's attributes. Timestamps are added by default, so you don't have to - specify them by hand as 'created_at:datetime updated_at:datetime'. - - You don't have to think up every attribute up front, but it helps to - sketch out a few so you can start working with the model immediately. - - This generates a model class in app/models, a unit test in test/unit, - a test fixture in test/fixtures/singular_name.yml, and a migration in - db/migrate. - -Examples: - `./script/generate model account` - - creates an Account model, test, fixture, and migration: - Model: app/models/account.rb - Test: test/unit/account_test.rb - Fixtures: test/fixtures/accounts.yml - Migration: db/migrate/XXX_add_accounts.rb - - `./script/generate model post title:string body:text published:boolean` - - creates a Post model with a string title, text body, and published flag. diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/model/model_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/model/model_generator.rb deleted file mode 100644 index 582a289..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/model/model_generator.rb +++ /dev/null @@ -1,45 +0,0 @@ -class ModelGenerator < Rails::Generator::NamedBase - default_options :skip_timestamps => false, :skip_migration => false, :skip_fixture => false - - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions class_name, "#{class_name}Test" - - # Model, test, and fixture directories. - m.directory File.join('app/models', class_path) - m.directory File.join('test/unit', class_path) - m.directory File.join('test/fixtures', class_path) - - # Model class, unit test, and fixtures. - m.template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb") - m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb") - - unless options[:skip_fixture] - m.template 'fixtures.yml', File.join('test/fixtures', "#{table_name}.yml") - end - - unless options[:skip_migration] - m.migration_template 'migration.rb', 'db/migrate', :assigns => { - :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}" - }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}" - end - end - end - - protected - def banner - "Usage: #{$0} #{spec.name} ModelName [field:type, field:type]" - end - - def add_options!(opt) - opt.separator '' - opt.separator 'Options:' - opt.on("--skip-timestamps", - "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v } - opt.on("--skip-migration", - "Don't generate a migration file for this model") { |v| options[:skip_migration] = v } - opt.on("--skip-fixture", - "Don't generation a fixture file for this model") { |v| options[:skip_fixture] = v} - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml b/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml deleted file mode 100644 index c210351..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html - -<% unless attributes.empty? -%> -one: -<% for attribute in attributes -%> - <%= attribute.name %>: <%= attribute.default %> -<% end -%> - -two: -<% for attribute in attributes -%> - <%= attribute.name %>: <%= attribute.default %> -<% end -%> -<% else -%> -# one: -# column: value -# -# two: -# column: value -<% end -%> diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/migration.rb b/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/migration.rb deleted file mode 100644 index 382fd11..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/migration.rb +++ /dev/null @@ -1,16 +0,0 @@ -class <%= migration_name %> < ActiveRecord::Migration - def self.up - create_table :<%= table_name %> do |t| -<% for attribute in attributes -%> - t.<%= attribute.type %> :<%= attribute.name %> -<% end -%> -<% unless options[:skip_timestamps] %> - t.timestamps -<% end -%> - end - end - - def self.down - drop_table :<%= table_name %> - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/model.rb b/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/model.rb deleted file mode 100644 index 6fcf393..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/model.rb +++ /dev/null @@ -1,5 +0,0 @@ -class <%= class_name %> < ActiveRecord::Base -<% attributes.select(&:reference?).each do |attribute| -%> - belongs_to :<%= attribute.name %> -<% end -%> -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb deleted file mode 100644 index 3e0bc29..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test_helper' - -class <%= class_name %>Test < ActiveSupport::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/observer/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/observer/USAGE deleted file mode 100644 index a5d744a..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/observer/USAGE +++ /dev/null @@ -1,13 +0,0 @@ -Description: - Stubs out a new observer. Pass the observer name, either CamelCased or - under_scored, as an argument. - - The generator creates an observer class in app/models and a unit test in - test/unit. - -Example: - `./script/generate observer Account` - - creates an Account observer and unit test: - Observer: app/models/account_observer.rb - Test: test/unit/account_observer_test.rb diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/observer/observer_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/observer/observer_generator.rb deleted file mode 100644 index 3c4b330..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/observer/observer_generator.rb +++ /dev/null @@ -1,16 +0,0 @@ -class ObserverGenerator < Rails::Generator::NamedBase - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions "#{class_name}Observer", "#{class_name}ObserverTest" - - # Observer, and test directories. - m.directory File.join('app/models', class_path) - m.directory File.join('test/unit', class_path) - - # Observer class and unit test fixtures. - m.template 'observer.rb', File.join('app/models', class_path, "#{file_name}_observer.rb") - m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_observer_test.rb") - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/observer.rb b/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/observer.rb deleted file mode 100644 index b9a3004..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/observer.rb +++ /dev/null @@ -1,2 +0,0 @@ -class <%= class_name %>Observer < ActiveRecord::Observer -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb deleted file mode 100644 index 03f6d56..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test_helper' - -class <%= class_name %>ObserverTest < ActiveSupport::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/USAGE deleted file mode 100644 index d84051e..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/USAGE +++ /dev/null @@ -1,8 +0,0 @@ -Description: - Stubs out a new performance test. Pass the name of the test, either - CamelCased or under_scored, as an argument. The new test class is - generated in test/performance/testname_test.rb - -Example: - `./script/generate performance_test GeneralStories` creates a GeneralStories - performance test in test/performance/general_stories_test.rb diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb deleted file mode 100644 index 83ce8ac..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb +++ /dev/null @@ -1,16 +0,0 @@ -class PerformanceTestGenerator < Rails::Generator::NamedBase - default_options :skip_migration => false - - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions class_name, "#{class_name}Test" - - # performance test directory - m.directory File.join('test/performance', class_path) - - # performance test stub - m.template 'performance_test.rb', File.join('test/performance', class_path, "#{file_name}_test.rb") - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb deleted file mode 100644 index 27c91b0..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'test_helper' -require 'performance_test_help' - -class <%= class_name %>Test < ActionController::PerformanceTest - # Replace this with your real tests. - def test_homepage - get '/' - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/USAGE deleted file mode 100644 index d2ecfc2..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/USAGE +++ /dev/null @@ -1,25 +0,0 @@ -Description: - Stubs out a new plugin. Pass the plugin name, either CamelCased or - under_scored, as an argument. Pass --with-generator to add an example - generator also. - - This creates a plugin in vendor/plugins including an init.rb and README - as well as standard lib, task, and test directories. - -Example: - `./script/generate plugin BrowserFilters` - - creates a standard browser_filters plugin: - vendor/plugins/browser_filters/README - vendor/plugins/browser_filters/init.rb - vendor/plugins/browser_filters/install.rb - vendor/plugins/browser_filters/lib/browser_filters.rb - vendor/plugins/browser_filters/test/browser_filters_test.rb - vendor/plugins/browser_filters/tasks/browser_filters_tasks.rake - - ./script/generate plugin BrowserFilters --with-generator - - creates a browser_filters generator also: - vendor/plugins/browser_filters/generators/browser_filters/browser_filters_generator.rb - vendor/plugins/browser_filters/generators/browser_filters/USAGE - vendor/plugins/browser_filters/generators/browser_filters/templates/ diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb deleted file mode 100644 index 6826998..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb +++ /dev/null @@ -1,39 +0,0 @@ -class PluginGenerator < Rails::Generator::NamedBase - attr_reader :plugin_path - - def initialize(runtime_args, runtime_options = {}) - @with_generator = runtime_args.delete("--with-generator") - super - @plugin_path = "vendor/plugins/#{file_name}" - end - - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions class_name - - m.directory "#{plugin_path}/lib" - m.directory "#{plugin_path}/tasks" - m.directory "#{plugin_path}/test" - - m.template 'README', "#{plugin_path}/README" - m.template 'MIT-LICENSE', "#{plugin_path}/MIT-LICENSE" - m.template 'Rakefile', "#{plugin_path}/Rakefile" - m.template 'init.rb', "#{plugin_path}/init.rb" - m.template 'install.rb', "#{plugin_path}/install.rb" - m.template 'uninstall.rb', "#{plugin_path}/uninstall.rb" - m.template 'plugin.rb', "#{plugin_path}/lib/#{file_name}.rb" - m.template 'tasks.rake', "#{plugin_path}/tasks/#{file_name}_tasks.rake" - m.template 'unit_test.rb', "#{plugin_path}/test/#{file_name}_test.rb" - m.template 'test_helper.rb', "#{plugin_path}/test/test_helper.rb" - if @with_generator - m.directory "#{plugin_path}/generators" - m.directory "#{plugin_path}/generators/#{file_name}" - m.directory "#{plugin_path}/generators/#{file_name}/templates" - - m.template 'generator.rb', "#{plugin_path}/generators/#{file_name}/#{file_name}_generator.rb" - m.template 'USAGE', "#{plugin_path}/generators/#{file_name}/USAGE" - end - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE deleted file mode 100644 index 8717df0..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) <%= Date.today.year %> [name of plugin creator] - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/README b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/README deleted file mode 100644 index 702db07..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/README +++ /dev/null @@ -1,13 +0,0 @@ -<%= class_name %> -<%= "=" * class_name.size %> - -Introduction goes here. - - -Example -======= - -Example goes here. - - -Copyright (c) <%= Date.today.year %> [name of plugin creator], released under the MIT license diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile deleted file mode 100644 index 85e8ff1..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile +++ /dev/null @@ -1,23 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the <%= file_name %> plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.libs << 'test' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate documentation for the <%= file_name %> plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = '<%= class_name %>' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/USAGE deleted file mode 100644 index ea9f4f1..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/USAGE +++ /dev/null @@ -1,8 +0,0 @@ -Description: - Explain the generator - -Example: - ./script/generate <%= file_name %> Thing - - This will create: - what/will/it/create diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/generator.rb deleted file mode 100644 index 3e800df..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/generator.rb +++ /dev/null @@ -1,8 +0,0 @@ -class <%= class_name %>Generator < Rails::Generator::NamedBase - def manifest - record do |m| - # m.directory "lib" - # m.template 'README', "README" - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/init.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/init.rb deleted file mode 100644 index 3c19a74..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/init.rb +++ /dev/null @@ -1 +0,0 @@ -# Include hook code here diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/install.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/install.rb deleted file mode 100644 index f7732d3..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/install.rb +++ /dev/null @@ -1 +0,0 @@ -# Install hook code here diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/plugin.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/plugin.rb deleted file mode 100644 index d8d908a..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/plugin.rb +++ /dev/null @@ -1 +0,0 @@ -# <%= class_name %> diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/tasks.rake b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/tasks.rake deleted file mode 100644 index 72920a9..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/tasks.rake +++ /dev/null @@ -1,4 +0,0 @@ -# desc "Explaining what the task does" -# task :<%= file_name %> do -# # Task goes here -# end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/test_helper.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/test_helper.rb deleted file mode 100644 index cf148b8..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/test_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'rubygems' -require 'active_support' -require 'active_support/test_case' \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/uninstall.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/uninstall.rb deleted file mode 100644 index 9738333..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +++ /dev/null @@ -1 +0,0 @@ -# Uninstall hook code here diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb deleted file mode 100644 index 3e0bc29..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test_helper' - -class <%= class_name %>Test < ActiveSupport::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/resource/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/resource/USAGE deleted file mode 100644 index e6043f1..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/resource/USAGE +++ /dev/null @@ -1,23 +0,0 @@ -Description: - Stubs out a new resource including an empty model and controller suitable - for a restful, resource-oriented application. Pass the singular model name, - either CamelCased or under_scored, as the first argument, and an optional - list of attribute pairs. - - Attribute pairs are column_name:sql_type arguments specifying the - model's attributes. Timestamps are added by default, so you don't have to - specify them by hand as 'created_at:datetime updated_at:datetime'. - - You don't have to think up every attribute up front, but it helps to - sketch out a few so you can start working with the resource immediately. - - This creates a model, controller, helper, tests and fixtures for all of them, - and the corresponding map.resources declaration in config/routes.rb - - Unlike the scaffold generator, the resource generator does not create - views or add any methods to the generated controller. - -Examples: - `./script/generate resource post` # no attributes - `./script/generate resource post title:string body:text published:boolean` - `./script/generate resource purchase order_id:integer amount:decimal` diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/resource/resource_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/resource/resource_generator.rb deleted file mode 100644 index 4ee2fbf..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/resource/resource_generator.rb +++ /dev/null @@ -1,76 +0,0 @@ -class ResourceGenerator < Rails::Generator::NamedBase - default_options :skip_timestamps => false, :skip_migration => false - - attr_reader :controller_name, - :controller_class_path, - :controller_file_path, - :controller_class_nesting, - :controller_class_nesting_depth, - :controller_class_name, - :controller_singular_name, - :controller_plural_name - alias_method :controller_file_name, :controller_singular_name - alias_method :controller_table_name, :controller_plural_name - - def initialize(runtime_args, runtime_options = {}) - super - - @controller_name = @name.pluralize - - base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name) - @controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name) - - if @controller_class_nesting.empty? - @controller_class_name = @controller_class_name_without_nesting - else - @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}" - end - end - - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions("#{controller_class_name}Controller", "#{controller_class_name}Helper") - m.class_collisions(class_name) - - # Controller, helper, views, and test directories. - m.directory(File.join('app/models', class_path)) - m.directory(File.join('app/controllers', controller_class_path)) - m.directory(File.join('app/helpers', controller_class_path)) - m.directory(File.join('app/views', controller_class_path, controller_file_name)) - m.directory(File.join('test/functional', controller_class_path)) - m.directory(File.join('test/unit', class_path)) - m.directory(File.join('test/unit/helpers', class_path)) - - m.dependency 'model', [name] + @args, :collision => :skip - - m.template( - 'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb") - ) - - m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb")) - m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb")) - m.template('helper_test.rb', File.join('test/unit/helpers', controller_class_path, "#{controller_file_name}_helper_test.rb")) - - m.route_resources controller_file_name - end - end - - protected - def banner - "Usage: #{$0} resource ModelName [field:type, field:type]" - end - - def add_options!(opt) - opt.separator '' - opt.separator 'Options:' - opt.on("--skip-timestamps", - "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v } - opt.on("--skip-migration", - "Don't generate a migration file for this model") { |v| options[:skip_migration] = v } - end - - def model_name - class_name.demodulize - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/controller.rb b/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/controller.rb deleted file mode 100644 index 765a942..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class <%= controller_class_name %>Controller < ApplicationController -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb deleted file mode 100644 index b1bb1da..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test_helper' - -class <%= controller_class_name %>ControllerTest < ActionController::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/helper.rb b/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/helper.rb deleted file mode 100644 index 9bd821b..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module <%= controller_class_name %>Helper -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/helper_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/helper_test.rb deleted file mode 100644 index 061f64a..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class <%= controller_class_name %>HelperTest < ActionView::TestCase -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/USAGE deleted file mode 100644 index 810aea1..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/USAGE +++ /dev/null @@ -1,29 +0,0 @@ -Description: - Scaffolds an entire resource, from model and migration to controller and - views, along with a full test suite. The resource is ready to use as a - starting point for your RESTful, resource-oriented application. - - Pass the name of the model (in singular form), either CamelCased or - under_scored, as the first argument, and an optional list of attribute - pairs. - - Attribute pairs are column_name:sql_type arguments specifying the - model's attributes. Timestamps are added by default, so you don't have to - specify them by hand as 'created_at:datetime updated_at:datetime'. - - You don't have to think up every attribute up front, but it helps to - sketch out a few so you can start working with the resource immediately. - - For example, 'scaffold post title:string body:text published:boolean' - gives you a model with those three attributes, a controller that handles - the create/show/update/destroy, forms to create and edit your posts, and - an index that lists them all, as well as a map.resources :posts - declaration in config/routes.rb. - - If you want to remove all the generated files, run - 'script/destroy scaffold ModelName'. - -Examples: - `./script/generate scaffold post` - `./script/generate scaffold post title:string body:text published:boolean` - `./script/generate scaffold purchase order_id:integer amount:decimal` diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb deleted file mode 100644 index 2a5edee..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +++ /dev/null @@ -1,102 +0,0 @@ -class ScaffoldGenerator < Rails::Generator::NamedBase - default_options :skip_timestamps => false, :skip_migration => false, :force_plural => false - - attr_reader :controller_name, - :controller_class_path, - :controller_file_path, - :controller_class_nesting, - :controller_class_nesting_depth, - :controller_class_name, - :controller_underscore_name, - :controller_singular_name, - :controller_plural_name - alias_method :controller_file_name, :controller_underscore_name - alias_method :controller_table_name, :controller_plural_name - - def initialize(runtime_args, runtime_options = {}) - super - - if @name == @name.pluralize && !options[:force_plural] - logger.warning "Plural version of the model detected, using singularized version. Override with --force-plural." - @name = @name.singularize - end - - @controller_name = @name.pluralize - - base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name) - @controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name) - @controller_singular_name=base_name.singularize - if @controller_class_nesting.empty? - @controller_class_name = @controller_class_name_without_nesting - else - @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}" - end - end - - def manifest - record do |m| - # Check for class naming collisions. - m.class_collisions("#{controller_class_name}Controller", "#{controller_class_name}Helper") - m.class_collisions(class_name) - - # Controller, helper, views, test and stylesheets directories. - m.directory(File.join('app/models', class_path)) - m.directory(File.join('app/controllers', controller_class_path)) - m.directory(File.join('app/helpers', controller_class_path)) - m.directory(File.join('app/views', controller_class_path, controller_file_name)) - m.directory(File.join('app/views/layouts', controller_class_path)) - m.directory(File.join('test/functional', controller_class_path)) - m.directory(File.join('test/unit', class_path)) - m.directory(File.join('test/unit/helpers', class_path)) - m.directory(File.join('public/stylesheets', class_path)) - - for action in scaffold_views - m.template( - "view_#{action}.html.erb", - File.join('app/views', controller_class_path, controller_file_name, "#{action}.html.erb") - ) - end - - # Layout and stylesheet. - m.template('layout.html.erb', File.join('app/views/layouts', controller_class_path, "#{controller_file_name}.html.erb")) - m.template('style.css', 'public/stylesheets/scaffold.css') - - m.template( - 'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb") - ) - - m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb")) - m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb")) - m.template('helper_test.rb', File.join('test/unit/helpers', controller_class_path, "#{controller_file_name}_helper_test.rb")) - - m.route_resources controller_file_name - - m.dependency 'model', [name] + @args, :collision => :skip - end - end - - protected - # Override with your own usage banner. - def banner - "Usage: #{$0} scaffold ModelName [field:type, field:type]" - end - - def add_options!(opt) - opt.separator '' - opt.separator 'Options:' - opt.on("--skip-timestamps", - "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v } - opt.on("--skip-migration", - "Don't generate a migration file for this model") { |v| options[:skip_migration] = v } - opt.on("--force-plural", - "Forces the generation of a plural ModelName") { |v| options[:force_plural] = v } - end - - def scaffold_views - %w[ index show new edit ] - end - - def model_name - class_name.demodulize - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb deleted file mode 100644 index 4d190b9..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb +++ /dev/null @@ -1,85 +0,0 @@ -class <%= controller_class_name %>Controller < ApplicationController - # GET /<%= table_name %> - # GET /<%= table_name %>.xml - def index - @<%= table_name %> = <%= class_name %>.all - - respond_to do |format| - format.html # index.html.erb - format.xml { render :xml => @<%= table_name %> } - end - end - - # GET /<%= table_name %>/1 - # GET /<%= table_name %>/1.xml - def show - @<%= file_name %> = <%= class_name %>.find(params[:id]) - - respond_to do |format| - format.html # show.html.erb - format.xml { render :xml => @<%= file_name %> } - end - end - - # GET /<%= table_name %>/new - # GET /<%= table_name %>/new.xml - def new - @<%= file_name %> = <%= class_name %>.new - - respond_to do |format| - format.html # new.html.erb - format.xml { render :xml => @<%= file_name %> } - end - end - - # GET /<%= table_name %>/1/edit - def edit - @<%= file_name %> = <%= class_name %>.find(params[:id]) - end - - # POST /<%= table_name %> - # POST /<%= table_name %>.xml - def create - @<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>]) - - respond_to do |format| - if @<%= file_name %>.save - flash[:notice] = '<%= class_name %> was successfully created.' - format.html { redirect_to(@<%= file_name %>) } - format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> } - else - format.html { render :action => "new" } - format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity } - end - end - end - - # PUT /<%= table_name %>/1 - # PUT /<%= table_name %>/1.xml - def update - @<%= file_name %> = <%= class_name %>.find(params[:id]) - - respond_to do |format| - if @<%= file_name %>.update_attributes(params[:<%= file_name %>]) - flash[:notice] = '<%= class_name %> was successfully updated.' - format.html { redirect_to(@<%= file_name %>) } - format.xml { head :ok } - else - format.html { render :action => "edit" } - format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity } - end - end - end - - # DELETE /<%= table_name %>/1 - # DELETE /<%= table_name %>/1.xml - def destroy - @<%= file_name %> = <%= class_name %>.find(params[:id]) - @<%= file_name %>.destroy - - respond_to do |format| - format.html { redirect_to(<%= table_name %>_url) } - format.xml { head :ok } - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb deleted file mode 100644 index cd2fc57..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'test_helper' - -class <%= controller_class_name %>ControllerTest < ActionController::TestCase - test "should get index" do - get :index - assert_response :success - assert_not_nil assigns(:<%= table_name %>) - end - - test "should get new" do - get :new - assert_response :success - end - - test "should create <%= file_name %>" do - assert_difference('<%= class_name %>.count') do - post :create, :<%= file_name %> => { } - end - - assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>)) - end - - test "should show <%= file_name %>" do - get :show, :id => <%= table_name %>(:one).to_param - assert_response :success - end - - test "should get edit" do - get :edit, :id => <%= table_name %>(:one).to_param - assert_response :success - end - - test "should update <%= file_name %>" do - put :update, :id => <%= table_name %>(:one).to_param, :<%= file_name %> => { } - assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>)) - end - - test "should destroy <%= file_name %>" do - assert_difference('<%= class_name %>.count', -1) do - delete :destroy, :id => <%= table_name %>(:one).to_param - end - - assert_redirected_to <%= table_name %>_path - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/helper.rb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/helper.rb deleted file mode 100644 index 9bd821b..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module <%= controller_class_name %>Helper -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/helper_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/helper_test.rb deleted file mode 100644 index 061f64a..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class <%= controller_class_name %>HelperTest < ActionView::TestCase -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb deleted file mode 100644 index ebc97f8..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +++ /dev/null @@ -1,17 +0,0 @@ -<!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><%= controller_class_name %>: <%%= controller.action_name %></title> - <%%= stylesheet_link_tag 'scaffold' %> -</head> -<body> - -<p style="color: green"><%%= flash[:notice] %></p> - -<%%= yield %> - -</body> -</html> diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/style.css b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/style.css deleted file mode 100644 index 093c209..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/style.css +++ /dev/null @@ -1,54 +0,0 @@ -body { background-color: #fff; color: #333; } - -body, p, ol, ul, td { - font-family: verdana, arial, helvetica, sans-serif; - font-size: 13px; - line-height: 18px; -} - -pre { - background-color: #eee; - padding: 10px; - font-size: 11px; -} - -a { color: #000; } -a:visited { color: #666; } -a:hover { color: #fff; background-color:#000; } - -.fieldWithErrors { - padding: 2px; - background-color: red; - display: table; -} - -#errorExplanation { - width: 400px; - border: 2px solid red; - padding: 7px; - padding-bottom: 12px; - margin-bottom: 20px; - background-color: #f0f0f0; -} - -#errorExplanation h2 { - text-align: left; - font-weight: bold; - padding: 5px 5px 5px 15px; - font-size: 12px; - margin: -7px; - background-color: #c00; - color: #fff; -} - -#errorExplanation p { - color: #333; - margin-bottom: 0; - padding: 5px; -} - -#errorExplanation ul li { - font-size: 12px; - list-style: square; -} - diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb deleted file mode 100644 index cca1d61..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<h1>Editing <%= singular_name %></h1> - -<%% form_for(@<%= singular_name %>) do |f| %> - <%%= f.error_messages %> - -<% for attribute in attributes -%> - <p> - <%%= f.label :<%= attribute.name %> %><br /> - <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %> - </p> -<% end -%> - <p> - <%%= f.submit 'Update' %> - </p> -<%% end %> - -<%%= link_to 'Show', @<%= singular_name %> %> | -<%%= link_to 'Back', <%= plural_name %>_path %> \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb deleted file mode 100644 index 2e603d5..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +++ /dev/null @@ -1,24 +0,0 @@ -<h1>Listing <%= plural_name %></h1> - -<table> - <tr> -<% for attribute in attributes -%> - <th><%= attribute.column.human_name %></th> -<% end -%> - </tr> - -<%% @<%= plural_name %>.each do |<%= singular_name %>| %> - <tr> -<% for attribute in attributes -%> - <td><%%=h <%= singular_name %>.<%= attribute.name %> %></td> -<% end -%> - <td><%%= link_to 'Show', <%= singular_name %> %></td> - <td><%%= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>) %></td> - <td><%%= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %></td> - </tr> -<%% end %> -</table> - -<br /> - -<%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %> \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb deleted file mode 100644 index 96c89fc..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +++ /dev/null @@ -1,17 +0,0 @@ -<h1>New <%= singular_name %></h1> - -<%% form_for(@<%= singular_name %>) do |f| %> - <%%= f.error_messages %> - -<% for attribute in attributes -%> - <p> - <%%= f.label :<%= attribute.name %> %><br /> - <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %> - </p> -<% end -%> - <p> - <%%= f.submit 'Create' %> - </p> -<%% end %> - -<%%= link_to 'Back', <%= plural_name %>_path %> \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb deleted file mode 100644 index adecaf7..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -<% for attribute in attributes -%> -<p> - <b><%= attribute.column.human_name %>:</b> - <%%=h @<%= singular_name %>.<%= attribute.name %> %> -</p> - -<% end -%> - -<%%= link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>) %> | -<%%= link_to 'Back', <%= plural_name %>_path %> \ No newline at end of file diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/USAGE deleted file mode 100644 index 87117a3..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/USAGE +++ /dev/null @@ -1,10 +0,0 @@ -Description: - Creates a migration to add the sessions table used by the Active Record - session store. Pass the migration name, either CamelCased or under_scored, - as an argument. - -Example: - `./script/generate session_migration CreateSessionTable` - - With 4 existing migrations, this creates the AddSessionTable migration - in db/migrate/005_add_session_table.rb diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb deleted file mode 100644 index 2e17703..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +++ /dev/null @@ -1,18 +0,0 @@ -class SessionMigrationGenerator < Rails::Generator::NamedBase - def initialize(runtime_args, runtime_options = {}) - runtime_args << 'add_session_table' if runtime_args.empty? - super - end - - def manifest - record do |m| - m.migration_template 'migration.rb', 'db/migrate', - :assigns => { :session_table_name => default_session_table_name } - end - end - - protected - def default_session_table_name - ActiveRecord::Base.pluralize_table_names ? 'session'.pluralize : 'session' - end -end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/templates/migration.rb b/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/templates/migration.rb deleted file mode 100644 index ca220a5..0000000 --- a/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/templates/migration.rb +++ /dev/null @@ -1,16 +0,0 @@ -class <%= class_name %> < ActiveRecord::Migration - def self.up - create_table :<%= session_table_name %> do |t| - t.string :session_id, :null => false - t.text :data - t.timestamps - end - - add_index :<%= session_table_name %>, :session_id - add_index :<%= session_table_name %>, :updated_at - end - - def self.down - drop_table :<%= session_table_name %> - end -end diff --git a/vendor/rails/railties/lib/rails_generator/lookup.rb b/vendor/rails/railties/lib/rails_generator/lookup.rb deleted file mode 100644 index a352536..0000000 --- a/vendor/rails/railties/lib/rails_generator/lookup.rb +++ /dev/null @@ -1,249 +0,0 @@ -require 'pathname' - -require File.dirname(__FILE__) + '/spec' - -class Object - class << self - # Lookup missing generators using const_missing. This allows any - # generator to reference another without having to know its location: - # RubyGems, ~/.rails/generators, and RAILS_ROOT/generators. - def lookup_missing_generator(class_id) - if md = /(.+)Generator$/.match(class_id.to_s) - name = md.captures.first.demodulize.underscore - Rails::Generator::Base.lookup(name).klass - else - const_missing_before_generators(class_id) - end - end - - unless respond_to?(:const_missing_before_generators) - alias_method :const_missing_before_generators, :const_missing - alias_method :const_missing, :lookup_missing_generator - end - end -end - -# User home directory lookup adapted from RubyGems. -def Dir.user_home - if ENV['HOME'] - ENV['HOME'] - elsif ENV['USERPROFILE'] - ENV['USERPROFILE'] - elsif ENV['HOMEDRIVE'] and ENV['HOMEPATH'] - "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}" - else - File.expand_path '~' - end -end - - -module Rails - module Generator - - # Generator lookup is managed by a list of sources which return specs - # describing where to find and how to create generators. This module - # provides class methods for manipulating the source list and looking up - # generator specs, and an #instance wrapper for quickly instantiating - # generators by name. - # - # A spec is not a generator: it's a description of where to find - # the generator and how to create it. A source is anything that - # yields generators from #each. PathSource and GemGeneratorSource are provided. - module Lookup - def self.included(base) - base.extend(ClassMethods) - base.use_component_sources! - end - - # Convenience method to instantiate another generator. - def instance(generator_name, args, runtime_options = {}) - self.class.instance(generator_name, args, runtime_options) - end - - module ClassMethods - # The list of sources where we look, in order, for generators. - def sources - read_inheritable_attribute(:sources) or use_component_sources! - end - - # Add a source to the end of the list. - def append_sources(*args) - sources.concat(args.flatten) - invalidate_cache! - end - - # Add a source to the beginning of the list. - def prepend_sources(*args) - write_inheritable_array(:sources, args.flatten + sources) - invalidate_cache! - end - - # Reset the source list. - def reset_sources - write_inheritable_attribute(:sources, []) - invalidate_cache! - end - - # Use application generators (app, ?). - def use_application_sources! - reset_sources - sources << PathSource.new(:builtin, "#{File.dirname(__FILE__)}/generators/applications") - end - - # Use component generators (model, controller, etc). - # 1. Rails application. If RAILS_ROOT is defined we know we're - # generating in the context of a Rails application, so search - # RAILS_ROOT/generators. - # 2. Look in plugins, either for generators/ or rails_generators/ - # directories within each plugin - # 3. User home directory. Search ~/.rails/generators. - # 4. RubyGems. Search for gems named *_generator, and look for - # generators within any RubyGem's - # /rails_generators/<generator_name>_generator.rb file. - # 5. Builtins. Model, controller, mailer, scaffold, and so on. - def use_component_sources! - reset_sources - if defined? ::RAILS_ROOT - sources << PathSource.new(:lib, "#{::RAILS_ROOT}/lib/generators") - sources << PathSource.new(:vendor, "#{::RAILS_ROOT}/vendor/generators") - Rails.configuration.plugin_paths.each do |path| - relative_path = Pathname.new(File.expand_path(path)).relative_path_from(Pathname.new(::RAILS_ROOT)) - sources << PathSource.new(:"plugins (#{relative_path})", "#{path}/*/**/{,rails_}generators") - end - end - sources << PathSource.new(:user, "#{Dir.user_home}/.rails/generators") - if Object.const_defined?(:Gem) - sources << GemGeneratorSource.new - sources << GemPathSource.new - end - sources << PathSource.new(:builtin, "#{File.dirname(__FILE__)}/generators/components") - end - - # Lookup knows how to find generators' Specs from a list of Sources. - # Searches the sources, in order, for the first matching name. - def lookup(generator_name) - @found ||= {} - generator_name = generator_name.to_s.downcase - @found[generator_name] ||= cache.find { |spec| spec.name == generator_name } - unless @found[generator_name] - chars = generator_name.scan(/./).map{|c|"#{c}.*?"} - rx = /^#{chars}$/ - gns = cache.select{|spec| spec.name =~ rx } - @found[generator_name] ||= gns.first if gns.length == 1 - raise GeneratorError, "Pattern '#{generator_name}' matches more than one generator: #{gns.map{|sp|sp.name}.join(', ')}" if gns.length > 1 - end - @found[generator_name] or raise GeneratorError, "Couldn't find '#{generator_name}' generator" - end - - # Convenience method to lookup and instantiate a generator. - def instance(generator_name, args = [], runtime_options = {}) - lookup(generator_name).klass.new(args, full_options(runtime_options)) - end - - private - # Lookup and cache every generator from the source list. - def cache - @cache ||= sources.inject([]) { |cache, source| cache + source.to_a } - end - - # Clear the cache whenever the source list changes. - def invalidate_cache! - @cache = nil - end - end - end - - # Sources enumerate (yield from #each) generator specs which describe - # where to find and how to create generators. Enumerable is mixed in so, - # for example, source.collect will retrieve every generator. - # Sources may be assigned a label to distinguish them. - class Source - include Enumerable - - attr_reader :label - def initialize(label) - @label = label - end - - # The each method must be implemented in subclasses. - # The base implementation raises an error. - def each - raise NotImplementedError - end - - # Return a convenient sorted list of all generator names. - def names - map { |spec| spec.name }.sort - end - end - - - # PathSource looks for generators in a filesystem directory. - class PathSource < Source - attr_reader :path - - def initialize(label, path) - super label - @path = path - end - - # Yield each eligible subdirectory. - def each - Dir["#{path}/[a-z]*"].each do |dir| - if File.directory?(dir) - yield Spec.new(File.basename(dir), dir, label) - end - end - end - end - - class AbstractGemSource < Source - def initialize - super :RubyGems - end - end - - # GemGeneratorSource hits the mines to quarry for generators. The latest versions - # of gems named *_generator are selected. - class GemGeneratorSource < AbstractGemSource - # Yield latest versions of generator gems. - def each - dependency = Gem::Dependency.new(/_generator$/, Gem::Requirement.default) - Gem::cache.search(dependency).inject({}) { |latest, gem| - hem = latest[gem.name] - latest[gem.name] = gem if hem.nil? or gem.version > hem.version - latest - }.values.each { |gem| - yield Spec.new(gem.name.sub(/_generator$/, ''), gem.full_gem_path, label) - } - end - end - - # GemPathSource looks for generators within any RubyGem's /rails_generators/<generator_name>_generator.rb file. - class GemPathSource < AbstractGemSource - # Yield each generator within rails_generator subdirectories. - def each - generator_full_paths.each do |generator| - yield Spec.new(File.basename(generator).sub(/_generator.rb$/, ''), File.dirname(generator), label) - end - end - - private - def generator_full_paths - @generator_full_paths ||= - Gem::cache.inject({}) do |latest, name_gem| - name, gem = name_gem - hem = latest[gem.name] - latest[gem.name] = gem if hem.nil? or gem.version > hem.version - latest - end.values.inject([]) do |mem, gem| - Dir[gem.full_gem_path + '/{rails_,}generators/**/*_generator.rb'].each do |generator| - mem << generator - end - mem - end - end - end - - end -end diff --git a/vendor/rails/railties/lib/rails_generator/manifest.rb b/vendor/rails/railties/lib/rails_generator/manifest.rb deleted file mode 100644 index 702effa..0000000 --- a/vendor/rails/railties/lib/rails_generator/manifest.rb +++ /dev/null @@ -1,53 +0,0 @@ -module Rails - module Generator - - # Manifest captures the actions a generator performs. Instantiate - # a manifest with an optional target object, hammer it with actions, - # then replay or rewind on the object of your choice. - # - # Example: - # manifest = Manifest.new { |m| - # m.make_directory '/foo' - # m.create_file '/foo/bar.txt' - # } - # manifest.replay(creator) - # manifest.rewind(destroyer) - class Manifest - attr_reader :target - - # Take a default action target. Yield self if block given. - def initialize(target = nil) - @target, @actions = target, [] - yield self if block_given? - end - - # Record an action. - def method_missing(action, *args, &block) - @actions << [action, args, block] - end - - # Replay recorded actions. - def replay(target = nil) - send_actions(target || @target, @actions) - end - - # Rewind recorded actions. - def rewind(target = nil) - send_actions(target || @target, @actions.reverse) - end - - # Erase recorded actions. - def erase - @actions = [] - end - - private - def send_actions(target, actions) - actions.each do |method, args, block| - target.send(method, *args, &block) - end - end - end - - end -end diff --git a/vendor/rails/railties/lib/rails_generator/options.rb b/vendor/rails/railties/lib/rails_generator/options.rb deleted file mode 100644 index 5f6aefa..0000000 --- a/vendor/rails/railties/lib/rails_generator/options.rb +++ /dev/null @@ -1,150 +0,0 @@ -require 'optparse' - -module Rails - module Generator - module Options - def self.included(base) - base.extend(ClassMethods) - class << base - if respond_to?(:inherited) - alias_method :inherited_without_options, :inherited - end - alias_method :inherited, :inherited_with_options - end - end - - module ClassMethods - def inherited_with_options(sub) - inherited_without_options(sub) if respond_to?(:inherited_without_options) - sub.extend(Rails::Generator::Options::ClassMethods) - end - - def mandatory_options(options = nil) - if options - write_inheritable_attribute(:mandatory_options, options) - else - read_inheritable_attribute(:mandatory_options) or write_inheritable_attribute(:mandatory_options, {}) - end - end - - def default_options(options = nil) - if options - write_inheritable_attribute(:default_options, options) - else - read_inheritable_attribute(:default_options) or write_inheritable_attribute(:default_options, {}) - end - end - - # Merge together our class options. In increasing precedence: - # default_options (class default options) - # runtime_options (provided as argument) - # mandatory_options (class mandatory options) - def full_options(runtime_options = {}) - default_options.merge(runtime_options).merge(mandatory_options) - end - - end - - # Each instance has an options hash that's populated by #parse. - def options - @options ||= {} - end - attr_writer :options - - protected - # Convenient access to class mandatory options. - def mandatory_options - self.class.mandatory_options - end - - # Convenient access to class default options. - def default_options - self.class.default_options - end - - # Merge together our instance options. In increasing precedence: - # default_options (class default options) - # options (instance options) - # runtime_options (provided as argument) - # mandatory_options (class mandatory options) - def full_options(runtime_options = {}) - self.class.full_options(options.merge(runtime_options)) - end - - # Parse arguments into the options hash. Classes may customize - # parsing behavior by overriding these methods: - # #banner Usage: ./script/generate [options] - # #add_options! Options: - # some options.. - # #add_general_options! General Options: - # general options.. - def parse!(args, runtime_options = {}) - self.options = {} - - @option_parser = OptionParser.new do |opt| - opt.banner = banner - add_options!(opt) - add_general_options!(opt) - opt.parse!(args) - end - - return args - ensure - self.options = full_options(runtime_options) - end - - # Raise a usage error. Override usage_message to provide a blurb - # after the option parser summary. - def usage(message = usage_message) - raise UsageError, "#{@option_parser}\n#{message}" - end - - def usage_message - '' - end - - # Override with your own usage banner. - def banner - "Usage: #{$0} [options]" - end - - # Override to add your options to the parser: - # def add_options!(opt) - # opt.on('-v', '--verbose') { |value| options[:verbose] = value } - # end - def add_options!(opt) - end - - # Adds general options like -h and --quiet. Usually don't override. - def add_general_options!(opt) - opt.separator '' - opt.separator 'Rails Info:' - opt.on('-v', '--version', 'Show the Rails version number and quit.') - opt.on('-h', '--help', 'Show this help message and quit.') { |v| options[:help] = v } - - opt.separator '' - opt.separator 'General Options:' - - opt.on('-p', '--pretend', 'Run but do not make any changes.') { |v| options[:pretend] = v } - opt.on('-f', '--force', 'Overwrite files that already exist.') { options[:collision] = :force } - opt.on('-s', '--skip', 'Skip files that already exist.') { options[:collision] = :skip } - opt.on('-q', '--quiet', 'Suppress normal output.') { |v| options[:quiet] = v } - opt.on('-t', '--backtrace', 'Debugging: show backtrace on errors.') { |v| options[:backtrace] = v } - opt.on('-c', '--svn', 'Modify files with subversion. (Note: svn must be in path)') do - options[:svn] = `svn status`.inject({}) do |opt, e| - opt[e.chomp[7..-1]] = true - opt - end - end - opt.on('-g', '--git', 'Modify files with git. (Note: git must be in path)') do - options[:git] = `git status`.inject({:new => {}, :modified => {}}) do |opt, e| - opt[:new][e.chomp[14..-1]] = true if e =~ /new file:/ - opt[:modified][e.chomp[14..-1]] = true if e =~ /modified:/ - opt - end - end - end - - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/scripts.rb b/vendor/rails/railties/lib/rails_generator/scripts.rb deleted file mode 100644 index 9b1a998..0000000 --- a/vendor/rails/railties/lib/rails_generator/scripts.rb +++ /dev/null @@ -1,89 +0,0 @@ -require File.dirname(__FILE__) + '/options' - -module Rails - module Generator - module Scripts - - # Generator scripts handle command-line invocation. Each script - # responds to an invoke! class method which handles option parsing - # and generator invocation. - class Base - include Options - default_options :collision => :ask, :quiet => false - - # Run the generator script. Takes an array of unparsed arguments - # and a hash of parsed arguments, takes the generator as an option - # or first remaining argument, and invokes the requested command. - def run(args = [], runtime_options = {}) - begin - parse!(args.dup, runtime_options) - rescue OptionParser::InvalidOption => e - # Don't cry, script. Generators want what you think is invalid. - end - - # Generator name is the only required option. - unless options[:generator] - usage if args.empty? - options[:generator] ||= args.shift - end - - # Look up generator instance and invoke command on it. - Rails::Generator::Base.instance(options[:generator], args, options).command(options[:command]).invoke! - rescue => e - puts e - puts " #{e.backtrace.join("\n ")}\n" if options[:backtrace] - raise SystemExit - end - - protected - # Override with your own script usage banner. - def banner - "Usage: #{$0} generator [options] [args]" - end - - def usage_message - usage = "\nInstalled Generators\n" - Rails::Generator::Base.sources.inject([]) do |mem, source| - # Using an association list instead of a hash to preserve order, - # for aesthetic reasons more than anything else. - label = source.label.to_s.capitalize - pair = mem.assoc(label) - mem << (pair = [label, []]) if pair.nil? - pair[1] |= source.names - mem - end.each do |label, names| - usage << " #{label}: #{names.join(', ')}\n" unless names.empty? - end - - usage << <<end_blurb - -More are available at http://wiki.rubyonrails.org/rails/pages/AvailableGenerators - 1. Download, for example, login_generator.zip - 2. Unzip to directory #{Dir.user_home}/.rails/generators/login - to use the generator with all your Rails apps -end_blurb - - if Object.const_defined?(:RAILS_ROOT) - usage << <<end_blurb - or to #{File.expand_path(RAILS_ROOT)}/lib/generators/login - to use with this app only. -end_blurb - end - - usage << <<end_blurb - 3. Run generate with no arguments for usage information - #{$0} login - -Generator gems are also available: - 1. gem search -r generator - 2. gem install login_generator - 3. #{$0} login - -end_blurb - return usage - end - end # Base - - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/scripts/destroy.rb b/vendor/rails/railties/lib/rails_generator/scripts/destroy.rb deleted file mode 100644 index a7c2a14..0000000 --- a/vendor/rails/railties/lib/rails_generator/scripts/destroy.rb +++ /dev/null @@ -1,29 +0,0 @@ -require File.dirname(__FILE__) + '/../scripts' - -module Rails::Generator::Scripts - class Destroy < Base - mandatory_options :command => :destroy - - protected - def usage_message - usage = "\nInstalled Generators\n" - Rails::Generator::Base.sources.each do |source| - label = source.label.to_s.capitalize - names = source.names - usage << " #{label}: #{names.join(', ')}\n" unless names.empty? - end - - usage << <<end_blurb - -script/generate command. For instance, 'script/destroy migration CreatePost' -will delete the appropriate XXX_create_post.rb migration file in db/migrate, -while 'script/destroy scaffold Post' will delete the posts controller and -views, post model and migration, all associated tests, and the map.resources -:posts line in config/routes.rb. - -For instructions on finding new generators, run script/generate. -end_blurb - return usage - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/scripts/generate.rb b/vendor/rails/railties/lib/rails_generator/scripts/generate.rb deleted file mode 100644 index 1fe2f54..0000000 --- a/vendor/rails/railties/lib/rails_generator/scripts/generate.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.dirname(__FILE__) + '/../scripts' - -module Rails::Generator::Scripts - class Generate < Base - mandatory_options :command => :create - end -end diff --git a/vendor/rails/railties/lib/rails_generator/scripts/update.rb b/vendor/rails/railties/lib/rails_generator/scripts/update.rb deleted file mode 100644 index 53a9faa..0000000 --- a/vendor/rails/railties/lib/rails_generator/scripts/update.rb +++ /dev/null @@ -1,12 +0,0 @@ -require File.dirname(__FILE__) + '/../scripts' - -module Rails::Generator::Scripts - class Update < Base - mandatory_options :command => :update - - protected - def banner - "Usage: #{$0} [options] scaffold" - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/secret_key_generator.rb b/vendor/rails/railties/lib/rails_generator/secret_key_generator.rb deleted file mode 100644 index 7dd495a..0000000 --- a/vendor/rails/railties/lib/rails_generator/secret_key_generator.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'active_support/deprecation' - -module Rails - # A class for creating random secret keys. This class will do its best to create a - # random secret key that's as secure as possible, using whatever methods are - # available on the current platform. For example: - # - # generator = Rails::SecretKeyGenerator("some unique identifier, such as the application name") - # generator.generate_secret # => "f3f1be90053fa851... (some long string)" - # - # This class is *deprecated* in Rails 2.2 in favor of ActiveSupport::SecureRandom. - # It is currently a wrapper around ActiveSupport::SecureRandom. - class SecretKeyGenerator - def initialize(identifier) - end - - # Generate a random secret key with the best possible method available on - # the current platform. - def generate_secret - ActiveSupport::SecureRandom.hex(64) - end - deprecate :generate_secret=>"You should use ActiveSupport::SecureRandom.hex(64)" - end -end diff --git a/vendor/rails/railties/lib/rails_generator/simple_logger.rb b/vendor/rails/railties/lib/rails_generator/simple_logger.rb deleted file mode 100644 index d750f07..0000000 --- a/vendor/rails/railties/lib/rails_generator/simple_logger.rb +++ /dev/null @@ -1,46 +0,0 @@ -module Rails - module Generator - class SimpleLogger # :nodoc: - attr_reader :out - attr_accessor :quiet - - def initialize(out = $stdout) - @out = out - @quiet = false - @level = 0 - end - - def log(status, message, &block) - @out.print("%12s %s%s\n" % [status, ' ' * @level, message]) unless quiet - indent(&block) if block_given? - end - - def indent(&block) - @level += 1 - if block_given? - begin - block.call - ensure - outdent - end - end - end - - def outdent - @level -= 1 - if block_given? - begin - block.call - ensure - indent - end - end - end - - private - def method_missing(method, *args, &block) - log(method.to_s, args.first, &block) - end - end - end -end diff --git a/vendor/rails/railties/lib/rails_generator/spec.rb b/vendor/rails/railties/lib/rails_generator/spec.rb deleted file mode 100644 index 9d780b7..0000000 --- a/vendor/rails/railties/lib/rails_generator/spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -module Rails - module Generator - # A spec knows where a generator was found and how to instantiate it. - # Metadata include the generator's name, its base path, and the source - # which yielded it (PathSource, GemPathSource, etc.) - class Spec - attr_reader :name, :path, :source - - def initialize(name, path, source) - @name, @path, @source = name, path, source - end - - # Look up the generator class. Require its class file, find the class - # in ObjectSpace, tag it with this spec, and return. - def klass - unless @klass - require class_file - @klass = lookup_class - @klass.spec = self - end - @klass - end - - def class_file - "#{path}/#{name}_generator.rb" - end - - def class_name - "#{name.camelize}Generator" - end - - private - # Search for the first Class descending from Rails::Generator::Base - # whose name matches the requested class name. - def lookup_class - ObjectSpace.each_object(Class) do |obj| - return obj if obj.ancestors.include?(Rails::Generator::Base) and - obj.name.split('::').last == class_name - end - raise NameError, "Missing #{class_name} class in #{class_file}" - end - end - end -end diff --git a/vendor/rails/railties/lib/railties_path.rb b/vendor/rails/railties/lib/railties_path.rb deleted file mode 100644 index a298a4c..0000000 --- a/vendor/rails/railties/lib/railties_path.rb +++ /dev/null @@ -1 +0,0 @@ -RAILTIES_PATH = File.join(File.dirname(__FILE__), '..') diff --git a/vendor/rails/railties/lib/ruby_version_check.rb b/vendor/rails/railties/lib/ruby_version_check.rb deleted file mode 100644 index 68d3acc..0000000 --- a/vendor/rails/railties/lib/ruby_version_check.rb +++ /dev/null @@ -1,17 +0,0 @@ -min_release = "1.8.2 (2004-12-25)" -ruby_release = "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE})" -if ruby_release =~ /1\.8\.3/ - abort <<-end_message - - Rails does not work with Ruby version 1.8.3. - Please upgrade to version 1.8.4 or downgrade to 1.8.2. - - end_message -elsif ruby_release < min_release - abort <<-end_message - - Rails requires Ruby version #{min_release} or later. - You're running #{ruby_release}; please upgrade to continue. - - end_message -end diff --git a/vendor/rails/railties/lib/rubyprof_ext.rb b/vendor/rails/railties/lib/rubyprof_ext.rb deleted file mode 100644 index f6e9035..0000000 --- a/vendor/rails/railties/lib/rubyprof_ext.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'prof' - -module Prof #:nodoc: - # Adapted from Shugo Maeda's unprof.rb - def self.print_profile(results, io = $stderr) - total = results.detect { |i| - i.method_class.nil? && i.method_id == :"#toplevel" - }.total_time - total = 0.001 if total < 0.001 - - io.puts " %% cumulative self self total" - io.puts " time seconds seconds calls ms/call ms/call name" - - sum = 0.0 - for r in results - sum += r.self_time - - name = if r.method_class.nil? - r.method_id.to_s - elsif r.method_class.is_a?(Class) - "#{r.method_class}##{r.method_id}" - else - "#{r.method_class}.#{r.method_id}" - end - io.printf "%6.2f %8.3f %8.3f %8d %8.2f %8.2f %s\n", - r.self_time / total * 100, - sum, - r.self_time, - r.count, - r.self_time * 1000 / r.count, - r.total_time * 1000 / r.count, - name - end - end -end diff --git a/vendor/rails/railties/lib/source_annotation_extractor.rb b/vendor/rails/railties/lib/source_annotation_extractor.rb deleted file mode 100644 index 591fd6f..0000000 --- a/vendor/rails/railties/lib/source_annotation_extractor.rb +++ /dev/null @@ -1,102 +0,0 @@ -# Implements the logic behind the rake tasks for annotations like -# -# rake notes -# rake notes:optimize -# -# and friends. See <tt>rake -T notes</tt> and <tt>railties/lib/tasks/annotations.rake</tt>. -# -# Annotation objects are triplets <tt>:line</tt>, <tt>:tag</tt>, <tt>:text</tt> that -# represent the line where the annotation lives, its tag, and its text. Note -# the filename is not stored. -# -# Annotations are looked for in comments and modulus whitespace they have to -# start with the tag optionally followed by a colon. Everything up to the end -# of the line (or closing ERb comment tag) is considered to be their text. -class SourceAnnotationExtractor - class Annotation < Struct.new(:line, :tag, :text) - - # Returns a representation of the annotation that looks like this: - # - # [126] [TODO] This algorithm is simple and clearly correct, make it faster. - # - # If +options+ has a flag <tt>:tag</tt> the tag is shown as in the example above. - # Otherwise the string contains just line and text. - def to_s(options={}) - s = "[%3d] " % line - s << "[#{tag}] " if options[:tag] - s << text - end - end - - # Prints all annotations with tag +tag+ under the root directories +app+, +lib+, - # and +test+ (recursively). Only filenames with extension +.builder+, +.rb+, - # +.rxml+, +.rjs+, +.rhtml+, or +.erb+ are taken into account. The +options+ - # hash is passed to each annotation's +to_s+. - # - # This class method is the single entry point for the rake tasks. - def self.enumerate(tag, options={}) - extractor = new(tag) - extractor.display(extractor.find, options) - end - - attr_reader :tag - - def initialize(tag) - @tag = tag - end - - # Returns a hash that maps filenames under +dirs+ (recursively) to arrays - # with their annotations. Only files with annotations are included, and only - # those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+ - # are taken into account. - def find(dirs=%w(app lib test)) - dirs.inject({}) { |h, dir| h.update(find_in(dir)) } - end - - # Returns a hash that maps filenames under +dir+ (recursively) to arrays - # with their annotations. Only files with annotations are included, and only - # those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+ - # are taken into account. - def find_in(dir) - results = {} - - Dir.glob("#{dir}/*") do |item| - next if File.basename(item)[0] == ?. - - if File.directory?(item) - results.update(find_in(item)) - elsif item =~ /\.(builder|(r(?:b|xml|js)))$/ - results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/)) - elsif item =~ /\.(rhtml|erb)$/ - results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/)) - end - end - - results - end - - # If +file+ is the filename of a file that contains annotations this method returns - # a hash with a single entry that maps +file+ to an array of its annotations. - # Otherwise it returns an empty hash. - def extract_annotations_from(file, pattern) - lineno = 0 - result = File.readlines(file).inject([]) do |list, line| - lineno += 1 - next list unless line =~ pattern - list << Annotation.new(lineno, $1, $2) - end - result.empty? ? {} : { file => result } - end - - # Prints the mapping from filenames to annotations in +results+ ordered by filename. - # The +options+ hash is passed to each annotation's +to_s+. - def display(results, options={}) - results.keys.sort.each do |file| - puts "#{file}:" - results[file].each do |note| - puts " * #{note.to_s(options)}" - end - puts - end - end -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/tasks/annotations.rake b/vendor/rails/railties/lib/tasks/annotations.rake deleted file mode 100644 index 48ac400..0000000 --- a/vendor/rails/railties/lib/tasks/annotations.rake +++ /dev/null @@ -1,20 +0,0 @@ -require 'source_annotation_extractor' - -desc "Enumerate all annotations" -task :notes do - SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", :tag => true -end - -namespace :notes do - ["OPTIMIZE", "FIXME", "TODO"].each do |annotation| - desc "Enumerate all #{annotation} annotations" - task annotation.downcase.intern do - SourceAnnotationExtractor.enumerate annotation - end - end - - desc "Enumerate a custom annotation, specify with ANNOTATION=WTFHAX" - task :custom do - SourceAnnotationExtractor.enumerate ENV['ANNOTATION'] - end -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/tasks/databases.rake b/vendor/rails/railties/lib/tasks/databases.rake deleted file mode 100644 index 9588fab..0000000 --- a/vendor/rails/railties/lib/tasks/databases.rake +++ /dev/null @@ -1,423 +0,0 @@ -namespace :db do - task :load_config => :rails_env do - require 'active_record' - ActiveRecord::Base.configurations = Rails::Configuration.new.database_configuration - end - - namespace :create do - desc 'Create all the local databases defined in config/database.yml' - task :all => :load_config do - ActiveRecord::Base.configurations.each_value do |config| - # Skip entries that don't have a database key, such as the first entry here: - # - # defaults: &defaults - # adapter: mysql - # username: root - # password: - # host: localhost - # - # development: - # database: blog_development - # <<: *defaults - next unless config['database'] - # Only connect to local databases - local_database?(config) { create_database(config) } - end - end - end - - desc 'Create the database defined in config/database.yml for the current RAILS_ENV' - task :create => :load_config do - create_database(ActiveRecord::Base.configurations[RAILS_ENV]) - end - - def create_database(config) - begin - if config['adapter'] =~ /sqlite/ - if File.exist?(config['database']) - $stderr.puts "#{config['database']} already exists" - else - begin - # Create the SQLite database - ActiveRecord::Base.establish_connection(config) - ActiveRecord::Base.connection - rescue - $stderr.puts $!, *($!.backtrace) - $stderr.puts "Couldn't create database for #{config.inspect}" - end - end - return # Skip the else clause of begin/rescue - else - ActiveRecord::Base.establish_connection(config) - ActiveRecord::Base.connection - end - rescue - case config['adapter'] - when 'mysql' - @charset = ENV['CHARSET'] || 'utf8' - @collation = ENV['COLLATION'] || 'utf8_general_ci' - begin - ActiveRecord::Base.establish_connection(config.merge('database' => nil)) - ActiveRecord::Base.connection.create_database(config['database'], :charset => (config['charset'] || @charset), :collation => (config['collation'] || @collation)) - ActiveRecord::Base.establish_connection(config) - rescue - $stderr.puts "Couldn't create database for #{config.inspect}, charset: #{config['charset'] || @charset}, collation: #{config['collation'] || @collation} (if you set the charset manually, make sure you have a matching collation)" - end - when 'postgresql' - @encoding = config[:encoding] || ENV['CHARSET'] || 'utf8' - begin - ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public')) - ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => @encoding)) - ActiveRecord::Base.establish_connection(config) - rescue - $stderr.puts $!, *($!.backtrace) - $stderr.puts "Couldn't create database for #{config.inspect}" - end - end - else - $stderr.puts "#{config['database']} already exists" - end - end - - namespace :drop do - desc 'Drops all the local databases defined in config/database.yml' - task :all => :load_config do - ActiveRecord::Base.configurations.each_value do |config| - # Skip entries that don't have a database key - next unless config['database'] - # Only connect to local databases - local_database?(config) { drop_database(config) } - end - end - end - - desc 'Drops the database for the current RAILS_ENV' - task :drop => :load_config do - config = ActiveRecord::Base.configurations[RAILS_ENV || 'development'] - begin - drop_database(config) - rescue Exception => e - puts "Couldn't drop #{config['database']} : #{e.inspect}" - end - end - - def local_database?(config, &block) - if %w( 127.0.0.1 localhost ).include?(config['host']) || config['host'].blank? - yield - else - puts "This task only modifies local databases. #{config['database']} is on a remote host." - end - end - - - desc "Migrate the database through scripts in db/migrate and update db/schema.rb by invoking db:schema:dump. Target specific version with VERSION=x. Turn off output with VERBOSE=false." - task :migrate => :environment do - ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true - ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil) - Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby - end - - namespace :migrate do - desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x. Target specific version with VERSION=x.' - task :redo => :environment do - if ENV["VERSION"] - Rake::Task["db:migrate:down"].invoke - Rake::Task["db:migrate:up"].invoke - else - Rake::Task["db:rollback"].invoke - Rake::Task["db:migrate"].invoke - end - end - - desc 'Resets your database using your migrations for the current environment' - task :reset => ["db:drop", "db:create", "db:migrate"] - - desc 'Runs the "up" for a given migration VERSION.' - task :up => :environment do - version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil - raise "VERSION is required" unless version - ActiveRecord::Migrator.run(:up, "db/migrate/", version) - Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby - end - - desc 'Runs the "down" for a given migration VERSION.' - task :down => :environment do - version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil - raise "VERSION is required" unless version - ActiveRecord::Migrator.run(:down, "db/migrate/", version) - Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby - end - end - - desc 'Rolls the schema back to the previous version. Specify the number of steps with STEP=n' - task :rollback => :environment do - step = ENV['STEP'] ? ENV['STEP'].to_i : 1 - ActiveRecord::Migrator.rollback('db/migrate/', step) - Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby - end - - desc 'Drops and recreates the database from db/schema.rb for the current environment.' - task :reset => ['db:drop', 'db:create', 'db:schema:load'] - - desc "Retrieves the charset for the current environment's database" - task :charset => :environment do - config = ActiveRecord::Base.configurations[RAILS_ENV || 'development'] - case config['adapter'] - when 'mysql' - ActiveRecord::Base.establish_connection(config) - puts ActiveRecord::Base.connection.charset - when 'postgresql' - ActiveRecord::Base.establish_connection(config) - puts ActiveRecord::Base.connection.encoding - else - puts 'sorry, your database adapter is not supported yet, feel free to submit a patch' - end - end - - desc "Retrieves the collation for the current environment's database" - task :collation => :environment do - config = ActiveRecord::Base.configurations[RAILS_ENV || 'development'] - case config['adapter'] - when 'mysql' - ActiveRecord::Base.establish_connection(config) - puts ActiveRecord::Base.connection.collation - else - puts 'sorry, your database adapter is not supported yet, feel free to submit a patch' - end - end - - desc "Retrieves the current schema version number" - task :version => :environment do - puts "Current version: #{ActiveRecord::Migrator.current_version}" - end - - desc "Raises an error if there are pending migrations" - task :abort_if_pending_migrations => :environment do - if defined? ActiveRecord - pending_migrations = ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations - - if pending_migrations.any? - puts "You have #{pending_migrations.size} pending migrations:" - pending_migrations.each do |pending_migration| - puts ' %4d %s' % [pending_migration.version, pending_migration.name] - end - abort %{Run "rake db:migrate" to update your database then try again.} - end - end - end - - namespace :fixtures do - desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures." - task :load => :environment do - require 'active_record/fixtures' - ActiveRecord::Base.establish_connection(Rails.env) - base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures') - fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir - - (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file| - Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*')) - end - end - - desc "Search for a fixture given a LABEL or ID. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures." - task :identify => :environment do - require "active_record/fixtures" - - label, id = ENV["LABEL"], ENV["ID"] - raise "LABEL or ID required" if label.blank? && id.blank? - - puts %Q(The fixture ID for "#{label}" is #{Fixtures.identify(label)}.) if label - - base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures') - Dir["#{base_dir}/**/*.yml"].each do |file| - if data = YAML::load(ERB.new(IO.read(file)).result) - data.keys.each do |key| - key_id = Fixtures.identify(key) - - if key == label || key_id == id.to_i - puts "#{file}: #{key} (#{key_id})" - end - end - end - end - end - end - - namespace :schema do - desc "Create a db/schema.rb file that can be portably used against any DB supported by AR" - task :dump => :environment do - require 'active_record/schema_dumper' - File.open(ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb", "w") do |file| - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file) - end - Rake::Task["db:schema:dump"].reenable - end - - desc "Load a schema.rb file into the database" - task :load => :environment do - file = ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb" - load(file) - end - end - - namespace :structure do - desc "Dump the database structure to a SQL file" - task :dump => :environment do - abcs = ActiveRecord::Base.configurations - case abcs[RAILS_ENV]["adapter"] - when "mysql", "oci", "oracle" - ActiveRecord::Base.establish_connection(abcs[RAILS_ENV]) - File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump } - when "postgresql" - ENV['PGHOST'] = abcs[RAILS_ENV]["host"] if abcs[RAILS_ENV]["host"] - ENV['PGPORT'] = abcs[RAILS_ENV]["port"].to_s if abcs[RAILS_ENV]["port"] - ENV['PGPASSWORD'] = abcs[RAILS_ENV]["password"].to_s if abcs[RAILS_ENV]["password"] - search_path = abcs[RAILS_ENV]["schema_search_path"] - search_path = "--schema=#{search_path}" if search_path - `pg_dump -i -U "#{abcs[RAILS_ENV]["username"]}" -s -x -O -f db/#{RAILS_ENV}_structure.sql #{search_path} #{abcs[RAILS_ENV]["database"]}` - raise "Error dumping database" if $?.exitstatus == 1 - when "sqlite", "sqlite3" - dbfile = abcs[RAILS_ENV]["database"] || abcs[RAILS_ENV]["dbfile"] - `#{abcs[RAILS_ENV]["adapter"]} #{dbfile} .schema > db/#{RAILS_ENV}_structure.sql` - when "sqlserver" - `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /f db\\#{RAILS_ENV}_structure.sql /q /A /r` - `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /F db\ /q /A /r` - when "firebird" - set_firebird_env(abcs[RAILS_ENV]) - db_string = firebird_db_string(abcs[RAILS_ENV]) - sh "isql -a #{db_string} > #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql" - else - raise "Task not supported by '#{abcs["test"]["adapter"]}'" - end - - if ActiveRecord::Base.connection.supports_migrations? - File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information } - end - end - end - - namespace :test do - desc "Recreate the test database from the current schema.rb" - task :load => 'db:test:purge' do - ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test']) - ActiveRecord::Schema.verbose = false - Rake::Task["db:schema:load"].invoke - end - - desc "Recreate the test database from the current environment's database schema" - task :clone => %w(db:schema:dump db:test:load) - - desc "Recreate the test databases from the development structure" - task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do - abcs = ActiveRecord::Base.configurations - case abcs["test"]["adapter"] - when "mysql" - ActiveRecord::Base.establish_connection(:test) - ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0') - IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table| - ActiveRecord::Base.connection.execute(table) - end - when "postgresql" - ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"] - ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"] - ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"] - `psql -U "#{abcs["test"]["username"]}" -f #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}` - when "sqlite", "sqlite3" - dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"] - `#{abcs["test"]["adapter"]} #{dbfile} < #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql` - when "sqlserver" - `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql` - when "oci", "oracle" - ActiveRecord::Base.establish_connection(:test) - IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl| - ActiveRecord::Base.connection.execute(ddl) - end - when "firebird" - set_firebird_env(abcs["test"]) - db_string = firebird_db_string(abcs["test"]) - sh "isql -i #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{db_string}" - else - raise "Task not supported by '#{abcs["test"]["adapter"]}'" - end - end - - desc "Empty the test database" - task :purge => :environment do - abcs = ActiveRecord::Base.configurations - case abcs["test"]["adapter"] - when "mysql" - ActiveRecord::Base.establish_connection(:test) - ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"], abcs["test"]) - when "postgresql" - ActiveRecord::Base.clear_active_connections! - drop_database(abcs['test']) - create_database(abcs['test']) - when "sqlite","sqlite3" - dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"] - File.delete(dbfile) if File.exist?(dbfile) - when "sqlserver" - dropfkscript = "#{abcs["test"]["host"]}.#{abcs["test"]["database"]}.DP1".gsub(/\\/,'-') - `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{dropfkscript}` - `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql` - when "oci", "oracle" - ActiveRecord::Base.establish_connection(:test) - ActiveRecord::Base.connection.structure_drop.split(";\n\n").each do |ddl| - ActiveRecord::Base.connection.execute(ddl) - end - when "firebird" - ActiveRecord::Base.establish_connection(:test) - ActiveRecord::Base.connection.recreate_database! - else - raise "Task not supported by '#{abcs["test"]["adapter"]}'" - end - end - - desc 'Check for pending migrations and load the test schema' - task :prepare => 'db:abort_if_pending_migrations' do - if defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank? - Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:load" }[ActiveRecord::Base.schema_format]].invoke - end - end - end - - namespace :sessions do - desc "Creates a sessions migration for use with ActiveRecord::SessionStore" - task :create => :environment do - raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations? - require 'rails_generator' - require 'rails_generator/scripts/generate' - Rails::Generator::Scripts::Generate.new.run(["session_migration", ENV["MIGRATION"] || "CreateSessions"]) - end - - desc "Clear the sessions table" - task :clear => :environment do - ActiveRecord::Base.connection.execute "DELETE FROM #{session_table_name}" - end - end -end - -def drop_database(config) - case config['adapter'] - when 'mysql' - ActiveRecord::Base.establish_connection(config) - ActiveRecord::Base.connection.drop_database config['database'] - when /^sqlite/ - FileUtils.rm(File.join(RAILS_ROOT, config['database'])) - when 'postgresql' - ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public')) - ActiveRecord::Base.connection.drop_database config['database'] - end -end - -def session_table_name - ActiveRecord::Base.pluralize_table_names ? :sessions : :session -end - -def set_firebird_env(config) - ENV["ISC_USER"] = config["username"].to_s if config["username"] - ENV["ISC_PASSWORD"] = config["password"].to_s if config["password"] -end - -def firebird_db_string(config) - FireRuby::Database.db_string_for(config.symbolize_keys) -end diff --git a/vendor/rails/railties/lib/tasks/documentation.rake b/vendor/rails/railties/lib/tasks/documentation.rake deleted file mode 100644 index 8b41478..0000000 --- a/vendor/rails/railties/lib/tasks/documentation.rake +++ /dev/null @@ -1,88 +0,0 @@ -namespace :doc do - desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\"" - Rake::RDocTask.new("app") { |rdoc| - rdoc.rdoc_dir = 'doc/app' - rdoc.template = ENV['template'] if ENV['template'] - rdoc.title = ENV['title'] || "Rails Application Documentation" - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.options << '--charset' << 'utf-8' - rdoc.rdoc_files.include('doc/README_FOR_APP') - rdoc.rdoc_files.include('app/**/*.rb') - rdoc.rdoc_files.include('lib/**/*.rb') - } - - desc "Generate documentation for the Rails framework" - Rake::RDocTask.new("rails") { |rdoc| - rdoc.rdoc_dir = 'doc/api' - rdoc.template = "#{ENV['template']}.rb" if ENV['template'] - rdoc.title = "Rails Framework Documentation" - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('vendor/rails/railties/CHANGELOG') - rdoc.rdoc_files.include('vendor/rails/railties/MIT-LICENSE') - rdoc.rdoc_files.include('vendor/rails/railties/README') - rdoc.rdoc_files.include('vendor/rails/railties/lib/{*.rb,commands/*.rb,rails_generator/*.rb}') - rdoc.rdoc_files.include('vendor/rails/activerecord/README') - rdoc.rdoc_files.include('vendor/rails/activerecord/CHANGELOG') - rdoc.rdoc_files.include('vendor/rails/activerecord/lib/active_record/**/*.rb') - rdoc.rdoc_files.exclude('vendor/rails/activerecord/lib/active_record/vendor/*') - rdoc.rdoc_files.include('vendor/rails/activeresource/README') - rdoc.rdoc_files.include('vendor/rails/activeresource/CHANGELOG') - rdoc.rdoc_files.include('vendor/rails/activeresource/lib/active_resource.rb') - rdoc.rdoc_files.include('vendor/rails/activeresource/lib/active_resource/*') - rdoc.rdoc_files.include('vendor/rails/actionpack/README') - rdoc.rdoc_files.include('vendor/rails/actionpack/CHANGELOG') - rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_controller/**/*.rb') - rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_view/**/*.rb') - rdoc.rdoc_files.include('vendor/rails/actionmailer/README') - rdoc.rdoc_files.include('vendor/rails/actionmailer/CHANGELOG') - rdoc.rdoc_files.include('vendor/rails/actionmailer/lib/action_mailer/base.rb') - rdoc.rdoc_files.include('vendor/rails/activesupport/README') - rdoc.rdoc_files.include('vendor/rails/activesupport/CHANGELOG') - rdoc.rdoc_files.include('vendor/rails/activesupport/lib/active_support/**/*.rb') - } - - plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) } - - desc "Generate documentation for all installed plugins" - task :plugins => plugins.collect { |plugin| "doc:plugins:#{plugin}" } - - desc "Remove plugin documentation" - task :clobber_plugins do - rm_rf 'doc/plugins' rescue nil - end - - desc "Generate Rails guides" - task :guides do - require File.join(RAILTIES_PATH, "guides/rails_guides") - RailsGuides::Generator.new(File.join(RAILS_ROOT, "doc/guides")).generate - end - - namespace :plugins do - # Define doc tasks for each plugin - plugins.each do |plugin| - desc "Generate documentation for the #{plugin} plugin" - task(plugin => :environment) do - plugin_base = "vendor/plugins/#{plugin}" - options = [] - files = Rake::FileList.new - options << "-o doc/plugins/#{plugin}" - options << "--title '#{plugin.titlecase} Plugin Documentation'" - options << '--line-numbers' << '--inline-source' - options << '--charset' << 'utf-8' - options << '-T html' - - files.include("#{plugin_base}/lib/**/*.rb") - if File.exist?("#{plugin_base}/README") - files.include("#{plugin_base}/README") - options << "--main '#{plugin_base}/README'" - end - files.include("#{plugin_base}/CHANGELOG") if File.exist?("#{plugin_base}/CHANGELOG") - - options << files.to_s - - sh %(rdoc #{options * ' '}) - end - end - end -end diff --git a/vendor/rails/railties/lib/tasks/framework.rake b/vendor/rails/railties/lib/tasks/framework.rake deleted file mode 100644 index 191c936..0000000 --- a/vendor/rails/railties/lib/tasks/framework.rake +++ /dev/null @@ -1,143 +0,0 @@ -namespace :rails do - namespace :freeze do - desc "Lock this application to the current gems (by unpacking them into vendor/rails)" - task :gems do - deps = %w(actionpack activerecord actionmailer activesupport activeresource) - require 'rubygems' - require 'rubygems/gem_runner' - - rails = (version = ENV['VERSION']) ? - Gem.cache.find_name('rails', "= #{version}").first : - Gem.cache.find_name('rails').sort_by { |g| g.version }.last - - version ||= rails.version - - unless rails - puts "No rails gem #{version} is installed. Do 'gem list rails' to see what you have available." - exit - end - - puts "Freezing to the gems for Rails #{rails.version}" - rm_rf "vendor/rails" - mkdir_p "vendor/rails" - - begin - chdir("vendor/rails") do - rails.dependencies.select { |g| deps.include? g.name }.each do |g| - Gem::GemRunner.new.run(["unpack", g.name, "--version", g.version_requirements.to_s]) - mv(Dir.glob("#{g.name}*").first, g.name) - end - - Gem::GemRunner.new.run(["unpack", "rails", "--version", "=#{version}"]) - FileUtils.mv(Dir.glob("rails*").first, "railties") - end - rescue Exception - rm_rf "vendor/rails" - raise - end - end - - desc 'Lock to latest Edge Rails, for a specific release use RELEASE=1.2.0' - task :edge do - require 'open-uri' - version = ENV["RELEASE"] || "edge" - target = "rails_#{version}.zip" - commits = "http://github.com/api/v1/yaml/rails/rails/commits/master" - url = "http://dev.rubyonrails.org/archives/#{target}" - - chdir 'vendor' do - latest_revision = YAML.load(open(commits))["commits"].first["id"] - - puts "Downloading Rails from #{url}" - File.open('rails.zip', 'wb') do |dst| - open url do |src| - while chunk = src.read(4096) - dst << chunk - end - end - end - - puts 'Unpacking Rails' - rm_rf 'rails' - `unzip rails.zip` - %w(rails.zip rails/Rakefile rails/cleanlogs.sh rails/pushgems.rb rails/release.rb).each do |goner| - rm_f goner - end - - touch "rails/REVISION_#{latest_revision}" - end - - puts 'Updating current scripts, javascripts, and configuration settings' - Rake::Task['rails:update'].invoke - end - end - - desc "Unlock this application from freeze of gems or edge and return to a fluid use of system gems" - task :unfreeze do - rm_rf "vendor/rails" - end - - desc "Update both configs, scripts and public/javascripts from Rails" - task :update => [ "update:scripts", "update:javascripts", "update:configs", "update:application_controller" ] - - desc "Applies the template supplied by LOCATION=/path/to/template" - task :template do - require 'rails_generator/generators/applications/app/template_runner' - Rails::TemplateRunner.new(ENV["LOCATION"]) - end - - namespace :update do - desc "Add new scripts to the application script/ directory" - task :scripts do - local_base = "script" - edge_base = "#{File.dirname(__FILE__)}/../../bin" - - local = Dir["#{local_base}/**/*"].reject { |path| File.directory?(path) } - edge = Dir["#{edge_base}/**/*"].reject { |path| File.directory?(path) } - - edge.each do |script| - base_name = script[(edge_base.length+1)..-1] - next if base_name == "rails" - next if local.detect { |path| base_name == path[(local_base.length+1)..-1] } - if !File.directory?("#{local_base}/#{File.dirname(base_name)}") - mkdir_p "#{local_base}/#{File.dirname(base_name)}" - end - install script, "#{local_base}/#{base_name}", :mode => 0755 - end - end - - desc "Update your javascripts from your current rails install" - task :javascripts do - require 'railties_path' - project_dir = RAILS_ROOT + '/public/javascripts/' - scripts = Dir[RAILTIES_PATH + '/html/javascripts/*.js'] - scripts.reject!{|s| File.basename(s) == 'application.js'} if File.exist?(project_dir + 'application.js') - FileUtils.cp(scripts, project_dir) - end - - desc "Update config/boot.rb from your current rails install" - task :configs do - require 'railties_path' - FileUtils.cp(RAILTIES_PATH + '/environments/boot.rb', RAILS_ROOT + '/config/boot.rb') - end - - desc "Rename application.rb to application_controller.rb" - task :application_controller do - old_style = RAILS_ROOT + '/app/controllers/application.rb' - new_style = RAILS_ROOT + '/app/controllers/application_controller.rb' - if File.exists?(old_style) && !File.exists?(new_style) - FileUtils.mv(old_style, new_style) - puts "#{old_style} has been renamed to #{new_style}, update your SCM as necessary" - end - end - - desc "Generate dispatcher files in RAILS_ROOT/public" - task :generate_dispatchers do - require 'railties_path' - FileUtils.cp(RAILTIES_PATH + '/dispatches/config.ru', RAILS_ROOT + '/config.ru') - FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.fcgi', RAILS_ROOT + '/public/dispatch.fcgi') - FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.rb') - FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.cgi') - end - end -end diff --git a/vendor/rails/railties/lib/tasks/gems.rake b/vendor/rails/railties/lib/tasks/gems.rake deleted file mode 100644 index ed07bf2..0000000 --- a/vendor/rails/railties/lib/tasks/gems.rake +++ /dev/null @@ -1,65 +0,0 @@ -desc "List the gems that this rails application depends on" -task :gems => 'gems:base' do - Rails.configuration.gems.each do |gem| - print_gem_status(gem) - end - puts - puts "I = Installed" - puts "F = Frozen" - puts "R = Framework (loaded before rails starts)" -end - -namespace :gems do - task :base do - $gems_rake_task = true - require 'rubygems' - require 'rubygems/gem_runner' - Rake::Task[:environment].invoke - end - - desc "Build any native extensions for unpacked gems" - task :build do - $gems_build_rake_task = true - Rake::Task['gems:unpack'].invoke - current_gems.each &:build - end - - desc "Installs all required gems." - task :install => :base do - current_gems.each &:install - end - - desc "Unpacks all required gems into vendor/gems." - task :unpack => :install do - current_gems.each &:unpack - end - - namespace :unpack do - desc "Unpacks all required gems and their dependencies into vendor/gems." - task :dependencies => :install do - current_gems.each { |gem| gem.unpack(:recursive => true) } - end - end - - desc "Regenerate gem specifications in correct format." - task :refresh_specs => :base do - current_gems.each &:refresh - end -end - -def current_gems - gems = Rails.configuration.gems - gems = gems.select { |gem| gem.name == ENV['GEM'] } unless ENV['GEM'].blank? - gems -end - -def print_gem_status(gem, indent=1) - code = case - when gem.framework_gem? then 'R' - when gem.frozen? then 'F' - when gem.installed? then 'I' - else ' ' - end - puts " "*(indent-1)+" - [#{code}] #{gem.name} #{gem.requirement.to_s}" - gem.dependencies.each { |g| print_gem_status(g, indent+1) } -end diff --git a/vendor/rails/railties/lib/tasks/log.rake b/vendor/rails/railties/lib/tasks/log.rake deleted file mode 100644 index 6e13346..0000000 --- a/vendor/rails/railties/lib/tasks/log.rake +++ /dev/null @@ -1,9 +0,0 @@ -namespace :log do - desc "Truncates all *.log files in log/ to zero bytes" - task :clear do - FileList["log/*.log"].each do |log_file| - f = File.open(log_file, "w") - f.close - end - end -end diff --git a/vendor/rails/railties/lib/tasks/middleware.rake b/vendor/rails/railties/lib/tasks/middleware.rake deleted file mode 100644 index 05f1591..0000000 --- a/vendor/rails/railties/lib/tasks/middleware.rake +++ /dev/null @@ -1,7 +0,0 @@ -desc 'Prints out your Rack middleware stack' -task :middleware => :environment do - ActionController::Dispatcher.middleware.active.each do |middleware| - puts "use #{middleware.inspect}" - end - puts "run ActionController::Dispatcher.new" -end diff --git a/vendor/rails/railties/lib/tasks/misc.rake b/vendor/rails/railties/lib/tasks/misc.rake deleted file mode 100644 index 9e6f96d..0000000 --- a/vendor/rails/railties/lib/tasks/misc.rake +++ /dev/null @@ -1,63 +0,0 @@ -task :default => :test -task :environment do - $rails_rake_task = true - require(File.join(RAILS_ROOT, 'config', 'environment')) -end - -task :rails_env do - unless defined? RAILS_ENV - RAILS_ENV = ENV['RAILS_ENV'] ||= 'development' - end -end - -desc 'Generate a crytographically secure secret key. This is typically used to generate a secret for cookie sessions.' -task :secret do - puts ActiveSupport::SecureRandom.hex(64) -end - -require 'active_support' -namespace :time do - namespace :zones do - desc 'Displays names of all time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6' - task :all do - build_time_zone_list(:all) - end - - desc 'Displays names of US time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6' - task :us do - build_time_zone_list(:us_zones) - end - - desc 'Displays names of time zones recognized by the Rails TimeZone class with the same offset as the system local time' - task :local do - jan_offset = Time.now.beginning_of_year.utc_offset - jul_offset = Time.now.beginning_of_year.change(:month => 7).utc_offset - offset = jan_offset < jul_offset ? jan_offset : jul_offset - build_time_zone_list(:all, offset) - end - - # to find UTC -06:00 zones, OFFSET can be set to either -6, -6:00 or 21600 - def build_time_zone_list(method, offset = ENV['OFFSET']) - if offset - offset = if offset.to_s.match(/(\+|-)?(\d+):(\d+)/) - sign = $1 == '-' ? -1 : 1 - hours, minutes = $2.to_f, $3.to_f - ((hours * 3600) + (minutes.to_f * 60)) * sign - elsif offset.to_f.abs <= 13 - offset.to_f * 3600 - else - offset.to_f - end - end - previous_offset = nil - ActiveSupport::TimeZone.__send__(method).each do |zone| - if offset.nil? || offset == zone.utc_offset - puts "\n* UTC #{zone.formatted_offset} *" unless zone.utc_offset == previous_offset - puts zone.name - previous_offset = zone.utc_offset - end - end - puts "\n" - end - end -end diff --git a/vendor/rails/railties/lib/tasks/rails.rb b/vendor/rails/railties/lib/tasks/rails.rb deleted file mode 100644 index 8c2b7f9..0000000 --- a/vendor/rails/railties/lib/tasks/rails.rb +++ /dev/null @@ -1,8 +0,0 @@ -$VERBOSE = nil - -# Load Rails rakefile extensions -Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext } - -# Load any custom rakefile extensions -Dir["#{RAILS_ROOT}/vendor/plugins/*/**/tasks/**/*.rake"].sort.each { |ext| load ext } -Dir["#{RAILS_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext } diff --git a/vendor/rails/railties/lib/tasks/routes.rake b/vendor/rails/railties/lib/tasks/routes.rake deleted file mode 100644 index 39b7139..0000000 --- a/vendor/rails/railties/lib/tasks/routes.rake +++ /dev/null @@ -1,17 +0,0 @@ -desc 'Print out all defined routes in match order, with names.' -task :routes => :environment do - routes = ActionController::Routing::Routes.routes.collect do |route| - name = ActionController::Routing::Routes.named_routes.routes.index(route).to_s - verb = route.conditions[:method].to_s.upcase - segs = route.segments.inject("") { |str,s| str << s.to_s } - segs.chop! if segs.length > 1 - reqs = route.requirements.empty? ? "" : route.requirements.inspect - {:name => name, :verb => verb, :segs => segs, :reqs => reqs} - end - name_width = routes.collect {|r| r[:name]}.collect {|n| n.length}.max - verb_width = routes.collect {|r| r[:verb]}.collect {|v| v.length}.max - segs_width = routes.collect {|r| r[:segs]}.collect {|s| s.length}.max - routes.each do |r| - puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:segs].ljust(segs_width)} #{r[:reqs]}" - end -end \ No newline at end of file diff --git a/vendor/rails/railties/lib/tasks/statistics.rake b/vendor/rails/railties/lib/tasks/statistics.rake deleted file mode 100644 index 5ab27a0..0000000 --- a/vendor/rails/railties/lib/tasks/statistics.rake +++ /dev/null @@ -1,17 +0,0 @@ -STATS_DIRECTORIES = [ - %w(Controllers app/controllers), - %w(Helpers app/helpers), - %w(Models app/models), - %w(Libraries lib/), - %w(APIs app/apis), - %w(Integration\ tests test/integration), - %w(Functional\ tests test/functional), - %w(Unit\ tests test/unit) - -].collect { |name, dir| [ name, "#{RAILS_ROOT}/#{dir}" ] }.select { |name, dir| File.directory?(dir) } - -desc "Report code statistics (KLOCs, etc) from the application" -task :stats do - require 'code_statistics' - CodeStatistics.new(*STATS_DIRECTORIES).to_s -end diff --git a/vendor/rails/railties/lib/tasks/testing.rake b/vendor/rails/railties/lib/tasks/testing.rake deleted file mode 100644 index fd5e52a..0000000 --- a/vendor/rails/railties/lib/tasks/testing.rake +++ /dev/null @@ -1,139 +0,0 @@ -TEST_CHANGES_SINCE = Time.now - 600 - -# Look up tests for recently modified sources. -def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago) - FileList[source_pattern].map do |path| - if File.mtime(path) > touched_since - tests = [] - source_dir = File.dirname(path).split("/") - source_file = File.basename(path, '.rb') - - # Support subdirs in app/models and app/controllers - modified_test_path = source_dir.length > 2 ? "#{test_path}/" << source_dir[1..source_dir.length].join('/') : test_path - - # For modified files in app/ run the tests for it. ex. /test/functional/account_controller.rb - test = "#{modified_test_path}/#{source_file}_test.rb" - tests.push test if File.exist?(test) - - # For modified files in app, run tests in subdirs too. ex. /test/functional/account/*_test.rb - test = "#{modified_test_path}/#{File.basename(path, '.rb').sub("_controller","")}" - FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exist?(test) - - return tests - - end - end.flatten.compact -end - - -# Recreated here from ActiveSupport because :uncommitted needs it before Rails is available -module Kernel - def silence_stderr - old_stderr = STDERR.dup - STDERR.reopen(RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'NUL:' : '/dev/null') - STDERR.sync = true - yield - ensure - STDERR.reopen(old_stderr) - end -end - -desc 'Run all unit, functional and integration tests' -task :test do - errors = %w(test:units test:functionals test:integration).collect do |task| - begin - Rake::Task[task].invoke - nil - rescue => e - task - end - end.compact - abort "Errors running #{errors.to_sentence(:locale => :en)}!" if errors.any? -end - -namespace :test do - Rake::TestTask.new(:recent => "db:test:prepare") do |t| - since = TEST_CHANGES_SINCE - touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } + - recent_tests('app/models/**/*.rb', 'test/unit', since) + - recent_tests('app/controllers/**/*.rb', 'test/functional', since) - - t.libs << 'test' - t.verbose = true - t.test_files = touched.uniq - end - Rake::Task['test:recent'].comment = "Test recent changes" - - Rake::TestTask.new(:uncommitted => "db:test:prepare") do |t| - def t.file_list - if File.directory?(".svn") - changed_since_checkin = silence_stderr { `svn status` }.map { |path| path.chomp[7 .. -1] } - elsif File.directory?(".git") - changed_since_checkin = silence_stderr { `git ls-files --modified --others` }.map { |path| path.chomp } - else - abort "Not a Subversion or Git checkout." - end - - models = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb$/ } - controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb$/ } - - unit_tests = models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" } - functional_tests = controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" } - - unit_tests.uniq + functional_tests.uniq - end - - t.libs << 'test' - t.verbose = true - end - Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)" - - Rake::TestTask.new(:units => "db:test:prepare") do |t| - t.libs << "test" - t.pattern = 'test/unit/**/*_test.rb' - t.verbose = true - end - Rake::Task['test:units'].comment = "Run the unit tests in test/unit" - - Rake::TestTask.new(:functionals => "db:test:prepare") do |t| - t.libs << "test" - t.pattern = 'test/functional/**/*_test.rb' - t.verbose = true - end - Rake::Task['test:functionals'].comment = "Run the functional tests in test/functional" - - Rake::TestTask.new(:integration => "db:test:prepare") do |t| - t.libs << "test" - t.pattern = 'test/integration/**/*_test.rb' - t.verbose = true - end - Rake::Task['test:integration'].comment = "Run the integration tests in test/integration" - - Rake::TestTask.new(:benchmark => 'db:test:prepare') do |t| - t.libs << 'test' - t.pattern = 'test/performance/**/*_test.rb' - t.verbose = true - t.options = '-- --benchmark' - end - Rake::Task['test:benchmark'].comment = 'Benchmark the performance tests' - - Rake::TestTask.new(:profile => 'db:test:prepare') do |t| - t.libs << 'test' - t.pattern = 'test/performance/**/*_test.rb' - t.verbose = true - end - Rake::Task['test:profile'].comment = 'Profile the performance tests' - - Rake::TestTask.new(:plugins => :environment) do |t| - t.libs << "test" - - if ENV['PLUGIN'] - t.pattern = "vendor/plugins/#{ENV['PLUGIN']}/test/**/*_test.rb" - else - t.pattern = 'vendor/plugins/*/**/test/**/*_test.rb' - end - - t.verbose = true - end - Rake::Task['test:plugins'].comment = "Run the plugin tests in vendor/plugins/*/**/test (or specify with PLUGIN=name)" -end diff --git a/vendor/rails/railties/lib/tasks/tmp.rake b/vendor/rails/railties/lib/tasks/tmp.rake deleted file mode 100644 index fea1505..0000000 --- a/vendor/rails/railties/lib/tasks/tmp.rake +++ /dev/null @@ -1,37 +0,0 @@ -namespace :tmp do - desc "Clear session, cache, and socket files from tmp/" - task :clear => [ "tmp:sessions:clear", "tmp:cache:clear", "tmp:sockets:clear"] - - desc "Creates tmp directories for sessions, cache, sockets, and pids" - task :create do - FileUtils.mkdir_p(%w( tmp/sessions tmp/cache tmp/sockets tmp/pids )) - end - - namespace :sessions do - desc "Clears all files in tmp/sessions" - task :clear do - FileUtils.rm(Dir['tmp/sessions/[^.]*']) - end - end - - namespace :cache do - desc "Clears all files and directories in tmp/cache" - task :clear do - FileUtils.rm_rf(Dir['tmp/cache/[^.]*']) - end - end - - namespace :sockets do - desc "Clears all files in tmp/sockets" - task :clear do - FileUtils.rm(Dir['tmp/sockets/[^.]*']) - end - end - - namespace :pids do - desc "Clears all files in tmp/pids" - task :clear do - FileUtils.rm(Dir['tmp/pids/[^.]*']) - end - end -end diff --git a/vendor/rails/railties/lib/test_help.rb b/vendor/rails/railties/lib/test_help.rb deleted file mode 100644 index ee24ea3..0000000 --- a/vendor/rails/railties/lib/test_help.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Make double-sure the RAILS_ENV is set to test, -# so fixtures are loaded to the right database -silence_warnings { RAILS_ENV = "test" } - -require 'test/unit' -require 'action_controller/test_case' -require 'action_view/test_case' -require 'action_controller/integration' -require 'action_mailer/test_case' if defined?(ActionMailer) - -if defined?(ActiveRecord) - require 'active_record/test_case' - require 'active_record/fixtures' - - class ActiveSupport::TestCase - include ActiveRecord::TestFixtures - self.fixture_path = "#{RAILS_ROOT}/test/fixtures/" - self.use_instantiated_fixtures = false - self.use_transactional_fixtures = true - end - - ActionController::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path - - def create_fixtures(*table_names, &block) - Fixtures.create_fixtures(ActiveSupport::TestCase.fixture_path, table_names, {}, &block) - end -end - -begin - require_library_or_gem 'ruby-debug' - Debugger.start - Debugger.settings[:autoeval] = true if Debugger.respond_to?(:settings) -rescue LoadError - # ruby-debug wasn't available so neither can the debugging be -end diff --git a/vendor/rails/railties/lib/webrick_server.rb b/vendor/rails/railties/lib/webrick_server.rb deleted file mode 100644 index 2f60151..0000000 --- a/vendor/rails/railties/lib/webrick_server.rb +++ /dev/null @@ -1,156 +0,0 @@ -# Donated by Florian Gross - -require 'webrick' -require 'cgi' -require 'stringio' -require 'dispatcher' - -include WEBrick - -class CGI #:nodoc: - def stdinput - @stdin || $stdin - end - - def env_table - @env_table || ENV - end - - def initialize(type = "query", table = nil, stdin = nil) - @env_table, @stdin = table, stdin - - if defined?(MOD_RUBY) && !ENV.key?("GATEWAY_INTERFACE") - Apache.request.setup_cgi_env - end - - extend QueryExtension - @multipart = false - if defined?(CGI_PARAMS) - warn "do not use CGI_PARAMS and CGI_COOKIES" - @params = CGI_PARAMS.dup - @cookies = CGI_COOKIES.dup - else - initialize_query() # set @params, @cookies - end - @output_cookies = nil - @output_hidden = nil - end -end - -# A custom dispatch servlet for use with WEBrick. It dispatches requests -# (using the Rails Dispatcher) to the appropriate controller/action. By default, -# it restricts WEBrick to a managing a single Rails request at a time, but you -# can change this behavior by setting ActionController::Base.allow_concurrency -# to true. -class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet - # Start the WEBrick server with the given options, mounting the - # DispatchServlet at <tt>/</tt>. - def self.dispatch(options = {}) - Socket.do_not_reverse_lookup = true # patch for OS X - - params = { :Port => options[:port].to_i, - :ServerType => options[:server_type], - :BindAddress => options[:ip] } - params[:MimeTypes] = options[:mime_types] if options[:mime_types] - - server = WEBrick::HTTPServer.new(params) - server.mount('/', DispatchServlet, options) - - trap("INT") { server.shutdown } - server.start - end - - def initialize(server, options) #:nodoc: - @server_options = options - @file_handler = WEBrick::HTTPServlet::FileHandler.new(server, options[:server_root]) - # Change to the RAILS_ROOT, since Webrick::Daemon.start does a Dir::cwd("/") - # OPTIONS['working_directory'] is an absolute path of the RAILS_ROOT, set in railties/lib/commands/servers/webrick.rb - Dir.chdir(OPTIONS['working_directory']) if defined?(OPTIONS) && File.directory?(OPTIONS['working_directory']) - super - end - - def service(req, res) #:nodoc: - unless handle_file(req, res) - unless handle_dispatch(req, res) - raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found." - end - end - end - - def handle_file(req, res) #:nodoc: - begin - req = req.dup - path = req.path.dup - - # Add .html if the last path piece has no . in it - path << '.html' if path != '/' && (%r{(^|/)[^./]+$} =~ path) - path.gsub!('+', ' ') # Unescape + since FileHandler doesn't do so. - - req.instance_variable_set(:@path_info, path) # Set the modified path... - - @file_handler.send(:service, req, res) - return true - rescue HTTPStatus::PartialContent, HTTPStatus::NotModified => err - res.set_error(err) - return true - rescue => err - return false - end - end - - def handle_dispatch(req, res, origin = nil) #:nodoc: - data = StringIO.new - Dispatcher.dispatch( - CGI.new("query", create_env_table(req, origin), StringIO.new(req.body || "")), - ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, - data - ) - - header, body = extract_header_and_body(data) - - set_charset(header) - assign_status(res, header) - res.cookies.concat(header.delete('set-cookie') || []) - header.each { |key, val| res[key] = val.join(", ") } - - res.body = body - return true - rescue => err - p err, err.backtrace - return false - end - - private - def create_env_table(req, origin) - env = req.meta_vars.clone - env.delete "SCRIPT_NAME" - env["QUERY_STRING"] = req.request_uri.query - env["REQUEST_URI"] = origin if origin - return env - end - - def extract_header_and_body(data) - data.rewind - data = data.read - - raw_header, body = *data.split(/^[\xd\xa]{2}/on, 2) - header = WEBrick::HTTPUtils::parse_header(raw_header) - - return header, body - end - - def set_charset(header) - ct = header["content-type"] - if ct.any? { |x| x =~ /^text\// } && ! ct.any? { |x| x =~ /charset=/ } - ch = @server_options[:charset] || "UTF-8" - ct.find { |x| x =~ /^text\// } << ("; charset=" + ch) - end - end - - def assign_status(res, header) - if /^(\d+)/ =~ header['status'][0] - res.status = $1.to_i - header.delete('status') - end - end -end