govuk_content_models 36.0.0 → 37.0.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 509f173b9c1d06101cb2b41fb74ae031a30fd99e
|
4
|
+
data.tar.gz: f2e8f1137985b74e33009062e68404774cc08be9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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' => '',
|
@@ -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.
|
6
|
+
refute completed_transaction_edition.promotes_something?
|
7
7
|
|
8
|
-
completed_transaction_edition.
|
9
|
-
completed_transaction_edition.
|
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
|
-
|
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.
|
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:
|
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-
|
11
|
+
date: 2016-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bson_ext
|