govuk_content_models 31.2.2 → 31.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1c8b1bd6abb500ea8be7aa4e1d19b2b3f8491d2
4
- data.tar.gz: 3d67a926016a63a09f2320a97da203eb49032345
3
+ metadata.gz: 958538091c31245d3c30d1007839a122b43e661b
4
+ data.tar.gz: d80419824d3224945339326583163a70c018fe9b
5
5
  SHA512:
6
- metadata.gz: 912c6673c12165718b90b0ab1fca381c9588cb0dc232f2dbeb61d454f1fe5ef20201d56ed4891224cc03d0846ea950864d914939fa8820dcad9a4db2101159b2
7
- data.tar.gz: 3e8c841fd6212244b754967511ea4cb0ee5b6626d3de3dcc262cfd6ace82e723954d6a1e1f43235938a579fa1458eae36a4bed9f9bc77797412f59dead5015e4
6
+ metadata.gz: ce9da9e40bc9b2fb21aaa114b1713e4c495b0ce74ed7d5370d5be96d91a0fd622fd77930078701913d7afdbbe77d3ec936fd6a858efe282bcaf1412e3afb5b44
7
+ data.tar.gz: dd73d319e49c6c15db262f85f25e8d2eb6ebe9389a76dfc62ed5325592eeac4b95b30c00830dc9dfe1d5960109f4917acde09f3065878ea86cb3186645abea2d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 31.3.0
4
+
5
+ - Include matching type-specific fields when converting editions
6
+
3
7
  ## 31.2.2
4
8
 
5
9
  - Add "official_statistics" artefact format
@@ -174,7 +174,7 @@ class Edition
174
174
  if target_class == self.class
175
175
  base_field_keys + type_specific_field_keys
176
176
  else
177
- base_field_keys
177
+ base_field_keys + common_type_specific_field_keys(target_class)
178
178
  end
179
179
  end
180
180
 
@@ -341,4 +341,8 @@ private
341
341
  def type_specific_field_keys
342
342
  (self.fields.keys - Edition.fields.keys).map(&:to_sym)
343
343
  end
344
+
345
+ def common_type_specific_field_keys(target_class)
346
+ ((self.fields.keys & target_class.fields.keys) - Edition.fields.keys).map(&:to_sym)
347
+ end
344
348
  end
@@ -217,7 +217,7 @@ FactoryGirl.define do
217
217
  lgil_code 0
218
218
  end
219
219
 
220
- factory :place_edition do
220
+ factory :place_edition, parent: :edition, class: 'PlaceEdition' do
221
221
  title "Far far away"
222
222
  introduction "Test introduction"
223
223
  more_information "More information"
@@ -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 = "31.2.2"
3
+ VERSION = "31.3.0"
4
4
  end
@@ -417,6 +417,12 @@ class EditionTest < ActiveSupport::TestCase
417
417
  assert_equal 7, new_edition.parts.size #there are 5 'default' parts plus an additional two created by the factory
418
418
  end
419
419
 
420
+ test "knows the common fields of two edition subclasses" do
421
+ to_copy = Set.new([:introduction, :need_to_know, :more_information])
422
+ result = Set.new(TransactionEdition.new.fields_to_copy(PlaceEdition))
423
+ assert to_copy.proper_subset?(result)
424
+ end
425
+
420
426
  # Mongoid 2.x marks array fields as dirty whenever they are accessed.
421
427
  # See https://github.com/mongoid/mongoid/issues/2311
422
428
  # This behaviour has been patched in lib/mongoid/monkey_patches.rb
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_content_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 31.2.2
4
+ version: 31.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Battley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-21 00:00:00.000000000 Z
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bson_ext