govuk_content_models 15.1.0 → 15.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/app/models/edition.rb +1 -1
- data/app/models/workflow.rb +7 -0
- data/app/models/workflow_actor.rb +1 -5
- data/lib/govuk_content_models/version.rb +1 -1
- data/test/models/edition_test.rb +9 -6
- metadata +4 -4
data/CHANGELOG.md
CHANGED
data/app/models/edition.rb
CHANGED
data/app/models/workflow.rb
CHANGED
@@ -221,6 +221,13 @@ module Workflow
|
|
221
221
|
published? ? 'Published editions' : 'Editions scheduled for publishing'
|
222
222
|
end
|
223
223
|
|
224
|
+
def perform_event_without_validations(event)
|
225
|
+
# http://rubydoc.info/github/pluginaweek/state_machine/StateMachine/Machine:event
|
226
|
+
# pass false to transition state without performing state machine actions
|
227
|
+
public_send(event, false)
|
228
|
+
save(validate: false)
|
229
|
+
end
|
230
|
+
|
224
231
|
private
|
225
232
|
|
226
233
|
def publish_at_is_in_the_future
|
@@ -95,11 +95,7 @@ module WorkflowActor
|
|
95
95
|
|
96
96
|
# Always records the action.
|
97
97
|
def receive_fact_check(edition, details)
|
98
|
-
|
99
|
-
# save separately without validation
|
100
|
-
# http://rubydoc.info/github/pluginaweek/state_machine/StateMachine/Machine:event
|
101
|
-
edition.receive_fact_check(false)
|
102
|
-
edition.save(validate: false)
|
98
|
+
edition.perform_event_without_validations(:receive_fact_check)
|
103
99
|
# Fact checks are processed async, so the user doesn't get an opportunity
|
104
100
|
# to retry without the content that (inadvertantly) fails validation, which happens frequently.
|
105
101
|
record_action_without_validation(edition, :receive_fact_check, details)
|
data/test/models/edition_test.rb
CHANGED
@@ -655,20 +655,23 @@ class EditionTest < ActiveSupport::TestCase
|
|
655
655
|
assert_not_nil GuideEdition.where(state: "published", panopticon_id: edition.panopticon_id).first
|
656
656
|
end
|
657
657
|
|
658
|
-
test "
|
659
|
-
edition = FactoryGirl.create(:
|
658
|
+
test "should archive older editions, even if there are validation errors, when a new edition is published" do
|
659
|
+
edition = FactoryGirl.create(:guide_edition_with_two_parts, panopticon_id: @artefact.id, state: "ready")
|
660
660
|
|
661
661
|
user = User.create name: "bob"
|
662
662
|
user.publish edition, comment: "First publication"
|
663
663
|
|
664
664
|
second_edition = edition.build_clone
|
665
|
-
second_edition.
|
666
|
-
second_edition.save!
|
665
|
+
second_edition.state = "ready"
|
667
666
|
user.publish second_edition, comment: "Second publication"
|
668
667
|
|
668
|
+
# simulate link validation errors in published edition
|
669
|
+
second_edition.parts.first.update_attribute(:body, "[register your vehicle](registering-an-imported-vehicle)")
|
670
|
+
|
669
671
|
third_edition = second_edition.build_clone
|
670
|
-
|
671
|
-
third_edition.
|
672
|
+
# fix link validation error in cloned edition by appending a '/' to the relative url
|
673
|
+
third_edition.parts.first.body = "[register your vehicle](/registering-an-imported-vehicle)"
|
674
|
+
third_edition.state = "ready"
|
672
675
|
user.publish third_edition, comment: "Third publication"
|
673
676
|
|
674
677
|
edition.reload
|
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: 15.1.
|
4
|
+
version: 15.1.1
|
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-07-
|
12
|
+
date: 2014-07-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bson_ext
|
@@ -466,7 +466,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
466
466
|
version: '0'
|
467
467
|
segments:
|
468
468
|
- 0
|
469
|
-
hash: -
|
469
|
+
hash: -4160553769298563389
|
470
470
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
471
471
|
none: false
|
472
472
|
requirements:
|
@@ -475,7 +475,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
475
475
|
version: '0'
|
476
476
|
segments:
|
477
477
|
- 0
|
478
|
-
hash: -
|
478
|
+
hash: -4160553769298563389
|
479
479
|
requirements: []
|
480
480
|
rubyforge_project:
|
481
481
|
rubygems_version: 1.8.23
|