public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Search Repo:
Merge [6360] from trunk. Fixes YAML Omap fixtures. References #2665.

git-svn-id: 
http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@6361 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
jeremy (author)
Thu Mar 08 18:09:04 -0800 2007
commit  243cdde6a849b3051739fd8824e4c62df6bd761a
tree    b393f37ce74ab3211c7878d8ffda215e52acc900
parent  a9ed24c2dde18e6f6b86af834c3513f62883b645
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Fixtures: fix YAML ordered map support. #2665 [Manuel Holtgrewe, nfbuckley]
0
+
0
 * Fix has_many :through << with custom foreign keys. #6466, #7153 [naffis, Rich Collins]
0
 
0
 
...
301
302
303
 
304
305
306
307
308
 
 
309
310
311
312
313
 
 
 
 
 
 
314
315
 
 
 
 
 
 
 
 
 
316
317
318
...
301
302
303
304
305
306
307
308
 
309
310
311
 
 
 
 
312
313
314
315
316
317
318
 
319
320
321
322
323
324
325
326
327
328
329
330
0
@@ -301,18 +301,30 @@
0
           yaml_string << IO.read(subfixture_path)
0
         end
0
         yaml_string << IO.read(yaml_file_path)
0
+
0
         begin
0
           yaml = YAML::load(erb_render(yaml_string))
0
         rescue Exception=>boom
0
           raise Fixture::FormatError, "a YAML error occurred parsing #{yaml_file_path}. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html\nThe exact error was:\n #{boom.class}: #{boom}"
0
- end
0
+ end
0
+
0
         if yaml
0
- yaml = yaml.value if yaml.respond_to?(:type_id) and yaml.respond_to?(:value)
0
- yaml.each do |name, data|
0
- unless data
0
- raise Fixture::FormatError, "Bad data for #{@class_name} fixture named #{name} (nil)"
0
+ # If the file is an ordered map, extract its children.
0
+ yaml_value =
0
+ if yaml.respond_to?(:type_id) && yaml.respond_to?(:value)
0
+ yaml.value
0
+ else
0
+ [yaml]
0
             end
0
- self[name] = Fixture.new(data, @class_name)
0
+
0
+ yaml_value.each do |fixture|
0
+ fixture.each do |name, data|
0
+ unless data
0
+ raise Fixture::FormatError, "Bad data for #{@class_name} fixture named #{name} (nil)"
0
+ end
0
+
0
+ self[name] = Fixture.new(data, @class_name)
0
+ end
0
           end
0
         end
0
       elsif File.file?(csv_file_path)
...
1
 
2
3
4
...
 
1
2
3
4
0
@@ -1,4 +1,4 @@
0
---- !!omap
0
+--- !!omap
0
 <% 100.times do |i| %>
0
 - fixture_no_<%= i %>:
0
     id: <%= i %>

Comments

    No one has commented yet.