draftsman 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- 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/child_spec.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Child do
|
3
|
+
describe Child, :type => :model 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,27 +13,27 @@ describe Child do
|
|
13
13
|
|
14
14
|
subject { child.draft.publish! }
|
15
15
|
|
16
|
-
|
16
|
+
it "destroys the child's draft" do
|
17
17
|
subject
|
18
|
-
child.reload.
|
18
|
+
expect(child.reload).to_not be_draft
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
it 'publishes the child' do
|
22
22
|
subject
|
23
|
-
child.reload.
|
23
|
+
expect(child.reload).to be_published
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
it 'publishes the parent' do
|
27
27
|
subject
|
28
|
-
parent.reload.
|
28
|
+
expect(parent.reload).to be_published
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
it "destroys the parent's draft" do
|
32
32
|
subject
|
33
|
-
parent.reload.
|
33
|
+
expect(parent.reload).to_not be_draft
|
34
34
|
end
|
35
35
|
|
36
|
-
it 'destroys
|
36
|
+
it 'destroys 2 drafts overall' do
|
37
37
|
expect { subject }.to change(Draftsman::Draft, :count).by(-2)
|
38
38
|
end
|
39
39
|
|
@@ -64,7 +64,7 @@ describe Child do
|
|
64
64
|
expect { subject }.to_not change(Parent, :count)
|
65
65
|
end
|
66
66
|
|
67
|
-
it 'destroys 1 draft' do
|
67
|
+
it 'destroys 1 draft overall' do
|
68
68
|
expect { subject }.to change(Draftsman::Draft, :count).by(-1)
|
69
69
|
end
|
70
70
|
|
@@ -74,7 +74,7 @@ describe Child do
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
describe
|
77
|
+
describe 'revert!' do
|
78
78
|
context 'parent `create` draft with child `create` draft' do
|
79
79
|
before do
|
80
80
|
parent.draft_creation
|
@@ -84,18 +84,18 @@ describe Child do
|
|
84
84
|
subject { child.draft.revert! }
|
85
85
|
|
86
86
|
it 'destroys the parent' do
|
87
|
-
expect { subject }.to_not change(Parent, :count)
|
87
|
+
expect { subject }.to_not change(Parent, :count)
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'destroys the child' do
|
91
91
|
expect { subject }.to change(Child, :count).by(-1)
|
92
92
|
end
|
93
93
|
|
94
|
-
it '
|
94
|
+
it 'destroys 1 draft overall' do
|
95
95
|
expect { subject }.to change(Draftsman::Draft, :count).by(-1)
|
96
96
|
end
|
97
97
|
|
98
|
-
it
|
98
|
+
it "destroys the child's draft" do
|
99
99
|
expect { subject }.to change(Draftsman::Draft.where(:item_type => 'Child'), :count).by(-1)
|
100
100
|
end
|
101
101
|
end
|
@@ -114,35 +114,43 @@ describe Child do
|
|
114
114
|
child.reload
|
115
115
|
end
|
116
116
|
|
117
|
-
it
|
118
|
-
|
119
|
-
|
117
|
+
it 'does not persist the child' do
|
118
|
+
expect(subject.persisted?).to eql true
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'removes the child from the trash' do
|
122
|
+
expect(subject.trashed?).to eql false
|
123
|
+
end
|
124
|
+
|
125
|
+
it "destroys the child's draft" do
|
126
|
+
expect(subject.draft?).to eql false
|
127
|
+
end
|
120
128
|
|
121
|
-
it '
|
129
|
+
it 'destroys 2 drafts overall' do
|
122
130
|
expect { subject }.to change(Draftsman::Draft, :count).by(-2)
|
123
131
|
end
|
124
132
|
|
125
|
-
it "
|
133
|
+
it "destroys the parent's draft" do
|
126
134
|
expect { subject }.to change(Draftsman::Draft.where(:item_type => 'Parent'), :count).by(-1)
|
127
135
|
end
|
128
136
|
|
129
|
-
it "
|
137
|
+
it "destroys the child's draft" do
|
130
138
|
expect { subject }.to change(Draftsman::Draft.where(:item_type => 'Child'), :count).by(-1)
|
131
139
|
end
|
132
140
|
|
133
|
-
|
141
|
+
it 'removes the parent from the trash' do
|
134
142
|
subject
|
135
|
-
parent.
|
143
|
+
expect(parent).to_not be_trashed
|
136
144
|
end
|
137
145
|
|
138
|
-
|
146
|
+
it "destroys the child's draft" do
|
139
147
|
subject
|
140
|
-
child.
|
148
|
+
expect(child).to_not be_draft
|
141
149
|
end
|
142
150
|
end
|
143
151
|
end
|
144
152
|
|
145
|
-
describe
|
153
|
+
describe 'draft_publication_dependencies' do
|
146
154
|
context 'parent `create` draft with child `create` draft' do
|
147
155
|
before do
|
148
156
|
parent.draft_creation
|
@@ -150,8 +158,14 @@ describe Child do
|
|
150
158
|
end
|
151
159
|
|
152
160
|
subject { child.draft }
|
153
|
-
|
154
|
-
|
161
|
+
|
162
|
+
it "creates publication dependencies for the child's draft" do
|
163
|
+
expect(subject.draft_publication_dependencies).to_not be_empty
|
164
|
+
end
|
165
|
+
|
166
|
+
it "includes the parent as a publication dependency for the child's draft" do
|
167
|
+
expect(subject.draft_publication_dependencies).to include parent.draft
|
168
|
+
end
|
155
169
|
end
|
156
170
|
|
157
171
|
context 'parent `create` draft with child `update` draft' do
|
@@ -163,12 +177,19 @@ describe Child do
|
|
163
177
|
end
|
164
178
|
|
165
179
|
subject { child.draft }
|
166
|
-
|
167
|
-
|
180
|
+
|
181
|
+
it "creates publication dependencies for the child's draft" do
|
182
|
+
expect(subject.draft_publication_dependencies).to_not be_empty
|
183
|
+
end
|
184
|
+
|
185
|
+
it "includes the parent as a publication dependency for the child's draft" do
|
186
|
+
expect(subject.draft_publication_dependencies).to include parent.draft
|
187
|
+
end
|
168
188
|
end
|
169
189
|
|
170
190
|
context 'parent `create` draft with child `update` draft pointing to new parent' do
|
171
191
|
let(:new_parent) { Parent.new(:name => 'Patty') }
|
192
|
+
|
172
193
|
before do
|
173
194
|
parent.draft_creation
|
174
195
|
child.save!
|
@@ -178,9 +199,18 @@ describe Child do
|
|
178
199
|
end
|
179
200
|
|
180
201
|
subject { child.draft }
|
181
|
-
|
182
|
-
|
183
|
-
|
202
|
+
|
203
|
+
it "creates publication dependencies for the child's draft" do
|
204
|
+
expect(subject.draft_publication_dependencies).to_not be_empty
|
205
|
+
end
|
206
|
+
|
207
|
+
it "removes the old parent as a publication dependency for the child's draft" do
|
208
|
+
expect(subject.draft_publication_dependencies).to_not include parent.draft
|
209
|
+
end
|
210
|
+
|
211
|
+
it "includes the new parent as a publication dependency for the child's draft" do
|
212
|
+
expect(subject.draft_publication_dependencies).to include new_parent.draft
|
213
|
+
end
|
184
214
|
end
|
185
215
|
|
186
216
|
context 'parent `destroy` draft with child `destroy` draft' do
|
@@ -191,11 +221,14 @@ describe Child do
|
|
191
221
|
end
|
192
222
|
|
193
223
|
subject { child.draft }
|
194
|
-
|
224
|
+
|
225
|
+
it "has no publication dependencies for the child's draft" do
|
226
|
+
expect(subject.draft_publication_dependencies).to be_empty
|
227
|
+
end
|
195
228
|
end
|
196
229
|
end
|
197
230
|
|
198
|
-
describe
|
231
|
+
describe 'draft_reversion_dependencies' do
|
199
232
|
context 'parent `create` draft with child `create` draft' do
|
200
233
|
before do
|
201
234
|
parent.draft_creation
|
@@ -203,7 +236,10 @@ describe Child do
|
|
203
236
|
end
|
204
237
|
|
205
238
|
subject { child.draft }
|
206
|
-
|
239
|
+
|
240
|
+
it "has no reversion dependencies for the child's draft" do
|
241
|
+
expect(subject.draft_reversion_dependencies).to be_empty
|
242
|
+
end
|
207
243
|
end
|
208
244
|
|
209
245
|
context 'parent `destroy` draft with child `destroy` draft' do
|
@@ -214,8 +250,14 @@ describe Child do
|
|
214
250
|
end
|
215
251
|
|
216
252
|
subject { child.draft }
|
217
|
-
|
218
|
-
|
253
|
+
|
254
|
+
it "creates reversion dependencies for the child's draft" do
|
255
|
+
expect(subject.draft_reversion_dependencies).to be_present
|
256
|
+
end
|
257
|
+
|
258
|
+
it "includes the parent as a reversion dependency for the child's draft" do
|
259
|
+
expect(subject.draft_reversion_dependencies).to include parent.draft
|
260
|
+
end
|
219
261
|
end
|
220
262
|
end
|
221
263
|
end
|