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 CHANGED
@@ -1,3 +1,7 @@
1
+ ## 28.6.0
2
+
3
+ - Add `presentation_toggles` field to CompletedTransactionEdition
4
+
1
5
  ## 28.5.0
2
6
 
3
7
  - Add `countryside_stewardship_grant` artefact format
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2012 HM Government (Government Digital Service)
1
+ Copyright (C) 2012 Crown copyright (Government Digital Service)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,6 +1,8 @@
1
1
  require "edition"
2
2
 
3
3
  class CompletedTransactionEdition < Edition
4
+ include PresentationToggles
5
+
4
6
  field :body, type: String
5
7
 
6
8
  GOVSPEAK_FIELDS = [:body]
@@ -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
@@ -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 = "28.5.0"
3
+ VERSION = "28.6.0"
4
4
  end
@@ -1,6 +1,7 @@
1
1
  require "govuk_content_models/version"
2
2
  require "mongoid"
3
3
  require "mongoid/monkey_patches"
4
+ require "govuk_content_models/presentation_toggles"
4
5
  require "govuk_content_models/action_processors"
5
6
 
6
7
  module GovukContentModels
@@ -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.5.0
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-02-19 00:00:00.000000000 Z
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: -3032678469725300228
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: -3032678469725300228
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