X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=vendor%2Frails%2Factiverecord%2Ftest%2Fcases%2Fhelper.rb;fp=vendor%2Frails%2Factiverecord%2Ftest%2Fcases%2Fhelper.rb;h=f7bdac801336c6439b461fbe3f53988120ec8dde;hb=d115f2e23823271635bad69229a42cd8ac68debe;hp=0000000000000000000000000000000000000000;hpb=37cb670bf3ddde90b214e591f100ed4446469484;p=depot.git diff --git a/vendor/rails/activerecord/test/cases/helper.rb b/vendor/rails/activerecord/test/cases/helper.rb new file mode 100644 index 0000000..f7bdac8 --- /dev/null +++ b/vendor/rails/activerecord/test/cases/helper.rb @@ -0,0 +1,62 @@ +$:.unshift(File.dirname(__FILE__) + '/../../lib') +$:.unshift(File.dirname(__FILE__) + '/../../../activesupport/lib') + +require 'config' +require 'test/unit' + +require 'active_record' +require 'active_record/fixtures' +require 'active_record/test_case' +require 'connection' + +# 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 + +def uses_mocha(description) + require 'rubygems' + require 'mocha' + yield +rescue LoadError + $stderr.puts "Skipping #{description} tests. `gem install mocha` and try again." +end + +ActiveRecord::Base.connection.class.class_eval do + IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/] + + 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 Test #:nodoc: + module Unit #:nodoc: + class << TestCase #:nodoc: + 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 + end +end \ No newline at end of file