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 +4 -4
- data/CHANGELOG.md +4 -0
- data/app/models/edition.rb +5 -1
- data/lib/govuk_content_models/test_helpers/factories.rb +1 -1
- data/lib/govuk_content_models/version.rb +1 -1
- data/test/models/edition_test.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 958538091c31245d3c30d1007839a122b43e661b
|
4
|
+
data.tar.gz: d80419824d3224945339326583163a70c018fe9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce9da9e40bc9b2fb21aaa114b1713e4c495b0ce74ed7d5370d5be96d91a0fd622fd77930078701913d7afdbbe77d3ec936fd6a858efe282bcaf1412e3afb5b44
|
7
|
+
data.tar.gz: dd73d319e49c6c15db262f85f25e8d2eb6ebe9389a76dfc62ed5325592eeac4b95b30c00830dc9dfe1d5960109f4917acde09f3065878ea86cb3186645abea2d
|
data/CHANGELOG.md
CHANGED
data/app/models/edition.rb
CHANGED
@@ -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"
|
data/test/models/edition_test.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bson_ext
|