Permalink
Browse files

Change notes should display published_at not first_published_at.

  • Loading branch information...
1 parent 1bda4ff commit 007eac6339aed4efa16c01d9028145385e3ac5da @floehopper floehopper committed Feb 2, 2012
@@ -24,7 +24,7 @@ def unpublished_edition
end
def editions_ever_published
- documents.where(state: [:published, :archived]).by_first_published_at
+ documents.where(state: [:published, :archived]).by_published_at
end
def update_slug_if_possible(new_title)
@@ -13,7 +13,7 @@
<ul>
<% @policy.editions_ever_published.each do |edition| %>
<li class="group">
- <%= time_ago(edition.first_published_at, class: 'first_published_at') %>
+ <%= time_ago(edition.published_at, class: 'published_at') %>
<p><%= edition.change_note %></p>
</li>
<% end %>
@@ -301,4 +301,21 @@ class PoliciesControllerTest < ActionController::TestCase
get :show, id: policy.document_identity
refute_select_policy_section_list
end
+
+ test "show displays change history for policy in reverse chronological order" do
+ editions = []
+ editions << create(:published_policy, change_note: "Third edition.", published_at: 1.month.ago)
+ document_identity = editions.first.document_identity
+ editions << create(:archived_policy, change_note: "Second edition.", document_identity: document_identity, published_at: 2.months.ago)
+ editions << create(:archived_policy, change_note: "First published.", document_identity: document_identity, published_at: 3.months.ago)
+
+ get :show, id: document_identity
+
+ assert_select ".policy .change_notes li" do |list_items|
+ list_items.each_with_index do |list_item, index|
+ assert_select list_item, ".published_at[title='#{editions[index].published_at.iso8601}']"
+ assert_select list_item, "p", text: editions[index].change_note
+ end
+ end
+ end
end
@@ -751,11 +751,11 @@ class DocumentTest < ActiveSupport::TestCase
new_edition.publish_as(create(:departmental_editor), force: true)
end
- test "should provide a list of all editions ever published in reverse chronological order by first publication date" do
- original_edition = create(:archived_document, first_published_at: 3.days.ago)
+ test "should provide a list of all editions ever published in reverse chronological order by publication date" do
+ original_edition = create(:archived_document, published_at: 3.days.ago)
document_identity = original_edition.document_identity
- new_edition_1 = create(:archived_document, document_identity: document_identity, first_published_at: 2.days.ago)
- new_edition_2 = create(:published_document, document_identity: document_identity, first_published_at: 1.day.ago)
+ new_edition_1 = create(:archived_document, document_identity: document_identity, published_at: 2.days.ago)
+ new_edition_2 = create(:published_document, document_identity: document_identity, published_at: 1.day.ago)
draft_edition = create(:draft_document, document_identity: document_identity)
assert_equal [new_edition_2, new_edition_1, original_edition], new_edition_2.editions_ever_published

0 comments on commit 007eac6

Please sign in to comment.