govuk_content_models 11.2.0 → 11.3.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.
- data/CHANGELOG.md +6 -0
- data/app/models/artefact.rb +4 -3
- data/app/models/edition.rb +1 -5
- data/lib/govuk_content_models/version.rb +1 -1
- data/test/models/artefact_test.rb +25 -18
- data/test/models/edition_test.rb +0 -27
- metadata +4 -4
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## 11.3.0
|
|
2
|
+
|
|
3
|
+
* When an artefact is saved, no longer attempt to update attributes on the
|
|
4
|
+
edition model - with the exception of the slug field, which will only be
|
|
5
|
+
updated when the artefact is in draft state.
|
|
6
|
+
|
|
1
7
|
## 11.2.0
|
|
2
8
|
|
|
3
9
|
* Added manual and manual-section formats with custom slug validation.
|
data/app/models/artefact.rb
CHANGED
|
@@ -278,12 +278,13 @@ class Artefact
|
|
|
278
278
|
end
|
|
279
279
|
|
|
280
280
|
def update_editions
|
|
281
|
-
|
|
281
|
+
case state
|
|
282
|
+
when 'draft'
|
|
282
283
|
Edition.where(:state.nin => ["archived"],
|
|
283
284
|
panopticon_id: self.id).each do |edition|
|
|
284
|
-
edition.
|
|
285
|
+
edition.update_slug_from_artefact(self)
|
|
285
286
|
end
|
|
286
|
-
|
|
287
|
+
when 'archived'
|
|
287
288
|
archive_editions
|
|
288
289
|
end
|
|
289
290
|
end
|
data/app/models/edition.rb
CHANGED
|
@@ -239,12 +239,8 @@ class Edition
|
|
|
239
239
|
notify_siblings_of_published_edition
|
|
240
240
|
end
|
|
241
241
|
|
|
242
|
-
def
|
|
243
|
-
self.title = artefact.name unless published?
|
|
242
|
+
def update_slug_from_artefact(artefact)
|
|
244
243
|
self.slug = artefact.slug
|
|
245
|
-
self.section = artefact.section
|
|
246
|
-
self.department = artefact.department
|
|
247
|
-
self.business_proposition = artefact.business_proposition
|
|
248
244
|
self.save!
|
|
249
245
|
end
|
|
250
246
|
|
|
@@ -306,29 +306,36 @@ class ArtefactTest < ActiveSupport::TestCase
|
|
|
306
306
|
end
|
|
307
307
|
end
|
|
308
308
|
|
|
309
|
-
|
|
310
|
-
FactoryGirl.create(:
|
|
311
|
-
|
|
312
|
-
slug: "foo-bar",
|
|
313
|
-
kind: "answer",
|
|
314
|
-
name: "Foo bar",
|
|
315
|
-
primary_section: "test-section",
|
|
316
|
-
sections: ["test-section"],
|
|
317
|
-
department: "Test dept",
|
|
318
|
-
owning_app: "publisher",
|
|
319
|
-
)
|
|
309
|
+
should "update the edition's slug when a draft artefact is saved" do
|
|
310
|
+
artefact = FactoryGirl.create(:draft_artefact)
|
|
311
|
+
edition = FactoryGirl.create(:answer_edition, panopticon_id: artefact.id)
|
|
320
312
|
|
|
321
|
-
|
|
322
|
-
|
|
313
|
+
artefact.slug = "something-something-draft"
|
|
314
|
+
artefact.save!
|
|
323
315
|
|
|
324
|
-
|
|
325
|
-
assert_equal artefact.
|
|
316
|
+
edition.reload
|
|
317
|
+
assert_equal artefact.slug, edition.slug
|
|
318
|
+
end
|
|
326
319
|
|
|
327
|
-
|
|
328
|
-
artefact.
|
|
320
|
+
should "not update the edition's slug when a live artefact is saved" do
|
|
321
|
+
artefact = FactoryGirl.create(:live_artefact, slug: "something-something-live")
|
|
322
|
+
edition = FactoryGirl.create(:answer_edition, panopticon_id: artefact.id, slug: "something-else")
|
|
323
|
+
|
|
324
|
+
artefact.save!
|
|
329
325
|
|
|
330
326
|
edition.reload
|
|
331
|
-
assert_equal
|
|
327
|
+
assert_equal "something-else", edition.slug
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
should "not update the edition's slug when an archived artefact is saved" do
|
|
331
|
+
artefact = FactoryGirl.create(:live_artefact, slug: "something-something-live")
|
|
332
|
+
edition = FactoryGirl.create(:answer_edition, panopticon_id: artefact.id, slug: "something-else")
|
|
333
|
+
|
|
334
|
+
artefact.state = 'archived'
|
|
335
|
+
artefact.save!
|
|
336
|
+
|
|
337
|
+
edition.reload
|
|
338
|
+
assert_equal "something-else", edition.slug
|
|
332
339
|
end
|
|
333
340
|
|
|
334
341
|
test "should not let you edit the slug if the artefact is live" do
|
data/test/models/edition_test.rb
CHANGED
|
@@ -375,33 +375,6 @@ class EditionTest < ActiveSupport::TestCase
|
|
|
375
375
|
assert_equal artefact.department, publication.department
|
|
376
376
|
end
|
|
377
377
|
|
|
378
|
-
# TODO: come back and remove this one.
|
|
379
|
-
test "should not change edition name if published" do
|
|
380
|
-
FactoryGirl.create(:tag, tag_id: "test-section", title: "Test section", tag_type: "section")
|
|
381
|
-
artefact = FactoryGirl.create(:artefact,
|
|
382
|
-
slug: "foo-bar",
|
|
383
|
-
kind: "answer",
|
|
384
|
-
name: "Foo bar",
|
|
385
|
-
department: "Test dept",
|
|
386
|
-
owning_app: "publisher",
|
|
387
|
-
)
|
|
388
|
-
|
|
389
|
-
guide = FactoryGirl.create(:guide_edition,
|
|
390
|
-
panopticon_id: artefact.id,
|
|
391
|
-
title: "Original title",
|
|
392
|
-
slug: "original-title"
|
|
393
|
-
)
|
|
394
|
-
guide.state = "ready"
|
|
395
|
-
guide.save!
|
|
396
|
-
User.create(name: "Winston").publish(guide, comment: "testing")
|
|
397
|
-
artefact.name = "New title"
|
|
398
|
-
artefact.primary_section = "test-section"
|
|
399
|
-
artefact.save
|
|
400
|
-
|
|
401
|
-
assert_equal "Original title", guide.reload.title
|
|
402
|
-
assert_equal "Test section", guide.reload.section
|
|
403
|
-
end
|
|
404
|
-
|
|
405
378
|
test "should not change edition metadata if archived" do
|
|
406
379
|
FactoryGirl.create(:tag, tag_id: "test-section", title: "Test section", tag_type: "section")
|
|
407
380
|
artefact = FactoryGirl.create(:artefact,
|
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: 11.
|
|
4
|
+
version: 11.3.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-06-
|
|
12
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bson_ext
|
|
@@ -463,7 +463,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
463
463
|
version: '0'
|
|
464
464
|
segments:
|
|
465
465
|
- 0
|
|
466
|
-
hash:
|
|
466
|
+
hash: 3691821515300644876
|
|
467
467
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
468
468
|
none: false
|
|
469
469
|
requirements:
|
|
@@ -472,7 +472,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
472
472
|
version: '0'
|
|
473
473
|
segments:
|
|
474
474
|
- 0
|
|
475
|
-
hash:
|
|
475
|
+
hash: 3691821515300644876
|
|
476
476
|
requirements: []
|
|
477
477
|
rubyforge_project:
|
|
478
478
|
rubygems_version: 1.8.23
|