govuk_content_models 10.2.2 → 10.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
+ ## 10.3.0
2
+
3
+ * Add artefacts for specialist sector tags
4
+
1
5
  ## 10.2.2
2
6
 
3
- - Prevent a Mongo error when tag_ids are set to nil
7
+ - Prevent a Mongo error when tag_ids are set to nil
4
8
 
5
9
  ## 10.2.0
6
10
 
@@ -122,7 +122,8 @@ class Artefact
122
122
  "transparency",
123
123
  "world_location_news_article",
124
124
  "worldwide_priority",
125
- "written_statement"]
125
+ "written_statement"],
126
+ "panopticon" => ["specialist_sector"],
126
127
  }.freeze
127
128
 
128
129
  FORMATS = FORMATS_BY_DEFAULT_OWNING_APP.values.flatten
@@ -7,6 +7,7 @@ class SlugValidator < ActiveModel::EachValidator
7
7
  HelpPageValidator,
8
8
  GovernmentPageValidator,
9
9
  SpecialistDocumentPageValidator,
10
+ BrowsePageValidator,
10
11
  DefaultValidator
11
12
  ].map { |klass| klass.new(record, attribute, value) }
12
13
 
@@ -114,6 +115,21 @@ protected
114
115
  end
115
116
  end
116
117
 
118
+ class BrowsePageValidator < InstanceValidator
119
+ def applicable?
120
+ of_kind?('specialist_sector')
121
+ end
122
+
123
+ def validate!
124
+ unless [1, 2].include?(url_parts.size)
125
+ record.errors[attribute] << "must contains one or two path parts"
126
+ end
127
+ unless url_parts.all? { |url_part| valid_slug?(url_part) }
128
+ record.errors[attribute] << "must be usable in a URL"
129
+ end
130
+ end
131
+ end
132
+
117
133
  class DefaultValidator < InstanceValidator
118
134
  def applicable?
119
135
  true
@@ -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 = "10.2.2"
3
+ VERSION = "10.3.0"
4
4
  end
@@ -85,4 +85,22 @@ class SlugTest < ActiveSupport::TestCase
85
85
  refute document_with_slug("some-finder/my-specialist-document/not-allowed", kind: "specialist-document").valid?
86
86
  end
87
87
  end
88
+
89
+ context "Specialist sector browse pages" do
90
+ should "allow a single path part" do
91
+ assert document_with_slug("oil-and-gas", kind: "specialist_sector").valid?
92
+ end
93
+
94
+ should "allow two path parts" do
95
+ assert document_with_slug("oil-and-gas/fields-and-wells", kind: "specialist_sector").valid?
96
+ end
97
+
98
+ should "not allow three path parts" do
99
+ refute document_with_slug("oil-and-gas/fields-and-wells/development", kind: "specialist_sector").valid?
100
+ end
101
+
102
+ should "not allow invalid path segments" do
103
+ refute document_with_slug("oil-and-gas/not.a.valid.slug", kind: "specialist_sector").valid?
104
+ end
105
+ end
88
106
  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: 10.2.2
4
+ version: 10.3.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-04-17 00:00:00.000000000 Z
12
+ date: 2014-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bson_ext
@@ -465,7 +465,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
465
465
  version: '0'
466
466
  segments:
467
467
  - 0
468
- hash: -333607112453720263
468
+ hash: -1098545351621195273
469
469
  required_rubygems_version: !ruby/object:Gem::Requirement
470
470
  none: false
471
471
  requirements:
@@ -474,7 +474,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
474
474
  version: '0'
475
475
  segments:
476
476
  - 0
477
- hash: -333607112453720263
477
+ hash: -1098545351621195273
478
478
  requirements: []
479
479
  rubyforge_project:
480
480
  rubygems_version: 1.8.23