govuk_content_models 28.0.0 → 28.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/app/models/action.rb +0 -3
- data/app/models/answer_edition.rb +1 -1
- data/app/models/artefact.rb +0 -4
- data/app/models/artefact_action.rb +0 -4
- data/app/models/artefact_external_link.rb +0 -4
- data/app/models/business_support_edition.rb +1 -1
- data/app/models/campaign_edition.rb +2 -1
- data/app/models/completed_transaction_edition.rb +1 -1
- data/app/models/curated_list.rb +0 -3
- data/app/models/edition.rb +1 -3
- data/app/models/guide_edition.rb +1 -0
- data/app/models/help_page_edition.rb +1 -1
- data/app/models/licence_edition.rb +2 -2
- data/app/models/local_authority.rb +0 -3
- data/app/models/local_interaction.rb +0 -3
- data/app/models/local_service.rb +0 -3
- data/app/models/local_transaction_edition.rb +1 -1
- data/app/models/manual_change_history.rb +0 -3
- data/app/models/overview_dashboard.rb +0 -4
- data/app/models/place_edition.rb +1 -1
- data/app/models/programme_edition.rb +1 -0
- data/app/models/rendered_manual.rb +0 -3
- data/app/models/rendered_specialist_document.rb +0 -3
- data/app/models/simple_smart_answer_edition.rb +2 -1
- data/app/models/simple_smart_answer_edition/node.rb +0 -1
- data/app/models/tag.rb +0 -2
- data/app/models/transaction_edition.rb +1 -1
- data/app/models/user.rb +0 -4
- data/app/models/video_edition.rb +1 -1
- data/lib/govuk_content_models/version.rb +1 -1
- data/test/models/artefact_test.rb +2 -2
- data/test/models/edition_test.rb +14 -6
- data/test/models/prerendered_entity_tests.rb +1 -1
- data/test/validators/safe_html_validator_test.rb +2 -2
- metadata +4 -4
data/CHANGELOG.md
CHANGED
data/app/models/action.rb
CHANGED
@@ -41,9 +41,6 @@ class Action
|
|
41
41
|
field :customised_message, type: String
|
42
42
|
field :created_at, type: DateTime, default: lambda { Time.zone.now }
|
43
43
|
|
44
|
-
GOVSPEAK_FIELDS = []
|
45
|
-
validates_with SafeHtml
|
46
|
-
|
47
44
|
def container_class_name(edition)
|
48
45
|
edition.container.class.name.underscore.humanize
|
49
46
|
end
|
data/app/models/artefact.rb
CHANGED
@@ -7,12 +7,8 @@ class ArtefactAction
|
|
7
7
|
field "action_type", type: String
|
8
8
|
field "snapshot", type: Hash
|
9
9
|
|
10
|
-
GOVSPEAK_FIELDS = []
|
11
|
-
|
12
10
|
embedded_in :artefact
|
13
11
|
|
14
|
-
validates_with SafeHtml
|
15
|
-
|
16
12
|
# Ideally we would like to use the UID field here, since that will be the
|
17
13
|
# same across all applications, but Mongoid doesn't yet support using a
|
18
14
|
# custom primary key on a related field
|
@@ -4,12 +4,8 @@ class ArtefactExternalLink
|
|
4
4
|
field "title", type: String
|
5
5
|
field "url", type: String
|
6
6
|
|
7
|
-
GOVSPEAK_FIELDS = []
|
8
|
-
|
9
7
|
embedded_in :artefact
|
10
8
|
|
11
|
-
validates_with SafeHtml
|
12
|
-
|
13
9
|
validates_presence_of :title
|
14
10
|
validates :url, :presence => true, :format => { :with => URI::regexp(%w{http https}) }
|
15
11
|
end
|
@@ -30,7 +30,7 @@ class BusinessSupportEdition < Edition
|
|
30
30
|
field :end_date, type: Date
|
31
31
|
field :areas, type: Array, default: []
|
32
32
|
|
33
|
-
GOVSPEAK_FIELDS =
|
33
|
+
GOVSPEAK_FIELDS = [:body, :eligibility, :evaluation, :additional_information]
|
34
34
|
|
35
35
|
validate :scheme_dates
|
36
36
|
validate :min_must_be_less_than_max
|
@@ -12,7 +12,8 @@ class CampaignEdition < Edition
|
|
12
12
|
|
13
13
|
attaches :large_image, :medium_image, :small_image
|
14
14
|
|
15
|
-
GOVSPEAK_FIELDS =
|
15
|
+
GOVSPEAK_FIELDS = [:body]
|
16
|
+
|
16
17
|
@fields_to_clone = [
|
17
18
|
:body, :large_image_id, :medium_image_id, :small_image_id,
|
18
19
|
:organisation_formatted_name, :organisation_url, :organisation_brand_colour, :organisation_crest
|
data/app/models/curated_list.rb
CHANGED
data/app/models/edition.rb
CHANGED
@@ -34,8 +34,6 @@ class Edition
|
|
34
34
|
field :change_note, type: String
|
35
35
|
field :review_requested_at, type: DateTime
|
36
36
|
|
37
|
-
GOVSPEAK_FIELDS = []
|
38
|
-
|
39
37
|
belongs_to :assigned_to, class_name: "User"
|
40
38
|
|
41
39
|
# state_machine comes from Workflow
|
@@ -57,7 +55,7 @@ class Edition
|
|
57
55
|
validates :version_number, presence: true, uniqueness: {scope: :panopticon_id}
|
58
56
|
validates :panopticon_id, presence: true
|
59
57
|
validates_with SafeHtml
|
60
|
-
validates_with LinkValidator, on: :update
|
58
|
+
validates_with LinkValidator, on: :update, unless: :archived?
|
61
59
|
validates_with TopicValidator, BrowsePageValidator, ReviewerValidator
|
62
60
|
validates_presence_of :change_note, if: :major_change
|
63
61
|
|
data/app/models/guide_edition.rb
CHANGED
@@ -8,12 +8,12 @@ class LicenceEdition < Edition
|
|
8
8
|
field :will_continue_on, :type => String
|
9
9
|
field :continuation_link, :type => String
|
10
10
|
|
11
|
-
GOVSPEAK_FIELDS =
|
11
|
+
GOVSPEAK_FIELDS = [:licence_overview]
|
12
12
|
|
13
13
|
validates :licence_identifier, :presence => true
|
14
14
|
validate :licence_identifier_unique
|
15
15
|
validates_format_of :continuation_link, :with => URI::regexp(%w(http https)), :allow_blank => true
|
16
|
-
|
16
|
+
|
17
17
|
@fields_to_clone = [:licence_identifier, :licence_short_description,
|
18
18
|
:licence_overview, :will_continue_on, :continuation_link]
|
19
19
|
|
@@ -16,11 +16,8 @@ class LocalAuthority
|
|
16
16
|
field :contact_phone, type: String
|
17
17
|
field :contact_email, type: String
|
18
18
|
|
19
|
-
GOVSPEAK_FIELDS = []
|
20
|
-
|
21
19
|
validates_uniqueness_of :snac
|
22
20
|
validates_presence_of :snac, :local_directgov_id, :name, :tier
|
23
|
-
validates_with SafeHtml
|
24
21
|
|
25
22
|
scope :for_snacs, ->(snacs) { any_in(snac: snacs) }
|
26
23
|
|
@@ -10,11 +10,8 @@ class LocalInteraction
|
|
10
10
|
field :lgil_code, type: Integer
|
11
11
|
field :url, type: String
|
12
12
|
|
13
|
-
GOVSPEAK_FIELDS = []
|
14
|
-
|
15
13
|
embedded_in :local_authority
|
16
14
|
|
17
15
|
validates_presence_of :url, :lgil_code, :lgsl_code
|
18
16
|
validates_uniqueness_of :lgil_code, :scope => :lgsl_code
|
19
|
-
validates_with SafeHtml
|
20
17
|
end
|
data/app/models/local_service.rb
CHANGED
@@ -9,14 +9,11 @@ class LocalService
|
|
9
9
|
field :lgsl_code, type: Integer
|
10
10
|
field :providing_tier, type: Array
|
11
11
|
|
12
|
-
GOVSPEAK_FIELDS = []
|
13
|
-
|
14
12
|
validates_presence_of :lgsl_code, :providing_tier
|
15
13
|
validates_uniqueness_of :lgsl_code
|
16
14
|
validates :providing_tier, inclusion: {
|
17
15
|
in: [%w{county unitary}, %w{district unitary}, %w{district unitary county}]
|
18
16
|
}
|
19
|
-
validates_with SafeHtml
|
20
17
|
|
21
18
|
def self.find_by_lgsl_code(lgsl_code)
|
22
19
|
LocalService.where(lgsl_code: lgsl_code).first
|
@@ -8,7 +8,7 @@ class LocalTransactionEdition < Edition
|
|
8
8
|
field :more_information, type: String
|
9
9
|
field :need_to_know, type: String
|
10
10
|
|
11
|
-
GOVSPEAK_FIELDS =
|
11
|
+
GOVSPEAK_FIELDS = [:introduction, :more_information, :need_to_know]
|
12
12
|
|
13
13
|
@fields_to_clone = [
|
14
14
|
:lgsl_code, :introduction, :more_information, :need_to_know
|
data/app/models/place_edition.rb
CHANGED
@@ -6,7 +6,7 @@ class PlaceEdition < Edition
|
|
6
6
|
field :need_to_know, type: String
|
7
7
|
field :place_type, type: String
|
8
8
|
|
9
|
-
GOVSPEAK_FIELDS =
|
9
|
+
GOVSPEAK_FIELDS = [:introduction, :more_information, :need_to_know]
|
10
10
|
|
11
11
|
@fields_to_clone = [:introduction, :more_information, :place_type, :need_to_know]
|
12
12
|
|
data/app/models/tag.rb
CHANGED
@@ -13,7 +13,6 @@ class Tag
|
|
13
13
|
field :parent_id, type: String
|
14
14
|
field :state, type: String, default: 'draft'
|
15
15
|
|
16
|
-
GOVSPEAK_FIELDS = []
|
17
16
|
STATES = ['draft', 'live']
|
18
17
|
|
19
18
|
index :tag_id
|
@@ -23,7 +22,6 @@ class Tag
|
|
23
22
|
validates_presence_of :tag_id, :title, :tag_type
|
24
23
|
validates_uniqueness_of :tag_id, scope: :tag_type
|
25
24
|
validates_with TagIdValidator
|
26
|
-
validates_with SafeHtml
|
27
25
|
|
28
26
|
attr_protected :state
|
29
27
|
|
@@ -8,7 +8,7 @@ class TransactionEdition < Edition
|
|
8
8
|
field :need_to_know, type: String
|
9
9
|
field :alternate_methods, type: String
|
10
10
|
|
11
|
-
GOVSPEAK_FIELDS =
|
11
|
+
GOVSPEAK_FIELDS = [:introduction, :more_information, :alternate_methods, :need_to_know]
|
12
12
|
|
13
13
|
@fields_to_clone = [:introduction, :will_continue_on, :link,
|
14
14
|
:more_information, :alternate_methods,
|
data/app/models/user.rb
CHANGED
@@ -26,8 +26,6 @@ class User
|
|
26
26
|
index "uid", unique: true
|
27
27
|
index "disabled"
|
28
28
|
|
29
|
-
GOVSPEAK_FIELDS = []
|
30
|
-
|
31
29
|
# Setup accessible (or protected) attributes for your model
|
32
30
|
attr_accessible :email, :name, :uid
|
33
31
|
attr_accessible :email, :name, :uid, :permissions, as: :oauth
|
@@ -36,8 +34,6 @@ class User
|
|
36
34
|
scope :enabled, any_of({ :disabled.exists => false },
|
37
35
|
{ :disabled.in => [false, nil] })
|
38
36
|
|
39
|
-
validates_with SafeHtml
|
40
|
-
|
41
37
|
def to_s
|
42
38
|
name || email || ""
|
43
39
|
end
|
data/app/models/video_edition.rb
CHANGED
@@ -286,11 +286,11 @@ class ArtefactTest < ActiveSupport::TestCase
|
|
286
286
|
parent = Artefact.create!(slug: "parent", name: "Parent", kind: "guide", owning_app: "x")
|
287
287
|
|
288
288
|
a = Artefact.create!(slug: "a", name: "has no published editions", kind: "guide", owning_app: "publisher")
|
289
|
-
|
289
|
+
GuideEdition.create!(panopticon_id: a.id, title: "Unpublished", state: "draft")
|
290
290
|
parent.related_artefacts << a
|
291
291
|
|
292
292
|
b = Artefact.create!(slug: "b", name: "has a published edition", kind: "guide", owning_app: "publisher")
|
293
|
-
|
293
|
+
GuideEdition.create!(panopticon_id: b.id, title: "Published", state: "published")
|
294
294
|
parent.related_artefacts << b
|
295
295
|
|
296
296
|
c = Artefact.create!(slug: "c", name: "not a publisher artefact", kind: "place", owning_app: "x")
|
data/test/models/edition_test.rb
CHANGED
@@ -106,34 +106,42 @@ class EditionTest < ActiveSupport::TestCase
|
|
106
106
|
refute edition.valid?
|
107
107
|
assert_include edition.errors.full_messages, %q<Body ["Don't include hover text in links. Delete the text in quotation marks eg \\"This appears when you hover over the link.\\""]>
|
108
108
|
end
|
109
|
+
|
110
|
+
should "allow archiving an edition with invalid links" do
|
111
|
+
edition = FactoryGirl.create(:answer_edition, state: 'published', body: 'abc [foobar](http://foobar.com "hover")')
|
112
|
+
|
113
|
+
assert_difference 'AnswerEdition.archived.count', 1 do
|
114
|
+
edition.archive!
|
115
|
+
end
|
116
|
+
end
|
109
117
|
end
|
110
118
|
|
111
119
|
context "change note" do
|
112
120
|
should "be a minor change by default" do
|
113
|
-
refute
|
121
|
+
refute AnswerEdition.new.major_change
|
114
122
|
end
|
115
123
|
should "not be valid for major changes with a blank change note" do
|
116
|
-
edition =
|
124
|
+
edition = AnswerEdition.new(major_change: true, change_note: "")
|
117
125
|
refute edition.valid?
|
118
126
|
assert edition.errors.has_key?(:change_note)
|
119
127
|
end
|
120
128
|
should "be valid for major changes with a change note" do
|
121
|
-
edition =
|
129
|
+
edition = AnswerEdition.new(title: "Edition", version_number: 1, panopticon_id: 123, major_change: true, change_note: "Changed")
|
122
130
|
assert edition.valid?
|
123
131
|
end
|
124
132
|
should "be valid when blank for minor changes" do
|
125
|
-
edition =
|
133
|
+
edition = AnswerEdition.new(title: "Edition", version_number: 1, panopticon_id: 123, change_note: "")
|
126
134
|
assert edition.valid?
|
127
135
|
end
|
128
136
|
should "be valid when populated for minor changes" do
|
129
|
-
edition =
|
137
|
+
edition = AnswerEdition.new(title: "Edition", version_number: 1, panopticon_id: 123, change_note: "Changed")
|
130
138
|
assert edition.valid?
|
131
139
|
end
|
132
140
|
end
|
133
141
|
|
134
142
|
test "reviewer cannot be the assignee" do
|
135
143
|
user = FactoryGirl.create(:user)
|
136
|
-
edition =
|
144
|
+
edition = AnswerEdition.new(title: "Edition", version_number: 1, panopticon_id: 123,
|
137
145
|
state: "in_review", review_requested_at: Time.zone.now, assigned_to: user)
|
138
146
|
edition.reviewer = user.name
|
139
147
|
refute edition.valid?
|
@@ -65,7 +65,7 @@ class SafeHtmlTest < ActiveSupport::TestCase
|
|
65
65
|
assert dummy.invalid?
|
66
66
|
end
|
67
67
|
|
68
|
-
should "all models should use this validator" do
|
68
|
+
should "all models that have govspeak fields should use this validator" do
|
69
69
|
models_dir = File.expand_path("../../app/models/*", File.dirname(__FILE__))
|
70
70
|
|
71
71
|
classes = Dir[models_dir]
|
@@ -73,7 +73,7 @@ class SafeHtmlTest < ActiveSupport::TestCase
|
|
73
73
|
File.basename(file, ".rb").camelize.constantize
|
74
74
|
}
|
75
75
|
.select { |klass|
|
76
|
-
klass.included_modules.include?(Mongoid::Document)
|
76
|
+
klass.included_modules.include?(Mongoid::Document) && klass.const_defined?(:GOVSPEAK_FIELDS)
|
77
77
|
}
|
78
78
|
.each { |klass|
|
79
79
|
assert_includes klass.validators.map(&:class), SafeHtml, "#{klass} must be validated with SafeHtml"
|
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.0.
|
4
|
+
version: 28.0.1
|
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:
|
12
|
+
date: 2015-01-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bson_ext
|
@@ -475,7 +475,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
475
475
|
version: '0'
|
476
476
|
segments:
|
477
477
|
- 0
|
478
|
-
hash:
|
478
|
+
hash: 1044253096296526038
|
479
479
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
480
480
|
none: false
|
481
481
|
requirements:
|
@@ -484,7 +484,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
484
484
|
version: '0'
|
485
485
|
segments:
|
486
486
|
- 0
|
487
|
-
hash:
|
487
|
+
hash: 1044253096296526038
|
488
488
|
requirements: []
|
489
489
|
rubyforge_project:
|
490
490
|
rubygems_version: 1.8.23
|