Permalink
Browse files

[rails2 fixture] Adds rails 2 integration tests

  • Loading branch information...
1 parent 8fd2ffb commit 7a26cd9fdce480f3f1f478e663063d76b8f8656f @nesquena nesquena committed Oct 2, 2011
Showing with 11,272 additions and 0 deletions.
  1. +7 −0 fixtures/rails2/Gemfile
  2. +15 −0 fixtures/rails2/Rakefile
  3. +10 −0 fixtures/rails2/app/controllers/application_controller.rb
  4. +15 −0 fixtures/rails2/app/controllers/posts_controller.rb
  5. +15 −0 fixtures/rails2/app/controllers/users_controller.rb
  6. +7 −0 fixtures/rails2/app/models/phone_number.rb
  7. +3 −0 fixtures/rails2/app/models/post.rb
  8. +3 −0 fixtures/rails2/app/models/user.rb
  9. +6 −0 fixtures/rails2/app/views/layouts/application.html.erb
  10. +3 −0 fixtures/rails2/app/views/posts/date.json.rabl
  11. +11 −0 fixtures/rails2/app/views/posts/index.json.rabl
  12. +16 −0 fixtures/rails2/app/views/posts/show.json.rabl
  13. +3 −0 fixtures/rails2/app/views/users/index.rabl
  14. +6 −0 fixtures/rails2/app/views/users/phone_number.rabl
  15. +16 −0 fixtures/rails2/app/views/users/show.rabl
  16. +129 −0 fixtures/rails2/config/boot.rb
  17. +16 −0 fixtures/rails2/config/database.yml
  18. +42 −0 fixtures/rails2/config/environment.rb
  19. +17 −0 fixtures/rails2/config/environments/development.rb
  20. +28 −0 fixtures/rails2/config/environments/production.rb
  21. +28 −0 fixtures/rails2/config/environments/test.rb
  22. +7 −0 fixtures/rails2/config/initializers/backtrace_silencers.rb
  23. +7 −0 fixtures/rails2/config/initializers/cookie_verification_secret.rb
  24. +10 −0 fixtures/rails2/config/initializers/inflections.rb
  25. +5 −0 fixtures/rails2/config/initializers/mime_types.rb
  26. +21 −0 fixtures/rails2/config/initializers/new_rails_defaults.rb
  27. +6 −0 fixtures/rails2/config/initializers/rabl_loader.rb
  28. +15 −0 fixtures/rails2/config/initializers/session_store.rb
  29. +5 −0 fixtures/rails2/config/locales/en.yml
  30. +20 −0 fixtures/rails2/config/preinitializer.rb
  31. +45 −0 fixtures/rails2/config/routes.rb
  32. +14 −0 fixtures/rails2/db/migrate/20111002075037_create_posts.rb
  33. +15 −0 fixtures/rails2/db/migrate/20111002075053_create_users.rb
  34. +16 −0 fixtures/rails2/db/migrate/20111002075112_create_phone_numbers.rb
  35. +40 −0 fixtures/rails2/db/schema.rb
  36. +7 −0 fixtures/rails2/db/seeds.rb
  37. +2 −0 fixtures/rails2/doc/README_FOR_APP
  38. +2,151 −0 fixtures/rails2/log/database.log
  39. +84 −0 fixtures/rails2/log/development.log
  40. 0 fixtures/rails2/log/production.log
  41. 0 fixtures/rails2/log/server.log
  42. +327 −0 fixtures/rails2/log/test.log
  43. +30 −0 fixtures/rails2/public/404.html
  44. +30 −0 fixtures/rails2/public/422.html
  45. +30 −0 fixtures/rails2/public/500.html
  46. 0 fixtures/rails2/public/favicon.ico
  47. BIN fixtures/rails2/public/images/rails.png
  48. +275 −0 fixtures/rails2/public/index.html
  49. +2 −0 fixtures/rails2/public/javascripts/application.js
  50. +963 −0 fixtures/rails2/public/javascripts/controls.js
  51. +973 −0 fixtures/rails2/public/javascripts/dragdrop.js
  52. +1,128 −0 fixtures/rails2/public/javascripts/effects.js
  53. +4,320 −0 fixtures/rails2/public/javascripts/prototype.js
  54. +5 −0 fixtures/rails2/public/robots.txt
  55. +4 −0 fixtures/rails2/script/about
  56. +3 −0 fixtures/rails2/script/console
  57. +3 −0 fixtures/rails2/script/dbconsole
  58. +3 −0 fixtures/rails2/script/destroy
  59. +3 −0 fixtures/rails2/script/generate
  60. +3 −0 fixtures/rails2/script/performance/benchmarker
  61. +3 −0 fixtures/rails2/script/performance/profiler
  62. +3 −0 fixtures/rails2/script/plugin
  63. +3 −0 fixtures/rails2/script/runner
  64. +3 −0 fixtures/rails2/script/server
  65. +11 −0 fixtures/rails2/test/fixtures/phone_numbers.yml
  66. +11 −0 fixtures/rails2/test/fixtures/posts.yml
  67. +11 −0 fixtures/rails2/test/fixtures/users.yml
  68. +108 −0 fixtures/rails2/test/functionals/posts_controller_test.rb
  69. +87 −0 fixtures/rails2/test/functionals/users_controller_test.rb
  70. +9 −0 fixtures/rails2/test/performance/browsing_test.rb
  71. +47 −0 fixtures/rails2/test/test_helper.rb
  72. +4 −0 fixtures/rails2/test/unit/helpers/posts_helper_test.rb
  73. +4 −0 fixtures/rails2/test/unit/helpers/users_helper_test.rb
View
@@ -0,0 +1,7 @@
+source :gemcutter
+gem "rails", "~> 2.3.14"
+gem "sqlite3-ruby", :require => "sqlite3"
+gem 'rabl', :path => File.expand_path(File.dirname(__FILE__) + "/../../")
+
+gem 'riot', :group => "test"
+gem 'rack-test', :require => "rack/test", :group => "test"
View
@@ -0,0 +1,15 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require(File.join(File.dirname(__FILE__), 'config', 'boot'))
+
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+require 'tasks/rails'
+
+Rake::TestTask.new("test:rabl") do |test|
+ test.pattern = "test/functionals/**/*_test.rb"
+ test.verbose = true
+end
@@ -0,0 +1,10 @@
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ApplicationController < ActionController::Base
+ helper :all # include all helpers, all the time
+ protect_from_forgery # See ActionController::RequestForgeryProtection for details
+
+ # Scrub sensitive parameters from your log
+ # filter_parameter_logging :password
+end
@@ -0,0 +1,15 @@
+class PostsController < ApplicationController
+ def index
+ @posts = Post.all(:order => "id ASC")
+ respond_to do |format|
+ format.json { render "posts/index" }
+ end
+ end
+
+ def show
+ @post = Post.find(params[:id])
+ respond_to do |format|
+ format.json { render "posts/show" }
+ end
+ end
+end
@@ -0,0 +1,15 @@
+class UsersController < ApplicationController
+ def index
+ @users = User.all(:order => "username ASC")
+ respond_to do |format|
+ format.json { render "users/index" }
+ end
+ end
+
+ def show
+ @user = User.find(params[:id])
+ respond_to do |format|
+ format.json { render "users/show" }
+ end
+ end
+end
@@ -0,0 +1,7 @@
+class PhoneNumber < ActiveRecord::Base
+ belongs_to :user
+
+ def formatted
+ "(#{self.area_code}) #{self.prefix}-#{self.suffix}"
+ end
+end
@@ -0,0 +1,3 @@
+class Post < ActiveRecord::Base
+ belongs_to :user
+end
@@ -0,0 +1,3 @@
+class User < ActiveRecord::Base
+ has_many :phone_numbers
+end
@@ -0,0 +1,6 @@
+<head>
+ Not for RABL
+</head>
+<body>
+ Not for RABL
+</body>
@@ -0,0 +1,3 @@
+code(:day) { |d| d.day }
+code(:hour) { |d| d.hour }
+code(:full) { |d| d.iso8601 }
@@ -0,0 +1,11 @@
+collection @posts => :articles
+
+extends "posts/show"
+
+node(:created_by_admin, :if => lambda { |p| p.user.is_admin }) do |p|
+ true
+end
+
+child({ :user => :admin }, { :if => lambda { |p| p.user.is_admin }}) do |p|
+ extends "users/show"
+end
@@ -0,0 +1,16 @@
+object @post
+
+attributes :title, :body
+attributes :created_at => :posted_at
+
+child :user do
+ extends "users/show"
+end
+
+glue :user do
+ attributes :username => :author_name
+end
+
+code(:created_date) do |p|
+ partial("posts/date", :object => p.created_at)
+end
@@ -0,0 +1,3 @@
+collection @users
+
+extends "users/show"
@@ -0,0 +1,6 @@
+attributes :prefix, :suffix, :area_code
+attributes :is_primary => :primary
+
+node :formatted do |n|
+ n.formatted
+end
@@ -0,0 +1,16 @@
+object @user => :person
+
+attributes :username, :email, :location
+attributes :created_at => :registered_at
+
+node :role do |user|
+ user.is_admin ? 'admin' : 'normal'
+end
+
+child :phone_numbers => :pnumbers do
+ extends "users/phone_number"
+end
+
+node :node_numbers do |u|
+ partial("users/phone_number", :object => u.phone_numbers)
+end
@@ -0,0 +1,129 @@
+# Don't change this file!
+# Configure your app in config/environment.rb and config/environments/*.rb
+
+RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
+
+module Rails
+ class << self
+ def boot!
+ unless booted?
+ preinitialize
+ pick_boot.run
+ end
+ end
+
+ def booted?
+ defined? Rails::Initializer
+ end
+
+ def pick_boot
+ (vendor_rails? ? VendorBoot : GemBoot).new
+ end
+
+ def vendor_rails?
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
+ end
+
+ def preinitialize
+ load(preinitializer_path) if File.exist?(preinitializer_path)
+ end
+
+ def preinitializer_path
+ "#{RAILS_ROOT}/config/preinitializer.rb"
+ end
+ end
+
+ class Boot
+ def run
+ load_initializer
+ Rails::Initializer.run(:set_load_path)
+ end
+ end
+
+ class VendorBoot < Boot
+ def load_initializer
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
+ Rails::Initializer.run(:install_gem_spec_stubs)
+ Rails::GemDependency.add_frozen_gem_path
+ end
+ end
+
+ class GemBoot < Boot
+ def load_initializer
+ self.class.load_rubygems
+ load_rails_gem
+ require 'initializer'
+ end
+
+ def load_rails_gem
+ if version = self.class.gem_version
+ gem 'rails', version
+ else
+ gem 'rails'
+ end
+ rescue Gem::LoadError => load_error
+ if load_error.message =~ /Could not find RubyGem rails/
+ STDERR.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
+ exit 1
+ else
+ raise
+ end
+ end
+
+ class << self
+ def rubygems_version
+ Gem::RubyGemsVersion rescue nil
+ end
+
+ def gem_version
+ if defined? RAILS_GEM_VERSION
+ RAILS_GEM_VERSION
+ elsif ENV.include?('RAILS_GEM_VERSION')
+ ENV['RAILS_GEM_VERSION']
+ else
+ parse_gem_version(read_environment_rb)
+ end
+ end
+
+ def load_rubygems
+ min_version = '1.3.2'
+ require 'rubygems'
+ unless rubygems_version >= min_version
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
+ exit 1
+ end
+
+ rescue LoadError
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
+ exit 1
+ end
+
+ def parse_gem_version(text)
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
+ end
+
+ private
+ def read_environment_rb
+ File.read("#{RAILS_ROOT}/config/environment.rb")
+ end
+ end
+ end
+end
+
+# Bundler: http://gembundler.com/rails23.html
+class Rails::Boot
+ def run
+ load_initializer
+
+ Rails::Initializer.class_eval do
+ def load_gems
+ @bundler_loaded ||= Bundler.require :default, Rails.env
+ end
+ end
+
+ Rails::Initializer.run(:set_load_path)
+ end
+end
+
+# All that for this:
+Rails.boot!
@@ -0,0 +1,16 @@
+# SQLite version 3.x
+# gem install sqlite3-ruby (not necessary on OS X Leopard)
+development:
+ adapter: sqlite3
+ database: ":memory:"
+ pool: 5
+ timeout: 5000
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: sqlite3
+ database: ":memory:"
+ pool: 5
+ timeout: 5000
@@ -0,0 +1,42 @@
+# Be sure to restart your server when you modify this file
+
+# Specifies gem version of Rails to use when vendor/rails is not present
+RAILS_GEM_VERSION = '2.3.14' unless defined? RAILS_GEM_VERSION
+
+# Bootstrap the Rails environment, frameworks, and default configuration
+require File.join(File.dirname(__FILE__), 'boot')
+
+Rails::Initializer.run do |config|
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Add additional load paths for your own custom dirs
+ # config.autoload_paths += %W( #{RAILS_ROOT}/extras )
+
+ # Specify gems that this application depends on and have them installed with rake gems:install
+ # config.gem "bj"
+ # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
+ # config.gem "sqlite3-ruby", :lib => "sqlite3"
+ # config.gem "aws-s3", :lib => "aws/s3"
+ config.gem "rack-test", :lib => "rack/test"
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Skip frameworks you're not going to use. To use Rails without a database,
+ # you must remove the Active Record framework.
+ # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
+
+ # Activate observers that should always be running
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names.
+ config.time_zone = 'UTC'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
+ # config.i18n.default_locale = :de
+end
@@ -0,0 +1,17 @@
+# Settings specified here will take precedence over those in config/environment.rb
+
+# In the development environment your application's code is reloaded on
+# every request. This slows down response time but is perfect for development
+# since you don't have to restart the webserver when you make code changes.
+config.cache_classes = false
+
+# Log error messages when you accidentally call methods on nil.
+config.whiny_nils = true
+
+# Show full error reports and disable caching
+config.action_controller.consider_all_requests_local = true
+config.action_view.debug_rjs = true
+config.action_controller.perform_caching = false
+
+# Don't care if the mailer can't send
+config.action_mailer.raise_delivery_errors = false
@@ -0,0 +1,28 @@
+# Settings specified here will take precedence over those in config/environment.rb
+
+# The production environment is meant for finished, "live" apps.
+# Code is not reloaded between requests
+config.cache_classes = true
+
+# Full error reports are disabled and caching is turned on
+config.action_controller.consider_all_requests_local = false
+config.action_controller.perform_caching = true
+config.action_view.cache_template_loading = true
+
+# See everything in the log (default is :info)
+# config.log_level = :debug
+
+# Use a different logger for distributed setups
+# config.logger = SyslogLogger.new
+
+# Use a different cache store in production
+# config.cache_store = :mem_cache_store
+
+# Enable serving of images, stylesheets, and javascripts from an asset server
+# config.action_controller.asset_host = "http://assets.example.com"
+
+# Disable delivery errors, bad email addresses will be ignored
+# config.action_mailer.raise_delivery_errors = false
+
+# Enable threaded mode
+# config.threadsafe!
Oops, something went wrong.

0 comments on commit 7a26cd9

Please sign in to comment.