<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>vendor/plugins/model_stubbing/init.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -11,7 +11,7 @@
   	&lt;p&gt;&lt;%= 'This user can moderate the following forums.  Click one to remove.'[:remove_moderated_forum] %&gt;&lt;/p&gt;
 
     &lt;ul class=&quot;flat&quot;&gt;
-    &lt;% @user.forums.find(:all, :select =&gt; &quot;#{Forum.table_name}.*, #{Moderatorship.table_name}.id as moderatorship_id&quot;).each do |forum| -%&gt;
+    &lt;% @user.forums.moderatable.each do |forum| -%&gt;
       &lt;li&gt;
         &lt;%= link_to forum.name, moderatorship_path(forum.moderatorship_id), :method =&gt; :delete, :confirm =&gt; &quot;#{'Remove user as moderator for'[:remove_user_as_moderator]} #{forum.name}?&quot; %&gt;
       &lt;/li&gt;</diff>
      <filename>app/views/users/show.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -50,7 +50,7 @@ module ModelStubbing
         # if options are given first, assume that base_name is default
         when Hash
           options   = base_name
-          base_name = nil
+          base_name = self
         when nil
         else
           unless options[:copy] || block.nil?</diff>
      <filename>vendor/plugins/model_stubbing/lib/model_stubbing.rb</filename>
    </modified>
    <modified>
      <diff>@@ -115,7 +115,7 @@ module ModelStubbing
       ModelStubbing.records.clear
       ModelStubbing.stub_current_time_with(current_time) if current_time
       return unless database?
-      ActiveRecord::Base.send :increment_open_transactions
+      ActiveRecord::Base.connection.increment_open_transactions
       ActiveRecord::Base.connection.begin_db_transaction
     end
     </diff>
      <filename>vendor/plugins/model_stubbing/lib/model_stubbing/definition.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@ module ModelStubbing
   # Models hold one or more stubs.
   class Model
     attr_accessor :name, :plural, :singular
-    attr_reader   :definition, :stubs, :model_class, :options
+    attr_reader   :definition, :stubs, :model_class, :options, :ordered_stubs
 
     # Creates a stub for this model.  A stub with no name is assumed to be the default
     # stub.  A global key for the definition is also created based on the singular
@@ -17,13 +17,14 @@ module ModelStubbing
     end
 
     def initialize(definition, klass, options = {}, &amp;block)
-      @definition  = definition
-      @model_class = klass
-      @name        = options.delete(:name)     || default_name.to_sym
-      @plural      = options.delete(:plural)   || name
-      @singular    = options.delete(:singular) || name.to_s.singularize
-      @options     = options
-      @stubs       = {}
+      @definition    = definition
+      @model_class   = klass
+      @name          = options.delete(:name)     || default_name.to_sym
+      @plural        = options.delete(:plural)   || name
+      @singular      = options.delete(:singular) || name.to_s.singularize
+      @options       = options
+      @stubs         = {}
+      @ordered_stubs = []
       unless @model_class.respond_to?(:mock_id)
         class &lt;&lt; @model_class
           define_method :mock_id do
@@ -92,7 +93,11 @@ module ModelStubbing
     
     def insert
       purge
-      @stubs.values.each &amp;:insert
+      @ordered_stubs.each do |name| 
+        if stub = @stubs[name]
+          stub.insert
+        end
+      end
     end
     
     def purge
@@ -104,5 +109,19 @@ module ModelStubbing
     def connection
       @connection ||= model_class.respond_to?(:connection) &amp;&amp; model_class.connection
     end
+
+  protected
+    def method_missing(model_name, stub_name, *args)
+      named_model = @definition.models[model_name]
+      if named_model.nil?
+        raise &quot;No #{model_name.inspect} model found when calling #{model_name}(#{stub_name})&quot;
+      end
+      stub = named_model.stubs[stub_name]
+      if stub.nil?
+        raise &quot;No #{stub_name.inspect} stub found in the #{model_name.inspect} model when calling #{model_name}(#{stub_name})&quot;
+      else
+        stub
+      end
+    end
   end
 end
\ No newline at end of file</diff>
      <filename>vendor/plugins/model_stubbing/lib/model_stubbing/model.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,6 +19,8 @@ module ModelStubbing
         end
 
       @global_key = (name == :default ? @model.singular : &quot;#{name}_#{@model.singular}&quot;).to_sym
+      @model.ordered_stubs &lt;&lt; name
+      @model.ordered_stubs.uniq!
       @model.all_stubs[@global_key] = @model.stubs[name] = self
     end
     
@@ -39,7 +41,11 @@ module ModelStubbing
     # pass :id =&gt; :new to specify you want a new record, not one in the database
     def record(attributes = {})
       this_record_key = record_key(attributes)
-      ModelStubbing.records[this_record_key] ||= instantiate(this_record_key, attributes)
+      if attributes[:id] != :new &amp;&amp; ModelStubbing.records.key?(this_record_key)
+        ModelStubbing.records[this_record_key]
+      else
+        ModelStubbing.records[this_record_key] = instantiate(this_record_key, attributes)
+      end
     end
     
     def inspect
@@ -157,7 +163,6 @@ module ModelStubbing
     def record_key(attributes)
       return @record_key if @record_key &amp;&amp; attributes.empty?
       key = [model.model_class.name, @global_key, @attributes.merge(attributes).inspect] * &quot;:&quot;
-      key &lt;&lt; model.model_class.base_class.mock_id.to_s if attributes[:id] == :new
       @record_key = key if attributes.empty?
       key 
     end</diff>
      <filename>vendor/plugins/model_stubbing/lib/model_stubbing/stub.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,9 @@
 namespace :stubs do
-  
   desc &quot;Load a ModelStubbing definition into the database. Specify Stub file with STUBS= and Definition with DEF=&quot;
   task :load do
     root = File.dirname(__FILE__) + '/../../../../'
     require File.expand_path(root + &quot;config/environment&quot;)
-    
+
     begin
       require 'spec'
     rescue
@@ -12,15 +11,10 @@ namespace :stubs do
       require 'spec'
     end
     require 'model_stubbing'
-    
-    # note to Rick: I've taken to using 'stubs.rb' instead of 'model_stubs.rb'
-    # because 'model_stubs' has a tab-completion collision with 'spec/models' and
-    # that drives me batty. Change the default to 'spec/model_stubs' if you want,
-    # you won't hurt my feelings.
+
     require root + (ENV['STUBS'] || 'spec/stubs')
     
     defn = (ENV['DEF'] || 'default').intern
     ModelStubbing.definitions[defn].insert!
   end
-  
 end
\ No newline at end of file</diff>
      <filename>vendor/plugins/model_stubbing/tasks/stubs.rake</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>94f575daace57ebeca4db0af9abec01bdcade50f</id>
    </parent>
    <parent>
      <id>80228688c179a6d05405c653631a4fab5616c006</id>
    </parent>
  </parents>
  <author>
    <name>Court3nay</name>
    <email>courtenay@caboo.se</email>
  </author>
  <url>http://github.com/courtenay/altered_beast/commit/bd2322c7877d3f51daf9ea7320a25a0219896305</url>
  <id>bd2322c7877d3f51daf9ea7320a25a0219896305</id>
  <committed-date>2008-10-14T15:51:56-07:00</committed-date>
  <authored-date>2008-10-14T15:51:56-07:00</authored-date>
  <message>Merge branch 'master' of git@git.caboo.se:altered_beast</message>
  <tree>96e6e8256347c9822ce80cff18b5a0c6bbbed4e7</tree>
  <committer>
    <name>Court3nay</name>
    <email>courtenay@caboo.se</email>
  </committer>
</commit>
