<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -7,6 +7,8 @@ class Recipe &lt; ActiveRecord::Base
 
   attr_accessible :name, :body, :description
   
+  named_scope :ordered, :order =&gt; &quot;name ASC&quot;
+  
   version_fu rescue nil # hack to silence migration errors when the original table is not there
   
   def validate</diff>
      <filename>app/models/recipe.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,7 @@
       &lt;th width=&quot;40%&quot;&gt;Name&lt;/th&gt;
       &lt;th width=&quot;60%&quot;&gt;Description&lt;/th&gt;
     &lt;/tr&gt;
-    &lt;% for recipe in @stage.recipes %&gt;
+    &lt;% for recipe in @stage.recipes.ordered %&gt;
       &lt;tr class=&quot;&lt;%= cycle :even, :odd, :name =&gt; 'recipes'  %&gt;&quot;&gt;
         &lt;td&gt;&lt;%= link_to h(recipe.name), recipe_path(recipe) %&gt;&lt;/td&gt;
         &lt;td&gt;&lt;%=h recipe.description %&gt;&lt;/td&gt;</diff>
      <filename>app/views/stages/_recipes.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -162,7 +162,7 @@ module Webistrano
     # load custom project recipes
     def load_stage_custom_recipes(config)
       begin
-        deployment.stage.recipes.each do |recipe|
+        deployment.stage.recipes.ordered.each do |recipe|
           logger.info(&quot;loading stage recipe '#{recipe.name}' &quot;)
           config.load(:string =&gt; recipe.body)
         end</diff>
      <filename>lib/webistrano/deployer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -569,6 +569,51 @@ class Webistrano::DeployerTest &lt; ActiveSupport::TestCase
     deployer.invoke_task!
   end
   
+  def test_load_order_of_recipes
+    recipe_1 = create_new_recipe(:name =&gt; 'B', :body =&gt; 'foobar here')
+    @stage.recipes &lt;&lt; recipe_1
+    
+    recipe_2 = create_new_recipe(:name =&gt; 'A', :body =&gt; 'more foobar here')
+    @stage.recipes &lt;&lt; recipe_2
+    
+    # Logger stubing
+    mock_cap_logger = mock
+    mock_cap_logger.expects(:level=).with(3)
+
+    # config stubbing
+    mock_cap_config = mock
+    mock_cap_config.stubs(:trigger)
+    mock_cap_config.stubs(:logger).returns(mock_cap_logger)
+    mock_cap_config.stubs(:logger=)
+    mock_cap_config.stubs(:find_and_execute_task)
+    mock_cap_config.stubs(:[])
+    mock_cap_config.stubs(:fetch).with(:scm)
+
+    # vars
+    mock_cap_config.stubs(:set)
+
+    # roles
+    mock_cap_config.stubs(:role)
+    
+    #
+    # now the interesting part, load
+    #
+    
+    seq = sequence('recipe_loading')
+    mock_cap_config.stubs(:load)
+    mock_cap_config.expects(:load).with(:string =&gt; recipe_2.body ).in_sequence(seq)
+    mock_cap_config.expects(:load).with(:string =&gt; recipe_1.body ).in_sequence(seq)
+
+    # main mock install
+    Webistrano::Configuration.expects(:new).returns(mock_cap_config)
+    
+    #
+    # start 
+    
+    deployer = Webistrano::Deployer.new(@deployment)
+    deployer.invoke_task!
+  end
+  
   def test_handling_of_exceptions_during_command_execution
     # Logger stubing
     mock_cap_logger = mock</diff>
      <filename>test/unit/webistrano_deployer_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>10d0fbddb39e4c2a7588d4cd37c3d09bf18025bd</id>
    </parent>
  </parents>
  <author>
    <name>Jonathan Weiss</name>
    <email>jw@innerewut.de</email>
  </author>
  <url>http://github.com/peritor/webistrano/commit/3411dada9d6f9e1e0a7938ecbb7643779f29376f</url>
  <id>3411dada9d6f9e1e0a7938ecbb7643779f29376f</id>
  <committed-date>2009-11-04T09:27:40-08:00</committed-date>
  <authored-date>2009-11-04T09:27:36-08:00</authored-date>
  <message>load recipes in order (by name ASC)</message>
  <tree>7c4f97c618a411f5f92686b832f7c30c67ff0f14</tree>
  <committer>
    <name>Jonathan Weiss</name>
    <email>jw@innerewut.de</email>
  </committer>
</commit>
