govuk_content_models 22.2.0 → 23.0.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 CHANGED
@@ -1,3 +1,9 @@
1
+ ## 23.0.0
2
+
3
+ * Remove important_notes field from Edition
4
+ * Add IMPORTANT_NOTE and IMPORTANT_NOTE_RESOLVED request_types to Action
5
+ * Add methods to find, create and resolve important note actions to Workflow and WorkflowActor.
6
+
1
7
  ## 22.2.0
2
8
 
3
9
  * Allow new formats for raib_report for Artefacts
data/app/models/action.rb CHANGED
@@ -21,6 +21,8 @@ class Action
21
21
 
22
22
  NON_STATUS_ACTIONS = [
23
23
  NOTE = "note",
24
+ IMPORTANT_NOTE = "important_note",
25
+ IMPORTANT_NOTE_RESOLVED = "important_note_resolved",
24
26
  ASSIGN = "assign",
25
27
  ]
26
28
 
@@ -19,7 +19,6 @@ class Edition
19
19
  field :slug, type: String
20
20
  field :department, type: String
21
21
  field :rejected_count, type: Integer, default: 0
22
- field :important_note, type: String
23
22
 
24
23
  field :browse_pages, type: Array, default: []
25
24
  field :primary_topic, type: String
@@ -216,6 +216,11 @@ module Workflow
216
216
  save(validate: false)
217
217
  end
218
218
 
219
+ def important_note
220
+ action = actions.where(:request_type.in => [Action::IMPORTANT_NOTE, Action::IMPORTANT_NOTE_RESOLVED]).last
221
+ action if action.try(:request_type) == Action::IMPORTANT_NOTE
222
+ end
223
+
219
224
  private
220
225
 
221
226
  def publish_at_is_in_the_future
@@ -54,8 +54,12 @@ module WorkflowActor
54
54
  edition.save if edition
55
55
  end
56
56
 
57
- def record_note(edition, comment)
58
- edition.new_action(self, "note", comment: comment)
57
+ def record_note(edition, comment, type = Action::NOTE)
58
+ edition.new_action(self, type, comment: comment)
59
+ end
60
+
61
+ def resolve_important_note(edition)
62
+ record_note(edition, nil, Action::IMPORTANT_NOTE_RESOLVED)
59
63
  end
60
64
 
61
65
  def create_edition(format, attributes = {})
@@ -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 = "22.2.0"
3
+ VERSION = "23.0.0"
4
4
  end
@@ -1001,34 +1001,6 @@ class EditionTest < ActiveSupport::TestCase
1001
1001
  end
1002
1002
  end
1003
1003
 
1004
- context "Important note" do
1005
- def set_note(edition, note)
1006
- edition.important_note = note
1007
- edition.save
1008
- edition.reload
1009
- end
1010
-
1011
- setup do
1012
- @edition = FactoryGirl.create(:guide_edition, panopticon_id: @artefact.id, state: "ready")
1013
- set_note(@edition, "This is an important note.")
1014
- end
1015
-
1016
- should "be able to add a important note to an edition" do
1017
- assert_equal "This is an important note.", @edition.important_note
1018
- end
1019
-
1020
- should "be able to update an existing important note" do
1021
- set_note(@edition, "New note.")
1022
- assert_equal "New note.", @edition.important_note
1023
- end
1024
-
1025
- should "should not exist when creating new editions" do
1026
- Edition.subclasses.each do |klass|
1027
- refute klass.fields_to_clone.include?(:important_note), "Important note is cloned in a #{klass}"
1028
- end
1029
- end
1030
- end
1031
-
1032
1004
  context "Tagging to collections" do
1033
1005
  setup do
1034
1006
  @edition = FactoryGirl.create(:guide_edition)
@@ -347,4 +347,15 @@ class WorkflowTest < ActiveSupport::TestCase
347
347
  user_2.request_amendments(edition, {comment: "More work needed"})
348
348
  assert edition.amends_needed?
349
349
  end
350
+
351
+ test "important_note returns last non-resolved important note" do
352
+ user = User.create(name: "Ben")
353
+ edition = template_guide
354
+ user.record_note(edition, 'this is an important note', Action::IMPORTANT_NOTE)
355
+ user.record_action(edition, 'request_review')
356
+ assert_equal edition.important_note.comment, 'this is an important note'
357
+
358
+ user.record_note(edition, nil, Action::IMPORTANT_NOTE_RESOLVED)
359
+ assert_nil edition.important_note
360
+ end
350
361
  end
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: 22.2.0
4
+ version: 23.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-10-28 00:00:00.000000000 Z
12
+ date: 2014-11-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bson_ext
@@ -464,7 +464,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
464
464
  version: '0'
465
465
  segments:
466
466
  - 0
467
- hash: -4313756439197638091
467
+ hash: -3179151873791569033
468
468
  required_rubygems_version: !ruby/object:Gem::Requirement
469
469
  none: false
470
470
  requirements:
@@ -473,7 +473,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
473
473
  version: '0'
474
474
  segments:
475
475
  - 0
476
- hash: -4313756439197638091
476
+ hash: -3179151873791569033
477
477
  requirements: []
478
478
  rubyforge_project:
479
479
  rubygems_version: 1.8.23