Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
558334a8
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,体验更适合开发者的 AI 搜索 >>
提交
558334a8
编写于
5月 10, 2011
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
deprecating CSV fixture support
上级
714fea81
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
7 addition
and
55 deletion
+7
-55
activerecord/CHANGELOG
activerecord/CHANGELOG
+2
-0
activerecord/lib/active_record/fixtures.rb
activerecord/lib/active_record/fixtures.rb
+2
-54
activerecord/test/cases/fixtures_test.rb
activerecord/test/cases/fixtures_test.rb
+3
-1
activerecord/test/fixtures/all/people.yml
activerecord/test/fixtures/all/people.yml
+0
-0
未找到文件。
activerecord/CHANGELOG
浏览文件 @
558334a8
*Rails 3.1.0 (unreleased)*
* CSV Fixtures are deprecated and support will be removed in Rails 3.2.0
* AR#new, AR#create and AR#update_attributes all accept a second hash as option that allows you
to specify which role to consider when assigning attributes. This is built on top of ActiveModel's
new mass assignment capabilities:
...
...
activerecord/lib/active_record/fixtures.rb
浏览文件 @
558334a8
...
...
@@ -29,11 +29,9 @@ class FixturesFileNotFound < StandardError; end
#
# = Fixture formats
#
# Fixtures come in
3 flavors
:
# Fixtures come in
1 flavor
:
#
# 1. YAML fixtures
# 2. CSV fixtures
# 3. Single-file fixtures
#
# == YAML fixtures
#
...
...
@@ -75,56 +73,6 @@ class FixturesFileNotFound < StandardError; end
# parent_id: 1
# title: Child
#
# == CSV fixtures
#
# Fixtures can also be kept in the Comma Separated Value (CSV) format. Akin to YAML fixtures, CSV fixtures are stored
# in a single file, but instead end with the <tt>.csv</tt> file extension
# (Rails example: <tt><your-rails-app>/test/fixtures/web_sites.csv</tt>).
#
# The format of this type of fixture file is much more compact than the others, but also a little harder to read by us
# humans. The first line of the CSV file is a comma-separated list of field names. The rest of the
# file is then comprised
# of the actual data (1 per line). Here's an example:
#
# id, name, url
# 1, Ruby On Rails, http://www.rubyonrails.org
# 2, Google, http://www.google.com
#
# Should you have a piece of data with a comma character in it, you can place double quotes around that value. If you
# need to use a double quote character, you must escape it with another double quote.
#
# Another unique attribute of the CSV fixture is that it has *no* fixture name like the other two formats. Instead, the
# fixture names are automatically generated by deriving the class name of the fixture file and adding an incrementing
# number to the end. In our example, the 1st fixture would be called "web_site_1" and the 2nd one would be called
# "web_site_2".
#
# Most databases and spreadsheets support exporting to CSV format, so this is a great format for you to choose if you
# have existing data somewhere already.
#
# == Single-file fixtures
#
# This type of fixture was the original format for Active Record that has since been deprecated in
# favor of the YAML and CSV formats.
# Fixtures for this format are created by placing text files in a sub-directory (with the name of the model)
# to the directory appointed by <tt>ActiveSupport::TestCase.fixture_path=(path)</tt> (this is automatically
# configured for Rails, so you can just put your files in <tt><your-rails-app>/test/fixtures/<your-model-name>/</tt> --
# like <tt><your-rails-app>/test/fixtures/web_sites/</tt> for the WebSite model).
#
# Each text file placed in this directory represents a "record". Usually these types of fixtures are named without
# extensions, but if you are on a Windows machine, you might consider adding <tt>.txt</tt> as the extension.
# Here's what the above example might look like:
#
# web_sites/google
# web_sites/yahoo.txt
# web_sites/ruby-on-rails
#
# The file format of a standard fixture is simple. Each line is a property (or column in db speak) and has the syntax
# of "name => value". Here's an example of the ruby-on-rails fixture above:
#
# id => 1
# name => Ruby on Rails
# url => http://www.rubyonrails.org
#
# = Using fixtures in testcases
#
# Since fixtures are a testing construct, we use them in our unit and functional tests. There are two ways to use the
...
...
@@ -177,7 +125,7 @@ class FixturesFileNotFound < StandardError; end
# = Dynamic fixtures with ERB
#
# Some times you don't care about the content of the fixtures as much as you care about the volume. In these cases, you can
# mix ERB in with your YAML
or CSV
fixtures to create a bunch of fixtures for load testing, like:
# mix ERB in with your YAML fixtures to create a bunch of fixtures for load testing, like:
#
# <% for i in 1..1000 %>
# fix_<%= i %>:
...
...
activerecord/test/cases/fixtures_test.rb
浏览文件 @
558334a8
...
...
@@ -175,7 +175,9 @@ def test_dirty_dirty_yaml_file
end
def
test_empty_csv_fixtures
assert_not_nil
ActiveRecord
::
Fixtures
.
new
(
Account
.
connection
,
"accounts"
,
'Account'
,
FIXTURES_ROOT
+
"/naked/csv/accounts"
)
assert_deprecated
do
assert_not_nil
ActiveRecord
::
Fixtures
.
new
(
Account
.
connection
,
"accounts"
,
'Account'
,
FIXTURES_ROOT
+
"/naked/csv/accounts"
)
end
end
def
test_omap_fixtures
...
...
activerecord/test/fixtures/all/people.
csv
→
activerecord/test/fixtures/all/people.
yml
浏览文件 @
558334a8
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录