Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

squelching more warnings in the AR tests. [#4218 state:resolved]

Signed-off-by: wycats <wycats@gmail.com>
  • Loading branch information...
commit 3911a7c197cf40fadab62d17def21db8a3d52f5e 1 parent 191a2f7
@tenderlove tenderlove authored wycats committed
View
7 activerecord/lib/active_record/railties/log_subscriber.rb
@@ -1,6 +1,11 @@
module ActiveRecord
module Railties
class LogSubscriber < Rails::LogSubscriber
+ def initialize
+ super
+ @odd_or_even = false
+ end
+
def sql(event)
name = '%s (%.1fms)' % [event.payload[:name], event.duration]
sql = event.payload[:sql].squeeze(' ')
@@ -24,4 +29,4 @@ def logger
end
end
end
-end
+end
View
2  activerecord/test/cases/callbacks_test.rb
@@ -139,7 +139,7 @@ class CallbackCancellationDeveloper < ActiveRecord::Base
attr_reader :after_save_called, :after_create_called, :after_update_called, :after_destroy_called
attr_accessor :cancel_before_save, :cancel_before_create, :cancel_before_update, :cancel_before_destroy
- before_save { !@cancel_before_save }
+ before_save {defined?(@cancel_before_save) ? !@cancel_before_save : false}
before_create { !@cancel_before_create }
before_update { !@cancel_before_update }
before_destroy { !@cancel_before_destroy }
View
12 activerecord/test/cases/fixtures_test.rb
@@ -244,14 +244,14 @@ class FixturesWithoutInstantiationTest < ActiveRecord::TestCase
fixtures :topics, :developers, :accounts
def test_without_complete_instantiation
- assert_nil @first
- assert_nil @topics
- assert_nil @developers
- assert_nil @accounts
+ assert !defined?(@first)
+ assert !defined?(@topics)
+ assert !defined?(@developers)
+ assert !defined?(@accounts)
end
def test_fixtures_from_root_yml_without_instantiation
- assert_nil @unknown
+ assert !defined?(@unknown), "@unknown is not defined"
end
def test_accessor_methods
@@ -279,7 +279,7 @@ class FixturesWithoutInstanceInstantiationTest < ActiveRecord::TestCase
fixtures :topics, :developers, :accounts
def test_without_instance_instantiation
- assert_nil @first
+ assert !defined?(@first), "@first is not defined"
assert_not_nil @topics
assert_not_nil @developers
assert_not_nil @accounts
View
38 activerecord/test/cases/transactions_test.rb
@@ -51,6 +51,7 @@ def commit_db_transaction
assert !Topic.find(2).approved?, "Second should have been unapproved"
ensure
class << Topic.connection
+ remove_method :commit_db_transaction
alias :commit_db_transaction :real_commit_db_transaction rescue nil
end
end
@@ -382,28 +383,53 @@ def test_sqlite_add_column_in_transaction
private
def add_exception_raising_after_save_callback_to_topic
- Topic.class_eval "def after_save_for_transaction; raise 'Make the transaction rollback' end"
+ Topic.class_eval <<-eoruby, __FILE__, __LINE__ + 1
+ remove_method(:after_save_for_transaction)
+ def after_save_for_transaction
+ raise 'Make the transaction rollback'
+ end
+ eoruby
end
def remove_exception_raising_after_save_callback_to_topic
- Topic.class_eval "def after_save_for_transaction; end"
+ Topic.class_eval <<-eoruby, __FILE__, __LINE__ + 1
+ remove_method :after_save_for_transaction
+ def after_save_for_transaction; end
+ eoruby
end
def add_exception_raising_after_create_callback_to_topic
- Topic.class_eval "def after_create_for_transaction; raise 'Make the transaction rollback' end"
+ Topic.class_eval <<-eoruby, __FILE__, __LINE__ + 1
+ remove_method(:after_create_for_transaction)
+ def after_create_for_transaction
+ raise 'Make the transaction rollback'
+ end
+ eoruby
end
def remove_exception_raising_after_create_callback_to_topic
- Topic.class_eval "def after_create_for_transaction; end"
+ Topic.class_eval <<-eoruby, __FILE__, __LINE__ + 1
+ remove_method :after_create_for_transaction
+ def after_create_for_transaction; end
+ eoruby
end
%w(validation save destroy).each do |filter|
define_method("add_cancelling_before_#{filter}_with_db_side_effect_to_topic") do
- Topic.class_eval "def before_#{filter}_for_transaction() Book.create; false end"
+ Topic.class_eval <<-eoruby, __FILE__, __LINE__ + 1
+ remove_method :before_#{filter}_for_transaction
+ def before_#{filter}_for_transaction
+ Book.create
+ false
+ end
+ eoruby
end
define_method("remove_cancelling_before_#{filter}_with_db_side_effect_to_topic") do
- Topic.class_eval "def before_#{filter}_for_transaction; end"
+ Topic.class_eval <<-eoruby, __FILE__, __LINE__ + 1
+ remove_method :before_#{filter}_for_transaction
+ def before_#{filter}_for_transaction; end
+ eoruby
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.