diff --git a/Rakefile b/Rakefile index 32440a7c..efe4442c 100644 --- a/Rakefile +++ b/Rakefile @@ -45,30 +45,12 @@ end desc "Clean files generated by rake tasks" task :clobber => [:clobber_rdoc, :clobber_package] -namespace :cucumber do - Cucumber::Rake::Task.new(:rails2, "Run the cucumber features in Rails 2") do |t| - t.fork = true - t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')] - t.profile = 'rails2' - end - - Cucumber::Rake::Task.new(:rails3, "Run the cucumber features in Rails 3") do |t| - t.fork = true - t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')] - t.profile = 'rails3' - end -end rescue nil - -desc "Run the cucumber features in both Rails 2 and 3" -task :cucumber => ["cucumber:rails2", "cucumber:rails3"] - -desc 'run tests for all supported versions of Rails' -task :test_all do - %w(2.3.8 3.0.0.beta4).each do |version| - system("RAILS_VERSION=#{version} rake -s test;") - end +Cucumber::Rake::Task.new do |t| + t.fork = true + t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')] + t.profile = 'default' end desc 'Default: run test and cucumber features for support versions' -task :default => [:test_all, :cucumber] +task :default => [:test, :cucumber] diff --git a/cucumber.yml b/cucumber.yml index 5531ca39..a5050277 100644 --- a/cucumber.yml +++ b/cucumber.yml @@ -1,2 +1 @@ -rails2: -r features/support -r features/step_definitions/common_steps.rb -r features/step_definitions/rails2_steps.rb -rails3: -r features/support -r features/step_definitions/common_steps.rb -r features/step_definitions/rails3_steps.rb +default: -r features/support -r features/step_definitions/common_steps.rb -r features/step_definitions/rails3_steps.rb diff --git a/features/rails_integration.feature b/features/rails_integration.feature index 53a49ae1..c5d3c2c5 100644 --- a/features/rails_integration.feature +++ b/features/rails_integration.feature @@ -2,7 +2,6 @@ Feature: integrate with Rails Background: When I generate a new rails application - And I configure the application to use "shoulda" from this project And I save the following as "db/migrate/1_create_users.rb" """ class CreateUsers < ActiveRecord::Migration @@ -31,36 +30,9 @@ Feature: integrate with Rails """ When I configure a wildcard route - Scenario: generate a rails application and use macros in Test::Unit - When I save the following as "test/unit/user_test.rb" - """ - require 'test_helper' - - class UserTest < ActiveSupport::TestCase - should_validate_presence_of :name - end - """ - When I save the following as "test/functional/examples_controller_test.rb" - """ - require 'test_helper' - - class ExamplesControllerTest < ActionController::TestCase - def setup - get :show - end - - should_respond_with :success - should_assign_to :example - end - """ - When I run "rake test TESTOPTS=-v" - Then I should see "1 tests, 1 assertions, 0 failures, 0 errors" - And I should see "2 tests, 2 assertions, 0 failures, 0 errors" - And I should see "User should require name to be set" - And I should see "ExamplesController should assign @example" - Scenario: generate a rails application and use matchers in Test::Unit - When I save the following as "test/unit/user_test.rb" + When I configure the application to use "shoulda" from this project + And I save the following as "test/unit/user_test.rb" """ require 'test_helper' @@ -89,6 +61,7 @@ Feature: integrate with Rails Scenario: generate a rails application and use matchers in Rspec When I configure the application to use rspec-rails + And I configure the application to use "shoulda" from this project And I run the rspec generator And I save the following as "spec/models/user_spec.rb" """ diff --git a/features/step_definitions/rails2_steps.rb b/features/step_definitions/rails2_steps.rb deleted file mode 100644 index 674184ab..00000000 --- a/features/step_definitions/rails2_steps.rb +++ /dev/null @@ -1,83 +0,0 @@ -When /^I generate a new rails application$/ do - load_rails = <<-RUBY - gem 'rails', '2.3.8'; \ - load Gem.bin_path('rails', 'rails', '2.3.8') - RUBY - - @terminal.cd(TEMP_ROOT) - @terminal.run(%{ruby -rubygems -e "#{load_rails.strip!}" #{APP_NAME}}) -end - -When /^I configure the application to use "([^\"]+)" from this project$/ do |name| - gemspec = File.join(PROJECT_ROOT, "#{name}.gemspec") - eval("$specification = begin; #{IO.read(gemspec)}; end") - version = $specification.version - name = $specification.name - - vendor_gem_root = File.join(RAILS_ROOT, 'vendor', 'gems') - vendor_gem_path = File.join(vendor_gem_root, "shoulda-#{version}") - - FileUtils.mkdir_p(vendor_gem_root) - FileUtils.ln_s(PROJECT_ROOT, vendor_gem_path) - File.open(File.join(vendor_gem_path, ".specification"), "w") do |file| - file.write($specification.to_yaml) - end - - insert_into_environment("config.gem '#{name}'") -end - -When /^I configure the application to use rspec\-rails$/ do - # we have to unpack and copy the generator because Rails won't find the - # generators if rspec-rails 2 is installed - insert_into_environment("config.gem 'rspec-rails', :lib => false, :version => '1.2.9'") - insert_into_environment("config.gem 'rspec', :lib => false, :version => '1.2.9'") - steps %{ - When I run "rake gems:unpack" - } - rspec_generator = File.join(RAILS_ROOT, - 'vendor', - 'gems', - 'rspec-rails-1.2.9', - 'generators') - FileUtils.cp_r(rspec_generator, File.join(RAILS_ROOT, 'lib')) -end - -When /^I run the rspec generator$/ do - steps %{ - When I run the "rspec" generator - } -end - -When /^I run the "([^"]*)" generator$/ do |name| - steps %{ - When I run "./script/generate #{name}" - } -end - -When /^I configure a wildcard route$/ do - steps %{ - When I save the following as "config/routes.rb" - """ - ActionController::Routing::Routes.draw do |map| - map.connect ':controller/:action/:id' - end - """ - } -end - -module InsertionHelpers - def insert_into(path, find, replace) - contents = IO.read(path) - contents.sub!(find, replace) - File.open(path, "w") { |file| file.write(contents) } - end - - def insert_into_environment(contents) - environment_file = File.join(RAILS_ROOT, 'config', 'environment.rb') - initializer = "Rails::Initializer.run do |config|" - replace = "#{initializer}\n #{contents}" - insert_into(environment_file, initializer, replace) - end -end - -World(InsertionHelpers) diff --git a/features/step_definitions/rails3_steps.rb b/features/step_definitions/rails3_steps.rb index dc981d85..55d09b09 100644 --- a/features/step_definitions/rails3_steps.rb +++ b/features/step_definitions/rails3_steps.rb @@ -13,7 +13,7 @@ end When /^I configure the application to use "([^\"]+)" from this project$/ do |name| append_to_gemfile "gem '#{name}', :path => '../../'" - steps %{And I run "bundle lock"} + steps %{And I run "bundle install"} end When /^I run the "([^"]*)" generator$/ do |name| @@ -30,7 +30,7 @@ end When /^I configure the application to use rspec\-rails$/ do append_to_gemfile "gem 'rspec-rails', '>= 2.0.0.beta.12'" - steps %{And I run "bundle lock"} + steps %{And I run "bundle install"} end When /^I configure a wildcard route$/ do diff --git a/lib/shoulda.rb b/lib/shoulda.rb index 6be2039f..45c2e2a9 100644 --- a/lib/shoulda.rb +++ b/lib/shoulda.rb @@ -1,8 +1,6 @@ require 'shoulda/version' if defined?(RSpec) - require 'shoulda/integrations/rspec2' -elsif defined?(Spec) require 'shoulda/integrations/rspec' else require 'shoulda/integrations/test_unit' diff --git a/lib/shoulda/integrations/rspec.rb b/lib/shoulda/integrations/rspec.rb index 010d73f3..15876fb5 100644 --- a/lib/shoulda/integrations/rspec.rb +++ b/lib/shoulda/integrations/rspec.rb @@ -1,13 +1,22 @@ require 'shoulda/active_record/matchers' require 'shoulda/action_controller/matchers' require 'shoulda/action_mailer/matchers' -require 'active_support/test_case' # :enddoc: -module ActiveSupport - class TestCase + +module RSpec + module Matchers include Shoulda::ActiveRecord::Matchers - include Shoulda::ActionController::Matchers - include Shoulda::ActionMailer::Matchers + end + + module Rails + module ControllerExampleGroup + include Shoulda::ActionController::Matchers + end + + module MailerExampleGroup + include Shoulda::ActionMailer::Matchers + end end end + diff --git a/lib/shoulda/integrations/rspec2.rb b/lib/shoulda/integrations/rspec2.rb deleted file mode 100644 index 15876fb5..00000000 --- a/lib/shoulda/integrations/rspec2.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'shoulda/active_record/matchers' -require 'shoulda/action_controller/matchers' -require 'shoulda/action_mailer/matchers' - -# :enddoc: - -module RSpec - module Matchers - include Shoulda::ActiveRecord::Matchers - end - - module Rails - module ControllerExampleGroup - include Shoulda::ActionController::Matchers - end - - module MailerExampleGroup - include Shoulda::ActionMailer::Matchers - end - end -end - diff --git a/test/rails2_model_builder.rb b/test/rails2_model_builder.rb deleted file mode 100644 index ea8c230a..00000000 --- a/test/rails2_model_builder.rb +++ /dev/null @@ -1,130 +0,0 @@ -class ActiveSupport::TestCase - - TMP_VIEW_PATH = - File.expand_path(File.join(File.dirname(__FILE__), 'rails2_root', 'tmp', 'views')).freeze - - def create_table(table_name, &block) - connection = ActiveRecord::Base.connection - - begin - connection.execute("DROP TABLE IF EXISTS #{table_name}") - connection.create_table(table_name, &block) - @created_tables ||= [] - @created_tables << table_name - connection - rescue Exception => e - connection.execute("DROP TABLE IF EXISTS #{table_name}") - raise e - end - end - - def define_constant(class_name, base, &block) - class_name = class_name.to_s.camelize - - klass = Class.new(base) - Object.const_set(class_name, klass) - - klass.class_eval(&block) if block_given? - - @defined_constants ||= [] - @defined_constants << class_name - - klass - end - - def define_model_class(class_name, &block) - define_constant(class_name, ActiveRecord::Base, &block) - end - - def define_model(name, columns = {}, &block) - class_name = name.to_s.pluralize.classify - table_name = class_name.tableize - - create_table(table_name) do |table| - columns.each do |name, type| - table.column name, type - end - end - - define_model_class(class_name, &block) - end - - def define_mailer(name, paths, &block) - class_name = name.to_s.pluralize.classify - klass = define_constant(class_name, ActionMailer::Base, &block) - - paths.each {|path| create_view("#{name}/#{path}", "<%= @message %>")} - klass.template_root = TMP_VIEW_PATH - end - - def define_controller(class_name, &block) - class_name = class_name.to_s - class_name << 'Controller' unless class_name =~ /Controller$/ - define_constant(class_name, ActionController::Base, &block) - end - - def define_routes(&block) - @replaced_routes = ActionController::Routing::Routes - new_routes = ActionController::Routing::RouteSet.new - silence_warnings do - ActionController::Routing.const_set('Routes', new_routes) - end - new_routes.draw(&block) - end - - def build_response(opts = {}, &block) - action = opts[:action] || 'example' - klass = define_controller('Examples') - block ||= lambda { render :nothing => true } - klass.class_eval { define_method(action, &block) } - define_routes do |map| - map.connect 'examples', :controller => 'examples', :action => action - end - - create_view("examples/#{action}.html.erb", "abc") - klass.view_paths = [TMP_VIEW_PATH] - - @controller = klass.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - get action - - @controller - end - - def create_view(path, contents) - full_path = File.join(TMP_VIEW_PATH, path) - FileUtils.mkdir_p(File.dirname(full_path)) - File.open(full_path, 'w') { |file| file.write(contents) } - end - - def teardown_with_models - if @defined_constants - @defined_constants.each do |class_name| - Object.send(:remove_const, class_name) - end - end - - if @created_tables - @created_tables.each do |table_name| - ActiveRecord::Base. - connection. - execute("DROP TABLE IF EXISTS #{table_name}") - end - end - - if @replaced_routes - ActionController::Routing::Routes.clear! - silence_warnings do - ActionController::Routing.const_set('Routes', @replaced_routes) - end - @replaced_routes.reload! - end - - FileUtils.rm_rf(TMP_VIEW_PATH) - - teardown_without_models - end - alias_method :teardown_without_models, :teardown - alias_method :teardown, :teardown_with_models -end diff --git a/test/rails2_root/app/controllers/application_controller.rb b/test/rails2_root/app/controllers/application_controller.rb deleted file mode 100644 index feada87d..00000000 --- a/test/rails2_root/app/controllers/application_controller.rb +++ /dev/null @@ -1,22 +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 - def ensure_logged_in - unless session[:logged_in] - respond_to do |accepts| - accepts.html do - flash[:error] = 'What do you think you\'re doing?' - redirect_to '/' - end - accepts.xml do - headers["Status"] = "Unauthorized" - headers["WWW-Authenticate"] = %(Basic realm="Web Password") - render :text => "Couldn't authenticate you", :status => '401 Unauthorized' - end - end - return false - end - return true - end -end diff --git a/test/rails2_root/app/controllers/posts_controller.rb b/test/rails2_root/app/controllers/posts_controller.rb deleted file mode 100644 index 44f02869..00000000 --- a/test/rails2_root/app/controllers/posts_controller.rb +++ /dev/null @@ -1,87 +0,0 @@ -class PostsController < ApplicationController - before_filter :ensure_logged_in - before_filter :load_user - - def index - @posts = @user.posts - - respond_to do |format| - format.html # index.rhtml - format.xml { render :xml => @posts.to_xml } - format.rss do - headers['Content-Type'] = 'application/rss+xml' - session[:special] = '$2 off your next purchase' - session[:special_user_id] = @user.id - session[:false_var] = false - head :ok - end - end - end - - def show - @post = @user.posts.find(params[:id]) - @false_flag = false - - respond_to do |format| - format.html { render :layout => 'wide' } - format.xml { render :xml => @post.to_xml } - end - end - - def new - @post = @user.posts.build - render :layout => false - end - - def edit - @post = @user.posts.find(params[:id]) - end - - def create - @post = @user.posts.build(params[:post]) - - respond_to do |format| - if @post.save - flash[:notice] = 'Post was successfully created.' - format.html { redirect_to user_post_url(@post.user, @post) } - format.xml { head :created, :location => user_post_url(@post.user, @post) } - else - format.html { render :action => "new" } - format.xml { render :xml => @post.errors.to_xml } - end - end - end - - def update - @post = @user.posts.find(params[:id]) - - respond_to do |format| - if @post.update_attributes(params[:post]) - flash[:notice] = 'Post was successfully updated.' - format.html { redirect_to user_post_url(@post.user, @post) } - format.xml { head :ok } - else - format.html { render :action => "edit" } - format.xml { render :xml => @post.errors.to_xml } - end - end - end - - def destroy - @post = @user.posts.find(params[:id]) - @post.destroy - - flash[:notice] = "Post was removed" - - respond_to do |format| - format.html { redirect_to user_posts_url(@post.user) } - format.xml { head :ok } - end - end - - private - - def load_user - @user = User.find(params[:user_id]) - end -end diff --git a/test/rails2_root/app/controllers/users_controller.rb b/test/rails2_root/app/controllers/users_controller.rb deleted file mode 100644 index 7a54a308..00000000 --- a/test/rails2_root/app/controllers/users_controller.rb +++ /dev/null @@ -1,84 +0,0 @@ -class UsersController < ApplicationController - - filter_parameter_logging :ssn - - # GET /users - # GET /users.xml - def index - @users = User.find(:all) - - respond_to do |format| - format.html # index.rhtml - format.xml { render :xml => @users.to_xml } - end - end - - # GET /users/1 - # GET /users/1.xml - def show - @user = User.find(params[:id]) - - respond_to do |format| - format.html # show.rhtml - format.xml { render :xml => @user.to_xml } - end - end - - # GET /users/new - def new - @user = User.new - end - - # GET /users/1;edit - def edit - @user = User.find(params[:id]) - end - - # POST /users - # POST /users.xml - def create - @user = User.new(params[:user]) - - respond_to do |format| - if @user.save - flash[:notice] = 'User was successfully created.' - format.html { redirect_to user_url(@user) } - format.xml { head :created, :location => user_url(@user) } - else - format.html { render :action => "new" } - format.xml { render :xml => @user.errors.to_xml } - end - end - end - - # PUT /users/1 - # PUT /users/1.xml - def update - @user = User.find(params[:id]) - - respond_to do |format| - if @user.update_attributes(params[:user]) - flash[:notice] = 'User was successfully updated.' - format.html { redirect_to user_url(@user) } - format.xml { head :ok } - else - format.html { render :action => "edit" } - format.xml { render :xml => @user.errors.to_xml } - end - end - end - - # DELETE /users/1 - # DELETE /users/1.xml - def destroy - @user = User.find(params[:id]) - @user.destroy - - flash[:notice] = "User was removed" - - respond_to do |format| - format.html { redirect_to users_url } - format.xml { head :ok } - end - end -end diff --git a/test/rails2_root/app/helpers/application_helper.rb b/test/rails2_root/app/helpers/application_helper.rb deleted file mode 100644 index 22a7940e..00000000 --- a/test/rails2_root/app/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/test/rails2_root/app/helpers/posts_helper.rb b/test/rails2_root/app/helpers/posts_helper.rb deleted file mode 100644 index a7b8cec8..00000000 --- a/test/rails2_root/app/helpers/posts_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module PostsHelper -end diff --git a/test/rails2_root/app/helpers/users_helper.rb b/test/rails2_root/app/helpers/users_helper.rb deleted file mode 100644 index 2310a240..00000000 --- a/test/rails2_root/app/helpers/users_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module UsersHelper -end diff --git a/test/rails2_root/app/models/address.rb b/test/rails2_root/app/models/address.rb deleted file mode 100644 index 225903eb..00000000 --- a/test/rails2_root/app/models/address.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Address < ActiveRecord::Base - belongs_to :addressable, :polymorphic => true - validates_uniqueness_of :title, :scope => [:addressable_type, :addressable_id] - - validates_length_of :zip, :minimum => 5 - validates_numericality_of :zip -end diff --git a/test/rails2_root/app/models/flea.rb b/test/rails2_root/app/models/flea.rb deleted file mode 100644 index ac410b58..00000000 --- a/test/rails2_root/app/models/flea.rb +++ /dev/null @@ -1,11 +0,0 @@ -class Flea < ActiveRecord::Base - has_and_belongs_to_many :dogs - - after_create :send_notification - - private - - def send_notification - Notifier.deliver_the_email - end -end diff --git a/test/rails2_root/app/models/friendship.rb b/test/rails2_root/app/models/friendship.rb deleted file mode 100644 index 3844c77e..00000000 --- a/test/rails2_root/app/models/friendship.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Friendship < ActiveRecord::Base - belongs_to :user - belongs_to :friend, :class_name => "User" -end diff --git a/test/rails2_root/app/models/notifier.rb b/test/rails2_root/app/models/notifier.rb deleted file mode 100644 index 9921c4c3..00000000 --- a/test/rails2_root/app/models/notifier.rb +++ /dev/null @@ -1,8 +0,0 @@ -class Notifier < ActionMailer::Base - def the_email - from "do-not-reply@example.com" - recipients "myself@me.com" - subject "This is spam" - body :body => "Every email is spam." - end -end diff --git a/test/rails2_root/app/models/pets/cat.rb b/test/rails2_root/app/models/pets/cat.rb deleted file mode 100644 index 8f654f3f..00000000 --- a/test/rails2_root/app/models/pets/cat.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Pets - class Cat < ActiveRecord::Base - belongs_to :owner, :class_name => 'User' - belongs_to :address, :dependent => :destroy - validates_presence_of :owner_id - end -end diff --git a/test/rails2_root/app/models/pets/dog.rb b/test/rails2_root/app/models/pets/dog.rb deleted file mode 100644 index c1810c00..00000000 --- a/test/rails2_root/app/models/pets/dog.rb +++ /dev/null @@ -1,10 +0,0 @@ -module Pets - class Dog < ActiveRecord::Base - belongs_to :user, :foreign_key => :owner_id - belongs_to :address, :dependent => :destroy - has_many :treats - has_and_belongs_to_many :fleas, :join_table => :fleas - validates_presence_of :treats, :fleas - validates_presence_of :owner_id - end -end diff --git a/test/rails2_root/app/models/post.rb b/test/rails2_root/app/models/post.rb deleted file mode 100644 index 4d5355fe..00000000 --- a/test/rails2_root/app/models/post.rb +++ /dev/null @@ -1,12 +0,0 @@ -class Post < ActiveRecord::Base - belongs_to :user - belongs_to :owner, :foreign_key => :user_id, :class_name => 'User' - has_many :taggings - has_many :tags, :through => :taggings - has_many :through_tags, :through => :taggings, :source => :tag - - validates_uniqueness_of :title - validates_presence_of :title - validates_presence_of :body, :message => 'Seriously, wtf' - validates_numericality_of :user_id -end diff --git a/test/rails2_root/app/models/product.rb b/test/rails2_root/app/models/product.rb deleted file mode 100644 index 6222bec8..00000000 --- a/test/rails2_root/app/models/product.rb +++ /dev/null @@ -1,12 +0,0 @@ -class Product < ActiveRecord::Base - validates_presence_of :title - - validates_inclusion_of :price, :in => 0..99, :unless => :tangible - validates_format_of :size, :with => /^\d+\D+$/, :unless => :tangible - - validates_presence_of :price, :if => :tangible - validates_inclusion_of :price, :in => 1..9999, :if => :tangible - validates_inclusion_of :weight, :in => 1..100, :if => :tangible - validates_format_of :size, :with => /.+x.+x.+/, :if => :tangible - validates_length_of :size, :in => 5..20, :if => :tangible -end diff --git a/test/rails2_root/app/models/profile.rb b/test/rails2_root/app/models/profile.rb deleted file mode 100644 index a169d92f..00000000 --- a/test/rails2_root/app/models/profile.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Profile < ActiveRecord::Base -end diff --git a/test/rails2_root/app/models/registration.rb b/test/rails2_root/app/models/registration.rb deleted file mode 100644 index eb8e4776..00000000 --- a/test/rails2_root/app/models/registration.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Registration < ActiveRecord::Base -end diff --git a/test/rails2_root/app/models/tag.rb b/test/rails2_root/app/models/tag.rb deleted file mode 100644 index 83692df0..00000000 --- a/test/rails2_root/app/models/tag.rb +++ /dev/null @@ -1,8 +0,0 @@ -class Tag < ActiveRecord::Base - has_many :taggings, :dependent => :destroy - has_many :posts, :through => :taggings - - validates_length_of :name, :minimum => 2 - - attr_accessible :name -end diff --git a/test/rails2_root/app/models/tagging.rb b/test/rails2_root/app/models/tagging.rb deleted file mode 100644 index 9b8fb6bd..00000000 --- a/test/rails2_root/app/models/tagging.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Tagging < ActiveRecord::Base - belongs_to :post - belongs_to :tag -end diff --git a/test/rails2_root/app/models/treat.rb b/test/rails2_root/app/models/treat.rb deleted file mode 100644 index a80a7e0a..00000000 --- a/test/rails2_root/app/models/treat.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Treat < ActiveRecord::Base - -end \ No newline at end of file diff --git a/test/rails2_root/app/models/user.rb b/test/rails2_root/app/models/user.rb deleted file mode 100644 index 11ae0f9b..00000000 --- a/test/rails2_root/app/models/user.rb +++ /dev/null @@ -1,32 +0,0 @@ -class User < ActiveRecord::Base - has_many :posts - has_many :dogs, :foreign_key => :owner_id, :class_name => "Pets::Dog" - has_many :cats, :foreign_key => :owner_id, :class_name => "Pets::Cat" - - has_many :friendships - has_many :friends, :through => :friendships - - has_one :address, :as => :addressable, :dependent => :destroy - has_one :registration - has_one :profile, :through => :registration - - named_scope :old, :conditions => "age > 50" - named_scope :eighteen, :conditions => { :age => 18 } - named_scope :recent, lambda {|count| { :limit => count } } - - def self.recent_via_method(count) - scoped(:limit => count) - end - - attr_protected :password - attr_readonly :name - - validates_format_of :email, :with => /\w*@\w*.com/ - validates_length_of :email, :in => 1..100 - validates_numericality_of :age, :greater_than_or_equal_to => 1, - :less_than_or_equal_to => 100 - validates_acceptance_of :eula - validates_uniqueness_of :email, :scope => :name, :case_sensitive => false - validates_length_of :ssn, :is => 9, :message => "Social Security Number is not the right length" - validates_numericality_of :ssn -end diff --git a/test/rails2_root/app/views/layouts/posts.rhtml b/test/rails2_root/app/views/layouts/posts.rhtml deleted file mode 100644 index 3b15ce3d..00000000 --- a/test/rails2_root/app/views/layouts/posts.rhtml +++ /dev/null @@ -1,19 +0,0 @@ - - - -
- - - -<%= flash[:notice] %>
- -<%= yield %> - - - diff --git a/test/rails2_root/app/views/layouts/users.rhtml b/test/rails2_root/app/views/layouts/users.rhtml deleted file mode 100644 index 23757aa6..00000000 --- a/test/rails2_root/app/views/layouts/users.rhtml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - -<%= flash[:notice] %>
- -<%= yield %> - - - diff --git a/test/rails2_root/app/views/layouts/wide.html.erb b/test/rails2_root/app/views/layouts/wide.html.erb deleted file mode 100644 index 668d3b76..00000000 --- a/test/rails2_root/app/views/layouts/wide.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= yield %> \ No newline at end of file diff --git a/test/rails2_root/app/views/notifier/the_email.html.erb b/test/rails2_root/app/views/notifier/the_email.html.erb deleted file mode 100644 index 31bd20e2..00000000 --- a/test/rails2_root/app/views/notifier/the_email.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= @body %> diff --git a/test/rails2_root/app/views/posts/edit.rhtml b/test/rails2_root/app/views/posts/edit.rhtml deleted file mode 100644 index 65bd4fe0..00000000 --- a/test/rails2_root/app/views/posts/edit.rhtml +++ /dev/null @@ -1,27 +0,0 @@ -
- User
- <%= f.text_field :user_id %>
-
- Title
- <%= f.text_field :title %>
-
- Body
- <%= f.text_area :body %>
-
- <%= submit_tag "Update" %> -
-<% end %> - -<%= link_to 'Show', user_post_path(@post.user, @post) %> | -<%= link_to 'Back', user_posts_path(@post.user) %> diff --git a/test/rails2_root/app/views/posts/index.rhtml b/test/rails2_root/app/views/posts/index.rhtml deleted file mode 100644 index f6bb3bd1..00000000 --- a/test/rails2_root/app/views/posts/index.rhtml +++ /dev/null @@ -1,25 +0,0 @@ -User | -Title | -Body | -|||
---|---|---|---|---|---|
<%=h post.user_id %> | -<%=h post.title %> | -<%=h post.body %> | -<%= link_to 'Show', user_post_path(post.user, post) %> | -<%= link_to 'Edit', edit_user_post_path(post.user, post) %> | -<%= link_to 'Destroy', user_post_path(post.user, post), :confirm => 'Are you sure?', - :method => :delete %> | -
- User
- <%= f.text_field :user_id %>
-
- Title
- <%= f.text_field :title %>
-
- Body
- <%= f.text_area :body %>
-
- <%= submit_tag "Create" %> -
-<% end %> - -<%= link_to 'Back', user_posts_path(@user) %> diff --git a/test/rails2_root/app/views/posts/show.rhtml b/test/rails2_root/app/views/posts/show.rhtml deleted file mode 100644 index b9d37914..00000000 --- a/test/rails2_root/app/views/posts/show.rhtml +++ /dev/null @@ -1,18 +0,0 @@ -- User: - <%=h @post.user_id %> -
- -- Title: - <%=h @post.title %> -
- -- Body: - <%=h @post.body %> -
- - -<%= link_to 'Edit', edit_user_post_path(@post.user, @post) %> | -<%= link_to 'Back', user_posts_path(@post.user) %> diff --git a/test/rails2_root/app/views/users/edit.rhtml b/test/rails2_root/app/views/users/edit.rhtml deleted file mode 100644 index 9c47ad56..00000000 --- a/test/rails2_root/app/views/users/edit.rhtml +++ /dev/null @@ -1,22 +0,0 @@ -
- Email
- <%= f.text_field :email %>
-
- Age
- <%= f.text_field :age %>
-
- <%= submit_tag "Update" %> -
-<% end %> - -<%= link_to 'Show', user_path(@user) %> | -<%= link_to 'Back', users_path %> \ No newline at end of file diff --git a/test/rails2_root/app/views/users/index.rhtml b/test/rails2_root/app/views/users/index.rhtml deleted file mode 100644 index 83f2e91a..00000000 --- a/test/rails2_root/app/views/users/index.rhtml +++ /dev/null @@ -1,22 +0,0 @@ -Age | -||||
---|---|---|---|---|
<%=h user.email %> | -<%=h user.age %> | -<%= link_to 'Show', user_path(user) %> | -<%= link_to 'Edit', edit_user_path(user) %> | -<%= link_to 'Destroy', user_path(user), :confirm => 'Are you sure?', :method => :delete %> | -
- Email
- <%= f.text_field :email %>
-
- Age
- <%= f.text_field :age %>
-
- <%= submit_tag "Create" %> -
-<% end %> - -<%= link_to 'Back', users_path %> \ No newline at end of file diff --git a/test/rails2_root/app/views/users/show.rhtml b/test/rails2_root/app/views/users/show.rhtml deleted file mode 100644 index bdcad8ad..00000000 --- a/test/rails2_root/app/views/users/show.rhtml +++ /dev/null @@ -1,13 +0,0 @@ -- Email: - <%=h @user.email %> -
- -- Age: - <%=h @user.age %> -
- - -<%= link_to 'Edit', edit_user_path(@user) %> | -<%= link_to 'Back', users_path %> \ No newline at end of file diff --git a/test/rails2_root/config/boot.rb b/test/rails2_root/config/boot.rb deleted file mode 100644 index 0ad0f787..00000000 --- a/test/rails2_root/config/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/test/rails2_root/config/database.yml b/test/rails2_root/config/database.yml deleted file mode 100644 index 14884975..00000000 --- a/test/rails2_root/config/database.yml +++ /dev/null @@ -1,4 +0,0 @@ -test: - :adapter: sqlite3 - # :dbfile: db/sqlite3.db - :database: ":memory:" diff --git a/test/rails2_root/config/environment.rb b/test/rails2_root/config/environment.rb deleted file mode 100644 index a49e3a86..00000000 --- a/test/rails2_root/config/environment.rb +++ /dev/null @@ -1,17 +0,0 @@ -# Specifies gem version of Rails to use when vendor/rails is not present -old_verbose, $VERBOSE = $VERBOSE, nil -$VERBOSE = old_verbose - -require File.join(File.dirname(__FILE__), 'boot') - -Rails::Initializer.run do |config| - config.log_level = :debug - config.cache_classes = false - config.whiny_nils = true - config.action_controller.session = { - :key => 'shoulda_session', - :secret => 'ceae6058a816b1446e09ce90d8372511' - } -end - -# Dependencies.log_activity = true diff --git a/test/rails2_root/config/environments/test.rb b/test/rails2_root/config/environments/test.rb deleted file mode 100644 index 5e3b89be..00000000 --- a/test/rails2_root/config/environments/test.rb +++ /dev/null @@ -1,23 +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 diff --git a/test/rails2_root/config/initializers/new_rails_defaults.rb b/test/rails2_root/config/initializers/new_rails_defaults.rb deleted file mode 100644 index 5e60c0ad..00000000 --- a/test/rails2_root/config/initializers/new_rails_defaults.rb +++ /dev/null @@ -1,15 +0,0 @@ -# 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. - -# 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 - -# 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/test/rails2_root/config/initializers/shoulda.rb b/test/rails2_root/config/initializers/shoulda.rb deleted file mode 100644 index d132470e..00000000 --- a/test/rails2_root/config/initializers/shoulda.rb +++ /dev/null @@ -1,8 +0,0 @@ -# This simulates loading the shoulda plugin, but without relying on -# vendor/plugins - -shoulda_path = File.join(File.dirname(__FILE__), *%w(.. .. .. ..)) -shoulda_lib_path = File.join(shoulda_path, "lib") - -$LOAD_PATH.unshift(shoulda_lib_path) -load File.join(shoulda_path, "init.rb") diff --git a/test/rails2_root/config/routes.rb b/test/rails2_root/config/routes.rb deleted file mode 100644 index ae2bddd5..00000000 --- a/test/rails2_root/config/routes.rb +++ /dev/null @@ -1,6 +0,0 @@ -ActionController::Routing::Routes.draw do |map| - - map.resources :posts - map.resources :users, :has_many => :posts - -end diff --git a/test/rails2_root/db/migrate/001_create_users.rb b/test/rails2_root/db/migrate/001_create_users.rb deleted file mode 100644 index 13abb7b5..00000000 --- a/test/rails2_root/db/migrate/001_create_users.rb +++ /dev/null @@ -1,19 +0,0 @@ -class CreateUsers < ActiveRecord::Migration - def self.up - create_table :users do |t| - t.column :name, :string - t.column :email, :string - t.column :age, :integer - t.column :ssn, :string - t.column :phone, :string - end - add_index :users, :email, :unique => true - add_index :users, :name - add_index :users, :age - add_index :users, [:email, :name], :unique => true - end - - def self.down - drop_table :users - end -end diff --git a/test/rails2_root/db/migrate/002_create_posts.rb b/test/rails2_root/db/migrate/002_create_posts.rb deleted file mode 100644 index 9ed4debd..00000000 --- a/test/rails2_root/db/migrate/002_create_posts.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreatePosts < ActiveRecord::Migration - def self.up - create_table :posts do |t| - t.column :user_id, :integer - t.column :title, :string - t.column :body, :text - end - end - - def self.down - drop_table :posts - end -end diff --git a/test/rails2_root/db/migrate/003_create_taggings.rb b/test/rails2_root/db/migrate/003_create_taggings.rb deleted file mode 100644 index e163a0a0..00000000 --- a/test/rails2_root/db/migrate/003_create_taggings.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateTaggings < ActiveRecord::Migration - def self.up - create_table :taggings do |t| - t.column :post_id, :integer - t.column :tag_id, :integer - end - end - - def self.down - drop_table :taggings - end -end diff --git a/test/rails2_root/db/migrate/004_create_tags.rb b/test/rails2_root/db/migrate/004_create_tags.rb deleted file mode 100644 index dc58c4f3..00000000 --- a/test/rails2_root/db/migrate/004_create_tags.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateTags < ActiveRecord::Migration - def self.up - create_table :tags do |t| - t.column :name, :string - end - end - - def self.down - drop_table :tags - end -end diff --git a/test/rails2_root/db/migrate/005_create_dogs.rb b/test/rails2_root/db/migrate/005_create_dogs.rb deleted file mode 100644 index d1ada909..00000000 --- a/test/rails2_root/db/migrate/005_create_dogs.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateDogs < ActiveRecord::Migration - def self.up - create_table :dogs do |t| - t.column :owner_id, :integer - t.column :address_id, :integer - end - end - - def self.down - drop_table :dogs - end -end diff --git a/test/rails2_root/db/migrate/006_create_addresses.rb b/test/rails2_root/db/migrate/006_create_addresses.rb deleted file mode 100644 index 151cf45b..00000000 --- a/test/rails2_root/db/migrate/006_create_addresses.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreateAddresses < ActiveRecord::Migration - def self.up - create_table :addresses do |t| - t.column :title, :string - t.column :addressable_id, :integer - t.column :addressable_type, :string - t.column :zip, :string - end - end - - def self.down - drop_table :addresses - end -end diff --git a/test/rails2_root/db/migrate/007_create_fleas.rb b/test/rails2_root/db/migrate/007_create_fleas.rb deleted file mode 100644 index 81ac051c..00000000 --- a/test/rails2_root/db/migrate/007_create_fleas.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateFleas < ActiveRecord::Migration - def self.up - create_table :fleas do |t| - t.string :name - end - end - - def self.down - drop_table :fleas - end -end diff --git a/test/rails2_root/db/migrate/008_create_dogs_fleas.rb b/test/rails2_root/db/migrate/008_create_dogs_fleas.rb deleted file mode 100644 index 98555aec..00000000 --- a/test/rails2_root/db/migrate/008_create_dogs_fleas.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateDogsFleas < ActiveRecord::Migration - def self.up - create_table :dogs_fleas do |t| - t.integer :dog_id - t.integer :flea_id - end - end - - def self.down - drop_table :dogs_fleas - end -end diff --git a/test/rails2_root/db/migrate/009_create_products.rb b/test/rails2_root/db/migrate/009_create_products.rb deleted file mode 100644 index 173f948f..00000000 --- a/test/rails2_root/db/migrate/009_create_products.rb +++ /dev/null @@ -1,17 +0,0 @@ -class CreateProducts < ActiveRecord::Migration - def self.up - create_table :products do |t| - t.string :title - t.integer :price - t.integer :weight - t.string :size - t.boolean :tangible - - t.timestamps - end - end - - def self.down - drop_table :products - end -end diff --git a/test/rails2_root/db/migrate/010_create_friendships.rb b/test/rails2_root/db/migrate/010_create_friendships.rb deleted file mode 100644 index 99d0f6ce..00000000 --- a/test/rails2_root/db/migrate/010_create_friendships.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreateFriendships < ActiveRecord::Migration - def self.up - create_table :friendships do |t| - t.integer :user_id - t.integer :friend_id - - t.timestamps - end - end - - def self.down - drop_table :friendships - end -end diff --git a/test/rails2_root/db/migrate/011_create_treats.rb b/test/rails2_root/db/migrate/011_create_treats.rb deleted file mode 100644 index 1b1a0027..00000000 --- a/test/rails2_root/db/migrate/011_create_treats.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateTreats < ActiveRecord::Migration - def self.up - create_table :treats do |t| - t.integer :dog_id - t.timestamps - end - end - - def self.down - drop_table :treats - end -end \ No newline at end of file diff --git a/test/rails2_root/db/migrate/20090506203502_create_profiles.rb b/test/rails2_root/db/migrate/20090506203502_create_profiles.rb deleted file mode 100644 index 6398c665..00000000 --- a/test/rails2_root/db/migrate/20090506203502_create_profiles.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateProfiles < ActiveRecord::Migration - def self.up - create_table :profiles do |t| - - t.timestamps - end - end - - def self.down - drop_table :profiles - end -end diff --git a/test/rails2_root/db/migrate/20090506203536_create_registrations.rb b/test/rails2_root/db/migrate/20090506203536_create_registrations.rb deleted file mode 100644 index ab9c317e..00000000 --- a/test/rails2_root/db/migrate/20090506203536_create_registrations.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreateRegistrations < ActiveRecord::Migration - def self.up - create_table :registrations do |t| - t.integer :user_id - t.integer :profile_id - - t.timestamps - end - end - - def self.down - drop_table :registrations - end -end diff --git a/test/rails2_root/db/migrate/20090513104502_create_cats.rb b/test/rails2_root/db/migrate/20090513104502_create_cats.rb deleted file mode 100644 index 648a547a..00000000 --- a/test/rails2_root/db/migrate/20090513104502_create_cats.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateCats < ActiveRecord::Migration - def self.up - create_table :cats do |t| - t.column :owner_id, :integer - t.column :address_id, :integer - end - end - - def self.down - drop_table :cats - end -end diff --git a/test/rails2_root/db/schema.rb b/test/rails2_root/db/schema.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/test/rails2_root/public/.htaccess b/test/rails2_root/public/.htaccess deleted file mode 100644 index d3c99834..00000000 --- a/test/rails2_root/public/.htaccess +++ /dev/null @@ -1,40 +0,0 @@ -# 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 "You may have mistyped the address or the page may have moved.
-Maybe you tried to change something you didn't have access to.
-We've been notified about this issue and we'll take a look at it shortly.
-