govuk_content_models 42.0.0 → 42.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/app/traits/attachable.rb +2 -2
  4. data/govuk_content_models.gemspec +1 -2
  5. data/lib/govuk_content_models/version.rb +1 -1
  6. metadata +3 -83
  7. data/test/fixtures/uploads/image.jpg +0 -0
  8. data/test/models/action_test.rb +0 -13
  9. data/test/models/artefact_action_test.rb +0 -130
  10. data/test/models/artefact_external_link_test.rb +0 -32
  11. data/test/models/artefact_test.rb +0 -482
  12. data/test/models/business_support/business_size_test.rb +0 -25
  13. data/test/models/business_support/business_type_test.rb +0 -25
  14. data/test/models/business_support/location_test.rb +0 -25
  15. data/test/models/business_support/purpose_test.rb +0 -29
  16. data/test/models/business_support/sector_test.rb +0 -25
  17. data/test/models/business_support/stage_test.rb +0 -25
  18. data/test/models/business_support/support_type_test.rb +0 -25
  19. data/test/models/business_support_edition_test.rb +0 -282
  20. data/test/models/campaign_edition_test.rb +0 -91
  21. data/test/models/completed_transaction_edition_test.rb +0 -56
  22. data/test/models/downtime_test.rb +0 -93
  23. data/test/models/edition_scheduled_for_publishing_test.rb +0 -91
  24. data/test/models/edition_test.rb +0 -1185
  25. data/test/models/help_page_edition_test.rb +0 -43
  26. data/test/models/licence_edition_test.rb +0 -105
  27. data/test/models/local_service_test.rb +0 -6
  28. data/test/models/local_transaction_edition_test.rb +0 -37
  29. data/test/models/overview_dashboard_test.rb +0 -46
  30. data/test/models/parted_test.rb +0 -26
  31. data/test/models/prerendered_entity_tests.rb +0 -46
  32. data/test/models/rendered_manual_test.rb +0 -10
  33. data/test/models/simple_smart_answer_edition_test.rb +0 -211
  34. data/test/models/simple_smart_answer_node_test.rb +0 -134
  35. data/test/models/simple_smart_answer_option_test.rb +0 -97
  36. data/test/models/time_zone_test.rb +0 -48
  37. data/test/models/transaction_edition_test.rb +0 -36
  38. data/test/models/travel_advice_edition_test.rb +0 -469
  39. data/test/models/user_test.rb +0 -155
  40. data/test/models/video_edition_test.rb +0 -64
  41. data/test/models/workflow_test.rb +0 -498
  42. data/test/test_helper.rb +0 -61
  43. data/test/traits/attachable_test.rb +0 -244
  44. data/test/validators/link_validator_test.rb +0 -86
  45. data/test/validators/safe_html_validator_test.rb +0 -83
  46. data/test/validators/slug_validator_test.rb +0 -109
@@ -1,109 +0,0 @@
1
- require 'test_helper'
2
-
3
- class SlugTest < ActiveSupport::TestCase
4
- class Dummy
5
- include Mongoid::Document
6
-
7
- field "name", type: String
8
- field "slug", type: String
9
- field "kind", type: String
10
-
11
- validates :name, presence: true
12
- validates :slug, presence: true, uniqueness: true, slug: true
13
- end
14
-
15
- def document_with_slug(slug, override_options = {})
16
- default_options = {
17
- name: "Test",
18
- slug: slug
19
- }
20
- Dummy.new(default_options.merge(override_options))
21
- end
22
-
23
- context "default slugs" do
24
- should "reject url paths" do
25
- refute document_with_slug("path/not-allowed").valid?
26
- end
27
-
28
- should "allow a normal slug" do
29
- assert document_with_slug("normal-slug").valid?
30
- end
31
-
32
- should "allow consecutive dashes in a slug" do
33
- # Gems like friendly_id use -- to de-dup slug collisions
34
- assert document_with_slug("normal-slug--1").valid?
35
- end
36
-
37
- should "allow a done page slug" do
38
- assert document_with_slug("done/normal-slug").valid?
39
- end
40
- end
41
-
42
- context "Foreign travel advice pages" do
43
- should "allow a travel-advice page to start with 'foreign-travel-advice/'" do
44
- assert document_with_slug("foreign-travel-advice/aruba", kind: "travel-advice").valid?
45
- end
46
-
47
- should "not allow other types to start with 'foreign-travel-advice/'" do
48
- refute document_with_slug("foreign-travel-advice/aruba", kind: "answer").valid?
49
- end
50
- end
51
-
52
- context "Help pages" do
53
- should "must start with help/" do
54
- refute document_with_slug("test", kind: "help_page").valid?
55
- assert document_with_slug("help/test", kind: "help_page").valid?
56
- end
57
-
58
- should "not allow non-help pages to start with help/" do
59
- refute document_with_slug("help/test", kind: "answer").valid?
60
- end
61
- end
62
-
63
- context "Inside government slugs" do
64
- should "allow slug starting government/" do
65
- refute document_with_slug("test", kind: "policy").valid?
66
- assert document_with_slug("government/test", kind: "policy").valid?
67
- end
68
-
69
- should "allow abritrarily deep slugs" do
70
- assert document_with_slug("government/test/foo", kind: "policy").valid?
71
- assert document_with_slug("government/test/foo/bar", kind: "policy").valid?
72
- end
73
-
74
- should "allow . in slugs" do
75
- assert document_with_slug("government/world-location-news/221033.pt", kind: "news_story").valid?
76
- end
77
- end
78
-
79
- context "Detailed guides slugs" do
80
- should "allow a '/' in the slug" do
81
- assert document_with_slug("guidance/british-forces-overseas-posting-cyprus", kind: "detailed_guide").valid?
82
- end
83
-
84
- should "allow only one '/' in the slug" do
85
- refute document_with_slug("guidance/british-forces-overseas-posting-cyprus/more-information", kind: "detailed_guide").valid?
86
- end
87
-
88
- should "ensure it allows slugs that start at the root" do
89
- assert document_with_slug("british-forces-overseas-posting-cyprus", kind: "detailed_guide").valid?
90
- end
91
- #TODO: disallow this once guidance migration has been complete
92
- end
93
-
94
- context "Manual pages" do
95
- should "allow slugs starting guidance/" do
96
- refute document_with_slug("manuals/a-manual", kind: "manual").valid?
97
- assert document_with_slug("guidance/a-manual", kind: "manual").valid?
98
- end
99
-
100
- should "allow two or three path parts" do
101
- refute document_with_slug("guidance", kind: "manual").valid?
102
- assert document_with_slug("guidance/a-manual", kind: "manual").valid?
103
- end
104
-
105
- should "not allow invalid path segments" do
106
- refute document_with_slug("guidance/bad.manual.slug", kind: "manual").valid?
107
- end
108
- end
109
- end