govuk_content_models 28.9.0 → 28.10.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.10.0
2
+
3
+ - Add conversion from LicenceEdition to AnswerEdition in `Edition#build_clone`
4
+
1
5
  ## 28.9.0
2
6
 
3
7
  - Add `department_analytics_profile` to transaction editions
@@ -17,7 +17,7 @@ class Downtime
17
17
  end
18
18
 
19
19
  def publicise?
20
- Time.zone.now.between?(start_time.to_date - 1, end_time) # starting at midnight a day before start time
20
+ Time.zone.now.between?(start_time.yesterday.at_midnight, end_time)
21
21
  end
22
22
 
23
23
  private
@@ -210,6 +210,11 @@ class Edition
210
210
  new_edition.body = whole_body
211
211
  end
212
212
 
213
+ if edition_class == AnswerEdition and self.is_a?(LicenceEdition)
214
+ new_edition.body = whole_body
215
+ new_edition.overview = licence_overview
216
+ end
217
+
213
218
  if edition_class == SimpleSmartAnswerEdition && %w(AnswerEdition GuideEdition ProgrammeEdition TransactionEdition).include?(self.class.name)
214
219
  new_edition.body = whole_body
215
220
  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.9.0"
3
+ VERSION = "28.10.0"
4
4
  end
@@ -65,16 +65,17 @@ class DowntimeTest < ActiveSupport::TestCase
65
65
 
66
66
  context "publicising downtime" do
67
67
  should "start at midnight a day before it is scheduled" do
68
- Timecop.freeze(Date.today) do # beginnning of today
68
+ now = Time.zone.parse("2015-01-01")
69
+ Timecop.freeze(now) do
69
70
  downtime = FactoryGirl.build(:downtime)
70
71
 
71
- downtime.start_time = (Date.today + 1).to_time + (3 * 60 * 60) # 3am tomorrow
72
+ downtime.start_time = Time.zone.parse("2015-01-02 03:00")
72
73
  assert downtime.publicise?
73
74
 
74
- downtime.start_time = Date.today.to_time + (21 * 60 * 60) # 9pm today
75
+ downtime.start_time = Time.zone.parse("2015-01-01 21:00")
75
76
  assert downtime.publicise?
76
77
 
77
- downtime.start_time = Date.today + 2 # day after tomorrow
78
+ downtime.start_time = Time.zone.parse("2015-01-03 00:00")
78
79
  refute downtime.publicise?
79
80
  end
80
81
  end
@@ -222,6 +222,30 @@ class EditionTest < ActiveSupport::TestCase
222
222
  assert_equal new_edition.whole_body, edition.whole_body
223
223
  end
224
224
 
225
+ test "Cloning from LicenceEdition into AnswerEdition" do
226
+ edition = FactoryGirl.create(
227
+ :licence_edition,
228
+ state: "published",
229
+ panopticon_id: @artefact.id,
230
+ version_number: 1,
231
+ department: "Test dept",
232
+ licence_overview: "I am a test overview",
233
+ licence_identifier: "Test identifier",
234
+ licence_short_description: "I am a test short description",
235
+ will_continue_on: "test will continue on",
236
+ continuation_link: "https://github.com/alphagov/"
237
+ )
238
+ new_edition = edition.build_clone AnswerEdition
239
+
240
+ assert_equal AnswerEdition, new_edition.class
241
+ assert_equal 2, new_edition.version_number
242
+ assert_equal @artefact.id.to_s, new_edition.panopticon_id
243
+ assert_equal "draft", new_edition.state
244
+ assert_equal "Test dept", new_edition.department
245
+ assert_equal "I am a test overview", new_edition.overview
246
+ assert_equal edition.whole_body, new_edition.body
247
+ end
248
+
225
249
  test "Cloning from ProgrammeEdition into AnswerEdition" do
226
250
  edition = FactoryGirl.create(
227
251
  :programme_edition,
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.9.0
4
+ version: 28.10.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -478,7 +478,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
478
478
  version: '0'
479
479
  segments:
480
480
  - 0
481
- hash: 1058733526370502898
481
+ hash: -2559664419333283544
482
482
  required_rubygems_version: !ruby/object:Gem::Requirement
483
483
  none: false
484
484
  requirements:
@@ -487,7 +487,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
487
487
  version: '0'
488
488
  segments:
489
489
  - 0
490
- hash: 1058733526370502898
490
+ hash: -2559664419333283544
491
491
  requirements: []
492
492
  rubyforge_project:
493
493
  rubygems_version: 1.8.23