Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
29ed612b
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
29ed612b
编写于
12月 18, 2012
作者:
M
Marc-Andre Lafortune
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simple replacement of variable name for consistency
上级
b045804c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
32 deletion
+32
-32
railties/test/generators/migration_generator_test.rb
railties/test/generators/migration_generator_test.rb
+32
-32
未找到文件。
railties/test/generators/migration_generator_test.rb
浏览文件 @
29ed612b
...
...
@@ -28,7 +28,7 @@ def test_migration_with_class_name
run_generator
[
migration
]
assert_migration
"db/migrate/change_title_body_from_posts.rb"
,
/class
#{
migration
}
< ActiveRecord::Migration/
end
def
test_migration_with_invalid_file_name
migration
=
"add_something:datetime"
assert_raise
ActiveRecord
::
IllegalMigrationNameError
do
...
...
@@ -41,9 +41,9 @@ def test_add_migration_with_attributes
run_generator
[
migration
,
"title:string"
,
"body:text"
]
assert_migration
"db/migrate/
#{
migration
}
.rb"
do
|
content
|
assert_method
:change
,
content
do
|
up
|
assert_match
(
/add_column :posts, :title, :string/
,
up
)
assert_match
(
/add_column :posts, :body, :text/
,
up
)
assert_method
:change
,
content
do
|
change
|
assert_match
(
/add_column :posts, :title, :string/
,
change
)
assert_match
(
/add_column :posts, :body, :text/
,
change
)
end
end
end
...
...
@@ -105,13 +105,13 @@ def test_add_migration_with_attributes_and_indices
run_generator
[
migration
,
"title:string:index"
,
"body:text"
,
"user_id:integer:uniq"
]
assert_migration
"db/migrate/
#{
migration
}
.rb"
do
|
content
|
assert_method
:change
,
content
do
|
up
|
assert_match
(
/add_column :posts, :title, :string/
,
up
)
assert_match
(
/add_column :posts, :body, :text/
,
up
)
assert_match
(
/add_column :posts, :user_id, :integer/
,
up
)
assert_method
:change
,
content
do
|
change
|
assert_match
(
/add_column :posts, :title, :string/
,
change
)
assert_match
(
/add_column :posts, :body, :text/
,
change
)
assert_match
(
/add_column :posts, :user_id, :integer/
,
change
)
assert_match
(
/add_index :posts, :title/
,
change
)
assert_match
(
/add_index :posts, :user_id, unique: true/
,
change
)
end
assert_match
(
/add_index :posts, :title/
,
content
)
assert_match
(
/add_index :posts, :user_id, unique: true/
,
content
)
end
end
...
...
@@ -120,10 +120,10 @@ def test_add_migration_with_attributes_and_wrong_index_declaration
run_generator
[
migration
,
"title:string:inex"
,
"content:text"
,
"user_id:integer:unik"
]
assert_migration
"db/migrate/
#{
migration
}
.rb"
do
|
content
|
assert_method
:change
,
content
do
|
up
|
assert_match
(
/add_column :books, :title, :string/
,
up
)
assert_match
(
/add_column :books, :content, :text/
,
up
)
assert_match
(
/add_column :books, :user_id, :integer/
,
up
)
assert_method
:change
,
content
do
|
change
|
assert_match
(
/add_column :books, :title, :string/
,
change
)
assert_match
(
/add_column :books, :content, :text/
,
change
)
assert_match
(
/add_column :books, :user_id, :integer/
,
change
)
end
assert_no_match
(
/add_index :books, :title/
,
content
)
assert_no_match
(
/add_index :books, :user_id/
,
content
)
...
...
@@ -135,13 +135,13 @@ def test_add_migration_with_attributes_without_type_and_index
run_generator
[
migration
,
"title:index"
,
"body:text"
,
"user_uuid:uniq"
]
assert_migration
"db/migrate/
#{
migration
}
.rb"
do
|
content
|
assert_method
:change
,
content
do
|
up
|
assert_match
(
/add_column :posts, :title, :string/
,
up
)
assert_match
(
/add_column :posts, :body, :text/
,
up
)
assert_match
(
/add_column :posts, :user_uuid, :string/
,
up
)
assert_method
:change
,
content
do
|
change
|
assert_match
(
/add_column :posts, :title, :string/
,
change
)
assert_match
(
/add_column :posts, :body, :text/
,
change
)
assert_match
(
/add_column :posts, :user_uuid, :string/
,
change
)
assert_match
(
/add_index :posts, :title/
,
change
)
assert_match
(
/add_index :posts, :user_uuid, unique: true/
,
change
)
end
assert_match
(
/add_index :posts, :title/
,
content
)
assert_match
(
/add_index :posts, :user_uuid, unique: true/
,
content
)
end
end
...
...
@@ -150,11 +150,11 @@ def test_add_migration_with_attributes_index_declaration_and_attribute_options
run_generator
[
migration
,
"title:string{40}:index"
,
"content:string{255}"
,
"price:decimal{1,2}:index"
,
"discount:decimal{3.4}:uniq"
]
assert_migration
"db/migrate/
#{
migration
}
.rb"
do
|
content
|
assert_method
:change
,
content
do
|
up
|
assert_match
(
/add_column :books, :title, :string, limit: 40/
,
up
)
assert_match
(
/add_column :books, :content, :string, limit: 255/
,
up
)
assert_match
(
/add_column :books, :price, :decimal, precision: 1, scale: 2/
,
up
)
assert_match
(
/add_column :books, :discount, :decimal, precision: 3, scale: 4/
,
up
)
assert_method
:change
,
content
do
|
change
|
assert_match
(
/add_column :books, :title, :string, limit: 40/
,
change
)
assert_match
(
/add_column :books, :content, :string, limit: 255/
,
change
)
assert_match
(
/add_column :books, :price, :decimal, precision: 1, scale: 2/
,
change
)
assert_match
(
/add_column :books, :discount, :decimal, precision: 3, scale: 4/
,
change
)
end
assert_match
(
/add_index :books, :title/
,
content
)
assert_match
(
/add_index :books, :price/
,
content
)
...
...
@@ -167,9 +167,9 @@ def test_add_migration_with_references_options
run_generator
[
migration
,
"author:belongs_to"
,
"distributor:references{polymorphic}"
]
assert_migration
"db/migrate/
#{
migration
}
.rb"
do
|
content
|
assert_method
:change
,
content
do
|
up
|
assert_match
(
/add_reference :books, :author, index: true/
,
up
)
assert_match
(
/add_reference :books, :distributor, polymorphic: true, index: true/
,
up
)
assert_method
:change
,
content
do
|
change
|
assert_match
(
/add_reference :books, :author, index: true/
,
change
)
assert_match
(
/add_reference :books, :distributor, polymorphic: true, index: true/
,
change
)
end
end
end
...
...
@@ -179,10 +179,10 @@ def test_create_join_table_migration
run_generator
[
migration
,
"artist_id"
,
"musics:uniq"
]
assert_migration
"db/migrate/
#{
migration
}
.rb"
do
|
content
|
assert_method
:change
,
content
do
|
up
|
assert_match
(
/create_join_table :artists, :musics/
,
up
)
assert_match
(
/# t.index \[:artist_id, :music_id\]/
,
up
)
assert_match
(
/ t.index \[:music_id, :artist_id\], unique: true/
,
up
)
assert_method
:change
,
content
do
|
change
|
assert_match
(
/create_join_table :artists, :musics/
,
change
)
assert_match
(
/# t.index \[:artist_id, :music_id\]/
,
change
)
assert_match
(
/ t.index \[:music_id, :artist_id\], unique: true/
,
change
)
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录