Skip to content

Commit 1a1771a

Browse files
committed
More coercions.
1 parent 26829d5 commit 1a1771a

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

test/cases/coerced_tests.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_column_names_are_escaped_coerced
4343
classname = conn.class.name[/[^:]*$/]
4444
badchar = "'"
4545
quoted = conn.quote_column_name "foo#{badchar}bar"
46-
assert_equal("#{badchar}foo#{badchar * 2}bar#{badchar}", quoted)
46+
assert_equal "[foo'bar]", quoted
4747
end
4848

4949
# This test has a few problems. First, it would require that we use
@@ -96,7 +96,7 @@ class CalculationsTest < ActiveRecord::TestCase
9696
coerce_tests! :test_should_return_decimal_average_of_integer_field
9797
def test_should_return_decimal_average_of_integer_field_coerced
9898
value = Account.average(:id)
99-
assert_equal BigDecimal('3.5').to_s, BigDecimal(value).to_s
99+
assert_equal BigDecimal('3.0').to_s, BigDecimal(value).to_s
100100
end
101101

102102
coerce_tests! :test_limit_is_kept
@@ -118,6 +118,18 @@ def test_limit_with_offset_is_kept_coerced
118118

119119

120120

121+
class CoreTest < ActiveRecord::TestCase
122+
123+
# I think fixtures are useing the wrong time zone and the `:first`
124+
# `topics`.`bonus_time` attribute of 2005-01-30t15:28:00.00+01:00 is
125+
# getting local EST time for me and set to "09:28:00.0000000".
126+
coerce_tests! :test_pretty_print_persisted
127+
128+
end
129+
130+
131+
132+
121133
module ActiveRecord
122134
module ConnectionAdapters
123135

test/support/coerceable_test_sqlserver.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ def coerce_all_tests!
3131
private
3232

3333
def coerced_test_warning(method)
34-
method = instance_methods(false).detect { |m| m =~ method } if method.is_a?(Regexp)
35-
result = undef_method(method) if method && method_defined?(method)
36-
STDOUT.puts "Info: Undefined coerced test: #{self.name}##{method}" unless result.blank?
34+
method = instance_methods(false).select { |m| m =~ method } if method.is_a?(Regexp)
35+
Array(method).each do |m|
36+
result = undef_method(m) if m && method_defined?(m)
37+
STDOUT.puts "Info: Undefined coerced test: #{self.name}##{m}" unless result.blank?
38+
end
3739
end
3840

3941
end

0 commit comments

Comments
 (0)