govuk_content_models 28.7.1 → 28.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 28.8.0
2
+
3
+ - Add `redirect_url` to artefact
4
+
1
5
  ## 28.7.1
2
6
 
3
7
  - Change the scheduled publishing timestamp to be London local time
@@ -48,6 +48,7 @@ class Artefact
48
48
  field "need_extended_font", type: Boolean, default: false
49
49
  field "latest_change_note", type: String
50
50
  field "public_timestamp", type: DateTime
51
+ field "redirect_url", type: String
51
52
 
52
53
  index "slug", :unique => true
53
54
 
@@ -173,6 +174,7 @@ class Artefact
173
174
  validates_with CannotEditSlugIfEverPublished
174
175
  validate :validate_prefixes_and_paths
175
176
  validate :format_of_new_need_ids, if: :need_ids_changed?
177
+ validate :validate_redirect_url
176
178
 
177
179
  scope :relatable_items, proc {
178
180
  where(:kind.ne => "completed_transaction", :state.ne => "archived")
@@ -404,4 +406,11 @@ class Artefact
404
406
  rescue URI::InvalidURIError
405
407
  false
406
408
  end
409
+
410
+ def validate_redirect_url
411
+ return unless self.redirect_url.present?
412
+ unless valid_url_path?(self.redirect_url)
413
+ errors[:redirect_url] << "is not a valid redirect target"
414
+ end
415
+ end
407
416
  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 = "28.7.1"
3
+ VERSION = "28.8.0"
4
4
  end
@@ -231,6 +231,19 @@ class ArtefactTest < ActiveSupport::TestCase
231
231
  end
232
232
  end
233
233
 
234
+ should "validate redirect_url" do
235
+ artefact = FactoryGirl.create(:artefact)
236
+
237
+ artefact.redirect_url = "foobar"
238
+ refute artefact.valid?
239
+
240
+ artefact.redirect_url = "/foobar"
241
+ assert artefact.valid?
242
+
243
+ artefact.redirect_url = "http://foo.bar/"
244
+ refute artefact.valid?
245
+ end
246
+
234
247
  test "should translate kind into internally normalised form" do
235
248
  a = Artefact.new(kind: "benefit / scheme")
236
249
  a.normalise
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: 28.7.1
4
+ version: 28.8.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: 2015-06-09 00:00:00.000000000 Z
12
+ date: 2015-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bson_ext
@@ -478,7 +478,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
478
478
  version: '0'
479
479
  segments:
480
480
  - 0
481
- hash: -1030593290210728004
481
+ hash: -3441532495869852238
482
482
  required_rubygems_version: !ruby/object:Gem::Requirement
483
483
  none: false
484
484
  requirements:
@@ -487,7 +487,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
487
487
  version: '0'
488
488
  segments:
489
489
  - 0
490
- hash: -1030593290210728004
490
+ hash: -3441532495869852238
491
491
  requirements: []
492
492
  rubyforge_project:
493
493
  rubygems_version: 1.8.23