<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,6 @@
 == master
 
+* Add support for ActiveRecord 2.0.*
 * Fix nil states being overwritten when they're explicitly set in ORM integrations
 * Fix default states not getting set in ORM integrations if the column has a default
 * Fix event transitions being kept around while running actions/callbacks, sometimes preventing object marshalling</diff>
      <filename>CHANGELOG.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -454,13 +454,13 @@ integrations if the proper dependencies are available):
 
 Target specific versions of integrations like so:
 
-  rake test AR_VERSION=2.1.0 DM_VERSION=0.9.4 SEQUEL_VERSION=2.8.0
+  rake test AR_VERSION=2.0.0 DM_VERSION=0.9.4 SEQUEL_VERSION=2.8.0
 
 == Dependencies
 
 By default, there are no dependencies.  If using specific integrations, those
 dependencies are listed below.
 
-* ActiveRecord[http://rubyonrails.org] integration: 2.1.0 or later
+* ActiveRecord[http://rubyonrails.org] integration: 2.0.0 or later
 * DataMapper[http://datamapper.org] integration: 0.9.4 or later
 * Sequel[http://sequel.rubyforge.org] integration: 2.8.0 or later</diff>
      <filename>README.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -432,16 +432,18 @@ module StateMachine
         # state names can be translated to their associated values and so that
         # inheritance is respected properly.
         def define_scope(name, scope)
-          name = name.to_sym
-          machine_name = self.name
-          
-          # Create the scope and then override it with state translation
-          owner_class.named_scope(name)
-          owner_class.scopes[name] = lambda do |klass, *states|
-            machine_states = klass.state_machine(machine_name).states
-            values = states.flatten.map {|state| machine_states.fetch(state).value}
+          if owner_class.respond_to?(:named_scope)
+            name = name.to_sym
+            machine_name = self.name
             
-            ::ActiveRecord::NamedScope::Scope.new(klass, scope.call(values))
+            # Create the scope and then override it with state translation
+            owner_class.named_scope(name)
+            owner_class.scopes[name] = lambda do |klass, *states|
+              machine_states = klass.state_machine(machine_name).states
+              values = states.flatten.map {|state| machine_states.fetch(state).value}
+              
+              ::ActiveRecord::NamedScope::Scope.new(klass, scope.call(values))
+            end
           end
           
           # Prevent the Machine class from wrapping the scope</diff>
      <filename>lib/state_machine/integrations/active_record.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@ begin
   # Load library
   require 'rubygems'
   
-  gem 'activerecord', ENV['AR_VERSION'] ? &quot;=#{ENV['AR_VERSION']}&quot; : '&gt;=2.1.0'
+  gem 'activerecord', ENV['AR_VERSION'] ? &quot;=#{ENV['AR_VERSION']}&quot; : '&gt;=2.0.0'
   require 'active_record'
   
   FIXTURES_ROOT = File.dirname(__FILE__) + '/../../fixtures/'
@@ -12,7 +12,17 @@ begin
   # Load TestCase helpers
   require 'active_support/test_case'
   require 'active_record/fixtures'
-  require 'active_record/test_case'
+  
+  require 'active_record/version'
+  if ActiveRecord::VERSION::STRING &gt;= '2.1.0'
+    require 'active_record/test_case'
+  else
+    class ActiveRecord::TestCase &lt; ActiveSupport::TestCase
+      self.fixture_path = FIXTURES_ROOT
+      self.use_instantiated_fixtures = false
+      self.use_transactional_fixtures = true
+    end
+  end
   
   # Establish database connection
   ActiveRecord::Base.establish_connection({'adapter' =&gt; 'sqlite3', 'database' =&gt; ':memory:'})
@@ -90,58 +100,6 @@ begin
         @machine.state :idling, :value =&gt; lambda {'idling'}
       end
       
-      def test_should_create_singular_with_scope
-        assert @model.respond_to?(:with_state)
-      end
-      
-      def test_should_only_include_records_with_state_in_singular_with_scope
-        parked = @model.create :state =&gt; 'parked'
-        idling = @model.create :state =&gt; 'idling'
-        
-        assert_equal [parked], @model.with_state(:parked)
-      end
-      
-      def test_should_create_plural_with_scope
-        assert @model.respond_to?(:with_states)
-      end
-      
-      def test_should_only_include_records_with_states_in_plural_with_scope
-        parked = @model.create :state =&gt; 'parked'
-        idling = @model.create :state =&gt; 'idling'
-        
-        assert_equal [parked, idling], @model.with_states(:parked, :idling)
-      end
-      
-      def test_should_create_singular_without_scope
-        assert @model.respond_to?(:without_state)
-      end
-      
-      def test_should_only_include_records_without_state_in_singular_without_scope
-        parked = @model.create :state =&gt; 'parked'
-        idling = @model.create :state =&gt; 'idling'
-        
-        assert_equal [parked], @model.without_state(:idling)
-      end
-      
-      def test_should_create_plural_without_scope
-        assert @model.respond_to?(:without_states)
-      end
-      
-      def test_should_only_include_records_without_states_in_plural_without_scope
-        parked = @model.create :state =&gt; 'parked'
-        idling = @model.create :state =&gt; 'idling'
-        first_gear = @model.create :state =&gt; 'first_gear'
-        
-        assert_equal [parked, idling], @model.without_states(:first_gear)
-      end
-      
-      def test_should_allow_chaining_scopes
-        parked = @model.create :state =&gt; 'parked'
-        idling = @model.create :state =&gt; 'idling'
-        
-        assert_equal [idling], @model.without_state(:parked).with_state(:idling)
-      end
-      
       def test_should_rollback_transaction_if_false
         @machine.within_transaction(@model.new) do
           @model.create
@@ -220,7 +178,7 @@ begin
         @model = new_model(false)
         
         # Drop the table so that it definitely doesn't exist
-        @model.connection.drop_table(:foo) if @model.connection.table_exists?(:foo)
+        @model.connection.drop_table(:foo) if @model.table_exists?
       end
       
       def test_should_allow_machine_creation
@@ -359,7 +317,7 @@ begin
     class MachineWithColumnDefaultTest &lt; ActiveRecord::TestCase
       def setup
         @model = new_model do
-          connection.change_table(:foo) {|t| t.string(:status, :default =&gt; 'idling')}
+          connection.add_column :foo, :status, :string, :default =&gt; 'idling'
         end
         @machine = StateMachine::Machine.new(@model, :status, :initial =&gt; :parked)
         @record = @model.new
@@ -483,47 +441,6 @@ begin
       end
     end
     
-    class MachineWithComplexPluralizationTest &lt; ActiveRecord::TestCase
-      def setup
-        @model = new_model
-        @machine = StateMachine::Machine.new(@model, :status)
-      end
-      
-      def test_should_create_singular_with_scope
-        assert @model.respond_to?(:with_status)
-      end
-      
-      def test_should_create_plural_with_scope
-        assert @model.respond_to?(:with_statuses)
-      end
-    end
-    
-    class MachineWithOwnerSubclassTest &lt; ActiveRecord::TestCase
-      def setup
-        @model = new_model
-        @machine = StateMachine::Machine.new(@model, :state)
-        
-        @subclass = Class.new(@model)
-        @subclass_machine = @subclass.state_machine(:state) {}
-        @subclass_machine.state :parked, :idling, :first_gear
-      end
-      
-      def test_should_only_include_records_with_subclass_states_in_with_scope
-        parked = @subclass.create :state =&gt; 'parked'
-        idling = @subclass.create :state =&gt; 'idling'
-        
-        assert_equal [parked, idling], @subclass.with_states(:parked, :idling)
-      end
-      
-      def test_should_only_include_records_without_subclass_states_in_without_scope
-        parked = @subclass.create :state =&gt; 'parked'
-        idling = @subclass.create :state =&gt; 'idling'
-        first_gear = @subclass.create :state =&gt; 'first_gear'
-        
-        assert_equal [parked, idling], @subclass.without_states(:first_gear)
-      end
-    end
-    
     class MachineWithCustomAttributeTest &lt; ActiveRecord::TestCase
       def setup
         @model = new_model do
@@ -701,42 +618,6 @@ begin
       end
     end
     
-    class MachineWithLoopbackTest &lt; ActiveRecord::TestCase
-      def setup
-        changed_attrs = nil
-        
-        @model = new_model do
-          connection.change_table(:foo) {|t| t.datetime(:updated_at)}
-          
-          define_method(:before_update) do
-            changed_attrs = changed_attributes.dup
-          end
-        end
-        
-        @machine = StateMachine::Machine.new(@model, :initial =&gt; :parked)
-        @machine.event :park
-        
-        @record = @model.create(:updated_at =&gt; Time.now - 1)
-        @timestamp = @record.updated_at
-        
-        @transition = StateMachine::Transition.new(@record, @machine, :park, :parked, :parked)
-        @transition.perform
-        
-        @changed_attrs = changed_attrs
-      end
-      
-      def test_should_include_state_in_changed_attributes
-        @changed_attrs.delete('updated_at')
-        
-        expected = {'state' =&gt; 'parked'}
-        assert_equal expected, @changed_attrs
-      end
-      
-      def test_should_update_record
-        assert_not_equal @timestamp, @record.updated_at
-      end
-    end
-    
     class MachineWithFailedBeforeCallbacksTest &lt; ActiveRecord::TestCase
       def setup
         @before_count = 0
@@ -1264,6 +1145,148 @@ begin
       end
     end
     
+    if ActiveRecord.const_defined?(:Dirty) || ActiveRecord::AttributeMethods.const_defined?(:Dirty)
+      class MachineWithLoopbackTest &lt; ActiveRecord::TestCase
+        def setup
+          changed_attrs = nil
+          
+          @model = new_model do
+            connection.add_column :foo, :updated_at, :datetime
+            
+            define_method(:before_update) do
+              changed_attrs = changed_attributes.dup
+            end
+          end
+          
+          @machine = StateMachine::Machine.new(@model, :initial =&gt; :parked)
+          @machine.event :park
+          
+          @record = @model.create(:updated_at =&gt; Time.now - 1)
+          @timestamp = @record.updated_at
+          
+          @transition = StateMachine::Transition.new(@record, @machine, :park, :parked, :parked)
+          @transition.perform
+          
+          @changed_attrs = changed_attrs
+        end
+        
+        def test_should_include_state_in_changed_attributes
+          @changed_attrs.delete('updated_at')
+          
+          expected = {'state' =&gt; 'parked'}
+          assert_equal expected, @changed_attrs
+        end
+        
+        def test_should_update_record
+          assert_not_equal @timestamp, @record.updated_at
+        end
+      end
+    end
+    
+    if ActiveRecord.const_defined?(:NamedScope)
+      class MachineWithScopesTest &lt; ActiveRecord::TestCase
+        def setup
+          @model = new_model
+          @machine = StateMachine::Machine.new(@model)
+          @machine.state :parked, :first_gear
+          @machine.state :idling, :value =&gt; lambda {'idling'}
+        end
+        
+        def test_should_create_singular_with_scope
+          assert @model.respond_to?(:with_state)
+        end
+        
+        def test_should_only_include_records_with_state_in_singular_with_scope
+          parked = @model.create :state =&gt; 'parked'
+          idling = @model.create :state =&gt; 'idling'
+          
+          assert_equal [parked], @model.with_state(:parked)
+        end
+        
+        def test_should_create_plural_with_scope
+          assert @model.respond_to?(:with_states)
+        end
+        
+        def test_should_only_include_records_with_states_in_plural_with_scope
+          parked = @model.create :state =&gt; 'parked'
+          idling = @model.create :state =&gt; 'idling'
+          
+          assert_equal [parked, idling], @model.with_states(:parked, :idling)
+        end
+        
+        def test_should_create_singular_without_scope
+          assert @model.respond_to?(:without_state)
+        end
+        
+        def test_should_only_include_records_without_state_in_singular_without_scope
+          parked = @model.create :state =&gt; 'parked'
+          idling = @model.create :state =&gt; 'idling'
+          
+          assert_equal [parked], @model.without_state(:idling)
+        end
+        
+        def test_should_create_plural_without_scope
+          assert @model.respond_to?(:without_states)
+        end
+        
+        def test_should_only_include_records_without_states_in_plural_without_scope
+          parked = @model.create :state =&gt; 'parked'
+          idling = @model.create :state =&gt; 'idling'
+          first_gear = @model.create :state =&gt; 'first_gear'
+          
+          assert_equal [parked, idling], @model.without_states(:first_gear)
+        end
+        
+        def test_should_allow_chaining_scopes
+          parked = @model.create :state =&gt; 'parked'
+          idling = @model.create :state =&gt; 'idling'
+          
+          assert_equal [idling], @model.without_state(:parked).with_state(:idling)
+        end
+      end
+      
+      class MachineWithScopesAndOwnerSubclassTest &lt; ActiveRecord::TestCase
+        def setup
+          @model = new_model
+          @machine = StateMachine::Machine.new(@model, :state)
+          
+          @subclass = Class.new(@model)
+          @subclass_machine = @subclass.state_machine(:state) {}
+          @subclass_machine.state :parked, :idling, :first_gear
+        end
+        
+        def test_should_only_include_records_with_subclass_states_in_with_scope
+          parked = @subclass.create :state =&gt; 'parked'
+          idling = @subclass.create :state =&gt; 'idling'
+          
+          assert_equal [parked, idling], @subclass.with_states(:parked, :idling)
+        end
+        
+        def test_should_only_include_records_without_subclass_states_in_without_scope
+          parked = @subclass.create :state =&gt; 'parked'
+          idling = @subclass.create :state =&gt; 'idling'
+          first_gear = @subclass.create :state =&gt; 'first_gear'
+          
+          assert_equal [parked, idling], @subclass.without_states(:first_gear)
+        end
+      end
+      
+      class MachineWithComplexPluralizationScopesTest &lt; ActiveRecord::TestCase
+        def setup
+          @model = new_model
+          @machine = StateMachine::Machine.new(@model, :status)
+        end
+        
+        def test_should_create_singular_with_scope
+          assert @model.respond_to?(:with_status)
+        end
+        
+        def test_should_create_plural_with_scope
+          assert @model.respond_to?(:with_statuses)
+        end
+      end
+    end
+    
     if Object.const_defined?(:I18n)
       class MachineWithInternationalizationTest &lt; ActiveRecord::TestCase
         def setup</diff>
      <filename>test/unit/integrations/active_record_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a6542258148d7e0540b546fe3e51af6019a37025</id>
    </parent>
  </parents>
  <author>
    <name>Chinasaur</name>
    <email>chinasaurli@gmail.com</email>
  </author>
  <url>http://github.com/pluginaweek/state_machine/commit/4d62cc1e86883841a67f49767b355972c01ddb91</url>
  <id>4d62cc1e86883841a67f49767b355972c01ddb91</id>
  <committed-date>2009-09-08T19:41:13-07:00</committed-date>
  <authored-date>2009-09-08T19:41:13-07:00</authored-date>
  <message>Add support for ActiveRecord 2.0.*</message>
  <tree>2b1f1e728e45eaeb1fc638445ac7fb30523683f8</tree>
  <committer>
    <name>Aaron Pfeifer</name>
    <email>aaron.pfeifer@gmail.com</email>
  </committer>
</commit>
