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 CHANGED
@@ -1,3 +1,6 @@
1
+ ## 15.1.1
2
+ * Allow archiving of siblings with validation errors
3
+
1
4
  ## 15.1.0
2
5
  * Add draft tag functionality to `Tag.by_tag_id/s`.
3
6
  * Permit tag type to be provided via an options
@@ -236,7 +236,7 @@ class Edition
236
236
  end
237
237
 
238
238
  def was_published
239
- previous_siblings.all.each(&:archive)
239
+ previous_siblings.each { |s| s.perform_event_without_validations(:archive) }
240
240
  notify_siblings_of_published_edition
241
241
  end
242
242
 
@@ -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
- # advance state if possible (i.e. if in "fact_check" state),
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)
@@ -1,4 +1,4 @@
1
1
  module GovukContentModels
2
2
  # Changing this causes Jenkins to tag and release the gem into the wild
3
- VERSION = "15.1.0"
3
+ VERSION = "15.1.1"
4
4
  end
@@ -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 "when an edition of a guide is published, all other published editions are archived" do
659
- edition = FactoryGirl.create(:guide_edition, panopticon_id: @artefact.id, state: "ready")
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.update_attribute(:state, "ready")
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
- third_edition.update_attribute(:state, "ready")
671
- third_edition.save!
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.0
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-14 00:00:00.000000000 Z
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: -630092204464727193
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: -630092204464727193
478
+ hash: -4160553769298563389
479
479
  requirements: []
480
480
  rubyforge_project:
481
481
  rubygems_version: 1.8.23