draftsman 0.3.1 → 0.3.2
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/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +9 -3
- data/README.md +1 -1
- data/bin/bundler +16 -0
- data/bin/erubis +16 -0
- data/bin/htmldiff +16 -0
- data/bin/ldiff +16 -0
- data/bin/nokogiri +16 -0
- data/bin/rackup +16 -0
- data/bin/rails +16 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/bin/thor +16 -0
- data/bin/tilt +16 -0
- data/draftsman.gemspec +2 -4
- data/lib/draftsman/draft.rb +13 -4
- data/lib/draftsman/frameworks/sinatra.rb +11 -6
- data/lib/draftsman/model.rb +12 -6
- data/lib/draftsman/version.rb +1 -1
- data/spec/controllers/informants_controller_spec.rb +28 -10
- data/spec/controllers/users_controller_spec.rb +16 -7
- data/spec/controllers/whodunnits_controller_spec.rb +16 -7
- data/spec/draftsman_spec.rb +12 -6
- data/spec/models/child_spec.rb +81 -39
- data/spec/models/draft_spec.rb +466 -135
- data/spec/models/parent_spec.rb +57 -28
- data/spec/models/skipper_spec.rb +195 -57
- data/spec/models/trashable_spec.rb +149 -50
- data/spec/models/vanilla_spec.rb +186 -59
- data/spec/models/whitelister_spec.rb +269 -90
- data/spec/spec_helper.rb +1 -6
- metadata +31 -38
- data/Gemfile.lock +0 -97
data/spec/models/parent_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe Parent do
|
|
4
4
|
let(:parent) { Parent.new(:name => 'Marge') }
|
5
5
|
let(:child) { Child.new(:name => 'Lisa', :parent => parent) }
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe 'publish!' do
|
8
8
|
context 'parent `create` draft with child `create` draft' do
|
9
9
|
before do
|
10
10
|
parent.draft_creation
|
@@ -13,24 +13,24 @@ describe Parent do
|
|
13
13
|
|
14
14
|
subject { parent.draft.publish! }
|
15
15
|
|
16
|
-
|
16
|
+
it 'publishes the parent' do
|
17
17
|
subject
|
18
|
-
parent.reload.
|
18
|
+
expect(parent.reload.published?).to eql true
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
it "removes the parent's draft" do
|
22
22
|
subject
|
23
|
-
parent.reload.
|
23
|
+
expect(parent.reload.draft?).to eql false
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
it 'keeps the child as a draft' do
|
27
27
|
subject
|
28
|
-
child.reload.
|
28
|
+
expect(child.reload.draft?).to eql true
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
it 'does not publish the child' do
|
32
32
|
subject
|
33
|
-
child.reload.
|
33
|
+
expect(child.reload.published?).to eql false
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'destroys 1 draft' do
|
@@ -65,7 +65,7 @@ describe Parent do
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
describe
|
68
|
+
describe 'revert!' do
|
69
69
|
context 'parent `create` draft with child `create` draft' do
|
70
70
|
before do
|
71
71
|
parent.draft_creation
|
@@ -100,9 +100,17 @@ describe Parent do
|
|
100
100
|
parent.reload
|
101
101
|
end
|
102
102
|
|
103
|
-
it
|
104
|
-
|
105
|
-
|
103
|
+
it 'is persisted to the database' do
|
104
|
+
expect(subject).to be_persisted
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'is no longer a draft' do
|
108
|
+
expect(subject.draft?).to eql false
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'is no longer trashed' do
|
112
|
+
expect(subject.trashed?).to eql false
|
113
|
+
end
|
106
114
|
|
107
115
|
it "keeps the child's draft" do
|
108
116
|
expect { subject }.to_not change(Draftsman::Draft.where(:item_type => 'Child'), :count)
|
@@ -112,24 +120,24 @@ describe Parent do
|
|
112
120
|
expect { subject }.to change(Draftsman::Draft.where(:item_type => 'Parent'), :count).by(-1)
|
113
121
|
end
|
114
122
|
|
115
|
-
|
123
|
+
it "keeps the child's draft" do
|
116
124
|
subject
|
117
|
-
child.
|
125
|
+
expect(child.draft?).to eql true
|
118
126
|
end
|
119
127
|
|
120
|
-
|
128
|
+
it "keeps the child as a `destroy` draft" do
|
121
129
|
subject
|
122
|
-
child.draft.reload.
|
130
|
+
expect(child.draft.reload.destroy?).to eql true
|
123
131
|
end
|
124
132
|
|
125
|
-
|
133
|
+
it 'keeps the child trashed' do
|
126
134
|
subject
|
127
|
-
child.
|
135
|
+
expect(child.trashed?).to eql true
|
128
136
|
end
|
129
137
|
end
|
130
138
|
end
|
131
139
|
|
132
|
-
describe
|
140
|
+
describe 'draft_publication_dependencies' do
|
133
141
|
context 'parent `create` draft with child `create` draft' do
|
134
142
|
before do
|
135
143
|
parent.draft_creation
|
@@ -137,7 +145,10 @@ describe Parent do
|
|
137
145
|
end
|
138
146
|
|
139
147
|
subject { parent.draft }
|
140
|
-
|
148
|
+
|
149
|
+
it 'does not have publication dependencies' do
|
150
|
+
expect(subject.draft_publication_dependencies).to be_empty
|
151
|
+
end
|
141
152
|
end
|
142
153
|
|
143
154
|
context 'parent `update` draft with child `create` draft' do
|
@@ -149,7 +160,10 @@ describe Parent do
|
|
149
160
|
end
|
150
161
|
|
151
162
|
subject { parent.draft }
|
152
|
-
|
163
|
+
|
164
|
+
it 'does not have publication dependencies' do
|
165
|
+
expect(subject.draft_publication_dependencies).to be_empty
|
166
|
+
end
|
153
167
|
end
|
154
168
|
|
155
169
|
context 'parent `destroy` draft with child `destroy` draft' do
|
@@ -160,12 +174,18 @@ describe Parent do
|
|
160
174
|
end
|
161
175
|
|
162
176
|
subject { parent.draft }
|
163
|
-
|
164
|
-
|
177
|
+
|
178
|
+
it 'has publication dependencies' do
|
179
|
+
expect(subject.draft_publication_dependencies).to be_present
|
180
|
+
end
|
181
|
+
|
182
|
+
it "has the child's draft as a publication dependency" do
|
183
|
+
expect(subject.draft_publication_dependencies).to include child.draft
|
184
|
+
end
|
165
185
|
end
|
166
186
|
end
|
167
187
|
|
168
|
-
describe
|
188
|
+
describe 'draft_reversion_dependencies' do
|
169
189
|
context 'parent `create` draft with child `create` draft' do
|
170
190
|
before do
|
171
191
|
parent.draft_creation
|
@@ -173,8 +193,14 @@ describe Parent do
|
|
173
193
|
end
|
174
194
|
|
175
195
|
subject { parent.draft }
|
176
|
-
|
177
|
-
|
196
|
+
|
197
|
+
it 'has reversion dependencies' do
|
198
|
+
expect(subject.draft_reversion_dependencies).to be_present
|
199
|
+
end
|
200
|
+
|
201
|
+
it "has the child's draft as a reversion dependency" do
|
202
|
+
expect(subject.draft_reversion_dependencies).to include child.draft
|
203
|
+
end
|
178
204
|
end
|
179
205
|
|
180
206
|
context 'parent `destroy` draft with child `destroy` draft' do
|
@@ -185,7 +211,10 @@ describe Parent do
|
|
185
211
|
end
|
186
212
|
|
187
213
|
subject { parent.draft }
|
188
|
-
|
214
|
+
|
215
|
+
it 'does not have reversion dependencies' do
|
216
|
+
expect(subject.draft_reversion_dependencies).to be_empty
|
217
|
+
end
|
189
218
|
end
|
190
219
|
end
|
191
220
|
end
|
data/spec/models/skipper_spec.rb
CHANGED
@@ -2,24 +2,47 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Skipper do
|
4
4
|
let(:skipper) { Skipper.new :name => 'Bob', :skip_me => 'Skipped 1' }
|
5
|
-
it { should be_draftable }
|
6
5
|
|
7
|
-
|
6
|
+
it 'is draftable' do
|
7
|
+
expect(subject.class.draftable?).to eql true
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'draft_creation' do
|
8
11
|
subject do
|
9
12
|
skipper.draft_creation
|
10
13
|
skipper.reload
|
11
14
|
end
|
12
15
|
|
13
|
-
it
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
it 'is persisted' do
|
17
|
+
expect(subject).to be_persisted
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'is a draft' do
|
21
|
+
expect(subject.draft?).to eql true
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'has a `draft_id`' do
|
25
|
+
expect(subject.draft_id).to be_present
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'has a draft' do
|
29
|
+
expect(subject.draft).to be_present
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'has a `create` draft' do
|
33
|
+
expect(subject.draft.create?).to eql true
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'has a `name`' do
|
37
|
+
expect(subject.name).to eql 'Bob'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'has a value for `skip_me`' do
|
41
|
+
expect(subject.skip_me).to eql 'Skipped 1'
|
42
|
+
end
|
20
43
|
end
|
21
44
|
|
22
|
-
describe
|
45
|
+
describe 'draft_update' do
|
23
46
|
subject do
|
24
47
|
skipper.draft_update
|
25
48
|
skipper.reload
|
@@ -32,13 +55,33 @@ describe Skipper do
|
|
32
55
|
skipper.skip_me = 'Skipped 2'
|
33
56
|
end
|
34
57
|
|
35
|
-
it
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
58
|
+
it 'is persisted' do
|
59
|
+
expect(subject).to be_persisted
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'is a draft' do
|
63
|
+
expect(subject.draft?).to eql true
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'has a `draft_id`' do
|
67
|
+
expect(subject.draft_id).to be_present
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'has a `draft`' do
|
71
|
+
expect(subject.draft).to be_present
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'identifies as an `update` draft' do
|
75
|
+
expect(subject.draft.update?).to eql true
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'has the original name' do
|
79
|
+
expect(subject.name).to eql 'Bob'
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'has the updated skipped attribute' do
|
83
|
+
expect(subject.skip_me).to eql 'Skipped 2'
|
84
|
+
end
|
42
85
|
|
43
86
|
it 'creates a new draft' do
|
44
87
|
expect { subject }.to change(Draftsman::Draft, :count).by(1)
|
@@ -56,11 +99,25 @@ describe Skipper do
|
|
56
99
|
skipper.skip_me = 'Skipped 2'
|
57
100
|
end
|
58
101
|
|
59
|
-
it
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
102
|
+
it 'is no longer a draft' do
|
103
|
+
expect(subject.draft?).to eql false
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'no longer has a `draft_id`' do
|
107
|
+
expect(subject.draft_id).to be_nil
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'no longer has a `draft`' do
|
111
|
+
expect(subject.draft).to be_nil
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'has its original `name`' do
|
115
|
+
expect(subject.name).to eql 'Bob'
|
116
|
+
end
|
117
|
+
|
118
|
+
it "retains the updated skipped attribute's value" do
|
119
|
+
expect(subject.skip_me).to eql 'Skipped 2'
|
120
|
+
end
|
64
121
|
|
65
122
|
it 'destroys the draft' do
|
66
123
|
expect { subject }.to change(Draftsman::Draft.where(:id => skipper.draft_id), :count).by(-1)
|
@@ -76,31 +133,71 @@ describe Skipper do
|
|
76
133
|
skipper.skip_me = 'Skipped 2'
|
77
134
|
end
|
78
135
|
|
79
|
-
it
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
136
|
+
it 'is persisted' do
|
137
|
+
expect(subject).to be_persisted
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'is a draft' do
|
141
|
+
expect(subject.draft?).to eql true
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'has a `draft_id`' do
|
145
|
+
expect(subject.draft_id).to be_present
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'has a `draft`' do
|
149
|
+
expect(subject.draft).to be_present
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'has a `create` draft' do
|
153
|
+
expect(subject.draft.create?).to eql true
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'has the updated `name`' do
|
157
|
+
expect(subject.name).to eql 'Sam'
|
158
|
+
end
|
159
|
+
|
160
|
+
it "retains the updated skipped attribute's value" do
|
161
|
+
expect(subject.skip_me).to eql 'Skipped 2'
|
162
|
+
end
|
86
163
|
|
87
164
|
it 'updates the existing draft' do
|
88
165
|
expect { subject }.to_not change(Draftsman::Draft.where(:id => skipper.draft_id), :count)
|
89
166
|
end
|
90
167
|
|
91
|
-
|
92
|
-
subject.draft.reify.name.
|
168
|
+
it "updates the draft's `name`" do
|
169
|
+
expect(subject.draft.reify.name).to eql 'Sam'
|
93
170
|
end
|
94
171
|
end
|
95
172
|
|
96
173
|
context 'with no changes' do
|
97
|
-
it
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
174
|
+
it 'is persisted' do
|
175
|
+
expect(subject).to be_persisted
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'is a draft' do
|
179
|
+
expect(subject.draft?).to eql true
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'has a `draft_id`' do
|
183
|
+
expect(subject.draft_id).to be_present
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'has a `draft`' do
|
187
|
+
expect(subject.draft).to be_present
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'has a `create` draft' do
|
191
|
+
expect(subject.draft.create?).to eql true
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'has the original `name`' do
|
195
|
+
expect(subject.name).to eql 'Bob'
|
196
|
+
end
|
197
|
+
|
198
|
+
it "has the original skipped attribute's value" do
|
199
|
+
expect(subject.skip_me).to eql 'Skipped 1'
|
200
|
+
end
|
104
201
|
|
105
202
|
it "doesn't change the number of drafts" do
|
106
203
|
expect { subject }.to_not change(Draftsman::Draft.where(:id => skipper.draft_id), :count)
|
@@ -120,45 +217,86 @@ describe Skipper do
|
|
120
217
|
|
121
218
|
context 'with changes' do
|
122
219
|
before { skipper.name = 'Steve' }
|
123
|
-
|
124
|
-
it
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
220
|
+
|
221
|
+
it 'is persisted' do
|
222
|
+
expect(subject).to be_persisted
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'is a draft' do
|
226
|
+
expect(subject.draft?).to eql true
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'has a `draft_id`' do
|
230
|
+
expect(subject.draft_id).to be_present
|
231
|
+
end
|
232
|
+
|
233
|
+
it 'has a `draft`' do
|
234
|
+
expect(subject.draft).to be_present
|
235
|
+
end
|
236
|
+
|
237
|
+
it 'has an `update` draft' do
|
238
|
+
expect(subject.draft.update?).to eql true
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'has the original `name`' do
|
242
|
+
expect(subject.name).to eql 'Bob'
|
243
|
+
end
|
244
|
+
|
245
|
+
it "has the updated skipped attribute's value" do
|
246
|
+
expect(subject.skip_me).to eql 'Skipped 2'
|
247
|
+
end
|
130
248
|
|
131
249
|
it 'updates the existing draft' do
|
132
250
|
expect { subject }.to_not change(Draftsman::Draft.where(:id => skipper.draft_id), :count)
|
133
251
|
end
|
134
252
|
|
135
|
-
|
136
|
-
subject.draft.reify.name.
|
253
|
+
it "updates the draft's `name`" do
|
254
|
+
expect(subject.draft.reify.name).to eql 'Steve'
|
137
255
|
end
|
138
256
|
end
|
139
257
|
|
140
258
|
context 'with no changes' do
|
141
|
-
it
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
259
|
+
it 'is persisted' do
|
260
|
+
expect(subject).to be_persisted
|
261
|
+
end
|
262
|
+
|
263
|
+
it 'is a draft' do
|
264
|
+
expect(subject.draft?).to eql true
|
265
|
+
end
|
266
|
+
|
267
|
+
it 'has a `draft_id`' do
|
268
|
+
expect(subject.draft_id).to be_present
|
269
|
+
end
|
270
|
+
|
271
|
+
it 'has a `draft`' do
|
272
|
+
expect(subject.draft).to be_present
|
273
|
+
end
|
274
|
+
|
275
|
+
it 'has an `update` draft' do
|
276
|
+
expect(subject.draft.update?).to eql true
|
277
|
+
end
|
278
|
+
|
279
|
+
it 'has the original `name`' do
|
280
|
+
expect(subject.name).to eql 'Bob'
|
281
|
+
end
|
282
|
+
|
283
|
+
it "has the updated skipped attributes' value" do
|
284
|
+
expect(subject.skip_me).to eql 'Skipped 2'
|
285
|
+
end
|
148
286
|
|
149
287
|
it "doesn't change the number of drafts" do
|
150
288
|
expect { subject }.to_not change(Draftsman::Draft.where(:id => skipper.draft_id), :count)
|
151
289
|
end
|
152
290
|
|
153
|
-
|
154
|
-
subject.draft.reify.name.
|
291
|
+
it "does not update the draft's `name`" do
|
292
|
+
expect(subject.draft.reify.name).to eql 'Sam'
|
155
293
|
end
|
156
294
|
end
|
157
295
|
end
|
158
296
|
end
|
159
297
|
|
160
298
|
# Not applicable to this customization
|
161
|
-
describe
|
299
|
+
describe 'draft_destroy' do
|
162
300
|
end
|
163
301
|
|
164
302
|
# Not applicable to this customization
|