ENV["RAILS_ENV"] = 'test' require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class Test::Unit::TestCase # Turn off transactional fixtures if you're working with MyISAM tables in MySQL self.use_transactional_fixtures = true # Instantiated fixtures are slow, but give you @david where you otherwise would need people(:david) self.use_instantiated_fixtures = false protected # Comment this method out to test for valid markup (will slow down the tests) def assert_valid_markup end def testing_repository_active? @testing_repository_active ||= if ENABLE_SUBVERSION repos = Repository::Subversion.new(:name => 'svn_test', :path => RAILS_ROOT + '/tmp/svn_test/') begin repos.latest_revision == 10 rescue false ensure repos.destroy end end end def skipped_test_warning warn "Skipped #{name}!\n This test requires the presence of a test repository.\n Please load the test repository fixture into tmp/svn_test." end def check_repository_testable return true if testing_repository_active? skipped_test_warning false end end module AttachmentsShouldNotWriteFilesInTestMode def self.included(base) base.send(:include, InstanceMethods) base.send(:alias_method, :write_physical_file, :write_physical_file_on_test) base.send(:alias_method, :delete_physical_file, :delete_physical_file_on_test) end module InstanceMethods def write_physical_file_on_test raise "Cannot write file. #{self.class.name} is not saved yet!" unless physical_filename true end def delete_physical_file_on_test true end end end Attachment.send(:include, AttachmentsShouldNotWriteFilesInTestMode) class FactoryHashcash < ActiveRecord::Base def self.exercise_solved?(params) return true end end module Retrospectiva module ConfigurationManager def self.update_required? false end private def self.load_config {} end def self.save_config(config_hash = nil) end end end module ActionController class TestRequest def accept_language @env["HTTP_ACCEPT_LANGUAGE"] end def accept_language=(language) @env["HTTP_ACCEPT_LANGUAGE"] = language end end module TestProcess unless method_defined?(:xhr_with_ensure_clear) def xhr_with_ensure_clear(*args) xhr_without_ensure_clear(*args) ensure @request.env.delete 'HTTP_X_REQUESTED_WITH' @request.env.delete 'HTTP_ACCEPT' end alias_method_chain :xhr, :ensure_clear end end end