govuk_content_models 10.2.1 → 10.2.2

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.2
2
+
3
+ - Prevent a Mongo error when tag_ids are set to nil
4
+
1
5
  ## 10.2.0
2
6
 
3
7
  * 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.
@@ -59,8 +59,12 @@ module Taggable
59
59
  # as documented on http://mongoid.org/en/mongoid/docs/documents.html
60
60
  tags
61
61
 
62
+ # Make sure that 'values' is an array. This stops the method blowing up
63
+ # if nil is provided.
64
+ values_as_array = Array(values)
65
+
62
66
  # This will raise a Tag::MissingTags exception unless all the tags exist
63
- new_tags = Tag.by_tag_ids!(values, tag_type)
67
+ new_tags = Tag.by_tag_ids!(values_as_array, tag_type)
64
68
 
65
69
  @tags.reject! { |t| t.tag_type == tag_type }
66
70
  @tags += new_tags
@@ -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.1"
3
+ VERSION = "10.2.2"
4
4
  end
@@ -111,4 +111,16 @@ class TaggableTest < ActiveSupport::TestCase
111
111
 
112
112
  assert_equal ['bacon'], @item.keyword_ids
113
113
  end
114
+
115
+ test "can set tags of type to be nil" do
116
+ @item.section_ids = nil
117
+ @item.save!
118
+
119
+ assert_equal [], @item.section_ids
120
+
121
+ @item.sections = nil
122
+ @item.save!
123
+
124
+ assert_equal [], @item.section_ids
125
+ end
114
126
  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.1
4
+ version: 10.2.2
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-15 00:00:00.000000000 Z
12
+ date: 2014-04-17 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: 2178874985606860121
468
+ hash: -333607112453720263
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: 2178874985606860121
477
+ hash: -333607112453720263
478
478
  requirements: []
479
479
  rubyforge_project:
480
480
  rubygems_version: 1.8.23