diff options
author | Gabe da Silveira <gabe@websaviour.com> | 2008-06-03 17:50:42 -0300 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-07-14 23:22:39 +0100 |
commit | cd9b24286a90111a08002e0da753198c5fb2432a (patch) | |
tree | 3edbdc4ddfaa8ea9ba5819e1a31afcd4f3b5ab1f /activerecord/test/cases | |
parent | 2d6562d51b96af518c1eb2947d6d34d5dd5bad12 (diff) | |
download | rails-cd9b24286a90111a08002e0da753198c5fb2432a.tar.gz rails-cd9b24286a90111a08002e0da753198c5fb2432a.tar.bz2 rails-cd9b24286a90111a08002e0da753198c5fb2432a.zip |
Add assert_sql helper method to check for specific SQL output in Active Record test suite. [#325 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/helper.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index dc83300efa..0530ba9bd9 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -32,13 +32,13 @@ end ActiveRecord::Base.connection.class.class_eval do IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/] - def execute_with_counting(sql, name = nil, &block) - $query_count ||= 0 - $query_count += 1 unless IGNORED_SQL.any? { |r| sql =~ r } - execute_without_counting(sql, name, &block) + 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, :counting + alias_method_chain :execute, :query_record end # Make with_scope public for tests |