govuk_content_models 7.3.1 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/action.rb +0 -1
- data/app/models/edition.rb +0 -1
- data/app/models/overview_dashboard.rb +0 -1
- data/app/models/specialist_document_edition.rb +0 -1
- data/app/models/workflow.rb +4 -12
- data/app/models/workflow_actor.rb +1 -1
- data/lib/govuk_content_models/version.rb +1 -1
- data/test/models/edition_test.rb +8 -11
- data/test/models/overview_dashboard_test.rb +0 -1
- data/test/models/workflow_test.rb +56 -31
- metadata +4 -4
data/app/models/action.rb
CHANGED
data/app/models/edition.rb
CHANGED
@@ -9,7 +9,6 @@ class OverviewDashboard
|
|
9
9
|
field :dashboard_type, type: String
|
10
10
|
field :result_group, type: Integer
|
11
11
|
field :count, type: Integer
|
12
|
-
field :lined_up, type: Integer
|
13
12
|
field :draft, type: Integer
|
14
13
|
field :amends_needed, type: Integer
|
15
14
|
field :in_review, type: Integer
|
@@ -43,7 +43,6 @@ class SpecialistDocumentEdition
|
|
43
43
|
|
44
44
|
belongs_to :assigned_to, class_name: "User"
|
45
45
|
|
46
|
-
scope :lined_up, where(state: "lined_up")
|
47
46
|
scope :draft, where(state: "draft")
|
48
47
|
scope :amends_needed, where(state: "amends_needed")
|
49
48
|
scope :in_review, where(state: "in_review")
|
data/app/models/workflow.rb
CHANGED
@@ -13,11 +13,11 @@ module Workflow
|
|
13
13
|
before_save :denormalise_users
|
14
14
|
after_create :notify_siblings_of_new_edition
|
15
15
|
|
16
|
-
field :state, type: String, default: "
|
16
|
+
field :state, type: String, default: "draft"
|
17
17
|
belongs_to :assigned_to, class_name: "User"
|
18
18
|
embeds_many :actions
|
19
19
|
|
20
|
-
state_machine initial: :
|
20
|
+
state_machine initial: :draft do
|
21
21
|
after_transition on: :request_amendments do |edition, transition|
|
22
22
|
edition.mark_as_rejected
|
23
23
|
end
|
@@ -26,10 +26,6 @@ module Workflow
|
|
26
26
|
edition.was_published
|
27
27
|
end
|
28
28
|
|
29
|
-
event :start_work do
|
30
|
-
transition lined_up: :draft
|
31
|
-
end
|
32
|
-
|
33
29
|
event :request_review do
|
34
30
|
transition [:draft, :amends_needed] => :in_review
|
35
31
|
end
|
@@ -43,12 +39,12 @@ module Workflow
|
|
43
39
|
end
|
44
40
|
|
45
41
|
event :request_amendments do
|
46
|
-
transition [:fact_check_received, :in_review] => :amends_needed
|
42
|
+
transition [:fact_check_received, :in_review, :ready, :fact_check] => :amends_needed
|
47
43
|
end
|
48
44
|
|
49
45
|
# Editions can optionally be sent out for fact check
|
50
46
|
event :send_fact_check do
|
51
|
-
transition ready: :fact_check
|
47
|
+
transition [:ready, :fact_check_received] => :fact_check
|
52
48
|
end
|
53
49
|
|
54
50
|
# If no response is received to a fact check request we can skip
|
@@ -76,10 +72,6 @@ module Workflow
|
|
76
72
|
transition all => :archived, :unless => :archived?
|
77
73
|
end
|
78
74
|
end
|
79
|
-
|
80
|
-
# alias_method :created_by, :creator
|
81
|
-
# alias_method :published_by, :publisher
|
82
|
-
# alias_method :archived_by, :archiver
|
83
75
|
end
|
84
76
|
|
85
77
|
def fact_checked?
|
@@ -6,7 +6,7 @@ require "programme_edition"
|
|
6
6
|
require "transaction_edition"
|
7
7
|
|
8
8
|
module WorkflowActor
|
9
|
-
SIMPLE_WORKFLOW_ACTIONS = %W[
|
9
|
+
SIMPLE_WORKFLOW_ACTIONS = %W[request_review
|
10
10
|
request_amendments approve_review approve_fact_check archive]
|
11
11
|
|
12
12
|
def record_action(edition, type, options={})
|
data/test/models/edition_test.rb
CHANGED
@@ -147,7 +147,7 @@ class EditionTest < ActiveSupport::TestCase
|
|
147
147
|
assert_equal new_edition.class, AnswerEdition
|
148
148
|
assert_equal new_edition.version_number, 2
|
149
149
|
assert_equal new_edition.panopticon_id, @artefact.id.to_s
|
150
|
-
assert_equal new_edition.state, "
|
150
|
+
assert_equal new_edition.state, "draft"
|
151
151
|
assert_equal new_edition.department, "Test dept"
|
152
152
|
assert_equal new_edition.overview, "I am a test overview"
|
153
153
|
assert_equal new_edition.alternative_title, "Alternative test title"
|
@@ -169,7 +169,7 @@ class EditionTest < ActiveSupport::TestCase
|
|
169
169
|
assert_equal new_edition.class, AnswerEdition
|
170
170
|
assert_equal new_edition.version_number, 2
|
171
171
|
assert_equal new_edition.panopticon_id, @artefact.id.to_s
|
172
|
-
assert_equal new_edition.state, "
|
172
|
+
assert_equal new_edition.state, "draft"
|
173
173
|
assert_equal new_edition.department, "Test dept"
|
174
174
|
assert_equal new_edition.overview, "I am a test overview"
|
175
175
|
assert_equal new_edition.alternative_title, "Alternative test title"
|
@@ -193,7 +193,7 @@ class EditionTest < ActiveSupport::TestCase
|
|
193
193
|
assert_equal new_edition.class, AnswerEdition
|
194
194
|
assert_equal new_edition.version_number, 2
|
195
195
|
assert_equal new_edition.panopticon_id, @artefact.id.to_s
|
196
|
-
assert_equal new_edition.state, "
|
196
|
+
assert_equal new_edition.state, "draft"
|
197
197
|
assert_equal new_edition.department, "Test dept"
|
198
198
|
assert_equal new_edition.overview, "I am a test overview"
|
199
199
|
assert_equal new_edition.alternative_title, "Alternative test title"
|
@@ -216,7 +216,7 @@ class EditionTest < ActiveSupport::TestCase
|
|
216
216
|
assert_equal new_edition.class, TransactionEdition
|
217
217
|
assert_equal new_edition.version_number, 2
|
218
218
|
assert_equal new_edition.panopticon_id, @artefact.id.to_s
|
219
|
-
assert_equal new_edition.state, "
|
219
|
+
assert_equal new_edition.state, "draft"
|
220
220
|
assert_equal new_edition.department, "Test dept"
|
221
221
|
assert_equal new_edition.overview, "I am a test overview"
|
222
222
|
assert_equal new_edition.alternative_title, "Alternative test title"
|
@@ -239,7 +239,7 @@ class EditionTest < ActiveSupport::TestCase
|
|
239
239
|
assert_equal new_edition.class, TransactionEdition
|
240
240
|
assert_equal new_edition.version_number, 2
|
241
241
|
assert_equal new_edition.panopticon_id, @artefact.id.to_s
|
242
|
-
assert_equal new_edition.state, "
|
242
|
+
assert_equal new_edition.state, "draft"
|
243
243
|
assert_equal new_edition.department, "Test dept"
|
244
244
|
assert_equal new_edition.overview, "I am a test overview"
|
245
245
|
assert_equal new_edition.alternative_title, "Alternative test title"
|
@@ -261,7 +261,7 @@ class EditionTest < ActiveSupport::TestCase
|
|
261
261
|
assert_equal new_edition.class, TransactionEdition
|
262
262
|
assert_equal new_edition.version_number, 2
|
263
263
|
assert_equal new_edition.panopticon_id, @artefact.id.to_s
|
264
|
-
assert_equal new_edition.state, "
|
264
|
+
assert_equal new_edition.state, "draft"
|
265
265
|
assert_equal new_edition.department, "Test dept"
|
266
266
|
assert_equal new_edition.overview, "I am a test overview"
|
267
267
|
assert_equal new_edition.alternative_title, "Alternative test title"
|
@@ -283,7 +283,7 @@ class EditionTest < ActiveSupport::TestCase
|
|
283
283
|
assert_equal new_edition.class, GuideEdition
|
284
284
|
assert_equal new_edition.version_number, 2
|
285
285
|
assert_equal new_edition.panopticon_id, @artefact.id.to_s
|
286
|
-
assert_equal new_edition.state, "
|
286
|
+
assert_equal new_edition.state, "draft"
|
287
287
|
assert_equal new_edition.department, "Test dept"
|
288
288
|
assert_equal new_edition.overview, "I am a test overview"
|
289
289
|
assert_equal new_edition.alternative_title, "Alternative test title"
|
@@ -756,7 +756,6 @@ class EditionTest < ActiveSupport::TestCase
|
|
756
756
|
user = User.create(name: "Mary")
|
757
757
|
|
758
758
|
edition = ProgrammeEdition.new(title: "Childcare", slug: "childcare", panopticon_id: @artefact.id)
|
759
|
-
user.start_work(edition)
|
760
759
|
assert edition.can_request_review?
|
761
760
|
user.request_review(edition,{comment: "Review this programme please."})
|
762
761
|
assert ! user.request_amendments(edition, {comment: "Well Done, but work harder"})
|
@@ -797,13 +796,11 @@ class EditionTest < ActiveSupport::TestCase
|
|
797
796
|
|
798
797
|
test "a draft edition cannot be published" do
|
799
798
|
edition = FactoryGirl.create(:guide_edition, panopticon_id: @artefact.id, state: "draft")
|
800
|
-
edition.start_work
|
801
799
|
refute edition.can_publish?
|
802
800
|
end
|
803
801
|
|
804
802
|
test "a draft edition can be emergency published" do
|
805
803
|
edition = FactoryGirl.create(:guide_edition, panopticon_id: @artefact.id, state: "draft")
|
806
|
-
edition.start_work
|
807
804
|
assert edition.can_emergency_publish?
|
808
805
|
end
|
809
806
|
|
@@ -833,7 +830,7 @@ class EditionTest < ActiveSupport::TestCase
|
|
833
830
|
@user1 = FactoryGirl.create(:user)
|
834
831
|
@user2 = FactoryGirl.create(:user)
|
835
832
|
|
836
|
-
edition = FactoryGirl.create(:guide_edition, panopticon_id: @artefact.id, state: "
|
833
|
+
edition = FactoryGirl.create(:guide_edition, panopticon_id: @artefact.id, state: "draft")
|
837
834
|
@user1.assign edition, @user2
|
838
835
|
|
839
836
|
assert_equal @user2, edition.assigned_to
|
@@ -13,14 +13,12 @@ class WorkflowTest < ActiveSupport::TestCase
|
|
13
13
|
|
14
14
|
def template_programme
|
15
15
|
p = ProgrammeEdition.new(slug:"childcare", title:"Children", panopticon_id: @artefact.id)
|
16
|
-
p.start_work
|
17
16
|
p.save
|
18
17
|
p
|
19
18
|
end
|
20
19
|
|
21
20
|
def template_guide
|
22
21
|
edition = FactoryGirl.create(:guide_edition, slug: "childcare", title: "One", panopticon_id: @artefact.id)
|
23
|
-
edition.start_work
|
24
22
|
edition.save
|
25
23
|
edition
|
26
24
|
end
|
@@ -31,7 +29,6 @@ class WorkflowTest < ActiveSupport::TestCase
|
|
31
29
|
|
32
30
|
guide = user.create_edition(:guide, panopticon_id: @artefact.id, overview: "My Overview", title: "My Title", slug: "my-title", alternative_title: "My Other Title")
|
33
31
|
edition = guide
|
34
|
-
user.start_work(edition)
|
35
32
|
user.request_review(edition,{comment: "Review this guide please."})
|
36
33
|
other_user.approve_review(edition, {comment: "I've reviewed it"})
|
37
34
|
user.send_fact_check(edition,{comment: "Review this guide please.", email_addresses: "test@test.com"})
|
@@ -50,8 +47,6 @@ class WorkflowTest < ActiveSupport::TestCase
|
|
50
47
|
transaction.expectation_ids = [expectation.id]
|
51
48
|
transaction.save
|
52
49
|
|
53
|
-
transaction.start_work
|
54
|
-
transaction.save
|
55
50
|
user.request_review(transaction, {comment: "Review this guide please."})
|
56
51
|
transaction.save
|
57
52
|
other_user.approve_review(transaction, {comment: "I've reviewed it"})
|
@@ -79,28 +74,13 @@ class WorkflowTest < ActiveSupport::TestCase
|
|
79
74
|
assert_equal "AnswerEdition", new_edition._type
|
80
75
|
end
|
81
76
|
|
82
|
-
test "a new answer is
|
83
|
-
g = AnswerEdition.new(slug: "childcare", panopticon_id: @artefact.id, title: "My new answer")
|
84
|
-
assert g.lined_up?
|
85
|
-
end
|
86
|
-
|
87
|
-
test "starting work on an answer removes it from lined up" do
|
77
|
+
test "a new answer is in draft" do
|
88
78
|
g = AnswerEdition.new(slug: "childcare", panopticon_id: @artefact.id, title: "My new answer")
|
89
|
-
g.
|
90
|
-
user = User.create(name: "Ben")
|
91
|
-
user.start_work(g)
|
92
|
-
assert_equal false, g.lined_up?
|
93
|
-
end
|
94
|
-
|
95
|
-
test "a new guide has lined_up but isn't published" do
|
96
|
-
g = FactoryGirl.create(:guide_edition, panopticon_id: @artefact.id)
|
97
|
-
assert g.lined_up?
|
98
|
-
refute g.published?
|
79
|
+
assert g.draft?
|
99
80
|
end
|
100
81
|
|
101
|
-
test "
|
82
|
+
test "a new guide has draft but isn't published" do
|
102
83
|
g = FactoryGirl.create(:guide_edition, panopticon_id: @artefact.id)
|
103
|
-
g.start_work
|
104
84
|
assert g.draft?
|
105
85
|
refute g.published?
|
106
86
|
end
|
@@ -119,7 +99,7 @@ class WorkflowTest < ActiveSupport::TestCase
|
|
119
99
|
|
120
100
|
guide = user.create_edition(:guide, title: "My Title", slug: "my-title", panopticon_id: @artefact.id)
|
121
101
|
edition = guide
|
122
|
-
|
102
|
+
|
123
103
|
assert edition.can_request_review?
|
124
104
|
user.request_review(edition,{comment: "Review this guide please."})
|
125
105
|
refute edition.can_request_review?
|
@@ -138,7 +118,6 @@ class WorkflowTest < ActiveSupport::TestCase
|
|
138
118
|
|
139
119
|
edition = user.create_edition(:guide, panopticon_id: @artefact.id, overview: "My Overview", title: "My Title", slug: "my-title", alternative_title: "My Other Title")
|
140
120
|
|
141
|
-
user.start_work(edition)
|
142
121
|
user.request_review(edition,{comment: "Review this guide please."})
|
143
122
|
other_user.approve_review(edition, {comment: "I've reviewed it"})
|
144
123
|
user.send_fact_check(edition,{comment: "Review this guide please.", email_addresses: "test@test.com"})
|
@@ -156,7 +135,7 @@ class WorkflowTest < ActiveSupport::TestCase
|
|
156
135
|
|
157
136
|
guide = user.create_edition(:guide, panopticon_id: FactoryGirl.create(:artefact).id, overview: "My Overview", title: "My Title", slug: "my-title", alternative_title: "My Other Title")
|
158
137
|
edition = guide
|
159
|
-
|
138
|
+
|
160
139
|
user.request_review(edition,{comment: "Review this guide please."})
|
161
140
|
other_user.approve_review(edition, {comment: "I've reviewed it"})
|
162
141
|
user.send_fact_check(edition,{comment: "Review this guide please.", email_addresses: "test@test.com"})
|
@@ -165,6 +144,52 @@ class WorkflowTest < ActiveSupport::TestCase
|
|
165
144
|
assert_equal "Text.<l>content that the SafeHtml validator would catch</l>", edition.actions.last.comment
|
166
145
|
end
|
167
146
|
|
147
|
+
test "fact_check_received can go back to out for fact_check" do
|
148
|
+
user = User.create(name: "Ben")
|
149
|
+
other_user = User.create(name: "James")
|
150
|
+
|
151
|
+
guide = user.create_edition(:guide, panopticon_id: FactoryGirl.create(:artefact).id, overview: "My Overview", title: "My Title", slug: "my-title", alternative_title: "My Other Title")
|
152
|
+
edition = guide
|
153
|
+
|
154
|
+
user.request_review(edition,{comment: "Review this guide please."})
|
155
|
+
other_user.approve_review(edition, {comment: "I've reviewed it"})
|
156
|
+
user.send_fact_check(edition,{comment: "Review this guide please.", email_addresses: "test@test.com"})
|
157
|
+
user.receive_fact_check(edition, {comment: "Text.<l>content that the SafeHtml validator would catch</l>"})
|
158
|
+
user.send_fact_check(edition,{comment: "Out of office reply triggered receive_fact_check", email_addresses: "test@test.com"})
|
159
|
+
|
160
|
+
assert(edition.actions.last.comment.include? "Out of office reply triggered receive_fact_check\n\nResponses should be sent to:")
|
161
|
+
end
|
162
|
+
|
163
|
+
test "when processing fact check, an edition can request for amendments" do
|
164
|
+
user = User.create(name: "Ben")
|
165
|
+
other_user = User.create(name: "James")
|
166
|
+
|
167
|
+
guide = user.create_edition(:guide, panopticon_id: FactoryGirl.create(:artefact).id, overview: "My Overview", title: "My Title", slug: "my-title", alternative_title: "My Other Title")
|
168
|
+
edition = guide
|
169
|
+
|
170
|
+
user.request_review(edition,{comment: "Review this guide please."})
|
171
|
+
other_user.approve_review(edition, {comment: "I've reviewed it"})
|
172
|
+
user.send_fact_check(edition,{comment: "Review this guide please.", email_addresses: "test@test.com"})
|
173
|
+
other_user.request_amendments(edition,{comment: "More amendments are required", email_addresses: "foo@bar.com"})
|
174
|
+
|
175
|
+
assert_equal "More amendments are required", edition.actions.last.comment
|
176
|
+
end
|
177
|
+
|
178
|
+
test "ready items may require further amendments" do
|
179
|
+
user = User.create(name: "Ben")
|
180
|
+
other_user = User.create(name: "James")
|
181
|
+
another_user = User.create(name: "Fiona")
|
182
|
+
|
183
|
+
guide = user.create_edition(:guide, panopticon_id: FactoryGirl.create(:artefact).id, overview: "My Overview", title: "My Title", slug: "my-title", alternative_title: "My Other Title")
|
184
|
+
edition = guide
|
185
|
+
|
186
|
+
user.request_review(edition,{comment: "Review this guide please."})
|
187
|
+
other_user.approve_review(edition, {comment: "I've reviewed it"})
|
188
|
+
another_user.request_amendments(edition,{comment: "More amendments are required", email_addresses: "foo@bar.com"})
|
189
|
+
|
190
|
+
assert_equal "More amendments are required", edition.actions.last.comment
|
191
|
+
end
|
192
|
+
|
168
193
|
test "check counting reviews" do
|
169
194
|
user = User.create(name: "Ben")
|
170
195
|
other_user = User.create(name: "James")
|
@@ -174,7 +199,6 @@ class WorkflowTest < ActiveSupport::TestCase
|
|
174
199
|
|
175
200
|
assert_equal 0, guide.rejected_count
|
176
201
|
|
177
|
-
user.start_work(edition)
|
178
202
|
user.request_review(edition,{comment: "Review this guide please."})
|
179
203
|
other_user.request_amendments(edition, {comment: "I've reviewed it"})
|
180
204
|
|
@@ -191,7 +215,7 @@ class WorkflowTest < ActiveSupport::TestCase
|
|
191
215
|
|
192
216
|
guide = user.create_edition(:guide, title: "My Title", slug: "my-title", panopticon_id: @artefact.id)
|
193
217
|
edition = guide
|
194
|
-
|
218
|
+
|
195
219
|
assert edition.can_request_review?
|
196
220
|
user.request_review(edition,{comment: "Review this guide please."})
|
197
221
|
refute user.request_amendments(edition, {comment: "Well Done, but work harder"})
|
@@ -202,7 +226,7 @@ class WorkflowTest < ActiveSupport::TestCase
|
|
202
226
|
|
203
227
|
guide = user.create_edition(:guide, title: "My Title", slug: "my-title", panopticon_id: @artefact.id)
|
204
228
|
edition = guide
|
205
|
-
|
229
|
+
|
206
230
|
assert edition.can_request_review?
|
207
231
|
user.request_review(edition,{comment: "Review this guide please."})
|
208
232
|
refute user.approve_review(edition, "")
|
@@ -227,7 +251,7 @@ class WorkflowTest < ActiveSupport::TestCase
|
|
227
251
|
user, other_user = template_users
|
228
252
|
|
229
253
|
edition = user.create_edition(:programme, panopticon_id: @artefact.id, title: "My title", slug: "my-slug")
|
230
|
-
|
254
|
+
|
231
255
|
assert edition.can_request_review?
|
232
256
|
user.request_review(edition,{comment: "Review this guide please."})
|
233
257
|
refute edition.can_request_review?
|
@@ -237,6 +261,7 @@ class WorkflowTest < ActiveSupport::TestCase
|
|
237
261
|
user.request_review(edition,{comment: "Review this guide please."})
|
238
262
|
assert edition.can_approve_review?
|
239
263
|
other_user.approve_review(edition, {comment: "Looks good to me"})
|
264
|
+
assert edition.can_request_amendments?
|
240
265
|
assert edition.can_publish?
|
241
266
|
end
|
242
267
|
|
@@ -244,7 +269,7 @@ class WorkflowTest < ActiveSupport::TestCase
|
|
244
269
|
user, other_user = template_users
|
245
270
|
|
246
271
|
edition = user.create_edition(:programme, panopticon_id: @artefact.id, title: "My title", slug: "my-slug")
|
247
|
-
|
272
|
+
|
248
273
|
assert edition.can_request_review?
|
249
274
|
user.request_review(edition,{comment: "Review this programme please."})
|
250
275
|
refute user.approve_review(edition, "")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_content_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bson_ext
|
@@ -456,7 +456,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
456
456
|
version: '0'
|
457
457
|
segments:
|
458
458
|
- 0
|
459
|
-
hash:
|
459
|
+
hash: 1977371837260361132
|
460
460
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
461
461
|
none: false
|
462
462
|
requirements:
|
@@ -465,7 +465,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
465
465
|
version: '0'
|
466
466
|
segments:
|
467
467
|
- 0
|
468
|
-
hash:
|
468
|
+
hash: 1977371837260361132
|
469
469
|
requirements: []
|
470
470
|
rubyforge_project:
|
471
471
|
rubygems_version: 1.8.23
|