Skip to content

Commit bfa3beb

Browse files
committed
Preparing for ActiveRecord v3.0.4
1 parent 2d357f5 commit bfa3beb

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

test/cases/calculations_test_sqlserver.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,22 @@ class CalculationsTestSqlserver < ActiveRecord::TestCase
55

66
class CalculationsTest < ActiveRecord::TestCase
77

8-
COERCED_TESTS = [:test_should_sum_expression]
8+
COERCED_TESTS = [:test_should_return_decimal_average_of_integer_field, :test_should_sum_expression]
99

1010
include SqlserverCoercedTest
1111

1212
fixtures :accounts
1313

14+
def test_coerced_should_return_decimal_average_of_integer_field
15+
# Other DBs return 3.5 like this.
16+
# Account.all.map(&:id).inspect # => [1, 2, 3, 4, 5, 6]
17+
# (1+2+3+4+5+6)/6.0 # => 3.5
18+
# But SQL Server does something like this. Bogus!
19+
# (1+2+3+4+5+6)/6 # => 3
20+
value = Account.average(:id)
21+
assert_equal 3, value
22+
end
23+
1424
def test_coerced_should_sum_expression
1525
assert_equal 636, Account.sum("2 * credit_limit")
1626
end

test/cases/pessimistic_locking_test_sqlserver.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ def setup
6666

6767
should 'cope with eager loading un-locked paginated' do
6868
eager_ids_sql = /SELECT DISTINCT TOP \(5\).*FROM \[people\] WITH \(NOLOCK\)/
69-
loader_sql = /FROM \[people\] WITH \(NOLOCK\).*WHERE \(\[people\].\[id\] IN/
69+
loader_sql = /FROM \[people\] WITH \(NOLOCK\).*WHERE \[people\]\.\[id\] IN/
7070
assert_sql(eager_ids_sql,loader_sql) do
7171
Person.all(:include => :readers, :lock => 'WITH (NOLOCK)', :limit => 5, :offset => 10)
7272
end
7373
end
74-
74+
7575
end
7676

7777

0 commit comments

Comments
 (0)