govuk_content_models 41.1.1 → 42.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: f62fa6f0be7b191abab1031c90c07477b6f441e9
4
- data.tar.gz: 740a4a1599e10251153f14593c6030be11fafbb2
3
+ metadata.gz: 8bacf08397308954506f1db7f3367eff5bb87825
4
+ data.tar.gz: d87f23b5972b468378aeb9085dc3241ffe2de61f
5
5
  SHA512:
6
- metadata.gz: 83a2942d1809c38aeebc939ac2f216264f6379322b34443e6ebc487f4b80fb0de3b8d0ae5afd19d7fbbe3d4c3f7ef36cc0ea0625e7179e213befa083f64ddd3e
7
- data.tar.gz: e4cb4108fbd8dc79627ea0916e7ed8e72ac55e2388c0c32a8a9ea5bd55d1d8ee51ae3614de2d83f7349516a4e16af250592eb67e55aa740d4e3b803ff06bec8c
6
+ metadata.gz: 74dcfde7b33e6dfd7b17af36967cfe065fe299a79c74e6d1d4024e0d100eacfbcaa4504b8f3a3d1bbf107b9bcfae117050da7181c6fa5a1a975ed97c44cca180
7
+ data.tar.gz: d0df800cf739c23c95372ce124df316b08d0a5feac079a4d90ce1e5cb167c235bb6c17ac11dc91fe182c346851923ed1d72cc909bcb52ae755012605b532876b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 42.0.0
4
+
5
+ - Remove everything related to tagging and related links. We now use the content
6
+ store for this.
7
+
3
8
  ## 41.1.1
4
9
 
5
10
  - Use `require_dependency` to avoid warnings in publisher sidekiq in development mode
@@ -1,5 +1,4 @@
1
1
  require "plek"
2
- require "traits/taggable"
3
2
  require "artefact_action" # Require this when running outside Rails
4
3
  require_dependency "safe_html"
5
4
 
@@ -15,11 +14,6 @@ class Artefact
15
14
  include Mongoid::Document
16
15
  include Mongoid::Timestamps
17
16
 
18
- include Taggable
19
- stores_tags_for :sections, :writing_teams, :propositions,
20
- :keywords, :specialist_sectors, :organisations
21
- has_primary_tag_for :section
22
-
23
17
  field "name", type: String
24
18
  field "slug", type: String
25
19
  field "paths", type: Array, default: []
@@ -60,8 +54,6 @@ class Artefact
60
54
 
61
55
  scope :not_archived, lambda { where(:state.nin => ["archived"]) }
62
56
 
63
- MAXIMUM_RELATED_ITEMS = 8
64
-
65
57
  FORMATS_BY_DEFAULT_OWNING_APP = {
66
58
  "publisher" => ["answer",
67
59
  "business_support",
@@ -124,7 +116,6 @@ class Artefact
124
116
  "world_location_news_article",
125
117
  "worldwide_priority",
126
118
  "written_statement"],
127
- "panopticon" => ["specialist_sector"],
128
119
  }.freeze
129
120
 
130
121
  FORMATS = FORMATS_BY_DEFAULT_OWNING_APP.values.flatten
@@ -141,7 +132,6 @@ class Artefact
141
132
  "find my nearest" => "place",
142
133
  }.tap { |h| h.default_proc = -> _, k { k } }.freeze
143
134
 
144
- has_and_belongs_to_many :related_artefacts, class_name: "Artefact"
145
135
  embeds_many :actions, class_name: "ArtefactAction", order: { created_at: :asc }
146
136
 
147
137
  embeds_many :external_links, class_name: "ArtefactExternalLink"
@@ -165,11 +155,6 @@ class Artefact
165
155
  validate :format_of_new_need_ids, if: :need_ids_changed?
166
156
  validate :validate_redirect_url
167
157
 
168
- scope :relatable_items, proc {
169
- where(:kind.ne => "completed_transaction", :state.ne => "archived")
170
- .order_by(name: :asc)
171
- }
172
-
173
158
  def self.in_alphabetical_order
174
159
  order_by(name: :asc)
175
160
  end
@@ -178,16 +163,6 @@ class Artefact
178
163
  where(slug: s).first
179
164
  end
180
165
 
181
- # The old-style section string identifier, of the form 'Crime:Prisons'
182
- def section
183
- return '' unless self.primary_section
184
- if primary_section.parent
185
- [primary_section.parent.title, primary_section.title].join ':'
186
- else
187
- primary_section.title
188
- end
189
- end
190
-
191
166
  # Fallback to english if no language is present
192
167
  def language
193
168
  attributes['language'] || "en"
@@ -204,69 +179,12 @@ class Artefact
204
179
  ].reject(&:blank?).join("?")
205
180
  end
206
181
 
207
- # TODO: Replace this nonsense with a proper API layer.
208
182
  def as_json(options={})
209
183
  super.tap { |hash|
210
- if hash["tag_ids"]
211
- hash["tags"] = Tag.by_tag_ids(hash["tag_ids"]).map(&:as_json)
212
- else
213
- hash["tag_ids"] = []
214
- hash["tags"] = []
215
- end
216
-
217
- if self.primary_section
218
- hash['primary_section'] = self.primary_section.tag_id
219
- end
220
-
221
- unless options[:ignore_related_artefacts]
222
- hash["related_items"] = published_related_artefacts.map do |a|
223
- {"artefact" => a.as_json(ignore_related_artefacts: true)}
224
- end
225
- end
226
- hash.delete("related_artefacts")
227
- hash.delete("related_artefact_ids")
228
184
  hash["id"] = hash.delete("_id")
229
-
230
- # Add a section identifier if needed
231
- hash["section"] ||= section
232
185
  }
233
186
  end
234
187
 
235
- def published_related_artefacts
236
- related_artefacts.select do |related_artefact|
237
- if related_artefact.owning_app == "publisher"
238
- related_artefact.any_editions_published?
239
- else
240
- true
241
- end
242
- end
243
- end
244
-
245
- # Pass in the desired scope, eg self.related_artefacts.live,
246
- # get back the items in the order they were set in, rather than natural order
247
- def ordered_related_artefacts(scope_or_array = self.related_artefacts)
248
- scope_or_array.sort_by { |artefact| related_artefact_ids.index(artefact.id) }
249
- end
250
-
251
- def related_artefacts_grouped_by_distance(scope_or_array = self.related_artefacts)
252
- groups = { "subsection" => [], "section" => [], "other" => [] }
253
- scoped_artefacts = ordered_related_artefacts(scope_or_array)
254
-
255
- if primary_tag = self.primary_section
256
- groups['subsection'] = scoped_artefacts.select {|a| a.tag_ids.include?(primary_tag.tag_id) }
257
-
258
- if primary_tag.parent_id.present?
259
- pattern = Regexp.new "^#{Regexp.quote(primary_tag.parent_id)}\/.+"
260
- groups['section'] = scoped_artefacts.reject {|a| groups['subsection'].include?(a) }.select {|a|
261
- a.tag_ids.grep(pattern).count > 0
262
- }
263
- end
264
- end
265
- groups['other'] = scoped_artefacts.reject {|a| (groups['subsection'] + groups['section']).include?(a) }
266
-
267
- groups
268
- end
269
-
270
188
  def any_editions_published?
271
189
  Edition.where(panopticon_id: self.id, state: 'published').any?
272
190
  end
@@ -370,9 +288,6 @@ class Artefact
370
288
  def snapshot
371
289
  attributes
372
290
  .except("_id", "created_at", "updated_at", "actions")
373
- .merge(
374
- "related_artefact_ids" => self.related_artefact_ids
375
- )
376
291
  end
377
292
 
378
293
  def need_id=(new_need_id)
@@ -18,10 +18,6 @@ class Edition
18
18
  field :slug, type: String
19
19
  field :rejected_count, type: Integer, default: 0
20
20
 
21
- field :browse_pages, type: Array, default: []
22
- field :primary_topic, type: String
23
- field :additional_topics, type: Array, default: []
24
-
25
21
  field :assignee, type: String
26
22
  field :reviewer, type: String
27
23
  field :creator, type: String
@@ -53,7 +49,7 @@ class Edition
53
49
  validates :panopticon_id, presence: true
54
50
  validates_with SafeHtml
55
51
  validates_with LinkValidator, on: :update, unless: :archived?
56
- validates_with TopicValidator, BrowsePageValidator, ReviewerValidator
52
+ validates_with ReviewerValidator
57
53
  validates_presence_of :change_note, if: :major_change
58
54
 
59
55
  before_save :check_for_archived_artefact
@@ -252,10 +248,6 @@ class Edition
252
248
  end
253
249
  end
254
250
 
255
- def panopticon_uri
256
- Plek.current.find("panopticon") + "/artefacts/" + (panopticon_id || slug).to_s
257
- end
258
-
259
251
  def format
260
252
  self.class.to_s.gsub("Edition", "")
261
253
  end
@@ -332,9 +324,6 @@ private
332
324
  :panopticon_id,
333
325
  :overview,
334
326
  :slug,
335
- :browse_pages,
336
- :primary_topic,
337
- :additional_topics,
338
327
  ]
339
328
  end
340
329
 
@@ -8,7 +8,6 @@ class SlugValidator < ActiveModel::EachValidator
8
8
  FinderEmailSignupValidator,
9
9
  GovernmentPageValidator,
10
10
  ManualPageValidator,
11
- BrowsePageValidator,
12
11
  DetailedGuideValidator,
13
12
  DefaultValidator
14
13
  ].map { |klass| klass.new(record, attribute, value) }
@@ -147,21 +146,6 @@ protected
147
146
  end
148
147
  end
149
148
 
150
- class BrowsePageValidator < InstanceValidator
151
- def applicable?
152
- of_kind?('specialist_sector')
153
- end
154
-
155
- def validate!
156
- unless [1, 2].include?(url_parts.size)
157
- record.errors[attribute] << "must contains one or two path parts"
158
- end
159
- unless url_parts.all? { |url_part| valid_slug?(url_part) }
160
- record.errors[attribute] << "must be usable in a URL"
161
- end
162
- end
163
- end
164
-
165
149
  class DetailedGuideValidator < InstanceValidator
166
150
  def applicable?
167
151
  of_kind?('detailed_guide')
@@ -1,7 +1,6 @@
1
1
  require "factory_girl"
2
2
  require "answer_edition"
3
3
  require "artefact"
4
- require "tag"
5
4
  require "user"
6
5
 
7
6
  FactoryGirl.define do
@@ -26,23 +25,6 @@ FactoryGirl.define do
26
25
  artefact
27
26
  end
28
27
 
29
- factory :tag do
30
- sequence(:tag_id) { |n| "crime-and-justice-#{n}" }
31
- sequence(:title) { |n| "The title #{n}" }
32
- tag_type "section"
33
-
34
- trait :draft do
35
- state "draft"
36
- end
37
-
38
- trait :live do
39
- state "live"
40
- end
41
-
42
- factory :draft_tag, traits: [:draft]
43
- factory :live_tag, traits: [:live]
44
- end
45
-
46
28
  factory :artefact do
47
29
  sequence(:name) { |n| "Artefact #{n}" }
48
30
  sequence(:slug) { |n| "slug-#{n}" }
@@ -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 = "41.1.1"
3
+ VERSION = "42.0.0"
4
4
  end
@@ -19,11 +19,8 @@ class ArtefactActionTest < ActiveSupport::TestCase
19
19
 
20
20
  DEFAULTS = {
21
21
  "active" => false,
22
- "tag_ids" => [],
23
- "tags" => [],
24
22
  "need_ids" => [],
25
23
  "state" => "draft",
26
- "related_artefact_ids" => [],
27
24
  "paths" => [],
28
25
  "prefixes" => [],
29
26
  "language" => "en",
@@ -272,63 +272,6 @@ class ArtefactTest < ActiveSupport::TestCase
272
272
  assert_equal "other", a.kind
273
273
  end
274
274
 
275
- test "should store and return related artefacts in order" do
276
- a = Artefact.create!(slug: "a", name: "a", kind: "place", need_ids: ["100001"], owning_app: "x")
277
- b = Artefact.create!(slug: "b", name: "b", kind: "place", need_ids: ["100001"], owning_app: "x")
278
- c = Artefact.create!(slug: "c", name: "c", kind: "place", need_ids: ["100001"], owning_app: "x")
279
-
280
- a.related_artefacts = [b, c]
281
- a.save!
282
- a.reload
283
-
284
- assert_equal [b, c], a.ordered_related_artefacts
285
- end
286
-
287
- test "should store and return related artefacts in order, even when not in natural order" do
288
- a = Artefact.create!(slug: "a", name: "a", kind: "place", need_ids: ["100001"], owning_app: "x")
289
- b = Artefact.create!(slug: "b", name: "b", kind: "place", need_ids: ["100001"], owning_app: "x")
290
- c = Artefact.create!(slug: "c", name: "c", kind: "place", need_ids: ["100001"], owning_app: "x")
291
-
292
- a.related_artefacts = [c, b]
293
- a.save!
294
- a.reload
295
-
296
- assert_equal [c, b], a.ordered_related_artefacts
297
- end
298
-
299
- test "should store and return related artefacts in order, with a scope" do
300
- a = Artefact.create!(slug: "a", name: "a", kind: "place", need_ids: ["100001"], owning_app: "x")
301
- b = Artefact.create!(state: "live", slug: "b", name: "b", kind: "place", need_ids: ["100001"], owning_app: "x")
302
- c = Artefact.create!(slug: "c", name: "c", kind: "place", need_ids: ["100001"], owning_app: "x")
303
- d = Artefact.create!(state: "live", slug: "d", name: "d", kind: "place", need_ids: ["100001"], owning_app: "x")
304
-
305
- a.related_artefacts = [d, c, b]
306
- a.save!
307
- a.reload
308
-
309
- assert_equal [d, b], a.ordered_related_artefacts(a.related_artefacts.where(state: "live"))
310
- end
311
-
312
- test "published_related_artefacts should return all non-publisher artefacts, but only published publisher artefacts" do
313
- # because currently only publisher has an idea of "published"
314
-
315
- parent = Artefact.create!(slug: "parent", name: "Parent", kind: "guide", owning_app: "x")
316
-
317
- a = Artefact.create!(slug: "a", name: "has no published editions", kind: "guide", owning_app: "publisher")
318
- GuideEdition.create!(panopticon_id: a.id, title: "Unpublished", state: "draft")
319
- parent.related_artefacts << a
320
-
321
- b = Artefact.create!(slug: "b", name: "has a published edition", kind: "guide", owning_app: "publisher")
322
- GuideEdition.create!(panopticon_id: b.id, title: "Published", state: "published")
323
- parent.related_artefacts << b
324
-
325
- c = Artefact.create!(slug: "c", name: "not a publisher artefact", kind: "place", owning_app: "x")
326
- parent.related_artefacts << c
327
- parent.save!
328
-
329
- assert_equal [b.slug, c.slug], parent.published_related_artefacts.map(&:slug)
330
- end
331
-
332
275
  test "should raise a not found exception if the slug doesn't match" do
333
276
  assert_raise Mongoid::Errors::DocumentNotFound do
334
277
  Artefact.from_param("something-fake")
@@ -398,13 +341,10 @@ class ArtefactTest < ActiveSupport::TestCase
398
341
  # should continue to work in the way it has been:
399
342
  # i.e. you can edit everything but the name/title for published content in panop
400
343
  test "on save title should not be applied to already published content" do
401
- FactoryGirl.create(:live_tag, tag_id: "test-section", title: "Test section", tag_type: "section")
402
344
  artefact = FactoryGirl.create(:artefact,
403
345
  slug: "foo-bar",
404
346
  kind: "answer",
405
347
  name: "Foo bar",
406
- primary_section: "test-section",
407
- sections: ["test-section"],
408
348
  owning_app: "publisher",
409
349
  )
410
350
 
@@ -532,72 +472,6 @@ class ArtefactTest < ActiveSupport::TestCase
532
472
  end
533
473
  end
534
474
 
535
- context "returning json representation" do
536
- context "returning tags" do
537
- setup do
538
- FactoryGirl.create(:live_tag, :tag_type => 'section', :tag_id => 'crime', :title => 'Crime')
539
- FactoryGirl.create(:live_tag, :tag_type => 'section', :tag_id => 'justice', :title => 'Justice', :description => "All about justice")
540
- @a = FactoryGirl.create(:artefact, :slug => 'fooey')
541
- end
542
-
543
- should "return empty array of tags and tag_ids" do
544
- hash = @a.as_json
545
-
546
- assert_equal [], hash['tag_ids']
547
- assert_equal [], hash['tags']
548
- end
549
-
550
- context "for an artefact with tags" do
551
- setup do
552
- @a.sections = ['justice']
553
- @a.save!
554
- end
555
-
556
- should "return an array of tag_id strings in tag_ids" do
557
- hash = @a.as_json
558
-
559
- assert_equal ['justice'], hash['tag_ids']
560
- end
561
-
562
- should "return an array of tag objects in tags" do
563
- hash = @a.as_json
564
-
565
- expected = [
566
- {
567
- :id => 'justice',
568
- :title => 'Justice',
569
- :type => 'section',
570
- :description => 'All about justice',
571
- :short_description => nil
572
- },
573
- ]
574
- assert_equal expected, hash['tags']
575
- end
576
-
577
- should "omit non-existent tags referenced from the tag_ids array" do
578
- @a.tag_ids << 'batman'
579
- hash = @a.as_json
580
-
581
- assert_equal %w(justice), hash['tags'].map {|t| t[:id] }
582
- end
583
- end
584
- end
585
- end
586
-
587
- context "artefact related external links" do
588
- should "have none by default" do
589
- artefact = FactoryGirl.create(:artefact)
590
- assert_equal 0, artefact.external_links.length
591
- end
592
-
593
- should "contain the title and URL of the link" do
594
- artefact = FactoryGirl.create(:artefact)
595
- artefact.external_links << ArtefactExternalLink.new(:title => "Foo", :url => "http://bar.com")
596
- assert_equal 1, artefact.external_links.length
597
- assert_equal "Foo", artefact.external_links.first.title
598
- end
599
- end
600
-
601
475
  should "have an archived? helper method" do
602
476
  published_artefact = FactoryGirl.create(:artefact, :slug => "scooby", :state => "live")
603
477
  archived_artefact = FactoryGirl.create(:artefact, :slug => "doo", :state => "archived")
@@ -605,83 +479,4 @@ class ArtefactTest < ActiveSupport::TestCase
605
479
  refute published_artefact.archived?
606
480
  assert archived_artefact.archived?
607
481
  end
608
-
609
- should "have a related_items method which discards artefacts that are archived or completed transactions" do
610
- generic = FactoryGirl.create(:artefact, slug: "generic")
611
- archived = FactoryGirl.create(:artefact, :slug => "archived", :state => "archived")
612
- completed = FactoryGirl.create(:artefact, slug: "completed-transaction", kind: "completed_transaction")
613
-
614
- assert_equal [generic], Artefact.relatable_items
615
- end
616
-
617
- context "related artefacts grouped by section tags" do
618
- setup do
619
- FactoryGirl.create(:live_tag, :tag_id => "fruit", :tag_type => 'section', :title => "Fruit")
620
- FactoryGirl.create(:live_tag, :tag_id => "fruit/simple", :tag_type => 'section', :title => "Simple fruits", :parent_id => "fruit")
621
- FactoryGirl.create(:live_tag, :tag_id => "fruit/aggregate", :tag_type => 'section', :title => "Aggregrate fruits", :parent_id => "fruit")
622
- FactoryGirl.create(:live_tag, :tag_id => "vegetables", :tag_type => 'section', :title => "Vegetables")
623
-
624
- @artefact = Artefact.create!(slug: "apple", name: "Apple", sections: [], kind: "guide", need_ids: ["100001"], owning_app: "x")
625
- end
626
-
627
- context "when related items are present in all groups" do
628
- setup do
629
- @artefact.sections = ["fruit/simple"]
630
-
631
- @artefact.related_artefacts = [
632
- Artefact.create!(slug: "pear", name: "Pear", kind: "guide", sections: ["fruit/simple"], need_ids: ["100001"], owning_app: "x"),
633
- Artefact.create!(slug: "pineapple", name: "Pineapple", kind: "guide", sections: ["fruit/aggregate"], need_ids: ["100001"], owning_app: "x"),
634
- Artefact.create!(slug: "broccoli", name: "Broccoli", kind: "guide", sections: ["vegetables"], need_ids: ["100001"], owning_app: "x")
635
- ]
636
- @artefact.save!
637
- @artefact.reload
638
- end
639
-
640
- should "return a hash of artefacts in the same subsection" do
641
- artefacts = @artefact.related_artefacts_grouped_by_distance
642
- assert_equal ["pear"], artefacts['subsection'].map(&:slug)
643
- end
644
-
645
- should "return a hash of other artefacts in the same parent section" do
646
- artefacts = @artefact.related_artefacts_grouped_by_distance
647
- assert_equal ["pineapple"], artefacts['section'].map(&:slug)
648
- end
649
-
650
- should "return a hash of artefacts in other sections" do
651
- artefacts = @artefact.related_artefacts_grouped_by_distance
652
- assert_equal ["broccoli"], artefacts['other'].map(&:slug)
653
- end
654
-
655
- should "return related artefacts in order, with a scope" do
656
- a = Artefact.create!(state: "live", slug: "a", name: "a", kind: "place", need_ids: ["100001"], owning_app: "x")
657
- b = Artefact.create!(slug: "b", name: "b", kind: "place", need_ids: ["100001"], owning_app: "x")
658
- c = Artefact.create!(state: "live", slug: "c", name: "c", kind: "place", need_ids: ["100001"], owning_app: "x")
659
-
660
- @artefact.related_artefacts = [c,b,a]
661
- @artefact.save!
662
- @artefact.reload
663
-
664
- assert_equal [c, a], @artefact.related_artefacts_grouped_by_distance(@artefact.related_artefacts.where(state: "live"))["other"]
665
- end
666
- end
667
-
668
- should "return an empty array for a group with no related artefacts" do
669
- # @artefact with no related items created in setup block
670
-
671
- assert_equal [], @artefact.related_artefacts_grouped_by_distance["subsection"]
672
- assert_equal [], @artefact.related_artefacts_grouped_by_distance["section"]
673
- assert_equal [], @artefact.related_artefacts_grouped_by_distance["other"]
674
- end
675
-
676
- should "return all related artefacts in 'other' when an artefact has no sections" do
677
- @artefact.related_artefacts = [
678
- Artefact.create!(slug: "pear", name: "Pear", kind: "guide", sections: ["fruit/simple"], need_ids: ["100001"], owning_app: "x"),
679
- Artefact.create!(slug: "banana", name: "Banana", kind: "guide", sections: ["fruit/simple"], need_ids: ["100001"], owning_app: "x")
680
- ]
681
-
682
- assert_equal [], @artefact.related_artefacts_grouped_by_distance["subsection"]
683
- assert_equal [], @artefact.related_artefacts_grouped_by_distance["section"]
684
- assert_equal ["pear", "banana"], @artefact.related_artefacts_grouped_by_distance["other"].map(&:slug)
685
- end
686
- end
687
482
  end
@@ -14,8 +14,6 @@ class EditionTest < ActiveSupport::TestCase
14
14
  artefact = FactoryGirl.create(:artefact,
15
15
  kind: "answer",
16
16
  name: "Foo bar",
17
- # primary_section: "test-section",
18
- # sections: ["test-section"],
19
17
  owning_app: "publisher")
20
18
 
21
19
  AnswerEdition.create(state: "ready", slug: "childcare", panopticon_id: artefact.id,
@@ -490,13 +488,10 @@ class EditionTest < ActiveSupport::TestCase
490
488
  end
491
489
 
492
490
  test "should not change edition metadata if archived" do
493
- FactoryGirl.create(:live_tag, tag_id: "test-section", title: "Test section", tag_type: "section")
494
491
  artefact = FactoryGirl.create(:artefact,
495
492
  slug: "foo-bar",
496
493
  kind: "answer",
497
494
  name: "Foo bar",
498
- primary_section: "test-section",
499
- sections: ["test-section"],
500
495
  owning_app: "publisher",
501
496
  )
502
497
 
@@ -588,9 +583,6 @@ class EditionTest < ActiveSupport::TestCase
588
583
  end
589
584
 
590
585
  test "should also delete associated artefact" do
591
-
592
- FactoryGirl.create(:live_tag, tag_id: "test-section", title: "Test section", tag_type: "section")
593
-
594
586
  user1 = FactoryGirl.create(:user)
595
587
  edition = AnswerEdition.find_or_create_from_panopticon_data(@artefact.id, user1)
596
588
 
@@ -600,8 +592,6 @@ class EditionTest < ActiveSupport::TestCase
600
592
  end
601
593
 
602
594
  test "should not delete associated artefact if there are other editions of this publication" do
603
-
604
- FactoryGirl.create(:live_tag, tag_id: "test-section", title: "Test section", tag_type: "section")
605
595
  user1 = FactoryGirl.create(:user)
606
596
  edition = AnswerEdition.find_or_create_from_panopticon_data(@artefact.id, user1)
607
597
  edition.update_attribute(:state, "published")
@@ -924,13 +914,10 @@ class EditionTest < ActiveSupport::TestCase
924
914
 
925
915
  test "should denormalise a creator's name when an edition is created" do
926
916
  user = FactoryGirl.create(:user)
927
- FactoryGirl.create(:live_tag, tag_id: "test-section", title: "Test section", tag_type: "section")
928
917
  artefact = FactoryGirl.create(:artefact,
929
918
  slug: "foo-bar",
930
919
  kind: "answer",
931
920
  name: "Foo bar",
932
- primary_section: "test-section",
933
- sections: ["test-section"],
934
921
  owning_app: "publisher",
935
922
  )
936
923
 
@@ -1020,7 +1007,7 @@ class EditionTest < ActiveSupport::TestCase
1020
1007
  end
1021
1008
  end
1022
1009
 
1023
- test "should return related artefact" do
1010
+ test "should return the artefact" do
1024
1011
  assert_equal "Foo bar", template_published_answer.artefact.name
1025
1012
  end
1026
1013
 
@@ -1093,74 +1080,6 @@ class EditionTest < ActiveSupport::TestCase
1093
1080
  end
1094
1081
  end
1095
1082
 
1096
- context "Tagging to collections" do
1097
- setup do
1098
- @edition = FactoryGirl.create(:guide_edition)
1099
- end
1100
-
1101
- should "allow tagging to browse pages" do
1102
- sample_browse_pages = [
1103
- 'education/school-admissions-transport',
1104
- 'driving/drivers-lorries-buses'
1105
- ]
1106
-
1107
- @edition.browse_pages = sample_browse_pages
1108
- @edition.save!; @edition.reload
1109
-
1110
- assert_equal sample_browse_pages, @edition.browse_pages
1111
- end
1112
-
1113
- should "allow tagging to a primary topic" do
1114
- sample_primary_topic = 'oil-and-gas/carbon-capture-and-storage'
1115
-
1116
- @edition.primary_topic = sample_primary_topic
1117
- @edition.save!; @edition.reload
1118
-
1119
- assert_equal sample_primary_topic, @edition.primary_topic
1120
- end
1121
-
1122
- should "allow tagging to multiple additional topics" do
1123
- sample_additional_topics = [
1124
- 'oil-and-gas/fields-and-wells',
1125
- 'oil-and-gas/licensing'
1126
- ]
1127
-
1128
- @edition.additional_topics = sample_additional_topics
1129
- @edition.save!; @edition.reload
1130
-
1131
- assert_equal sample_additional_topics, @edition.additional_topics
1132
- end
1133
-
1134
- should "validates topics" do
1135
- assert_includes Edition.validators.map(&:class), TopicValidator
1136
- end
1137
-
1138
- should "validates browse pages" do
1139
- assert_includes Edition.validators.map(&:class), BrowsePageValidator
1140
- end
1141
-
1142
- should "retain collections across new editions" do
1143
- edition = FactoryGirl.create(:guide_edition,
1144
- panopticon_id: @artefact.id,
1145
- state: "published",
1146
- primary_topic: 'oil-and-gas/carbon-capture-and-storage',
1147
- additional_topics: [
1148
- 'oil-and-gas/fields-and-wells',
1149
- 'oil-and-gas/licensing'
1150
- ],
1151
- browse_pages: [
1152
- 'education/school-admissions-transport',
1153
- 'driving/drivers-lorries-buses'
1154
- ]
1155
- )
1156
-
1157
- new_edition = edition.build_clone
1158
- assert_equal edition.primary_topic, new_edition.primary_topic
1159
- assert_equal edition.additional_topics, new_edition.additional_topics
1160
- assert_equal edition.browse_pages, new_edition.browse_pages
1161
- end
1162
- end
1163
-
1164
1083
  context "#latest_major_update" do
1165
1084
  should 'return the most recent published edition with a major change' do
1166
1085
  edition1 = FactoryGirl.create(:answer_edition, major_change: true,