diff --git a/app/views/content_items/_content_item.html.erb b/app/views/content_items/_content_item.html.erb
index 0cec05dda..8c4f23cff 100644
--- a/app/views/content_items/_content_item.html.erb
+++ b/app/views/content_items/_content_item.html.erb
@@ -7,5 +7,11 @@
<% end %>
<%= content_item.document_type %> |
<%= content_item.unique_page_views %> |
- <%= time_ago_in_words(content_item.public_updated_at) %> ago |
+
+ <% if content_item.public_updated_at %>
+ <%= time_ago_in_words(content_item.public_updated_at) %> ago
+ <% else %>
+ Never
+ <% end %>
+ |
diff --git a/app/views/content_items/show.html.erb b/app/views/content_items/show.html.erb
index c5d2b3b21..9cdf43f0f 100644
--- a/app/views/content_items/show.html.erb
+++ b/app/views/content_items/show.html.erb
@@ -26,7 +26,13 @@
Last updated |
- <%= time_ago_in_words(@content_item.public_updated_at) %> ago |
+
+ <% if @content_item.public_updated_at %>
+ <%= time_ago_in_words(@content_item.public_updated_at) %> ago
+ <% else %>
+ Never
+ <% end %>
+ |
Organisation |
diff --git a/spec/views/content_items/index.html.erb_spec.rb b/spec/views/content_items/index.html.erb_spec.rb
index 87138f929..97d20161b 100644
--- a/spec/views/content_items/index.html.erb_spec.rb
+++ b/spec/views/content_items/index.html.erb_spec.rb
@@ -31,6 +31,15 @@
expect(rendered).to have_selector('table tbody tr', count: 2)
end
+ context 'items that have never been published' do
+ it 'renders for no last updated value' do
+ content_items[0].public_updated_at = nil
+ render
+
+ expect(rendered).to have_selector('table tr td:nth(5)', text: 'Never')
+ end
+ end
+
describe 'row content' do
it 'items depict the Organisations they each belong to' do
content_items[0].organisations.build(title: 'An organisation', slug: 'organisation-slug ')
@@ -114,6 +123,15 @@
expect(rendered).to have_link('Last Updated', href: href)
end
+
+ context 'items that have never been published' do
+ it 'renders for no last updated value' do
+ content_items[0].public_updated_at = nil
+ render
+
+ expect(rendered).to have_selector('table tr td:nth(4)', text: 'Never')
+ end
+ end
end
end
end
diff --git a/spec/views/content_items/show.html.erb_spec.rb b/spec/views/content_items/show.html.erb_spec.rb
index e2601b468..0bb0a277c 100644
--- a/spec/views/content_items/show.html.erb_spec.rb
+++ b/spec/views/content_items/show.html.erb_spec.rb
@@ -78,5 +78,14 @@
expect(rendered).to have_selector('td', text: 'Organisation')
expect(rendered).to have_selector('td + td', text: 'An Organisation, Another Organisation')
end
+
+ context 'item has never been published' do
+ it 'renders for no last updated value' do
+ content_item.public_updated_at = nil
+ render
+
+ expect(rendered).to have_selector('table tbody tr:nth(5) td:nth(2)', text: 'Never')
+ end
+ end
end
end