-
Notifications
You must be signed in to change notification settings - Fork 387
/
mssql_legacy_types_test.rb
58 lines (44 loc) · 1.12 KB
/
mssql_legacy_types_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require 'jdbc_common'
require 'db/mssql'
ActiveRecord::Schema.verbose = false
class CreateArticles < ActiveRecord::Migration
def self.up
execute <<-SQL
CREATE TABLE articles (
[id] int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
[title] VARCHAR(100),
[author] VARCHAR(60) DEFAULT 'anonymous',
[body] TEXT
)
SQL
end
def self.down
drop_table "articles"
end
end
class Article < ActiveRecord::Base
end
class MsSQLLegacyTypesTest < Test::Unit::TestCase
def setup
CreateArticles.up
@connection = ActiveRecord::Base.connection
end
def teardown
CreateArticles.down
ActiveRecord::Base.clear_active_connections!
end
def test_varchar_column
Article.create!(:title => "Blah blah")
article = Article.first
assert_equal("Blah blah", article.title)
end
SAMPLE_TEXT = "Lorem ipsum dolor sit amet ..."
def test_text_column
Article.create!(:body => SAMPLE_TEXT)
article = Article.first
assert_equal(SAMPLE_TEXT, article.body)
end
def test_varchar_default_value
assert_equal("anonymous", Article.new.author)
end
end