Permalink
Browse files

cleaning up a bunch of parse time warnings in AR [#4186 state:resolved]

Signed-off-by: wycats <wycats@gmail.com>
  • Loading branch information...
1 parent 8dd731b commit 1def14309f32cc1c7d66b8625754ba2827410c96 @tenderlove tenderlove committed with wycats Mar 16, 2010
@@ -805,7 +805,7 @@ def test_preload_has_many_using_primary_key
end
def test_include_has_many_using_primary_key
- expected = Firm.find(1).clients_using_primary_key.sort_by &:name
+ expected = Firm.find(1).clients_using_primary_key.sort_by(&:name)
# Oracle adapter truncates alias to 30 characters
if current_adapter?(:OracleAdapter)
firm = Firm.find 1, :include => :clients_using_primary_key, :order => 'clients_using_primary_keys_companies'[0,30]+'.name'
@@ -291,7 +291,7 @@ def test_association_callback_ordering
], log.last(2)
post.people_with_callbacks = [people(:michael),people(:david), Person.new(:first_name => "Julian"), Person.create!(:first_name => "Roger")]
- assert_equal (%w(Ted Bob Sam Lary) * 2).sort, log[-12..-5].collect(&:last).sort
+ assert_equal((%w(Ted Bob Sam Lary) * 2).sort, log[-12..-5].collect(&:last).sort)
assert_equal [
[:added, :before, "Julian"],
[:added, :after, "Julian"],
@@ -300,7 +300,7 @@ def test_association_callback_ordering
], log.last(4)
post.people_with_callbacks.clear
- assert_equal (%w(Michael David Julian Roger) * 2).sort, log.last(8).collect(&:last).sort
+ assert_equal((%w(Michael David Julian Roger) * 2).sort, log.last(8).collect(&:last).sort)
end
def test_dynamic_find_should_respect_association_include
@@ -15,12 +15,12 @@ def test_construct_finder_sql_applies_aliases_tables_on_association_conditions
def test_construct_finder_sql_ignores_empty_joins_hash
sql = Author.joins({}).to_sql
- assert_no_match /JOIN/i, sql
+ assert_no_match(/JOIN/i, sql)
end
def test_construct_finder_sql_ignores_empty_joins_array
sql = Author.joins([]).to_sql
- assert_no_match /JOIN/i, sql
+ assert_no_match(/JOIN/i, sql)
end
def test_find_with_implicit_inner_joins_honors_readonly_without_select
@@ -674,10 +674,10 @@ def test_increment_counter
def test_decrement_counter
Topic.decrement_counter("replies_count", 2)
- assert_equal -1, Topic.find(2).replies_count
+ assert_equal(-1, Topic.find(2).replies_count)
Topic.decrement_counter("replies_count", 2)
- assert_equal -2, Topic.find(2).replies_count
+ assert_equal(-2, Topic.find(2).replies_count)
end
def test_reset_counters
@@ -1533,7 +1533,7 @@ def test_numeric_fields
def test_auto_id
auto = AutoId.new
auto.save
- assert (auto.id > 0)
+ assert(auto.id > 0)
end
def quote_column_name(name)
@@ -2181,7 +2181,7 @@ def test_inspect_instance
end
def test_inspect_new_instance
- assert_match /Topic id: nil/, Topic.new.inspect
+ assert_match(/Topic id: nil/, Topic.new.inspect)
end
def test_inspect_limited_select_instance
@@ -2240,9 +2240,9 @@ def test_benchmark_with_log_level
ActiveRecord::Base.benchmark("Debug Topic Count", :level => :debug) { Topic.count }
ActiveRecord::Base.benchmark("Warn Topic Count", :level => :warn) { Topic.count }
ActiveRecord::Base.benchmark("Error Topic Count", :level => :error) { Topic.count }
- assert_no_match /Debug Topic Count/, log.string
- assert_match /Warn Topic Count/, log.string
- assert_match /Error Topic Count/, log.string
+ assert_no_match(/Debug Topic Count/, log.string)
+ assert_match(/Warn Topic Count/, log.string)
+ assert_match(/Error Topic Count/, log.string)
ensure
ActiveRecord::Base.logger = original_logger
end
@@ -2253,8 +2253,8 @@ def test_benchmark_with_use_silence
ActiveRecord::Base.logger = Logger.new(log)
ActiveRecord::Base.benchmark("Logging", :level => :debug, :silence => true) { ActiveRecord::Base.logger.debug "Loud" }
ActiveRecord::Base.benchmark("Logging", :level => :debug, :silence => false) { ActiveRecord::Base.logger.debug "Quiet" }
- assert_no_match /Loud/, log.string
- assert_match /Quiet/, log.string
+ assert_no_match(/Loud/, log.string)
+ assert_match(/Quiet/, log.string)
ensure
ActiveRecord::Base.logger = original_logger
end
@@ -24,7 +24,7 @@ def test_default_integers
assert_instance_of Fixnum, default.positive_integer
assert_equal 1, default.positive_integer
assert_instance_of Fixnum, default.negative_integer
- assert_equal -1, default.negative_integer
+ assert_equal(-1, default.negative_integer)
assert_instance_of BigDecimal, default.decimal_number
assert_equal BigDecimal.new("2.78"), default.decimal_number
end
@@ -33,7 +33,7 @@ def test_default_integers
if current_adapter?(:PostgreSQLAdapter)
def test_multiline_default_text
# older postgres versions represent the default with escapes ("\\012" for a newline)
- assert ( "--- []\n\n" == Default.columns_hash['multiline_default'].default ||
+ assert( "--- []\n\n" == Default.columns_hash['multiline_default'].default ||
"--- []\\012\\012" == Default.columns_hash['multiline_default'].default)
end
end
@@ -26,8 +26,8 @@ def test_basic_query_logging
Developer.all
wait
assert_equal 1, @logger.logged(:debug).size
- assert_match /Developer Load/, @logger.logged(:debug).last
- assert_match /SELECT .*?FROM .?developers.?/, @logger.logged(:debug).last
+ assert_match(/Developer Load/, @logger.logged(:debug).last)
+ assert_match(/SELECT .*?FROM .?developers.?/, @logger.logged(:debug).last)
end
def test_cached_queries
@@ -37,7 +37,7 @@ def test_cached_queries
end
wait
assert_equal 2, @logger.logged(:debug).size
- assert_match /CACHE/, @logger.logged(:debug).last
- assert_match /SELECT .*?FROM .?developers.?/, @logger.logged(:debug).last
+ assert_match(/CACHE/, @logger.logged(:debug).last)
+ assert_match(/SELECT .*?FROM .?developers.?/, @logger.logged(:debug).last)
end
-end
+end
@@ -382,7 +382,7 @@ def test_merged_scoped_find
Developer.send(:with_scope, :find => { :conditions => "salary < 100000" }) do
Developer.send(:with_scope, :find => { :offset => 1, :order => 'id asc' }) do
# Oracle adapter does not generated space after asc therefore trailing space removed from regex
- assert_sql /ORDER BY id asc/ do
+ assert_sql(/ORDER BY id asc/) do
assert_equal(poor_jamis, Developer.find(:first, :order => 'id asc'))
end
end
@@ -477,7 +477,7 @@ def test_native_types
assert_not_equal "Z", bob.moment_of_truth.zone
# US/Eastern is -5 hours from GMT
assert_equal Rational(-5, 24), bob.moment_of_truth.offset
- assert_match /\A-05:?00\Z/, bob.moment_of_truth.zone #ruby 1.8.6 uses HH:MM, prior versions use HHMM
+ assert_match(/\A-05:?00\Z/, bob.moment_of_truth.zone) #ruby 1.8.6 uses HH:MM, prior versions use HHMM
assert_equal DateTime::ITALY, bob.moment_of_truth.start
end
end
@@ -493,7 +493,7 @@ def test_unabstracted_database_dependent_types
ActiveRecord::Migration.add_column :people, :intelligence_quotient, :tinyint
Person.reset_column_information
- assert_match /tinyint/, Person.columns_hash['intelligence_quotient'].sql_type
+ assert_match(/tinyint/, Person.columns_hash['intelligence_quotient'].sql_type)
ensure
ActiveRecord::Migration.remove_column :people, :intelligence_quotient rescue nil
end
@@ -83,8 +83,8 @@ def test_scopes_can_be_specified_with_deep_hash_conditions
end
def test_scopes_are_composable
- assert_equal (approved = Topic.find(:all, :conditions => {:approved => true})), Topic.approved
- assert_equal (replied = Topic.find(:all, :conditions => 'replies_count > 0')), Topic.replied
+ assert_equal((approved = Topic.find(:all, :conditions => {:approved => true})), Topic.approved)
+ assert_equal((replied = Topic.find(:all, :conditions => 'replies_count > 0')), Topic.replied)
assert !(approved == replied)
assert !(approved & replied).empty?

0 comments on commit 1def143

Please sign in to comment.