govuk_content_models 10.0.0 → 10.1.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/README.md CHANGED
@@ -1,5 +1,5 @@
1
- # Gov.uk Content Models
1
+ # GOV.UK Content Models
2
2
 
3
- A gem containing the shared models for Panopticon and Publisher.
3
+ A gem containing the shared models for the GOV.UK publishing platform, including [Panopticon](https://github.com/alphagov/panopticon) and [Publisher](https://github.com/alphagov/publisher).
4
4
 
5
5
  This is a continual **work in progress**.
@@ -284,4 +284,14 @@ class Edition
284
284
  Artefact.find(self.panopticon_id).destroy
285
285
  end
286
286
  end
287
+
288
+ def previous_edition_differences
289
+ return if version_number <= 1
290
+
291
+ if in_progress?
292
+ edition_changes.to_s # diff of current changes
293
+ else
294
+ actions.select { |a| a.request_type == 'publish' }.last.diff # diff with previous published version
295
+ end
296
+ end
287
297
  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 = "10.0.0"
3
+ VERSION = "10.1.0"
4
4
  end
@@ -40,6 +40,14 @@ class EditionTest < ActiveSupport::TestCase
40
40
  template_answer(version_number)
41
41
  end
42
42
 
43
+ def draft_second_edition_from(published_edition)
44
+ published_edition.build_clone(AnswerEdition).tap { |edition|
45
+ edition.body = "Test Body 2"
46
+ edition.save
47
+ edition.reload
48
+ }
49
+ end
50
+
43
51
  test "it must have a title" do
44
52
  a = LocalTransactionEdition.new
45
53
  refute a.valid?
@@ -542,6 +550,31 @@ class EditionTest < ActiveSupport::TestCase
542
550
  assert edition.new_action(user, "note", comment: "Something important")
543
551
  end
544
552
 
553
+ test "first edition has no previous edition diffrences" do
554
+ first_edition = template_published_answer
555
+
556
+ assert_nil first_edition.previous_edition_differences
557
+ end
558
+
559
+ test "can access the changes since the last version" do
560
+ second_edition = draft_second_edition_from(template_published_answer)
561
+
562
+ assert_equal("{\"Lots of info\" >> \"Test Body 2\"}",
563
+ second_edition.previous_edition_differences)
564
+ end
565
+
566
+ test "can show the differences between published editions" do
567
+ second_edition = draft_second_edition_from(template_published_answer)
568
+ second_edition.update_attribute(:state, "ready")
569
+ second_edition.save!
570
+
571
+ user = User.create(name: "bob")
572
+ user.publish second_edition, comment: "Published comment"
573
+
574
+ assert_equal("{\"Lots of info\" >> \"Test Body 2\"}",
575
+ second_edition.previous_edition_differences)
576
+ end
577
+
545
578
  test "status should not be affected by notes" do
546
579
  user = User.create(name: "bob")
547
580
  edition = FactoryGirl.create(:guide_edition, panopticon_id: @artefact.id, state: "ready")
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: 10.0.0
4
+ version: 10.1.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: 2014-04-03 00:00:00.000000000 Z
12
+ date: 2014-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bson_ext
@@ -465,7 +465,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
465
465
  version: '0'
466
466
  segments:
467
467
  - 0
468
- hash: -283248144793344771
468
+ hash: -4548551299969788770
469
469
  required_rubygems_version: !ruby/object:Gem::Requirement
470
470
  none: false
471
471
  requirements:
@@ -474,7 +474,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
474
474
  version: '0'
475
475
  segments:
476
476
  - 0
477
- hash: -283248144793344771
477
+ hash: -4548551299969788770
478
478
  requirements: []
479
479
  rubyforge_project:
480
480
  rubygems_version: 1.8.23