<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -22,7 +22,7 @@ module AASM
 
   module ClassMethods
     def inherited(klass)
-      AASM::StateMachine[klass] = AASM::StateMachine[self].dup
+      AASM::StateMachine[klass] = AASM::StateMachine[self].clone
       super
     end
 </diff>
      <filename>lib/aasm.rb</filename>
    </modified>
    <modified>
      <diff>@@ -22,6 +22,12 @@ module AASM
       @config = OpenStruct.new
     end
 
+    def clone
+      klone = super
+      klone.states = states.clone
+      klone
+    end
+
     def create_state(name, options)
       @states &lt;&lt; AASM::SupportingClasses::State.new(name, options) unless @states.include?(name)
     end</diff>
      <filename>lib/state_machine.rb</filename>
    </modified>
    <modified>
      <diff>@@ -70,12 +70,21 @@ describe AASM, '- class level definitions' do
 end
 
 
-describe AASM, '- when included' do
-  it 'should invoke the original inherited callback when subclassed' do
-    parent = Class.new
-    parent.should_receive(:inherited)
-    parent.send(:include, AASM)
-    child = Class.new(parent)
+describe AASM, '- subclassing' do
+  before(:each) do
+    @parent = Class.new do
+      include AASM
+    end
+  end
+
+  it 'should invoke the original inherited callback' do
+    @parent.should_receive(:inherited)
+    Class.new(@parent)
+  end
+
+  it 'should have a unique states hash' do
+    child = Class.new(@parent)
+    child.aasm_states.equal?(@parent.aasm_states).should be_false
   end
 end
 </diff>
      <filename>spec/unit/aasm_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>fee9487e0d5464fc328f1c9c91eb059fef75988e</id>
    </parent>
  </parents>
  <author>
    <name>Tim Pope</name>
    <email>code@tpope.net</email>
  </author>
  <url>http://github.com/eric/aasm/commit/d59dbbf6b0db2f07a4f0175f6de46aef832ecba5</url>
  <id>d59dbbf6b0db2f07a4f0175f6de46aef832ecba5</id>
  <committed-date>2008-11-05T08:06:36-08:00</committed-date>
  <authored-date>2008-11-05T08:06:36-08:00</authored-date>
  <message>Allow duplicate state names in subclasses

When an AASM including class is subclassed, a shallow copy is made of
the StateMachine object.  This means that all subclasses share the same
states hash and thus the same set of states, which prevents (among other
things) different subclasses from using the same state names.

Give StateMachine a smart #clone method that copies the states hash and
invoke that rather than #dup upon subclassing.</message>
  <tree>3c1f3441bb77e3bde75ee2d17fa665138c71b164</tree>
  <committer>
    <name>Tim Pope</name>
    <email>code@tpope.net</email>
  </committer>
</commit>
