5
5
class self ::DefaultRandom < ActiveRecord ::Base
6
6
stampable
7
7
end
8
+
8
9
subject { self . class ::DefaultRandom . new }
9
10
10
11
temporary_table ( :default_randoms ) do |t |
11
- t . userstamps ( null : false )
12
+ t . userstamps ( ** { null : false } )
12
13
end
13
14
14
15
with_temporary_table ( :default_randoms ) do
@@ -30,22 +31,14 @@ class self::DefaultRandom < ActiveRecord::Base
30
31
end
31
32
32
33
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
42
38
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
49
42
end
50
43
51
44
subject { self . class ::OverriddenRandom . new }
@@ -54,7 +47,15 @@ class self.class::OverriddenRandom < ActiveRecord::Base
54
47
t . userstamps
55
48
end
56
49
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
58
59
it 'has a created_by attribute' do
59
60
expect ( subject . has_attribute? ( :created_by ) ) . to be true
60
61
end
0 commit comments