govuk_content_models 36.0.0 → 37.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78511b72b76121386601a27a3406e48cdbdb12ee
4
- data.tar.gz: 8b6f3505b3570a4e9015c752ef6b31eaaa3d9917
3
+ metadata.gz: 509f173b9c1d06101cb2b41fb74ae031a30fd99e
4
+ data.tar.gz: f2e8f1137985b74e33009062e68404774cc08be9
5
5
  SHA512:
6
- metadata.gz: fc472a37b621228b0d1dc12a61a429a38d8ffab42af3d682afbc100a83c32dfeaad62a887cebb5776ecb5cd5d515a196e9efc614544e23f38f581a11a65c7446
7
- data.tar.gz: 7cfe6d0c2585856f333686db8bf9d1a9055752fdd01f381aae4a19647d7218a61b9932145ac32aeb505614ca8acf73a4c404e8e28b96183fc2a196f6cad1833b
6
+ metadata.gz: 19d98c962dcb6fcaf9bc02f4c083ede71233ef2fb2b94a350cca2165b9edab0933b67e9990194ce6008d48e1fbe26a33f99a95ee5bb60116349427edf0a592a7
7
+ data.tar.gz: 3c873f461815c6b99b35675f6daf0446ffb64cbb0484f63768c0af40ab0b9d72a4d048567be3619efb1d813d279fe8a84fbaed5b74969395e13c80ee6a701cfb
@@ -3,36 +3,10 @@ module PresentationToggles
3
3
 
4
4
  included do
5
5
  field :presentation_toggles, type: Hash, default: default_presentation_toggles
6
- validates_presence_of :organ_donor_registration_url, if: :promote_organ_donor_registration?
7
6
  validates :promotion_choice_url, presence: true, if: :promotes_something?
8
7
  validates :promotion_choice, inclusion: { in: %w(none organ_donor register_to_vote) }
9
8
  end
10
9
 
11
- def promote_organ_donor_registration=(value)
12
- value = value.is_a?(Boolean) ? value : value != '0' # if assigned using a checkbox
13
- organ_donor_registration_key['promote_organ_donor_registration'] = value
14
- end
15
-
16
- def promote_organ_donor_registration
17
- organ_donor_registration_key['promote_organ_donor_registration']
18
- end
19
- alias_method :promote_organ_donor_registration?, :promote_organ_donor_registration
20
-
21
- def organ_donor_registration_url=(value)
22
- organ_donor_registration_key['organ_donor_registration_url'] = value
23
- end
24
-
25
- def organ_donor_registration_url
26
- organ_donor_registration_key['organ_donor_registration_url']
27
- end
28
-
29
- def organ_donor_registration_key
30
- unless presentation_toggles.key? 'organ_donor_registration'
31
- presentation_toggles['organ_donor_registration'] = self.class.default_presentation_toggles['organ_donor_registration']
32
- end
33
- presentation_toggles['organ_donor_registration']
34
- end
35
-
36
10
  def promotion_choice=(value)
37
11
  promotion_choice_key["choice"] = value
38
12
  end
@@ -42,17 +16,8 @@ module PresentationToggles
42
16
  end
43
17
 
44
18
  def promotion_choice
45
- has_legacy_promote = promote_organ_donor_registration
46
19
  choice = promotion_choice_key["choice"]
47
- if choice.empty?
48
- if has_legacy_promote
49
- "organ_donor"
50
- else
51
- "none"
52
- end
53
- else
54
- choice
55
- end
20
+ choice.empty? ? "none" : choice
56
21
  end
57
22
 
58
23
  def promotes_something?
@@ -60,8 +25,7 @@ module PresentationToggles
60
25
  end
61
26
 
62
27
  def promotion_choice_url
63
- url = promotion_choice_key["url"]
64
- url.empty? ? organ_donor_registration_url : url
28
+ promotion_choice_key["url"]
65
29
  end
66
30
 
67
31
  def promotion_choice_key
@@ -74,11 +38,6 @@ module PresentationToggles
74
38
  module ClassMethods
75
39
  def default_presentation_toggles
76
40
  {
77
- 'organ_donor_registration' =>
78
- {
79
- 'promote_organ_donor_registration' => false,
80
- 'organ_donor_registration_url' => ''
81
- },
82
41
  'promotion_choice' =>
83
42
  {
84
43
  'choice' => '',
@@ -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 = "36.0.0"
3
+ VERSION = "37.0.0"
4
4
  end
@@ -3,35 +3,17 @@ require "test_helper"
3
3
  class CompletedTransactionEditionTest < ActiveSupport::TestCase
4
4
  test "controls whether organ donor registration promotion should be displayed on a completed transaction page" do
5
5
  completed_transaction_edition = FactoryGirl.create(:completed_transaction_edition)
6
- refute completed_transaction_edition.promote_organ_donor_registration?
6
+ refute completed_transaction_edition.promotes_something?
7
7
 
8
- completed_transaction_edition.promote_organ_donor_registration = true
9
- completed_transaction_edition.organ_donor_registration_url = "https://www.organdonation.nhs.uk/registration/"
10
- completed_transaction_edition.save!
11
- assert completed_transaction_edition.reload.promote_organ_donor_registration?
8
+ completed_transaction_edition.promotion_choice = "organ_donor"
9
+ completed_transaction_edition.promotion_choice_url = "https://www.organdonation.nhs.uk/registration/"
12
10
 
13
- completed_transaction_edition.promote_organ_donor_registration = false
14
11
  completed_transaction_edition.save!
15
- refute completed_transaction_edition.reload.promote_organ_donor_registration?
16
- end
17
-
18
- test "stores organ donor registration promotion URL" do
19
- completed_transaction_edition = FactoryGirl.build(:completed_transaction_edition,
20
- promote_organ_donor_registration: true)
12
+ assert completed_transaction_edition.reload.promotes_something?
21
13
 
22
- completed_transaction_edition.organ_donor_registration_url = "https://www.organdonation.nhs.uk/registration/"
14
+ completed_transaction_edition.promotion_choice = ''
23
15
  completed_transaction_edition.save!
24
-
25
- assert_equal "https://www.organdonation.nhs.uk/registration/",
26
- completed_transaction_edition.reload.organ_donor_registration_url
27
- end
28
-
29
- test "invalid if organ_donor_registration_url is not specified when promotion is on" do
30
- completed_transaction_edition = FactoryGirl.build(:completed_transaction_edition,
31
- promote_organ_donor_registration: true, organ_donor_registration_url: "")
32
-
33
- assert completed_transaction_edition.invalid?
34
- assert_includes completed_transaction_edition.errors[:organ_donor_registration_url], "can't be blank"
16
+ refute completed_transaction_edition.reload.promotes_something?
35
17
  end
36
18
 
37
19
  test "invalid if promotion_choice_url is not specified when a promotion choice is made" do
@@ -71,47 +53,4 @@ class CompletedTransactionEditionTest < ActiveSupport::TestCase
71
53
  assert_equal "register_to_vote", completed_transaction_edition.reload.promotion_choice
72
54
  assert_equal "https://www.gov.uk/register-to-vote", completed_transaction_edition.promotion_choice_url
73
55
  end
74
-
75
- test "stores promotion choice and URL on legacy documents" do
76
- completed_transaction_edition = FactoryGirl.build(:completed_transaction_edition,
77
- presentation_toggles: {
78
- 'organ_donor_registration' => {
79
- 'promote_organ_donor_registration' => false,
80
- 'organ_donor_registration_url' => ''
81
- },
82
- }
83
- )
84
- completed_transaction_edition.save(validate: false)
85
- completed_transaction_edition.reload
86
-
87
- completed_transaction_edition.promotion_choice = "register_to_vote"
88
- completed_transaction_edition.promotion_choice_url = "https://www.gov.uk/register-to-vote"
89
- completed_transaction_edition.save!
90
-
91
- assert_equal "register_to_vote", completed_transaction_edition.reload.promotion_choice
92
- assert_equal "https://www.gov.uk/register-to-vote", completed_transaction_edition.promotion_choice_url
93
-
94
- completed_transaction_edition.promotion_choice = "none"
95
- completed_transaction_edition.save!
96
-
97
- assert_equal "none", completed_transaction_edition.reload.promotion_choice
98
-
99
- completed_transaction_edition.promotion_choice = "organ_donor"
100
- completed_transaction_edition.promotion_choice_url = "https://www.organdonation.nhs.uk/registration/"
101
- completed_transaction_edition.save!
102
-
103
- assert_equal "organ_donor", completed_transaction_edition.reload.promotion_choice
104
- assert_equal "https://www.organdonation.nhs.uk/registration/", completed_transaction_edition.promotion_choice_url
105
- end
106
-
107
- test "passes through legacy organ donor info" do
108
- completed_transaction_edition = FactoryGirl.build(:completed_transaction_edition,
109
- promote_organ_donor_registration: true)
110
-
111
- completed_transaction_edition.organ_donor_registration_url = "https://www.organdonation.nhs.uk/registration/"
112
- completed_transaction_edition.save!
113
-
114
- assert_equal "organ_donor", completed_transaction_edition.reload.promotion_choice
115
- assert_equal "https://www.organdonation.nhs.uk/registration/", completed_transaction_edition.promotion_choice_url
116
- end
117
56
  end
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: 36.0.0
4
+ version: 37.0.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: 2016-06-15 00:00:00.000000000 Z
11
+ date: 2016-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bson_ext