govuk_content_models 8.4.1 → 8.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,7 +21,7 @@ class Edition
21
21
  field :department, type: String
22
22
  field :rejected_count, type: Integer, default: 0
23
23
  field :tags, type: String
24
- field :editors_note, type: String
24
+ field :important_note, type: String
25
25
 
26
26
  field :assignee, type: String
27
27
  field :creator, type: String
@@ -0,0 +1,22 @@
1
+ class RenderedSpecialistDocument
2
+ include Mongoid::Document
3
+
4
+ field :slug, type: String
5
+ field :title, type: String
6
+ field :summary, type: String
7
+ field :body, type: String
8
+ field :opened_date, type: Date
9
+ field :closed_date, type: Date
10
+ field :case_type, type: String
11
+ field :case_state, type: String
12
+ field :market_sector, type: String
13
+ field :outcome_type, type: String
14
+ field :headers, type: Array
15
+
16
+ index "slug", unique: true
17
+
18
+ GOVSPEAK_FIELDS = []
19
+
20
+ validates :slug, uniqueness: true
21
+ validates_with SafeHtml
22
+ end
@@ -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 = "8.4.1"
3
+ VERSION = "8.5.0"
4
4
  end
@@ -0,0 +1,16 @@
1
+ module SpecialistDocumentFixtures
2
+ def basic_specialist_document_fields
3
+ {
4
+ slug: 'cma-cases/merger-investigation-2014',
5
+ title: "Merger Investigation 2014",
6
+ summary: "This is the summary of stuff going on in the Merger Investigation 2014",
7
+ state: "published",
8
+ body: "A body",
9
+ opened_date: '2012-04-21',
10
+ document_id: 'a-document-id',
11
+ market_sector: 'oil-and-gas',
12
+ case_type: 'some-case-type',
13
+ case_state: 'open'
14
+ }
15
+ end
16
+ end
@@ -984,9 +984,9 @@ class EditionTest < ActiveSupport::TestCase
984
984
  end
985
985
  end
986
986
 
987
- context "Editors note" do
987
+ context "Important note" do
988
988
  def set_note(edition, note)
989
- edition.editors_note = note
989
+ edition.important_note = note
990
990
  edition.save
991
991
  edition.reload
992
992
  end
@@ -996,18 +996,18 @@ class EditionTest < ActiveSupport::TestCase
996
996
  set_note(@edition, "This is an important note.")
997
997
  end
998
998
 
999
- should "be able to add an editors note to an edition" do
1000
- assert_equal "This is an important note.", @edition.editors_note
999
+ should "be able to add a important note to an edition" do
1000
+ assert_equal "This is an important note.", @edition.important_note
1001
1001
  end
1002
1002
 
1003
- should "be able to update an existing editors note" do
1003
+ should "be able to update an existing important note" do
1004
1004
  set_note(@edition, "New note.")
1005
- assert_equal "New note.", @edition.editors_note
1005
+ assert_equal "New note.", @edition.important_note
1006
1006
  end
1007
1007
 
1008
1008
  should "should not exist when creating new editions" do
1009
1009
  Edition.subclasses.each do |klass|
1010
- refute klass.fields_to_clone.include?(:editors_note), "Editors note is cloned in a #{klass}"
1010
+ refute klass.fields_to_clone.include?(:important_note), "Important note is cloned in a #{klass}"
1011
1011
  end
1012
1012
  end
1013
1013
  end
@@ -0,0 +1,52 @@
1
+ require "test_helper"
2
+ require "fixtures/specialist_document_fixtures"
3
+
4
+ class RenderedSpecialistDocumentTest < ActiveSupport::TestCase
5
+ include SpecialistDocumentFixtures
6
+
7
+ test "can assign all attributes" do
8
+ r = RenderedSpecialistDocument.new(basic_specialist_document_fields)
9
+ basic_specialist_document_fields.each do |k,v|
10
+ if (k =~ /date$/)
11
+ assert_equal Date.parse(v), r.send(k.to_sym)
12
+ else
13
+ assert_equal v, r.send(k.to_sym)
14
+ end
15
+ end
16
+ end
17
+
18
+ test "can persist" do
19
+ r = RenderedSpecialistDocument.new(basic_specialist_document_fields)
20
+ r.save!
21
+
22
+ assert_equal 1, RenderedSpecialistDocument.where(slug: r.slug).count
23
+ end
24
+
25
+ test "duplicate slugs disallowed" do
26
+ RenderedSpecialistDocument.create(slug: "my-slug")
27
+ second = RenderedSpecialistDocument.create(slug: "my-slug")
28
+
29
+ refute second.valid?
30
+ assert_equal 1, RenderedSpecialistDocument.count
31
+ end
32
+
33
+ test "has no govspeak fields" do
34
+ assert_equal [], RenderedSpecialistDocument::GOVSPEAK_FIELDS
35
+ end
36
+
37
+ test "can store headers hash" do
38
+ sample_headers = [
39
+ {
40
+ "text" => "Phase 1",
41
+ "level" => 2,
42
+ "id" => "phase-1",
43
+ "headers" => []
44
+ }
45
+ ]
46
+ sample_fields = basic_specialist_document_fields.merge(headers: sample_headers)
47
+ r = RenderedSpecialistDocument.create!(sample_fields)
48
+
49
+ found = RenderedSpecialistDocument.where(slug: r.slug).first
50
+ assert_equal sample_headers, found.headers
51
+ end
52
+ end
@@ -1,22 +1,10 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require "test_helper"
4
+ require "fixtures/specialist_document_fixtures"
4
5
 
5
6
  class SpecialistDocumentEditionTest < ActiveSupport::TestCase
6
- def basic_edition_fields
7
- {
8
- slug: 'cma-cases/merger-investigation-2014',
9
- title: "Merger Investigation 2014",
10
- summary: "This is the summary of stuff going on in the Merger Investigation 2014",
11
- state: "published",
12
- body: "A body",
13
- opened_date: '2012-04-21',
14
- document_id: 'a-document-id',
15
- market_sector: 'oil-and-gas',
16
- case_type: 'some-case-type',
17
- case_state: 'open'
18
- }
19
- end
7
+ include SpecialistDocumentFixtures
20
8
 
21
9
  setup do
22
10
  @original_asset_api_client = Attachable.asset_api_client
@@ -28,13 +16,13 @@ class SpecialistDocumentEditionTest < ActiveSupport::TestCase
28
16
  end
29
17
 
30
18
  should "have correct fields" do
31
- edition = SpecialistDocumentEdition.new(basic_edition_fields)
19
+ edition = SpecialistDocumentEdition.new(basic_specialist_document_fields)
32
20
 
33
- assert_equal basic_edition_fields[:title], edition.title
21
+ assert_equal basic_specialist_document_fields[:title], edition.title
34
22
  end
35
23
 
36
24
  should "be persistable" do
37
- edition = SpecialistDocumentEdition.create!(basic_edition_fields)
25
+ edition = SpecialistDocumentEdition.create!(basic_specialist_document_fields)
38
26
 
39
27
  found = SpecialistDocumentEdition.where(slug: edition.slug).first
40
28
  assert_equal found.attributes, edition.attributes
@@ -56,7 +44,7 @@ class SpecialistDocumentEditionTest < ActiveSupport::TestCase
56
44
  should "persist attachment record when document saved" do
57
45
  Attachable.asset_api_client.stubs(:create_asset)
58
46
 
59
- edition = SpecialistDocumentEdition.new(basic_edition_fields)
47
+ edition = SpecialistDocumentEdition.new(basic_specialist_document_fields)
60
48
  file = OpenStruct.new(original_filename: "document.pdf")
61
49
 
62
50
  edition.build_attachment(title: "baz", file: file)
@@ -69,7 +57,7 @@ class SpecialistDocumentEditionTest < ActiveSupport::TestCase
69
57
  end
70
58
 
71
59
  should "transmit attached file to asset manager when document saved" do
72
- edition = SpecialistDocumentEdition.new(basic_edition_fields)
60
+ edition = SpecialistDocumentEdition.new(basic_specialist_document_fields)
73
61
  file = OpenStruct.new(original_filename: "document.pdf")
74
62
 
75
63
  success_response = stub("asset manager response", id: "/test-id")
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: 8.4.1
4
+ version: 8.5.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-03-10 00:00:00.000000000 Z
12
+ date: 2014-03-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bson_ext
@@ -375,6 +375,7 @@ files:
375
375
  - app/models/parted.rb
376
376
  - app/models/place_edition.rb
377
377
  - app/models/programme_edition.rb
378
+ - app/models/rendered_specialist_document.rb
378
379
  - app/models/simple_smart_answer_edition.rb
379
380
  - app/models/simple_smart_answer_edition/node.rb
380
381
  - app/models/simple_smart_answer_edition/node/option.rb
@@ -403,6 +404,7 @@ files:
403
404
  - lib/govuk_content_models/version.rb
404
405
  - lib/mongoid/monkey_patches.rb
405
406
  - test/fixtures/contactotron_api_response.json
407
+ - test/fixtures/specialist_document_fixtures.rb
406
408
  - test/fixtures/uploads/image.jpg
407
409
  - test/models/artefact_action_test.rb
408
410
  - test/models/artefact_external_link_test.rb
@@ -428,6 +430,7 @@ files:
428
430
  - test/models/local_service_test.rb
429
431
  - test/models/local_transaction_edition_test.rb
430
432
  - test/models/overview_dashboard_test.rb
433
+ - test/models/rendered_specialist_document_test.rb
431
434
  - test/models/simple_smart_answer_edition_test.rb
432
435
  - test/models/simple_smart_answer_node_test.rb
433
436
  - test/models/simple_smart_answer_option_test.rb
@@ -460,7 +463,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
460
463
  version: '0'
461
464
  segments:
462
465
  - 0
463
- hash: 61628774300595589
466
+ hash: -2243778202903254649
464
467
  required_rubygems_version: !ruby/object:Gem::Requirement
465
468
  none: false
466
469
  requirements:
@@ -469,7 +472,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
469
472
  version: '0'
470
473
  segments:
471
474
  - 0
472
- hash: 61628774300595589
475
+ hash: -2243778202903254649
473
476
  requirements: []
474
477
  rubyforge_project:
475
478
  rubygems_version: 1.8.23
@@ -478,6 +481,7 @@ specification_version: 3
478
481
  summary: Shared models for Panopticon and Publisher, as a Rails Engine
479
482
  test_files:
480
483
  - test/fixtures/contactotron_api_response.json
484
+ - test/fixtures/specialist_document_fixtures.rb
481
485
  - test/fixtures/uploads/image.jpg
482
486
  - test/models/artefact_action_test.rb
483
487
  - test/models/artefact_external_link_test.rb
@@ -503,6 +507,7 @@ test_files:
503
507
  - test/models/local_service_test.rb
504
508
  - test/models/local_transaction_edition_test.rb
505
509
  - test/models/overview_dashboard_test.rb
510
+ - test/models/rendered_specialist_document_test.rb
506
511
  - test/models/simple_smart_answer_edition_test.rb
507
512
  - test/models/simple_smart_answer_node_test.rb
508
513
  - test/models/simple_smart_answer_option_test.rb