govuk_content_models 28.5.0 → 28.6.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.
- data/CHANGELOG.md +4 -0
- data/LICENSE +1 -1
- data/app/models/completed_transaction_edition.rb +2 -0
- data/lib/govuk_content_models/presentation_toggles.rb +39 -0
- data/lib/govuk_content_models/version.rb +1 -1
- data/lib/govuk_content_models.rb +1 -0
- data/test/models/completed_transaction_edition_test.rb +36 -0
- metadata +7 -4
data/CHANGELOG.md
CHANGED
data/LICENSE
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module PresentationToggles
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
included do
|
|
5
|
+
field :presentation_toggles, type: Hash, default: default_presentation_toggles
|
|
6
|
+
validates_presence_of :organ_donor_registration_url, if: :promote_organ_donor_registration?
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def promote_organ_donor_registration=(value)
|
|
10
|
+
value = value.is_a?(Boolean) ? value : value != '0' # if assigned using a checkbox
|
|
11
|
+
organ_donor_registration_key['promote_organ_donor_registration'] = value
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def promote_organ_donor_registration
|
|
15
|
+
organ_donor_registration_key['promote_organ_donor_registration']
|
|
16
|
+
end
|
|
17
|
+
alias_method :promote_organ_donor_registration?, :promote_organ_donor_registration
|
|
18
|
+
|
|
19
|
+
def organ_donor_registration_url=(value)
|
|
20
|
+
organ_donor_registration_key['organ_donor_registration_url'] = value
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def organ_donor_registration_url
|
|
24
|
+
organ_donor_registration_key['organ_donor_registration_url']
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def organ_donor_registration_key
|
|
28
|
+
presentation_toggles['organ_donor_registration']
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
module ClassMethods
|
|
32
|
+
def default_presentation_toggles
|
|
33
|
+
{
|
|
34
|
+
'organ_donor_registration' =>
|
|
35
|
+
{ 'promote_organ_donor_registration' => false, 'organ_donor_registration_url' => '' }
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
data/lib/govuk_content_models.rb
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class CompletedTransactionEditionTest < ActiveSupport::TestCase
|
|
4
|
+
test "controls whether organ donor registration promotion should be displayed on a completed transaction page" do
|
|
5
|
+
completed_transaction_edition = FactoryGirl.create(:completed_transaction_edition)
|
|
6
|
+
refute completed_transaction_edition.promote_organ_donor_registration?
|
|
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?
|
|
12
|
+
|
|
13
|
+
completed_transaction_edition.promote_organ_donor_registration = false
|
|
14
|
+
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)
|
|
21
|
+
|
|
22
|
+
completed_transaction_edition.organ_donor_registration_url = "https://www.organdonation.nhs.uk/registration/"
|
|
23
|
+
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"
|
|
35
|
+
end
|
|
36
|
+
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: 28.
|
|
4
|
+
version: 28.6.0
|
|
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: 2015-
|
|
12
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bson_ext
|
|
@@ -406,6 +406,7 @@ files:
|
|
|
406
406
|
- lib/govuk_content_models/action_processors/schedule_for_publishing_processor.rb
|
|
407
407
|
- lib/govuk_content_models/action_processors/send_fact_check_processor.rb
|
|
408
408
|
- lib/govuk_content_models/action_processors/skip_fact_check_processor.rb
|
|
409
|
+
- lib/govuk_content_models/presentation_toggles.rb
|
|
409
410
|
- lib/govuk_content_models/require_all.rb
|
|
410
411
|
- lib/govuk_content_models/test_helpers/action_processor_helpers.rb
|
|
411
412
|
- lib/govuk_content_models/test_helpers/factories.rb
|
|
@@ -429,6 +430,7 @@ files:
|
|
|
429
430
|
- test/models/business_support/support_type_test.rb
|
|
430
431
|
- test/models/business_support_edition_test.rb
|
|
431
432
|
- test/models/campaign_edition_test.rb
|
|
433
|
+
- test/models/completed_transaction_edition_test.rb
|
|
432
434
|
- test/models/curated_list_test.rb
|
|
433
435
|
- test/models/downtime_test.rb
|
|
434
436
|
- test/models/edition_scheduled_for_publishing_test.rb
|
|
@@ -478,7 +480,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
478
480
|
version: '0'
|
|
479
481
|
segments:
|
|
480
482
|
- 0
|
|
481
|
-
hash: -
|
|
483
|
+
hash: -413850837367129269
|
|
482
484
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
483
485
|
none: false
|
|
484
486
|
requirements:
|
|
@@ -487,7 +489,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
487
489
|
version: '0'
|
|
488
490
|
segments:
|
|
489
491
|
- 0
|
|
490
|
-
hash: -
|
|
492
|
+
hash: -413850837367129269
|
|
491
493
|
requirements: []
|
|
492
494
|
rubyforge_project:
|
|
493
495
|
rubygems_version: 1.8.23
|
|
@@ -512,6 +514,7 @@ test_files:
|
|
|
512
514
|
- test/models/business_support/support_type_test.rb
|
|
513
515
|
- test/models/business_support_edition_test.rb
|
|
514
516
|
- test/models/campaign_edition_test.rb
|
|
517
|
+
- test/models/completed_transaction_edition_test.rb
|
|
515
518
|
- test/models/curated_list_test.rb
|
|
516
519
|
- test/models/downtime_test.rb
|
|
517
520
|
- test/models/edition_scheduled_for_publishing_test.rb
|