draftsman 0.3.7 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/README.md +61 -13
- data/draftsman.gemspec +3 -3
- data/lib/draftsman/model.rb +147 -122
- data/lib/draftsman/version.rb +1 -1
- data/lib/generators/draftsman/templates/create_drafts.rb +1 -1
- data/lib/generators/draftsman/templates/create_drafts_json.rb +1 -1
- data/spec/dummy/app/controllers/application_controller.rb +1 -1
- data/spec/dummy/app/models/enumable.rb +4 -0
- data/spec/dummy/app/models/talkative.rb +66 -0
- data/spec/dummy/config/environments/development.rb +1 -1
- data/spec/dummy/db/migrate/20150404203627_add_talkatives_table_to_tests.rb +18 -0
- data/spec/dummy/db/migrate/20160328184419_create_enumables.rb +9 -0
- data/spec/dummy/db/schema.rb +28 -11
- data/spec/models/child_spec.rb +6 -6
- data/spec/models/draft_spec.rb +9 -9
- data/spec/models/enumable_spec.rb +14 -0
- data/spec/models/parent_spec.rb +6 -6
- data/spec/models/skipper_spec.rb +1 -1
- data/spec/models/talkative_spec.rb +224 -0
- data/spec/models/trashable_spec.rb +17 -15
- data/spec/models/vanilla_spec.rb +1 -1
- data/spec/models/whitelister_spec.rb +1 -1
- metadata +21 -10
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,10 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
15
|
-
|
16
|
-
# These are extensions that must be enabled in order to support this database
|
17
|
-
enable_extension "plpgsql"
|
14
|
+
ActiveRecord::Schema.define(version: 20160328184419) do
|
18
15
|
|
19
16
|
create_table "bastards", force: :cascade do |t|
|
20
17
|
t.string "name"
|
@@ -56,6 +53,21 @@ ActiveRecord::Schema.define(version: 20150408234937) do
|
|
56
53
|
t.string "user_agent"
|
57
54
|
end
|
58
55
|
|
56
|
+
create_table "enumables", force: :cascade do |t|
|
57
|
+
t.integer "status", null: false
|
58
|
+
t.integer "draft_id"
|
59
|
+
t.datetime "published_at"
|
60
|
+
end
|
61
|
+
|
62
|
+
create_table "moneybags", force: :cascade do |t|
|
63
|
+
t.integer "price_cents", default: 0, null: false
|
64
|
+
t.string "price_currency", default: "USD", null: false
|
65
|
+
t.integer "draft_id"
|
66
|
+
t.datetime "published_at"
|
67
|
+
t.datetime "created_at", null: false
|
68
|
+
t.datetime "updated_at", null: false
|
69
|
+
end
|
70
|
+
|
59
71
|
create_table "only_children", force: :cascade do |t|
|
60
72
|
t.string "name"
|
61
73
|
t.integer "parent_id"
|
@@ -85,6 +97,18 @@ ActiveRecord::Schema.define(version: 20150408234937) do
|
|
85
97
|
t.datetime "updated_at"
|
86
98
|
end
|
87
99
|
|
100
|
+
create_table "talkatives", force: :cascade do |t|
|
101
|
+
t.string "before_comment"
|
102
|
+
t.string "around_early_comment"
|
103
|
+
t.string "around_late_comment"
|
104
|
+
t.string "after_comment"
|
105
|
+
t.integer "draft_id"
|
106
|
+
t.datetime "trashed_at"
|
107
|
+
t.datetime "published_at"
|
108
|
+
t.datetime "created_at"
|
109
|
+
t.datetime "updated_at"
|
110
|
+
end
|
111
|
+
|
88
112
|
create_table "trashables", force: :cascade do |t|
|
89
113
|
t.string "name"
|
90
114
|
t.string "title"
|
@@ -112,11 +136,4 @@ ActiveRecord::Schema.define(version: 20150408234937) do
|
|
112
136
|
t.datetime "updated_at"
|
113
137
|
end
|
114
138
|
|
115
|
-
add_foreign_key "children", "drafts"
|
116
|
-
add_foreign_key "only_children", "drafts"
|
117
|
-
add_foreign_key "parents", "drafts"
|
118
|
-
add_foreign_key "skippers", "drafts"
|
119
|
-
add_foreign_key "trashables", "drafts"
|
120
|
-
add_foreign_key "vanillas", "drafts"
|
121
|
-
add_foreign_key "whitelisters", "drafts"
|
122
139
|
end
|
data/spec/models/child_spec.rb
CHANGED
@@ -50,8 +50,8 @@ describe Child, :type => :model do
|
|
50
50
|
before do
|
51
51
|
parent.save!
|
52
52
|
child.save!
|
53
|
-
child.
|
54
|
-
parent.
|
53
|
+
child.draft_destruction
|
54
|
+
parent.draft_destruction
|
55
55
|
end
|
56
56
|
|
57
57
|
subject { child.draft.publish! }
|
@@ -104,8 +104,8 @@ describe Child, :type => :model do
|
|
104
104
|
before do
|
105
105
|
parent.save!
|
106
106
|
child.save!
|
107
|
-
child.
|
108
|
-
parent.
|
107
|
+
child.draft_destruction
|
108
|
+
parent.draft_destruction
|
109
109
|
end
|
110
110
|
|
111
111
|
subject do
|
@@ -216,7 +216,7 @@ describe Child, :type => :model do
|
|
216
216
|
context 'parent `destroy` draft with child `destroy` draft' do
|
217
217
|
before do
|
218
218
|
child.save!
|
219
|
-
parent.
|
219
|
+
parent.draft_destruction
|
220
220
|
child.reload
|
221
221
|
end
|
222
222
|
|
@@ -245,7 +245,7 @@ describe Child, :type => :model do
|
|
245
245
|
context 'parent `destroy` draft with child `destroy` draft' do
|
246
246
|
before do
|
247
247
|
child.save!
|
248
|
-
parent.
|
248
|
+
parent.draft_destruction
|
249
249
|
child.reload
|
250
250
|
end
|
251
251
|
|
data/spec/models/draft_spec.rb
CHANGED
@@ -229,7 +229,7 @@ describe Draftsman::Draft do
|
|
229
229
|
context 'without previous draft' do
|
230
230
|
before do
|
231
231
|
trashable.save!
|
232
|
-
trashable.
|
232
|
+
trashable.draft_destruction
|
233
233
|
end
|
234
234
|
|
235
235
|
it 'does not identify as a `create` event' do
|
@@ -268,7 +268,7 @@ describe Draftsman::Draft do
|
|
268
268
|
context 'with previous `create` draft' do
|
269
269
|
before do
|
270
270
|
trashable.draft_creation
|
271
|
-
trashable.
|
271
|
+
trashable.draft_destruction
|
272
272
|
end
|
273
273
|
|
274
274
|
it 'does not identify as a `create` event' do
|
@@ -422,7 +422,7 @@ describe Draftsman::Draft do
|
|
422
422
|
context 'without previous draft' do
|
423
423
|
before do
|
424
424
|
trashable.save!
|
425
|
-
trashable.
|
425
|
+
trashable.draft_destruction
|
426
426
|
end
|
427
427
|
|
428
428
|
subject { trashable.draft.publish! }
|
@@ -439,7 +439,7 @@ describe Draftsman::Draft do
|
|
439
439
|
context 'with previous `create` draft' do
|
440
440
|
before do
|
441
441
|
trashable.draft_creation
|
442
|
-
trashable.
|
442
|
+
trashable.draft_destruction
|
443
443
|
end
|
444
444
|
|
445
445
|
subject { trashable.draft.publish! }
|
@@ -515,7 +515,7 @@ describe Draftsman::Draft do
|
|
515
515
|
context 'without previous draft' do
|
516
516
|
before do
|
517
517
|
trashable.save!
|
518
|
-
trashable.
|
518
|
+
trashable.draft_destruction
|
519
519
|
end
|
520
520
|
|
521
521
|
subject { trashable.draft.revert!; return trashable.reload }
|
@@ -556,7 +556,7 @@ describe Draftsman::Draft do
|
|
556
556
|
context 'with previous `create` draft' do
|
557
557
|
before do
|
558
558
|
trashable.draft_creation
|
559
|
-
trashable.
|
559
|
+
trashable.draft_destruction
|
560
560
|
end
|
561
561
|
|
562
562
|
subject { trashable.draft.revert!; return trashable.reload }
|
@@ -666,7 +666,7 @@ describe Draftsman::Draft do
|
|
666
666
|
context 'without previous draft' do
|
667
667
|
before do
|
668
668
|
trashable.save!
|
669
|
-
trashable.
|
669
|
+
trashable.draft_destruction
|
670
670
|
end
|
671
671
|
|
672
672
|
it 'records the `name`' do
|
@@ -681,7 +681,7 @@ describe Draftsman::Draft do
|
|
681
681
|
context 'with previous `create` draft' do
|
682
682
|
before do
|
683
683
|
trashable.draft_creation
|
684
|
-
trashable.
|
684
|
+
trashable.draft_destruction
|
685
685
|
end
|
686
686
|
|
687
687
|
it 'records the `name`' do
|
@@ -700,7 +700,7 @@ describe Draftsman::Draft do
|
|
700
700
|
trashable.title = 'My Title'
|
701
701
|
trashable.draft_update
|
702
702
|
# Typically, 2 draft operations won't happen in the same request, so reload before draft-destroying.
|
703
|
-
trashable.reload.
|
703
|
+
trashable.reload.draft_destruction
|
704
704
|
end
|
705
705
|
|
706
706
|
it 'records the updated `name`' do
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Enumable, :type => :model do
|
4
|
+
let(:enumable) { Enumable.new(status: :active) }
|
5
|
+
describe '#draft' do
|
6
|
+
describe '#reify' do
|
7
|
+
before { enumable.draft_creation }
|
8
|
+
|
9
|
+
it 'does not raise an exception' do
|
10
|
+
expect { enumable.draft.reify }.to_not raise_error
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/spec/models/parent_spec.rb
CHANGED
@@ -45,8 +45,8 @@ describe Parent do
|
|
45
45
|
context 'parent `destroy` draft with child `destroy` draft' do
|
46
46
|
before do
|
47
47
|
child.save!
|
48
|
-
child.
|
49
|
-
parent.
|
48
|
+
child.draft_destruction
|
49
|
+
parent.draft_destruction
|
50
50
|
end
|
51
51
|
|
52
52
|
subject { parent.draft.publish! }
|
@@ -90,8 +90,8 @@ describe Parent do
|
|
90
90
|
context 'parent `destroy` draft with child `destroy` draft' do
|
91
91
|
before do
|
92
92
|
child.save!
|
93
|
-
child.
|
94
|
-
parent.
|
93
|
+
child.draft_destruction
|
94
|
+
parent.draft_destruction
|
95
95
|
end
|
96
96
|
|
97
97
|
subject do
|
@@ -169,7 +169,7 @@ describe Parent do
|
|
169
169
|
context 'parent `destroy` draft with child `destroy` draft' do
|
170
170
|
before do
|
171
171
|
child.save!
|
172
|
-
parent.
|
172
|
+
parent.draft_destruction
|
173
173
|
child.reload
|
174
174
|
end
|
175
175
|
|
@@ -206,7 +206,7 @@ describe Parent do
|
|
206
206
|
context 'parent `destroy` draft with child `destroy` draft' do
|
207
207
|
before do
|
208
208
|
child.save!
|
209
|
-
parent.
|
209
|
+
parent.draft_destruction
|
210
210
|
child.reload
|
211
211
|
end
|
212
212
|
|
data/spec/models/skipper_spec.rb
CHANGED
@@ -0,0 +1,224 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# A Talkative has a call to `has_drafts` and all nine callbacks defined:
|
4
|
+
#
|
5
|
+
# - `before_draft_creation`
|
6
|
+
# - `around_draft_creation`
|
7
|
+
# - `after_draft_creation`
|
8
|
+
# - `before_draft_update`
|
9
|
+
# - `around_draft_update`
|
10
|
+
# - `after_draft_update`
|
11
|
+
# - `before_draft_destruction`
|
12
|
+
# - `around_draft_destruction`
|
13
|
+
# - `after_draft_destruction`
|
14
|
+
RSpec.describe Talkative do
|
15
|
+
let(:talkative) { subject }
|
16
|
+
|
17
|
+
describe '.draftable?' do
|
18
|
+
it 'is draftable' do
|
19
|
+
expect(talkative.class.draftable?).to eql true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#draft_creation' do
|
24
|
+
before { talkative.draft_creation }
|
25
|
+
|
26
|
+
describe '`before_draft_creation` callback' do
|
27
|
+
it 'changes `before_comment` attribute' do
|
28
|
+
expect(talkative.before_comment).to eql "I changed before creation"
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'persists updated `before_comment` attribute to draft' do
|
32
|
+
talkative.reload
|
33
|
+
expect(talkative.draft.reify.before_comment).to eql "I changed before creation"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'around_draft_creation callback' do
|
38
|
+
it 'changes `around_early_comment` attribute (before yield)' do
|
39
|
+
expect(talkative.around_early_comment).to eql "I changed around creation (before yield)"
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'persists updated `around_early_comment` attribute to draft' do
|
43
|
+
talkative.reload
|
44
|
+
expect(talkative.draft.reify.around_late_comment).to be_nil
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'changes `around_late_comment` attribute (after yield)' do
|
48
|
+
expect(talkative.around_late_comment).to eql "I changed around creation (after yield)"
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'does not persist updated `around_late_comment` attribute' do
|
52
|
+
talkative.reload
|
53
|
+
expect(talkative.around_late_comment).to be_nil
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'does not persist updated `around_late_comment` attribute to draft' do
|
57
|
+
talkative.reload
|
58
|
+
expect(talkative.draft.reify.around_late_comment).to be_nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '`after_draft_creation` callback' do
|
63
|
+
it 'changes `after_comment` attribute' do
|
64
|
+
expect(talkative.after_comment).to eql "I changed after creation"
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'does not persist updated `after_comment` attribute' do
|
68
|
+
talkative.reload
|
69
|
+
expect(talkative.after_comment).to be_nil
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'does not persist updated `after_comment` attribute to draft' do
|
73
|
+
talkative.reload
|
74
|
+
expect(talkative.draft.reify.after_comment).to be_nil
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#draft_update' do
|
80
|
+
before do
|
81
|
+
talkative.draft_creation
|
82
|
+
talkative.draft_update
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '`before_draft_update` callback' do
|
86
|
+
it 'changes `before_comment` attribute' do
|
87
|
+
expect(talkative.before_comment).to eql "I changed before update"
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'persists updated `before_comment` attribute to draft' do
|
91
|
+
talkative.reload
|
92
|
+
expect(talkative.draft.reify.before_comment).to eql "I changed before update"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '`around_draft_update` callback' do
|
97
|
+
it 'changes `around_early_comment` attribute (before yield)' do
|
98
|
+
expect(talkative.around_early_comment).to eql "I changed around update (before yield)"
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'persists updated `around_early_comment` attribute' do
|
102
|
+
talkative.reload
|
103
|
+
expect(talkative.around_early_comment).to eql "I changed around update (before yield)"
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'persists updated `around_early_comment` attribute to draft' do
|
107
|
+
talkative.reload
|
108
|
+
expect(talkative.draft.reify.around_early_comment).to eql "I changed around update (before yield)"
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'changes `around_late_comment` attribute (after yield)' do
|
112
|
+
expect(talkative.around_late_comment).to eql "I changed around update (after yield)"
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'does not persist updated `around_late_comment` attribute' do
|
116
|
+
talkative.reload
|
117
|
+
expect(talkative.around_late_comment).to eql 'I changed around creation (after yield)'
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'does not persist updated `around_late_comment` attribute to draft' do
|
121
|
+
talkative.reload
|
122
|
+
expect(talkative.draft.reify.around_late_comment).to eql 'I changed around creation (after yield)'
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe 'after callback' do
|
127
|
+
it 'changes `after_comment` attribute' do
|
128
|
+
expect(talkative.after_comment).to eql "I changed after update"
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'does not persist updated `after_comment` attribute' do
|
132
|
+
talkative.reload
|
133
|
+
expect(talkative.after_comment).to eql 'I changed after creation'
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'does not persist updated `after_comment` attribute to draft' do
|
137
|
+
talkative.reload
|
138
|
+
expect(talkative.draft.reify.after_comment).to eql 'I changed after creation'
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe '#draft_destruction' do
|
144
|
+
before do
|
145
|
+
talkative.draft_creation
|
146
|
+
talkative.draft_destruction
|
147
|
+
end
|
148
|
+
|
149
|
+
describe '`before_draft_destruction` callback' do
|
150
|
+
it 'changes `before_comment` attribute' do
|
151
|
+
expect(talkative.before_comment).to eql "I changed before destroy"
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'does not persist updated `before_comment` attribute' do
|
155
|
+
talkative.reload
|
156
|
+
expect(talkative.before_comment).to eql "I changed before creation"
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'does not persist updated `before_comment` attribute to draft' do
|
160
|
+
talkative.reload
|
161
|
+
expect(talkative.draft.reify.before_comment).to eql "I changed before creation"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe '`around_draft_destruction` callback' do
|
166
|
+
it 'changes `around_early_comment` attribute (before yield)' do
|
167
|
+
expect(talkative.around_early_comment).to eql "I changed around destroy (before yield)"
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'does not persist `around_early_comment` attribute (before yield)' do
|
171
|
+
expect(talkative.around_early_comment).to eql "I changed around destroy (before yield)"
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'does not persist updated `around_early_comment` attribute to draft' do
|
175
|
+
talkative.reload
|
176
|
+
expect(talkative.draft.reify.around_early_comment).to eql "I changed around creation (before yield)"
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'changes `around_late_comment` attribute (after yield)' do
|
180
|
+
expect(talkative.around_late_comment).to eql "I changed around destroy (after yield)"
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'does not persist updated `around_late_comment` attribute' do
|
184
|
+
talkative.reload
|
185
|
+
expect(talkative.around_late_comment).to be_nil
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'does not persist updated `around_late_comment` attribute to draft' do
|
189
|
+
talkative.reload
|
190
|
+
expect(talkative.draft.reify.around_late_comment).to be_nil
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
describe '`after_draft_destruction` callback' do
|
195
|
+
it 'changes `before_comment` attribute' do
|
196
|
+
expect(talkative.before_comment).to eql "I changed before destroy"
|
197
|
+
end
|
198
|
+
|
199
|
+
it 'does not persist updated `before_comment` attribute' do
|
200
|
+
talkative.reload
|
201
|
+
expect(talkative.before_comment).to eql 'I changed before creation'
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'does not persist updated `before_comment` attribute to draft' do
|
205
|
+
talkative.reload
|
206
|
+
expect(talkative.draft.reify.before_comment).to eql 'I changed before creation'
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'changes `after_comment` attribute' do
|
210
|
+
expect(talkative.after_comment).to eql "I changed after destroy"
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'does not persist updated `after_comment` attribute' do
|
214
|
+
talkative.reload
|
215
|
+
expect(talkative.after_comment).to be_nil
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'does not persist updated `after_comment` attribute to draft' do
|
219
|
+
talkative.reload
|
220
|
+
expect(talkative.draft.reify.after_comment).to be_nil
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
@@ -5,22 +5,24 @@ require 'spec_helper'
|
|
5
5
|
describe Trashable do
|
6
6
|
let(:trashable) { Trashable.new :name => 'Bob' }
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
describe '.draftable?' do
|
9
|
+
it 'is draftable' do
|
10
|
+
expect(subject.class.draftable?).to eql true
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
12
14
|
# Not affected by this customization
|
13
|
-
describe 'draft_creation' do
|
15
|
+
describe '#draft_creation' do
|
14
16
|
end
|
15
17
|
|
16
18
|
# Not affected by this customization
|
17
|
-
describe 'draft_update' do
|
19
|
+
describe '#draft_update' do
|
18
20
|
end
|
19
21
|
|
20
|
-
describe '
|
22
|
+
describe '#draft_destruction' do
|
21
23
|
context 'with `:create` draft' do
|
22
24
|
before { trashable.draft_creation }
|
23
|
-
subject { trashable.
|
25
|
+
subject { trashable.draft_destruction; return trashable }
|
24
26
|
|
25
27
|
it 'is persisted' do
|
26
28
|
expect(subject).to be_persisted
|
@@ -84,7 +86,7 @@ describe Trashable do
|
|
84
86
|
trashable.draft_update
|
85
87
|
end
|
86
88
|
|
87
|
-
subject { trashable.
|
89
|
+
subject { trashable.draft_destruction; return trashable.reload }
|
88
90
|
|
89
91
|
it 'is persisted' do
|
90
92
|
expect(subject).to be_persisted
|
@@ -145,8 +147,8 @@ describe Trashable do
|
|
145
147
|
trashable.update_attributes! :published_at => Time.now
|
146
148
|
end
|
147
149
|
|
148
|
-
subject { trashable.
|
149
|
-
|
150
|
+
subject { trashable.draft_destruction; return trashable.reload }
|
151
|
+
|
150
152
|
it 'is persisted' do
|
151
153
|
expect(subject).to be_persisted
|
152
154
|
end
|
@@ -203,11 +205,11 @@ describe Trashable do
|
|
203
205
|
let!(:trashed_trashable) { Trashable.create :name => 'Ralph' }
|
204
206
|
|
205
207
|
# Not affected by this customization
|
206
|
-
describe 'drafted' do
|
208
|
+
describe '.drafted' do
|
207
209
|
end
|
208
210
|
|
209
|
-
describe 'live' do
|
210
|
-
before { trashed_trashable.
|
211
|
+
describe '.live' do
|
212
|
+
before { trashed_trashable.draft_destruction }
|
211
213
|
subject { Trashable.live }
|
212
214
|
|
213
215
|
it 'returns 2 records' do
|
@@ -232,11 +234,11 @@ describe Trashable do
|
|
232
234
|
end
|
233
235
|
|
234
236
|
# Not affected by this customization
|
235
|
-
describe 'published' do
|
237
|
+
describe '.published' do
|
236
238
|
end
|
237
239
|
|
238
|
-
describe 'trashed' do
|
239
|
-
before { trashed_trashable.
|
240
|
+
describe '.trashed' do
|
241
|
+
before { trashed_trashable.draft_destruction }
|
240
242
|
subject { Trashable.trashed }
|
241
243
|
|
242
244
|
it 'returns 1 record' do
|
data/spec/models/vanilla_spec.rb
CHANGED