Skip to content

Commit 14eb27a

Browse files
committed
Rails2.3 - Add coerced tests for true/false attributes in selects use SQL Server case statement.
1 parent 1124ed6 commit 14eb27a

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

2000-2005-adapter.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
2525
s.test_files = [
2626
"test/cases/aaaa_create_tables_test_sqlserver.rb",
2727
"test/cases/adapter_test_sqlserver.rb",
28+
"test/cases/attribute_methods_test_sqlserver.rb",
2829
"test/cases/basics_test_sqlserver.rb",
2930
"test/cases/calculations_test_sqlserver.rb",
3031
"test/cases/column_test_sqlserver.rb",

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
MASTER
33

4+
* Rails2.3 - Add coerced tests for true/false attributes in selects use SQL Server case statement. [Ken Collins]
5+
46
* Making sure that smalldatetime types are OK to use. Also fixed a bug in the #view_information method that
57
checks to see if a view definition is equal to 4000 chars, meaning that it is most likely truncated and
68
needs to use the backup method of sp_helptext to get it's view definition. [Ken Collins]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require 'cases/sqlserver_helper'
2+
require 'models/topic'
3+
4+
class AttributeMethodsTestSqlserver < ActiveRecord::TestCase
5+
end
6+
7+
class AttributeMethodsTest < ActiveRecord::TestCase
8+
9+
COERCED_TESTS = [
10+
:test_typecast_attribute_from_select_to_false,
11+
:test_typecast_attribute_from_select_to_true
12+
]
13+
14+
include SqlserverCoercedTest
15+
16+
fixtures :topics
17+
18+
19+
def test_coerced_typecast_attribute_from_select_to_false
20+
topic = Topic.create(:title => 'Budget')
21+
topic = Topic.find(:first, :select => "topics.*, CASE WHEN 1=2 THEN 1 ELSE 0 END as is_test")
22+
assert !topic.is_test?
23+
end
24+
25+
def test_coerced_typecast_attribute_from_select_to_true
26+
topic = Topic.create(:title => 'Budget')
27+
topic = Topic.find(:first, :select => "topics.*, CASE WHEN 2=2 THEN 1 ELSE 0 END as is_test")
28+
assert topic.is_test?
29+
end
30+
31+
32+
end
33+

0 commit comments

Comments
 (0)