govuk_content_models 10.1.2 → 10.2.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,7 @@
1
+ ## 10.2.0
2
+
3
+ * Adding a nil check around `need_ids` field in validations and using the correct gem version number to reflect the new feature that got added in 10.1.1.
4
+
1
5
  ## 10.1.2
2
6
 
3
7
  * Use `\A\z` anchors instead of `^$` in need ID validation regex
@@ -377,10 +377,13 @@ class Artefact
377
377
  end
378
378
 
379
379
  def filter_out_empty_need_ids
380
+ return if need_ids.blank?
380
381
  need_ids.reject!(&:blank?)
381
382
  end
382
383
 
383
384
  def format_of_new_need_ids
385
+ return if need_ids.blank?
386
+
384
387
  # http://api.rubyonrails.org/classes/ActiveModel/Dirty.html
385
388
  new_need_ids = need_ids_was.blank? ? need_ids : need_ids - need_ids_was
386
389
  errors.add(:need_ids, "must be six-digit integers") if new_need_ids.any? {|need_id| need_id !~ /\A\d{6}\z/ }
@@ -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.1.2"
3
+ VERSION = "10.2.0"
4
4
  end
@@ -97,6 +97,13 @@ class ArtefactTest < ActiveSupport::TestCase
97
97
  assert_empty FactoryGirl.build(:artefact).need_ids
98
98
  end
99
99
 
100
+ should "do validations if nil" do
101
+ artefact = FactoryGirl.create(:artefact, need_ids: ["100001"])
102
+ artefact.need_ids = nil
103
+
104
+ assert_nothing_raised { artefact.valid? }
105
+ end
106
+
100
107
  should "filter out empty strings" do
101
108
  artefact = FactoryGirl.create(:artefact, need_ids: ["", "100002"])
102
109
  assert_equal ["100002"], artefact.reload.need_ids
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.1.2
4
+ version: 10.2.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-14 00:00:00.000000000 Z
12
+ date: 2014-04-15 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: -2514232089714122932
468
+ hash: 1908367784692454141
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: -2514232089714122932
477
+ hash: 1908367784692454141
478
478
  requirements: []
479
479
  rubyforge_project:
480
480
  rubygems_version: 1.8.23