55    class  self ::DefaultRandom  < ActiveRecord ::Base 
66      stampable 
77    end 
8+ 
89    subject  {  self . class ::DefaultRandom . new  } 
910
1011    temporary_table ( :default_randoms )  do  |t |
11-       t . userstamps ( null : false ) 
12+       t . userstamps ( ** { null : false } ) 
1213    end 
1314
1415    with_temporary_table ( :default_randoms )  do 
@@ -30,22 +31,14 @@ class self::DefaultRandom < ActiveRecord::Base
3031  end 
3132
3233  context  'when overridden attribute names are used'  do 
33-     before ( :each )  do 
34-       ActiveRecord ::Userstamp . configure  do  |config |
35-         config . creator_attribute  =  :created_by 
36-         config . updater_attribute  =  :updated_by 
37-         config . deleter_attribute  =  :deleted_by 
38-       end 
39-       class  self . class ::OverriddenRandom  < ActiveRecord ::Base 
40-         stampable 
41-       end 
34+     ActiveRecord ::Userstamp . configure  do  |config |
35+       config . creator_attribute  =  :created_by 
36+       config . updater_attribute  =  :updated_by 
37+       config . deleter_attribute  =  :deleted_by 
4238    end 
43-     after ( :each )  do 
44-       ActiveRecord ::Userstamp . configure  do  |config |
45-         config . creator_attribute  =  :creator_id 
46-         config . updater_attribute  =  :updater_id 
47-         config . deleter_attribute  =  :deleter_id 
48-       end 
39+ 
40+     class  self ::OverriddenRandom  < ActiveRecord ::Base 
41+       stampable 
4942    end 
5043
5144    subject  {  self . class ::OverriddenRandom . new  } 
@@ -54,7 +47,15 @@ class self.class::OverriddenRandom < ActiveRecord::Base
5447      t . userstamps 
5548    end 
5649
57-     with_temporary_table ( :overridden_randoms ,  :each )  do 
50+     after  do 
51+       ActiveRecord ::Userstamp . configure  do  |config |
52+         config . creator_attribute  =  :creator_id 
53+         config . updater_attribute  =  :updater_id 
54+         config . deleter_attribute  =  :deleter_id 
55+       end 
56+     end 
57+ 
58+     with_temporary_table ( :overridden_randoms ,  :all )  do 
5859      it  'has a created_by attribute'  do 
5960        expect ( subject . has_attribute? ( :created_by ) ) . to  be  true 
6061      end 
0 commit comments