test/test_helper.rb in acts-as-joinable-0.0.6 vs test/test_helper.rb in acts-as-joinable-0.1.0
- old
+ new
@@ -24,11 +24,11 @@
Dir["#{this}/lib/*"].each { |c| require c if File.extname(c) == ".rb" }
require "#{this}/lib/group"
ActiveRecord::Base.class_eval do
def self.detonate
- all.map(&:destroy)
+ delete_all
end
end
ActiveSupport::TestCase.class_eval do
def create_models(parent = 1, child = 2)
@@ -53,6 +53,18 @@
Page.detonate
ActsAsJoinable::Relationship.detonate
Group.detonate
Asset.detonate
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
\ No newline at end of file